nix/lib/default.nix

89 lines
2.6 KiB
Nix
Raw Normal View History

2023-08-23 21:39:51 +09:00
{ inputs, outputs, stateVersion, hmStateVersion, ... }: {
2023-08-25 19:07:54 +09:00
2023-08-23 16:53:29 +09:00
# Helper function for generating home-manager configs
2023-08-31 20:22:44 +09:00
mkHome = {
hostname,
2023-09-16 21:21:45 +09:00
username ? "albert",
2023-08-31 20:22:44 +09:00
desktop ? null,
platform ? "x86_64-linux",
2023-09-15 12:03:35 +09:00
theme ? "default"
2023-08-31 20:22:44 +09:00
}: inputs.home-manager.lib.homeManagerConfiguration {
2023-08-23 19:47:21 +09:00
pkgs = inputs.nixpkgs.legacyPackages.${platform};
2023-08-31 20:22:44 +09:00
extraSpecialArgs = { inherit inputs outputs desktop hostname platform username hmStateVersion theme; };
2023-08-25 19:07:54 +09:00
modules = [
2023-09-19 11:26:38 +09:00
../home-manager
2023-08-25 19:07:54 +09:00
];
2023-08-23 16:53:29 +09:00
};
# Helper function for generating host configs
2023-08-31 20:22:44 +09:00
mkHost = {
hostname,
2023-09-16 21:21:45 +09:00
username ? "albert",
2023-08-31 20:22:44 +09:00
desktop ? null,
gpu ? null,
platform ? "x86_64-linux",
2023-09-15 12:03:35 +09:00
theme ? "default"
2023-08-31 20:22:44 +09:00
}: inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs desktop hostname username stateVersion gpu platform theme; };
2023-08-23 16:53:29 +09:00
modules = [
2023-08-23 17:11:24 +09:00
../nixos
2023-08-27 19:50:23 +09:00
inputs.sops-nix.nixosModules.sops
inputs.lanzaboote.nixosModules.lanzaboote
2023-09-19 09:30:44 +09:00
];
2023-08-23 16:53:29 +09:00
};
2023-09-19 08:03:21 +09:00
# Combines mkHost and mkHome for image building
mkImage = {
2023-09-19 09:54:18 +09:00
hostname ,
2023-09-19 09:30:44 +09:00
username ? "albert",
desktop ? null,
platform ? "x86_64-linux",
2023-09-19 08:03:21 +09:00
gpu ? null,
2023-09-19 10:19:31 +09:00
theme ? "default",
2023-09-19 13:19:24 +09:00
format
2023-09-19 10:41:49 +09:00
}:
inputs.nixos-generators.nixosGenerate {
2023-09-21 10:49:49 +09:00
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu platform theme format; };
2023-09-19 13:13:57 +09:00
format = format;
system = platform;
2023-09-19 10:41:49 +09:00
2023-09-19 08:45:25 +09:00
modules = [
2023-09-19 09:30:44 +09:00
../nixos
2023-09-22 08:32:18 +09:00
../nixos/common/modules/installer.nix
2023-09-19 09:30:44 +09:00
inputs.sops-nix.nixosModules.sops
inputs.lanzaboote.nixosModules.lanzaboote
2023-09-21 21:47:59 +09:00
inputs.home-manager.nixosModules.home-manager {
home-manager.extraSpecialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu platform theme format; };
home-manager.users."${username}" = import ../home-manager;
}
2023-09-19 09:30:44 +09:00
];
2023-09-19 08:03:21 +09:00
};
2023-09-22 21:09:37 +09:00
# Combines mkHost and mkHome for image building
2023-09-21 20:31:55 +09:00
mkMinImage = {
hostname ,
username ? "albert",
desktop ? null,
platform ? "x86_64-linux",
gpu ? null,
theme ? "default",
format
}:
inputs.nixos-generators.nixosGenerate {
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu platform theme format; };
format = format;
system = platform;
modules = [
../nixos/minimal.nix
2023-09-22 08:32:18 +09:00
../nixos/common/modules/installer.nix
2023-09-21 20:31:55 +09:00
inputs.sops-nix.nixosModules.sops
inputs.lanzaboote.nixosModules.lanzaboote
];
};
2023-08-23 16:53:29 +09:00
forAllSystems = inputs.nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
];
2023-09-19 08:48:43 +09:00
}