Docker image broken
srid opened this issue · 5 comments
https://github.com/srid/notes.srid.ca/runs/2347514181?check_suite_focus=true
docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "neuron": executable file not found in $PATH: unknown.
time="2021-04-14T21:59:22Z" level=error msg="error waiting for container: context canceled"
Looks to be regression from #594
May I ask you why the regression happens? It's a little beyond my understanding with nix.
AFAIK,
import ./.
in docker.nix > default.nix > defaultPackage
in flake.nix > (import ./project.nix { inherit pkgs; }).neuron
should be identical to
(import ./project.nix {}).neuron
Do you think this is an flake-compat
issue? Or anything subtle I missed.
@TheKK see https://nixos.wiki/wiki/Import_From_Derivation
They are not identical. The former (when importing default.nix) requires a callPackage
, but with project.nix, importing alone gets you neuron derivation. Both approaches will work, but I went with the latter because then there is no need to import nixpkgs.nix again (when invoking callPackage).
It is nothing to do with flake per se.
Oh, I just found that it might not be the issue of IFD. Some simple experiment correct my wrong expectation.
flake-compat
actually returns the entire flake plus the default
attribute, which is a derivation points to our defaultPackage
.
repl> import ./.
{ apps = { ... };
default = «derivation /nix/store/k9ljivccyvn4bm624w1g3mazpx65pw0q-neuron-1.9.27.2.drv»;
defaultApp = { ... };
defaultPackage = { ... };
devShell = { ... };
inputs = { ... };
lastModified = 1618440730;
lastModifiedDate = "20210414225210";
narHash = "sha256-Q6ukNOOxd3m++WGbR5FmGkwcoTu0kS/NsQuMDcsL72s=";
outPath = "/nix/store/smqsgc1wm1rzrzcm2x6gwq2bx3l11rm8-source";
outputs = { ... };
packages = { ... };
rev = "54975f803cae925dc2d6aa29de92aab875cef16c";
revCount = 1604; shortRev = "54975f8"; sourceInfo = { ... }; submodules = false; }
So import ./.
is different from (import ./project.nix { inherit pkgs; }).neuron
obviously. The next question comes to me is why nix-build
still works on this default.nix
? Then I found that nix-build
accepts derivation and an object that some of its values are derivation. And our default
field from default.nix
got built by nix-build
magically!
Interesting. Is that nix-build behaviour (of accepting .default
attr) documented somewhere? I wonder if that's a Nix 2.4 only behaviour.
From the doc of Nix 2.3.10
nix-build is essentially a wrapper around nix-instantiate (to translate a high-level Nix expression to a low-level store derivation) and nix-store --realise (to build the store derivation).
The command nix-instantiate generates store derivations from (high-level) Nix expressions. It evaluates the Nix expressions in each of files (which defaults to ./default.nix). Each top-level expression should evaluate to a derivation, a list of derivations, or a set of derivations.
I can't find the old document but looks like it's not recent added feature.