export homeConfigurations for all user@host pairs and add better home-manager only defaults

This commit is contained in:
Pacman99 2021-03-23 07:37:11 -07:00
parent cc52cd9fa2
commit dc9d9877b8
7 changed files with 36 additions and 18 deletions

View file

@ -47,6 +47,8 @@
}); });
}); });
homeConfigurations = os.mkHomeConfigurations;
nixosModules = nixosModules =
let moduleList = import ./modules/module-list.nix; let moduleList = import ./modules/module-list.nix;
in lib.pathsToImportedAttrs moduleList; in lib.pathsToImportedAttrs moduleList;
@ -86,9 +88,6 @@
devShell = import ./shell { devShell = import ./shell {
inherit self system; inherit self system;
}; };
legacyPackages.hmActivationPackages =
os.mkHomeActivation;
} }
); );
in in

View file

@ -19,7 +19,7 @@
devosSystem = dev.callLibs ./devosSystem.nix; devosSystem = dev.callLibs ./devosSystem.nix;
mkHomeActivation = dev.callLibs ./mkHomeActivation.nix; mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix;
mkPackages = dev.callLibs ./mkPackages.nix; mkPackages = dev.callLibs ./mkPackages.nix;
} }

View file

@ -73,10 +73,29 @@ lib.nixosSystem (args // {
}) })
]; ];
})).config; })).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 in
moduleList ++ [{ moduleList ++ [{
system.build = { system.build = {
iso = isoConfig.system.build.isoImage; iso = isoConfig.system.build.isoImage;
homes = hmConfig.home-manager.users;
}; };
}]; }];
}) })

View file

@ -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

View file

@ -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)

View file

@ -81,7 +81,7 @@ case "$1" in
;; ;;
"home") "home")
ref="$DEVSHELL_ROOT/#hmActivationPackages.$2.$3" ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.home.activationPackage"
if [[ "$4" == "switch" ]]; then if [[ "$4" == "switch" ]]; then
nix build "$ref" && result/activate && nix build "$ref" && result/activate &&

View file

@ -42,7 +42,7 @@ flk home NixOS nixos switch
### Manually from outside the project: ### Manually from outside the project:
```sh ```sh
# build # build
nix build "github:divnix/devos#hmActivationPackages.NixOS.nixos" nix build "github:divnix/devos#homeConfigurations.nixos@NixOS.home.activationPackage"
# activate # activate
./result/activate && unlink result ./result/activate && unlink result