From 73ecd4e89ec9e0a8d259616aed604f279669f6fc Mon Sep 17 00:00:00 2001 From: Konstantin Fickel Date: Thu, 2 Apr 2026 22:54:42 +0200 Subject: [PATCH] feat(flake): add musl static build for streamd Add mkMuslCraneLib and mkStreamdMusl functions to create a statically-linked binary using the x86_64-unknown-linux-musl target. This enables portable binaries that don't depend on system glibc. --- flake.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/flake.nix b/flake.nix index 430150f..9f0f395 100644 --- a/flake.nix +++ b/flake.nix @@ -105,6 +105,32 @@ commitizen.enable = true; }; }; + + mkMuslCraneLib = + system: + let + pkgs = mkPkgs system; + toolchain = pkgs.rust-bin.stable.latest.default.override { + targets = [ "x86_64-unknown-linux-musl" ]; + }; + in + (crane.mkLib pkgs).overrideToolchain toolchain; + + mkStreamdMusl = + system: + let + craneLib = mkMuslCraneLib system; + commonArgs = { + src = craneLib.path ./.; + pname = "streamd"; + inherit version; + strictDeps = true; + CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl"; + CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static"; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + in + craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); in { packages = forAllSystems (