Skip to content

Conversation

@zgagnon
Copy link

@zgagnon zgagnon commented Dec 17, 2024

  • Add new devShell input
  • defaults to default
  • add test to make sure we can enter

Passing the devshell in the args line wasn't working, because default was added to the args list in the script. This change give a clean mechanism to enable that

- Add new devShell input
- defaults to default
- add test to make sure we can enter
@nicknovitski
Copy link
Owner

Thank you for the contribution but I don't understand the defect you're encountering. I test setting the arguments input to devShell outputs besides default on this line:

arguments: github:DeterminateSystems/zero-to-nix#${{ matrix.shell }}

You can see from any run of that workflow that the matrix is a list of many different devShells, like example, cpp, hook, etc.

Also, I pushed a branch that adds the same test you've added here, and it passes without your change: https://github.com/nicknovitski/nix-develop/actions/runs/12385445478/job/34571695093

default was added to the args list in the script
When this happens, what are the effects, and what environment is it happening in? Does the action fail, or are the wrong tools present?

In bash, the parameter expansion ${varname:-word} evaluates to word if $varname is unset or null, and to $varname otherwise, so the expression ${@:-./#default} evaluates to ./#default if the parameters variable $@ is null and to $@ otherwise. This is what I see on my system:

~/Source/nix-develop/ > nix develop
bash-5.2$ defaultOr() {
> echo "${@:-./#default}"
> }
bash-5.2$ defaultOr
./#default
bash-5.2$ defaultOr ./#notDefault
./#notDefault

@zgagnon
Copy link
Author

zgagnon commented Dec 18, 2024

So, we have a dev shell for local dev with a lot of tools for doing dev, and a ci one with only the build tools. When passing .#ci as an argument, the default profile was still activating

@nicknovitski
Copy link
Owner

Then what am I doing wrong here?

- name: Test with another local shell target
uses: ./
with:
arguments: ./#notDefault
- run: which shfmt
id: should-fail
continue-on-error: true
- name: Fail if the action succeeded when the nix command failed
if: steps.should-fail.outcome == 'success'
run: exit 1

The notDefault devShell is evaluated, and then which shfmt fails, because it doesn't include that package. The default devShell does, but it's not evaluated, and it's packages are not added to PATH. Here's the ci job where it passes. https://github.com/nicknovitski/nix-develop/actions/runs/12385985222/job/34573126333

@zgagnon
Copy link
Author

zgagnon commented Dec 18, 2024

No, I mean, I am probably doing something wrong. Let me go back and look at it again, and see if I can figure out why it wasn't working for me. At worst, I'll have some logs to share

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