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 develop: Add --redirect flag to redirect dependencies #4161

Merged
merged 2 commits into from Oct 22, 2020

Conversation

@edolstra
Copy link
Member

@edolstra edolstra commented Oct 18, 2020

This is primarily useful if you're hacking simultaneously on a package and one of its dependencies. E.g. if you're hacking on Hydra and Nix, you would start a dev shell for Nix (which installs in e.g. ~/Dev/nix/outputs), and then a dev shell for Hydra as follows:

$ nix develop \
  --redirect .#hydraJobs.build.x86_64-linux.nix ~/Dev/nix/outputs/out \
  --redirect .#hydraJobs.build.x86_64-linux.nix.dev ~/Dev/nix/outputs/dev

(This assumes hydraJobs.build.x86_64-linux has a passthru.nix attribute. You can also use a store path.)

This causes all references in the environment to those store paths to be rewritten to ~/Dev/nix/outputs/{out,dev}. Note: don't forget to run fixupPhase in the first shell, otherwise pkgconfig files are not in the correct location. Note 2: unfortunately, you may need to set LD_LIBRARY_PATH=~/Dev/nix/outputs/out/lib because Nixpkgs' ld-wrapper only adds -rpath entries for -L flags that point to the Nix store.

@viric

@edolstra edolstra force-pushed the nix-develop-redirects branch from f0388bf to ea1881b Oct 19, 2020
@viric
Copy link
Member

@viric viric commented Oct 20, 2020

Oh I'll have to give a try to this! I have yet to grasp flakes fully. I'll go through your blogposts for that.

@viric
Copy link
Member

@viric viric commented Oct 20, 2020

Do you think this will work for a common c++ scenario of, let's say, qpdfview and poppler?

@edolstra edolstra force-pushed the nix-develop-redirects branch from 56f329f to e1c3e1f Oct 21, 2020
@edolstra
Copy link
Member Author

@edolstra edolstra commented Oct 21, 2020

@viric It should also work without flakes though (e.g. nix develop -f /path/to/nixpkgs poppler). Though I just ran into a bug starting nix develop on qpdfview...

edolstra added 2 commits Oct 22, 2020
This is primarily useful if you're hacking simultaneously on a package
and one of its dependencies. E.g. if you're hacking on Hydra and Nix,
you would start a dev shell for Nix, and then a dev shell for Hydra as
follows:

  $ nix develop \
    --redirect .#hydraJobs.build.x86_64-linux.nix ~/Dev/nix/outputs/out \
    --redirect .#hydraJobs.build.x86_64-linux.nix.dev ~/Dev/nix/outputs/dev

(This assumes hydraJobs.build.x86_64-linux has a passthru.nix
attribute. You can also use a store path.)

This causes all references in the environment to those store paths to
be rewritten to ~/Dev/nix/outputs/{out,dev}. Note: unfortunately, you
may need to set LD_LIBRARY_PATH=~/Dev/nix/outputs/out/lib because
Nixpkgs' ld-wrapper only adds -rpath entries for -L flags that point
to the Nix store.
@edolstra edolstra force-pushed the nix-develop-redirects branch from e1c3e1f to 750ce50 Oct 22, 2020
@edolstra edolstra merged commit a78582c into NixOS:master Oct 22, 2020
2 checks passed
@edolstra edolstra deleted the nix-develop-redirects branch Oct 22, 2020
@nixos-discourse
Copy link

@nixos-discourse nixos-discourse commented Nov 5, 2020

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

https://discourse.nixos.org/t/tweag-nix-dev-update-4/9862/1

nixos-discourse
Copy link

nixos-discourse commented on f9438fb Dec 20, 2020

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

https://discourse.nixos.org/t/nixos-vs-imperative-development-setups/5863/11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants