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

fix dockertools.pullImage on darwin #41908

Merged
merged 2 commits into from
Jul 28, 2018

Conversation

nicknovitski
Copy link
Contributor

Motivation for this change

buildImage works, so I wanted to start using it.

The --override-{os,architecture} arguments are necessary for me, since skopeo's default behavior is to choose the manifest which matches the host system's os and architecture. For people on macs, this frequently doesn't exist, and is rarely what we want.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg GrahamcOfBorg added 6.topic: darwin Running or building packages on Darwin 8.has: documentation 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 13, 2018
@nlewo
Copy link
Member

nlewo commented Jun 13, 2018

Could you add to describe a bit these arguments and the default behavior in the manual?
Otherwise, LGTM.

@nlewo nlewo self-assigned this Jun 13, 2018
@nicknovitski nicknovitski force-pushed the dockertools-darwin branch 2 times, most recently from 428c44b to c2932a2 Compare June 14, 2018 22:20
@nicknovitski
Copy link
Contributor Author

Like this?

@nlewo
Copy link
Member

nlewo commented Jun 15, 2018

@nicknovitski I was actually more talking about describing these new arguments of dockerTools.pullImage in the description of this function in the manual. Sorry if I haven't been really clear:/ I was thinking to something such as:

diff --git a/doc/functions.xml b/doc/functions.xml
index 9dd3ccb5752..f1c7e0142a7 100644
--- a/doc/functions.xml
+++ b/doc/functions.xml
@@ -649,6 +649,8 @@ merge:"diff3"
     imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b"; <co xml:id='ex-dockerTools-pullImage-2' />
     finalImageTag = "1.11";  <co xml:id='ex-dockerTools-pullImage-3' />
     sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8"; <co xml:id='ex-dockerTools-pullImage-4' />
+    os = "linux";  <co xml:id='ex-dockerTools-pullImage-5' />
+    architecture = "x86_64"; <co xml:id='ex-dockerTools-pullImage-6' />
   }
   </programlisting>
    </example>
@@ -693,6 +695,16 @@ merge:"diff3"
       This argument is required.
      </para>
     </callout>
+    <callout arearefs='ex-dockerTools-pullImage-5'>
+     <para>
+      <varname>os</varname> ...  By default it's <literal>"linux"</literal>.
+     </para>
+    </callout>
+    <callout arearefs='ex-dockerTools-pullImage-6'>
+     <para>
+      <varname>architecture</varname> .... By default it's <literal>"x86_64"</literal>.
+     </para>
+    </callout>
    </calloutlist>
   </section>

@nicknovitski
Copy link
Contributor Author

Oh, sure! 😄

@nlewo
Copy link
Member

nlewo commented Jun 15, 2018

(you can easily build the manual by running nix-build doc from the nixpkgs repository root directory).

@nicknovitski nicknovitski force-pushed the dockertools-darwin branch 2 times, most recently from a95816e to bf39fee Compare June 17, 2018 18:08
@nicknovitski
Copy link
Contributor Author

Thank you, I've fixed my build errors.

@nlewo
Copy link
Member

nlewo commented Jun 17, 2018

@GrahamcOfBorg test docker-tools

@GrahamcOfBorg
Copy link

Success on aarch64-linux

Attempted: tests.docker-tools

No partial log is available.

@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: tests.docker-tools

Partial log (click to expand)

building '/nix/store/hiadprn77k9lmdafrxysfcwgdr4jdds0-system-units.drv'...
building '/nix/store/zzrgdrlxsk1wdbl0jbycrl5wsy8vypg2-xscreensaver.pam.drv'...
cannot build derivation '/nix/store/fmjm8fysxp8bbjr1fjyd2y21n661gb3c-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/swkd1ca0nbk26l4j78y1ffkq2xc7lgv9-nixos-system-docker-18.09.git.fbff70a.drv': 5 dependencies couldn't be built
cannot build derivation '/nix/store/d0ayldfrmq6y3gaa4dza0pz18xihgca9-closure-info.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/b449z8mbprbxki1wabim8idd6pf2ywpk-run-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/c4qhc0sg20a6448sxajjcvbqxnwf28x4-nixos-vm.drv': 2 dependencies couldn't be built
cannot build derivation '/nix/store/jr31r9lqilnqzj4lv655gvjca835d45y-nixos-test-driver-docker-tools.drv': 3 dependencies couldn't be built
cannot build derivation '/nix/store/hy5dvr2pn81iaa387ff410jip08kx6c7-vm-test-run-docker-tools.drv': 1 dependencies couldn't be built
error: build of '/nix/store/hy5dvr2pn81iaa387ff410jip08kx6c7-vm-test-run-docker-tools.drv' failed

@nicknovitski
Copy link
Contributor Author

I'm not sure I understand the failure, but it looks to me that like there's a nixos test for docker-tools, and some derivations it depends on failed to build. Is that right?

@copumpkin
Copy link
Member

This looks good to me but I'm also not sure what the problem is with the test.

@copumpkin
Copy link
Member

@GrahamcOfBorg test docker-tools

@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: tests.docker-tools

Partial log (click to expand)

while evaluating ‘hydraJob’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/lib/customisation.nix:162:14, called from /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/nixos/release.nix:23:16:
while evaluating the attribute ‘drvPath’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/lib/customisation.nix:179:13:
while evaluating the attribute ‘drvPath’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/lib/customisation.nix:146:13:
while evaluating the attribute ‘buildCommand’ of the derivation ‘vm-test-run-docker-tools’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/pkgs/stdenv/generic/make-derivation.nix:175:11:
while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-test-driver-docker-tools’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/pkgs/stdenv/generic/make-derivation.nix:175:11:
while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-vm’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/pkgs/stdenv/generic/make-derivation.nix:175:11:
while evaluating the attribute ‘text’ of the derivation ‘run-nixos-vm’ at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/pkgs/stdenv/generic/make-derivation.nix:175:11:
while evaluating anonymous function at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/pkgs/build-support/closure-info.nix:9:1, called from /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/nixos/modules/virtualisation/qemu-vm.nix:121:13:
assertion failed at /var/lib/gc-of-borg/.nix-test-rs/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/rbvermaa-spot/pkgs/build-support/closure-info.nix:11:1

@GrahamcOfBorg
Copy link

Success on aarch64-linux

Attempted: tests.docker-tools

No partial log is available.

@copumpkin
Copy link
Member

@GrahamcOfBorg build spokeo

@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: spokeo

Partial log (click to expand)

Cannot nix-instantiate `spokeo' because:
error: attribute 'spokeo' in selection path 'spokeo' not found

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: spokeo

Partial log (click to expand)

Cannot nix-instantiate `spokeo' because:
error: attribute 'spokeo' in selection path 'spokeo' not found

@copumpkin
Copy link
Member

@GrahamcOfBorg build skopeo

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: skopeo

Partial log (click to expand)

  /nix/store/daxwjb9rs15hjk48g2hyhxibvcgbiyac-ostree-2018.6
  /nix/store/lrryp7v0q9mhrwwnhf63v9yvrkp2df1m-skopeo-0.1.30-bin
  /nix/store/pvlrqiwqkm64sprlq73zyk4dfxr47q56-thin-provisioning-tools-0.7.6
copying path '/nix/store/baaaaqrjjmyjgx9r8papjq5f7pv9928m-skopeo-default-policy.json' from 'https://cache.nixos.org'...
copying path '/nix/store/83ikzl794c4asbs5j5r3byv1vg6qqigh-libaio-0.3.110' from 'https://cache.nixos.org'...
copying path '/nix/store/daxwjb9rs15hjk48g2hyhxibvcgbiyac-ostree-2018.6' from 'https://cache.nixos.org'...
copying path '/nix/store/pvlrqiwqkm64sprlq73zyk4dfxr47q56-thin-provisioning-tools-0.7.6' from 'https://cache.nixos.org'...
copying path '/nix/store/453a18ic6vfsa58367s2xjdvyic05x7p-lvm2-2.02.177' from 'https://cache.nixos.org'...
copying path '/nix/store/lrryp7v0q9mhrwwnhf63v9yvrkp2df1m-skopeo-0.1.30-bin' from 'https://cache.nixos.org'...
/nix/store/lrryp7v0q9mhrwwnhf63v9yvrkp2df1m-skopeo-0.1.30-bin

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: skopeo

