forked from tangled.org/core
Monorepo for Tangled

nix: static builds

Changed files
+20 -10
+1
.gitignore
··· 3 3 *.db 4 4 .bin/ 5 5 appview/pages/static/* 6 + result 6 7 !.gitkeep
+19 -10
flake.nix
··· 45 45 }; 46 46 47 47 appview = with final; 48 - final.buildGoModule { 48 + final.pkgsStatic.buildGoModule { 49 49 pname = "appview"; 50 50 version = "0.1.0"; 51 51 src = gitignoreSource ./.; ··· 56 56 subPackages = ["cmd/appview"]; 57 57 vendorHash = "sha256-QgUPTOgAdKUTg+ztfs194G7pt3/qDtqTMkDRmMECxSo="; 58 58 env.CGO_ENABLED = 1; 59 + stdenv = pkgsStatic.stdenv; 59 60 }; 60 - knotserver = with final; 61 - final.buildGoModule { 62 - pname = "knotserver"; 63 - version = "0.1.0"; 64 - src = gitignoreSource ./.; 65 - subPackages = ["cmd/knotserver"]; 66 - vendorHash = "sha256-QgUPTOgAdKUTg+ztfs194G7pt3/qDtqTMkDRmMECxSo="; 67 - env.CGO_ENABLED = 1; 68 - }; 61 + 62 + knotserver = with final; 63 + final.pkgsStatic.buildGoModule { 64 + pname = "knotserver"; 65 + version = "0.1.0"; 66 + src = gitignoreSource ./.; 67 + subPackages = ["cmd/knotserver"]; 68 + vendorHash = "sha256-QgUPTOgAdKUTg+ztfs194G7pt3/qDtqTMkDRmMECxSo="; 69 + env.CGO_ENABLED = 1; 70 + nativeBuildInputs = with pkgsMusl; [ pkg-config ]; 71 + 72 + # Add these ldflags for static compilation 73 + ldflags = [ "-s" "-w" "-linkmode external" ''-extldflags "-static -L${pkgsStatic.musl}/lib"'' ]; 74 + 75 + # Use static stdenv 76 + stdenv = pkgMusl.stdenv; 77 + }; 69 78 }; 70 79 packages = forAllSystems (system: { 71 80 inherit (nixpkgsFor."${system}") indigo-lexgen appview knotserver;