From b6417ac732f6c1d529bb0c167eba13ce74b07462 Mon Sep 17 00:00:00 2001 From: Charles Gould Date: Tue, 21 Dec 2021 03:20:20 -0500 Subject: [PATCH] fish: add nix-env plugin --- fish/conf.d/nix.fish | 21 --------------------- fish/fish_plugins | 1 + install/install-nix-packages.sh | 18 +++++++++++++----- install/install-nix.sh | 2 +- 4 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 fish/conf.d/nix.fish diff --git a/fish/conf.d/nix.fish b/fish/conf.d/nix.fish deleted file mode 100644 index aa5ef71..0000000 --- a/fish/conf.d/nix.fish +++ /dev/null @@ -1,21 +0,0 @@ -# Nix package manager -# -# If Nix is installed: -# - source the profile with bash -# - export the NIX_* variables in fish -# - add Nix profile to PATH -# -# There is no fish profile to source yet. -# https://github.com/NixOS/nix/issues/1512 -if test -f ~/.nix-profile/etc/profile.d/nix.sh - for line in (bash -c 'source $0; for name in "${!NIX_@}"; do printf "%s=%s\n" "$name" "${!name}"; done' ~/.nix-profile/etc/profile.d/nix.sh) - set -gx (string split -m 1 = $line) - end - if functions -q fish_add_path - fish_add_path -gP ~/.nix-profile/bin - else - if not contains -- ~/.nix-profile/bin $PATH - set PATH ~/.nix-profile/bin $PATH 2>/dev/null - end - end -end diff --git a/fish/fish_plugins b/fish/fish_plugins index 7557c36..2db09c7 100644 --- a/fish/fish_plugins +++ b/fish/fish_plugins @@ -2,5 +2,6 @@ jorgebucaran/fisher jorgebucaran/replay.fish oakninja/MakeMeFish laughedelic/fish_logo +lilyball/nix-env.fish jethrokuan/z reitzig/sdkman-for-fish@v1.4.0 diff --git a/install/install-nix-packages.sh b/install/install-nix-packages.sh index 8be94df..ce080d5 100755 --- a/install/install-nix-packages.sh +++ b/install/install-nix-packages.sh @@ -3,12 +3,20 @@ echo "***** INSTALL NIX PACKAGES *****" ROOTDIR=$(cd "$(dirname "$0")/.." && pwd) -NIX_ENV="$HOME/.nix-profile/bin/nix-env" -if [ -x "$NIX_ENV" ]; then - "$NIX_ENV" --install --remove-all --file "$ROOTDIR/nix/packages.nix" -else - echo "Cannot install Nix packages! $NIX_ENV is not executable." +found_nix_command=0 + +for profile in "$HOME/.nix-profile" "/nix/var/nix/profiles/default" +do + if test -x "$profile/bin/nix-env"; then + "$profile/bin/nix-env" --install --remove-all --file "$ROOTDIR/nix/packages.nix" + found_nix_command=1 + break + fi +done + +if test $found_nix_command -ne 1; then + echo "Cannot install Nix packages! Command not found: nix-env" fi echo diff --git a/install/install-nix.sh b/install/install-nix.sh index aec2b0b..e006370 100755 --- a/install/install-nix.sh +++ b/install/install-nix.sh @@ -5,7 +5,7 @@ echo "***** INSTALL NIX *****" if [ -d /nix ]; then echo "Nix is already installed." else - /bin/bash -c "$(curl -fsSL https://nixos.org/nix/install) --no-daemon" + curl -fsSL https://nixos.org/nix/install | sh fi echo