Changes for cashew, added mobile site

This commit is contained in:
niten 2021-11-17 17:32:27 -08:00
parent b5cdfc7293
commit 451ee1d0ae
14 changed files with 262 additions and 108 deletions

View File

@ -11,7 +11,7 @@ let
config.fudo.secrets.host-secrets.${config.instance.hostname}; config.fudo.secrets.host-secrets.${config.instance.hostname};
host-password-files = mapAttrs (hostname: hostOpts: host-password-files = mapAttrs (hostname: hostOpts:
make-password-file hostname) config.fudo.hosts; make-passwd-file hostname) config.fudo.hosts;
in { in {
config = { config = {
@ -19,7 +19,7 @@ in {
secrets.host-secrets = mapAttrs (hostname: hostOpts: { secrets.host-secrets = mapAttrs (hostname: hostOpts: {
backplane-client-passwd = { backplane-client-passwd = {
source-file = host-password-files.${hostname}; source-file = host-password-files.${hostname};
target-file = "/var/fudo/client/passwd"; target-file = "/var/fudo/backplane-client/passwd";
user = config.fudo.client.dns.user; user = config.fudo.client.dns.user;
}; };
}) config.fudo.hosts; }) config.fudo.hosts;

View File

@ -4,6 +4,7 @@
imports = [ imports = [
./aliases.nix ./aliases.nix
./bash.nix ./bash.nix
./client.nix
./common.nix ./common.nix
./domains.nix ./domains.nix
./groups.nix ./groups.nix

View File

@ -1,5 +1,19 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
networking = {
useDHCP = false;
macvlans = {
extif0 = {
interface = "eno2";
mode = "bridge";
};
};
interfaces = {
extif0.macAddress =
pkgs.lib.fudo.network.generate-mac-address config.instance.hostname "extif0";
};
};
} }

View File

@ -3,13 +3,10 @@
with lib; with lib;
let let
hostname = config.instance.hostname; hostname = config.instance.hostname;
host-ipv4 = pkgs.lib.fudo.network.host-ipv4 config hostname; host-ipv4 = "208.81.4.82";
site-name = config.fudo.hosts.${hostname}.site; site-name = config.fudo.hosts.${hostname}.site;
site = config.fudo.sites.${site-name}; site = config.fudo.sites.${site-name};
network-prefix-length =
pkgs.lib.fudo.ip.getNetworkMask site.network;
local-packages = with pkgs; [ local-packages = with pkgs; [
bind bind
]; ];
@ -25,7 +22,7 @@ in {
interfaces.extif0 = { interfaces.extif0 = {
ipv4.addresses = [{ ipv4.addresses = [{
address = host-ipv4; address = host-ipv4;
prefixLength = network-prefix-length; prefixLength = 29;
}]; }];
}; };
}; };

View File

@ -25,8 +25,6 @@ in {
config = { config = {
networking = { networking = {
enableIPv6 = true;
nameservers = [ "1.1.1.1" ]; nameservers = [ "1.1.1.1" ];
defaultGateway = { defaultGateway = {
address = site.gateway-v4; address = site.gateway-v4;
@ -201,33 +199,108 @@ in {
}; };
containers.cashew = let containers.cashew = let
initialize-host = import ../../initialize.nix; local-packages = with pkgs; [
build-timestamp = config.instance.build-timestamp; bind
site = "nuttyclub-vm"; vim
domain = config.instance.local-domain; ];
profile = "container";
in { in {
autoStart = true; autoStart = true;
bindMounts = { bindMounts = {
"/state" = {
hostPath = "/state/cashew";
isReadOnly = false;
};
"/etc/bind" = {
hostPath = "/state/cashew/bind";
isReadOnly = false;
};
"/var/log" = {
hostPath = "/state/cashew/logs";
isReadOnly = false;
};
"/home" = {
hostPath = "/state/cashew/home";
isReadOnly = false;
};
"/etc/dns-root-data" = {
hostPath = "${pkgs.dns-root-data}/";
isReadOnly = true;
};
}; };
config = { pkgs, ... }: { interfaces = [ "eno2" ];
imports = [
(initialize-host {
inherit
lib
pkgs
build-timestamp
site
domain
profile;
hostname = "cashew";
})
];
instance.build-seed = build-seed; config = { ... }: {
nixpkgs.pkgs = pkgs;
environment.systemPackages = local-packages;
users = {
users = {
niten = config.users.users.niten;
reaper = config.users.users.reaper // {
openssh.authorizedKeys.keys = [
"ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBADtR1gMK7JnIOht8yZNPROr+0VHgt5eWrGFPscVPk1crVuEvIv1MF544Qk1IHi+2OA2xUvI1BTgmXp3TLvCjEn4lQF4Uc5hcUGENS6TNMPByHx69rAeXVMtmjW0sL4Tbhqd0iNh85STdtzXNZUY31+A6ugrJSnvnSt5wv9ZpMz0SFIE1Q=="
];
};
root.openssh.authorizedKeys.keys = [
"ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBADtR1gMK7JnIOht8yZNPROr+0VHgt5eWrGFPscVPk1crVuEvIv1MF544Qk1IHi+2OA2xUvI1BTgmXp3TLvCjEn4lQF4Uc5hcUGENS6TNMPByHx69rAeXVMtmjW0sL4Tbhqd0iNh85STdtzXNZUY31+A6ugrJSnvnSt5wv9ZpMz0SFIE1Q=="
];
};
groups = {
wheel.members = [
"niten"
"reaper"
];
dns = {
members = [
"niten"
"reaper"
"named"
];
};
};
};
networking = {
defaultGateway = {
address = "208.81.4.81";
interface = "eno2";
};
interfaces.eno2 = {
ipv4.addresses = [{
address = "208.81.4.82";
prefixLength = 29;
}];
};
};
services = {
bind = {
enable = true;
configFile = "/etc/bind/named.conf";
};
openssh = {
enable = true;
startWhenNeeded = true;
useDns = true;
permitRootLogin = "prohibit-password";
hostKeys = [
{
path = "/state/ssh/ssh_host_ed25519_key";
type = "ed25519";
}
{
path = "/state/ssh/ssh_host_rsa_key";
type = "rsa";
bits = 4096;
}
];
};
};
}; };
}; };
}; };

View File

@ -9,4 +9,8 @@
arch = "x86_64-linux"; arch = "x86_64-linux";
nixos-system = true; nixos-system = true;
machine-id = "e5f456e3183a4dc186181a70bc3af2d1"; machine-id = "e5f456e3183a4dc186181a70bc3af2d1";
master-key = {
public-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC5/2uOE13eKUnXboxPYoZxZkS6sw5m0emR684HFr34l";
key-path = "/state/master-key/ed25519_key";
};
} }

View File

@ -136,6 +136,7 @@
}; };
hosts = { hosts = {
cashew = { ipv4-address = "208.81.4.82"; };
cisco = { ipv4-address = "198.163.150.211"; }; cisco = { ipv4-address = "198.163.150.211"; };
cisco-int = { ipv4-address = "10.73.77.10"; }; cisco-int = { ipv4-address = "10.73.77.10"; };
cupid = { ipv4-address = "208.38.36.100"; }; cupid = { ipv4-address = "208.38.36.100"; };

View File

@ -1,21 +0,0 @@
{ config, lib, pkgs, ... }:
let
hostname = config.instance.hostname;
host-cfg = config.fudo.hosts.${hostname};
secrets = config.fudo.secrets.host-secrets.${hostname};
in {
config.fudo = {
secrets.host-secrets.${hostname} = {
backplane-passwd = {
source-file = host-cfg.backplane-password-file;
target-file = "/run/backplane/client/passwd";
user = config.fudo.client.dns.user;
};
};
client.dns.password-file =
secrets.backplane-passwd.target-file;
};
}

View File

@ -0,0 +1,5 @@
{ config, lib, pkgs, ... }:
{
}

View File

@ -51,8 +51,8 @@
}; };
nuttyclub-vm = { nuttyclub-vm = {
gateway-v4 = "FIXME"; gateway-v4 = "208.81.4.81";
network = "FIXME/29"; network = "208.81.4.80/29";
nameservers = [ "1.1.1.1" ]; nameservers = [ "1.1.1.1" ];
timezone = "America/Winnipeg"; timezone = "America/Winnipeg";
deploy-pubkeys = [ deploy-pubkeys = [

View File

@ -1,26 +1,38 @@
{ {
"nodes": { "nodes": {
"backplane-passwords": {
"flake": false,
"locked": {
"narHash": "sha256-Bf5sVg4oSg6uCKMJl21btfBH4NQI/Wz4SU9j130Shyg=",
"path": "./backplane-passwords",
"type": "path"
},
"original": {
"path": "./backplane-passwords",
"type": "path"
}
},
"build-keypairs": { "build-keypairs": {
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-4eRLRLCzZ6kQIRZqy51bj60jhFSQ/wlKLeNgABPhTyw=", "narHash": "sha256-4eRLRLCzZ6kQIRZqy51bj60jhFSQ/wlKLeNgABPhTyw=",
"path": "./build-keypairs", "path": "/state/secrets/build-keypairs",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "./build-keypairs", "path": "/state/secrets/build-keypairs",
"type": "path"
}
},
"build-seed": {
"flake": false,
"locked": {
"narHash": "sha256-6rzGK/itD/RBRoNGw1L2wLV1IcVbn2b0V49ay1J9z7k=",
"path": "/state/secrets/build.seed",
"type": "path"
},
"original": {
"path": "/state/secrets/build.seed",
"type": "path"
}
},
"dnssec-keys": {
"flake": false,
"locked": {
"narHash": "sha256-KGZFtyc7Sd5mGjLxnM+R/XnCtOwyZ4IuOMcblIjlCnM=",
"path": "/state/secrets/dnssec-keys",
"type": "path"
},
"original": {
"path": "/state/secrets/dnssec-keys",
"type": "path" "type": "path"
} }
}, },
@ -193,11 +205,11 @@
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-K2wdsA4vcNTaLR9A9qxB+aMaeANL0LXOwBWvUm63lX0=", "narHash": "sha256-K2wdsA4vcNTaLR9A9qxB+aMaeANL0LXOwBWvUm63lX0=",
"path": "./filesystem-keys", "path": "/state/secrets/filesystem-keys",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "./filesystem-keys", "path": "/state/secrets/filesystem-keys",
"type": "path" "type": "path"
} }
}, },
@ -220,29 +232,44 @@
"inputs": { "inputs": {
"doom-emacs": "doom-emacs", "doom-emacs": "doom-emacs",
"home-manager": "home-manager", "home-manager": "home-manager",
"niten-doom-config": "niten-doom-config" "niten-doom-config": "niten-doom-config",
"nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"narHash": "sha256-7vxYISWq8BAp88ej37PCdv9Rg6+WgTtFxcOVBH6C1Sw=", "narHash": "sha256-7Yl9CqBD8dahWQvJJEKrvqUMLDYkoLTApNP7BzqGGpg=",
"path": "./nix-home", "path": "/state/nixops/fudo-home",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "./nix-home", "path": "/state/nixops/fudo-home",
"type": "path"
}
},
"fudo-pkgs": {
"locked": {
"narHash": "sha256-XwEs/VkqJp1mNwYUeBUqCPrW6GUEwAxbXMVOy7bF2P8=",
"path": "/state/nixops/fudo-pkgs",
"type": "path"
},
"original": {
"path": "/state/nixops/fudo-pkgs",
"type": "path" "type": "path"
} }
}, },
"fudo-secrets": { "fudo-secrets": {
"inputs": { "inputs": {
"backplane-passwords": "backplane-passwords",
"build-keypairs": "build-keypairs", "build-keypairs": "build-keypairs",
"build-seed": "build-seed",
"dnssec-keys": "dnssec-keys",
"filesystem-keys": "filesystem-keys", "filesystem-keys": "filesystem-keys",
"host-keytabs": "host-keytabs", "host-keytabs": "host-keytabs",
"realm-master-keys": "realm-master-keys",
"service-keytabs": "service-keytabs",
"service-passwords": "service-passwords", "service-passwords": "service-passwords",
"ssh-keypairs": "ssh-keypairs" "ssh-keypairs": "ssh-keypairs"
}, },
"locked": { "locked": {
"narHash": "sha256-cCvorbK8puCKs25oad9l11xveVq2UfKcAs+FJ4LD8r0=", "narHash": "sha256-Q89s52d8KAMIbxh7aBoUwUTFAbgUBE5IaAIwd267k20=",
"path": "/state/secrets", "path": "/state/secrets",
"type": "path" "type": "path"
}, },
@ -253,7 +280,10 @@
}, },
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2" "nixpkgs": [
"fudo-home",
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1633291410, "lastModified": 1633291410,
@ -273,12 +303,12 @@
"host-keytabs": { "host-keytabs": {
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-yvGgY3mgzaGjYBNHr0m4Lg2rxrB0+CRlzWdJ2A06MeM=", "narHash": "sha256-LzDfB9ubACWyQzjXzsPH6eNoESmSVcMFFb3V025Xgow=",
"path": "./kerberos/host-keytabs", "path": "/state/secrets/kerberos/host-keytabs",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "./kerberos/host-keytabs", "path": "/state/secrets/kerberos/host-keytabs",
"type": "path" "type": "path"
} }
}, },
@ -332,25 +362,26 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1633381874, "lastModified": 1636944046,
"narHash": "sha256-RkoVeo4K1IKqQzCI9W28UOyw4ic3Lhb3XoMDFDp7X74=", "narHash": "sha256-74KLDsiWSBsYXKj/ql9EGbw1TbIJRE7clFkhl30HV/c=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "35b808214a1ca158a04d6980cb95cc1a77ce1f94", "rev": "46251a79f752ae1d46ef733e8e9760b6d3429da4",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-21.05",
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1633267966, "lastModified": 1636944046,
"narHash": "sha256-gFKvZ5AmV/dDTKXVxacPbXe4R0BsFpwtVaQxuIm2nnk=", "narHash": "sha256-74KLDsiWSBsYXKj/ql9EGbw1TbIJRE7clFkhl30HV/c=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "7daf35532d2d8bf5e6f7f962e6cd13a66d01a71d", "rev": "46251a79f752ae1d46ef733e8e9760b6d3429da4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -455,6 +486,18 @@
"type": "github" "type": "github"
} }
}, },
"realm-master-keys": {
"flake": false,
"locked": {
"narHash": "sha256-5hDmPweE6lshRKA+AKRgJv7VwWxHsYekwMT32uAUKJU=",
"path": "/state/secrets/kerberos/master-keys",
"type": "path"
},
"original": {
"path": "/state/secrets/kerberos/master-keys",
"type": "path"
}
},
"revealjs": { "revealjs": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -474,6 +517,7 @@
"root": { "root": {
"inputs": { "inputs": {
"fudo-home": "fudo-home", "fudo-home": "fudo-home",
"fudo-pkgs": "fudo-pkgs",
"fudo-secrets": "fudo-secrets", "fudo-secrets": "fudo-secrets",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
} }
@ -494,27 +538,39 @@
"type": "github" "type": "github"
} }
}, },
"service-passwords": { "service-keytabs": {
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-JPMZdokzw+vyWoIKwgDhD60BYi5gch/MfgQyvx5AXZA=", "narHash": "sha256-9lw22Gh1IDX+MtXMLi+o3XbjvqEhOiZQG9FiG/xz/U0=",
"path": "./service-passwords", "path": "/state/secrets/kerberos/service-keytabs",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "./service-passwords", "path": "/state/secrets/kerberos/service-keytabs",
"type": "path"
}
},
"service-passwords": {
"flake": false,
"locked": {
"narHash": "sha256-4xEJlPU+KeBtQuFqRlB1bzJMXUQ6a+DT2v3OptaHyTg=",
"path": "/state/secrets/service-passwords",
"type": "path"
},
"original": {
"path": "/state/secrets/service-passwords",
"type": "path" "type": "path"
} }
}, },
"ssh-keypairs": { "ssh-keypairs": {
"flake": false, "flake": false,
"locked": { "locked": {
"narHash": "sha256-fD2ZTNMc399XtlVWLCU4crC0RZZ8yTZPFzEm9VWjiL8=", "narHash": "sha256-TlRfaYFuJxLUCarxZ1XYnW8PruKyYO5RErVGo5hTgo4=",
"path": "./ssh-keypairs", "path": "/state/secrets/ssh-keypairs",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "./ssh-keypairs", "path": "/state/secrets/ssh-keypairs",
"type": "path" "type": "path"
} }
} }

