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

View File

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

View File

@ -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;
};
}];
})

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")
ref="$DEVSHELL_ROOT/#hmActivationPackages.$2.$3"
ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.home.activationPackage"
if [[ "$4" == "switch" ]]; then
nix build "$ref" && result/activate &&

View File

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