mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-05 20:40:02 -08:00
This splits the complexity of the `flake.nix` into multiple files. At cross-compiled and static builds at the benefit of simpler nix expressions and generally better cross compilation compatibility. the same time, naersk is removed; causing much slower builds for cross- compiled packages. This partially addresses the points mentioned in #412.
79 lines
2.0 KiB
Nix
79 lines
2.0 KiB
Nix
{ lib, stdenv, rustPlatform, cmake, mandoc, removeReferencesTo, bash, package ? "rosenpass" }:
|
|
|
|
let
|
|
# whether we want to build a statically linked binary
|
|
isStatic = stdenv.targetPlatform.isStatic;
|
|
|
|
scoped = (scope: scope.result);
|
|
|
|
# source files relevant for rust
|
|
src = scoped rec {
|
|
# File suffices to include
|
|
extensions = [
|
|
"lock"
|
|
"rs"
|
|
"toml"
|
|
];
|
|
# Files to explicitly include
|
|
files = [
|
|
"to/README.md"
|
|
];
|
|
|
|
src = ../.;
|
|
filter = (path: type: scoped rec {
|
|
inherit (lib) any id removePrefix hasSuffix;
|
|
anyof = (any id);
|
|
|
|
basename = baseNameOf (toString path);
|
|
relative = removePrefix (toString src + "/") (toString path);
|
|
|
|
result = anyof [
|
|
(type == "directory")
|
|
(any (ext: hasSuffix ".${ext}" basename) extensions)
|
|
(any (file: file == relative) files)
|
|
];
|
|
});
|
|
|
|
result = lib.sources.cleanSourceWith { inherit src filter; };
|
|
};
|
|
|
|
# parsed Cargo.toml
|
|
cargoToml = builtins.fromTOML (builtins.readFile (src + "/rosenpass/Cargo.toml"));
|
|
in
|
|
rustPlatform.buildRustPackage {
|
|
name = cargoToml.package.name;
|
|
version = cargoToml.package.version;
|
|
inherit src;
|
|
|
|
cargoBuildOptions = [ "--package" package ];
|
|
cargoTestOptions = [ "--package" package ];
|
|
|
|
doCheck = true;
|
|
|
|
cargoLock = {
|
|
lockFile = src + "/Cargo.lock";
|
|
outputHashes = {
|
|
"memsec-0.6.3" = "sha256-4ri+IEqLd77cLcul3lZrmpDKj4cwuYJ8oPRAiQNGeLw=";
|
|
"uds-0.4.2" = "sha256-qlxr/iJt2AV4WryePIvqm/8/MK/iqtzegztNliR93W8=";
|
|
};
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
stdenv.cc
|
|
cmake # for oqs build in the oqs-sys crate
|
|
mandoc # for the built-in manual
|
|
removeReferencesTo
|
|
rustPlatform.bindgenHook # for C-bindings in the crypto libs
|
|
];
|
|
buildInputs = [ bash ];
|
|
|
|
hardeningDisable = lib.optional isStatic "fortify";
|
|
|
|
meta = {
|
|
inherit (cargoToml.package) description homepage;
|
|
license = with lib.licenses; [ mit asl20 ];
|
|
maintainers = [ lib.maintainers.wucke13 ];
|
|
platforms = lib.platforms.all;
|
|
};
|
|
}
|