From 43087082c4a824628039fe99d8977d2c59a3e037 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Sat, 23 Nov 2024 04:06:04 -0500 Subject: [PATCH] Infini-STICK: resetup with disko --- hosts/Infini-STICK/default.nix | 4 +- hosts/Infini-STICK/disks.nix | 28 +++++ hosts/Infini-STICK/filesystems.nix | 49 -------- hosts/Infini-STICK/install.bash | 7 -- hosts/Infini-STICK/mount.bash | 35 ------ hosts/Infini-STICK/readme.org | 189 ----------------------------- hosts/Infini-STICK/reinstall.bash | 55 --------- hosts/Infini-STICK/setup.bash | 86 ------------- secrets/secrets.nix | 2 +- users/infinidoge/ssh-keys.nix | 2 +- 10 files changed, 32 insertions(+), 425 deletions(-) create mode 100644 hosts/Infini-STICK/disks.nix delete mode 100644 hosts/Infini-STICK/filesystems.nix delete mode 100755 hosts/Infini-STICK/install.bash delete mode 100755 hosts/Infini-STICK/mount.bash delete mode 100644 hosts/Infini-STICK/readme.org delete mode 100755 hosts/Infini-STICK/reinstall.bash delete mode 100755 hosts/Infini-STICK/setup.bash diff --git a/hosts/Infini-STICK/default.nix b/hosts/Infini-STICK/default.nix index ab76c6c..64e611a 100644 --- a/hosts/Infini-STICK/default.nix +++ b/hosts/Infini-STICK/default.nix @@ -1,11 +1,11 @@ { pkgs, ... }: { imports = [ ./hardware-configuration.nix - ./filesystems.nix + ./disks.nix ]; system.stateVersion = "24.11"; - networking.hostId = "06a3f197"; + networking.hostId = "deadbeef"; boot.kernelPackages = pkgs.linuxPackages; diff --git a/hosts/Infini-STICK/disks.nix b/hosts/Infini-STICK/disks.nix new file mode 100644 index 0000000..ebdc4be --- /dev/null +++ b/hosts/Infini-STICK/disks.nix @@ -0,0 +1,28 @@ +{ lib, ... }: +with lib.our.disko; +let + inherit (lib) genAttrs flip; +in +{ + disko.devices = { + nodev."/" = mkTmpfs "2G"; + disk.stick = mkDisk "some-usb-stick" { + partitions = { + boot = mkESP "64M" "/boot/efi"; + main = mkBtrfsPart "100%" "/media/main" { + subvolumes = mkBtrfsSubvols { + "/boot" = { }; + "/etc/ssh" = { }; + "/nix" = { }; + "/persist" = { }; + }; + }; + }; + }; + }; + + fileSystems = flip genAttrs (_: { neededForBoot = true; }) [ + "/persist" + "/etc/ssh" + ]; +} diff --git a/hosts/Infini-STICK/filesystems.nix b/hosts/Infini-STICK/filesystems.nix deleted file mode 100644 index cfa16a7..0000000 --- a/hosts/Infini-STICK/filesystems.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ ... }: - -let - uuid = uuid: "/dev/disk/by-uuid/${uuid}"; - commonOptions = [ "autodefrag" "noatime" "compress-force=zstd:1" ]; - - mkMain' = options: { - device = uuid "85d60c21-bc62-471e-b305-f7e26499adb3"; - fsType = "btrfs"; - options = commonOptions ++ options; - }; - mkMain = options: (mkMain' options) // { neededForBoot = true; }; -in -{ - environment.etc.crypttab.text = '' - vault UUID=8fe59989-cd9c-4142-bdf7-fc748cb56b34 - luks,noauto - ''; - - fileSystems = { - "/" = { - device = "root"; - fsType = "tmpfs"; - options = [ "defaults" "size=4G" "mode=755" ]; - }; - - "/media/main" = mkMain' [ ]; - "/media/storage" = { - device = uuid "B56A-F857"; - fsType = "exfat"; - options = [ "defaults" "noatime" ]; - }; - "/media/vault" = { - device = "/dev/mapper/vault"; - fsType = "ext4"; - options = [ "defaults" "noauto" ]; - }; - - "/persist" = mkMain [ "subvol=root" ]; - "/etc/ssh" = mkMain [ "subvol=root/etc/ssh" ]; - "/nix" = mkMain [ "subvol=nix" ]; - "/boot" = mkMain [ "subvol=boot" ]; - - "/boot/efi" = { - device = uuid "C167-F1F0"; - fsType = "vfat"; - neededForBoot = true; - }; - }; -} diff --git a/hosts/Infini-STICK/install.bash b/hosts/Infini-STICK/install.bash deleted file mode 100755 index e620d8a..0000000 --- a/hosts/Infini-STICK/install.bash +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -# [[file:readme.org::install][install]] -# [[file:readme.org::install][installing]] -echo "LOG: Installing NixOS" -sudo nixos-install --flake /etc/nixos#Infini-STICK --no-root-password -# installing ends here -# install ends here diff --git a/hosts/Infini-STICK/mount.bash b/hosts/Infini-STICK/mount.bash deleted file mode 100755 index 24fbc1a..0000000 --- a/hosts/Infini-STICK/mount.bash +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# [[file:readme.org::mount][mount]] -# [[file:readme.org::mount][boilerplate]] -DISK=$1 - -sudo mkdir -p /mnt -# boilerplate ends here - -# [[file:readme.org::mount][mount_check]] -if mountpoint -q -- "/mnt"; then - echo "ERROR: /mnt is a mounted filesystem, aborting" - exit 1 -fi -# mount_check ends here - -# [[file:readme.org::mount][mounting]] -echo "LOG: Mounting tmpfs" -sudo mount -t tmpfs root /mnt - -echo "LOG: - Mounting persistent directories" -sudo mkdir -p /mnt/persist /mnt/nix /mnt/boot -sudo mount -o subvol=root,autodefrag,noatime "${DISK}3" /mnt/persist -sudo mount -o subvol=nix,autodefrag,noatime "${DISK}3" /mnt/nix -sudo mount -o subvol=boot,autodefrag,noatime "${DISK}3" /mnt/boot - -echo "LOG: - - Mounting persistent subdirectories" -sudo mkdir -p /mnt/home /mnt/etc/ssh -sudo mount --bind /mnt/persist/home /mnt/home -sudo mount --bind /mnt/persist/etc/ssh /mnt/etc/ssh - -echo "LOG: - Mounting EFI System Partition" -sudo mkdir -p /mnt/boot/efi -sudo mount "${DISK}4" /mnt/boot/efi -# mounting ends here -# mount ends here diff --git a/hosts/Infini-STICK/readme.org b/hosts/Infini-STICK/readme.org deleted file mode 100644 index a2e7a5a..0000000 --- a/hosts/Infini-STICK/readme.org +++ /dev/null @@ -1,189 +0,0 @@ -#+TITLE: Infini-STICK Setup -#+AUTHOR: Infinidoge -#+OPTIONS: toc:nil -#+LaTeX_CLASS_OPTIONS: [12pt] -#+LATEX_HEADER: \usepackage[margin=1in]{geometry} - -* Partition Scheme - -| Position | Label | FS Type | Size | Type | -|----------+----------------+-------------+--------+-----------------------------| -| 0 | =storage= | =exfat= | 24.6GB | Generic Storage Partition | -| 1 | =vault= | =LUKS/ext4= | 3GB | Encrypted Storage Partition | -| 2 | =Infini-STICK= | =btrfs= | 33.3GB | Root Partition | -| 3 | =boot= | =vfat= | 511MB | EFI System Partition | - -* Configuration - -Setup with a wide array of hardware compatibility, specifically using the =portable= form defined in the =hardware/form= module. - -=Infini-STICK= currently lives on my SanDisk 3.2Gen1 64GB USB C/USB A flashdrive. - -* Setup Scripts - -#+NAME: full_install -#+BEGIN_SRC bash :tangle setup.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb -<> - -<> - -<> - -<> - -<> - -<> - -<> - -<> - -<> - -<> -#+END_SRC - -#+NAME: reinstall -#+BEGIN_SRC bash :tangle reinstall.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb -<> - -<> - -<> - -<> - -<> -#+END_SRC - -#+NAME: mount -#+BEGIN_SRC bash :tangle mount.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb -<> - -<> - -<> -#+END_SRC - -#+NAME: install -#+BEGIN_SRC bash :tangle install.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb -<> -#+END_SRC - -** Script Boilerplate - -#+NAME: boilerplate -#+BEGIN_SRC bash -DISK=$1 - -sudo mkdir -p /mnt -#+END_SRC - -#+NAME: mount_check -#+BEGIN_SRC bash -if mountpoint -q -- "/mnt"; then - echo "ERROR: /mnt is a mounted filesystem, aborting" - exit 1 -fi -#+END_SRC - -** Partitioning - -#+NAME: partitioning -#+BEGIN_SRC bash -echo "LOG: Partitioning $DISK" -sudo parted $DISK -- mktable gpt -sudo parted $DISK -s -- mkpart primary 0% 100% -sudo parted $DISK -s -- mkpart primary 40% 100% -sudo parted $DISK -s -- mkpart primary btrfs 45% 100% -sudo parted $DISK -s -- mkpart ESP fat32 -512MiB 100% -sudo parted $DISK -s -- set 4 esp on -#+END_SRC - -** Making Filesystems - -#+NAME: filesystems -#+BEGIN_SRC bash -echo "LOG: Making filesystems" -echo "- Making btrfs filesystem on ${DISK}1" -sudo mkfs.btrfs "${DISK}1" -L "Infini-STICK" -f -echo "- Making fat32 filesystem on ${DISK}2" -sudo mkfs.fat -F 32 -n boot "${DISK}2" -#+END_SRC - -** Making Subvolumes - -#+NAME: subvolumes -#+BEGIN_SRC bash -echo "LOG: Making subvolumes on ${DISK}1" -sudo mount "${DISK}1" /mnt -sudo btrfs subvolume create /mnt/root -sudo btrfs subvolume create /mnt/root/home -sudo mkdir -p /mnt/root/etc -sudo btrfs subvolume create /mnt/root/etc/nixos -sudo btrfs subvolume create /mnt/boot -sudo btrfs subvolume create /mnt/nix -sudo btrfs subvolume create /mnt/nix/store -sudo umount /mnt -#+END_SRC - -** Mounting Volumes - -#+NAME: mounting -#+BEGIN_SRC bash -echo "LOG: Mounting tmpfs" -sudo mount -t tmpfs root /mnt - -echo "LOG: - Mounting persistent directories" -sudo mkdir -p /mnt/persist /mnt/nix /mnt/boot -sudo mount -o subvol=root,autodefrag,noatime "${DISK}3" /mnt/persist -sudo mount -o subvol=nix,autodefrag,noatime "${DISK}3" /mnt/nix -sudo mount -o subvol=boot,autodefrag,noatime "${DISK}3" /mnt/boot - -echo "LOG: - - Mounting persistent subdirectories" -sudo mkdir -p /mnt/home /mnt/etc/ssh -sudo mount --bind /mnt/persist/home /mnt/home -sudo mount --bind /mnt/persist/etc/ssh /mnt/etc/ssh - -echo "LOG: - Mounting EFI System Partition" -sudo mkdir -p /mnt/boot/efi -sudo mount "${DISK}4" /mnt/boot/efi -#+END_SRC - -** Installing - -#+NAME: installing -#+BEGIN_SRC bash -echo "LOG: Installing NixOS" -sudo nixos-install --flake /etc/nixos#Infini-STICK --no-root-password -#+END_SRC - -** Extra (Full Install) - -#+NAME: full_extra -#+BEGIN_SRC bash -echo "LOG: Cloning configuration" -sudo git clone --no-hardlinks --progress ssh://git@github.com/Infinidoge/universe.git /mnt/persist/etc/nixos -sudo git clone --no-hardlinks --progress https://git@github.com/Infinidoge/universe.git /mnt/persist/etc/nixos-private -#+END_SRC - -** Extra (Reinstall) - -#+NAME: reinstall_extra -#+BEGIN_SRC bash -#+END_SRC - -** Finishing Setup - -#+NAME: finishing_setup -#+BEGIN_SRC bash -#+END_SRC - -** Cleanup - -#+NAME: cleanup -#+BEGIN_SRC bash -echo "LOG: Unmounting all" -sudo umount -R /mnt -#+END_SRC diff --git a/hosts/Infini-STICK/reinstall.bash b/hosts/Infini-STICK/reinstall.bash deleted file mode 100755 index 4bffc77..0000000 --- a/hosts/Infini-STICK/reinstall.bash +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# [[file:readme.org::reinstall][reinstall]] -# [[file:readme.org::mount][mount]] -# [[file:readme.org::mount][boilerplate]] -DISK=$1 - -sudo mkdir -p /mnt -# boilerplate ends here - -# [[file:readme.org::mount][mount_check]] -if mountpoint -q -- "/mnt"; then - echo "ERROR: /mnt is a mounted filesystem, aborting" - exit 1 -fi -# mount_check ends here - -# [[file:readme.org::mount][mounting]] -echo "LOG: Mounting tmpfs" -sudo mount -t tmpfs root /mnt - -echo "LOG: - Mounting persistent directories" -sudo mkdir -p /mnt/persist /mnt/nix /mnt/boot -sudo mount -o subvol=root,autodefrag,noatime "${DISK}3" /mnt/persist -sudo mount -o subvol=nix,autodefrag,noatime "${DISK}3" /mnt/nix -sudo mount -o subvol=boot,autodefrag,noatime "${DISK}3" /mnt/boot - -echo "LOG: - - Mounting persistent subdirectories" -sudo mkdir -p /mnt/home /mnt/etc/ssh -sudo mount --bind /mnt/persist/home /mnt/home -sudo mount --bind /mnt/persist/etc/ssh /mnt/etc/ssh - -echo "LOG: - Mounting EFI System Partition" -sudo mkdir -p /mnt/boot/efi -sudo mount "${DISK}4" /mnt/boot/efi -# mounting ends here -# mount ends here - -# [[file:readme.org::reinstall][installing]] -echo "LOG: Installing NixOS" -sudo nixos-install --flake /etc/nixos#Infini-STICK --no-root-password -# installing ends here - -# [[file:readme.org::reinstall_extra][reinstall_extra]] - -# reinstall_extra ends here - -# [[file:readme.org::reinstall][finishing_setup]] - -# finishing_setup ends here - -# [[file:readme.org::reinstall][cleanup]] -echo "LOG: Unmounting all" -sudo umount -R /mnt -# cleanup ends here -# reinstall ends here diff --git a/hosts/Infini-STICK/setup.bash b/hosts/Infini-STICK/setup.bash deleted file mode 100755 index e3fab84..0000000 --- a/hosts/Infini-STICK/setup.bash +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash -# [[file:readme.org::full_install][full_install]] -# [[file:readme.org::boilerplate][boilerplate]] -DISK=$1 - -sudo mkdir -p /mnt -# boilerplate ends here - -# [[file:readme.org::mount_check][mount_check]] -if mountpoint -q -- "/mnt"; then - echo "ERROR: /mnt is a mounted filesystem, aborting" - exit 1 -fi -# mount_check ends here - -# [[file:readme.org::partitioning][partitioning]] -echo "LOG: Partitioning $DISK" -sudo parted $DISK -- mktable gpt -sudo parted $DISK -s -- mkpart primary 0% 100% -sudo parted $DISK -s -- mkpart primary 40% 100% -sudo parted $DISK -s -- mkpart primary btrfs 45% 100% -sudo parted $DISK -s -- mkpart ESP fat32 -512MiB 100% -sudo parted $DISK -s -- set 4 esp on -# partitioning ends here - -# [[file:readme.org::filesystems][filesystems]] -echo "LOG: Making filesystems" -echo "- Making btrfs filesystem on ${DISK}1" -sudo mkfs.btrfs "${DISK}1" -L "Infini-STICK" -f -echo "- Making fat32 filesystem on ${DISK}2" -sudo mkfs.fat -F 32 -n boot "${DISK}2" -# filesystems ends here - -# [[file:readme.org::subvolumes][subvolumes]] -echo "LOG: Making subvolumes on ${DISK}1" -sudo mount "${DISK}1" /mnt -sudo btrfs subvolume create /mnt/root -sudo btrfs subvolume create /mnt/root/home -sudo mkdir -p /mnt/root/etc -sudo btrfs subvolume create /mnt/root/etc/nixos -sudo btrfs subvolume create /mnt/boot -sudo btrfs subvolume create /mnt/nix -sudo btrfs subvolume create /mnt/nix/store -sudo umount /mnt -# subvolumes ends here - -# [[file:readme.org::mounting][mounting]] -echo "LOG: Mounting tmpfs" -sudo mount -t tmpfs root /mnt - -echo "LOG: - Mounting persistent directories" -sudo mkdir -p /mnt/persist /mnt/nix /mnt/boot -sudo mount -o subvol=root,autodefrag,noatime "${DISK}3" /mnt/persist -sudo mount -o subvol=nix,autodefrag,noatime "${DISK}3" /mnt/nix -sudo mount -o subvol=boot,autodefrag,noatime "${DISK}3" /mnt/boot - -echo "LOG: - - Mounting persistent subdirectories" -sudo mkdir -p /mnt/home /mnt/etc/ssh -sudo mount --bind /mnt/persist/home /mnt/home -sudo mount --bind /mnt/persist/etc/ssh /mnt/etc/ssh - -echo "LOG: - Mounting EFI System Partition" -sudo mkdir -p /mnt/boot/efi -sudo mount "${DISK}4" /mnt/boot/efi -# mounting ends here - -# [[file:readme.org::installing][installing]] -echo "LOG: Installing NixOS" -sudo nixos-install --flake /etc/nixos#Infini-STICK --no-root-password -# installing ends here - -# [[file:readme.org::full_extra][full_extra]] -echo "LOG: Cloning configuration" -sudo git clone --no-hardlinks --progress ssh://git@github.com/Infinidoge/universe.git /mnt/persist/etc/nixos -sudo git clone --no-hardlinks --progress https://git@github.com/Infinidoge/universe.git /mnt/persist/etc/nixos-private -# full_extra ends here - -# [[file:readme.org::finishing_setup][finishing_setup]] - -# finishing_setup ends here - -# [[file:readme.org::cleanup][cleanup]] -echo "LOG: Unmounting all" -sudo umount -R /mnt -# cleanup ends here -# full_install ends here diff --git a/secrets/secrets.nix b/secrets/secrets.nix index f04b6ab..55c317e 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -11,7 +11,7 @@ let Infini-FRAMEWORK = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF7PmPq/7e+YIVAvIcs6EOJ3pZVJhinwus6ZauJ3aVp0 root@Infini-FRAMEWORK"; Infini-SERVER = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO8ptHWTesaUzglq01O8OVqeAGxFhXutUZpkgPpBFqzY root@Infini-SERVER"; Infini-OPTIPLEX = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEG8fY684SPKeOUsJqaV6LJwwztWxztaU9nAHPBxBtyU root@Infini-OPTIPLEX"; - Infini-STICK = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMCg81G/oysjFkHXo1E9XPGoULpv9rR0HyWoR2wIcl6C root@Infini-STICK"; + Infini-STICK = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB0fWuozCHyPrkFKPcnqX1MyUAgnn2fJEpDSoD7bhDA4 root@Infini-STICK"; Infini-SD = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO8oViHNz64NG51uyll/q/hrSGwoHRgvYI3luD/IWTUT root@Infini-SD"; Infini-DL360 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPjmvE76BcPwZSjeNGzlguDQC67Yxa3uyOf5ZmVDWNys root@Infini-DL360"; Infini-RASPBERRY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIwPqTFCztLbYFFUej42hRzzCBzG6BCZIb7zXi2cxeJp root@Infini-RASPBERRY"; diff --git a/users/infinidoge/ssh-keys.nix b/users/infinidoge/ssh-keys.nix index 03692ee..e5f7dc8 100644 --- a/users/infinidoge/ssh-keys.nix +++ b/users/infinidoge/ssh-keys.nix @@ -5,7 +5,7 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINwo8TGBe91mmkc/QonsXtTBKCJtsAGz3YzphDZlzmaO infinidoge@Infini-FRAMEWORK" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJbNOMgVDM/hJQgzd1ff5uuouDtTLOAgmTt57cNNySif infinidoge@Infini-SERVER" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBfpzp4nROMc3nuSu+/ivkm0koyn2Da5NtVbYl+Rg+O1 infinidoge@Infini-OPTIPLEX" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBhkjhMascGZhPKK/WxiXTjPoSJSZIkiFx9W+EaaCPiT infinidoge@Infini-STICK" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAjPn04o81mf4obA0zaXbyQlsYbXL3sZa4aNxmDlFDZe infinidoge@Infini-STICK" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIAFZRE0BLE8pPixrwNu8oqtL+MEhkePNnc8/kWrYsOm infinidoge@Infini-SD" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIUIcQljnMxXsLU8RO33kqFRqEOgQi7U0x+UFG4Caskk infinidoge@Infini-DL360" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPpqFpFfQEWr4CVu7N/0MDyaktoMEsB+m2NuIaDx5j0r infinidoge@Infini-RASPBERRY"