From 105b2f9c02a54b6e78ad083995baa81b1ff74850 Mon Sep 17 00:00:00 2001 From: ponymushama Date: Sun, 21 Jul 2024 16:41:23 +0800 Subject: [PATCH] update install.sh --- install.sh | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index c167cf4..622cc01 100755 --- a/install.sh +++ b/install.sh @@ -3,24 +3,23 @@ # Automated script to install my dotfiles # Clone dotfiles -if [ $# -gt 0 ] - then - SCRIPT_DIR=$1 - else - SCRIPT_DIR=~/.dotfiles +if [ $# -gt 0 ]; then + SCRIPT_DIR=$1 +else + SCRIPT_DIR=~/.dotfiles fi -nix-shell -p git --command "git clone https://gitlab.com/librephoenix/nixos-config $SCRIPT_DIR" +nix-shell -p git --command "git clone https://github.com/ponymushama/nixos-config.git $SCRIPT_DIR" # Generate hardware config for new system -sudo nixos-generate-config --show-hardware-config > $SCRIPT_DIR/system/hardware-configuration.nix +sudo nixos-generate-config --show-hardware-config >$SCRIPT_DIR/system/hardware-configuration.nix # Check if uefi or bios if [ -d /sys/firmware/efi/efivars ]; then - sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"uefi\";/" $SCRIPT_DIR/flake.nix + sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"uefi\";/" $SCRIPT_DIR/flake.nix else - sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"bios\";/" $SCRIPT_DIR/flake.nix - grubDevice=$(findmnt / | awk -F' ' '{ print $2 }' | sed 's/\[.*\]//g' | tail -n 1 | lsblk -no pkname | tail -n 1 ) - sed -i "0,/grubDevice.*=.*\".*\";/s//grubDevice = \"\/dev\/$grubDevice\";/" $SCRIPT_DIR/flake.nix + sed -i "0,/bootMode.*=.*\".*\";/s//bootMode = \"bios\";/" $SCRIPT_DIR/flake.nix + grubDevice=$(findmnt / | awk -F' ' '{ print $2 }' | sed 's/\[.*\]//g' | tail -n 1 | lsblk -no pkname | tail -n 1) + sed -i "0,/grubDevice.*=.*\".*\";/s//grubDevice = \"\/dev\/$grubDevice\";/" $SCRIPT_DIR/flake.nix fi # Patch flake.nix with different username/name and remove email by default @@ -31,15 +30,15 @@ sed -i "s+~/.dotfiles+$SCRIPT_DIR+g" $SCRIPT_DIR/flake.nix # Open up editor to manually edit flake.nix before install if [ -z "$EDITOR" ]; then - EDITOR=nano; + EDITOR=nano fi -$EDITOR $SCRIPT_DIR/flake.nix; +$EDITOR $SCRIPT_DIR/flake.nix # Permissions for files that should be owned by root -sudo $SCRIPT_DIR/harden.sh $SCRIPT_DIR; +sudo $SCRIPT_DIR/harden.sh $SCRIPT_DIR # Rebuild system -sudo nixos-rebuild switch --flake $SCRIPT_DIR#system; +sudo nixos-rebuild switch --flake $SCRIPT_DIR#system # Install and build home-manager configuration -nix run home-manager/master --extra-experimental-features nix-command --extra-experimental-features flakes -- switch --flake $SCRIPT_DIR#user; +nix run home-manager/master --extra-experimental-features nix-command --extra-experimental-features flakes -- switch --flake $SCRIPT_DIR#user