nix: static linking via nix

This commit is contained in:
Ophestra 2025-07-24 18:12:54 +09:00
parent 4d9d4bcef2
commit b298c5f572
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
2 changed files with 25 additions and 0 deletions

1
default.nix Normal file
View File

@ -0,0 +1 @@
with import <nixpkgs> { }; pkgsStatic.callPackage ./package.nix { }

24
package.nix Normal file
View File

@ -0,0 +1,24 @@
{
lib,
stdenv,
buildGoModule,
pkg-config,
}:
buildGoModule {
pname = "nix-tool";
version = "0.1.4";
src = ./.;
vendorHash = "sha256-SVSrY9SZnS6NLin+apdN4efqCzHgBBY8LIjXcUCXbUo=";
ldflags =
[ "-s -w" ]
++ lib.optionals stdenv.hostPlatform.isStatic [
"-linkmode external"
"-extldflags \"-static\""
];
nativeBuildInputs = [
pkg-config
];
}