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
Add a derefPath function that copies a path to the store #37730
Conversation
This function will copy a path to the nix store. The difference with using `src = ./.` is how symbolic links are handled. Nix normally just copies those links as-is into the store. This function can be used to dereference all symbolic links. ``` { stdenv, derefPath }: stdenv.mkDerivation rec { name = "hello"; src = derefPath { name = "${name}-src"; src = ./.; }; } ``` This is a quick and dirty fix for the following issues in `NixOS/nix`: * NixOS/nix#1232 * NixOS/nix#897
I'm having trouble composing this with if lib.inNixShell
then null
else lib.flip lib.sourceFilesBySuffices tex_exts (derefPath {
name = "${name}-src";
src = ./.;
}); yields
Any tips? Am I doing this wrong, or is there a way to improve the compositionality of this function? Also, some documentation might be good! EDIT: I can confirm that this does work well for its intended purpose. Thank you for sharing! EDIT 2: There's actually one other small issue: when the content backing the symlink is updated, Nix doesn't notice and rebuild |
@peti Does this seem like a decent first step to dealing with NixOS/nix#897 and NixOS/nix#1232 to you? |
Though, I think this might not work correctly with sandboxing, because it creates a derivation which the sandboxed builder runs and tries to |
Disadvantage of course is that it has two copy stuff twice. |
I don't understand the name. "Dereferencing a path" means something like Also this would be better to handle in Nix (maybe as a flag to |
Yeah. Something like |
I don't think this should be part of nixpkgs. This of course nobody stops it from copying the function into their own projects. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/how-to-stop-nix-from-unpacking-a-directory/6866/4 |
This function will copy a path to the nix store. The difference with
using
src = ./.
is how symbolic links are handled. Nix normally just copies those links as-is into the store.This function can be used to dereference all symbolic links.
Example
This is a quick and dirty fix for the following issues in
NixOS/nix
:Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)