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

option to keep derivations #63

Open
nrdxp opened this issue Jan 20, 2023 · 7 comments
Open

option to keep derivations #63

nrdxp opened this issue Jan 20, 2023 · 7 comments

Comments

@nrdxp
Copy link
Contributor

nrdxp commented Jan 20, 2023

There are a variety of Nix commands that can be run on derivation files themselves to avoid additional evaluation.

For example, if one calls nix print-dev-env on an outpath whose derivation exists in the store, then that derivation will be used as the basis for the shell that is loaded. If the derivation does not exist in the store the command fails. I would like to use this command to enter a devshell in a container without any extra evaluation (the devshell outpath already exists in the image), but I cannot do this because the derivation path is stripped out.

I also cannot reference drvPath directly as it adds over 20G of dependencies to the images, which is obviously not cool. Instead, It'd be nice to give users the option to copy over the derivation files for the outpaths included in the image for these types of usecases, similar to Nix's own keep-derivations nix.conf setting.

@nlewo
Copy link
Owner

nlewo commented Jan 25, 2023

IIUC, in the /nix/store presents in the container, you would like to have the container derivation file, without its derivation file dependencies. I think that would be possible but this would lead to a broken /nix/store and i don't think that's a good idea.

@blaggacao
Copy link
Contributor

blaggacao commented Jan 25, 2023

Untitled Diagram (1)

IIUC

Pretty much! "Kill the toil..."

Premise: wanting to use nix inside the container, e.g. containers.dev

@nlewo
Copy link
Owner

nlewo commented Jan 25, 2023

Hm, ok.

I think the closure-graph.json file should contains both the store path and the drv paths. I however don't have any idea on how to do that :/

Could be related to this issue: NixOS/nix#1245 (comment)

@nrdxp
Copy link
Contributor Author

nrdxp commented Jan 26, 2023

IIUC, in the /nix/store presents in the container, you would like to have the container derivation file, without its derivation file dependencies. I think that would be possible but this would lead to a broken /nix/store and i don't think that's a good idea.

No I don't mind having all the drv dependencies, they are usually pretty light since they are just text and maybe a few fetched sources. I think it'd be good to have as a non-default option.

@nlewo
Copy link
Owner

nlewo commented Jan 26, 2023

@nrdxp yes, I agree (and i have understood that with the @blaggacao diagram).
However, i think having runtime drvs without build time storepaths seems to be pretty difficult (i dont really understand all of these internal Nix mechanisms).

If the implementation is straightforward, i agree having an option would be nice.

@nrdxp
Copy link
Contributor Author

nrdxp commented Jan 27, 2023

I know how to do it in straight Nix. nix copy can do it but its kinda expensive as it copies one file at a time. The most efficient way to do it is with nix-store --export piped to a nix-store --import. Here is an example of how we do it in std-action to pass the derivations to the runner jobs for them to build.

@nlewo
Copy link
Owner

nlewo commented Jan 27, 2023

@nrdxp yes, but this would have to be done at build time (in the sandbox), and i think that's much more difficult than doing it at runtime where you can query the Nix database.

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

No branches or pull requests

3 participants