From db43a2090fec702d26356a4fda83ac94da238928 Mon Sep 17 00:00:00 2001 From: Dustin Frisch Date: Thu, 14 Nov 2024 15:22:38 +0100 Subject: [PATCH] More progress --- client/default.nix | 11 +++++++++ clients.nix | 15 +++++++++++++ flake.nix | 24 +++++++++++++++----- machines/nfs/nfs.nix | 53 ++++++++++++++++++++++++++++++++++++++++++++ sops-config.nix | 2 +- 5 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 clients.nix diff --git a/client/default.nix b/client/default.nix index 734acdd..b67194b 100644 --- a/client/default.nix +++ b/client/default.nix @@ -1,7 +1,12 @@ +id: + { lib, ... }: with lib; +let + client = (import ../clients.nix).${id}; +in { imports = [ ./hardware.nix @@ -14,9 +19,15 @@ with lib; deployment = { targetHost = "10.32.45.150"; + tags = [ "client" ]; + }; + + _module.args = { + inherit id client; }; networking = { + hostName = mkForce "client-${id}"; useDHCP = mkForce true; }; diff --git a/clients.nix b/clients.nix new file mode 100644 index 0000000..6c14424 --- /dev/null +++ b/clients.nix @@ -0,0 +1,15 @@ +{ + "01" = { + mac = ""; + }; + "02" = { + mac = ""; + }; + "03" = { + mac = ""; + }; + "04" = { + mac = ""; + }; +} + diff --git a/flake.nix b/flake.nix index 57ffeae..0ca887a 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,8 @@ # List of all machine names as defined in the machines directory machines = builtins.attrNames (builtins.readDir ./machines); + clients = builtins.attrNames (import ./clients.nix); + in { colmena = { @@ -76,15 +78,24 @@ deployment.replaceUnknownProfiles = false; }; + } - "client" = ./client; - - } // (builtins.listToAttrs (builtins.map + # Machines + // (builtins.listToAttrs (builtins.map (name: { inherit name; value = ./machines/${name}; }) - machines)); + machines)) + + # Clients + // (builtins.listToAttrs (builtins.map + (id: { + name = "client-${id}"; + value = (import ./client) id; + }) + clients)) + ; } // flake-utils.lib.eachDefaultSystem (system: { checks = { @@ -130,12 +141,13 @@ ''; }; - packages.disks = + packages.disks = let pkgs = nixpkgs.legacyPackages.${system}; hive = colmena.lib.makeHive self.outputs.colmena; - in pkgs.linkFarm "linuxlab-testing" (builtins.mapAttrs + in + pkgs.linkFarm "linuxlab-testing" (builtins.mapAttrs (_: node: node.config.system.build.diskoImages) hive.nodes); }); diff --git a/machines/nfs/nfs.nix b/machines/nfs/nfs.nix index ae7adb7..991b3ce 100644 --- a/machines/nfs/nfs.nix +++ b/machines/nfs/nfs.nix @@ -1,3 +1,7 @@ +{ pkgs, lib, ... }: + +with lib; + { services.nfs.server = { enable = true; @@ -9,5 +13,54 @@ networking.firewall.allowedTCPPorts = [ 2049 # NFSv4 ]; + + environment.systemPackages = with pkgs; [ + quota + ]; + + disko.devices = { + disk = genAttrs [ + "pci-0000:00:17.0-ata-1" + "pci-0000:00:17.0-ata-2" + "pci-0000:00:17.0-ata-3" + "pci-0000:00:17.0-ata-4" + ] + (path: { + type = "disk"; + device = "/dev/disk/by-path/${path}"; + content = { + type = "mdraid"; + name = "home"; + }; + }); + + mdadm = { + home = { + type = "mdadm"; + level = 5; + content = { + type = "gpt"; + partitions = { + primary = { + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/home"; + extraArgs = [ + "-Oquota" + "-Equotatype=usrquota" + ]; + mountOptions = [ + "defaults" + "quota" + ]; + }; + }; + }; + }; + }; + }; + }; } diff --git a/sops-config.nix b/sops-config.nix index a45b969..9f920c6 100644 --- a/sops-config.nix +++ b/sops-config.nix @@ -14,7 +14,7 @@ let }; hosts = { - "nfs" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIENsd6EdgIn5jhqXUEyPckoViHLLsYM2on/liwf1IO8p"; + "nfs" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMA+Q4wLe0AuZ8OC5BKJLrvmpKcy+6a8Iez9hCSVgtX8"; "ldap" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFhkh5L4jYl/i4E+lBVDppHcoiohR/gDricyV2wY/3Np"; "installer" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOrc58WlxYKaPNO1J8j8KQxOLJooc9fIxp6gZZoB4Y7o"; };