diff --git a/machines/default.nix b/machines/default.nix index 9a0c0c8..c32a0b4 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -25,11 +25,6 @@ flake-utils.lib.eachDefaultSystem (system: let ''; }; - isRaspberryPi = lib.mkOption { - default = false; - type = lib.types.bool; - }; - nixosModule = lib.mkOption { default = {...}: {}; type = lib.types.anything; diff --git a/machines/warwick/default.nix b/machines/warwick/default.nix index ac0caaa..0035e27 100644 --- a/machines/warwick/default.nix +++ b/machines/warwick/default.nix @@ -1,16 +1,21 @@ { machines.warwick = { arch = "aarch64-linux"; - isRaspberryPi = true; facterReportPath = ./facter.json; - nixosModule.lab = { - storage.profile = "pi"; - monitoring.server.enable = true; + nixosModule = {inputs, ...}: { + imports = [inputs.nixos-hardware.nixosModules.raspberry-pi-4]; - tailscale = { - advertiseExitNode = true; - enable = true; + config = { + lab = { + storage.profile = "pi"; + monitoring.server.enable = true; + + tailscale = { + advertiseExitNode = true; + enable = true; + }; + }; }; }; }; diff --git a/modules/default.nix b/modules/default.nix index a595904..99e0605 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,28 +1,26 @@ { self, pkgs, - config, lib, inputs, machine, + config, ... }: { - imports = - [ - ./storage.nix - ./backups.nix - ./networking - ./data-sharing.nix - ./monitoring - ./k3s - ./tailscale.nix - machine.nixosModule - inputs.disko.nixosModules.disko - inputs.sops-nix.nixosModules.sops - inputs.nix-snapshotter.nixosModules.nix-snapshotter - inputs.nixos-facter-modules.nixosModules.facter - ] - ++ lib.lists.optional (machine.isRaspberryPi) inputs.nixos-hardware.nixosModules.raspberry-pi-4; + imports = [ + ./storage.nix + ./backups.nix + ./networking + ./data-sharing.nix + ./monitoring + ./k3s + ./tailscale.nix + ./facter.nix + machine.nixosModule + inputs.disko.nixosModules.disko + inputs.sops-nix.nixosModules.sops + inputs.nix-snapshotter.nixosModules.nix-snapshotter + ]; config = { time.timeZone = "Europe/Amsterdam"; @@ -107,7 +105,7 @@ fastfetch ]; - boot = lib.mkIf (! machine.isRaspberryPi) { + boot = lib.mkIf (! config.facter.lab.isRaspberryPi) { loader = { systemd-boot.enable = lib.mkDefault true; efi.canTouchEfiVariables = true; diff --git a/modules/facter.nix b/modules/facter.nix new file mode 100644 index 0000000..2ee214d --- /dev/null +++ b/modules/facter.nix @@ -0,0 +1,15 @@ +{ + inputs, + lib, + config, + ... +}: { + imports = [inputs.nixos-facter-modules.nixosModules.facter]; + + options.facter.lab = { + isRaspberryPi = lib.mkOption { + type = lib.types.bool; + default = config.facter.report.system == "aarch64-linux"; + }; + }; +} diff --git a/modules/networking/default.nix b/modules/networking/default.nix index 0f235cc..ef68c4e 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -1,5 +1,6 @@ { lib, + config, machine, ... }: { @@ -16,7 +17,7 @@ enable = true; networks = lib.attrsets.mergeAttrsList [ - (lib.optionalAttrs (! machine.isRaspberryPi) { + (lib.optionalAttrs (! config.facter.lab.isRaspberryPi) { "30-main-nic" = { matchConfig.Name = "en*"; @@ -25,7 +26,7 @@ }; }; }) - (lib.optionalAttrs machine.isRaspberryPi { + (lib.optionalAttrs config.facter.lab.isRaspberryPi { "30-main-nic" = { matchConfig.Name = "end*"; networkConfig = {