ctucx.git: nixfiles

ctucx' nixfiles

commit 524be211318eae5d313d04dded9fec3da6e11732
parent 97145ffb9906ecf052820e3f43b5ecc46b4fbb03
Author: Katja (ctucx) <git@ctu.cx>
Date: Tue, 18 Mar 2025 12:46:39 +0100

configurations/homeManager/programs: move `use` from shell-fuction to a script
3 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/configurations/homeManager/programs/bash.nix b/configurations/homeManager/programs/bash.nix
@@ -10,15 +10,7 @@
     historyControl  = [ "ignoredups" "ignorespace" ];
     historyIgnore   = [ "ls" "clear" "exit" ];
 
-    bashrcExtra = ''
-      use() {
-        declare -a all
-        for p in "$@"; do
-          all+=("''${NIXPKGS_PATH}#$p")
-        done
-        eval nix shell ''${all[@]}
-      }
-    '' + lib.optionalString pkgs.stdenv.isDarwin ''
+    bashrcExtra = lib.mkIf pkgs.stdenv.isDarwin ''
       if [ "$TERM" != "dumb" ]; then
         source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
         nullglobStatus=$(shopt -p nullglob)
diff --git a/configurations/homeManager/programs/shellUtilities.nix b/configurations/homeManager/programs/shellUtilities.nix
@@ -31,6 +31,14 @@
     coreutils
     trash-cli
 
+    (pkgs.writeShellScriptBin "use" ''
+      declare -a all
+      for p in "$@"; do
+        all+=("''${NIXPKGS_PATH}#$p")
+      done
+      eval nix shell ''${all[@]}
+    '')
+
     wget
     curl
     rsync
diff --git a/configurations/homeManager/programs/zsh.nix b/configurations/homeManager/programs/zsh.nix
@@ -36,15 +36,7 @@
       '';
     };
 
-    initExtra = ''
-      use() {
-        declare -a all
-        for p in "$@"; do
-          all+=("''${NIXPKGS_PATH}#$p")
-        done
-        eval nix shell ''${all[@]}
-      }
-    '' + lib.optionalString pkgs.stdenv.isDarwin ''
+    initExtra = lib.mkIf pkgs.stdenv.isDarwin ''
       if [ "$TERM" != "dumb" ]; then
         source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
         nullglobStatus=$(shopt -p nullglob)