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

dockerTools: use makeOverridable for buildImage family of functions #208944

Merged
merged 2 commits into from
Sep 12, 2023

Conversation

risicle
Copy link
Contributor

@risicle risicle commented Jan 3, 2023

Description of changes

This may be a bit naive as I haven't really dug into the internals of dockerTools before - but to me we're missing a trick by not making the resulting images overridable. Using makeOverridable allows dockerTools-based images to be customized at the nix-level, which has numerous advantages over using image inheritance via fromImage, e.g.

  • the duplicated-nix-store-paths issues can be avoided
  • config can actually be extended rather than wholesale-replaced

buildImage has passthru.buildArgs but it is unique in this and is a bit more awkward to use than .override.

Have built dockerTools.examples on x86_64 linux and verified this causes no rebuilds.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@risicle risicle requested a review from roberth as a code owner January 3, 2023 22:33
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jan 3, 2023
Copy link
Member

@nlewo nlewo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with the override mecanism, but this looks legit to me.

I think we should do it on all buildImage* functions: it's missing for the buildImageWithNixDB.

@risicle
Copy link
Contributor Author

risicle commented Jan 11, 2023

I didn't do it on buildImageWithNixDB et al because it just passes the call straight through to buildImage which will have its own .override which is probably more useful.

@SuperSandro2000 SuperSandro2000 added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jan 23, 2023
@risicle risicle force-pushed the ris-dockertools-makeoverridable branch from bd0dec0 to b04d3d4 Compare September 9, 2023 22:16
@risicle
Copy link
Contributor Author

risicle commented Sep 10, 2023

@ofborg test docker-tools
@ofborg test docker-tools-cross
@ofborg test docker-tools-overlay

@risicle
Copy link
Contributor Author

risicle commented Sep 10, 2023

@ofborg test docker-tools

Regretting enabling the redis tests way back when.

@risicle
Copy link
Contributor Author

risicle commented Sep 10, 2023

Oh nixosTests.docker-tools appear to be broken at the moment anyway.

@risicle
Copy link
Contributor Author

risicle commented Sep 10, 2023

nixosTests.docker-tools-cross pass for me on nixos x86_64.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog labels Sep 10, 2023
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2023
this allows nix users to modify existing images without having
to rely on container image inheritance mechanisms via fromImage
@risicle risicle force-pushed the ris-dockertools-makeoverridable branch from 5e67c5c to 680dfee Compare September 11, 2023 20:12
@ofborg ofborg bot added 10.rebuild-linux: 1-10 and removed 2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 11, 2023
@teto
Copy link
Member

teto commented Sep 12, 2023

Something I would have been happy to use in my code recently so +1

@considerate
Copy link
Member

Oh nixosTests.docker-tools appear to be broken at the moment anyway.

How are the tests broken?

@risicle
Copy link
Contributor Author

risicle commented Sep 12, 2023

docker # [  382.861639] dockerd[895]: time="2023-09-12T21:47:41.600272616Z" level=info msg="Layer sha256:e4452b4eeb643615eed8321271a15ea843c23c3fa3c426241095961022cd4869 cleaned up"
docker # Error processing tar file(exit status 1): write /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/gconv/IBM1390.so: no space left on device

Appears to work though if I give the test machine more disk space.

@deliciouslytyped
Copy link
Contributor

This may or may not cause some sort of (caching?) breakage in Arion, per hercules-ci/arion#217

@risicle
Copy link
Contributor Author

risicle commented Oct 11, 2023

That's interesting. If you look at the definition of makeOverridable it appears to go to special effort to make this work (as long as you use lib.functionArgs rather than builtins.functionArgs) but I agree, I can't get it to work like that either:

nix-repl> let lib = (import ./. {}).lib; in lib.functionArgs (lib.makeOverridable ({foo, bar ? "ahoy"}: { abc = "${foo}+${bar}";} ))
{ }

@roberth
Copy link
Member

roberth commented Oct 11, 2023

Possible fix:

Haven't tested the integration with arion, but I'd expect that to work.

@risicle
Copy link
Contributor Author

risicle commented Oct 11, 2023

Awesome love it when someone's 10 minutes ahead of me. Will review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: docker tools 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants