2024-10-14 00:59:15 +03:00
|
|
|
{ ... }:
|
2024-10-11 23:27:07 +03:00
|
|
|
{
|
|
|
|
text = ''
|
|
|
|
# Spawn shell with specified nix environment.
|
|
|
|
# Uses flake.nix in current dir by default.
|
|
|
|
# Usage: shell [NAME]
|
|
|
|
function shell() {
|
|
|
|
local target="''${1}"
|
|
|
|
[[ "''${target}" = "" ]] && target="default"
|
|
|
|
|
2024-10-14 00:59:15 +03:00
|
|
|
SHELL_NAME="''${target}" nix develop ".#''${target}"
|
2024-10-11 23:27:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Spawn temporary nix-shell with specified packages.
|
|
|
|
# Usage: tmpshell <PACKAGES>
|
|
|
|
function tmpshell() {
|
|
|
|
local IFS=$'\n'
|
|
|
|
local input=("''${@}")
|
|
|
|
local pkgs=()
|
2024-10-14 00:59:15 +03:00
|
|
|
local tag="''${1}"
|
2024-10-11 23:27:07 +03:00
|
|
|
|
|
|
|
if [[ "''${input}" = "" ]]; then
|
|
|
|
help tmpshell
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
for pkg in ''${input[@]}; do
|
|
|
|
pkgs+=("nixpkgs#''${pkg}")
|
|
|
|
done
|
|
|
|
|
|
|
|
SHELL_NAME="''${tag}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure ''${pkgs[@]}
|
|
|
|
}
|
|
|
|
|
2024-10-14 00:59:15 +03:00
|
|
|
# Run stuff directrly from Nixpks.
|
|
|
|
# Usage: nixpkgs_run <REV> <PACKAGE> [COMMAND]
|
|
|
|
function nixpkgs_run() {
|
|
|
|
local rev="''${1}"
|
|
|
|
local pkg="''${2}"
|
|
|
|
local cmd="''${@:3}"
|
2024-10-11 23:27:07 +03:00
|
|
|
|
2024-10-14 00:59:15 +03:00
|
|
|
if [[ "''${pkg}" = "" ]]; then
|
|
|
|
help nixpkgs_run
|
|
|
|
return 2
|
|
|
|
fi
|
2024-10-11 23:27:07 +03:00
|
|
|
|
2024-10-14 00:59:15 +03:00
|
|
|
[[ "''${cmd}" = "" ]] && cmd="''${pkg}"
|
2024-10-11 23:27:07 +03:00
|
|
|
|
2024-10-14 00:59:15 +03:00
|
|
|
SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd}
|
2024-10-11 23:27:07 +03:00
|
|
|
}
|
|
|
|
'';
|
2024-04-06 03:03:58 +03:00
|
|
|
}
|