From 0f68e97843b7b460be5672709cbee0016341ad2b Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Mon, 9 May 2022 13:30:26 -0400 Subject: [PATCH] feat(setup): create Infini-FRAMEWORK setup scripts --- hosts/Infini-FRAMEWORK/bare_install.bash | 7 + hosts/Infini-FRAMEWORK/install.bash | 58 ++++++++ hosts/Infini-FRAMEWORK/mount.bash | 35 +++++ hosts/Infini-FRAMEWORK/prep.bash | 43 ++++++ hosts/Infini-FRAMEWORK/readme.org | 178 +++++++++++++++++++++++ 5 files changed, 321 insertions(+) create mode 100755 hosts/Infini-FRAMEWORK/bare_install.bash create mode 100755 hosts/Infini-FRAMEWORK/install.bash create mode 100755 hosts/Infini-FRAMEWORK/mount.bash create mode 100755 hosts/Infini-FRAMEWORK/prep.bash create mode 100644 hosts/Infini-FRAMEWORK/readme.org diff --git a/hosts/Infini-FRAMEWORK/bare_install.bash b/hosts/Infini-FRAMEWORK/bare_install.bash new file mode 100755 index 0000000..89bb6aa --- /dev/null +++ b/hosts/Infini-FRAMEWORK/bare_install.bash @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# [[file:readme.org::bare_install][bare_install]] +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::installing][installing]]][installing]] +echo "LOG: Installing NixOS" +sudo nixos-install --flake /etc/nixos#Infini-FRAMEWORK --no-root-password +# installing ends here +# bare_install ends here diff --git a/hosts/Infini-FRAMEWORK/install.bash b/hosts/Infini-FRAMEWORK/install.bash new file mode 100755 index 0000000..a1856ae --- /dev/null +++ b/hosts/Infini-FRAMEWORK/install.bash @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# [[file:readme.org::install][install]] +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::mount][mount]]][mount]] +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::boilerplate][boilerplate]]][boilerplate]] +DISK=$1 +PART=$DISK$2 + +sudo mkdir -p /mnt +# boilerplate ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::mount_check][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:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::mounting][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 "${PART}2" /mnt/persist +sudo mount -o subvol=nix,autodefrag,noatime "${PART}2" /mnt/nix +sudo mount -o subvol=boot,autodefrag,noatime "${PART}2" /mnt/boot + +echo "LOG: - - Mounting persistent subdirectories" +sudo mkdir -p /mnt/home +sudo mount --bind /mnt/persist/home /mnt/home + +echo "LOG: - Mounting EFI System Partition" +sudo mkdir -p /mnt/boot/efi +sudo mount "${PART}1" /mnt/boot/efi +# mounting ends here +# mount ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::installing][installing]]][installing]] +echo "LOG: Installing NixOS" +sudo nixos-install --flake /etc/nixos#Infini-FRAMEWORK --no-root-password +# installing ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::install_extra][install_extra]]][install_extra]] +echo "LOG: Cloning configuration" +sudo chown -R infinidoge /mnt/persist/etc/nixos +git clone --no-hardlinks --progress https://gitlab.com/infinidoge/universe.git /mnt/persist/etc/nixos + +echo "LOG: Installing Doom Emacs" +sudo mkdir -p /mnt/persist/home/infinidoge/.config/emacs +git clone --no-hardlinks --progress --depth 1 https://github.com/hlissner/doom-emacs /mnt/persist/home/infinidoge/.config/emacs +HOME=/mnt/persist/home/infinidoge /mnt/persist/home/infinidoge/.config/emacs/bin/doom -y install --no-config +# install_extra ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::cleanup][cleanup]]][cleanup]] +echo "LOG: Unmounting all" +sudo umount -R /mnt +# cleanup ends here +# install ends here diff --git a/hosts/Infini-FRAMEWORK/mount.bash b/hosts/Infini-FRAMEWORK/mount.bash new file mode 100755 index 0000000..3c75b81 --- /dev/null +++ b/hosts/Infini-FRAMEWORK/mount.bash @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# [[file:readme.org::mount][mount]] +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::boilerplate][boilerplate]]][boilerplate]] +DISK=$1 +PART=$DISK$2 + +sudo mkdir -p /mnt +# boilerplate ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::mount_check][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:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::mounting][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 "${PART}2" /mnt/persist +sudo mount -o subvol=nix,autodefrag,noatime "${PART}2" /mnt/nix +sudo mount -o subvol=boot,autodefrag,noatime "${PART}2" /mnt/boot + +echo "LOG: - - Mounting persistent subdirectories" +sudo mkdir -p /mnt/home +sudo mount --bind /mnt/persist/home /mnt/home + +echo "LOG: - Mounting EFI System Partition" +sudo mkdir -p /mnt/boot/efi +sudo mount "${PART}1" /mnt/boot/efi +# mounting ends here +# mount ends here diff --git a/hosts/Infini-FRAMEWORK/prep.bash b/hosts/Infini-FRAMEWORK/prep.bash new file mode 100755 index 0000000..5f6815d --- /dev/null +++ b/hosts/Infini-FRAMEWORK/prep.bash @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# [[file:readme.org::preparation][preparation]] +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::boilerplate][boilerplate]]][boilerplate]] +DISK=$1 +PART=$DISK$2 + +sudo mkdir -p /mnt +# boilerplate ends here + + + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::partitioning][partitioning]]][partitioning]] +echo "LOG: Partitioning $DISK" +sudo parted $DISK -- mktable gpt +sudo parted $DISK -s -- mkpart ESP fat32 1MiB 512MiB +sudo parted $DISK -s -- mkpart primary btrfs 512MiB -24GiB +sudo parted $DISK -s -- mkpart primary linux-swap -24GiB 100% +sudo parted $DISK -s -- set 1 esp on +# partitioning ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::filesystems][filesystems]]][filesystems]] +echo "LOG: Making filesystems" +echo "- Making fat32 filesystem on ${PART}1" +sudo mkfs.fat -F 32 -n boot "${PART}1" +echo "- Making btrfs filesystem on ${PART}2" +sudo mkfs.btrfs "${PART}2" -L "Infini-FRAMEWORK" -f +echo "- Making swap space on ${PART}3" +sudo mkswap -L swap "${PART}3" +# filesystems ends here + +# [[[[file:/etc/nixos/hosts/Infini-FRAMEWORK/readme.org::subvolumes][subvolumes]]][subvolumes]] +echo "LOG: Making subvolumes on ${PART}2" +sudo mount "${PART}2" /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 +# preparation ends here diff --git a/hosts/Infini-FRAMEWORK/readme.org b/hosts/Infini-FRAMEWORK/readme.org new file mode 100644 index 0000000..07d8868 --- /dev/null +++ b/hosts/Infini-FRAMEWORK/readme.org @@ -0,0 +1,178 @@ +#+TITLE: Infini-FRAMEWORK Setup +#+AUTHOR: Infinidoge +#+OPTIONS: toc:nil +#+LaTeX_CLASS_OPTIONS: [12pt] +#+LATEX_HEADER: \usepackage[margin=1in]{geometry} + +* Partition Scheme + +| Position | Label | FS Type | Size | Type | +|----------+--------------------+------------------+------+----------------------| +| 1 | =boot= | =vfat= / =fat32= | 511M | EFI System Partition | +| 2 | =Infini-FRAMEWORK= | =btrfs= | Rest | Root Partition | +| 3 | =swap= | =swap= | 24G | Swap Space | + +* Configuration + +My main laptop, the [[https://frame.work][Framework Laptop]]. + +** Specs + +| | Component | +|---------+-----------------------------| +| CPU | 11th Gen Intel i5-1135G7 | +| GPU | Iris Xe Integrated Graphics | +| RAM | 16gb | +| Storage | 1tb SSD | + + +* Setup Scripts + +#+NAME: preparation +#+BEGIN_SRC bash :tangle prep.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 + +#+NAME: mount +#+BEGIN_SRC bash :tangle mount.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb +<> + +<> + +<> +#+END_SRC + +#+NAME: bare_install +#+BEGIN_SRC bash :tangle bare_install.bash :shebang "#!/usr/bin/env bash" :noweb yes :comments noweb +<> +#+END_SRC + +** Script Boilerplate + +#+NAME: boilerplate +#+BEGIN_SRC bash +DISK=$1 +PART=$DISK$2 + +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 ESP fat32 1MiB 512MiB +sudo parted $DISK -s -- mkpart primary btrfs 512MiB -24GiB +sudo parted $DISK -s -- mkpart primary linux-swap -24GiB 100% +sudo parted $DISK -s -- set 1 esp on +#+END_SRC + +** Making Filesystems + +#+NAME: filesystems +#+BEGIN_SRC bash +echo "LOG: Making filesystems" +echo "- Making fat32 filesystem on ${PART}1" +sudo mkfs.fat -F 32 -n boot "${PART}1" +echo "- Making btrfs filesystem on ${PART}2" +sudo mkfs.btrfs "${PART}2" -L "Infini-FRAMEWORK" -f +echo "- Making swap space on ${PART}3" +sudo mkswap -L swap "${PART}3" +#+END_SRC + +** Making Subvolumes + +#+NAME: subvolumes +#+BEGIN_SRC bash +echo "LOG: Making subvolumes on ${PART}2" +sudo mount "${PART}2" /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 "${PART}2" /mnt/persist +sudo mount -o subvol=nix,autodefrag,noatime "${PART}2" /mnt/nix +sudo mount -o subvol=boot,autodefrag,noatime "${PART}2" /mnt/boot + +echo "LOG: - - Mounting persistent subdirectories" +sudo mkdir -p /mnt/home +sudo mount --bind /mnt/persist/home /mnt/home + +echo "LOG: - Mounting EFI System Partition" +sudo mkdir -p /mnt/boot/efi +sudo mount "${PART}1" /mnt/boot/efi +#+END_SRC + +** Installing + +#+NAME: installing +#+BEGIN_SRC bash +echo "LOG: Installing NixOS" +sudo nixos-install --flake /etc/nixos#Infini-FRAMEWORK --no-root-password +#+END_SRC + +** Extra (Install) + +#+NAME: install_extra +#+BEGIN_SRC bash +echo "LOG: Cloning configuration" +sudo chown -R infinidoge /mnt/persist/etc/nixos +git clone --no-hardlinks --progress https://gitlab.com/infinidoge/universe.git /mnt/persist/etc/nixos + +echo "LOG: Installing Doom Emacs" +sudo mkdir -p /mnt/persist/home/infinidoge/.config/emacs +git clone --no-hardlinks --progress --depth 1 https://github.com/hlissner/doom-emacs /mnt/persist/home/infinidoge/.config/emacs +HOME=/mnt/persist/home/infinidoge /mnt/persist/home/infinidoge/.config/emacs/bin/doom -y install --no-config +#+END_SRC + +** Cleanup + +#+NAME: cleanup +#+BEGIN_SRC bash +echo "LOG: Unmounting all" +sudo umount -R /mnt +#+END_SRC