continuwuity/nix/packages/default.nix
Henry-Hiles fddca8d534
feat: Static musl builds via nix
fix: don't do check on all builds

Checks can be done with `nix flake check`, no need to slow down build process with this.

feat: add static binary build instructions to docs

feat: add max-perf package

feat: add build-nix workflow

chore: add changelog

fix: fix max-perf-static packages not statically linking

feat: improve docs for building with nix

chore: more descriptive name for binary build step of workflow

fix: resolve review comment about Haswell CPUs

chore: enable __structuredAttrs on build

This is a good practice for modern nix packages
2026-06-20 16:54:35 +01:00

83 lines
2.4 KiB
Nix

{
inputs,
self,
...
}:
{
perSystem =
{
self',
lib,
pkgs,
system,
craneLib,
...
}:
{
packages =
let
mkPackages =
pkgs:
let
fnx = inputs.fenix.packages.${system};
isStatic = pkgs.stdenv.hostPlatform.isMusl;
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (
_:
if isStatic then
fnx.combine [
self'.packages.stable-toolchain
(fnx.targets.${pkgs.stdenv.hostPlatform.config}.stable).rust-std
]
else
self'.packages.stable-toolchain
);
default = pkgs.callPackage ./continuwuity.nix {
inherit self craneLib;
liburing = (if isStatic then pkgs.pkgsStatic else pkgs).liburing;
# extra features via `cargoExtraArgs`
cargoExtraArgs = "-F http3";
# extra RUSTFLAGS via `rustflags`
# the stuff below is required for http3
rustflags = "--cfg reqwest_unstable";
};
# users may also override this with other cargo profiles to build for other feature sets
# for features configuration see `default` package which enables http3 by default
max-perf = default.override {
# compiles slower but with more thorough optimizations
profile = "release-max-perf";
};
max-perf-haswell = max-perf.override {
# compiles explicitly for haswell arch cpus
target_cpu = "haswell";
};
in
{
inherit default max-perf max-perf-haswell;
};
in
(mkPackages pkgs)
// (lib.mapAttrs' (name: value: lib.nameValuePair "${name}-static-x86_64" value) (
mkPackages (
import inputs.nixpkgs {
localSystem = system;
crossSystem = "x86_64-unknown-linux-musl";
}
)
))
// (lib.mapAttrs' (name: value: lib.nameValuePair "${name}-static-aarch64" value) (
mkPackages (
import inputs.nixpkgs {
localSystem = system;
crossSystem = "aarch64-unknown-linux-musl";
}
)
));
};
}