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
Conversation
f0388bf
to
ea1881b
Compare
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. |
Do you think this will work for a common c++ scenario of, let's say, qpdfview and poppler? |
56f329f
to
e1c3e1f
Compare
@viric It should also work without flakes though (e.g. |
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.
e1c3e1f
to
750ce50
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Is this supposed to work when the input is not a flake? Or is that a desired feature? |
Can this be used to build some package against host libc? I wanted to build latest librsvg from Nix against libc-2.31 from Ubuntu 20.04. I used this command to start shell: nix develop nixpkgs/nixos-unstable#librsvg --redirect nixpkgs/nixos-unstable#glibc.dev /usr However, I got the warning, that this flake is not used by the build environment. Then I tried to write simple program to ensure I build against old libc: #include <unistd.h>
int main(void) {
closefrom(3);
return 0;
} I expected that this program should not compile as |
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:(This assumes
hydraJobs.build.x86_64-linux
has apassthru.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 runfixupPhase
in the first shell, otherwise pkgconfig files are not in the correct location. Note 2: unfortunately, you may need to setLD_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