From 680cd54a0b056a8fb1c765e56e875cdf3d8c64e1 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Fri, 3 Jan 2025 15:43:05 -0500 Subject: [PATCH 1/3] Setup a Pi 3, fix hetznix02 This focuses on being able to build a SD card image for a Pi 3 named raspberry and the cofig it contains. As part of making that happen, I found that I had totally messed up hetznix02's hardware config. I fixed this as it is where I am builiding the SD image. This work also resulted in adding a "volume" to hetznix02 and moving `/nix` onto it. --- flake.nix | 4 +++ modules/hosts/nixos/hetznix02/disk-config.nix | 25 +++++++++++++-- .../hetznix02/hardware-configuration.nix | 27 ++++++++++------ modules/hosts/nixos/raspberry/default.nix | 31 +++++++++++++++++++ modules/hosts/nixos/raspberry/home-gene.nix | 4 +++ 5 files changed, 79 insertions(+), 12 deletions(-) create mode 100644 modules/hosts/nixos/raspberry/default.nix create mode 100644 modules/hosts/nixos/raspberry/home-gene.nix diff --git a/flake.nix b/flake.nix index a43a6aa..75ce579 100644 --- a/flake.nix +++ b/flake.nix @@ -159,6 +159,10 @@ inputs.nixos-hardware.nixosModules.dell-xps-13-9360 ]; }; + raspberry = localLib.mkNixosHost { + system = "aarch64-linux"; + hostname = "raspberry"; + }; }; # end nixosConfigurations # Home Manager (only) users diff --git a/modules/hosts/nixos/hetznix02/disk-config.nix b/modules/hosts/nixos/hetznix02/disk-config.nix index 76a07cd..bf22bdd 100644 --- a/modules/hosts/nixos/hetznix02/disk-config.nix +++ b/modules/hosts/nixos/hetznix02/disk-config.nix @@ -2,8 +2,8 @@ { lib, ... }: { disko.devices = { - disk.disk1 = { - device = lib.mkDefault "/dev/sda"; + disk.primary = { + device = lib.mkDefault "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_51838383"; type = "disk"; content = { type = "gpt"; @@ -38,5 +38,26 @@ }; }; }; + disk.volume1 = { + device = lib.mkDefault "/dev/disk/by-id/scsi-0HC_Volume_101886924"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + nix = { + name = "nix"; + size = "100%"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/nix"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; }; } diff --git a/modules/hosts/nixos/hetznix02/hardware-configuration.nix b/modules/hosts/nixos/hetznix02/hardware-configuration.nix index 0d6440a..d13bb36 100644 --- a/modules/hosts/nixos/hetznix02/hardware-configuration.nix +++ b/modules/hosts/nixos/hetznix02/hardware-configuration.nix @@ -10,23 +10,30 @@ boot = { initrd = { - availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" ]; - kernelModules = [ "nvme" ]; + availableKernelModules = [ "xhci_pci" "virtio_scsi" "sr_mod" ]; + kernelModules = [ ]; }; kernelModules = [ ]; extraModulePackages = [ ]; }; - fileSystems = { - "/boot" = { - device = lib.mkForce "/dev/disk/by-uuid/D005-6C65"; - fsType = "vfat"; - }; - "/" = { - device = lib.mkForce "/dev/sda1"; + fileSystems."/" = + { device = "/dev/disk/by-partlabel/disk-primary-root"; fsType = "ext4"; }; - }; + + fileSystems."/boot" = + { device = "/dev/disk/by-partlabel/disk-primary-ESP"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-partlabel/disk-volume1-nix"; + fsType = "ext4"; + }; + + swapDevices = [ ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/modules/hosts/nixos/raspberry/default.nix b/modules/hosts/nixos/raspberry/default.nix new file mode 100644 index 0000000..d0db09b --- /dev/null +++ b/modules/hosts/nixos/raspberry/default.nix @@ -0,0 +1,31 @@ +{ inputs, username, ... }: { + imports = [ + # SD card image + "${inputs.nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" + ]; + + system.stateVersion = "24.11"; + + networking.wireless = { + enable = true; + networks = { + # Public networks + "Gallery Row-GuestWiFi" = {}; + "LocalTies Guest" = { + psk = "DrinkLocal!"; + }; + }; + }; + + users.users.${username} = { + isNormalUser = true; + description = "Gene Liverman"; + extraGroups = [ "networkmanager" "wheel" ]; + linger = true; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFvLaPTfG3r+bcbI6DV4l69UgJjnwmZNCQk79HXyf1Pt gene@rainbow-planet" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIp42X5DZ713+bgbOO+GXROufUFdxWo7NjJbGQ285x3N gene.liverman@ltnglobal.com" + ]; + }; +} + diff --git a/modules/hosts/nixos/raspberry/home-gene.nix b/modules/hosts/nixos/raspberry/home-gene.nix new file mode 100644 index 0000000..422b341 --- /dev/null +++ b/modules/hosts/nixos/raspberry/home-gene.nix @@ -0,0 +1,4 @@ +{ ... }: { + home.stateVersion = "24.11"; +} + From 65206b78f781c0f8603e45c1538d2b7970ae8674 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Sat, 4 Jan 2025 01:39:14 -0500 Subject: [PATCH 2/3] Add hardware config for Pi 3 --- flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flake.nix b/flake.nix index 75ce579..c06734b 100644 --- a/flake.nix +++ b/flake.nix @@ -162,6 +162,9 @@ raspberry = localLib.mkNixosHost { system = "aarch64-linux"; hostname = "raspberry"; + additionalModules = [ + inputs.nixos-hardware.nixosModules.raspberry-pi-3 + ]; }; }; # end nixosConfigurations From 122137b25ec6a5c772e9ac5e55a32dea61f0cb43 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 7 Jan 2025 11:11:40 -0500 Subject: [PATCH 3/3] Add initial doc for installing new systems --- INSTALLATION.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 INSTALLATION.md diff --git a/INSTALLATION.md b/INSTALLATION.md new file mode 100644 index 0000000..f41aaa7 --- /dev/null +++ b/INSTALLATION.md @@ -0,0 +1,16 @@ +## Installing on aarch64-linux + +1. set password +2. create a temp ubuntu server if this is the first aarch64 host and ssh into it: `ssh -o UserKnownHostsFile=/dev/null root@` +3. `curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install` +4. `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh` +5. Run these commands: + ```bash + read -s SSHPASS + export SSHPASS=$SSHPASS + export TARGET_HOST=hetznix02 + export DOTS_BRANCH=pi-setup + nix --extra-experimental-features 'flakes nix-command' run github:nix-community/nixos-anywhere -- --env-password --flake github:genebean/dots/${DOTS_BRANCH}#${TARGET_HOST} --target-host nixos@195.201.224.89 + ``` +6. Delete temp server +7. \ No newline at end of file