From 41ab7354c1f06313bed3c2e92762cb660dd82f61 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 25 Nov 2024 15:19:13 +0100 Subject: [PATCH] Ensure nix channels are functioning --- scripts/lib/nix.fish | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/lib/nix.fish b/scripts/lib/nix.fish index f61cb698..7f44084d 100644 --- a/scripts/lib/nix.fish +++ b/scripts/lib/nix.fish @@ -3,10 +3,14 @@ begin set -l config "$dir/config.fish" set nixPkgsDir "/nix/var/nix/profiles/per-user/root/channels/nixpkgs" + function __isNixModule -a path + nix-instantiate --eval --expr "{ path }: import path" --argstr path "$path" &>/dev/null + end + function downloadNixPkgs -V config source "$config" - if [ ! -d "$nixPkgsCache" ] + if ! __isNixModule "$nixPkgsCache" mkdir -p "$nixPkgsCache" and git clone https://github.com/NixOS/nixpkgs.git --depth=1 -b "$nixPkgsVersion" "$nixPkgsCache" and rm -rf "$nixPkgsCache/.git" @@ -16,8 +20,8 @@ begin function installNixPkgs -V config -V nixPkgsDir source "$config" - if [ ! -d "$nixPkgsDir" ] - if [ ! -d "$nixPkgsCache" ] + if ! __isNixModule "$nixPkgsDir" + if ! __isNixModule "$nixPkgsCache" downloadNixPkgs end