summary refs log tree commit diff stats
path: root/bin/home-manager
diff options
context:
space:
mode:
authorAlan Pearce2024-05-06 13:07:15 +0200
committerAlan Pearce2024-05-18 12:17:12 +0200
commita46864566b13b61bddd9b0ee15457efa288ec3de (patch)
treee786fc6178040ceb62b3fee8374233c18c842c00 /bin/home-manager
parent64139f9a3660d779fdc59747ca465c48aef04648 (diff)
downloadnixfiles-a46864566b13b61bddd9b0ee15457efa288ec3de.tar.lz
nixfiles-a46864566b13b61bddd9b0ee15457efa288ec3de.tar.zst
nixfiles-a46864566b13b61bddd9b0ee15457efa288ec3de.zip
pin channels using nix.nixPath rather than using ~/.nix-defexpr
Diffstat (limited to 'bin/home-manager')
-rwxr-xr-xbin/home-manager54
1 files changed, 4 insertions, 50 deletions
diff --git a/bin/home-manager b/bin/home-manager
index de6f4edb..39ed1639 100755
--- a/bin/home-manager
+++ b/bin/home-manager
@@ -29,40 +29,9 @@ for i in 1
         echo "user home-manager configuration folder $hm_config_dir does not exist, creating it"
         mkdir -p $hm_config_dir
     end
-    if test ! -e $channel_root
-        if test -L $channel_root
-            # broken symlink
-            rm $channel_root
-        end
-        echo "channel root $channel_root does not exist, creating it"
-        mkdir -p $channel_root
-    else
-        if test ! -d $channel_root
-            echo "error: $channel_root is not a directory"
-        else if test -L $channel_root
-            echo "error: $channel_root is a symlink, please remove it"
-        else if path is --invert --perm write $channel_root
-            echo "error: $channel_root is not writable; might be a symlink"
-        else if path is --invert --type link $channel_root/*
-            for p in (path filter --invert --type link $channel_root/*)
-                # might be a broken symlink
-                if test -L $p -a ! -e $p
-                    rm $p
-                else
-                    echo "error: channel $p is not a broken symlink, don't know what to do with it"
-                end
-            end
-            # check again and fail if there are still unknown files
-            if path is --invert --type link $channel_root/*
-                echo "error: non-link(s) in $channel_root"
-                path filter --invert --type link $channel_root/*
-            else
-                continue
-            end
-        else
-            continue # with script
-        end
-        exit 1
+    if test -e $channel_root
+        rm $channel_root/* || exit 1
+        rmdir $channel_root
     end
 end
 
@@ -94,8 +63,6 @@ switch $current_script_name
         set --export HOME_MANAGER_CONFIG $hm_config_source
 end
 
-set --function old_channels (path basename $channel_root/*)
-
 function update_link --argument-names new_src target
     set --function current_src (path resolve $target)
     if test -e $current_src
@@ -110,25 +77,12 @@ 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)
+    echo $np | read --function --delimiter "=" channel new_src
 
-    if test $channel = darwin-config
-        continue
-    end
     if test $channel = nixpkgs-overlays
         update_link $new_src $user_nixpkgs/overlays
         continue
     end
-    if set --local i (contains --index $channel $old_channels)
-        set --erase old_channels[$i]
-    end
-
-    update_link $new_src $channel_root/$channel
-end
-
-for old in $channel_root/$old_channels
-    rm $old
 end
 
 set --function i (contains --index (status dirname) $PATH)