nix/lib/default.nix

65 lines
1.9 KiB
Nix
Raw Normal View History

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