cleanup more nix code

This commit is contained in:
Pim Kunis 2024-04-13 16:06:35 +02:00
parent 3b7c72f326
commit 6b9fffb022
54 changed files with 49 additions and 96 deletions

View file

@ -13,7 +13,7 @@ in
specialArgs = { inherit nixpkgs-unstable machines machine dns agenix nixos-hardware kubenix disko; }; specialArgs = { inherit nixpkgs-unstable machines machine dns agenix nixos-hardware kubenix disko; };
modules = [ modules = [
../. ../configuration.nix
{ networking.hostName = name; } { networking.hostName = name; }
{ {
nixpkgs.overlays = [ nixpkgs.overlays = [

View file

@ -39,14 +39,14 @@
let let
hostSystem = "x86_64-linux"; hostSystem = "x86_64-linux";
hostPkgs = import nixpkgs { system = hostSystem; }; hostPkgs = import nixpkgs { system = hostSystem; };
machines = (hostPkgs.lib.modules.evalModules { modules = [ (import ./nix/machines) ]; }).config.machines; machines = (hostPkgs.lib.modules.evalModules { modules = [ (import ./machines) ]; }).config.machines;
in in
flake-utils.lib.meld (inputs // { inherit hostPkgs machines; }) [ flake-utils.lib.meld (inputs // { inherit hostPkgs machines; }) [
./nix/flake/scripts ./flake-parts/scripts
./nix/flake/checks.nix ./flake-parts/checks.nix
./nix/flake/deploy.nix ./flake-parts/deploy.nix
./nix/flake/nixos.nix ./flake-parts/nixos.nix
./nix/flake/kubenix ./flake-parts/kubenix
] // (flake-utils.lib.eachDefaultSystem (system: { ] // (flake-utils.lib.eachDefaultSystem (system: {
formatter = nixpkgs.legacyPackages.${system}.nixfmt; formatter = nixpkgs.legacyPackages.${system}.nixfmt;
})); }));

View file

@ -5,7 +5,6 @@
nixosModule.lab = { nixosModule.lab = {
backups.enable = true; backups.enable = true;
data-sharing.enable = true; data-sharing.enable = true;
networking.dmz.allowConnectivity = true;
storage = { storage = {
osDisk = "/dev/sda"; osDisk = "/dev/sda";

View file

@ -18,10 +18,10 @@ let
- path: ${cfg.repoLocation} - path: ${cfg.repoLocation}
label: nfs label: nfs
- path: ssh://s6969ym3@s6969ym3.repo.borgbase.com/./repo - path: ssh://s6969ym3@s6969ym3.repo.borgbase.com/./repo
label: ec2 label: borgbase
exclude_patterns: exclude_patterns:
- ${cfg.snapshotLocation}/media - ${cfg.snapshotLocation}/media
ssh_command: "${pkgs.openssh}/bin/ssh -i ${config.age.secrets."ec2_borg_server.pem".path} -o StrictHostKeychecking=no" ssh_command: "${pkgs.openssh}/bin/ssh -i ${config.age.secrets."borgbase.pem".path} -o StrictHostKeychecking=no"
keep_daily: 7 keep_daily: 7
keep_weekly: 4 keep_weekly: 4
keep_monthly: 6 keep_monthly: 6
@ -123,7 +123,7 @@ in
age.secrets = { age.secrets = {
"database_passwords.env".file = ../secrets/database_passwords.env.age; "database_passwords.env".file = ../secrets/database_passwords.env.age;
"borg_passphrase".file = ../secrets/borg_passphrase.age; "borg_passphrase".file = ../secrets/borg_passphrase.age;
"ec2_borg_server.pem".file = ../secrets/ec2_borg_server.pem.age; "borgbase.pem".file = ../secrets/borgbase.pem.age;
}; };
}; };
} }

View file

@ -0,0 +1,38 @@
{ lib, machine, ... }: {
config = {
networking = {
domain = "dmz";
nftables.enable = true;
useDHCP = false;
firewall = {
enable = true;
};
};
systemd.network = {
enable = true;
networks = lib.attrsets.mergeAttrsList [
(lib.optionalAttrs (! machine.isRaspberryPi) {
"30-main-nic" = {
matchConfig.Name = "en*";
networkConfig = {
DHCP = "yes";
};
};
})
(lib.optionalAttrs machine.isRaspberryPi {
"30-main-nic" = {
matchConfig.Name = "end*";
networkConfig = {
IPv6AcceptRA = true;
DHCP = "yes";
};
};
})
];
};
};
}

View file

@ -1,84 +0,0 @@
{ lib, config, machine, ... }:
let cfg = config.lab.networking;
in {
options.lab.networking = {
dmz = {
allowConnectivity = lib.mkOption {
default = false;
type = lib.types.bool;
description = ''
Whether to allow networking on the DMZ bridge interface.
'';
};
bridgeName = lib.mkOption {
default = "bridgedmz";
type = lib.types.str;
description = ''
The name of the DMZ bridge.
'';
};
};
staticNetworking = lib.mkOption {
default = false;
type = lib.types.bool;
description = ''
Whether this machine has static networking configuration applied.
Routing is prepopulated, but IP addresses have to be set.
'';
};
staticIPv4 = lib.mkOption {
type = lib.types.str;
description = ''
Static IPv4 address for the machine.
'';
};
staticIPv6 = lib.mkOption {
type = lib.types.str;
description = ''
Static IPv6 address for the machine.
'';
};
};
config = {
networking = {
domain = "dmz";
nftables.enable = true;
useDHCP = false;
firewall = {
enable = true;
checkReversePath = false;
};
};
systemd.network = {
enable = true;
networks = lib.attrsets.mergeAttrsList [
(lib.optionalAttrs (! machine.isRaspberryPi) {
"30-main-nic" = {
matchConfig.Name = "en*";
networkConfig = {
DHCP = "yes";
};
};
})
(lib.optionalAttrs machine.isRaspberryPi {
"30-main-nic" = {
matchConfig.Name = "end*";
networkConfig = {
IPv6AcceptRA = true;
DHCP = "yes";
};
};
})
];
};
};
}

View file

@ -10,7 +10,7 @@ let
encryptedFileNames = [ encryptedFileNames = [
"database_passwords.env.age" "database_passwords.env.age"
"borg_passphrase.age" "borg_passphrase.age"
"ec2_borg_server.pem.age" "borgbase.pem.age"
]; ];
machinePublicKeys = [ machinePublicKeys = [