Skip to content

Conversation

6543
Copy link
Member

@6543 6543 commented Jul 23, 2025

with nix develop -c $SHELL you can enter the dev environment.
now with make clean-all generate build -j1 you will get a static linked binary that has sqlite support

example:
image

@6543 6543 requested a review from techknowlogick July 23, 2025 13:42
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 23, 2025
@6543 6543 changed the title Nix flake build static with sqlite support WIP: Nix flake build static with sqlite support Jul 23, 2025
@6543 6543 added the pr/wip This PR is not ready for review label Jul 23, 2025
@6543
Copy link
Member Author

6543 commented Jul 24, 2025

Before, we can build (cross-compile) Gitea without CGO

@wxiaoguang now it should not break anything :)

You could probably put this env var in the nix flake though.

done ...

I suggest something like GO_BUILD_VARS ?= in the Makefile ...

well the makefile could be reworked to use less specific env vars and build things up to be collected in one var ... but I think this is some refactor to be done in another pull dedicated to it ... if one wants to

Same question, why CGO_ENABLED is needed, why -extldflags -static is needed

because if you dont build static in nixos the gitea binary just panics:

image

@6543 6543 requested a review from techknowlogick July 24, 2025 14:39
@6543 6543 changed the title WIP: Nix flake build static with sqlite support Nix flake build static with sqlite support Jul 24, 2025
@6543 6543 removed the pr/wip This PR is not ready for review label Jul 24, 2025
@6543
Copy link
Member Author

6543 commented Jul 24, 2025

image

@6543
Copy link
Member Author

6543 commented Jul 24, 2025

@techknowlogick pam needs cgo too - added :)

and it does not support static linking ...

@6543 6543 added the pr/wip This PR is not ready for review label Aug 6, 2025
@6543 6543 requested a review from techknowlogick August 6, 2025 16:24
@6543
Copy link
Member Author

6543 commented Aug 6, 2025

@techknowlogick static also works on windows :)

no static:
image

with static:
image
image

@6543 6543 removed the pr/wip This PR is not ready for review label Aug 6, 2025
@techknowlogick techknowlogick enabled auto-merge (squash) August 6, 2025 17:00
Copy link
Member

@techknowlogick techknowlogick left a comment

Choose a reason for hiding this comment

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

Thanks :)

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 6, 2025
@techknowlogick techknowlogick added skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Aug 6, 2025
@6543 6543 requested a review from silverwind August 6, 2025 17:46
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 6, 2025
@techknowlogick techknowlogick merged commit 28a7cc4 into go-gitea:main Aug 6, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.25.0 milestone Aug 6, 2025
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 6, 2025
@lafriks lafriks deleted the nix-flake_allow-CGO-builds branch August 6, 2025 20:22
@6543 6543 added the backport/v1.24 This PR should be backported to Gitea 1.24 label Aug 6, 2025
6543 added a commit to 6543-forks/gitea that referenced this pull request Aug 6, 2025
with `nix develop -c $SHELL` you can enter the dev environment.
now with `make clean-all generate build -j1` you will get a static
linked binary that has sqlite support
@6543
Copy link
Member Author

6543 commented Aug 6, 2025

backpott -> #35225

@6543 6543 added the backport/done All backports for this PR have been created label Aug 6, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 7, 2025
* giteaofficial/main:
  Nix flake build static with sqlite support (go-gitea#35149)
  Vertically center "Show Resolved" (go-gitea#35211)
  [skip ci] Updated translations via Crowdin
lafriks pushed a commit that referenced this pull request Aug 7, 2025
Backport #35149

with `nix develop -c $SHELL` you can enter the dev environment. now with
`make clean-all generate build -j1` you will get a static linked binary
that has sqlite support

outside of an nix dev shell if you set `STATIC=true` you also will get a
static binary
hiifong added a commit to hiifong/gitea that referenced this pull request Aug 11, 2025
* upstream/main:
  [skip ci] Updated translations via Crowdin
  [skip ci] Updated translations via Crowdin
  Update stylelint, enable `report*` options (go-gitea#35236)
  Add `has_code` to repository REST API (go-gitea#35214)
  Upgrade go to 1.24.6 (go-gitea#35235)
  [skip ci] Updated translations via Crowdin
  Nix flake build static with sqlite support (go-gitea#35149)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.24 This PR should be backported to Gitea 1.24 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/internal skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants