diff --git a/SwarselSystems.org b/SwarselSystems.org index 485dd31..0183536 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -158,6 +158,7 @@ In =outputs = inputs@ [...]=, the =inputs@= makes it so that all inputs are auto in { <> + nixosConfigurations = <> homeConfigurations = @@ -166,6 +167,7 @@ In =outputs = inputs@ [...]=, the =inputs@= makes it so that all inputs are auto <> nixOnDroidConfigurations = <> + topology = <> }; @@ -302,26 +304,15 @@ When setting this option normally, the password would normally be written world- :CUSTOM_ID: h:df0072bc-853f-438f-bd85-bfc869501015 :END: -Here I define a few variables that I need for my system specifications. First and foremost, =pkgs=, which gets passed the emacs-overlay, nur, and nixgl modules to it. With this, I can grab all these packages by referencing =pkgs.= instead of having to put e.g. =nixgl.auto.nixGLDefault=. - -The interesting part is in the start: -- first, I define =pkgsFor=. This function reads all available systems from nixpkgs and generates pkgs for them. -- next, =forEachSystem= is a function that can be called to declare an output for each such defined system. -- =forAllSystems= is a crude function that I use for expressions that depend on =system=, as the prior two attributes already consumed it at that stage. This is only really used to generate the checks in their own file. -- =mkFullHost= is a function that takes a hostname as well as a boolean whether it is NixOS or not, and returns a matching =nixosSystem= or =darwinSystem=. This function is only used for systems that can use both NixOS and home-manager options (darwin still counts here as it can use some NixOS options). -- =mkFullHostConfigs= is the function that dynamically creates all definded hosts. The hosts are defined by placing a directory in =hosts/= under either the =nixos/= or =darwin/= directory. These directories are being read by =readHosts= and delivered to this funtion in the later call in [[#h:9c9b9e3b-8771-44fa-ba9e-5056ae809655][nixosConfigurations]] or [[#h:f881aa05-a670-48dd-a57b-2916abdcb692][darwinConfigurations]]. +Here I define a few variables that I need for my system specifications. There used to be more here, but I managed to optimize my configuration, and only two things remain: +- =outputs=, which is needed for =lib= +- =lib=: This exposes a common =lib= for NixOS and home-manager that is extended by my own personal =lib= functions. #+begin_src nix :tangle no :noweb-ref flakelet inherit (self) outputs; lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; }); - - - # Home-Manager modules wanted on non-NixOS systems - - # Home-Manager modules wanted on both NixOS and non-NixOS systems - #+end_src ** General (outputs) :PROPERTIES: @@ -4378,9 +4369,13 @@ This section defines all functions of my own that I add to =lib=. These are used A breakdown of each function: -TODO +The interesting part is in the start: +- first, I define =pkgsFor=. This function reads all available systems from nixpkgs and generates pkgs for them. +- next, =forEachSystem= is a function that can be called to declare an output for each such defined system. +- =forAllSystems= is a crude function that I use for expressions that depend on =system=, as the prior two attributes already consumed it at that stage. This is only really used to generate the checks in their own file. +- =mkFullHostConfigs= is the function that dynamically creates all definded hosts. The hosts are defined by placing a directory in =hosts/= under either the =nixos/= or =darwin/= directory. These directories are being read by =readHosts= and delivered to this funtion in the later call in [[#h:9c9b9e3b-8771-44fa-ba9e-5056ae809655][nixosConfigurations]] or [[#h:f881aa05-a670-48dd-a57b-2916abdcb692][darwinConfigurations]]. - =mkFullHost=: - This function is used in mkFullHostConfigs. It basically dynamically creates a nixosConfiguration host, setting its =speciaArgs= and =modules= attributes. The modules are populated based on whether this is a NixOS or darwin host. For the latter, I will only ever use machines that I get for testing from work, and for these my username is different, so I implemented an if-condition for it. This could be done more cleanly using variables, but some care needs to be taken with the home-manager imports and this approach works, so for now this is fine. Thanks to this function, the import sections of the host configs are pretty clean for most hosts. + This is a function that takes a hostname as well as a boolean whether it is NixOS or not, and returns a matching =nixosSystem= or =darwinSystem=. This function is only used for systems that can use both NixOS and home-manager options (darwin still counts here as it can use some NixOS options). This is used in mkFullHostConfigs. In more detail, it dynamically creates a nixosConfiguration host, setting its =speciaArgs= and =modules= attributes. The modules are populated based on whether this is a NixOS or darwin host. For the latter, I will only ever use machines that I get for testing from work, and for these my username is different, so I implemented an if-condition for it. This could be done more cleanly using variables, but some care needs to be taken with the home-manager imports and this approach works, so for now this is fine. Thanks to this function, the import sections of the host configs are pretty clean for most hosts. =lib.optionals= evaluates to an empty list (=[]=) in case that the conditional is not met. TODO @@ -4428,11 +4423,11 @@ TODO ] ++ (if (host == "toto" || host == "iso") then [ ] else ([ - # put inports here that are for all servers and normal hosts + # put nixos imports here that are for all servers and normal hosts inputs.nix-topology.nixosModules.default ] ++ (if (host == "winters" || host == "sync") then [ ] else [ - # put imports here that are for all normal hosts + # put nixos imports here that are for all normal hosts "${self}/profiles/${type}/common" inputs.stylix.nixosModules.stylix inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm @@ -4441,20 +4436,22 @@ TODO { home-manager.users.swarsel.imports = ( if (host == "winters" || host == "sync") then [ ] else [ - # put imports here that are for all normal hosts + # put home-manager imports here that are for all normal hosts "${self}/profiles/home/common" ] ) ++ [ - # put inports here that are for all servers and normal hosts + # put home-manager imports here that are for all servers and normal hosts inputs.sops-nix.homeManagerModules.sops inputs.nix-index-database.hmModules.nix-index ] ++ (builtins.attrValues outputs.homeModules); } ] else [ + # put nixos imports here that are for darwin hosts "${self}/profiles/darwin/nixos/common" inputs.home-manager.darwinModules.home-manager { home-manager.users."leon.schwarzaeugl".imports = [ + # put home-manager imports here that are for darwin hosts "${self}/profiles/darwin/home" ] ++ (builtins.attrValues outputs.homeModules); } diff --git a/flake.lock b/flake.lock index 383decf..e65ae7a 100644 --- a/flake.lock +++ b/flake.lock @@ -255,7 +255,6 @@ } }, "flake-compat_6": { - "flake": false, "locked": { "lastModified": 1733328505, "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", @@ -474,11 +473,11 @@ ] }, "locked": { - "lastModified": 1735882644, - "narHash": "sha256-3FZAG+pGt3OElQjesCAWeMkQ7C/nB1oTHLRQ8ceP110=", + "lastModified": 1737465171, + "narHash": "sha256-R10v2hoJRLq8jcL4syVFag7nIGE7m13qO48wRIukWNg=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "a5a961387e75ae44cc20f0a57ae463da5e959656", + "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", "type": "github" }, "original": { @@ -640,11 +639,11 @@ ] }, "locked": { - "lastModified": 1737630279, - "narHash": "sha256-wJQCxyMRc4P26zDrHmZiRD5bbfcJpqPG3e2djdGG3pk=", + "lastModified": 1740347597, + "narHash": "sha256-st5q9egkPGz8TUcVVlIQX7y6G3AzHob+6M963bwVq74=", "owner": "nix-community", "repo": "home-manager", - "rev": "0db5c8bfcce78583ebbde0b2abbc95ad93445f7c", + "rev": "12e26a74e5eb1a31e13daaa08858689e25ebd449", "type": "github" }, "original": { @@ -1168,11 +1167,11 @@ }, "nixpkgs_9": { "locked": { - "lastModified": 1736798957, - "narHash": "sha256-qwpCtZhSsSNQtK4xYGzMiyEDhkNzOCz/Vfu4oL2ETsQ=", + "lastModified": 1740367490, + "narHash": "sha256-WGaHVAjcrv+Cun7zPlI41SerRtfknGQap281+AakSAw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9abb87b552b7f55ac8916b6fc9e5cb486656a2f3", + "rev": "0196c0175e9191c474c26ab5548db27ef5d34b05", "type": "github" }, "original": { @@ -1285,11 +1284,11 @@ "treefmt-nix": "treefmt-nix_2" }, "locked": { - "lastModified": 1739903703, - "narHash": "sha256-w2tTcjx39lJoPDaFbIxi+INIjAKE0jbIx9TNjj9ghmg=", + "lastModified": 1740408283, + "narHash": "sha256-2xECnhgF3MU9YjmvOkrRp8wRFo2OjjewgCtlfckhL5s=", "owner": "nix-community", "repo": "NUR", - "rev": "2215ad5c4347f522523715e809f5f2022509f504", + "rev": "496a4a11162bdffb9a7b258942de138873f019f7", "type": "github" }, "original": { @@ -1500,11 +1499,11 @@ "tinted-zed": "tinted-zed" }, "locked": { - "lastModified": 1740241659, - "narHash": "sha256-2CXyPERfW6rm9R7nV73orfEsuqMlP/LoAfMUBK4s2jE=", + "lastModified": 1740520441, + "narHash": "sha256-CWK3L7i7YqubbcrdS/5D/+Vo+IuClrNR+5B+ByhBlEo=", "owner": "danth", "repo": "stylix", - "rev": "3a686a20b8f4dc026e561c1c5a85671c8cfeeb4f", + "rev": "a98c363a58accad047a2580382d90433619a08e0", "type": "github" }, "original": { @@ -1610,11 +1609,11 @@ "tinted-schemes": { "flake": false, "locked": { - "lastModified": 1737565458, - "narHash": "sha256-y+9cvOA6BLKT0WfebDsyUpUa/YxKow9hTjBp6HpQv68=", + "lastModified": 1740351358, + "narHash": "sha256-Hdk850xgAd3DL8KX0AbyU7tC834d3Lej1jOo3duWiOA=", "owner": "tinted-theming", "repo": "schemes", - "rev": "ae31625ba47aeaa4bf6a98cf11a8d4886f9463d9", + "rev": "a1bc2bd89e693e7e3f5764cfe8114e2ae150e184", "type": "github" }, "original": { @@ -1626,11 +1625,11 @@ "tinted-tmux": { "flake": false, "locked": { - "lastModified": 1735737224, - "narHash": "sha256-FO2hRBkZsjlIRqzNHCPc/52yxg11kHGA8MEtSun9RwE=", + "lastModified": 1740272597, + "narHash": "sha256-/etfUV3HzAaLW3RSJVwUaW8ULbMn3v6wbTlXSKbcoWQ=", "owner": "tinted-theming", "repo": "tinted-tmux", - "rev": "aead506a9930c717ebf81cc83a2126e9ca08fa64", + "rev": "b6c7f46c8718cc484f2db8b485b06e2a98304cd0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 9732ef6..04108b3 100644 --- a/flake.nix +++ b/flake.nix @@ -90,12 +90,6 @@ inherit (self) outputs; lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; }); - - - # Home-Manager modules wanted on non-NixOS systems - - # Home-Manager modules wanted on both NixOS and non-NixOS systems - in { @@ -157,6 +151,7 @@ import ./checks { inherit self inputs system pkgs; } ); + nixosConfigurations = lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") "nixos"; homeConfigurations = @@ -183,6 +178,7 @@ lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "android") "android" lib.swarselsystems.pkgsFor.aarch64-linux; + topology = lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology { diff --git a/lib/default.nix b/lib/default.nix index 29c28cf..8410cdc 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -41,11 +41,11 @@ ] ++ (if (host == "toto" || host == "iso") then [ ] else ([ - # put inports here that are for all servers and normal hosts + # put nixos imports here that are for all servers and normal hosts inputs.nix-topology.nixosModules.default ] ++ (if (host == "winters" || host == "sync") then [ ] else [ - # put imports here that are for all normal hosts + # put nixos imports here that are for all normal hosts "${self}/profiles/${type}/common" inputs.stylix.nixosModules.stylix inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm @@ -54,20 +54,22 @@ { home-manager.users.swarsel.imports = ( if (host == "winters" || host == "sync") then [ ] else [ - # put imports here that are for all normal hosts + # put home-manager imports here that are for all normal hosts "${self}/profiles/home/common" ] ) ++ [ - # put inports here that are for all servers and normal hosts + # put home-manager imports here that are for all servers and normal hosts inputs.sops-nix.homeManagerModules.sops inputs.nix-index-database.hmModules.nix-index ] ++ (builtins.attrValues outputs.homeModules); } ] else [ + # put nixos imports here that are for darwin hosts "${self}/profiles/darwin/nixos/common" inputs.home-manager.darwinModules.home-manager { home-manager.users."leon.schwarzaeugl".imports = [ + # put home-manager imports here that are for darwin hosts "${self}/profiles/darwin/home" ] ++ (builtins.attrValues outputs.homeModules); }