From cf53c2fdad8101799847ff64b8aa3be9b01478fd Mon Sep 17 00:00:00 2001 From: foglar Date: Sat, 11 Jan 2025 22:45:25 +0100 Subject: [PATCH] script update --- README.md | 6 ++---- install.sh | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index ffc8212..70a99d8 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ - to start installation you can simply run: -```bash -nix-shell -p git --command "nix run --experimental-features 'nix-command flakes' github:foglar/nixos-config" -# or -nix-shell -p git --command "nix run --experimental-features 'nix-command flakes' git+https://git.foglar.tech/foglar/dotfiles.git" +```bash +nix-shell -p git --command "nix run --experimental-features 'nix-command flakes' git+https://git.foglar.tech/foglar/psychonix-install.git" ``` diff --git a/install.sh b/install.sh index 3e8648f..7d8267b 100755 --- a/install.sh +++ b/install.sh @@ -1,53 +1,53 @@ #!/bin/sh if [ $# -gt 0 ]; then - SCRIPT_DIR=$1 + SCRIPT_DIR=$1 else - SCRIPT_DIR=~/.dotfiles + SCRIPT_DIR=~/.dotfiles fi -if [ -d $SCRIPT_DIR ]; then - gum confirm "The directory $SCRIPT_DIR already exists. Do you want to delete it?" && yes | rm -rv $SCRIPT_DIR +if [ -d "$SCRIPT_DIR" ]; then + gum confirm "The directory $SCRIPT_DIR already exists. Do you want to delete it?" && rm -rfv "$SCRIPT_DIR" fi nixos_profile=$(gum choose kogami ginoza) download_wallpapers=$(gum confirm "Do you want to download wallpapers (it may take longer)?" && echo true || echo false) -if [ -d $SCRIPT_DIR ]; then - gum log --structured --level warn "The directory $SCRIPT_DIR already exists. Downloading updates..." - cd $SCRIPT_DIR && git pull +if [ -d "$SCRIPT_DIR" ]; then + gum log --structured --level warn "The directory $SCRIPT_DIR already exists. Downloading updates..." + cd "$SCRIPT_DIR" && git pull else - nix-shell -p git --command "git clone https://git.foglar.tech/foglar/dotfiles.git $SCRIPT_DIR" + nix-shell -p git --command "git clone https://git.foglar.tech/foglar/dotfiles.git $SCRIPT_DIR" fi -sudo nixos-generate-config --show-hardware-config >$SCRIPT_DIR/kogami/hardware-configuration.nix -gum log --structured --level info "Creating hardware configuration..." file $SCRIPT_DIR/kogami/hardware-configuration.nix -sudo nixos-generate-config --show-hardware-config >$SCRIPT_DIR/ginoza/hardware-configuration.nix -gum log --structured --level info "Creating hardware configuration..." file $SCRIPT_DIR/kogami/hardware-configuration.nix +sudo nixos-generate-config --show-hardware-config tee "$SCRIPT_DIR/kogami/hardware-configuration.nix" >sudo +gum log --structured --level info "Creating hardware configuration..." file "$SCRIPT_DIR/kogami/hardware-configuration.nix" +sudo nixos-generate-config --show-hardware-config tee "$SCRIPT_DIR/ginoza/hardware-configuration.nix" >sudo +gum log --structured --level info "Creating hardware configuration..." file "$SCRIPT_DIR/kogami/hardware-configuration.nix" # Username -sed -i "0,/shinya/s//$(whoami)/" $SCRIPT_DIR/flake.nix -gum log --structured --level info "Setting user name in flake.nix..." file $SCRIPT_DIR/flake.nix +sed -i "0,/shinya/s//$(whoami)/" "$SCRIPT_DIR/flake.nix" +gum log --structured --level info "Setting user name in flake.nix..." file "$SCRIPT_DIR/flake.nix" # Set hostname by selected profile -sed -i "0,/kogami/s//$nixos_profile/" $SCRIPT_DIR/flake.nix -gum log --structured --level info "Setting hostname in flake.nix..." file $SCRIPT_DIR/flake.nix +sed -i "0,/kogami/s//$nixos_profile/" "$SCRIPT_DIR/flake.nix" +gum log --structured --level info "Setting hostname in flake.nix..." file "$SCRIPT_DIR/flake.nix" # Set dotfiles path as $SCRIPT_DIR path #! IMPORTANT # Editor -if [ -z $EDITOR ]; then - EDITOR=nano +if [ -z "$EDITOR" ]; then + EDITOR=nano fi -gum log --structured --level info "Opening flake.nix in $EDITOR..." file $SCRIPT_DIR/flake.nix -$EDITOR $SCRIPT_DIR/flake.nix +gum log --structured --level info "Opening flake.nix in $EDITOR..." file "$SCRIPT_DIR/flake.nix" +$EDITOR "$SCRIPT_DIR/flake.nix" -gum log --structured --level info "Building configuration for $nixos_profile..." profile $nixos_profile -sudo nixos-rebuild build --flake $SCRIPT_DIR#"${$nixos_profile}" +gum log --structured --level info "Building configuration for $nixos_profile..." profile "$nixos_profile" +sudo nixos-rebuild build --flake "$SCRIPT_DIR#$nixos_profile" # Wallpapers -if [ $download_wallpapers = true ]; then - gum log --structured --level info "Downloading wallpapers..." profile $nixos_profile - nix-shell -p git --command "git clone https://git.foglar.tech/foglar/wallpapers.git ~/Pictures/wallpapers" +if [ "$download_wallpapers" = true ]; then + gum log --structured --level info "Downloading wallpapers..." profile "$nixos_profile" + nix-shell -p git --command "git clone https://git.foglar.tech/foglar/wallpapers.git ~/Pictures/wallpapers" fi gum confirm "Do you want to reboot now?" && systemctl reboot || gum log --structured --level info "Please reboot later, to switch to the new configuration"