From ac86ac1cdcd80a0a0b836a34b58ba367640f1766 Mon Sep 17 00:00:00 2001 From: iFargle Date: Sat, 16 Sep 2023 20:58:47 +0900 Subject: [PATCH] rpi4 images --- README.md | 2 +- flake.nix | 13 +++++++ nixos/hosts/nixos-rpi4-02/default.nix | 53 +++++++++++++++++++++++++++ nixos/hosts/nixos-rpi4-03/default.nix | 53 +++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 nixos/hosts/nixos-rpi4-02/default.nix create mode 100644 nixos/hosts/nixos-rpi4-03/default.nix diff --git a/README.md b/README.md index 7ab77edb..fefa6b5f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## NOTE: These configs expect this repo to be cloned to /etc/nixos/git/ ``` # First run as root: -git clone https://git.sysctl.io/albert/nix /etc/nixos/git +nix-shell -p git --run git clone https://git.sysctl.io/albert/nix /etc/nixos/git ln -s /etc/nixos/git/flake.nix /etc/nixos/flake.nix nixos-rebuild switch --flake '/etc/nixos#' mkdir /nix/var/nix/profiles/per-user/ diff --git a/flake.nix b/flake.nix index f7bf5acf..fa78cf5e 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,10 @@ { hostname = "nixos-framework"; username = "albert"; desktop = "hyprland"; gpu = "amd"; theme = "gruvbox"; }; nixos-rpi4-01 = libx.mkHost { hostname = "nixos-rpi4-01"; username = "albert"; platform = "aarch64-linux"; }; + nixos-rpi4-02 = libx.mkHost + { hostname = "nixos-rpi4-02"; username = "albert"; platform = "aarch64-linux"; }; + nixos-rpi4-03 = libx.mkHost + { hostname = "nixos-rpi4-03"; username = "albert"; platform = "aarch64-linux"; }; }; homeConfigurations = { "albert@nixos-laptop" = libx.mkHome @@ -33,6 +37,15 @@ { hostname = "nixos-framework"; username = "albert"; desktop = "hyprland"; theme = "gruvbox"; }; "albert@nixos-rpi4-01" = libx.mkHome { hostname = "nixos-rpi4-01"; username = "albert"; platform = "aarch64-linux"; }; + "albert@nixos-rpi4-02" = libx.mkHome + { hostname = "nixos-rpi4-01"; username = "albert"; platform = "aarch64-linux"; }; + "albert@nixos-rpi4-03" = libx.mkHome + { hostname = "nixos-rpi4-01"; username = "albert"; platform = "aarch64-linux"; }; + }; + images = { + nixos-rpi4-01 = nixosConfigurations.nixos-rpi4-01.config.system.build.sdImage; + nixos-rpi4-02 = nixosConfigurations.nixos-rpi4-02.config.system.build.sdImage; + nixos-rpi4-03 = nixosConfigurations.nixos-rpi4-03.config.system.build.sdImage; }; }; } \ No newline at end of file diff --git a/nixos/hosts/nixos-rpi4-02/default.nix b/nixos/hosts/nixos-rpi4-02/default.nix new file mode 100644 index 00000000..2ecd2162 --- /dev/null +++ b/nixos/hosts/nixos-rpi4-02/default.nix @@ -0,0 +1,53 @@ +# 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 = [ + (modulesPath + "/installer/scan/not-detected.nix") + + ]; + ##################################################################################### + # 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 = "nixos-rpi4-02"; + ##################################################################################### + # END hardware config + ##################################################################################### + + # Generic Tailscale configs are in /nixos/common/services/tailscale.nix + # Set up the secrets file: + sops.secrets.nixos-rpi4-01_tailscale_key = { + owner = "root"; + sopsFile = ../../../secrets/tailscale.yaml; + restartUnits = [ + "tailscaled.service" + "tailscaled-autoconnect.service" + ]; + }; + services.tailscale.authKeyFile = "/run/secrets/nixos-rpi4-02_tailscale_key"; + services.tailscale.extraUpFlags = [ "--advertise-exit-node" ]; + boot.kernel.sysctl = { "net.ipv4.ip_forward" = true; }; + + # Temporary + networking.firewall.allowedTCPPorts = [ 22 ]; +} \ No newline at end of file diff --git a/nixos/hosts/nixos-rpi4-03/default.nix b/nixos/hosts/nixos-rpi4-03/default.nix new file mode 100644 index 00000000..1f23f149 --- /dev/null +++ b/nixos/hosts/nixos-rpi4-03/default.nix @@ -0,0 +1,53 @@ +# 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 = [ + (modulesPath + "/installer/scan/not-detected.nix") + + ]; + ##################################################################################### + # 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 = "nixos-rpi4-03"; + ##################################################################################### + # END hardware config + ##################################################################################### + + # Generic Tailscale configs are in /nixos/common/services/tailscale.nix + # Set up the secrets file: + sops.secrets.nixos-rpi4-01_tailscale_key = { + owner = "root"; + sopsFile = ../../../secrets/tailscale.yaml; + restartUnits = [ + "tailscaled.service" + "tailscaled-autoconnect.service" + ]; + }; + services.tailscale.authKeyFile = "/run/secrets/nixos-rpi4-03_tailscale_key"; + services.tailscale.extraUpFlags = [ "--advertise-exit-node" ]; + boot.kernel.sysctl = { "net.ipv4.ip_forward" = true; }; + + # Temporary + networking.firewall.allowedTCPPorts = [ 22 ]; +} \ No newline at end of file