continuwuity/nix/packages/continuwuity.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

62 lines
1.5 KiB
Nix

{
lib,
self,
stdenv,
liburing,
craneLib,
pkg-config,
rustPlatform,
cargoExtraArgs ? "",
rustflags ? "",
target_cpu ? null,
profile ? "release",
}:
let
# see https://crane.dev/API.html#cranelibfiltercargosources
# we need to keep the `web` directory which would be filtered out by the regular source filtering function
# https://crane.dev/API.html#cranelibcleancargosource
isWebTemplate = path: _type: builtins.match ".*(src/(web|service)|docs).*" path != null;
isRust = craneLib.filterCargoSources;
isNix = path: _type: builtins.match ".+/nix.*" path != null;
webOrRustNotNix = p: t: !(isNix p t) && (isWebTemplate p t || isRust p t);
src = lib.cleanSourceWith {
src = self;
filter = webOrRustNotNix;
name = "source";
};
attrs = {
__structuredAttrs = true;
strictDeps = true;
inherit src;
nativeBuildInputs = [
pkg-config
rustPlatform.bindgenHook
];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ liburing ];
doCheck = false;
env = {
CARGO_PROFILE = profile;
RUSTFLAGS = rustflags;
}
// (lib.optionalAttrs (target_cpu != null) {
TARGET_CPU = target_cpu;
});
};
in
craneLib.buildPackage (
lib.recursiveUpdate attrs {
inherit cargoExtraArgs;
cargoArtifacts = craneLib.buildDepsOnly attrs;
meta = {
description = "A community-driven Matrix homeserver in Rust";
mainProgram = "conduwuit";
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ quadradical ];
};
}
)