From 9869a7129effc0e3d1a41a6de280ee9f972f76e7 Mon Sep 17 00:00:00 2001 From: Tiago Castro Date: Tue, 7 Jan 2025 12:51:32 +0000 Subject: [PATCH] build(nix-shell): add missing lvm packages to pure nix-shell Adds lvm2 and jq Also ensure sudo works in a pure shell Signed-off-by: Tiago Castro --- nix/.gitignore | 1 + shell.nix | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nix/.gitignore b/nix/.gitignore index 5a89bf48..117ba42c 100644 --- a/nix/.gitignore +++ b/nix/.gitignore @@ -1,2 +1,3 @@ .go/ .tmp/ +/bins/ \ No newline at end of file diff --git a/shell.nix b/shell.nix index f09eee7d..6b51fe9e 100644 --- a/shell.nix +++ b/shell.nix @@ -21,12 +21,27 @@ pkgs.mkShell { cacert util-linux musl - ] ++ pkgs.lib.optional (builtins.getEnv "IN_NIX_SHELL" == "pure") docker; + jq + lvm2 + ] ++ pkgs.lib.optional (builtins.getEnv "IN_NIX_SHELL" == "pure") [ docker ]; shellHook = '' export GOPATH=$(pwd)/nix/.go export GOCACHE=$(pwd)/nix/.go/cache export TMPDIR=$(pwd)/nix/.tmp export PATH=$GOPATH/bin:$PATH mkdir -p "$TMPDIR" + + if [ "$IN_NIX_SHELL" = "pure" ]; then + # working sudo within a pure nix-shell + for sudo in /run/wrappers/bin/sudo /usr/bin/sudo /usr/local/bin/sudo /sbin/sudo /bin/sudo; do + mkdir -p $(pwd)/nix/bins + ln -sf $sudo $(pwd)/nix/bins/sudo + export PATH=$(pwd)/nix/bins:$PATH + break + done + else + rm $(pwd)/nix/bins/sudo 2>/dev/null || : + rmdir $(pwd)/nix/bins 2>/dev/null || : + fi ''; }