From b67abcce27eaab6cd49dddbb4ea65925571bca3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Schwarz=C3=A4ugl?= Date: Wed, 26 Feb 2025 00:42:24 +0100 Subject: [PATCH] chore: make dynamic import usage clearer --- SwarselSystems.org | 63 ++++++++++++++++++++++++---------------------- lib/default.nix | 63 ++++++++++++++++++++++++---------------------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/SwarselSystems.org b/SwarselSystems.org index 0b2d00f..485dd31 100644 --- a/SwarselSystems.org +++ b/SwarselSystems.org @@ -4419,43 +4419,46 @@ TODO systemFunc { specialArgs = { inherit inputs outputs lib self; }; modules = [ + # put inports here that are for all hosts inputs.disko.nixosModules.disko inputs.sops-nix.nixosModules.sops inputs.impermanence.nixosModules.impermanence inputs.lanzaboote.nixosModules.lanzaboote "${self}/hosts/${type}/${host}" ] ++ - # toto (deployment sandbox) & iso should never receive general configuration (if (host == "toto" || host == "iso") then [ ] else - ( - # sync & winters (servers) should not receive common non-server config - (if (host == "winters" || host == "sync") then [ ] else [ - "${self}/profiles/${type}/common" - inputs.stylix.nixosModules.stylix - inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm - inputs.nix-topology.nixosModules.default - ]) ++ (if (type == "nixos") then [ - inputs.home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = ( - # sync & winters (servers) should not receive common non-server config - if (host == "winters" || host == "sync") then [ ] else [ - "${self}/profiles/home/common" - ] - ) ++ [ - inputs.sops-nix.homeManagerModules.sops - inputs.nix-index-database.hmModules.nix-index - ] ++ (builtins.attrValues outputs.homeModules); - } - ] else [ - "${self}/profiles/darwin/nixos/common" - inputs.home-manager.darwinModules.home-manager - { - home-manager.users."leon.schwarzaeugl".imports = [ - "${self}/profiles/darwin/home" - ] ++ (builtins.attrValues outputs.homeModules); - } - ]) ++ (builtins.attrValues outputs.nixosModules) ++ (builtins.attrValues outputs.homeModules) + ([ + # put inports 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 + "${self}/profiles/${type}/common" + inputs.stylix.nixosModules.stylix + inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm + ]) ++ (if (type == "nixos") then [ + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = ( + if (host == "winters" || host == "sync") then [ ] else [ + # put imports here that are for all normal hosts + "${self}/profiles/home/common" + ] + ) ++ [ + # put inports 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 [ + "${self}/profiles/darwin/nixos/common" + inputs.home-manager.darwinModules.home-manager + { + home-manager.users."leon.schwarzaeugl".imports = [ + "${self}/profiles/darwin/home" + ] ++ (builtins.attrValues outputs.homeModules); + } + ]) ++ (builtins.attrValues outputs.nixosModules) ++ (builtins.attrValues outputs.homeModules) )); }; }; diff --git a/lib/default.nix b/lib/default.nix index 8800dc6..29c28cf 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -32,43 +32,46 @@ systemFunc { specialArgs = { inherit inputs outputs lib self; }; modules = [ + # put inports here that are for all hosts inputs.disko.nixosModules.disko inputs.sops-nix.nixosModules.sops inputs.impermanence.nixosModules.impermanence inputs.lanzaboote.nixosModules.lanzaboote "${self}/hosts/${type}/${host}" ] ++ - # toto (deployment sandbox) & iso should never receive general configuration (if (host == "toto" || host == "iso") then [ ] else - ( - # sync & winters (servers) should not receive common non-server config - (if (host == "winters" || host == "sync") then [ ] else [ - "${self}/profiles/${type}/common" - inputs.stylix.nixosModules.stylix - inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm - inputs.nix-topology.nixosModules.default - ]) ++ (if (type == "nixos") then [ - inputs.home-manager.nixosModules.home-manager - { - home-manager.users.swarsel.imports = ( - # sync & winters (servers) should not receive common non-server config - if (host == "winters" || host == "sync") then [ ] else [ - "${self}/profiles/home/common" - ] - ) ++ [ - inputs.sops-nix.homeManagerModules.sops - inputs.nix-index-database.hmModules.nix-index - ] ++ (builtins.attrValues outputs.homeModules); - } - ] else [ - "${self}/profiles/darwin/nixos/common" - inputs.home-manager.darwinModules.home-manager - { - home-manager.users."leon.schwarzaeugl".imports = [ - "${self}/profiles/darwin/home" - ] ++ (builtins.attrValues outputs.homeModules); - } - ]) ++ (builtins.attrValues outputs.nixosModules) ++ (builtins.attrValues outputs.homeModules) + ([ + # put inports 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 + "${self}/profiles/${type}/common" + inputs.stylix.nixosModules.stylix + inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm + ]) ++ (if (type == "nixos") then [ + inputs.home-manager.nixosModules.home-manager + { + home-manager.users.swarsel.imports = ( + if (host == "winters" || host == "sync") then [ ] else [ + # put imports here that are for all normal hosts + "${self}/profiles/home/common" + ] + ) ++ [ + # put inports 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 [ + "${self}/profiles/darwin/nixos/common" + inputs.home-manager.darwinModules.home-manager + { + home-manager.users."leon.schwarzaeugl".imports = [ + "${self}/profiles/darwin/home" + ] ++ (builtins.attrValues outputs.homeModules); + } + ]) ++ (builtins.attrValues outputs.nixosModules) ++ (builtins.attrValues outputs.homeModules) )); }; };