nix/lib/default.nix
2024-01-05 16:10:10 +09:00

106 lines
No EOL
3.1 KiB
Nix

{ self, inputs, outputs, stateVersion, hmStateVersion, ... }: {
deploy = {
hostname,
platform ? "x86_64-linux",
username ? "albert"
}: {
user = "root";
sshUser = "${username}";
hostname = "${hostname}";
sshOpts = [ "-A" "-q"];
profiles = {
system.path = inputs.deploy-rs.lib.${platform}.activate.nixos self.nixosConfigurations.${hostname};
home-manager.path = inputs.deploy-rs.lib.${platform}.activate.home-manager self.homeConfigurations."${username}@${hostname}";
home-manager.user = "${username}";
};
};
# Helper function for generating home-manager configs
mkHome = {
hostname,
username ? "albert",
desktop ? null,
platform ? "x86_64-linux",
color ? "default",
type ? "default"
}: inputs.home-manager.lib.homeManagerConfiguration {
pkgs = inputs.nixpkgs.legacyPackages.${platform};
extraSpecialArgs = { inherit inputs outputs desktop hostname platform username hmStateVersion color; };
modules = [
../home-manager/${type}.nix
];
};
# Helper function for generating host configs
mkHost = {
hostname,
username ? "albert",
desktop ? null,
gpu ? null,
platform ? "x86_64-linux",
color ? "default",
type ? "default"
}: inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs desktop hostname username stateVersion gpu platform color; };
modules = [
# Types are 'default', 'small', and 'minimal'
../nixos/${type}.nix
inputs.sops-nix.nixosModules.sops
inputs.lanzaboote.nixosModules.lanzaboote
];
};
# Combines mkHost and mkHome for image building
mkImage = {
hostname ,
username ? "albert",
desktop ? null,
platform ? "x86_64-linux",
gpu ? null,
color ? "default",
format
}: inputs.nixos-generators.nixosGenerate {
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu platform color format; };
system = platform;
format = format;
modules = [
../nixos
../nixos/common/modules/installer.nix
inputs.sops-nix.nixosModules.sops
inputs.lanzaboote.nixosModules.lanzaboote
inputs.home-manager.nixosModules.home-manager {
home-manager.extraSpecialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu platform color format; };
home-manager.users."${username}" = import ../home-manager;
}
];
};
# Small version
mkMinImage = {
hostname ,
username ? "albert",
desktop ? null,
platform ? "x86_64-linux",
gpu ? null,
color ? "default",
format
}:
inputs.nixos-generators.nixosGenerate {
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu platform color format; };
system = platform;
format = format;
modules = [
../nixos/minimal.nix
../nixos/common/modules/installer.nix
inputs.sops-nix.nixosModules.sops
];
};
forAllSystems = inputs.nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
];
}