Working flake-based nixops config

This commit is contained in:
niten 2021-10-08 15:26:19 -07:00
parent 5a48c78b48
commit a323dbdd9c
7 changed files with 59 additions and 53 deletions

View File

@ -22,19 +22,19 @@ in {
}; };
}; };
fudo.secrets = { # fudo.secrets = {
host-secrets.lambda = { # host-secrets.lambda = {
host-keytab = { # host-keytab = {
source-file = /state/secrets/kerberos/lambda.keytab; # source-file = /state/secrets/kerberos/lambda.keytab;
target-file = "/etc/krb5.keytab"; # target-file = "/etc/krb5.keytab";
user = "root"; # user = "root";
}; # };
}; # };
secret-group = "fudo-secrets"; # secret-group = "fudo-secrets";
secret-users = [ "niten" ]; # secret-users = [ "niten" ];
secret-paths = [ "/state/secrets" ]; # secret-paths = [ "/state/secrets" ];
}; # };
fudo.games.valheim = { fudo.games.valheim = {
enable = true; enable = true;

View File

@ -63,20 +63,6 @@ in {
network-definition = config.fudo.networks.${domain-name}; network-definition = config.fudo.networks.${domain-name};
}; };
secrets.host-secrets.limina = {
backplane-client-passwd = {
source-file = /state/secrets/backplane-client/limina.passwd;
target-file = "/srv/backplane/dns/client.passwd";
user = config.fudo.client.dns.user;
};
host-keytab = {
source-file = /state/secrets/kerberos/limina.keytab;
target-file = "/etc/krb5.keytab";
user = "root";
};
};
client.dns = { client.dns = {
enable = true; enable = true;
ipv4 = true; ipv4 = true;

View File

@ -2,8 +2,8 @@
{ {
config.fudo.networks = { config.fudo.networks = {
"rus.selby.ca" = import ./networks/rus.selby.ca.nix { inherit config lib; }; "rus.selby.ca" = import ./networks/rus.selby.ca.nix;
"sea.fudo.org" = import ./networks/sea.fudo.org.nix { inherit config lib; }; "sea.fudo.org" = import ./networks/sea.fudo.org.nix;
"informis.land" = import ./networks/informis.land.nix { inherit config lib; }; "informis.land" = import ./networks/informis.land.nix;
}; };
} }

View File

@ -1,5 +1,4 @@
{ hostname, site, domain, profile, build-timestamp, ... }: { hostname, site, domain, profile, build-timestamp, config, lib, pkgs, ... }:
{ config, lib, pkgs, ... }:
let let
# Get info on this host so we know what to load # Get info on this host so we know what to load
@ -10,8 +9,6 @@ in {
./lib ./lib
./config ./config
#home-manager-module
(config-dir + /hardware/${hostname}.nix) (config-dir + /hardware/${hostname}.nix)
(config-dir + /host-config/${hostname}.nix) (config-dir + /host-config/${hostname}.nix)
(config-dir + /profile-config/${profile}.nix) (config-dir + /profile-config/${profile}.nix)
@ -21,9 +18,10 @@ in {
config = { config = {
instance = { instance = {
inherit hostname site domain profile build-timestamp; inherit hostname build-timestamp;
local-site = site;
local-domain = domain;
local-profile = profile;
}; };
nixpkgs.pkgs = pkgs;
}; };
} }

View File

@ -72,6 +72,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
users.users = { users.users = {
"${cfg.user}" = { "${cfg.user}" = {
isSystemUser = true; isSystemUser = true;

View File

@ -102,17 +102,23 @@ in {
boot.tmpOnTmpfs = host-cfg.tmp-on-tmpfs; boot.tmpOnTmpfs = host-cfg.tmp-on-tmpfs;
fudo.secrets.host-secrets.${hostname} = let fudo = let
keytab-file = try-attr = attr: set: if (hasAttr attr set) then set.${attr} else null;
if (hasAttr hostname config.fudo.secrets.files.host-keytabs) then
config.fudo.secrets.files.host-keytabs.${hostname} files = config.fudo.secrets.files;
else null;
keytab-file = try-attr hostname files.host-keytabs;
build-private-key-file = build-private-key-file =
if (hasAttr hostname config.fudo.secrets.files.build-keypairs) then mapOptional
config.fudo.secrets.files.build-keypairs.${hostname}.private-key (keypair: keypair.private-key)
else null; (try-attr hostname files.build-keypairs);
backplane-passwd-source = try-attr hostname files.backplane-passwords;
backplane-passwd-target = "/var/run/backplane/passwd";
in { in {
secrets.host-secrets.${hostname} = {
host-keytab = mkIf (keytab-file != null) { host-keytab = mkIf (keytab-file != null) {
source-file = keytab-file; source-file = keytab-file;
target-file = "/etc/krb5.keytab"; target-file = "/etc/krb5.keytab";
@ -124,6 +130,16 @@ in {
target-file = "/var/run/nix-build/host.key"; target-file = "/var/run/nix-build/host.key";
user = "root"; user = "root";
}; };
backplane-passwd = mkIf (backplane-passwd-source != null) {
source-file = backplane-passwd-source;
target-file = backplane-passwd-target;
user = config.fudo.client.dns.user;
};
};
client.dns.password-file = mkIf (backplane-passwd != null)
backplane-password-target;
}; };
programs.adb.enable = host-cfg.android-dev; programs.adb.enable = host-cfg.android-dev;

View File

@ -27,6 +27,11 @@ in {
description = "Site name of the current local host."; description = "Site name of the current local host.";
}; };
local-profile = mkOption {
type = str;
description = "Profile name of the current local host.";
};
local-admins = mkOption { local-admins = mkOption {
type = listOf str; type = listOf str;
description = "List of users who should have admin access to the local host."; description = "List of users who should have admin access to the local host.";