75 lines
2.2 KiB
Nix
75 lines
2.2 KiB
Nix
args@{
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
self,
|
|
...
|
|
}: let
|
|
inherit (inputs.nixpkgs.lib) nixosSystem;
|
|
inherit (builtins) baseNameOf elem map listToAttrs;
|
|
inherit (lib) filterAttrs nameValuePair attrNames;
|
|
inherit (lib.modules) mkAliasOptionModule mkDefault mkIf;
|
|
inherit (lib.strings) removeSuffix;
|
|
inherit (self.modules) mapModules mapModulesRec';
|
|
inherit (self) mkSysUser mkHmUser;
|
|
in rec
|
|
{
|
|
mkHost = path: attrs @ {system ? "x86_64-linux", ...}:
|
|
nixosSystem {
|
|
inherit system;
|
|
|
|
specialArgs = {inherit lib inputs system; };
|
|
|
|
modules = let
|
|
stateVersion = "23.11";
|
|
users = attrNames (mapModules "${path}/users" (p: p));
|
|
in [
|
|
inputs.nixos-boot.nixosModules.default
|
|
({ options, config, ...}: {
|
|
nixpkgs.pkgs = pkgs;
|
|
|
|
networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path));
|
|
|
|
system = {
|
|
inherit stateVersion;
|
|
configurationRevision = with inputs; mkIf (self ? rev) self.rev;
|
|
};
|
|
|
|
imports = [
|
|
inputs.home-manager.nixosModules.home-manager
|
|
"${path}/hardware.nix"
|
|
./_root.nix
|
|
]
|
|
++ (mapModulesRec' ../modules/system import);
|
|
|
|
users = {
|
|
mutableUsers = true; # Set this to false when I get sops with passwords set up properly
|
|
users = mapModules "${path}/users" mkSysUser;
|
|
};
|
|
|
|
home-manager = {
|
|
backupFileExtension = "bak";
|
|
useGlobalPkgs = true;
|
|
sharedModules = [
|
|
inputs.plasma-manager.homeManagerModules.plasma-manager
|
|
];
|
|
|
|
users = listToAttrs (map (user: (nameValuePair user { home = { inherit stateVersion; }; })) (users ++ [ "root" ]));
|
|
};
|
|
})
|
|
(filterAttrs (n: v: !elem n ["system"]) attrs)
|
|
(import path)
|
|
]
|
|
++ (map (user: {
|
|
_module.args.user = user;
|
|
|
|
imports = []
|
|
++ (mapModulesRec' ../modules/home (file: file));
|
|
|
|
modules.${user} = (import "${path}/users/${user}/default.nix" args);
|
|
}) users);
|
|
};
|
|
|
|
mapHosts = dir: attrs @ {system ? system, ...}:
|
|
mapModules dir (hostPath: mkHost hostPath attrs);
|
|
}
|