Commit 0a8a4c54f57a

Vincent Demeester <vincent@sbr.pm>
2018-09-06 14:21:01
Extract common function somewhere…
… and name it weirdly (starting with a) to make sure it's loaded first Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent d3e7420
fish/a_nix_run.fish
@@ -0,0 +1,24 @@
+function _nix_run_package
+    set -l s $argv[1]
+    set -l package (string split ":" $s)
+    switch (count $package)
+	case 1
+	    _nix_run $s $s $argv[2] $argv[3]
+	case 2
+	    _nix_run $package[1] $package[2] $argv[2] $argv[3]
+    end
+end
+
+function _nix_run
+    set -l c $argv[1]
+    set -l p $argv[2]
+    set -l channel $argv[3]
+    set -l channelsfile $argv[4]
+    function $c --inherit-variable c --inherit-variable p --inherit-variable channel --inherit-variable channelsfile
+	set -l cmd nix run
+	if test -n "$channelsfile"
+	    set cmd $cmd -f $channelsfile
+	end
+	eval $cmd $channel.$p -c $c $argv
+    end
+end
fish/nix-aliases.fish
@@ -9,29 +9,4 @@ function _def_nix_run_aliases
     end
 end
 
-function _nix_run_package
-    set -l s $argv[1]
-    set -l package (string split ":" $s)
-    switch (count $package)
-	case 1
-	    _nix_run $s $s $argv[2] $argv[3]
-	case 2
-	    _nix_run $package[1] $package[2] $argv[2] $argv[3]
-    end
-end
-
-function _nix_run
-    set -l c $argv[1]
-    set -l p $argv[2]
-    set -l channel $argv[3]
-    set -l channelsfile $argv[4]
-    function $c --inherit-variable c --inherit-variable p --inherit-variable channel --inherit-variable channelsfile
-	set -l cmd nix run
-	if test -n "$channelsfile"
-	    set cmd $cmd -f $channelsfile
-	end
-	eval $cmd $channel.$p -c $c $argv
-    end
-end
-
 _def_nix_run_aliases
fish.nix
@@ -8,6 +8,7 @@
     eval (${pkgs.direnv}/bin/direnv hook fish)
     '';
   };
+  xdg.configFile."fish/conf.d/a_nix_run.fish".source = ./fish/a_nix_run.fish;
   xdg.configFile."fish/conf.d/nix-aliases.fish".source = ./fish/nix-aliases.fish;
   xdg.configFile."fish/conf.d/sudope.fish".source = ./fish/sudope.fish;
   xdg.configFile."fish/functions/sudope.fish".source = ./fish/sudope.function.fish;