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

bundlerApp: take buildInputs #45435

Merged
merged 1 commit into from Oct 29, 2018
Merged

Conversation

alyssais
Copy link
Member

It would be reasonable to have a Ruby program that depends on some other program being in the PATH. In this case, the obvious thing to do would be something like this:

bundlerApp {
  # ...
  buildInputs = [ makeWrapper ];
  postBuild = ''
    wrapProgram "$out/bin/foo" \
      --prefix PATH : ${lib.makeBinPath [ dep ]}
  '';
}

However, this doesn't work, because even though it just forwards most of its arguments to runCommand, bundlerApp won't take a buildInputs parameter. It doesn't even specify its own buildInputs, which means that the scripts parameter to bundlerApp (which depends on makeWrapper) is completely broken, and, as far as I can tell, has been since its inception. By making the default [ makeWrapper ], I have fixed this.

I've added a buildInputs option to bundlerApp. It's also passed through to bundled-common because postBuild scripts are run there as well. This actually means that in this example we'd end up going through two layers of wrappers (one from bundlerApp and one from bundled-common), but that has always been the case and isn't likely to break anything. That oddity does suggest that it might be prudent to not forward postBuild to bundled-common (or to at least use a different option) though...

FWIW, as far as I can tell no package in nixpkgs uses either the scripts or postBuild options to bundlerApp.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@globin
Copy link
Member

globin commented Aug 21, 2018

cc @manveru

@manveru
Copy link
Contributor

manveru commented Aug 22, 2018

I don't see any problems with it and the code looks good, but haven't used bundlerApp myself yet.

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

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

It makes sense. Can you also add nativeBuildInputs and propagatedBuildInputs and propagatedNativeBuildInputs?

@@ -25,6 +25,7 @@
, preferLocalBuild ? false
, allowSubstitutes ? false
, meta ? {}
, buildInputs ? [ makeWrapper ]
Copy link
Member

Choose a reason for hiding this comment

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

makeWrapper should be passed as a nativeBuildInput for cross-compiling

@zimbatm
Copy link
Member

zimbatm commented Aug 24, 2018

anonymous function at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/pkgs/build-support/buildenv/default.nix:8:2 called with unexpected argument 'propagatedNativeBuildInputs', at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/lib/customisation.nix:69:12

@globin
Copy link
Member

globin commented Aug 24, 2018

Also I don't think makeWrapper should be passed in as default? Especially since when specifying the parameter it wouldn't be merged with the default value.

@alyssais
Copy link
Member Author

@globin if makeWrapper isn't passed, the scripts parameter doesn't work. I guess I could add it later if scripts is set, rather than having it be a default…

@globin
Copy link
Member

globin commented Aug 24, 2018

That would be better

@alyssais
Copy link
Member Author

@zimbatm It looks like the other *buildInputs aren't going to work, because they end up being passed to buildEnv, which only takes buildInputs and will error on anything else. Should buildEnv be updated to take the others as well?

@zimbatm
Copy link
Member

zimbatm commented Aug 27, 2018

sorry about the extra work. in that case only buildInputs is already an improvement

It would be reasonable to have a Ruby program that depends on some other
program being in the PATH. In this case, the obvious thing to do would
be something like this:

    bundlerApp {
      # ...
      buildInputs = [ makeWrapper ];
      postBuild = ''
        wrapProgram "$out/bin/foo" \
          --prefix PATH : ${lib.makeBinPath [ dep ]}
      '';
    }

However, this doesn't work, because even though it just forwards most of
its arguments to `runCommand`, `bundlerApp` won't take a `buildInputs`
parameter. It doesn't even specify its own `buildInputs`, which means
that the `scripts` parameter to `bundlerApp` (which depends on
`makeWrapper`) is completely broken, and, as far as I can tell, has been
since its inception. I've added a `makeWrapper` build input if the
scripts parameter is present to fix this.

I've added a `buildInputs` option to `bundlerApp`. It's also passed
through to bundled-common because `postBuild` scripts are run there as
well. This actually means that in this example we'd end up going through
two layers of wrappers (one from `bundlerApp` and one from
bundled-common), but that has always been the case and isn't likely to
break anything. That oddity does suggest that it might be prudent to
not forward `postBuild` to bundled-common (or to at least use a
different option) though...

FWIW, as far as I can tell no package in nixpkgs uses either the
`scripts` or `postBuild` options to `bundlerApp`.
@alyssais
Copy link
Member Author

Updated to fix a merge conflict. @zimbatm is there anything else needing done here?

@zimbatm
Copy link
Member

zimbatm commented Oct 29, 2018

all good, thanks!

@zimbatm zimbatm merged commit 69dcb1a into NixOS:master Oct 29, 2018
@alyssais alyssais deleted the bundler-buildInputs branch November 2, 2018 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants