chore(devshell): add test shell without static glibc
The default shell links cgo statically against glibc.static for the production gitea binary. Test binaries built in that shell segfault inside cgo NSS calls (getaddrinfo/getpwuid_r) because the static glibc NSS modules need matching dynamic libs at runtime. Split the shell: - `nix develop` -> production build shell (static, unchanged) - `nix develop .#test` -> test/dev shell, no static glibc Verified: TestAPIProjects passes in the `test` shell.
This commit is contained in:
@@ -27,8 +27,6 @@
|
||||
{
|
||||
devShells = forEachSupportedSystem (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
default =
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
|
||||
@@ -38,20 +36,7 @@
|
||||
python3 = pkgs.python314;
|
||||
pnpm = pkgs.pnpm_10;
|
||||
|
||||
# Platform-specific dependencies
|
||||
linuxOnlyInputs = lib.optionals pkgs.stdenv.isLinux [
|
||||
pkgs.glibc.static
|
||||
];
|
||||
|
||||
linuxOnlyEnv = lib.optionalAttrs pkgs.stdenv.isLinux {
|
||||
CFLAGS = "-I${pkgs.glibc.static.dev}/include";
|
||||
LDFLAGS = "-L ${pkgs.glibc.static}/lib";
|
||||
};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
packages =
|
||||
with pkgs;
|
||||
[
|
||||
commonPackages = with pkgs; [
|
||||
# generic
|
||||
git
|
||||
git-lfs
|
||||
@@ -79,17 +64,36 @@
|
||||
golangci-lint
|
||||
govulncheck
|
||||
tea
|
||||
]
|
||||
++ linuxOnlyInputs;
|
||||
];
|
||||
|
||||
env = {
|
||||
commonEnv = {
|
||||
GO = "${go}/bin/go";
|
||||
GOROOT = "${go}/share/go";
|
||||
|
||||
TAGS = "";
|
||||
};
|
||||
in
|
||||
{
|
||||
# production build shell: cgo links statically against glibc.static
|
||||
default = pkgs.mkShell {
|
||||
packages =
|
||||
commonPackages
|
||||
++ lib.optionals pkgs.stdenv.isLinux [ pkgs.glibc.static ];
|
||||
|
||||
env =
|
||||
commonEnv
|
||||
// {
|
||||
STATIC = "true";
|
||||
}
|
||||
// linuxOnlyEnv;
|
||||
// lib.optionalAttrs pkgs.stdenv.isLinux {
|
||||
CFLAGS = "-I${pkgs.glibc.static.dev}/include";
|
||||
LDFLAGS = "-L ${pkgs.glibc.static}/lib";
|
||||
};
|
||||
};
|
||||
|
||||
# test/dev shell: no static glibc — avoids cgo NSS segfaults in `go test`
|
||||
test = pkgs.mkShell {
|
||||
packages = commonPackages;
|
||||
env = commonEnv;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user