View File

@ -4,25 +4,27 @@
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-21.05"; nixpkgs.url = "nixpkgs/nixos-21.05";
fudo-home.url = "path:./nix-home"; fudo-home.url = "path:/state/nixops/fudo-home";
fudo-pkgs.url = "path:/state/nixops/fudo-pkgs";
fudo-secrets.url = "path:/state/secrets"; fudo-secrets.url = "path:/state/secrets";
}; };
outputs = { self, nixpkgs, fudo-secrets, fudo-home, ... }: { outputs = { self, nixpkgs, fudo-home, fudo-pkgs, fudo-secrets, ... }: {
nixosConfigurations = let nixosConfigurations = let
lib = nixpkgs.lib; lib = nixpkgs.lib;
hostlib = import ./lib/hosts.nix { inherit lib; }; hostlib = import ./lib/hosts.nix { inherit lib; };
hosts = lib.filterAttrs (hostname: hostOpts: nixos-hosts = lib.filterAttrs (hostname: hostOpts:
hostOpts.nixos-system) (hostlib.base-host-config ./config/hosts); hostOpts.nixos-system) (hostlib.base-host-config ./config/hosts);
build-timestamp = self.sourceInfo.lastModified; build-timestamp = self.sourceInfo.lastModified;
in lib.mapAttrs (hostname: hostOpts: let
pkgs = import nixpkgs { pkgs-for = arch: import nixpkgs {
system = hostOpts.arch; system = arch;
config = { config = {
allowUnfree = true; allowUnfree = true;
permittedInsecurePackages = [ permittedInsecurePackages = [
@ -30,20 +32,43 @@
]; ];
}; };
overlays = [ overlays = [
(import ./fudo-pkgs/overlay.nix) fudo-pkgs.overlay
(import ./lib/overlay.nix) (import ./lib/overlay.nix)
]; ];
}; };
in lib.nixosSystem { in lib.mapAttrs (hostname: hostOpts: let
system = hostOpts.arch; system = hostOpts.arch;
pkgs = pkgs-for system;
lib = pkgs.lib;
site = hostOpts.site;
domain = hostOpts.domain;
profile = hostOpts.profile;
build-seed =
builtins.readFile fudo-secrets.build-seed;
in nixpkgs.lib.nixosSystem {
inherit system;
modules = [ modules = let
config-path = ./config;
in [
fudo-home.nixosModule fudo-home.nixosModule
fudo-secrets.nixosModule fudo-secrets.nixosModule
(import ./initialize.nix { ./lib
inherit hostname lib pkgs build-timestamp fudo-secrets; ./config
(config-path + /hardware/${hostname}.nix)
(config-path + /host-config/${hostname}.nix)
(config-path + /profile-config/${profile}.nix)
(config-path + /domain-config/${domain}.nix)
(config-path + /site-config/${site}.nix)
({ ... }: {
config = {
instance = {
inherit hostname build-timestamp build-seed;
};
};
}) })
]; ];
}) hosts; }) nixos-hosts;
}; };
} }

View File

@ -2,8 +2,7 @@
with lib; with lib;
let let
# Get info on this host so we know what to load config-dir = ./config;
config-dir = ./. + "/config";
in { in {
imports = [ imports = [