Format all nix files with new nixfmt
This commit is contained in:
committed by
June Strawberry
parent
dbc208d5d9
commit
f2a15fda34
21
default.nix
21
default.nix
@@ -1,10 +1,11 @@
|
|||||||
(import
|
(import (
|
||||||
(
|
let
|
||||||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
fetchTarball {
|
in
|
||||||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
fetchTarball {
|
||||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
url =
|
||||||
}
|
lock.nodes.flake-compat.locked.url
|
||||||
)
|
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||||
{ src = ./.; }
|
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||||
).defaultNix
|
}
|
||||||
|
) { src = ./.; }).defaultNix
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
{ inputs
|
{
|
||||||
|
inputs,
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
, main
|
main,
|
||||||
, mdbook
|
mdbook,
|
||||||
, stdenv
|
stdenv,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
# Dependencies
|
# Dependencies
|
||||||
{ bashInteractive
|
{
|
||||||
, buildEnv
|
bashInteractive,
|
||||||
, coreutils
|
buildEnv,
|
||||||
, dockerTools
|
coreutils,
|
||||||
, lib
|
dockerTools,
|
||||||
, main
|
lib,
|
||||||
, stdenv
|
main,
|
||||||
, tini
|
stdenv,
|
||||||
, writeShellScriptBin
|
tini,
|
||||||
|
writeShellScriptBin,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@@ -16,24 +17,24 @@ let
|
|||||||
all_features = true;
|
all_features = true;
|
||||||
disable_release_max_log_level = true;
|
disable_release_max_log_level = true;
|
||||||
disable_features = [
|
disable_features = [
|
||||||
# console/CLI stuff isn't used or relevant for complement
|
# console/CLI stuff isn't used or relevant for complement
|
||||||
"console"
|
"console"
|
||||||
"tokio_console"
|
"tokio_console"
|
||||||
# sentry telemetry isn't useful for complement, disabled by default anyways
|
# sentry telemetry isn't useful for complement, disabled by default anyways
|
||||||
"sentry_telemetry"
|
"sentry_telemetry"
|
||||||
"perf_measurements"
|
"perf_measurements"
|
||||||
# this is non-functional on nix for some reason
|
# this is non-functional on nix for some reason
|
||||||
"hardened_malloc"
|
"hardened_malloc"
|
||||||
# dont include experimental features
|
# dont include experimental features
|
||||||
"experimental"
|
"experimental"
|
||||||
# compression isn't needed for complement
|
# compression isn't needed for complement
|
||||||
"brotli_compression"
|
"brotli_compression"
|
||||||
"gzip_compression"
|
"gzip_compression"
|
||||||
"zstd_compression"
|
"zstd_compression"
|
||||||
# complement doesn't need hot reloading
|
# complement doesn't need hot reloading
|
||||||
"tuwunel_mods"
|
"tuwunel_mods"
|
||||||
# complement doesn't have URL preview media tests
|
# complement doesn't have URL preview media tests
|
||||||
"url_preview"
|
"url_preview"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,11 +69,18 @@ dockerTools.buildImage {
|
|||||||
"${lib.getExe start}"
|
"${lib.getExe start}"
|
||||||
];
|
];
|
||||||
|
|
||||||
Entrypoint = if !stdenv.hostPlatform.isDarwin
|
Entrypoint =
|
||||||
|
if
|
||||||
|
!stdenv.hostPlatform.isDarwin
|
||||||
# Use the `tini` init system so that signals (e.g. ctrl+c/SIGINT)
|
# Use the `tini` init system so that signals (e.g. ctrl+c/SIGINT)
|
||||||
# are handled as expected
|
# are handled as expected
|
||||||
then [ "${lib.getExe' tini "tini"}" "--" ]
|
then
|
||||||
else [];
|
[
|
||||||
|
"${lib.getExe' tini "tini"}"
|
||||||
|
"--"
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[ ];
|
||||||
|
|
||||||
Env = [
|
Env = [
|
||||||
"TUWUNEL_TLS__KEY=${./private_key.key}"
|
"TUWUNEL_TLS__KEY=${./private_key.key}"
|
||||||
@@ -82,8 +90,8 @@ dockerTools.buildImage {
|
|||||||
];
|
];
|
||||||
|
|
||||||
ExposedPorts = {
|
ExposedPorts = {
|
||||||
"8008/tcp" = {};
|
"8008/tcp" = { };
|
||||||
"8448/tcp" = {};
|
"8448/tcp" = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,35 @@
|
|||||||
{ lib
|
{
|
||||||
, pkgsBuildHost
|
lib,
|
||||||
, rust
|
pkgsBuildHost,
|
||||||
, stdenv
|
rust,
|
||||||
|
stdenv,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
lib.optionalAttrs stdenv.hostPlatform.isStatic {
|
lib.optionalAttrs stdenv.hostPlatform.isStatic {
|
||||||
ROCKSDB_STATIC = "";
|
ROCKSDB_STATIC = "";
|
||||||
}
|
}
|
||||||
//
|
// {
|
||||||
{
|
CARGO_BUILD_RUSTFLAGS = lib.concatStringsSep " " (
|
||||||
CARGO_BUILD_RUSTFLAGS =
|
[ ]
|
||||||
lib.concatStringsSep
|
# 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
|
||||||
# This disables PIE for static builds, which isn't great in terms
|
# leaving PIE enabled.
|
||||||
# of security. Unfortunately, my hand is forced because nixpkgs'
|
++ lib.optionals stdenv.hostPlatform.isStatic [
|
||||||
# `libstdc++.a` is built without `-fPIE`, which precludes us from
|
"-C"
|
||||||
# leaving PIE enabled.
|
"relocation-model=static"
|
||||||
++ lib.optionals
|
]
|
||||||
stdenv.hostPlatform.isStatic
|
++ lib.optionals (stdenv.buildPlatform.config != stdenv.hostPlatform.config) [
|
||||||
[ "-C" "relocation-model=static" ]
|
"-l"
|
||||||
++ lib.optionals
|
"c"
|
||||||
(stdenv.buildPlatform.config != stdenv.hostPlatform.config)
|
|
||||||
[
|
|
||||||
"-l"
|
|
||||||
"c"
|
|
||||||
|
|
||||||
"-l"
|
"-l"
|
||||||
"stdc++"
|
"stdc++"
|
||||||
|
|
||||||
"-L"
|
"-L"
|
||||||
"${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib"
|
"${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# What follows is stolen from [here][0]. Its purpose is to properly
|
# What follows is stolen from [here][0]. Its purpose is to properly
|
||||||
@@ -41,26 +38,21 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic {
|
|||||||
# run on the build platform (I think).
|
# run on the build platform (I think).
|
||||||
#
|
#
|
||||||
# [0]: https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/build-support/rust/lib/default.nix#L48-L68
|
# [0]: https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/build-support/rust/lib/default.nix#L48-L68
|
||||||
//
|
// (
|
||||||
(
|
|
||||||
let
|
let
|
||||||
inherit (rust.lib) envVars;
|
inherit (rust.lib) envVars;
|
||||||
in
|
in
|
||||||
lib.optionalAttrs
|
lib.optionalAttrs (stdenv.targetPlatform.rust.rustcTarget != stdenv.hostPlatform.rust.rustcTarget) (
|
||||||
(stdenv.targetPlatform.rust.rustcTarget
|
let
|
||||||
!= stdenv.hostPlatform.rust.rustcTarget)
|
inherit (stdenv.targetPlatform.rust) cargoEnvVarTarget;
|
||||||
(
|
in
|
||||||
let
|
{
|
||||||
inherit (stdenv.targetPlatform.rust) cargoEnvVarTarget;
|
"CC_${cargoEnvVarTarget}" = envVars.ccForTarget;
|
||||||
in
|
"CXX_${cargoEnvVarTarget}" = envVars.cxxForTarget;
|
||||||
{
|
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.ccForTarget;
|
||||||
"CC_${cargoEnvVarTarget}" = envVars.ccForTarget;
|
}
|
||||||
"CXX_${cargoEnvVarTarget}" = envVars.cxxForTarget;
|
)
|
||||||
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.ccForTarget;
|
// (
|
||||||
}
|
|
||||||
)
|
|
||||||
//
|
|
||||||
(
|
|
||||||
let
|
let
|
||||||
inherit (stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget;
|
inherit (stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget;
|
||||||
in
|
in
|
||||||
@@ -71,8 +63,7 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic {
|
|||||||
CARGO_BUILD_TARGET = rustcTarget;
|
CARGO_BUILD_TARGET = rustcTarget;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
//
|
// (
|
||||||
(
|
|
||||||
let
|
let
|
||||||
inherit (stdenv.buildPlatform.rust) cargoEnvVarTarget;
|
inherit (stdenv.buildPlatform.rust) cargoEnvVarTarget;
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -1,177 +1,203 @@
|
|||||||
# Dependencies (keep sorted)
|
# Dependencies (keep sorted)
|
||||||
{ craneLib
|
{
|
||||||
, inputs
|
craneLib,
|
||||||
, jq
|
inputs,
|
||||||
, lib
|
jq,
|
||||||
, libiconv
|
lib,
|
||||||
, liburing
|
libiconv,
|
||||||
, pkgsBuildHost
|
liburing,
|
||||||
, rocksdb
|
pkgsBuildHost,
|
||||||
, removeReferencesTo
|
rocksdb,
|
||||||
, rust
|
removeReferencesTo,
|
||||||
, autoPatchelfHook
|
rust,
|
||||||
, rust-jemalloc-sys-unprefixed
|
autoPatchelfHook,
|
||||||
, stdenv
|
rust-jemalloc-sys-unprefixed,
|
||||||
|
stdenv,
|
||||||
|
|
||||||
# Options (keep sorted)
|
# Options (keep sorted)
|
||||||
, all_features ? false
|
all_features ? false,
|
||||||
, default_features ? true
|
default_features ? true,
|
||||||
# default list of disabled features
|
# default list of disabled features
|
||||||
, disable_features ? [
|
disable_features ? [
|
||||||
# dont include experimental features
|
# dont include experimental features
|
||||||
"experimental"
|
"experimental"
|
||||||
# jemalloc profiling/stats features are expensive and shouldn't
|
# jemalloc profiling/stats features are expensive and shouldn't
|
||||||
# be expected on non-debug builds.
|
# be expected on non-debug builds.
|
||||||
"jemalloc_prof"
|
"jemalloc_prof"
|
||||||
"jemalloc_stats"
|
"jemalloc_stats"
|
||||||
# tuwunel_mods is a development-only hot reload feature
|
# tuwunel_mods is a development-only hot reload feature
|
||||||
"tuwunel_mods"
|
"tuwunel_mods"
|
||||||
]
|
],
|
||||||
, disable_release_max_log_level ? false
|
disable_release_max_log_level ? false,
|
||||||
, features ? []
|
features ? [ ],
|
||||||
, profile ? "release"
|
profile ? "release",
|
||||||
# rocksdb compiled with -march=haswell and target-cpu=haswell rustflag
|
# rocksdb compiled with -march=haswell and target-cpu=haswell rustflag
|
||||||
# haswell is pretty much any x86 cpu made in the last 12 years, and
|
# haswell is pretty much any x86 cpu made in the last 12 years, and
|
||||||
# supports modern CPU extensions that rocksdb can make use of.
|
# supports modern CPU extensions that rocksdb can make use of.
|
||||||
# disable if trying to make a portable x86_64 build for very old hardware
|
# disable if trying to make a portable x86_64 build for very old hardware
|
||||||
, x86_64_haswell_target_optimised ? false
|
x86_64_haswell_target_optimised ? false,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
# We perform default-feature unification in nix, because some of the dependencies
|
# We perform default-feature unification in nix, because some of the dependencies
|
||||||
# on the nix side depend on feature values.
|
# on the nix side depend on feature values.
|
||||||
crateFeatures = path:
|
crateFeatures =
|
||||||
let manifest = lib.importTOML "${path}/Cargo.toml"; in
|
path:
|
||||||
lib.remove "default" (lib.attrNames manifest.features);
|
let
|
||||||
crateDefaultFeatures = path:
|
manifest = lib.importTOML "${path}/Cargo.toml";
|
||||||
(lib.importTOML "${path}/Cargo.toml").features.default;
|
in
|
||||||
allDefaultFeatures = crateDefaultFeatures "${inputs.self}/src/main";
|
lib.remove "default" (lib.attrNames manifest.features);
|
||||||
allFeatures = crateFeatures "${inputs.self}/src/main";
|
crateDefaultFeatures = path: (lib.importTOML "${path}/Cargo.toml").features.default;
|
||||||
features' = lib.unique
|
allDefaultFeatures = crateDefaultFeatures "${inputs.self}/src/main";
|
||||||
(features ++
|
allFeatures = crateFeatures "${inputs.self}/src/main";
|
||||||
lib.optionals default_features allDefaultFeatures ++
|
features' = lib.unique (
|
||||||
lib.optionals all_features allFeatures);
|
features
|
||||||
disable_features' = disable_features ++ lib.optionals disable_release_max_log_level ["release_max_log_level"];
|
++ lib.optionals default_features allDefaultFeatures
|
||||||
features'' = lib.subtractLists disable_features' features';
|
++ lib.optionals all_features allFeatures
|
||||||
|
);
|
||||||
|
disable_features' =
|
||||||
|
disable_features ++ lib.optionals disable_release_max_log_level [ "release_max_log_level" ];
|
||||||
|
features'' = lib.subtractLists disable_features' features';
|
||||||
|
|
||||||
featureEnabled = feature : builtins.elem feature features'';
|
featureEnabled = feature: builtins.elem feature features'';
|
||||||
|
|
||||||
enableLiburing = featureEnabled "io_uring" && !stdenv.hostPlatform.isDarwin;
|
enableLiburing = featureEnabled "io_uring" && !stdenv.hostPlatform.isDarwin;
|
||||||
|
|
||||||
# This derivation will set the JEMALLOC_OVERRIDE variable, causing the
|
# This derivation will set the JEMALLOC_OVERRIDE variable, causing the
|
||||||
# tikv-jemalloc-sys crate to use the nixpkgs jemalloc instead of building it's
|
# tikv-jemalloc-sys crate to use the nixpkgs jemalloc instead of building it's
|
||||||
# own. In order for this to work, we need to set flags on the build that match
|
# own. In order for this to work, we need to set flags on the build that match
|
||||||
# whatever flags tikv-jemalloc-sys was going to use. These are dependent on
|
# whatever flags tikv-jemalloc-sys was going to use. These are dependent on
|
||||||
# which features we enable in tikv-jemalloc-sys.
|
# which features we enable in tikv-jemalloc-sys.
|
||||||
rust-jemalloc-sys' =
|
rust-jemalloc-sys' =
|
||||||
# tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms feature
|
# tikv-jemalloc-sys/unprefixed_malloc_on_supported_platforms feature
|
||||||
rust-jemalloc-sys-unprefixed
|
rust-jemalloc-sys-unprefixed.overrideAttrs (old: {
|
||||||
.overrideAttrs (old: { configureFlags = old.configureFlags ++
|
configureFlags =
|
||||||
# we dont need docs
|
old.configureFlags
|
||||||
[ "--disable-doc" ] ++
|
++
|
||||||
# we dont need cxx/C++ integration
|
# we dont need docs
|
||||||
[ "--disable-cxx" ] ++
|
[ "--disable-doc" ]
|
||||||
# tikv-jemalloc-sys/profiling feature
|
++
|
||||||
lib.optional (featureEnabled "jemalloc_prof") "--enable-prof" ++
|
# we dont need cxx/C++ integration
|
||||||
# tikv-jemalloc-sys/stats feature
|
[ "--disable-cxx" ]
|
||||||
(if (featureEnabled "jemalloc_stats") then [ "--enable-stats" ] else [ "--disable-stats" ]);
|
++
|
||||||
});
|
# tikv-jemalloc-sys/profiling feature
|
||||||
|
lib.optional (featureEnabled "jemalloc_prof") "--enable-prof"
|
||||||
|
++
|
||||||
|
# tikv-jemalloc-sys/stats feature
|
||||||
|
(if (featureEnabled "jemalloc_stats") then [ "--enable-stats" ] else [ "--disable-stats" ]);
|
||||||
|
});
|
||||||
|
|
||||||
rocksdb' = (rocksdb.override {
|
rocksdb' =
|
||||||
jemalloc = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys';
|
(rocksdb.override {
|
||||||
# rocksdb fails to build with prefixed jemalloc, which is required on
|
jemalloc = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys';
|
||||||
# darwin due to [1]. In this case, fall back to building rocksdb with
|
# rocksdb fails to build with prefixed jemalloc, which is required on
|
||||||
# libc malloc. This should not cause conflicts, because all of the
|
# darwin due to [1]. In this case, fall back to building rocksdb with
|
||||||
# jemalloc symbols are prefixed.
|
# libc malloc. This should not cause conflicts, because all of the
|
||||||
#
|
# jemalloc symbols are prefixed.
|
||||||
# [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17
|
#
|
||||||
enableJemalloc = featureEnabled "jemalloc" && !stdenv.hostPlatform.isDarwin;
|
# [1]: https://github.com/tikv/jemallocator/blob/ab0676d77e81268cd09b059260c75b38dbef2d51/jemalloc-sys/src/env.rs#L17
|
||||||
|
enableJemalloc = featureEnabled "jemalloc" && !stdenv.hostPlatform.isDarwin;
|
||||||
|
|
||||||
# for some reason enableLiburing in nixpkgs rocksdb is default true
|
# for some reason enableLiburing in nixpkgs rocksdb is default true
|
||||||
# which breaks Darwin entirely
|
# which breaks Darwin entirely
|
||||||
enableLiburing = enableLiburing;
|
enableLiburing = enableLiburing;
|
||||||
}).overrideAttrs (old: {
|
}).overrideAttrs
|
||||||
enableLiburing = enableLiburing;
|
(old: {
|
||||||
cmakeFlags = (if x86_64_haswell_target_optimised then (lib.subtractLists [
|
enableLiburing = enableLiburing;
|
||||||
# dont make a portable build if x86_64_haswell_target_optimised is enabled
|
cmakeFlags =
|
||||||
"-DPORTABLE=1"
|
(
|
||||||
] old.cmakeFlags
|
if x86_64_haswell_target_optimised then
|
||||||
++ [ "-DPORTABLE=haswell" ]) else ([ "-DPORTABLE=1" ])
|
(
|
||||||
)
|
lib.subtractLists [
|
||||||
++ old.cmakeFlags;
|
# dont make a portable build if x86_64_haswell_target_optimised is enabled
|
||||||
|
"-DPORTABLE=1"
|
||||||
|
] old.cmakeFlags
|
||||||
|
++ [ "-DPORTABLE=haswell" ]
|
||||||
|
)
|
||||||
|
else
|
||||||
|
([ "-DPORTABLE=1" ])
|
||||||
|
)
|
||||||
|
++ old.cmakeFlags;
|
||||||
|
|
||||||
# outputs has "tools" which we dont need or use
|
# outputs has "tools" which we dont need or use
|
||||||
outputs = [ "out" ];
|
outputs = [ "out" ];
|
||||||
|
|
||||||
# preInstall hooks has stuff for messing with ldb/sst_dump which we dont need or use
|
# preInstall hooks has stuff for messing with ldb/sst_dump which we dont need or use
|
||||||
preInstall = "";
|
preInstall = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
buildDepsOnlyEnv = {
|
buildDepsOnlyEnv = {
|
||||||
# https://crane.dev/faq/rebuilds-bindgen.html
|
# https://crane.dev/faq/rebuilds-bindgen.html
|
||||||
NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa";
|
NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa";
|
||||||
|
|
||||||
CARGO_PROFILE = profile;
|
CARGO_PROFILE = profile;
|
||||||
ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
|
ROCKSDB_INCLUDE_DIR = "${rocksdb'}/include";
|
||||||
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
|
ROCKSDB_LIB_DIR = "${rocksdb'}/lib";
|
||||||
}
|
}
|
||||||
//
|
// (import ./cross-compilation-env.nix {
|
||||||
(import ./cross-compilation-env.nix {
|
|
||||||
# Keep sorted
|
# Keep sorted
|
||||||
inherit
|
inherit
|
||||||
lib
|
lib
|
||||||
pkgsBuildHost
|
pkgsBuildHost
|
||||||
rust
|
rust
|
||||||
stdenv;
|
stdenv
|
||||||
|
;
|
||||||
});
|
});
|
||||||
|
|
||||||
buildPackageEnv = {
|
buildPackageEnv = {
|
||||||
TUWUNEL_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
|
TUWUNEL_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
|
||||||
TUWUNEL_DATABASE_PATH = "/var/tmp/tuwunel.db";
|
TUWUNEL_DATABASE_PATH = "/var/tmp/tuwunel.db";
|
||||||
} // buildDepsOnlyEnv // {
|
}
|
||||||
# Only needed in static stdenv because these are transitive dependencies of rocksdb
|
// buildDepsOnlyEnv
|
||||||
CARGO_BUILD_RUSTFLAGS = buildDepsOnlyEnv.CARGO_BUILD_RUSTFLAGS
|
// {
|
||||||
+ lib.optionalString (enableLiburing && stdenv.hostPlatform.isStatic)
|
# Only needed in static stdenv because these are transitive dependencies of rocksdb
|
||||||
" -L${lib.getLib liburing}/lib -luring"
|
CARGO_BUILD_RUSTFLAGS =
|
||||||
+ lib.optionalString x86_64_haswell_target_optimised
|
buildDepsOnlyEnv.CARGO_BUILD_RUSTFLAGS
|
||||||
" -Ctarget-cpu=haswell";
|
+ lib.optionalString (
|
||||||
};
|
enableLiburing && stdenv.hostPlatform.isStatic
|
||||||
|
) " -L${lib.getLib liburing}/lib -luring"
|
||||||
|
+ lib.optionalString x86_64_haswell_target_optimised " -Ctarget-cpu=haswell";
|
||||||
|
};
|
||||||
|
|
||||||
|
commonAttrs = {
|
||||||
|
inherit
|
||||||
|
(craneLib.crateNameFromCargoToml {
|
||||||
|
cargoToml = "${inputs.self}/Cargo.toml";
|
||||||
|
})
|
||||||
|
pname
|
||||||
|
version
|
||||||
|
;
|
||||||
|
|
||||||
|
src =
|
||||||
|
let
|
||||||
|
filter = inputs.nix-filter.lib;
|
||||||
|
in
|
||||||
|
filter {
|
||||||
|
root = inputs.self;
|
||||||
|
|
||||||
commonAttrs = {
|
# Keep sorted
|
||||||
inherit
|
include = [
|
||||||
(craneLib.crateNameFromCargoToml {
|
".cargo"
|
||||||
cargoToml = "${inputs.self}/Cargo.toml";
|
"Cargo.lock"
|
||||||
})
|
"Cargo.toml"
|
||||||
pname
|
"src"
|
||||||
version;
|
];
|
||||||
|
};
|
||||||
src = let filter = inputs.nix-filter.lib; in filter {
|
|
||||||
root = inputs.self;
|
|
||||||
|
|
||||||
# Keep sorted
|
|
||||||
include = [
|
|
||||||
".cargo"
|
|
||||||
"Cargo.lock"
|
|
||||||
"Cargo.toml"
|
|
||||||
"src"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
cargoExtraArgs = "--no-default-features --locked "
|
cargoExtraArgs =
|
||||||
+ lib.optionalString
|
"--no-default-features --locked "
|
||||||
(features'' != [])
|
+ lib.optionalString (features'' != [ ]) "--features "
|
||||||
"--features " + (builtins.concatStringsSep "," features'');
|
+ (builtins.concatStringsSep "," features'');
|
||||||
|
|
||||||
dontStrip = profile == "dev" || profile == "test";
|
dontStrip = profile == "dev" || profile == "test";
|
||||||
dontPatchELF = profile == "dev" || profile == "test";
|
dontPatchELF = profile == "dev" || profile == "test";
|
||||||
|
|
||||||
buildInputs = lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys-unprefixed
|
buildInputs =
|
||||||
# needed to build Rust applications on macOS
|
lib.optional (featureEnabled "jemalloc") rust-jemalloc-sys-unprefixed
|
||||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
# needed to build Rust applications on macOS
|
||||||
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||||
# https://github.com/NixOS/nixpkgs/issues/206242
|
# https://github.com/NixOS/nixpkgs/issues/206242
|
||||||
# ld: library not found for -liconv
|
# ld: library not found for -liconv
|
||||||
libiconv
|
libiconv
|
||||||
@@ -188,56 +214,62 @@ commonAttrs = {
|
|||||||
# differing values for `NIX_CFLAGS_COMPILE`, which contributes to spurious
|
# differing values for `NIX_CFLAGS_COMPILE`, which contributes to spurious
|
||||||
# rebuilds of bindgen and its depedents.
|
# rebuilds of bindgen and its depedents.
|
||||||
jq
|
jq
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
craneLib.buildPackage ( commonAttrs // rec {
|
craneLib.buildPackage (
|
||||||
cargoArtifacts = craneLib.buildDepsOnly (commonAttrs // {
|
commonAttrs
|
||||||
env = buildDepsOnlyEnv;
|
// rec {
|
||||||
});
|
cargoArtifacts = craneLib.buildDepsOnly (
|
||||||
|
commonAttrs
|
||||||
|
// {
|
||||||
|
env = buildDepsOnlyEnv;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
# Adds runpath settings to the resulting binary
|
# Adds runpath settings to the resulting binary
|
||||||
buildInputs = (commonAttrs.buildInputs or []) ++ [
|
buildInputs = (commonAttrs.buildInputs or [ ]) ++ [
|
||||||
rocksdb'
|
rocksdb'
|
||||||
];
|
];
|
||||||
nativeBuildInputs = (commonAttrs.nativeBuildInputs or []) ++ [
|
nativeBuildInputs = (commonAttrs.nativeBuildInputs or [ ]) ++ [
|
||||||
autoPatchelfHook
|
autoPatchelfHook
|
||||||
];
|
];
|
||||||
# This is needed for tests to link
|
# This is needed for tests to link
|
||||||
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [
|
||||||
pkgsBuildHost.libredirect.hook
|
pkgsBuildHost.libredirect.hook
|
||||||
];
|
];
|
||||||
|
|
||||||
preCheck =
|
preCheck =
|
||||||
let
|
let
|
||||||
fakeResolvConf = pkgsBuildHost.writeTextFile {
|
fakeResolvConf = pkgsBuildHost.writeTextFile {
|
||||||
name = "resolv.conf";
|
name = "resolv.conf";
|
||||||
text = ''
|
text = ''
|
||||||
nameserver 0.0.0.0
|
nameserver 0.0.0.0
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
export NIX_REDIRECTS="/etc/resolv.conf=${fakeResolvConf}"
|
export NIX_REDIRECTS="/etc/resolv.conf=${fakeResolvConf}"
|
||||||
export TUWUNEL_DATABASE_PATH="$(mktemp -d)/smoketest.db"
|
export TUWUNEL_DATABASE_PATH="$(mktemp -d)/smoketest.db"
|
||||||
'';
|
'';
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
doBenchmark = false;
|
doBenchmark = false;
|
||||||
|
|
||||||
cargoExtraArgs = "--no-default-features --locked "
|
cargoExtraArgs =
|
||||||
+ lib.optionalString
|
"--no-default-features --locked "
|
||||||
(features'' != [])
|
+ lib.optionalString (features'' != [ ]) "--features "
|
||||||
"--features " + (builtins.concatStringsSep "," features'');
|
+ (builtins.concatStringsSep "," features'');
|
||||||
|
|
||||||
env = buildPackageEnv;
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
env = buildPackageEnv;
|
env = buildPackageEnv;
|
||||||
};
|
|
||||||
|
|
||||||
meta.mainProgram = commonAttrs.pname;
|
passthru = {
|
||||||
})
|
env = buildPackageEnv;
|
||||||
|
};
|
||||||
|
|
||||||
|
meta.mainProgram = commonAttrs.pname;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
{ inputs
|
{
|
||||||
|
inputs,
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
, dockerTools
|
dockerTools,
|
||||||
, lib
|
lib,
|
||||||
, main
|
main,
|
||||||
, stdenv
|
stdenv,
|
||||||
, tini
|
tini,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
dockerTools.buildLayeredImage {
|
dockerTools.buildLayeredImage {
|
||||||
@@ -17,11 +18,18 @@ dockerTools.buildLayeredImage {
|
|||||||
main
|
main
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
Entrypoint = if !stdenv.hostPlatform.isDarwin
|
Entrypoint =
|
||||||
|
if
|
||||||
|
!stdenv.hostPlatform.isDarwin
|
||||||
# Use the `tini` init system so that signals (e.g. ctrl+c/SIGINT)
|
# Use the `tini` init system so that signals (e.g. ctrl+c/SIGINT)
|
||||||
# are handled as expected
|
# are handled as expected
|
||||||
then [ "${lib.getExe' tini "tini"}" "--" ]
|
then
|
||||||
else [];
|
[
|
||||||
|
"${lib.getExe' tini "tini"}"
|
||||||
|
"--"
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[ ];
|
||||||
Cmd = [
|
Cmd = [
|
||||||
"${lib.getExe main}"
|
"${lib.getExe main}"
|
||||||
];
|
];
|
||||||
@@ -29,9 +37,10 @@ dockerTools.buildLayeredImage {
|
|||||||
"RUST_BACKTRACE=full"
|
"RUST_BACKTRACE=full"
|
||||||
];
|
];
|
||||||
Labels = {
|
Labels = {
|
||||||
"org.opencontainers.image.authors" = "June Clementine Strawberry <june@girlboss.ceo> and Jason Volk
|
"org.opencontainers.image.authors" =
|
||||||
|
"June Clementine Strawberry <june@girlboss.ceo> and Jason Volk
|
||||||
<jason@zemos.net>";
|
<jason@zemos.net>";
|
||||||
"org.opencontainers.image.created" ="@${toString inputs.self.lastModified}";
|
"org.opencontainers.image.created" = "@${toString inputs.self.lastModified}";
|
||||||
"org.opencontainers.image.description" = "a very cool Matrix chat homeserver written in Rust";
|
"org.opencontainers.image.description" = "a very cool Matrix chat homeserver written in Rust";
|
||||||
"org.opencontainers.image.documentation" = "https://conduwuit.puppyirl.gay/";
|
"org.opencontainers.image.documentation" = "https://conduwuit.puppyirl.gay/";
|
||||||
"org.opencontainers.image.licenses" = "Apache-2.0";
|
"org.opencontainers.image.licenses" = "Apache-2.0";
|
||||||
|
|||||||
Reference in New Issue
Block a user