diff options
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/docker/default.nix | 16 | ||||
-rw-r--r-- | pkgs/build-support/docker/examples.nix | 17 | ||||
-rw-r--r-- | pkgs/build-support/mkshell/default.nix | 15 | ||||
-rw-r--r-- | pkgs/build-support/rust/build-rust-crate/configure-crate.nix | 5 | ||||
-rw-r--r-- | pkgs/build-support/rust/build-rust-crate/lib.sh | 6 |
5 files changed, 42 insertions, 17 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index c6ab4589aefa..48c780e2dbe4 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -74,7 +74,7 @@ let # Reference: https://github.com/opencontainers/image-spec/blob/master/config.md#properties # For the mapping from Nixpkgs system parameters to GOARCH, we can reuse the # mapping from the go package. - defaultArch = go.GOARCH; + defaultArchitecture = go.GOARCH; in rec { @@ -101,8 +101,8 @@ rec { , imageDigest , sha256 , os ? "linux" - , arch ? defaultArch - + , # Image architecture, defaults to the architecture of the `hostPlatform` when unset + arch ? defaultArchitecture # This is used to set name to the pulled image , finalImageName ? imageName # This used to set a tag to the pulled image @@ -514,6 +514,8 @@ rec { keepContentsDirlinks ? false , # Docker config; e.g. what command to run on the container. config ? null + , # Image architecture, defaults to the architecture of the `hostPlatform` when unset + architecture ? defaultArchitecture , # Optional bash script to run on the files prior to fixturizing the layer. extraCommands ? "" , uid ? 0 @@ -546,8 +548,7 @@ rec { baseJson = let pure = writeText "${baseName}-config.json" (builtins.toJSON { - inherit created config; - architecture = defaultArch; + inherit created config architecture; preferLocalBuild = true; os = "linux"; }); @@ -838,6 +839,8 @@ rec { contents ? [ ] , # Docker config; e.g. what command to run on the container. config ? { } + , # Image architecture, defaults to the architecture of the `hostPlatform` when unset + architecture ? defaultArchitecture , # Time of creation of the image. Passing "now" will make the # created date be the time of building. created ? "1970-01-01T00:00:01Z" @@ -869,8 +872,7 @@ rec { streamScript = writePython3 "stream" { } ./stream_layered_image.py; baseJson = writeText "${baseName}-base.json" (builtins.toJSON { - inherit config; - architecture = defaultArch; + inherit config architecture; os = "linux"; }); diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix index 71c3574963c8..5784e650dc2e 100644 --- a/pkgs/build-support/docker/examples.nix +++ b/pkgs/build-support/docker/examples.nix @@ -92,7 +92,7 @@ rec { ]; extraCommands = '' - mkdir -p tmp + mkdir -p tmp/nginx_client_body # nginx still tries to read this directory even if error_log # directive is specifying another file :/ @@ -700,6 +700,21 @@ rec { contents = [ pkgs.bashInteractive ./test-dummy ]; }; + build-image-with-architecture = buildImage { + name = "build-image-with-architecture"; + tag = "latest"; + architecture = "arm64"; + # Not recommended. Use `buildEnv` between copy and packages to avoid file duplication. + copyToRoot = [ pkgs.bashInteractive ./test-dummy ]; + }; + + layered-image-with-architecture = pkgs.dockerTools.streamLayeredImage { + name = "layered-image-with-architecture"; + tag = "latest"; + architecture = "arm64"; + contents = [ pkgs.bashInteractive ./test-dummy ]; + }; + # ensure that caCertificates builds image-with-certs = buildImage { name = "image-with-certs"; diff --git a/pkgs/build-support/mkshell/default.nix b/pkgs/build-support/mkshell/default.nix index e7552f434848..39b02a47141a 100644 --- a/pkgs/build-support/mkshell/default.nix +++ b/pkgs/build-support/mkshell/default.nix @@ -44,12 +44,13 @@ stdenv.mkDerivation ({ phases = [ "buildPhase" ]; buildPhase = '' - echo "------------------------------------------------------------" >>$out - echo " WARNING: the existence of this path is not guaranteed." >>$out - echo " It is an internal implementation detail for pkgs.mkShell." >>$out - echo "------------------------------------------------------------" >>$out - echo >> $out - # Record all build inputs as runtime dependencies - export >> $out + { echo "------------------------------------------------------------"; + echo " WARNING: the existence of this path is not guaranteed."; + echo " It is an internal implementation detail for pkgs.mkShell."; + echo "------------------------------------------------------------"; + echo; + # Record all build inputs as runtime dependencies + export; + } >> "$out" ''; } // rest) diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 473a91f9ce07..ea150c2fe85d 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -186,7 +186,10 @@ in '' set +e EXTRA_BUILD=$(sed -n "s/^cargo:rustc-flags=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u) EXTRA_FEATURES=$(sed -n "s/^cargo:rustc-cfg=\(.*\)/--cfg \1/p" target/build/${crateName}.opt | tr '\n' ' ') - EXTRA_LINK=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_ARGS=$(sed -n "s/^cargo:rustc-link-arg=\(.*\)/-C link-arg=\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_ARGS_BINS=$(sed -n "s/^cargo:rustc-link-arg-bins=\(.*\)/-C link-arg=\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_ARGS_LIB=$(sed -n "s/^cargo:rustc-link-arg-lib=\(.*\)/-C link-arg=\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_LIBS=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ') EXTRA_LINK_SEARCH=$(sed -n "s/^cargo:rustc-link-search=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u) # We want to read part of every line that has cargo:rustc-env= prefix and diff --git a/pkgs/build-support/rust/build-rust-crate/lib.sh b/pkgs/build-support/rust/build-rust-crate/lib.sh index 39f7d53f6f75..7f98701b5409 100644 --- a/pkgs/build-support/rust/build-rust-crate/lib.sh +++ b/pkgs/build-support/rust/build-rust-crate/lib.sh @@ -17,6 +17,8 @@ build_lib() { -L dependency=target/deps \ --cap-lints allow \ $LINK \ + $EXTRA_LINK_ARGS \ + $EXTRA_LINK_ARGS_LIB \ $LIB_RUSTC_OPTS \ $BUILD_OUT_DIR \ $EXTRA_BUILD \ @@ -47,6 +49,8 @@ build_bin() { --out-dir target/bin \ -L dependency=target/deps \ $LINK \ + $EXTRA_LINK_ARGS \ + $EXTRA_LINK_ARGS_BINS \ $EXTRA_LIB \ --cap-lints allow \ $BUILD_OUT_DIR \ @@ -94,7 +98,7 @@ setup_link_paths() { done fi done - echo "$EXTRA_LINK" | while read i; do + echo "$EXTRA_LINK_LIBS" | while read i; do if [[ ! -z "$i" ]]; then for library in $i; do echo "-l $library" >> target/link |