From 7f3aaed6ed30becd330fc00c5a33ded0fd1f043c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Fri, 21 Mar 2025 16:21:13 +0100 Subject: [PATCH 1/2] refactor: don't include the whole modules Instead only import the nixos/hm/nixvim module. This _should_ reduce rebuilds. --- example-vm/default.nix | 40 +++++++++++++++++ .../default.nix => example-vm/vm-config.nix | 43 +++++++++--------- flake-modules/example-vm.nix | 44 ++----------------- flake-modules/home-modules.nix | 5 +-- flake-modules/nixos-modules.nix | 18 +------- flake-modules/nixvim-modules.nix | 15 ++++--- 6 files changed, 78 insertions(+), 87 deletions(-) create mode 100644 example-vm/default.nix rename machines/vm/default.nix => example-vm/vm-config.nix (50%) diff --git a/example-vm/default.nix b/example-vm/default.nix new file mode 100644 index 0000000..305f847 --- /dev/null +++ b/example-vm/default.nix @@ -0,0 +1,40 @@ +{ + import = [ ./vm_config.nix ]; + + time.timeZone = "Europe/Berlin"; + i18n.defaultLocale = "en_US.UTF-8"; + users.users.jdoe = { + password = "example"; + isNormalUser = true; + extraGroups = [ + "wheel" + "video" + "networkmanager" + ]; + }; + home-manager.users.jdoe = { + home = { + username = "jdoe"; + homeDirectory = "/home/jdoe"; + }; + jhome = { + enable = true; + gui.enable = true; + dev = { + enable = true; + rust.enable = true; + }; + }; + }; + + # password is 'test' see module documentation for more options + services.jupyter.password = "'sha1:1b961dc713fb:88483270a63e57d18d43cf337e629539de1436ba'"; + jconfig = { + enable = true; + dev = { + enable = true; + jupyter.enable = true; + }; + gui.enable = true; + }; +} diff --git a/machines/vm/default.nix b/example-vm/vm-config.nix similarity index 50% rename from machines/vm/default.nix rename to example-vm/vm-config.nix index ced0faa..1b2b4d0 100644 --- a/machines/vm/default.nix +++ b/example-vm/vm-config.nix @@ -1,31 +1,34 @@ +## Default QEMU guest config { - services.qemuGuest.enable = true; + services = { + qemuGuest.enable = true; + openssh.enable = true; + }; - boot.initrd.availableKernelModules = [ - "xhci_pci" - "ehci_pci" - "ahci" - "usbhid" - "usb_storage" - "sd_mod" - "virtio_balloon" - "virtio_blk" - "virtio_pci" - "virtio_ring" - # "virtio_vga" - "virtio_gpu" - ]; + boot = { + loader.systemd-boot.enable = true; + initrd.availableKernelModules = [ + "xhci_pci" + "ehci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + "virtio_balloon" + "virtio_blk" + "virtio_pci" + "virtio_ring" + # "virtio_vga" + "virtio_gpu" + ]; + }; fileSystems."/".device = "/dev/disk/by-label/nixos"; - boot.loader.systemd-boot.enable = true; - - services.openssh.enable = true; - # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave # this value at the release version of the first install of this system. # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "22.11"; # Did you read the comment? + system.stateVersion = "24.11"; # Did you read the comment? } diff --git a/flake-modules/example-vm.nix b/flake-modules/example-vm.nix index a8ce4b3..d6b88de 100644 --- a/flake-modules/example-vm.nix +++ b/flake-modules/example-vm.nix @@ -8,47 +8,11 @@ in { # Example vm configuration flake.nixosConfigurations.vm = lib.nixosSystem { - inherit system pkgs; + inherit pkgs; modules = [ - inputs.self.nixosModules.vm # import vm module - { - time.timeZone = "Europe/Berlin"; - i18n.defaultLocale = "en_US.UTF-8"; - users.users.jdoe = { - password = "example"; - isNormalUser = true; - extraGroups = [ - "wheel" - "video" - "networkmanager" - ]; - }; - home-manager.users.jdoe = { - home = { - username = "jdoe"; - homeDirectory = "/home/jdoe"; - }; - jhome = { - enable = true; - gui.enable = true; - dev = { - enable = true; - rust.enable = true; - }; - }; - }; - nix.registry.nixpkgs.flake = inputs.nixpkgs; - # password is 'test' see module documentation for more options - services.jupyter.password = "'sha1:1b961dc713fb:88483270a63e57d18d43cf337e629539de1436ba'"; - jconfig = { - enable = true; - dev = { - enable = true; - jupyter.enable = true; - }; - gui.enable = true; - }; - } + inputs.self.nixosModules.default + ../example-vm # import vm configuration + { nix.registry.nixpkgs.flake = inputs.nixpkgs; } ]; }; diff --git a/flake-modules/home-modules.nix b/flake-modules/home-modules.nix index 8d8ca71..54e348b 100644 --- a/flake-modules/home-modules.nix +++ b/flake-modules/home-modules.nix @@ -1,7 +1,4 @@ { self, inputs, ... }: -let - modules = ../modules; -in { # FIXME(25.05): this version of HM should have the flake module # imports = [ inputs.home-manager.flakeModules.home-manager ]; @@ -11,7 +8,7 @@ in defaultModules = [ inputs.nixvim.homeManagerModules.nixvim self.nixvimModules.homeManager - (modules + "/hm") + ../module/hm ]; nixos = { imports = defaultModules; diff --git a/flake-modules/nixos-modules.nix b/flake-modules/nixos-modules.nix index 41bd64f..ef8355e 100644 --- a/flake-modules/nixos-modules.nix +++ b/flake-modules/nixos-modules.nix @@ -4,9 +4,6 @@ lib, ... }: -let - modules = ../modules; -in { flake.nixosModules = let @@ -14,7 +11,7 @@ in imports = [ inputs.stylix.nixosModules.stylix inputs.home-manager.nixosModules.home-manager - (modules + "/nixos") + ../modules/nixos ] ++ lib.optional (inputs.lix-module != null) inputs.lix-module.nixosModules.default; home-manager = { useGlobalPkgs = true; @@ -24,20 +21,9 @@ in # Pin nixpkgs nix.registry.nixpkgs.flake = inputs.nixpkgs; }; - - machines = [ "vm" ]; - mkMachine = hostname: { - imports = [ - nixosModule - (import (../machines + "/${hostname}")) - ]; - home-manager.sharedModules = [ { jhome.hostName = hostname; } ]; - }; - machineModules = lib.genAttrs machines mkMachine; in { default = nixosModule; inherit nixosModule; - } - // machineModules; + }; } diff --git a/flake-modules/nixvim-modules.nix b/flake-modules/nixvim-modules.nix index 9841d46..1f8a395 100644 --- a/flake-modules/nixvim-modules.nix +++ b/flake-modules/nixvim-modules.nix @@ -1,7 +1,4 @@ { self, inputs, ... }: -let - modules = ../modules; -in { imports = [ inputs.nixvim.flakeModules.default ]; @@ -10,10 +7,14 @@ in checks.enable = false; # FIXME: borked due to nix-community/nixvim#3074 }; - flake.nixvimModules = { - standalone = modules + "/nixvim/standalone.nix"; - homeManager = modules + "/nixvim"; - }; + flake.nixvimModules = + let + module = ../modules/nixvim; + in + { + standalone = "${module}/standalone.nix"; + homeManager = module; + }; perSystem = { system, ... }: -- 2.48.1 From 63f9776a318948fa1d9ed2508b026f74dc484211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 16 Mar 2025 22:25:58 +0100 Subject: [PATCH 2/2] wip: niri take 2 [skip-ci] Take two, since one wasn't enough. --- flake-modules/nixos-modules.nix | 1 + flake.lock | 62 +++++++++++++++++++++++++++++++++ flake.nix | 11 ++++++ 3 files changed, 74 insertions(+) diff --git a/flake-modules/nixos-modules.nix b/flake-modules/nixos-modules.nix index ef8355e..44ec630 100644 --- a/flake-modules/nixos-modules.nix +++ b/flake-modules/nixos-modules.nix @@ -9,6 +9,7 @@ let nixosModule = { imports = [ + inputs.niri.nixosModules.niri inputs.stylix.nixosModules.stylix inputs.home-manager.nixosModules.home-manager ../modules/nixos diff --git a/flake.lock b/flake.lock index 84b6b4f..ba3e58a 100644 --- a/flake.lock +++ b/flake.lock @@ -275,6 +275,50 @@ "url": "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0.tar.gz" } }, + "niri": { + "inputs": { + "niri-stable": "niri-stable", + "niri-unstable": [], + "nixpkgs": [ + "unstable" + ], + "nixpkgs-stable": [ + "nixpkgs" + ], + "xwayland-satellite-stable": "xwayland-satellite-stable", + "xwayland-satellite-unstable": [] + }, + "locked": { + "lastModified": 1742108116, + "narHash": "sha256-NrV9ysEfSbeRUPo0jdCBeesuNLTVrpHGXg40snH1YGE=", + "owner": "sodiboo", + "repo": "niri-flake", + "rev": "824f10012de455a1d0ef795a605f28948ee10467", + "type": "github" + }, + "original": { + "owner": "sodiboo", + "repo": "niri-flake", + "type": "github" + } + }, + "niri-stable": { + "flake": false, + "locked": { + "lastModified": 1740117926, + "narHash": "sha256-mTTHA0RAaQcdYe+9A3Jx77cmmyLFHmRoZdd8RpWa+m8=", + "owner": "YaLTeR", + "repo": "niri", + "rev": "b94a5db8790339cf9134873d8b490be69e02ac71", + "type": "github" + }, + "original": { + "owner": "YaLTeR", + "ref": "v25.02", + "repo": "niri", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1742388435, @@ -334,6 +378,7 @@ "flake-parts": "flake-parts", "home-manager": "home-manager", "lix-module": "lix-module", + "niri": "niri", "nixpkgs": "nixpkgs", "nixvim": "nixvim", "stylix": "stylix", @@ -471,6 +516,23 @@ "repo": "treefmt-nix", "type": "github" } + }, + "xwayland-satellite-stable": { + "flake": false, + "locked": { + "lastModified": 1739246919, + "narHash": "sha256-/hBM43/Gd0/tW+egrhlWgOIISeJxEs2uAOIYVpfDKeU=", + "owner": "Supreeeme", + "repo": "xwayland-satellite", + "rev": "44590a416d4a3e8220e19e29e0b6efe64a80315d", + "type": "github" + }, + "original": { + "owner": "Supreeeme", + "ref": "v0.5.1", + "repo": "xwayland-satellite", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8c9a20b..6f6c265 100644 --- a/flake.nix +++ b/flake.nix @@ -43,6 +43,17 @@ nuschtosSearch.follows = ""; }; }; + niri = { + url = "github:sodiboo/niri-flake"; + inputs = { + # Deduplicate + nixpkgs.follows = "unstable"; + nixpkgs-stable.follows = "nixpkgs"; + # Unused + niri-unstable.follows = ""; + xwayland-satellite-unstable.follows = ""; + }; + }; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; -- 2.48.1