58 lines
1.6 KiB
Nix
58 lines
1.6 KiB
Nix
{ nixpkgs, self, ... }@inputs:
|
|
|
|
let
|
|
lib = nixpkgs.lib.extend (import ../lib);
|
|
|
|
inherit (inputs.home-manager.lib) homeManagerConfiguration;
|
|
inherit (nixpkgs.lib) nixosSystem;
|
|
inherit (lib.strings) optionalString;
|
|
inherit (lib.attrsets) nameValuePair;
|
|
in
|
|
rec {
|
|
toPartialNixosConfig =
|
|
{ hostname, system }:
|
|
nameValuePair
|
|
hostname
|
|
(nixosSystem {
|
|
inherit system;
|
|
specialArgs = { inherit inputs lib self; };
|
|
modules = [
|
|
../hosts/${hostname}/hardware-configuration.nix
|
|
../hosts/${hostname}/configuration.nix
|
|
inputs.home-manager.nixosModules.default
|
|
];
|
|
});
|
|
compileSystems =
|
|
systems:
|
|
lib.right
|
|
builtins.listToAttrs
|
|
(map toPartialNixosConfig)
|
|
systems;
|
|
|
|
toPartialHomeManagerConfig =
|
|
{ user, system, hostname ? "", configHostname ? "" }:
|
|
let
|
|
configHost = if builtins.stringLength configHostname > 0 then configHostname else hostname;
|
|
hostStr = optionalString (builtins.stringLength hostname > 0) "@${hostname}";
|
|
in
|
|
assert lib.assertMsg (builtins.stringLength configHost > 0) "either configHostname or hostname need to exist";
|
|
nameValuePair
|
|
"${user}${hostStr}"
|
|
(homeManagerConfiguration {
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
extraSpecialArgs = {
|
|
inherit inputs self;
|
|
lib = lib.extend (_: _: inputs.home-manager.lib);
|
|
};
|
|
|
|
modules = [
|
|
../hosts/${configHost}/home.nix
|
|
];
|
|
});
|
|
compileHomes =
|
|
systems:
|
|
lib.right
|
|
builtins.listToAttrs
|
|
(map toPartialHomeManagerConfig)
|
|
systems;
|
|
}
|