Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-shell: look up shell.nix when argument is a directory #11057

Merged

Conversation

roberth
Copy link
Member

@roberth roberth commented Jul 6, 2024

Motivation

Solve a long standing bug responsibly; see release note.

Users who have complicated shell.nix/default.nix setups can opt out by setting nix-shell-always-looks-for-shell-nix to false.
If they do, they'll be warned when the new behavior would be triggered.

  expectStderr 1 nix-shell $TEST_ROOT/lookup-test -A shellDrv --run 'echo "it works"' --option nix-shell-always-looks-for-shell-nix false \
    | grepQuiet "Skipping .*lookup-test/shell\.nix.*, because the setting .*nix-shell-always-looks-for-shell-nix.* is disabled. This is a deprecated behavior\. Consider enabling .*nix-shell-always-looks-for-shell-nix.*"

Context

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@roberth roberth added bug cli The old and/or new command line interface nix-shell nix-shell, nix develop, nix print-dev-env, etc breaking Changes we can't make without breaking old expressions, changing hashes, etc significant Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc. labels Jul 6, 2024
@github-actions github-actions bot added documentation with-tests Issues related to testing. PRs with tests have some priority labels Jul 6, 2024
@roberth roberth force-pushed the nix-shell-lookup-shell-nix branch from afbe7c3 to 6959ac1 Compare July 6, 2024 22:26
@roberth roberth force-pushed the nix-shell-lookup-shell-nix branch from 6959ac1 to d5e16f6 Compare July 6, 2024 23:04
@roberth roberth force-pushed the nix-shell-lookup-shell-nix branch from d5e16f6 to c4a20a4 Compare July 6, 2024 23:22
Copy link
Contributor

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

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

This is a great fix! I've ran into the problem a couple of times, it's one of the thousand paper cuts.

It is unclear to me why this worked when not in a VM test, but the
explanation would be in the part of nix-shell we're getting rid of
with the devShell attribute.
@fricklerhandwerk fricklerhandwerk merged commit cfe3ee3 into NixOS:master Jul 8, 2024
11 checks passed
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-07-08-nix-team-meeting-minutes/49099/1

@@ -317,7 +338,8 @@ static void main_nix_build(int argc, char * * argv)

auto sourcePath = lookupFileArg(*state,
baseDir);
auto resolvedPath = resolveExprPath(sourcePath);
auto resolvedPath =
isNixShell ? resolveShellExprPath(sourcePath) : resolveExprPath(sourcePath);
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe the condition should be: isNixShell and no -A was passed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Changes we can't make without breaking old expressions, changing hashes, etc bug cli The old and/or new command line interface documentation nix-shell nix-shell, nix develop, nix print-dev-env, etc significant Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc. with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
3 participants