Skip to content

Conversation

@dcarley
Copy link
Contributor

@dcarley dcarley commented Jun 11, 2025

go: Add runtime-packages for Flox v1.4.4

Flox v1.4.4 is more strict about checking runtime-packages so we need
to explicitly install and reference the following. It's common for these
to be copied into containers that use a scratch base image.

It seems that it should be possible to use an embedded tzdata with go build -tags timetzdata but this still left a reference to the tzdata
package when I tried it.

The 4th dependency that's not enumerated in the error message will be
covered in a separate commit.

Failure before this change:

% FLOXBIN="nix run github:flox/flox/v1.4.4 -- " ./test.sh quotes-app-go
Using flox binary: nix run github:flox/flox/v1.4.4 --
🔨 Building quotes-app-go with Flox...
✨ Clean completed successfully
Rendering quotes-app-go build script to /tmp/ce9fea35/quotes-app-go/build.bash
Building quotes-app-go-0.0.1 in local mode
00:00:00.003592 + mkdir -p /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin
00:00:00.005472 + cp -pr quotes.json /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib
00:00:00.007484 + go mod tidy
00:00:00.056542 + go build -o /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go main.go
00:00:00.764525 + chmod +x /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go
❌ 4 packages found in /nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
   -      not found in /nix/store/w0gb9h28csv70a9f4scq0vvpx2bp8fva-environment-build-quotes-app-go

Displaying first 3 only:

/nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
└───bin/.quotes-app-go-wrapped: … signature algorithms/nix/store/crypr3i24qfc0ac71z442kcdz7s5zcvp-iana-etc-20250108/etc/servicesc…
    → /nix/store/crypr3i24qfc0ac71z442kcdz7s5zcvp-iana-etc-20250108

/nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
└───bin/.quotes-app-go-wrapped: … have a SAN extension/nix/store/k6ixkpwfikqsjagnjnhrmhf8mjrrw27p-tzdata-2025a/share/zoneinfo/run…
    → /nix/store/k6ixkpwfikqsjagnjnhrmhf8mjrrw27p-tzdata-2025a

/nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
└───bin/.quotes-app-go-wrapped: …ns mode, ignoring it./nix/store/lpzdpl7h5yvg9xdbdxqpdc9rvx98rpca-mailcap-2.1.54/etc/mime.typestl…
    → /nix/store/lpzdpl7h5yvg9xdbdxqpdc9rvx98rpca-mailcap-2.1.54

make: *** [/nix/store/c1qb21zsv61mlkcd1hg2ahangg5vdcrq-package-builder-1.0.0/libexec/flox-build.mk:676: quotes_app_go_CHECK_BUILD] Error 1
❌ ERROR: Build failed with status: exit status: 2

go: Add -trimpath for Flox v1.4.4

Flox v1.4.4 is more strict about checking runtime-packages and by
default Go includes absolute references to stdlib paths, so to prevent
depending on the go package at runtime we have to trim them. Michael
found this tip at:

Failure before this change:

% FLOXBIN="nix run github:flox/flox/v1.4.4 -- " ./test.sh quotes-app-go
Using flox binary: nix run github:flox/flox/v1.4.4 --
🔨 Building quotes-app-go with Flox...
✨ Clean completed successfully
Rendering quotes-app-go build script to /tmp/ce9fea35/quotes-app-go/build.bash
Building quotes-app-go-0.0.1 in local mode
00:00:00.003501 + mkdir -p /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin
00:00:00.005283 + cp -pr quotes.json /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib
00:00:00.007546 + go mod tidy
00:00:00.054665 + go build -o /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go main.go
00:00:00.679072 + chmod +x /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go
this derivation will be built:
  /nix/store/vpfdd3csbks3q861lz821inl64m111pa-quotes-app-go-0.0.1.drv
building '/nix/store/vpfdd3csbks3q861lz821inl64m111pa-quotes-app-go-0.0.1.drv'...
quotes-app-go> signing /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1
quotes-app-go> patching script interpreter paths in /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1/bin/quotes-app-go
❌ 1 packages found in /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1
   -      not found in /nix/store/2hxgy88g8w10zah5prc80wdr41hfhl50-environment-build-quotes-app-go

/nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1
└───bin/.quotes-app-go-wrapped: …...................../nix/store/jp3z5jp9gaxsw7fdzbqn29aabmrxq62j-go-1.24.1/share/go.............…
    → /nix/store/jp3z5jp9gaxsw7fdzbqn29aabmrxq62j-go-1.24.1

make: *** [/nix/store/c1qb21zsv61mlkcd1hg2ahangg5vdcrq-package-builder-1.0.0/libexec/flox-build.mk:676: quotes_app_go_CHECK_BUILD] Error 1
❌ ERROR: Build failed with status: exit status: 2

dcarley added 2 commits June 11, 2025 11:11
Flox v1.4.4 is more strict about checking `runtime-packages` so we need
to explicitly install and reference the following. It's common for these
to be copied into containers that use a scratch base image.

