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

37 lines
1.3 KiB
Nix
Raw Normal View History

2023-05-22 01:06:42 +00:00
{ withSystem, lib, inputs, ... }: {
2023-05-22 02:08:50 +00:00
flake = withSystem "x86_64-linux" ({ pkgs, ... }:
2023-05-22 01:06:42 +00:00
let
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
inputs.emanote.homeManagerModule
inputs.nix-index-database.hmModules.nix-index
];
});
buildModesForHost = host: modes:
(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;
});
in {
homeConfigurations =
lib.mapAttrs (_: buildHomeManager) (flattenAttrs machines);
homeModes =
lib.mapAttrs buildModesForHost { inherit (machines) zeus apollo; };
2023-02-03 05:37:18 +00:00
});
}