Mention Nix derivation in another derivation, but do not create dependency

Whenever the output of a derivation mentions a nix path in /nix/store, Nix creates a dependency between the derivations. Copying the derivation closure copies over all dependencies.

Is there any way to stop this behavior for certain dependencies. My use case is I want nix to build a set of packages, and then create a ‘manifest’ file that mentions a set of disjoint derivations. I want to be able to process the manifest independently of the derivation on a fleet of other machines to determine which derivations I want to copy over to save on bandwidth.

I think one easy idea is to simple mangle the /nix/store names somehow, but if there’s a more elegant way that preserves human readability, I’d be interested.

Any ideas?

You can use nix-instantiate to make .drv files without building them.

And maybe you can use builtins.unsafeDiscardOutputDependency and/or builtins.unsafeDiscardStringContext?

2 Likes

Yeah, I’m familiar with nix-instantiate but this is a bit different. I want to create a ‘manifest file’ in my nix store with lines like

servicename /nix/store/service-closure
servicename2 /nix/store/service-closure2

etc. I want to copy this to servers where the services are deployed without copying the closures mentioned

From my own research, I think I can use nix copy with the --no-recursive flag.

1 Like