1
0
Fork 0
nixos-config/home-manager/flake-module.nix

51 lines
1.3 KiB
Nix
Raw Normal View History

2023-02-03 05:37:18 +00:00
{
withSystem,
lib,
inputs,
...
}: {
2023-02-11 14:14:51 +00:00
flake = withSystem "x86_64-linux" ({
self',
pkgs,
...
}: let
2023-02-03 05:37:18 +00:00
flattenAttrs = attrs:
lib.listToAttrs (lib.flatten (lib.mapAttrsToList
(
outer_key:
lib.mapAttrsToList
(inner_key: value: {
name = "${outer_key}-${inner_key}";
inherit value;
})
)
attrs));
machines = import ./machines.nix;
buildHomeManager = config: (inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
config
2023-02-04 00:43:09 +00:00
inputs.emanote.homeManagerModule
2023-03-07 23:45:49 +00:00
inputs.impermanence.nixosModules.home-manager.impermanence
2023-02-03 05:37:18 +00:00
];
});
buildModesForHost = host: modes:
2023-03-06 16:26:46 +00:00
(pkgs.recursiveLinkFarm "${host}-modes"
(lib.mapAttrs
(_: config: (buildHomeManager config).activationPackage)
modes))
.overrideAttrs (old: {
buildCommand =
if inputs.self.sourceInfo ? rev
then ''
${old.buildCommand}
echo ${inputs.self.sourceInfo.rev} > $out/config-commit;
''
else old.buildCommand;
});
2023-02-03 05:37:18 +00:00
in {
homeConfigurations = lib.mapAttrs (_: buildHomeManager) (flattenAttrs machines);
2023-02-27 20:30:00 +00:00
homeModes = lib.mapAttrs buildModesForHost {inherit (machines) zeus apollo;};
2023-02-03 05:37:18 +00:00
});
}