From b53c14bf7791034d7adb7971f36f2d5971cc2115 Mon Sep 17 00:00:00 2001 From: pagedmov Date: Thu, 17 Oct 2024 22:51:52 -0400 Subject: [PATCH] various temporary testing changes --- flake.lock | 21 -------- hosts/installer/default.nix | 22 +++++--- hosts/installer/disko-ext4-singledisk.nix | 10 ++-- hosts/installer/movcfg.sh | 63 +++++++++++++++++++++++ modules/home/default.nix | 4 +- 5 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 hosts/installer/movcfg.sh diff --git a/flake.lock b/flake.lock index d801bcb..3b7e93d 100644 --- a/flake.lock +++ b/flake.lock @@ -119,26 +119,6 @@ "type": "github" } }, - "disko": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1729099656, - "narHash": "sha256-VftVIg7UXTy1bq+tzi1aVYOWl7PQ35IpjW88yMYjjpc=", - "owner": "nix-community", - "repo": "disko", - "rev": "d7d57edb72e54891fa67a6f058a46b2bb405663b", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "disko", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -926,7 +906,6 @@ "catppuccin-cava": "catppuccin-cava", "catppuccin-starship": "catppuccin-starship", "catppuccin-yazi": "catppuccin-yazi", - "disko": "disko", "home-manager": "home-manager", "hypr-contrib": "hypr-contrib", "hyprland": "hyprland", diff --git a/hosts/installer/default.nix b/hosts/installer/default.nix index 7cae87b..1c5b6bc 100644 --- a/hosts/installer/default.nix +++ b/hosts/installer/default.nix @@ -4,7 +4,7 @@ let nvim = inputs.nvim.packages."x86_64-linux".default; toilet = inputs.toilet.packages."x86_64-linux".default; install-script = pkgs.writeShellScriptBin "movcfg-install" '' - #!/bin/bash + #!/run/current-system/sw/bin/bash set -e trap 'echo "Aborting installation."; exit 1' INT @@ -30,12 +30,17 @@ let echo -n "Which drive do you wish to sacrifice? " read -r drive - size=$(lsblk -b -d -o NAME,SIZE | grep "$drive" | awk '{ printf "%.0f\n", $2 / 1024 / 1024 / 1024 }') 1024 / 1024 / 1024 }') - root_end=$(echo "scale=0;$size * 0.10 / 1" | bc) - nix_end=$(echo "scale=0;$size * 0.35 / 1" | bc) - + size=$(lsblk -b -d -o NAME,SIZE | grep "$drive" | awk '{ printf "%.0f\n", $2 / 1024 / 1024 / 1024 }') + root_size=$(echo "scale=0;$size * 0.10 / 1" | bc) + nix_size=$(echo "scale=0;$size * 0.35 / 1" | bc) + # commence formatting - nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/install_pwd/disko.nix --arg device "\"/dev/$drive\"" --arg root_end "\"$root_end\G\"" --arg nix_end "\"$nix_end\G\"" + nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/install_pwd/disko.nix --arg device "\"/dev/$drive\"" --arg root_size "\"$root_size\G\"" --arg nix_size "\"$nix_size\G\"" + + mount /dev/disk/by-partlabel/disk-main-root /mnt + mkdir -p /mnt/nix && mount /dev/disk/by-partlabel/disk-main-nix /mnt/nix + mkdir -p /mnt/boot && mount /dev/disk/by-partlabel/disk-main-boot /mnt/boot + mkdir -p /mnt/home && mount /dev/disk/by-partlabel/disk-main-home /mnt/home # set up home directory in /mnt/persist, create /persist/etc/nixos, cd to /etc/nixos and install my flake config mkdir -p /mnt/etc @@ -55,8 +60,8 @@ let ln -s /mnt/home/pagedmov/.sysflake /etc/nixos nixos-enter < disko.nix +echo "Done!" + +echo +echo "This script is about to format and partition a hard drive." +sleep 2.5 +echo -e "\033[4;31mThis process is irreversible and will destroy all data on the drive.\033[0m" +sleep 2.5 +echo "Make absolutely sure that you know which drive you are choosing." +sleep 2.5 +echo +lsblk -d -o NAME,SIZE +echo +echo -n "Which drive do you wish to sacrifice? " +read -r drive + +size=$(lsblk -b -d -o NAME,SIZE | grep "$drive" | awk '{ printf "%.0f\n", $2 / 1024 / 1024 / 1024 }') +root_size=$(echo "scale=0;$size * 0.10 / 1" | bc) +nix_size=$(echo "scale=0;$size * 0.35 / 1" | bc) + +# commence formatting +nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/install_pwd/disko.nix --arg device "\"/dev/$drive\"" --arg root_size "\"$root_size\G\"" --arg nix_size "\"$nix_size\G\"" + +mount /dev/disk/by-partlabel/disk-main-root /mnt +mkdir -p /mnt/nix && mount /dev/disk/by-partlabel/disk-main-nix /mnt/nix +mkdir -p /mnt/boot && mount /dev/disk/by-partlabel/disk-main-boot /mnt/boot +mkdir -p /mnt/home && mount /dev/disk/by-partlabel/disk-main-home /mnt/home + +# set up home directory in /mnt/persist, create /persist/etc/nixos, cd to /etc/nixos and install my flake config +mkdir -p /mnt/etc +cd /mnt/etc/ +git clone https://github.com/pagedMov/pagedmov-nix-cfg.git ./nixos + +nixos-install --root /mnt --flake /mnt/etc/nixos#mercury --no-root-password + +echo +echo "Preliminary installation successful!" +echo "Beginning secondary installation phase... " +echo + +cp -r /mnt/etc/nixos /mnt/home/pagedmov/.sysflake +chown -R pagedmov /mnt/home/pagedmov/.sysflake +rm -rf /mnt/etc/nixos +ln -s /mnt/home/pagedmov/.sysflake /etc/nixos + +nixos-enter <