106 lines
3.2 KiB
Nix
Executable File
106 lines
3.2 KiB
Nix
Executable File
{
|
|
inputs,
|
|
mkPkgs,
|
|
supportedSystems,
|
|
...
|
|
}:
|
|
{
|
|
generate =
|
|
{ host }:
|
|
let
|
|
syscfg = import ./systems/${host}/cfg.nix;
|
|
nameValuePair = name: value: { inherit name value; };
|
|
systemType = syscfg.syscfg.type or "nixos";
|
|
defaultSystem =
|
|
{
|
|
nixos = "x86_64-linux";
|
|
macos = "x86_64-darwin";
|
|
home = "x86_64-linux";
|
|
}
|
|
.${systemType} or (throw "Unsupported system type: ${systemType}");
|
|
system = syscfg.syscfg.system or defaultSystem;
|
|
checkedSystem =
|
|
if builtins.elem system supportedSystems then
|
|
system
|
|
else
|
|
throw "Unsupported system '${system}' for host '${host}'";
|
|
pkgs = mkPkgs checkedSystem;
|
|
in
|
|
(
|
|
{
|
|
"nixos" = inputs.nixpkgs.lib.nixosSystem {
|
|
system = checkedSystem;
|
|
specialArgs = { inherit inputs; };
|
|
modules = [
|
|
./modules/shared/syscfg
|
|
./modules/shared/sops
|
|
./modules/nixos
|
|
syscfg
|
|
./systems/${host}
|
|
inputs.sops-nix.nixosModules.sops
|
|
inputs.home-manager.nixosModules.home-manager
|
|
|
|
inputs.nixos-wsl.nixosModules.wsl
|
|
inputs.vscode-server.nixosModules.default
|
|
|
|
{
|
|
home-manager.useGlobalPkgs = true;
|
|
home-manager.useUserPackages = true;
|
|
home-manager.extraSpecialArgs = { inherit inputs; };
|
|
home-manager.users = builtins.listToAttrs (
|
|
map (
|
|
userConfig:
|
|
nameValuePair userConfig.username {
|
|
imports = [
|
|
./modules/shared/syscfg
|
|
./modules/shared/colors
|
|
./modules/home
|
|
syscfg
|
|
{ usercfg = userConfig; }
|
|
inputs.nix-colors.homeManagerModule
|
|
inputs.sops-nix.homeManagerModules.sops
|
|
];
|
|
}
|
|
) (syscfg.syscfg.users or [ ])
|
|
);
|
|
}
|
|
];
|
|
};
|
|
|
|
"macos" = inputs.darwin.lib.darwinSystem {
|
|
system = checkedSystem;
|
|
modules = [
|
|
./modules/shared/syscfg
|
|
./modules/shared/sops
|
|
syscfg
|
|
./systems/${host}
|
|
inputs.sops-nix.darwinModules.sops
|
|
inputs.home-manager.darwinModules.home-manager
|
|
{
|
|
home-manager.useGlobalPkgs = true;
|
|
home-manager.useUserPackages = true;
|
|
home-manager.extraSpecialArgs = { inherit inputs; };
|
|
home-manager.users = builtins.listToAttrs (
|
|
map (
|
|
userConfig:
|
|
nameValuePair userConfig.username {
|
|
imports = [
|
|
inputs.nix-colors.homeManagerModule
|
|
inputs.sops-nix.homeManagerModules.sops
|
|
];
|
|
}
|
|
) (syscfg.syscfg.users or [ ])
|
|
);
|
|
}
|
|
];
|
|
};
|
|
"home" = inputs.home-manager.lib.homeManagerConfiguration {
|
|
inherit pkgs;
|
|
modules = [ ./modules/home ];
|
|
};
|
|
_ = throw "Unsupported system";
|
|
}
|
|
.${systemType}
|
|
);
|
|
}
|