2022-10-15 20:02:13 +00:00
|
|
|
{
|
2023-04-04 23:56:51 +00:00
|
|
|
inputs = {
|
2023-06-18 00:02:10 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
2023-04-04 23:56:51 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-01-21 02:58:57 +00:00
|
|
|
nix-filter.url = "github:numtide/nix-filter";
|
2024-02-07 16:36:05 +00:00
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
2023-04-04 23:56:51 +00:00
|
|
|
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-04-05 00:30:30 +00:00
|
|
|
crane = {
|
2024-03-06 02:42:17 +00:00
|
|
|
# Pin latest crane that's not affected by the following bugs:
|
|
|
|
#
|
|
|
|
# * <https://github.com/ipetkov/crane/issues/527#issuecomment-1978079140>
|
|
|
|
# * <https://github.com/toml-rs/toml/issues/691>
|
|
|
|
# * <https://github.com/toml-rs/toml/issues/267>
|
|
|
|
url = "github:ipetkov/crane?rev=2c653e4478476a52c6aa3ac0495e4dea7449ea0e";
|
2023-04-04 23:56:51 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2023-01-27 21:10:21 +00:00
|
|
|
};
|
2024-01-26 04:39:59 +00:00
|
|
|
attic.url = "github:zhaofengli/attic?ref=main";
|
2023-04-04 23:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, flake-utils
|
2024-01-21 02:58:57 +00:00
|
|
|
, nix-filter
|
2023-04-04 23:56:51 +00:00
|
|
|
|
|
|
|
, fenix
|
2023-04-05 00:30:30 +00:00
|
|
|
, crane
|
2024-01-26 04:39:59 +00:00
|
|
|
, ...
|
2023-04-04 23:56:51 +00:00
|
|
|
}: flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
2024-01-26 04:39:59 +00:00
|
|
|
pkgsHost = nixpkgs.legacyPackages.${system};
|
2024-04-11 03:03:40 +00:00
|
|
|
allocator = null;
|
2023-04-05 02:11:34 +00:00
|
|
|
|
2024-03-09 20:45:27 +00:00
|
|
|
rocksdb' = pkgs:
|
|
|
|
let
|
2024-04-18 23:43:56 +00:00
|
|
|
version = "9.1.0";
|
2024-03-09 20:45:27 +00:00
|
|
|
in
|
2024-04-11 00:31:00 +00:00
|
|
|
(pkgs.rocksdb.overrideAttrs (old: {
|
2024-03-09 20:45:27 +00:00
|
|
|
inherit version;
|
|
|
|
src = pkgs.fetchFromGitHub {
|
2024-04-19 00:49:52 +00:00
|
|
|
owner = "facebook";
|
2024-03-09 20:45:27 +00:00
|
|
|
repo = "rocksdb";
|
2024-04-19 00:49:52 +00:00
|
|
|
rev = "bcf88d48ce8aa8b536aee4dd305533b3b83cf435";
|
|
|
|
hash = "sha256-vRPyrXkXVVhP56n5FVYef8zbIsnnanQSpElmQLZ7mh8";
|
2024-03-09 20:45:27 +00:00
|
|
|
};
|
2024-04-11 00:31:00 +00:00
|
|
|
}));
|
2024-02-14 18:08:23 +00:00
|
|
|
|
2023-04-04 23:56:51 +00:00
|
|
|
# Nix-accessible `Cargo.toml`
|
|
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
|
|
|
|
|
|
# The Rust toolchain to use
|
2024-01-26 04:39:59 +00:00
|
|
|
toolchain = fenix.packages.${system}.fromToolchainFile {
|
|
|
|
file = ./rust-toolchain.toml;
|
2023-04-04 23:56:51 +00:00
|
|
|
|
2024-01-26 04:39:59 +00:00
|
|
|
# See also `rust-toolchain.toml`
|
2024-01-17 18:18:36 +00:00
|
|
|
sha256 = "sha256-SXRtAuO4IqNOQq+nLbrsDFbVk+3aVA8NNpSZsKlVH/8=";
|
2023-04-04 23:56:51 +00:00
|
|
|
};
|
|
|
|
|
2024-01-26 04:39:59 +00:00
|
|
|
builder = pkgs:
|
|
|
|
((crane.mkLib pkgs).overrideToolchain toolchain).buildPackage;
|
2023-12-21 00:11:49 +00:00
|
|
|
|
2024-01-26 04:39:59 +00:00
|
|
|
nativeBuildInputs = pkgs: [
|
|
|
|
# bindgen needs the build platform's libclang. Apparently due to
|
|
|
|
# "splicing weirdness", pkgs.rustPlatform.bindgenHook on its own doesn't
|
|
|
|
# quite do the right thing here.
|
2024-03-06 02:42:17 +00:00
|
|
|
pkgs.pkgsBuildHost.rustPlatform.bindgenHook
|
2024-01-26 04:39:59 +00:00
|
|
|
];
|
2023-12-21 00:11:49 +00:00
|
|
|
|
2024-01-26 04:39:59 +00:00
|
|
|
env = pkgs: {
|
2024-03-22 23:50:57 +00:00
|
|
|
CONDUIT_VERSION_EXTRA = self.shortRev or self.dirtyShortRev;
|
2024-02-14 18:28:28 +00:00
|
|
|
ROCKSDB_INCLUDE_DIR = "${rocksdb' pkgs}/include";
|
|
|
|
ROCKSDB_LIB_DIR = "${rocksdb' pkgs}/lib";
|
2024-01-26 04:39:59 +00:00
|
|
|
}
|
|
|
|
// pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isStatic {
|
|
|
|
ROCKSDB_STATIC = "";
|
|
|
|
}
|
|
|
|
// {
|
|
|
|
CARGO_BUILD_RUSTFLAGS = let inherit (pkgs) lib stdenv; in
|
2024-03-09 20:45:27 +00:00
|
|
|
lib.concatStringsSep " " ([ ]
|
2024-01-26 04:39:59 +00:00
|
|
|
++ lib.optionals
|
2024-03-09 20:45:27 +00:00
|
|
|
# This disables PIE for static builds, which isn't great in terms
|
|
|
|
# of security. Unfortunately, my hand is forced because nixpkgs'
|
|
|
|
# `libstdc++.a` is built without `-fPIE`, which precludes us from
|
|
|
|
# leaving PIE enabled.
|
|
|
|
stdenv.hostPlatform.isStatic
|
|
|
|
[ "-C" "relocation-model=static" ]
|
2024-01-26 04:39:59 +00:00
|
|
|
++ lib.optionals
|
2024-03-09 20:45:27 +00:00
|
|
|
(stdenv.buildPlatform.config != stdenv.hostPlatform.config)
|
|
|
|
[ "-l" "c" ]
|
2024-01-26 04:39:59 +00:00
|
|
|
++ lib.optionals
|
2024-03-09 20:45:27 +00:00
|
|
|
# This check has to match the one [here][0]. We only need to set
|
|
|
|
# these flags when using a different linker. Don't ask me why,
|
|
|
|
# though, because I don't know. All I know is it breaks otherwise.
|
|
|
|
#
|
|
|
|
# [0]: https://github.com/NixOS/nixpkgs/blob/5cdb38bb16c6d0a38779db14fcc766bc1b2394d6/pkgs/build-support/rust/lib/default.nix#L37-L40
|
|
|
|
(
|
|
|
|
# Nixpkgs doesn't check for x86_64 here but we do, because I
|
|
|
|
# observed a failure building statically for x86_64 without
|
|
|
|
# including it here. Linkers are weird.
|
|
|
|
(stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64)
|
|
|
|
&& stdenv.hostPlatform.isStatic
|
|
|
|
&& !stdenv.isDarwin
|
|
|
|
&& !stdenv.cc.bintools.isLLVM
|
|
|
|
)
|
|
|
|
[
|
|
|
|
"-l"
|
|
|
|
"stdc++"
|
|
|
|
"-L"
|
|
|
|
"${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib"
|
|
|
|
]
|
2024-01-26 04:39:59 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# What follows is stolen from [here][0]. Its purpose is to properly
|
|
|
|
# configure compilers and linkers for various stages of the build, and
|
|
|
|
# even covers the case of build scripts that need native code compiled and
|
|
|
|
# run on the build platform (I think).
|
|
|
|
#
|
2024-03-06 02:42:17 +00:00
|
|
|
# [0]: https://github.com/NixOS/nixpkgs/blob/5cdb38bb16c6d0a38779db14fcc766bc1b2394d6/pkgs/build-support/rust/lib/default.nix#L57-L80
|
2024-01-26 04:39:59 +00:00
|
|
|
// (
|
|
|
|
let
|
|
|
|
inherit (pkgs.rust.lib) envVars;
|
|
|
|
in
|
|
|
|
pkgs.lib.optionalAttrs
|
|
|
|
(pkgs.stdenv.targetPlatform.rust.rustcTarget
|
|
|
|
!= pkgs.stdenv.hostPlatform.rust.rustcTarget)
|
|
|
|
(
|
|
|
|
let
|
|
|
|
inherit (pkgs.stdenv.targetPlatform.rust) cargoEnvVarTarget;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
"CC_${cargoEnvVarTarget}" = envVars.ccForTarget;
|
|
|
|
"CXX_${cargoEnvVarTarget}" = envVars.cxxForTarget;
|
|
|
|
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" =
|
|
|
|
envVars.linkerForTarget;
|
|
|
|
}
|
|
|
|
)
|
2024-03-09 20:45:27 +00:00
|
|
|
// (
|
|
|
|
let
|
|
|
|
inherit (pkgs.stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
"CC_${cargoEnvVarTarget}" = envVars.ccForHost;
|
|
|
|
"CXX_${cargoEnvVarTarget}" = envVars.cxxForHost;
|
|
|
|
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForHost;
|
|
|
|
CARGO_BUILD_TARGET = rustcTarget;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// (
|
|
|
|
let
|
|
|
|
inherit (pkgs.stdenv.buildPlatform.rust) cargoEnvVarTarget;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
"CC_${cargoEnvVarTarget}" = envVars.ccForBuild;
|
|
|
|
"CXX_${cargoEnvVarTarget}" = envVars.cxxForBuild;
|
|
|
|
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForBuild;
|
|
|
|
HOST_CC = "${pkgs.pkgsBuildHost.stdenv.cc}/bin/cc";
|
|
|
|
HOST_CXX = "${pkgs.pkgsBuildHost.stdenv.cc}/bin/c++";
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
2024-01-26 04:39:59 +00:00
|
|
|
|
2024-04-19 00:40:10 +00:00
|
|
|
mkPackage = pkgs: allocator: cargoArgs: profile: builder pkgs {
|
2024-01-25 02:52:42 +00:00
|
|
|
src = nix-filter {
|
|
|
|
root = ./.;
|
|
|
|
include = [
|
|
|
|
"src"
|
|
|
|
"Cargo.toml"
|
|
|
|
"Cargo.lock"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-04-11 03:03:40 +00:00
|
|
|
buildFeatures = [ ]
|
|
|
|
++ (if allocator == "jemalloc" then [ "jemalloc" ] else [ ])
|
|
|
|
++ (if allocator == "hmalloc" then [ "hardened_malloc" ] else [ ])
|
|
|
|
;
|
2024-04-11 00:31:00 +00:00
|
|
|
|
2024-04-11 03:03:40 +00:00
|
|
|
rocksdb' = (if allocator == "jemalloc" then (pkgs.rocksdb.override { enableJemalloc = true; }) else (rocksdb' pkgs));
|
2024-04-11 00:31:00 +00:00
|
|
|
|
|
|
|
# This is redundant with CI
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
env = env pkgs;
|
|
|
|
nativeBuildInputs = nativeBuildInputs pkgs;
|
|
|
|
|
2024-04-19 00:40:10 +00:00
|
|
|
cargoExtraArgs = cargoArgs;
|
|
|
|
|
2024-04-11 00:31:00 +00:00
|
|
|
meta.mainProgram = cargoToml.package.name;
|
2024-04-19 00:40:10 +00:00
|
|
|
|
|
|
|
CARGO_PROFILE = profile;
|
2024-04-11 00:31:00 +00:00
|
|
|
};
|
|
|
|
|
2024-04-19 23:21:36 +00:00
|
|
|
mkOciImage = pkgs: package:
|
2024-04-17 02:06:52 +00:00
|
|
|
pkgs.dockerTools.buildLayeredImage {
|
2024-01-26 04:39:59 +00:00
|
|
|
name = package.pname;
|
2024-04-17 07:02:01 +00:00
|
|
|
tag = "main";
|
2024-04-17 02:06:52 +00:00
|
|
|
# Debian makes builds reproducible through using the HEAD commit's date
|
|
|
|
created = "@${toString self.lastModified}";
|
|
|
|
contents = [
|
2024-01-27 21:27:00 +00:00
|
|
|
pkgs.dockerTools.caCertificates
|
|
|
|
];
|
2024-01-26 04:39:59 +00:00
|
|
|
config = {
|
|
|
|
# Use the `tini` init system so that signals (e.g. ctrl+c/SIGINT)
|
|
|
|
# are handled as expected
|
2024-04-19 23:21:36 +00:00
|
|
|
Entrypoint = if !pkgs.stdenv.isDarwin then [
|
2024-01-26 04:39:59 +00:00
|
|
|
"${pkgs.lib.getExe' pkgs.tini "tini"}"
|
|
|
|
"--"
|
2024-04-19 23:21:36 +00:00
|
|
|
] else [];
|
2024-01-26 04:39:59 +00:00
|
|
|
Cmd = [
|
|
|
|
"${pkgs.lib.getExe package}"
|
|
|
|
];
|
|
|
|
};
|
2024-01-25 02:52:42 +00:00
|
|
|
};
|
2024-04-19 00:40:10 +00:00
|
|
|
|
|
|
|
createComplementRuntime = pkgs: image: let
|
|
|
|
complement = pkgs.fetchFromGitHub {
|
|
|
|
owner = "matrix-org";
|
|
|
|
repo = "complement";
|
|
|
|
rev = "d73c81a091604b0fc5b6b0617dcac58c25763f57";
|
|
|
|
hash = "sha256-hom/Lt0gZzLWqFhUJG0X2i88CAMIILInO5w0tPj6G3s";
|
|
|
|
};
|
|
|
|
|
|
|
|
script = pkgs.writeShellScriptBin "run.sh"
|
|
|
|
''
|
|
|
|
export PATH=${pkgs.lib.makeBinPath [ pkgs.olm pkgs.gcc ]}
|
|
|
|
${pkgs.lib.getExe pkgs.docker} load < ${image}
|
|
|
|
set +o pipefail
|
|
|
|
/usr/bin/env -C "${complement}" COMPLEMENT_BASE_IMAGE="complement-conduit:dev" ${pkgs.lib.getExe pkgs.go} test -json ${complement}/tests | ${pkgs.toybox}/bin/tee $1
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
# Post-process the results into an easy-to-compare format
|
|
|
|
${pkgs.coreutils}/bin/cat "$1" | ${pkgs.lib.getExe pkgs.jq} -c '
|
|
|
|
select(
|
|
|
|
(.Action == "pass" or .Action == "fail" or .Action == "skip")
|
|
|
|
and .Test != null
|
|
|
|
) | {Action: .Action, Test: .Test}
|
|
|
|
' | ${pkgs.coreutils}/bin/sort > "$2"
|
|
|
|
'';
|
|
|
|
|
|
|
|
in script;
|
|
|
|
|
|
|
|
createComplementImage = pkgs: let
|
|
|
|
|
|
|
|
conduwuit = mkPackage pkgs "jemalloc" "--features=axum_dual_protocol" "dev";
|
|
|
|
|
|
|
|
in pkgs.dockerTools.buildImage {
|
|
|
|
name = "complement-conduit";
|
|
|
|
tag = "dev";
|
|
|
|
|
|
|
|
copyToRoot = pkgs.stdenv.mkDerivation {
|
|
|
|
|
|
|
|
name = "complement_data";
|
|
|
|
src = nix-filter {
|
|
|
|
root = ./.;
|
|
|
|
include = [
|
|
|
|
"tests/complement/conduwuit-complement.toml"
|
|
|
|
"tests/complement/v3.ext"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
phases = [ "unpackPhase" "installPhase" ];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/conduwuit/data
|
|
|
|
cp $src/tests/complement/conduwuit-complement.toml $out/conduwuit/conduit.toml
|
|
|
|
cp $src/tests/complement/v3.ext $out/v3.ext
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|
|
|
Cmd = [
|
|
|
|
"${pkgs.bash}/bin/sh"
|
|
|
|
"-c"
|
|
|
|
''
|
|
|
|
echo "Starting server as $SERVER_NAME" &&
|
|
|
|
export CONDUIT_SERVER_NAME=$SERVER_NAME CONDUIT_WELL_KNOWN_SERVER="$SERVER_NAME:8448" CONDUIT_WELL_KNOWN_SERVER="$SERVER_NAME:8008" &&
|
|
|
|
${pkgs.lib.getExe pkgs.openssl} genrsa -out /conduwuit/private_key.key 2048 &&
|
|
|
|
${pkgs.lib.getExe pkgs.openssl} req -new -sha256 -key /conduwuit/private_key.key -subj "/C=US/ST=CA/O=MyOrg, Inc./CN=$SERVER_NAME" -out /conduwuit/signing_request.csr &&
|
|
|
|
echo "DNS.1 = $SERVER_NAME" >> /v3.ext &&
|
|
|
|
echo "IP.1 = $(${pkgs.lib.getExe pkgs.gawk} 'END{print $1}' /etc/hosts)" >> /v3.ext &&
|
|
|
|
${pkgs.lib.getExe pkgs.openssl} x509 -req -extfile /v3.ext -in /conduwuit/signing_request.csr -CA /complement/ca/ca.crt -CAkey /complement/ca/ca.key -CAcreateserial -out /conduwuit/certificate.crt -days 1 -sha256 &&
|
|
|
|
${pkgs.lib.getExe conduwuit}
|
|
|
|
''
|
|
|
|
];
|
|
|
|
|
2024-04-19 23:21:36 +00:00
|
|
|
Entrypoint = if !pkgs.stdenv.isDarwin then [
|
2024-04-19 00:40:10 +00:00
|
|
|
"${pkgs.lib.getExe' pkgs.tini "tini"}"
|
|
|
|
"--"
|
2024-04-19 23:21:36 +00:00
|
|
|
] else [];
|
2024-04-19 00:40:10 +00:00
|
|
|
|
|
|
|
Env = [
|
|
|
|
"SSL_CERT_FILE=/complement/ca/ca.crt"
|
|
|
|
"SERVER_NAME=localhost"
|
|
|
|
"CONDUIT_CONFIG=/conduwuit/conduit.toml"
|
|
|
|
];
|
|
|
|
|
|
|
|
ExposedPorts = {
|
|
|
|
"8008/tcp" = {};
|
|
|
|
"8448/tcp" = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
2024-01-26 04:39:59 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages = {
|
2024-04-19 00:40:10 +00:00
|
|
|
default = mkPackage pkgsHost null "" "release";
|
|
|
|
jemalloc = mkPackage pkgsHost "jemalloc" "" "release";
|
|
|
|
hmalloc = mkPackage pkgsHost "hmalloc" "" "release";
|
2024-04-19 23:21:36 +00:00
|
|
|
oci-image = mkOciImage pkgsHost self.packages.${system}.default;
|
2024-04-19 22:57:26 +00:00
|
|
|
oci-image-jemalloc = mkOciImage pkgsHost self.packages.${system}.jemalloc;
|
|
|
|
oci-image-hmalloc = mkOciImage pkgsHost self.packages.${system}.hmalloc;
|
2024-03-17 22:06:10 +00:00
|
|
|
|
|
|
|
book =
|
|
|
|
let
|
|
|
|
package = self.packages.${system}.default;
|
|
|
|
in
|
|
|
|
pkgsHost.stdenv.mkDerivation {
|
|
|
|
pname = "${package.pname}-book";
|
|
|
|
version = package.version;
|
|
|
|
|
|
|
|
src = nix-filter {
|
|
|
|
root = ./.;
|
|
|
|
include = [
|
|
|
|
"book.toml"
|
2024-03-18 05:10:54 +00:00
|
|
|
"conduwuit-example.toml"
|
2024-03-17 22:06:10 +00:00
|
|
|
"README.md"
|
|
|
|
"debian/README.md"
|
|
|
|
"docs"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = (with pkgsHost; [
|
|
|
|
mdbook
|
|
|
|
]);
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mdbook build
|
|
|
|
mv public $out
|
|
|
|
'';
|
|
|
|
};
|
2024-04-19 00:40:10 +00:00
|
|
|
complement-image = createComplementImage pkgsHost;
|
|
|
|
complement-runtime = createComplementRuntime pkgsHost self.outputs.packages.${system}.complement-image;
|
2024-01-29 23:48:30 +00:00
|
|
|
}
|
|
|
|
//
|
|
|
|
builtins.listToAttrs
|
|
|
|
(builtins.concatLists
|
|
|
|
(builtins.map
|
|
|
|
(crossSystem:
|
|
|
|
let
|
|
|
|
binaryName = "static-${crossSystem}";
|
|
|
|
pkgsCrossStatic =
|
|
|
|
(import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
crossSystem = {
|
|
|
|
config = crossSystem;
|
|
|
|
};
|
|
|
|
}).pkgsStatic;
|
|
|
|
in
|
|
|
|
[
|
|
|
|
# An output for a statically-linked binary
|
|
|
|
{
|
|
|
|
name = binaryName;
|
2024-04-19 00:40:10 +00:00
|
|
|
value = mkPackage pkgsCrossStatic null "" "release";
|
2024-01-29 23:48:30 +00:00
|
|
|
}
|
|
|
|
|
2024-04-11 00:31:00 +00:00
|
|
|
# An output for a statically-linked binary with jemalloc
|
|
|
|
{
|
|
|
|
name = "${binaryName}-jemalloc";
|
2024-04-19 00:40:10 +00:00
|
|
|
value = mkPackage pkgsCrossStatic "jemalloc" "" "release";
|
2024-04-11 00:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# An output for a statically-linked binary with hardened_malloc
|
|
|
|
{
|
|
|
|
name = "${binaryName}-hmalloc";
|
2024-04-19 00:40:10 +00:00
|
|
|
value = mkPackage pkgsCrossStatic "hmalloc" "" "release";
|
2024-04-11 00:31:00 +00:00
|
|
|
}
|
|
|
|
|
2024-01-29 23:48:30 +00:00
|
|
|
# An output for an OCI image based on that binary
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}";
|
|
|
|
value = mkOciImage
|
|
|
|
pkgsCrossStatic
|
2024-04-19 23:21:36 +00:00
|
|
|
self.packages.${system}.${binaryName};
|
2024-01-29 23:48:30 +00:00
|
|
|
}
|
2024-04-11 00:31:00 +00:00
|
|
|
|
|
|
|
# An output for an OCI image based on that binary with jemalloc
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}-jemalloc";
|
2024-04-11 03:03:40 +00:00
|
|
|
value = mkOciImage
|
2024-04-11 00:31:00 +00:00
|
|
|
pkgsCrossStatic
|
2024-04-19 23:21:36 +00:00
|
|
|
self.packages.${system}.${binaryName};
|
2024-04-11 00:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# An output for an OCI image based on that binary with hardened_malloc
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}-hmalloc";
|
2024-04-11 03:03:40 +00:00
|
|
|
value = mkOciImage
|
2024-04-11 00:31:00 +00:00
|
|
|
pkgsCrossStatic
|
2024-04-19 23:21:36 +00:00
|
|
|
self.packages.${system}.${binaryName};
|
2024-04-11 00:31:00 +00:00
|
|
|
}
|
2024-01-29 23:48:30 +00:00
|
|
|
]
|
|
|
|
)
|
|
|
|
[
|
|
|
|
"x86_64-unknown-linux-musl"
|
|
|
|
"aarch64-unknown-linux-musl"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
2024-01-26 04:39:59 +00:00
|
|
|
|
|
|
|
devShells.default = pkgsHost.mkShell {
|
|
|
|
env = env pkgsHost // {
|
2023-12-21 00:11:49 +00:00
|
|
|
# Rust Analyzer needs to be able to find the path to default crate
|
|
|
|
# sources, and it can read this environment variable to do so. The
|
|
|
|
# `rust-src` component is required in order for this to work.
|
2024-01-26 04:39:59 +00:00
|
|
|
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
2023-12-21 00:11:49 +00:00
|
|
|
};
|
2023-07-16 20:38:33 +00:00
|
|
|
|
2023-04-04 23:56:51 +00:00
|
|
|
# Development tools
|
2024-01-26 04:39:59 +00:00
|
|
|
nativeBuildInputs = nativeBuildInputs pkgsHost ++ [
|
|
|
|
# Always use nightly rustfmt because most of its options are unstable
|
|
|
|
#
|
|
|
|
# This needs to come before `toolchain` in this list, otherwise
|
|
|
|
# `$PATH` will have stable rustfmt instead.
|
|
|
|
fenix.packages.${system}.latest.rustfmt
|
|
|
|
|
|
|
|
toolchain
|
|
|
|
] ++ (with pkgsHost; [
|
2023-12-21 00:33:31 +00:00
|
|
|
engage
|
2024-01-28 23:53:27 +00:00
|
|
|
|
2024-03-06 02:42:17 +00:00
|
|
|
# Needed for producing Debian packages
|
|
|
|
cargo-deb
|
|
|
|
|
2024-01-28 23:53:27 +00:00
|
|
|
# Needed for Complement
|
|
|
|
go
|
|
|
|
olm
|
|
|
|
|
|
|
|
# Needed for our script for Complement
|
|
|
|
jq
|
2024-03-17 22:06:10 +00:00
|
|
|
|
|
|
|
# Needed for finding broken markdown links
|
|
|
|
lychee
|
2024-03-21 22:40:10 +00:00
|
|
|
|
|
|
|
# Useful for editing the book locally
|
|
|
|
mdbook
|
2023-12-21 00:33:31 +00:00
|
|
|
]);
|
2023-04-04 23:56:51 +00:00
|
|
|
};
|
|
|
|
});
|
2022-10-15 20:02:13 +00:00
|
|
|
}
|