Infini-STICK: resetup with disko

This commit is contained in:
Infinidoge 2024-11-23 04:06:04 -05:00
parent f27d02d161
commit 43087082c4
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A
10 changed files with 32 additions and 425 deletions

View file

@ -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;

View file

@ -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"
];
}

View file

@ -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;
};
};
}

View file

@ -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

View file

@ -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

View file

@ -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
<<boilerplate>>
<<mount_check>>
<<partitioning>>
<<filesystems>>
<<subvolumes>>
<<mounting>>
<<installing>>
<<full_extra>>
<<finishing_setup>>
<<cleanup>>
#+END_SRC
#+NAME: reinstall
#+BEGIN_SRC bash :tangle reinstall.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb
<<mount>>
<<installing>>
<<reinstall_extra>>
<<finishing_setup>>
<<cleanup>>
#+END_SRC
#+NAME: mount
#+BEGIN_SRC bash :tangle mount.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb
<<boilerplate>>
<<mount_check>>
<<mounting>>
#+END_SRC
#+NAME: install
#+BEGIN_SRC bash :tangle install.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb
<<installing>>
#+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

View file

@ -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

View file

@ -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

View file

@ -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";

View file

@ -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"