Partial log (click to expand)

strip is /nix/store/0pjsgkxz0rp5baycq5sp2s72lrr5q9sg-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/spriwza2cv8jc6q35pk2skxz36asnwdd-skopeo-0.1.30-bin/bin
patching script interpreter paths in /nix/store/spriwza2cv8jc6q35pk2skxz36asnwdd-skopeo-0.1.30-bin
checking for references to /build in /nix/store/spriwza2cv8jc6q35pk2skxz36asnwdd-skopeo-0.1.30-bin...
shrinking RPATHs of ELF executables and libraries in /nix/store/wbqmblm5sahvdhyjjcrgdrfcj04cf7rj-skopeo-0.1.30-man
strip is /nix/store/0pjsgkxz0rp5baycq5sp2s72lrr5q9sg-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/wbqmblm5sahvdhyjjcrgdrfcj04cf7rj-skopeo-0.1.30-man
checking for references to /build in /nix/store/wbqmblm5sahvdhyjjcrgdrfcj04cf7rj-skopeo-0.1.30-man...
strip is /nix/store/0pjsgkxz0rp5baycq5sp2s72lrr5q9sg-binutils-2.30/bin/strip
/nix/store/spriwza2cv8jc6q35pk2skxz36asnwdd-skopeo-0.1.30-bin

