Skip to content

Commit

Permalink
build(nix-shell): add missing lvm packages to pure nix-shell
Browse files Browse the repository at this point in the history
Adds lvm2 and jq
Also ensure sudo works in a pure shell

Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Jan 7, 2025
1 parent 77bbd1a commit 37f58a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions nix/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.go/
.tmp/
/bins/
17 changes: 16 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
}

0 comments on commit 37f58a3

Please sign in to comment.