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
dockerTools.buildImageWithNixDb: simplifications and switch to closure info #49414
Conversation
@GrahamcOfBorg test docker-tools |
Success on aarch64-linux Attempted: tests.docker-tools No partial log is available. |
Success on x86_64-linux (full log) Attempted: tests.docker-tools Partial log (click to expand)
|
If I am correct we already rely on Nix 2 features so I don't see any reason why not. |
echo "Copying everything to /nix/store (will take a while)..." | ||
cp -prd $storePaths nix/store/ | ||
${nix}/bin/nix-store --verify --check-contents | ||
${nix}/bin/nix-store --load-db < ${closureInfo {rootPaths = contents;}}/registration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contents
can be a list of derivations. It can also be one single derivation that defines the docker image layer.
See this:
nixpkgs/pkgs/build-support/docker/default.nix
Line 268 in 2f9fc89
let contentsList = if builtins.isList contents then contents else [ contents ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have been nice to have typed Nix here :)
I fixed this. Thanks!
# https://github.com/NixOS/nix/commit/c2b0d8749f7e77afc1c4b3e8dd36b7ee9720af4a | ||
storePaths=$(cat ${nixRegistration contents}/storePaths) | ||
echo "Copying everything to /nix/store (will take a while)..." | ||
cp -prd $storePaths nix/store/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the closure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The closure is copied by the buildImage
function. This copy was needed to do the --check-contents
at the layer level. This is no longer required (with Nix 2.0) to initialize correctly the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see.
8e70baa
to
8a4cb4a
Compare
@FRidh yes, it seems now we can. In fact, I already submitted this PR 6 months back but it was too early to rely on Nix 2 features. |
8a4cb4a
to
abe49bf
Compare
…eInfo Since Nix 2 is now the stable Nix version, we can use closureInfo which simplifies the Nix database initialisation (size and hash are included in the "dump").
abe49bf
to
c12f756
Compare
Since Nix 2 is now the stable Nix version, we can use closureInfo
which simplifies the Nix database initialisation (size and hash are
included in the "dump").
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)