Skip to content

Conversation

@phanirithvij
Copy link
Contributor

@phanirithvij phanirithvij commented Jan 19, 2026

Previously

$ nix-shell
# prints menu
$ nix-shell --pure
/nix/store/...-devshell-dir/bin/menu: line 4: cat: command not found
bash: cat: command not found
$ nix-shell --pure --run 'exit'
/tmp/nix-shell-704775-1158748079/rc: line 1: rm: command not found

Now

$ nix-shell --pure
# prints menu
[devshell]$
$ nix-shell --pure --run 'exit'
$ echo $?
0

@phanirithvij phanirithvij force-pushed the refactor-and-fix-cat-bug branch 2 times, most recently from d1256bc to 15aeaab Compare January 19, 2026 07:37
@phanirithvij phanirithvij marked this pull request as draft January 19, 2026 07:40
@phanirithvij phanirithvij force-pushed the refactor-and-fix-cat-bug branch from 15aeaab to 7fc7675 Compare January 19, 2026 07:56
@phanirithvij phanirithvij marked this pull request as ready for review January 19, 2026 08:05
@phanirithvij phanirithvij changed the title fix: use cat from coreutils fix: support pure mode Jan 19, 2026
Comment on lines +11 to +14
rmCommand = runCommand "coreutils-rm" { } ''
mkdir -p $out/bin
ln -s ${coreutils}/bin/rm $out/bin/rm
'';
Copy link
Contributor Author

@phanirithvij phanirithvij Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this to avoid adding all of coreutils to the naked shell.

# Fix for `nix-shell --pure` line 1: rm: command not found
# occurs at `_nix_shell_clean_tmpdir` in `nixos/nix`
${lib.optionalString (builtins.getEnv "IN_NIX_SHELL" == "pure") ''
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builtins.getEnv "IN_NIX_SHELL" doesn't seems to be problematic from my cursory running of nix develop --ignore-environment --pure-eval nix-shell nix-shell --pure etc.

This issue occurs only for nix-shell --pure and I fixed it only for that case.

Comment on lines 30 to 37
export PATH=${cfg.package}/bin:${pkgs.coreutils}/bin
# Abort if the data dir already exists
[[ ! -d "$PGDATA" ]] || exit 0
initdb ${concatStringsSep " " cfg.initdbArgs}
initdb ${lib.concatStringsSep " " cfg.initdbArgs}
cat >> "$PGDATA/postgresql.conf" <<EOF
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cat is fine. because of coreutils added to the path.

@zimbatm
Copy link
Member

zimbatm commented Jan 19, 2026

Do you mind sending a second PR with the changes to lib? Those changes are mostly mechanical and then I can review the meaty changes more easily.

When it comes to with lib;, I'm with you. I used to like with lib; for the convenience, but nowadays I prefer to be explicit always.

The only place where I sometimes still use the keyword is on a very limited scope, like with pkgs; [ curl gnused ].

Sometimes when the repetition of lib. or pkgs. prefix gets too much, I stick a inherit (lib) mkOption mkEnableOption; line at the top.

@phanirithvij phanirithvij force-pushed the refactor-and-fix-cat-bug branch from 7fc7675 to 8622022 Compare January 19, 2026 09:30
@phanirithvij
Copy link
Contributor Author

Opened #360

@zimbatm
Copy link
Member

zimbatm commented Jan 19, 2026

thanks, merged

Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
@phanirithvij phanirithvij force-pushed the refactor-and-fix-cat-bug branch from 8622022 to fc08871 Compare January 19, 2026 09:41
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
@zimbatm zimbatm merged commit 255a2b1 into numtide:main Jan 19, 2026
3 of 10 checks passed
@zimbatm
Copy link
Member

zimbatm commented Jan 19, 2026

thanks!

@phanirithvij phanirithvij deleted the refactor-and-fix-cat-bug branch January 19, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants