Skip to content

fix(nix): use gomod2nix and build scard#1212

Merged
andrinoff merged 2 commits intofloatpane:masterfrom
endoze:fix/scard-cgo-enabled
May 3, 2026
Merged

fix(nix): use gomod2nix and build scard#1212
andrinoff merged 2 commits intofloatpane:masterfrom
endoze:fix/scard-cgo-enabled

Conversation

@endoze
Copy link
Copy Markdown
Contributor

@endoze endoze commented May 1, 2026

What?

Switch from buildGoModule to gomod2nix's buildGoApplication so CGO works, and add platform-specific dependencies (apple-sdk on macOS, pcsclite on Linux). Add a CI job to keep gomod2nix.toml in sync.

Why?

buildGoModule with CGO_ENABLED=0 prevented the scard smart card package from linking against platform libraries.

Closes #1211

@endoze endoze requested a review from a team as a code owner May 1, 2026 23:13
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @endoze! Please fix the following issues with your PR:

  • Title: Is too long (64 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@github-actions github-actions Bot added the bug Something isn't working label May 1, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @endoze! Please fix the following issues with your PR:

  • Title: Is too long (64 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@endoze endoze changed the title fix(nix): switch to gomod2nix with CGO enabled for scard support fix(nix): use gomod2nix and build scard May 1, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @endoze! Please fix the following issues with your PR:

  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@github-actions github-actions Bot added the ci CI / build pipeline label May 1, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @endoze! Please fix the following issues with your PR:

  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@floatpanebot floatpanebot dismissed stale reviews from themself May 1, 2026 23:21

Formatting issues have been resolved. Thank you!

@endoze endoze force-pushed the fix/scard-cgo-enabled branch from 92c5b18 to d7ef388 Compare May 1, 2026 23:25
@andrinoff
Copy link
Copy Markdown
Member

Hey, @endoze , didn't know about the problem, will check out the fix later.

p.s. drop the last commit removing snapcraft validation, it started failing yesterday, probably an issue with snapcraft's servers

@andrinoff andrinoff force-pushed the fix/scard-cgo-enabled branch from 2f16bba to d7ef388 Compare May 2, 2026 17:11
@andrinoff
Copy link
Copy Markdown
Member

@endoze we need some sort of an automatic workflow for the gomod2nix. There is no way anyone will actually update it manually. Please, use the same workflow, as in update-flake.yml

@endoze
Copy link
Copy Markdown
Contributor Author

endoze commented May 2, 2026

@andrinoff I've added a workflow to open a pull request when go.mod/go.sum change that updates the gomod2nix toml file. Let me know if you need anything else to get this shipped.

@andrinoff
Copy link
Copy Markdown
Member

@endoze just got home, doesn't work on my machine (Arch Linux, amd64).

I do not use nix, so I do not know what the problem is. I'll try to look for a fix though.

@endoze
Copy link
Copy Markdown
Contributor Author

endoze commented May 2, 2026

@andrinoff Happy to help debug. I'll run it on my linux machine as well to verify it works as I was expecting. I think it might be the include paths for scard. Did you get a stack trace from nix when you tried building via nix?

@andrinoff
Copy link
Copy Markdown
Member

there is like a log:

Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/czr6admaaam4zz29fwf2r0ca7b06z1ay-6h3fk6riq8qg4g17rav22d11g6781sfq-source
source root is 6h3fk6riq8qg4g17rav22d11g6781sfq-source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Executing goConfigHook
Setting up vendor directory from /nix/store/52i6v8i7pp7ca6hkxiwbqqh3vkrdw9h5-vendor-env
Restoring Go build cache from /nix/store/fwaa38xd6pipvns3dgz7qdc86jz7w1ki-go-cache-env/cache.tar.zst
Finished goConfigHook
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "configurePhase" }
no configure script, doing nothing
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Executing goBuildHook
Building subPackage .
internal/goarch
internal/abi
internal/unsafeheader
internal/cpu
internal/bytealg
internal/byteorder
internal/chacha8rand
internal/coverage/rtcov
internal/godebugs
internal/goexperiment
internal/goos
internal/profilerecord
internal/runtime/atomic
internal/runtime/syscall/linux
math/bits
internal/strconv
internal/runtime/cgroup
internal/runtime/exithook
internal/runtime/gc
internal/runtime/sys
internal/runtime/gc/scan
internal/asan
internal/msan
internal/race
internal/runtime/math
internal/runtime/maps
internal/runtime/pprof/label
internal/stringslite
internal/trace/tracev2
runtime
internal/reflectlite
errors
sync/atomic
internal/sync
internal/synctest
sync
io
iter
unicode
unicode/utf8
bytes
cmp

....

(truncated)

just lists all dependencies 🤷‍♂

@andrinoff
Copy link
Copy Markdown
Member

error itself:

error: Cannot build '/nix/store/xd5nlinn04f6bqlkd3f5f5ihd51ic75i-matcha-dev.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/y7pv1am4lx3pkwsi1zs9b52x9086s5m9-matcha-dev
       Last 25 log lines:
       > github.com/yuin/gopher-lua/parse
       > github.com/yuin/gopher-lua/pm
       > github.com/yuin/gopher-lua
       > github.com/floatpane/matcha/plugin
       > charm.land/lipgloss/v2
       > github.com/floatpane/matcha/theme
       > charm.land/bubbles/v2/key
       > charm.land/bubbles/v2/help
       > charm.land/bubbles/v2/paginator
       > charm.land/bubbles/v2/spinner
       > charm.land/bubbles/v2/cursor
       > charm.land/bubbles/v2/internal/runeutil
       > github.com/atotto/clipboard
       > charm.land/bubbles/v2/textinput
       > github.com/sahilm/fuzzy
       > charm.land/bubbles/v2/list
       > charm.land/bubbles/v2/internal/memoization
       > charm.land/bubbles/v2/viewport
       > charm.land/bubbles/v2/textarea
       > github.com/floatpane/matcha/plugins
       > github.com/hashicorp/golang-lru/v2/internal
       > github.com/hashicorp/golang-lru/v2/simplelru
       > github.com/hashicorp/golang-lru/v2
       > github.com/floatpane/matcha/view
       > github.com/floatpane/matcha/tui
       For full logs, run:
         nix log /nix/store/xd5nlinn04f6bqlkd3f5f5ihd51ic75i-matcha-dev.drv

@andrinoff andrinoff removed the ci CI / build pipeline label May 2, 2026
@andrinoff
Copy link
Copy Markdown
Member

i run nix build --extra-experimental-features nix-command --extra-experimental-features flakes (doesnt run without the flags) btw, maybe that is the issue

@endoze
Copy link
Copy Markdown
Contributor Author

endoze commented May 2, 2026

@andrinoff Nix is a complicated beast 😄 . Depending on how you installed/configured it on your machine, those flags would be necessary for a flake based build. Though I've recreated the issue locally on my own linux machine. I'll push up a fix shortly.

endoze added 2 commits May 2, 2026 16:35
buildGoModule with CGO_ENABLED=0 prevented the scard smart card
package from linking against platform libraries. Switch to
gomod2nix's buildGoApplication so CGO works and add the required
platform-specific dependencies (apple-sdk on macOS, pcsclite on
Linux). Add a CI job to keep gomod2nix.toml in sync.
The gomod2nix CI check required contributors to have a working
Nix environment to regenerate gomod2nix.toml before their PR
could pass. This created unnecessary friction for Go dependency
updates since most contributors don't need Nix tooling.

Replace the blocking check with a post-merge workflow that
automatically opens a PR to sync gomod2nix.toml whenever
go.mod or go.sum change on master, keeping the Nix build
in sync without burdening contributors.
@endoze endoze force-pushed the fix/scard-cgo-enabled branch from 5c11028 to fce4152 Compare May 2, 2026 20:36
@endoze
Copy link
Copy Markdown
Contributor Author

endoze commented May 2, 2026

I rewrote my commits so you'll need to make sure you pull down the latest, but this should now build correctly on linux. The issue was missing pkg-config when compiling the native stuff for scard.

@andrinoff
Copy link
Copy Markdown
Member

I rewrote my commits so you'll need to make sure you pull down the latest, but this should now build correctly on linux. The issue was missing pkg-config when compiling the native stuff for scard.

weird, seems to still not work... i will try it tomorrow, its 1 am. ttys

@andrinoff
Copy link
Copy Markdown
Member

i'll trust you on this one

Copy link
Copy Markdown
Member

@andrinoff andrinoff left a comment

Choose a reason for hiding this comment

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

lgtm

@andrinoff
Copy link
Copy Markdown
Member

/approve

Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Approved on behalf of @andrinoff via /approve command.

@andrinoff andrinoff merged commit 5eac18c into floatpane:master May 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Nix build broken

3 participants