From ce1c589651e50d0aa72d93ecb28a4f50349b98c5 Mon Sep 17 00:00:00 2001 From: iFargle Date: Wed, 13 Dec 2023 14:17:46 +0900 Subject: [PATCH] Prep for new rpi images --- flake.nix | 8 ++- nixos/hosts/backups-rpi4/default.nix | 66 ++++++++++++++++++++++++ nixos/hosts/framework-server/default.nix | 1 - nixos/hosts/nixos-rpi4-01/default.nix | 20 +++++-- nixos/hosts/nixos-rpi4-02/default.nix | 17 +++++- nixos/hosts/nixos-rpi4-03/default.nix | 16 +++++- nixos/hosts/piaware-rpi4/default.nix | 66 ++++++++++++++++++++++++ 7 files changed, 187 insertions(+), 7 deletions(-) create mode 100644 nixos/hosts/backups-rpi4/default.nix create mode 100644 nixos/hosts/piaware-rpi4/default.nix diff --git a/flake.nix b/flake.nix index 6499144a..2f084b9b 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,9 @@ framework-server = libx.mkHost { hostname = "framework-server"; }; # nixos-desktop = libx.mkHost { hostname = "nixos-desktop"; desktop = "gnome"; gpu = "nvidia"; }; # nixos-framework = libx.mkHost { hostname = "nixos-framework"; desktop = "hyprland"; gpu = "amd"; theme = "green"; }; - nixos-rpi4-01 = libx.mkHost { hostname = "nixos-rpi4-01"; platform = "aarch64-linux"; }; + backups-rpi4 = libx.deploy { hostname = "backups-rpi4"; platform = "aarch64-linux"; }; + piaware-rpi4 = libx.deploy { hostname = "piaware-rpi4"; platform = "aarch64-linux"; }; + nixos-rpi4-01 = libx.deploy { hostname = "nixos-rpi4-01"; platform = "aarch64-linux"; }; nixos-rpi4-02 = libx.mkHost { hostname = "nixos-rpi4-02"; platform = "aarch64-linux"; }; nixos-rpi4-03 = libx.mkHost { hostname = "nixos-rpi4-03"; platform = "aarch64-linux"; }; }; @@ -54,6 +56,8 @@ "albert@framework-server" = libx.mkHome { hostname = "framework-server"; }; # "albert@nixos-desktop" = libx.mkHome { hostname = "nixos-desktop"; desktop = "gnome"; }; # "albert@nixos-framework" = libx.mkHome { hostname = "nixos-framework"; desktop = "hyprland"; theme = "green"; }; + "albert@backups-rpi4" = libx.mkHome { hostname = "backups-rpi4"; platform = "aarch64-linux"; type = "small"; }; + "albert@piaware-rpi4" = libx.mkHome { hostname = "piaware-rpi4"; platform = "aarch64-linux"; type = "small"; }; "albert@nixos-rpi4-01" = libx.mkHome { hostname = "nixos-rpi4-01"; platform = "aarch64-linux"; type = "small"; }; "albert@nixos-rpi4-02" = libx.mkHome { hostname = "nixos-rpi4-02"; platform = "aarch64-linux"; type = "small"; }; "albert@nixos-rpi4-03" = libx.mkHome { hostname = "nixos-rpi4-03"; platform = "aarch64-linux"; type = "small"; }; @@ -64,6 +68,8 @@ framework-server = libx.deploy { hostname = "framework-server"; }; # nixos-desktop = libx.deploy { hostname = "nixos-desktop"; }; # nixos-framework = libx.deploy { hostname = "nixos-framework"; }; + backups-rpi4 = libx.deploy { hostname = "backups-rpi4"; platform = "aarch64-linux"; }; + piaware-rpi4 = libx.deploy { hostname = "piaware-rpi4"; platform = "aarch64-linux"; }; nixos-rpi4-01 = libx.deploy { hostname = "nixos-rpi4-01"; platform = "aarch64-linux"; }; nixos-rpi4-02 = libx.deploy { hostname = "nixos-rpi4-02"; platform = "aarch64-linux"; }; nixos-rpi4-03 = libx.deploy { hostname = "nixos-rpi4-03"; platform = "aarch64-linux"; }; diff --git a/nixos/hosts/backups-rpi4/default.nix b/nixos/hosts/backups-rpi4/default.nix new file mode 100644 index 00000000..5bd16978 --- /dev/null +++ b/nixos/hosts/backups-rpi4/default.nix @@ -0,0 +1,66 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ inputs, config, lib, pkgs, modulesPath, ... }: { + imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-4 + (modulesPath + "/installer/scan/not-detected.nix") + ]; + # Enable distributed Builds + nix.distributedBuilds = true; + + hardware = { + raspberry-pi."4".apply-overlays-dtmerge.enable = true; + deviceTree = { + enable = true; + filter = "*rpi-4-*.dtb"; + }; + }; + console.enable = false; + environment.systemPackages = with pkgs; [ + libraspberrypi + raspberrypi-eeprom + ]; + + ##################################################################################### + # BEGIN hardware config + ##################################################################################### + + # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) + boot.loader.grub.enable = false; + # Enables the generation of /boot/extlinux/extlinux.conf + boot.loader.generic-extlinux-compatible.enable = true; + + boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + networking.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + networking.hostName = "backups-rpi4"; + ##################################################################################### + # END hardware config + ##################################################################################### + + # Generic Tailscale configs are in /nixos/common/services/tailscale.nix + # Set up the secrets file: + sops.secrets."tailscale_keys/backups-rpi4" = { + owner = "root"; + sopsFile = ../../../secrets/tailscale.yaml; + restartUnits = [ + "tailscaled.service" + "tailscaled-autoconnect.service" + ]; + }; + services.tailscale.authKeyFile = "/run/secrets/tailscale_keys/backups-rpi4"; + services.tailscale.extraUpFlags = [ "--advertise-exit-node" ]; + boot.kernel.sysctl = { "net.ipv4.ip_forward" = true; }; +} \ No newline at end of file diff --git a/nixos/hosts/framework-server/default.nix b/nixos/hosts/framework-server/default.nix index a616a688..5d94f2a9 100644 --- a/nixos/hosts/framework-server/default.nix +++ b/nixos/hosts/framework-server/default.nix @@ -1,6 +1,5 @@ { inputs, config, lib, pkgs, modulesPath, desktop, username, platform, ... }: { imports = [ - # inputs.nixos-hardware.nixosModules.framework-13-inch-13th-gen-intel inputs.nixos-hardware.nixosModules.framework-13th-gen-intel (modulesPath + "/installer/scan/not-detected.nix") ./disks.nix diff --git a/nixos/hosts/nixos-rpi4-01/default.nix b/nixos/hosts/nixos-rpi4-01/default.nix index 1f97177a..fc96981e 100644 --- a/nixos/hosts/nixos-rpi4-01/default.nix +++ b/nixos/hosts/nixos-rpi4-01/default.nix @@ -1,13 +1,27 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: { - imports = [ +{ inputs, config, lib, pkgs, modulesPath, ... }: { + imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-4 (modulesPath + "/installer/scan/not-detected.nix") - ]; # Enable distributed Builds nix.distributedBuilds = true; + + hardware = { + raspberry-pi."4".apply-overlays-dtmerge.enable = true; + deviceTree = { + enable = true; + filter = "*rpi-4-*.dtb"; + }; + }; + console.enable = false; + environment.systemPackages = with pkgs; [ + libraspberrypi + raspberrypi-eeprom + ]; + ##################################################################################### # BEGIN hardware config ##################################################################################### diff --git a/nixos/hosts/nixos-rpi4-02/default.nix b/nixos/hosts/nixos-rpi4-02/default.nix index 60f380c8..3273816c 100644 --- a/nixos/hosts/nixos-rpi4-02/default.nix +++ b/nixos/hosts/nixos-rpi4-02/default.nix @@ -1,12 +1,27 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: { +{ inputs, config, lib, pkgs, modulesPath, ... }: { imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-4 (modulesPath + "/installer/scan/not-detected.nix") ]; # Enable distributed Builds nix.distributedBuilds = true; + + hardware = { + raspberry-pi."4".apply-overlays-dtmerge.enable = true; + deviceTree = { + enable = true; + filter = "*rpi-4-*.dtb"; + }; + }; + console.enable = false; + environment.systemPackages = with pkgs; [ + libraspberrypi + raspberrypi-eeprom + ]; + ##################################################################################### # BEGIN hardware config ##################################################################################### diff --git a/nixos/hosts/nixos-rpi4-03/default.nix b/nixos/hosts/nixos-rpi4-03/default.nix index 5ced2a78..61971cb4 100644 --- a/nixos/hosts/nixos-rpi4-03/default.nix +++ b/nixos/hosts/nixos-rpi4-03/default.nix @@ -1,13 +1,27 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: { +{ inputs, config, lib, pkgs, modulesPath, ... }: { imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-4 (modulesPath + "/installer/scan/not-detected.nix") ]; # Enable distributed Builds nix.distributedBuilds = true; + hardware = { + raspberry-pi."4".apply-overlays-dtmerge.enable = true; + deviceTree = { + enable = true; + filter = "*rpi-4-*.dtb"; + }; + }; + console.enable = false; + environment.systemPackages = with pkgs; [ + libraspberrypi + raspberrypi-eeprom + ]; + ##################################################################################### # BEGIN hardware config ##################################################################################### diff --git a/nixos/hosts/piaware-rpi4/default.nix b/nixos/hosts/piaware-rpi4/default.nix new file mode 100644 index 00000000..921fea4f --- /dev/null +++ b/nixos/hosts/piaware-rpi4/default.nix @@ -0,0 +1,66 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ inputs, config, lib, pkgs, modulesPath, ... }: { + imports = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-4 + (modulesPath + "/installer/scan/not-detected.nix") + ]; + # Enable distributed Builds + nix.distributedBuilds = true; + + hardware = { + raspberry-pi."4".apply-overlays-dtmerge.enable = true; + deviceTree = { + enable = true; + filter = "*rpi-4-*.dtb"; + }; + }; + console.enable = false; + environment.systemPackages = with pkgs; [ + libraspberrypi + raspberrypi-eeprom + ]; + + ##################################################################################### + # BEGIN hardware config + ##################################################################################### + + # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) + boot.loader.grub.enable = false; + # Enables the generation of /boot/extlinux/extlinux.conf + boot.loader.generic-extlinux-compatible.enable = true; + + boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + networking.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + networking.hostName = "piaware-rpi4"; + ##################################################################################### + # END hardware config + ##################################################################################### + + # Generic Tailscale configs are in /nixos/common/services/tailscale.nix + # Set up the secrets file: + sops.secrets."tailscale_keys/piaware-rpi4" = { + owner = "root"; + sopsFile = ../../../secrets/tailscale.yaml; + restartUnits = [ + "tailscaled.service" + "tailscaled-autoconnect.service" + ]; + }; + services.tailscale.authKeyFile = "/run/secrets/tailscale_keys/piaware-rpi4"; + services.tailscale.extraUpFlags = [ "--advertise-exit-node" ]; + boot.kernel.sysctl = { "net.ipv4.ip_forward" = true; }; +} \ No newline at end of file