It seems that it should be possible to use an embedded `tzdata` with `go
build -tags timetzdata` but this still left a reference to the `tzdata`
package when I tried it.

The 4th dependency that's not enumerated in the error message will be
covered in a separate commit.

Failure before this change:

    % FLOXBIN="nix run github:flox/flox/v1.4.4 -- " ./test.sh quotes-app-go
    Using flox binary: nix run github:flox/flox/v1.4.4 --
    🔨 Building quotes-app-go with Flox...
    ✨ Clean completed successfully
    Rendering quotes-app-go build script to /tmp/ce9fea35/quotes-app-go/build.bash
    Building quotes-app-go-0.0.1 in local mode
    00:00:00.003592 + mkdir -p /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin
    00:00:00.005472 + cp -pr quotes.json /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib
    00:00:00.007484 + go mod tidy
    00:00:00.056542 + go build -o /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go main.go
    00:00:00.764525 + chmod +x /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go
    ❌ 4 packages found in /nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
       -      not found in /nix/store/w0gb9h28csv70a9f4scq0vvpx2bp8fva-environment-build-quotes-app-go

    Displaying first 3 only:

    /nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
    └───bin/.quotes-app-go-wrapped: … signature algorithms/nix/store/crypr3i24qfc0ac71z442kcdz7s5zcvp-iana-etc-20250108/etc/servicesc…
        → /nix/store/crypr3i24qfc0ac71z442kcdz7s5zcvp-iana-etc-20250108

    /nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
    └───bin/.quotes-app-go-wrapped: … have a SAN extension/nix/store/k6ixkpwfikqsjagnjnhrmhf8mjrrw27p-tzdata-2025a/share/zoneinfo/run…
        → /nix/store/k6ixkpwfikqsjagnjnhrmhf8mjrrw27p-tzdata-2025a

    /nix/store/69bwi1mf5x67b6w6gjrx4kp8amjyr026-quotes-app-go-0.0.1
    └───bin/.quotes-app-go-wrapped: …ns mode, ignoring it./nix/store/lpzdpl7h5yvg9xdbdxqpdc9rvx98rpca-mailcap-2.1.54/etc/mime.typestl…
        → /nix/store/lpzdpl7h5yvg9xdbdxqpdc9rvx98rpca-mailcap-2.1.54

    make: *** [/nix/store/c1qb21zsv61mlkcd1hg2ahangg5vdcrq-package-builder-1.0.0/libexec/flox-build.mk:676: quotes_app_go_CHECK_BUILD] Error 1
    ❌ ERROR: Build failed with status: exit status: 2
Flox v1.4.4 is more strict about checking `runtime-packages` and by
default Go includes absolute references to stdlib paths, so to prevent
depending on the `go` package at runtime we have to trim them. Michael
found this tip at:

- https://xnacly.me/posts/2023/go-metadata/#trimming-module-paths

Failure before this change:

    % FLOXBIN="nix run github:flox/flox/v1.4.4 -- " ./test.sh quotes-app-go
    Using flox binary: nix run github:flox/flox/v1.4.4 --
    🔨 Building quotes-app-go with Flox...
    ✨ Clean completed successfully
    Rendering quotes-app-go build script to /tmp/ce9fea35/quotes-app-go/build.bash
    Building quotes-app-go-0.0.1 in local mode
    00:00:00.003501 + mkdir -p /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin
    00:00:00.005283 + cp -pr quotes.json /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/lib
    00:00:00.007546 + go mod tidy
    00:00:00.054665 + go build -o /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go main.go
    00:00:00.679072 + chmod +x /tmp/store_a3c7f9ca1f6058e48c8a710e0eea5bec-quotes-app-go-0.0.1/bin/quotes-app-go
    this derivation will be built:
      /nix/store/vpfdd3csbks3q861lz821inl64m111pa-quotes-app-go-0.0.1.drv
    building '/nix/store/vpfdd3csbks3q861lz821inl64m111pa-quotes-app-go-0.0.1.drv'...
    quotes-app-go> signing /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1
    quotes-app-go> patching script interpreter paths in /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1/bin/quotes-app-go
    ❌ 1 packages found in /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1
       -      not found in /nix/store/2hxgy88g8w10zah5prc80wdr41hfhl50-environment-build-quotes-app-go

    /nix/store/g33793a604z2cwqngi3zarn3j13ypr96-quotes-app-go-0.0.1
    └───bin/.quotes-app-go-wrapped: …...................../nix/store/jp3z5jp9gaxsw7fdzbqn29aabmrxq62j-go-1.24.1/share/go.............…
        → /nix/store/jp3z5jp9gaxsw7fdzbqn29aabmrxq62j-go-1.24.1

    make: *** [/nix/store/c1qb21zsv61mlkcd1hg2ahangg5vdcrq-package-builder-1.0.0/libexec/flox-build.mk:676: quotes_app_go_CHECK_BUILD] Error 1
    ❌ ERROR: Build failed with status: exit status: 2
@zmitchell
Copy link
Member

This works for me without any mention of a fourth dependency.

@zmitchell zmitchell merged commit d8322d0 into main Jun 11, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants