nix/lib/default.nix

109 lines
3.2 KiB
Nix
Raw Normal View History

2024-01-31 04:20:05 +01:00
{ self, inputs, outputs, stateVersion, hmStateVersion , ... }: {
2023-12-09 14:10:15 +01:00
deploy = {
hostname,
platform ? "x86_64-linux",
username ? "albert"
}: {
2023-12-12 12:37:35 +01:00
user = "root";
2023-12-12 13:06:50 +01:00
sshUser = "${username}";
2023-12-10 03:07:31 +01:00
hostname = "${hostname}";
2023-12-12 12:37:35 +01:00
sshOpts = [ "-A" "-q"];
2023-12-10 04:43:57 +01:00
2023-12-11 05:09:49 +01:00
profiles = {
2023-12-13 00:53:03 +01:00
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}";
2023-12-13 01:09:39 +01:00
home-manager.user = "${username}";
2023-12-10 04:43:57 +01:00
};
2023-12-11 05:18:06 +01:00
};
2023-12-09 14:10:15 +01: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",
2024-01-06 13:48:55 +01:00
theme ? "default",
type ? "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};
2024-01-06 13:48:55 +01:00
extraSpecialArgs = { inherit inputs outputs desktop hostname platform username hmStateVersion theme; };
2023-08-25 12:07:54 +02:00
modules = [
../home-manager/${type}.nix
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",
2024-01-06 13:48:55 +01:00
theme ? "default",
2024-01-31 03:36:27 +01:00
type ? "default",
repo ? "nixpkgs"
2023-08-31 13:22:44 +02:00
}: inputs.nixpkgs.lib.nixosSystem {
2024-01-06 13:48:55 +01:00
specialArgs = { inherit inputs outputs desktop hostname username stateVersion gpu platform theme; };
2024-01-31 04:25:12 +01:00
pkgs = import inputs.${repo};
2024-01-31 03:36:27 +01:00
2023-08-23 09:53:29 +02:00
modules = [
2023-11-26 03:51:14 +01:00
# Types are 'default', 'small', and 'minimal'
../nixos/${type}.nix
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,
2024-01-06 13:48:55 +01:00
theme ? "default",
2023-09-19 06:19:24 +02:00
format
2023-12-09 13:34:27 +01:00
}: inputs.nixos-generators.nixosGenerate {
2024-01-06 13:48:55 +01:00
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu platform theme format; };
2023-09-19 06:13:57 +02:00
system = platform;
2023-12-14 12:00:41 +01:00
format = format;
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
2023-09-22 01:32:18 +02:00
../nixos/common/modules/installer.nix
2023-09-19 02:30:44 +02:00
inputs.sops-nix.nixosModules.sops
inputs.lanzaboote.nixosModules.lanzaboote
2023-09-21 14:47:59 +02:00
inputs.home-manager.nixosModules.home-manager {
2024-01-06 13:48:55 +01:00
home-manager.extraSpecialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu platform theme format; };
2023-09-21 14:47:59 +02:00
home-manager.users."${username}" = import ../home-manager;
}
2023-09-19 02:30:44 +02:00
];
2023-09-19 01:03:21 +02:00
};
2023-12-14 11:41:07 +01:00
# Small version
2023-09-21 13:31:55 +02:00
mkMinImage = {
hostname ,
username ? "albert",
desktop ? null,
platform ? "x86_64-linux",
gpu ? null,
2024-01-06 13:48:55 +01:00
theme ? "default",
2023-09-21 13:31:55 +02:00
format
}:
inputs.nixos-generators.nixosGenerate {
2024-01-06 13:48:55 +01:00
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu platform theme format; };
2023-09-21 13:31:55 +02:00
system = platform;
2023-12-14 12:00:41 +01:00
format = format;
2023-09-21 13:31:55 +02:00
modules = [
../nixos/minimal.nix
2023-09-22 01:32:18 +02:00
../nixos/common/modules/installer.nix
2023-09-21 13:31:55 +02:00
inputs.sops-nix.nixosModules.sops
];
};
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
}