@@ -37,8 +37,8 @@ buildGoPackage rec {
'';

preBuild = ''
export CGO_CFLAGS="-I${getDev gpgme}/include -I${getDev libgpgerror}/include -I${getDev devicemapper}/include -I${getDev btrfs-progs}/include"
export CGO_LDFLAGS="-L${getLib gpgme}/lib -L${getLib libgpgerror}/lib -L${getLib devicemapper}/lib"
export CGO_CFLAGS="-I${getDev gpgme}/include${lib.optionalString stdenv.isLinux " -I${getDev libgpgerror}/include -I${getDev devicemapper}/include -I${getDev btrfs-progs}/include"}"
Copy link
Member

Choose a reason for hiding this comment

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

Might this make more sense as CGO_CFLAGS=$CFLAGS? and same with LDFLAGS. I think stdenv sets up the -I automatically for us in CFLAGS so this would mirror the buildInputs conditional logic more naturally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try that.

@GrahamcOfBorg
Copy link

No attempt on x86_64-darwin (full log)

The following builds were skipped because they don't evaluate on x86_64-darwin: spokeo

Partial log (click to expand)

Cannot nix-instantiate `spokeo' because:
�[31;1merror:�[0m attribute 'spokeo' in selection path 'spokeo' not found

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: skopeo

Partial log (click to expand)

find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
find: '/nix/store/zj5zprla0rnd540wcshksla59wdjirzg-skopeo-0.1.30': No such file or directory
/nix/store/l1jb1wfn1kv956rshb3jr80hw8rg2nkz-skopeo-0.1.30-bin

Copy link
Member

@puffnfresh puffnfresh left a comment

Choose a reason for hiding this comment

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

What are you going to do with pullImage on Darwin?

@nicknovitski
Copy link
Contributor Author

Use it as an argument to buildImage. I've realized there isn't much I can do without cross-compilation, but, ehn, maybe I could try to make it work.

@puffnfresh
Copy link
Member

@nicknovitski yeah, I've been working on https://github.com/nix-community/linuxkit-builder for this reason. Would love for my team to easily build Docker images using Nix on Darwin ❤️

@nicknovitski
Copy link
Contributor Author

nicknovitski commented Jul 11, 2018

As @copumpkin suggests, I'm going to try a simpler way of setting CGO_* env vars.

e: pushed changes

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-linux: 1-10 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jul 11, 2018
@copumpkin
Copy link
Member

@puffnfresh in my case I found this because I wanted to interact with a docker registry with skopeo from my Mac 😄and of course skopeo doesn't work on macOS without this PR

@puffnfresh
Copy link
Member

@copumpkin yeah, definitely no reason why Skopeo shouldn't work well on macOS.

@copumpkin
Copy link
Member

Could a Darwin pullImage also be useful in isolation with Docker for Mac? I haven't really thought it through

@puffnfresh
Copy link
Member

@copumpkin should be able to docker load one, I think.

@nicknovitski
Copy link
Contributor Author

Rebased on upstream skopeo change.

Is there something blocking this that I can fix?

@copumpkin
Copy link
Member

@GrahamcOfBorg build skopeo

@copumpkin
Copy link
Member

And no, if the borg says we're good, I'll click merge. Thanks for your patience @nicknovitski

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: skopeo

Partial log (click to expand)

find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
find: '/nix/store/y75gjykhr3v3xkafyi5xbz2pxdb31fp1-skopeo-0.1.30': No such file or directory
/nix/store/21z7pk0j2k0cy7n7l9dilyywnxs802va-skopeo-0.1.30-bin

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: skopeo

Partial log (click to expand)

shrinking /nix/store/m7vs4bzbpvycms7aggz395q8jixjxsdm-skopeo-0.1.30-bin/bin/skopeo
strip is /nix/store/a3nk8z2i7m7wa3jdckgv710n7j3yx4b5-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/m7vs4bzbpvycms7aggz395q8jixjxsdm-skopeo-0.1.30-bin/bin
patching script interpreter paths in /nix/store/m7vs4bzbpvycms7aggz395q8jixjxsdm-skopeo-0.1.30-bin
checking for references to /build in /nix/store/m7vs4bzbpvycms7aggz395q8jixjxsdm-skopeo-0.1.30-bin...
shrinking RPATHs of ELF executables and libraries in /nix/store/i6rffvfhnfkji4mb2107rsrfa8jmljk1-skopeo-0.1.30-man
strip is /nix/store/a3nk8z2i7m7wa3jdckgv710n7j3yx4b5-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/i6rffvfhnfkji4mb2107rsrfa8jmljk1-skopeo-0.1.30-man
checking for references to /build in /nix/store/i6rffvfhnfkji4mb2107rsrfa8jmljk1-skopeo-0.1.30-man...
strip is /nix/store/a3nk8z2i7m7wa3jdckgv710n7j3yx4b5-binutils-2.30/bin/strip

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: skopeo

Partial log (click to expand)

strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/j7wq0ig6n8f4gwqplc8c3gvbggk0zw9h-skopeo-0.1.30-bin/bin
patching script interpreter paths in /nix/store/j7wq0ig6n8f4gwqplc8c3gvbggk0zw9h-skopeo-0.1.30-bin
checking for references to /build in /nix/store/j7wq0ig6n8f4gwqplc8c3gvbggk0zw9h-skopeo-0.1.30-bin...
shrinking RPATHs of ELF executables and libraries in /nix/store/a66iazbfq6z9nc1k9bpmyhxks7fwv5c9-skopeo-0.1.30-man
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
patching script interpreter paths in /nix/store/a66iazbfq6z9nc1k9bpmyhxks7fwv5c9-skopeo-0.1.30-man
checking for references to /build in /nix/store/a66iazbfq6z9nc1k9bpmyhxks7fwv5c9-skopeo-0.1.30-man...
strip is /nix/store/a245zacjzf3qw0davhvlfarihcy2yyrc-binutils-2.30/bin/strip
/nix/store/j7wq0ig6n8f4gwqplc8c3gvbggk0zw9h-skopeo-0.1.30-bin

@copumpkin copumpkin merged commit fe036ea into NixOS:master Jul 28, 2018
@copumpkin
Copy link
Member

Thanks!

@nicknovitski nicknovitski deleted the dockertools-darwin branch August 15, 2018 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants