No, unfortunately we cannot. When Nix runs it executes all the expressions to instantiate derivations, whose hash is then used to query the binary cache. At the point where the derivation is instantiated all of the context where it came from is lost. You can check this for yourself by having a look at the JSON serialization of the derivation contents, e.g.
$ nix show-derivation "$(nix-instantiate '<nixpkgs>' -A hello)"
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
{
"/nix/store/90jjw94xiyg5drj70whm9yll6xjj0ca9-hello-2.10.drv": {
"outputs": {
"out": {
"path": "/nix/store/fjc71ycmr5fnfxyfgwi2dwh323z12gvq-hello-2.10"
}
},
"inputSrcs": [
"/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
],
"inputDrvs": {
"/nix/store/cy27ypqr3ipxsvjl1mni2xcyf62rgvwj-stdenv-linux.drv": [
"out"
],
"/nix/store/q4dcb46srn8ykn02wjqp1gdxvwcfaw2i-hello-2.10.tar.gz.drv": [
"out"
],
"/nix/store/xa4b7dfdsnig7n6glm696wmqad0zvybj-bash-4.4-p23.drv": [
"out"
]
},
"system": "x86_64-linux",
"builder": "/nix/store/xvvgw9sb8wk6d2c0j3ybn7sll67s3s4z-bash-4.4-p23/bin/bash",
"args": [
"-e",
"/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
],
"env": {
"buildInputs": "",
"builder": "/nix/store/xvvgw9sb8wk6d2c0j3ybn7sll67s3s4z-bash-4.4-p23/bin/bash",
"configureFlags": "",
"depsBuildBuild": "",
"depsBuildBuildPropagated": "",
"depsBuildTarget": "",
"depsBuildTargetPropagated": "",
"depsHostHost": "",
"depsHostHostPropagated": "",
"depsTargetTarget": "",
"depsTargetTargetPropagated": "",
"doCheck": "1",
"doInstallCheck": "",
"name": "hello-2.10",
"nativeBuildInputs": "",
"out": "/nix/store/fjc71ycmr5fnfxyfgwi2dwh323z12gvq-hello-2.10",
"outputs": "out",
"patches": "",
"pname": "hello",
"propagatedBuildInputs": "",
"propagatedNativeBuildInputs": "",
"src": "/nix/store/3x7dwzq014bblazs7kq20p9hyzz0qh8g-hello-2.10.tar.gz",
"stdenv": "/nix/store/7gdji02y6rbnzv5mcxcf3mwksk785y8j-stdenv-linux",
"strictDeps": "",
"system": "x86_64-linux",
"version": "2.10"
}
}
}
As you can see there is absolutely no reference to pkgs/applications/misc/hello/default.nix
or anything similar left.
The hash of the outPath
is used to query the binary cache:
$ curl https://cache.nixos.org/fjc71ycmr5fnfxyfgwi2dwh323z12gvq.narinfo
StorePath: /nix/store/fjc71ycmr5fnfxyfgwi2dwh323z12gvq-hello-2.10
URL: nar/0nb8qh3ihhls6jh2kgdl1jlkrzrf0w1advrr31s5dfy8pmmkirr4.nar.xz
Compression: xz
FileHash: sha256:0nb8qh3ihhls6jh2kgdl1jlkrzrf0w1advrr31s5dfy8pmmkirr4
FileSize: 41096
NarHash: sha256:17fcqinwrvgb2ybws0rlxg73zc4i61ps7pd5bs9p6wv2rn9nvd67
NarSize: 206000
References: fjc71ycmr5fnfxyfgwi2dwh323z12gvq-hello-2.10 gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48
Deriver: 90jjw94xiyg5drj70whm9yll6xjj0ca9-hello-2.10.drv
Sig: cache.nixos.org-1:LWlFpKJGMOQIwuiLEiFt4YwLHWC5ynMyVogLEHc6ZV4Xd+vXHanSr5ZqJ7XJN1kI90Li8xE1XGnbI6tHc8GJCA==