161 lines
5 KiB
Nix
161 lines
5 KiB
Nix
{ lib ? lib, self, inputs, outputs, stateVersion, hmStateVersion , ... }: {
|
|
deploy = {
|
|
hostname,
|
|
system ? "x86_64-linux",
|
|
username ? "albert"
|
|
}: {
|
|
user = "root";
|
|
sshUser = "${username}";
|
|
hostname = "${hostname}";
|
|
sshOpts = [ "-A" "-q"];
|
|
|
|
profiles = {
|
|
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}";
|
|
home-manager.user = "${username}";
|
|
};
|
|
};
|
|
|
|
# Helper function for generating home-manager configs
|
|
mkHome = {
|
|
hostname,
|
|
username ? "albert",
|
|
desktop ? null,
|
|
system ? "x86_64-linux",
|
|
theme ? "stylix",
|
|
type ? "default"
|
|
}: inputs.home-manager.lib.homeManagerConfiguration {
|
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
|
extraSpecialArgs = { inherit inputs outputs desktop hostname system username hmStateVersion theme; };
|
|
modules = [ ../home-manager/${type}.nix ];
|
|
};
|
|
|
|
mkContainer = {
|
|
hostname,
|
|
username ? "albert",
|
|
desktop ? null,
|
|
system ? "x86_64-linux",
|
|
theme ? "stylix",
|
|
type ? "default",
|
|
repo ? "nixpkgs",
|
|
unfree ? false,
|
|
ip ? null,
|
|
pkgs ? import inputs.${repo}
|
|
{ inherit system; config.allowUnfree = unfree; hostPlatform = system; },
|
|
pkgs-unstable ? import inputs.nixpkgs-unstable
|
|
{ inherit system; config.allowUnfree = unfree; hostPlatform = system; }
|
|
}: {
|
|
bindMounts = lib.mkMerge [
|
|
( import ../nixos/containers/mounts.nix )
|
|
( import ../nixos/containers/${hostname}/mounts.nix )
|
|
];
|
|
autoStart = true;
|
|
privateNetwork = true;
|
|
localAddress = "192.168.2.${ip}/32";
|
|
hostAddress = "192.168.2.1";
|
|
restartIfChanged = true;
|
|
enableTun = true;
|
|
additionalCapabilities = [ "CAP_NET_ADMIN" "CAP_NET_RAW" ];
|
|
specialArgs = { inherit pkgs-unstable hostname username desktop theme system repo unfree stateVersion; };
|
|
config = { lib, config, pkgs-unstable, hostname, username, desktop, theme, system, repo, stateVersion, ... }: {
|
|
# Choose whether to pull from stable or unstable
|
|
nixpkgs.pkgs = import inputs.${repo} {
|
|
inherit system;
|
|
config.allowUnfree = unfree;
|
|
hostPlatform = system;
|
|
};
|
|
|
|
imports = [
|
|
../nixos/containers
|
|
inputs.sops-nix.nixosModules.sops
|
|
];
|
|
};
|
|
};
|
|
|
|
# Helper function for generating host configs
|
|
mkHost = {
|
|
hostname,
|
|
username ? "albert",
|
|
desktop ? null,
|
|
gpu ? null,
|
|
system ? "x86_64-linux",
|
|
theme ? "stylix",
|
|
type ? "default",
|
|
repo ? "nixpkgs",
|
|
unfree ? false
|
|
}: inputs.${repo}.lib.nixosSystem {
|
|
specialArgs = { inherit inputs outputs desktop hostname username hmStateVersion stateVersion gpu system theme self;
|
|
# 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;
|
|
};
|
|
};
|
|
|
|
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,
|
|
system ? "x86_64-linux",
|
|
gpu ? null,
|
|
theme ? "stylix",
|
|
format
|
|
}: inputs.nixos-generators.nixosGenerate {
|
|
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu system theme format; };
|
|
system = system;
|
|
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 system theme format; };
|
|
home-manager.users."${username}" = import ../home-manager;
|
|
}
|
|
];
|
|
};
|
|
|
|
# Small version
|
|
mkMinImage = {
|
|
hostname ,
|
|
username ? "albert",
|
|
desktop ? null,
|
|
system ? "x86_64-linux",
|
|
gpu ? null,
|
|
theme ? "stylix",
|
|
format
|
|
}: inputs.nixos-generators.nixosGenerate {
|
|
specialArgs = { inherit inputs outputs desktop hostname username stateVersion hmStateVersion gpu system theme format; };
|
|
system = system;
|
|
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"
|
|
];
|
|
}
|