2024-03-25 03:53:39 +01:00
|
|
|
{ lib ? lib, self, inputs, outputs, stateVersion, hmStateVersion , ... }: {
|
2023-12-09 14:10:15 +01:00
|
|
|
deploy = {
|
|
|
|
hostname,
|
2024-01-31 04:31:01 +01:00
|
|
|
system ? "x86_64-linux",
|
2023-12-09 14:10:15 +01:00
|
|
|
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 = {
|
2024-01-31 04:31:01 +01:00
|
|
|
system.path = inputs.deploy-rs.lib.${system}.activate.nixos self.nixosConfigurations.${hostname};
|
|
|
|
home-manager.path = inputs.deploy-rs.lib.${system}.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,
|
2024-01-31 04:31:01 +01:00
|
|
|
system ? "x86_64-linux",
|
2024-06-12 12:15:32 +02:00
|
|
|
theme ? "default",
|
2023-12-12 11:29:04 +01:00
|
|
|
type ? "default"
|
2023-08-31 13:22:44 +02:00
|
|
|
}: inputs.home-manager.lib.homeManagerConfiguration {
|
2024-01-31 04:31:01 +01:00
|
|
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
|
|
|
extraSpecialArgs = { inherit inputs outputs desktop hostname system username hmStateVersion theme; };
|
2024-02-19 06:40:42 +01:00
|
|
|
modules = [ ../home-manager/${type}.nix ];
|
2023-08-23 09:53:29 +02:00
|
|
|
};
|
|
|
|
|
2024-03-20 09:23:30 +01:00
|
|
|
mkContainer = {
|
2024-03-21 10:51:41 +01:00
|
|
|
hostname,
|
2024-03-20 09:23:30 +01:00
|
|
|
username ? "albert",
|
2024-03-22 14:36:01 +01:00
|
|
|
desktop ? null,
|
2024-03-20 09:23:30 +01:00
|
|
|
system ? "x86_64-linux",
|
2024-06-12 12:15:32 +02:00
|
|
|
theme ? "default",
|
2024-03-22 14:36:01 +01:00
|
|
|
type ? "default",
|
2024-03-20 09:23:30 +01:00
|
|
|
repo ? "nixpkgs",
|
2024-03-22 14:36:01 +01:00
|
|
|
unfree ? false,
|
2024-03-26 01:00:46 +01:00
|
|
|
ip ? null,
|
2024-04-05 15:51:54 +02:00
|
|
|
ephemeral ? false,
|
2024-07-02 10:54:14 +02:00
|
|
|
deployment_type ? "containers",
|
2024-03-22 14:36:01 +01:00
|
|
|
pkgs ? import inputs.${repo}
|
|
|
|
{ inherit system; config.allowUnfree = unfree; hostPlatform = system; },
|
|
|
|
pkgs-unstable ? import inputs.nixpkgs-unstable
|
|
|
|
{ inherit system; config.allowUnfree = unfree; hostPlatform = system; }
|
2024-03-20 09:23:30 +01:00
|
|
|
}: {
|
2024-04-05 15:51:54 +02:00
|
|
|
bindMounts = lib.mkMerge [
|
2024-03-25 03:53:39 +01:00
|
|
|
( import ../nixos/containers/mounts.nix )
|
|
|
|
( import ../nixos/containers/${hostname}/mounts.nix )
|
|
|
|
];
|
2024-04-07 14:05:15 +02:00
|
|
|
ephemeral = ephemeral;
|
2024-04-05 15:51:54 +02:00
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
2024-04-07 01:42:00 +02:00
|
|
|
hostBridge = "nix-br0";
|
|
|
|
localAddress = "192.168.2.${ip}";
|
2024-03-25 04:30:28 +01:00
|
|
|
restartIfChanged = true;
|
2024-04-07 01:42:00 +02:00
|
|
|
enableTun = true;
|
2024-07-02 10:54:14 +02:00
|
|
|
specialArgs = { inherit pkgs-unstable hostname username desktop theme system repo unfree stateVersion ip deployment_type; };
|
|
|
|
config = { lib, config, pkgs-unstable, hostname, username, desktop, theme, system, repo, stateVersion, ip, deployment_type, ... }: {
|
2024-03-26 01:00:46 +01:00
|
|
|
nixpkgs.pkgs = import inputs.${repo} {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = unfree;
|
|
|
|
hostPlatform = system;
|
|
|
|
};
|
|
|
|
|
2024-03-21 12:27:53 +01:00
|
|
|
imports = [
|
|
|
|
../nixos/containers
|
2024-03-25 04:30:28 +01:00
|
|
|
inputs.sops-nix.nixosModules.sops
|
2024-04-26 13:49:35 +02:00
|
|
|
inputs.home-manager.nixosModules.home-manager {
|
|
|
|
home-manager.extraSpecialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion system theme ; };
|
|
|
|
home-manager.users."${username}" = import ../home-manager;
|
|
|
|
}
|
2024-03-21 12:27:53 +01:00
|
|
|
];
|
2024-03-20 09:23:30 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-26 13:49:35 +02:00
|
|
|
# Helper function for generating host configs
|
|
|
|
mkDeck = {
|
|
|
|
hostname,
|
|
|
|
username ? "albert",
|
|
|
|
desktop ? null,
|
|
|
|
gpu ? null,
|
|
|
|
system ? "x86_64-linux",
|
2024-06-12 12:15:32 +02:00
|
|
|
theme ? "default",
|
2024-04-26 13:49:35 +02:00
|
|
|
type ? "default",
|
2024-07-02 10:54:14 +02:00
|
|
|
repo ? "nixpkgs-unstable",
|
|
|
|
deployment_type ? "hosts",
|
2024-04-26 13:49:35 +02:00
|
|
|
}: inputs.${repo}.lib.nixosSystem {
|
|
|
|
specialArgs = {
|
2024-07-02 10:54:14 +02:00
|
|
|
inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system theme self deployment_type;
|
2024-04-26 13:49:35 +02:00
|
|
|
# Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use
|
|
|
|
pkgs-unstable = import inputs.nixpkgs-unstable {
|
|
|
|
inherit system;
|
2024-04-26 15:00:24 +02:00
|
|
|
config.allowUnfree = true;
|
2024-04-26 13:49:35 +02:00
|
|
|
hostPlatform = system;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
modules = [
|
|
|
|
# Types are 'default', 'small', and 'minimal'
|
2024-04-27 08:59:29 +02:00
|
|
|
../nixos/${type}.nix
|
2024-04-26 13:49:35 +02:00
|
|
|
inputs.sops-nix.nixosModules.sops
|
|
|
|
inputs.lanzaboote.nixosModules.lanzaboote
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-02-09 14:59:27 +01:00
|
|
|
# Helper function for generating host configs
|
2024-02-09 14:38:38 +01:00
|
|
|
mkHost = {
|
|
|
|
hostname,
|
|
|
|
username ? "albert",
|
|
|
|
desktop ? null,
|
|
|
|
gpu ? null,
|
|
|
|
system ? "x86_64-linux",
|
2024-06-12 12:15:32 +02:00
|
|
|
theme ? "default",
|
2024-02-09 14:38:38 +01:00
|
|
|
type ? "default",
|
|
|
|
repo ? "nixpkgs",
|
2024-07-02 10:54:14 +02:00
|
|
|
deployment_type ? "hosts",
|
2024-02-09 14:38:38 +01:00
|
|
|
unfree ? false
|
2024-03-20 09:26:47 +01:00
|
|
|
}: inputs.${repo}.lib.nixosSystem {
|
2024-04-26 13:49:35 +02:00
|
|
|
specialArgs = {
|
2024-07-02 10:54:14 +02:00
|
|
|
inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system theme self deployment_type;
|
2024-04-26 13:49:35 +02:00
|
|
|
# Choose whether to pull from stable or unstable
|
|
|
|
pkgs = import inputs.${repo} {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = unfree;
|
|
|
|
hostPlatform = system;
|
|
|
|
};
|
|
|
|
# Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use
|
|
|
|
pkgs-unstable = import inputs.nixpkgs-unstable {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = unfree;
|
|
|
|
hostPlatform = system;
|
|
|
|
};
|
2024-02-09 14:42:09 +01:00
|
|
|
};
|
2024-02-09 14:50:43 +01:00
|
|
|
|
2024-04-26 13:49:35 +02:00
|
|
|
modules = [
|
|
|
|
# Types are 'default', 'small', and 'minimal'
|
|
|
|
../nixos/${type}.nix
|
|
|
|
inputs.sops-nix.nixosModules.sops
|
|
|
|
inputs.lanzaboote.nixosModules.lanzaboote
|
2024-02-09 14:59:27 +01:00
|
|
|
];
|
2024-02-09 14:23:02 +01: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,
|
2024-01-31 04:31:01 +01:00
|
|
|
system ? "x86_64-linux",
|
2023-09-19 01:03:21 +02:00
|
|
|
gpu ? null,
|
2024-06-12 12:15:32 +02:00
|
|
|
theme ? "default",
|
2024-04-24 03:46:03 +02:00
|
|
|
repo ? "nixpkgs",
|
|
|
|
unfree ? false,
|
2023-09-19 06:19:24 +02:00
|
|
|
format
|
2023-12-09 13:34:27 +01:00
|
|
|
}: inputs.nixos-generators.nixosGenerate {
|
2024-04-24 03:46:03 +02:00
|
|
|
specialArgs = {
|
|
|
|
inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu system theme format;
|
|
|
|
# Choose whether to pull from stable or unstable
|
|
|
|
pkgs = import inputs.${repo} {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = unfree;
|
|
|
|
hostPlatform = system;
|
|
|
|
};
|
|
|
|
# Some packages (ie, Vintage Story) I want to keep on unstable no matter what default repo I use
|
|
|
|
pkgs-unstable = import inputs.nixpkgs-unstable {
|
|
|
|
inherit system;
|
|
|
|
config.allowUnfree = unfree;
|
|
|
|
hostPlatform = system;
|
|
|
|
};
|
|
|
|
};
|
2024-01-31 04:31:01 +01:00
|
|
|
system = system;
|
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
|
2024-05-08 01:28:11 +02:00
|
|
|
"${inputs.nixpkgs}/nixos/modules/profiles/all-hardware.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-31 04:31:01 +01:00
|
|
|
home-manager.extraSpecialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system 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,
|
2024-01-31 04:32:27 +01:00
|
|
|
system ? "x86_64-linux",
|
2023-09-21 13:31:55 +02:00
|
|
|
gpu ? null,
|
2024-06-12 12:15:32 +02:00
|
|
|
theme ? "default",
|
2023-09-21 13:31:55 +02:00
|
|
|
format
|
2024-03-20 09:26:47 +01:00
|
|
|
}: inputs.nixos-generators.nixosGenerate {
|
2024-01-31 04:31:01 +01:00
|
|
|
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu system theme format; };
|
|
|
|
system = system;
|
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"
|
|
|
|
];
|
2024-02-19 06:40:42 +01:00
|
|
|
}
|