summary refs log tree commit diff stats
path: root/bin/home-manager
diff options
context:
space:
mode:
Diffstat (limited to 'bin/home-manager')
-rwxr-xr-xbin/home-manager27
1 files changed, 16 insertions, 11 deletions
diff --git a/bin/home-manager b/bin/home-manager
index 5e10bc77..cf434738 100755
--- a/bin/home-manager
+++ b/bin/home-manager
@@ -19,6 +19,10 @@ end
 
 for i in 1
     if test ! -d $user_nixpkgs
+        if test ! -e $user_nixpkgs && test -L $user_nixpkgs
+            echo "~/.config/nixpkgs is a broken symlink, deleting it"
+            rm $channel_root
+        end
         echo "user nixpkgs folder $user_nixpkgs does not exist, creating it"
         mkdir -p $user_nixpkgs
     end
@@ -112,25 +116,26 @@ function update_link --argument-names new_src target
 end
 
 for np in $NIX_PATH
-    echo $np | read --function --delimiter "=" channel new_src_rel
-    set --local new_src (path resolve $new_src_rel)
+    if string match --quiet --entire "=" $np
+        echo $np | read --function --delimiter "=" channel new_src_rel
+        set --local new_src (path resolve $new_src_rel)
 
-    if test $channel = darwin-config
-        continue
-    end
-    if set --local i (contains --index $channel $old_channels)
-        set --erase old_channels[$i]
-    end
+        if test $channel = darwin-config
+            continue
+        end
+        if set --local i (contains --index $channel $old_channels)
+            set --erase old_channels[$i]
+        end
 
-    update_link $new_src $channel_root/$channel
+        update_link $new_src $channel_root/$channel
+    end
 end
 
 for old in $channel_root/$old_channels
     rm $old
 end
 
-set --function i (contains --index (status dirname) $PATH)
-if test -n $i
+if set --function i (contains --index (status dirname) $PATH) && test -n $i
     set --erase PATH[$i]
 end