add (lib): make the function to create nixos system
This commit is contained in:
parent
9e25340e88
commit
159801e764
1 changed files with 88 additions and 0 deletions
88
lib/config.nix
Normal file
88
lib/config.nix
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{
|
||||
inputs,
|
||||
nixpkgs,
|
||||
nixpkgs-old,
|
||||
nixpkgs-latest,
|
||||
}:
|
||||
deviceName:
|
||||
{
|
||||
hostName,
|
||||
userName,
|
||||
additionalOverlays ? [ ],
|
||||
systemArch ? builtins.currentSystem,
|
||||
}:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
customFunctions = import ./utils.nix { inherit lib; };
|
||||
|
||||
baseOverlays =
|
||||
import ../overlays {
|
||||
inherit
|
||||
systemArch
|
||||
nixpkgs-old
|
||||
nixpkgs-latest
|
||||
packagesConfig
|
||||
;
|
||||
}
|
||||
|> builtins.attrValues;
|
||||
overlays = baseOverlays ++ additionalOverlays;
|
||||
|
||||
DeviceConfig = ../devices/${deviceName};
|
||||
HostConfig = ../users/${hostName}/host;
|
||||
HomeConfig = ../users/${userName}/home;
|
||||
|
||||
userData = import ../users/${userName}/data.nix {
|
||||
inherit
|
||||
deviceName
|
||||
hostName
|
||||
userName
|
||||
systemArch
|
||||
;
|
||||
};
|
||||
|
||||
userPackagesConfig = import ../users/${hostName}/packages-config.nix { inherit lib; };
|
||||
|
||||
additionalArgs = { inherit inputs customFunctions userData; };
|
||||
|
||||
sops = {
|
||||
defaultSopsFormat = "yaml";
|
||||
defaultSopsFile = ../secrets/main.yaml;
|
||||
age.keyFile = "${userData.paths.sopsKeyFile}";
|
||||
};
|
||||
in
|
||||
lib.nixosSystem {
|
||||
system = systemArch;
|
||||
specialArgs = additionalArgs;
|
||||
|
||||
modules = [
|
||||
DeviceConfig
|
||||
HostConfig
|
||||
|
||||
{
|
||||
nixpkgs = {
|
||||
inherit overlays;
|
||||
config = userPackagesConfig;
|
||||
};
|
||||
}
|
||||
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager = {
|
||||
users.${userName} = import HomeConfig;
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = additionalArgs;
|
||||
sharedModules = [
|
||||
inputs.sops-nix.homeManagerModules.sops
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
{
|
||||
inherit sops;
|
||||
home-manager.users.${userName} = { inherit sops; };
|
||||
}
|
||||
];
|
||||
}
|
||||
Reference in a new issue