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

diskrsync: add ssh to PATH #37969

Merged
merged 1 commit into from Apr 1, 2018
Merged

Conversation

jluttine
Copy link
Member

Motivation for this change

SSH is a required runtime-only dependency of Diskrsync. This adds SSH to PATH by
using a wrapper.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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/)
  • Fits CONTRIBUTING.md.

@jluttine
Copy link
Member Author

I'm not sure if this wrapping is done correctly. For instance, does the metadata propagate properly to the wrapped package?

makeWrapper \
${diskrsync}/bin/diskrsync \
$out/bin/diskrsync \
--prefix PATH : ${openssh}/bin
Copy link
Member

Choose a reason for hiding this comment

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

use wrapProgram instead in the preFixup phase of the original derivation instead in runCommand: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/nrpl/default.nix#L32

Copy link
Member Author

Choose a reason for hiding this comment

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

But that would cause unnecessary re-compilation of the Go package when just the runtime-only dependency SSH changes. Doesn't sound right to me...

@Mic92
Copy link
Member

Mic92 commented Mar 28, 2018

These are micro-optimization that hurt maintainability and probably do not even pay of:

$ cd ~/go/src/github.com/dop251/diskrsync/diskrsync
$ time go build .
go build .  0.36s user 0.09s system 138% cpu 0.326 total

Your runCommand creates a separate derivation which probably takes longer if sandboxing is enabled then recompiling diskrsync

@jluttine
Copy link
Member Author

Ok! In that case, is preFixup wrapping in some way better than just adding openssh to propagatedBuildInputs? In my opinion, propagatedBuildInputs is easier to understand and maintain, but is it worse in some sense in this case?

@Mic92
Copy link
Member

Mic92 commented Mar 28, 2018

It would only propagate in the context of a build or in a nix-shell, not if someone installs the package. Therefore a wrapper is the way to go.

@jluttine
Copy link
Member Author

Ok, thanks for the explanation. I'll make the suggested fix.

@jluttine
Copy link
Member Author

Well this is weird.. I tried prePatch phase but ls $out gives:

drwxr-xr-x 3 nixbld nixbld 4096 Mar 28 18:55 share

So there is no $out/bin, so I have no idea where .../bin/diskrsync should be located at this point of the build process...

@jluttine
Copy link
Member Author

Ah, the executable is in $bin/bin/diskrsync not in $out/bin/diskrsync. Always learning something.

SSH is a required runtime-only dependency of Diskrsync. This adds SSH to PATH by
by using a wrapper.
@jluttine
Copy link
Member Author

Ok, made the fix. Good to merge now?

@matthewbauer matthewbauer merged commit f4b9d01 into NixOS:master Apr 1, 2018
@jluttine jluttine mentioned this pull request Apr 23, 2018
8 tasks
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

4 participants