From 63547cc0f62e54ec687c0e56030477b9db9f5191 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 | 18 +++++++++++++++++- 2 files changed, 18 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 57b99aee..bcdce055 100644 --- a/shell.nix +++ b/shell.nix @@ -21,13 +21,29 @@ 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 + make bootstrap ''; }