From 1e0dc4783f04184f9912afc25ba07b318d71671d Mon Sep 17 00:00:00 2001 From: Rachel Lambda Samuelsson Date: Tue, 9 Jul 2024 18:16:28 +0200 Subject: [PATCH] shell functions for running and creating shells --- home-manager/shell.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/home-manager/shell.nix b/home-manager/shell.nix index c0cc426..116b712 100644 --- a/home-manager/shell.nix +++ b/home-manager/shell.nix @@ -21,6 +21,27 @@ initExtra = '' source ~/.profile set -o vi + + run() { + pkg="$1" + [ "$pkg" = "''${pkg##*#}" ] && pkg="nixpkgs#$pkg" + export NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_BROKEN=1 + nix run --impure "$pkg" + } + + shell() { + i="$#" + while [ "$i" -gt 0 ]; do + pkg="$1" + [ "$pkg" = "''${pkg##*#}" ] && pkg="nixpkgs#$pkg" + shift + set -- "$@" "$pkg" + : $(( i -= 1 )) + done + export NIXPKGS_ALLOW_UNFREE=1 NIXPKGS_ALLOW_BROKEN=1 + nix shell --impure "$@" + } + ''; }; programs.direnv = {