From dc9d9877b87c4bce3d82503b1b9974c9ff5417a6 Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Tue, 23 Mar 2021 07:37:11 -0700 Subject: [PATCH] export homeConfigurations for all user@host pairs and add better home-manager only defaults --- flake.nix | 5 ++--- lib/devos/default.nix | 2 +- lib/devos/devosSystem.nix | 19 +++++++++++++++++++ lib/devos/mkHomeActivation.nix | 12 ------------ lib/devos/mkHomeConfigurations.nix | 12 ++++++++++++ shell/flk.sh | 2 +- users/README.md | 2 +- 7 files changed, 36 insertions(+), 18 deletions(-) delete mode 100644 lib/devos/mkHomeActivation.nix create mode 100644 lib/devos/mkHomeConfigurations.nix diff --git a/flake.nix b/flake.nix index 0e945c5b..082f501a 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,8 @@ }); }); + homeConfigurations = os.mkHomeConfigurations; + nixosModules = let moduleList = import ./modules/module-list.nix; in lib.pathsToImportedAttrs moduleList; @@ -86,9 +88,6 @@ devShell = import ./shell { inherit self system; }; - - legacyPackages.hmActivationPackages = - os.mkHomeActivation; } ); in diff --git a/lib/devos/default.nix b/lib/devos/default.nix index 32ce4901..bf109ba3 100644 --- a/lib/devos/default.nix +++ b/lib/devos/default.nix @@ -19,7 +19,7 @@ devosSystem = dev.callLibs ./devosSystem.nix; - mkHomeActivation = dev.callLibs ./mkHomeActivation.nix; + mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix; mkPackages = dev.callLibs ./mkPackages.nix; } diff --git a/lib/devos/devosSystem.nix b/lib/devos/devosSystem.nix index f8d08f97..82458181 100644 --- a/lib/devos/devosSystem.nix +++ b/lib/devos/devosSystem.nix @@ -73,10 +73,29 @@ lib.nixosSystem (args // { }) ]; })).config; + hmConfig = (lib.nixosSystem + (args // { + modules = moduleList ++ [ + ({ config, ... }: { + home-manager.useUserPackages = lib.mkForce false; + home-manager.sharedModules = [ + { + home.packages = config.environment.systemPackages; + home.sessionVariables = { + inherit (config.environment.sessionVariables) NIX_PATH; + }; + xdg.configFile."nix/registry.json".text = + config.environment.etc."nix/registry.json".text; + } + ]; + }) + ]; + })).config; in moduleList ++ [{ system.build = { iso = isoConfig.system.build.isoImage; + homes = hmConfig.home-manager.users; }; }]; }) diff --git a/lib/devos/mkHomeActivation.nix b/lib/devos/mkHomeActivation.nix deleted file mode 100644 index 6b7176a3..00000000 --- a/lib/devos/mkHomeActivation.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ lib, self, ... }: - -let hmConfigs = - lib.mapAttrs - (_: config: config.config.home-manager.users) - self.nixosConfigurations; -in -lib.mapAttrs - (_: x: lib.mapAttrs - (_: cfg: cfg.home.activationPackage) - x) - hmConfigs diff --git a/lib/devos/mkHomeConfigurations.nix b/lib/devos/mkHomeConfigurations.nix new file mode 100644 index 00000000..ab843938 --- /dev/null +++ b/lib/devos/mkHomeConfigurations.nix @@ -0,0 +1,12 @@ +{ lib, self, ... }: + +with lib; +let + mkHomes = host: config: + mapAttrs' (user: v: nameValuePair "${user}@${host}" v) + config.config.system.build.homes; + + hmConfigs = mapAttrs mkHomes self.nixosConfigurations; + +in +foldl recursiveUpdate {} (attrValues hmConfigs) diff --git a/shell/flk.sh b/shell/flk.sh index d22b327c..344e9d39 100755 --- a/shell/flk.sh +++ b/shell/flk.sh @@ -81,7 +81,7 @@ case "$1" in ;; "home") - ref="$DEVSHELL_ROOT/#hmActivationPackages.$2.$3" + ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.home.activationPackage" if [[ "$4" == "switch" ]]; then nix build "$ref" && result/activate && diff --git a/users/README.md b/users/README.md index c36aa3ac..7000c8e6 100644 --- a/users/README.md +++ b/users/README.md @@ -42,7 +42,7 @@ flk home NixOS nixos switch ### Manually from outside the project: ```sh # build -nix build "github:divnix/devos#hmActivationPackages.NixOS.nixos" +nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage" # activate ./result/activate && unlink result