dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit 69e078e92de0449b6f0ca35556820ff00546ac4f parent 9ad8a7dc7deb0f8709317207127d16b5ea117fe3 Author: maydayv7 <maydayv7@gmail.com> Date: Mon, 23 Oct 2023 13:22:08 +0530 fix(`nixos install`): Add `--first-boot` flag
Diffstat:
| M | .templates/minimal/flake.nix | | | 5 | ++--- |
| M | README.md | | | 8 | +++++--- |
| M | packages/dotfiles.nix | | | 1 | - |
| M | scripts/commands.sh | | | 8 | ++++++++ |
| M | scripts/nixos.nix | | | 144 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
5 files changed, 89 insertions(+), 77 deletions(-)
diff --git a/.templates/minimal/flake.nix b/.templates/minimal/flake.nix @@ -4,8 +4,8 @@ ## System Repositories ## inputs = { ## Package Repositories ## - # NixOS Stable Release - nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-23.05"; + # NixOS Package Repository + nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; ## Configuration Modules ## # My PC Dotfiles @@ -19,7 +19,6 @@ nixosConfigurations.host = lib.build.device { name = "HOST_NAME"; system = "x86_64-linux"; - channel = "stable"; # Generate these files using 'nixos-generate-config' imports = [./configuration.nix ./hardware-configuration.nix]; diff --git a/README.md b/README.md @@ -136,7 +136,6 @@ github:maydayv7/dotfiles ┌── configuration.nix ├── flake.nix ├── flake.lock -├── .version ├── .templates ├── files ├── secrets @@ -168,7 +167,6 @@ github:maydayv7/dotfiles - `configuration.nix`: main system configuration file - `flake.nix`: repository version control using `inputs` -- `.version`: system state version - `.templates`: custom Flakes configuration templates - [`files`](./files/README.md): `dotfiles` and program configuration - [`secrets`](./secrets/README.md): authentication credentials management using [`sops-nix`](https://github.com/Mic92/sops-nix) @@ -275,7 +273,7 @@ _Note that the `install` script automatically creates and labels all the require To install the OS, just boot the Live USB and run `sudo nixos install` _If the image doesn't boot, try disabling the `secure boot` and `RAID` options from `BIOS`_ -After the reboot, run `nixos setup` in the newly installed system to finish setup +After the reboot, run `nixos install --first-boot` to finish the install _In case you are using the `advanced` filesystem scheme, you may need to set the boot flag `zfs_force=1` on first boot_ </details> @@ -318,6 +316,10 @@ There are two branches, [`stable`](../../tree/stable) and [`develop`](../../tree While rebuilding system with Flakes, make sure that any file with unstaged changes will not be included. Use `git add .` in cases where the `git` tree is dirty +#### Boot + +To boot into a different build generation, hold down the Spacebar (for `efi`) or the `Shift`/`Esc` key (for `mbr`) upon startup to access the boot menu + #### Cache The system build cache is publicly hosted using [Cachix](https://www.cachix.org) at [maydayv7-dotfiles](https://app.cachix.org/cache/maydayv7-dotfiles), and can be used while building the system to prevent rebuilding from scratch diff --git a/packages/dotfiles.nix b/packages/dotfiles.nix @@ -7,7 +7,6 @@ pkgs.stdenv.mkDerivation rec { pname = "Dotfiles"; version = "v13"; - longVersion = "unstable"; src = files.path.toplevel; dontBuild = true; diff --git a/scripts/commands.sh b/scripts/commands.sh @@ -64,6 +64,14 @@ up () { cd "$P" || exit } +info() { + echo -e "\n\033[0;35minfo:\033[0m $1" + if [ -n "$2" ] + then + echo -e "\n$2" + fi +} + warn() { echo -e "\n\033[0;35mwarning:\033[0m $1" if [ -n "$2" ] diff --git a/scripts/nixos.nix b/scripts/nixos.nix @@ -195,78 +195,82 @@ in esac ;; install) - internet - if [ "$EUID" -ne 0 ] - then - error "This Command must be Executed as 'root'" - fi - read -rp "Enter Name of Device to Install: " HOST - read -rp "Do you want to Automatically Create the Partitions? (Y/N): " choice - case $choice in - [Yy]*) warn "Assuming Disk is Completely Empty"; partition_disk;; - *) warn "You must Create, Format and Label the Partitions on your own"; gparted > /dev/null;; - esac - newline - read -rp "Select Filesystem to use for Disk (simple/advanced): " choice - case $choice in - 1|[Ss]*) - read -rp "Do you want to Create and Format the EXT4 Partitions? (Y/N): " choice - case $choice in - [Yy]*) DIR=${path.system}; create_ext4; mount_ext4;; - *) warn "Assuming that Required EXT4 Partition has already been Created"; mount_ext4;; - esac - ;; - 2|[Aa]*) - read -rp "Do you want to Create the ZFS Pool and Datasets? (Y/N): " choice - case $choice in - [Yy]*) DIR=${persist}${path.system}; create_zfs; mount_zfs;; - *) warn "Assuming that Required ZFS Pool and Datasets have already been Created"; mount_zfs;; - esac - ;; - *) error "Choose (1)simple or (2)advanced";; - esac - newline - mount_other - newline - read -rp "Enter Path to Repository (path/URL): " URL - if [ -z "$URL" ] - then - URL=${path.flake} - fi - echo "Installing System from '$URL'..." - nixos-install --no-root-passwd --root /mnt --flake "$URL"#"$HOST" - newline - - read -rp "Enter Path to GPG Keys (path/.git): " KEY - LINK='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' - if [ -z "$KEY" ] - then - error "Path to GPG Keys cannot be empty" - elif [[ $KEY =~ $LINK ]] - then - echo "Cloning Keys..." - git clone "$KEY" keys --progress - else - cp -r "$KEY"/. ./keys - fi - echo "Importing Keys..." - find ./keys -name '*.gpg' -exec gpg --homedir /mnt${files.gpg} --import {} \+ - rm -rf ./keys - newline - - echo "Preparing ${path.system}..." - DIR=/mnt$DIR - rm -rf "$DIR" && mkdir "$DIR" - newline + case $2 in + "--first-boot") + if [ -d ${persist} ]; then + DIR=${persist}${path.system} + else + DIR=${path.system} + fi + git clone --recurse-submodules ${path.repo} "$DIR" + nixos apply --activate + ;; + "") + internet + if [ "$EUID" -ne 0 ] + then + error "This Command must be Executed as 'root'" + fi + read -rp "Enter Name of Device to Install: " HOST + read -rp "Do you want to Automatically Create the Partitions? (Y/N): " choice + case $choice in + [Yy]*) warn "Assuming Disk is Completely Empty"; partition_disk;; + *) warn "You must Create, Format and Label the Partitions on your own"; gparted > /dev/null;; + esac + newline + read -rp "Select Filesystem to use for Disk (simple/advanced): " choice + case $choice in + 1|[Ss]*) + read -rp "Do you want to Create and Format the EXT4 Partitions? (Y/N): " choice + case $choice in + [Yy]*) DIR=${path.system}; create_ext4; mount_ext4;; + *) warn "Assuming that Required EXT4 Partition has already been Created"; mount_ext4;; + esac + ;; + 2|[Aa]*) + read -rp "Do you want to Create the ZFS Pool and Datasets? (Y/N): " choice + case $choice in + [Yy]*) DIR=${persist}${path.system}; create_zfs; mount_zfs;; + *) warn "Assuming that Required ZFS Pool and Datasets have already been Created"; mount_zfs;; + esac + ;; + *) error "Choose (1)simple or (2)advanced";; + esac + newline + mount_other + newline + read -rp "Enter Path to Repository (path/URL): " URL + if [ -z "$URL" ] + then + URL=${path.flake} + fi + echo "Installing System from '$URL'..." + nixos-install --no-root-passwd --root /mnt --flake "$URL"#"$HOST" + newline - echo "Cloning Repository..." - git clone --recurse-submodules ${path.repo} "$DIR" - chgrp -R keys "$DIR" && chmod g+rwx "$DIR" -R - newline + read -rp "Enter Path to GPG Keys (path/.git): " KEY + LINK='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' + if [ -z "$KEY" ] + then + error "Path to GPG Keys cannot be empty" + elif [[ $KEY =~ $LINK ]] + then + echo "Cloning Keys..." + git clone "$KEY" keys --progress + else + cp -r "$KEY"/. ./keys + fi + echo "Importing Keys..." + find ./keys -name '*.gpg' -exec gpg --homedir /mnt${files.gpg} --import {} \+ + rm -rf ./keys + newline - unmount_all - newline - restart + unmount_all + newline + info "Run 'nixos install --first-boot' after rebooting to finish the install" + restart + ;; + esac ;; iso) case $2 in