about summary refs log tree commit diff stats
path: root/bootstrap/01_install
blob: 5a3acc2dd28fcf9b3a8df4cdeb664ce733c2f8ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env dash

# shellcheck source=/dev/null
SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH

INSTALL=y . %SCRIPT_ENSURE_CONFIG_VARIABLES

msg "started creating filesystem..."
nix run github:nix-community/disko -- --flake "git+https://codeberg.org/soispha/nixos-config#$NIX_HOST" --mode disko
msg "Finished mounting and generating btrfs subvolumes"

msg "Creating swapfile..."
msg2 "$(btrfs filesystem mkswapfile --size "$(free -m | awk '{if (NR==2) {printf "%sm\n", $2 + 500}}')" /mnt/swap/swapfile)";
msg "Finished creating swapfile!"

msg "Important information:"
msg2 "Swapfile UUID is: $(findmnt -no UUID -T /mnt/swap/swapfile)";
msg2 "Swapfile resume offset is: $(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile)";
msg2 "Root-disk UUID is: $(lsblk -no UUID -T $DISK_ROOT)";
msg2 "EFI-disk UUID is: $(lsblk -no UUID -T $DISK_EFI)";
warning "This information needs to be entered in the host configuration BEFORE rebuilding it. Otherwise the system won't boot!"

info_applied=false;
while [ "$info_applied" = false ];do
    readp "Have you updated your chosen host with this information? [N/y]: " result
    case $result in
        [Yy])
            info_applied=true;
            ;;
        *)
            warning "You won't be able to boot, if you don't update it!"
            ;;
    esac
done

msg "Checking for incompatibilities..."
ssd_or_hdd=$(cat /sys/block/$disk/queue/rotational);
case "$ssd_or_hdd" in
    0)
        msg2 "You seem to use a ssd."
        trim_support=$(lsblk --bytes --json --discard | jq --arg name "$disk" '.blockdevices | .[] | select(.name == $name) | (.["disc-gran"] + .["disc-max"]) != 0');
        case $trim_support in
            "true")
                msg2 "Yay, your ssd supports trim, go on and activate it";
                ;;
            "false")
                msg2 "Nay, your ssd doesn't support trim, go on";
                ;;
            *)
                warning "Your ssd doesn't seem to exists, if this bothers you please open an issue.'";
                ;;
        esac
        ;;
    1)
        msg2 "You seem to use a hdd there is nothing you have to do";
        ;;
    *)
        warning "There is no indicator, which shows, which drive your are using.\n This means, that you have to check yourself, which optimizations you should activate."
        ;;
esac


readp "Do you want to continue with nixos-install? [N/y]: " result
case $result in
    [Yy])
        nix run "git+https://codeberg.org/soispha/nixos-config#setup" --experimental-features 'nix-command flakes';
        ;;
    *)
        msg "Sure, do it yourself"
        exit 1
        ;;
esac