2022-10-15 22:02:13 +02:00
|
|
|
{
|
2023-04-05 01:56:51 +02:00
|
|
|
inputs = {
|
2024-04-22 02:15:02 +02:00
|
|
|
attic.url = "github:zhaofengli/attic?ref=main";
|
2024-06-16 03:24:25 +02:00
|
|
|
cachix.url = "github:cachix/cachix?ref=master";
|
2024-05-02 05:36:07 +02:00
|
|
|
complement = { url = "github:matrix-org/complement?ref=main"; flake = false; };
|
2024-09-08 05:03:30 +02:00
|
|
|
crane = { url = "github:ipetkov/crane?ref=master"; };
|
2024-05-02 05:36:07 +02:00
|
|
|
fenix = { url = "github:nix-community/fenix?ref=main"; inputs.nixpkgs.follows = "nixpkgs"; };
|
|
|
|
flake-compat = { url = "github:edolstra/flake-compat?ref=master"; flake = false; };
|
|
|
|
flake-utils.url = "github:numtide/flake-utils?ref=main";
|
|
|
|
nix-filter.url = "github:numtide/nix-filter?ref=main";
|
2024-09-08 05:03:30 +02:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixpkgs-unstable";
|
2024-09-08 19:21:23 +02:00
|
|
|
rocksdb = { url = "github:girlbossceo/rocksdb?ref=v9.6.1"; flake = false; };
|
2024-05-06 20:59:59 +02:00
|
|
|
liburing = { url = "github:axboe/liburing?ref=master"; flake = false; };
|
2023-04-05 01:56:51 +02:00
|
|
|
};
|
|
|
|
|
2024-04-22 00:33:54 +02:00
|
|
|
outputs = inputs:
|
|
|
|
inputs.flake-utils.lib.eachDefaultSystem (system:
|
2023-04-05 01:56:51 +02:00
|
|
|
let
|
2024-08-22 04:08:24 +02:00
|
|
|
pkgsHost = import inputs.nixpkgs{
|
|
|
|
inherit system;
|
|
|
|
config.permittedInsecurePackages = [ "olm-3.2.16" ];
|
|
|
|
};
|
2024-05-24 00:50:41 +02:00
|
|
|
pkgsHostStatic = pkgsHost.pkgsStatic;
|
2023-04-05 04:11:34 +02:00
|
|
|
|
2023-04-05 01:56:51 +02:00
|
|
|
# The Rust toolchain to use
|
2024-04-22 00:33:54 +02:00
|
|
|
toolchain = inputs.fenix.packages.${system}.fromToolchainFile {
|
2024-01-26 05:39:59 +01:00
|
|
|
file = ./rust-toolchain.toml;
|
2023-04-05 01:56:51 +02:00
|
|
|
|
2024-01-26 05:39:59 +01:00
|
|
|
# See also `rust-toolchain.toml`
|
2024-09-07 03:08:21 +02:00
|
|
|
sha256 = "sha256-VZZnlyP69+Y3crrLHQyJirqlHrTtGTsyiSnZB8jEvVo=";
|
2023-04-05 01:56:51 +02:00
|
|
|
};
|
|
|
|
|
2024-05-24 00:46:48 +02:00
|
|
|
mkScope = pkgs: pkgs.lib.makeScope pkgs.newScope (self: {
|
|
|
|
inherit pkgs;
|
2024-04-22 00:28:35 +02:00
|
|
|
book = self.callPackage ./nix/pkgs/book {};
|
|
|
|
complement = self.callPackage ./nix/pkgs/complement {};
|
2024-08-30 10:35:05 +02:00
|
|
|
craneLib = ((inputs.crane.mkLib pkgs).overrideToolchain (_: toolchain));
|
2024-04-22 00:28:35 +02:00
|
|
|
inherit inputs;
|
|
|
|
main = self.callPackage ./nix/pkgs/main {};
|
|
|
|
oci-image = self.callPackage ./nix/pkgs/oci-image {};
|
2024-09-08 05:03:30 +02:00
|
|
|
liburing = pkgs.liburing.overrideAttrs {
|
|
|
|
# Tests weren't building
|
|
|
|
outputs = [ "out" "dev" "man" ];
|
|
|
|
buildFlags = [ "library"];
|
|
|
|
src = inputs.liburing;
|
|
|
|
};
|
|
|
|
rocksdb = (pkgs.rocksdb.override {
|
|
|
|
liburing = self.liburing;
|
|
|
|
}).overrideAttrs (old: {
|
2024-04-22 00:28:35 +02:00
|
|
|
src = inputs.rocksdb;
|
|
|
|
version = pkgs.lib.removePrefix
|
|
|
|
"v"
|
|
|
|
(builtins.fromJSON (builtins.readFile ./flake.lock))
|
|
|
|
.nodes.rocksdb.original.ref;
|
2024-07-08 23:07:31 +02:00
|
|
|
# we have this already at https://github.com/girlbossceo/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
|
|
|
# unsetting this so i don't have to revert it and make this nix exclusive
|
|
|
|
patches = [];
|
2024-07-09 01:51:05 +02:00
|
|
|
cmakeFlags = pkgs.lib.subtractLists
|
2024-07-14 05:23:40 +02:00
|
|
|
[
|
|
|
|
# no real reason to have snappy, no one uses this
|
|
|
|
"-DWITH_SNAPPY=1"
|
|
|
|
# we dont need to use ldb or sst_dump (core_tools)
|
|
|
|
"-DWITH_CORE_TOOLS=1"
|
2024-07-14 06:11:37 +02:00
|
|
|
# we dont need to build rocksdb tests
|
|
|
|
"-DWITH_TESTS=1"
|
2024-07-14 06:38:29 +02:00
|
|
|
# we use rust-rocksdb via C interface and dont need C++ RTTI
|
|
|
|
"-DUSE_RTTI=1"
|
2024-07-14 05:23:40 +02:00
|
|
|
]
|
|
|
|
old.cmakeFlags
|
2024-07-14 06:11:37 +02:00
|
|
|
++ [
|
|
|
|
# we dont need to use ldb or sst_dump (core_tools)
|
|
|
|
"-DWITH_CORE_TOOLS=0"
|
|
|
|
# we dont need trace tools
|
|
|
|
"-DWITH_TRACE_TOOLS=0"
|
|
|
|
# we dont need to build rocksdb tests
|
|
|
|
"-DWITH_TESTS=0"
|
2024-07-14 06:38:29 +02:00
|
|
|
# we use rust-rocksdb via C interface and dont need C++ RTTI
|
|
|
|
"-DUSE_RTTI=0"
|
2024-07-14 06:11:37 +02:00
|
|
|
];
|
2024-07-14 05:23:40 +02:00
|
|
|
|
|
|
|
# outputs has "tools" which we dont need or use
|
|
|
|
outputs = [ "out" ];
|
|
|
|
|
|
|
|
# preInstall hooks has stuff for messing with ldb/sst_dump which we dont need or use
|
|
|
|
preInstall = "";
|
2024-04-22 00:28:35 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-05-24 00:46:48 +02:00
|
|
|
scopeHost = mkScope pkgsHost;
|
2024-05-24 00:50:41 +02:00
|
|
|
scopeHostStatic = mkScope pkgsHostStatic;
|
2024-05-24 00:46:48 +02:00
|
|
|
|
|
|
|
mkDevShell = scope: scope.pkgs.mkShell {
|
|
|
|
env = scope.main.env // {
|
|
|
|
# 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.
|
|
|
|
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
|
|
|
|
|
|
|
|
# Convenient way to access a pinned version of Complement's source
|
|
|
|
# code.
|
|
|
|
COMPLEMENT_SRC = inputs.complement.outPath;
|
2024-05-24 08:48:28 +02:00
|
|
|
|
|
|
|
# Needed for Complement
|
|
|
|
CGO_CFLAGS = "-I${scope.pkgs.olm}/include";
|
|
|
|
CGO_LDFLAGS = "-L${scope.pkgs.olm}/lib";
|
2024-05-24 00:46:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Development tools
|
|
|
|
packages = [
|
|
|
|
# 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.
|
|
|
|
inputs.fenix.packages.${system}.latest.rustfmt
|
|
|
|
|
|
|
|
toolchain
|
|
|
|
]
|
|
|
|
++ (with pkgsHost.pkgs; [
|
|
|
|
engage
|
|
|
|
cargo-audit
|
2024-09-08 17:40:02 +02:00
|
|
|
liburing
|
2024-05-24 00:46:48 +02:00
|
|
|
|
2024-09-08 19:21:23 +02:00
|
|
|
# Required by hardened-malloc.rs dep
|
|
|
|
binutils
|
|
|
|
|
2024-05-24 00:46:48 +02:00
|
|
|
# Needed for producing Debian packages
|
|
|
|
cargo-deb
|
|
|
|
|
2024-07-25 01:34:19 +02:00
|
|
|
# Needed for CI to check validity of produced Debian packages (dpkg-deb)
|
|
|
|
dpkg
|
|
|
|
|
2024-05-24 00:46:48 +02:00
|
|
|
# Needed for Complement
|
|
|
|
go
|
|
|
|
|
|
|
|
# Needed for our script for Complement
|
|
|
|
jq
|
|
|
|
|
|
|
|
# Needed for finding broken markdown links
|
|
|
|
lychee
|
|
|
|
|
2024-07-03 09:32:18 +02:00
|
|
|
# Needed for linting markdown files
|
|
|
|
markdownlint-cli
|
|
|
|
|
2024-05-24 00:46:48 +02:00
|
|
|
# Useful for editing the book locally
|
|
|
|
mdbook
|
2024-07-25 04:22:45 +02:00
|
|
|
|
2024-07-30 01:11:02 +02:00
|
|
|
# used for rust caching in CI to speed it up
|
2024-07-25 04:22:45 +02:00
|
|
|
sccache
|
2024-07-30 01:11:02 +02:00
|
|
|
|
|
|
|
# needed so we can get rid of gcc and other unused deps that bloat OCI images
|
|
|
|
removeReferencesTo
|
2024-05-24 00:46:48 +02:00
|
|
|
])
|
2024-05-25 02:04:34 +02:00
|
|
|
++ scope.main.buildInputs
|
2024-05-24 00:46:48 +02:00
|
|
|
++ scope.main.propagatedBuildInputs
|
|
|
|
++ scope.main.nativeBuildInputs;
|
2024-05-24 05:40:29 +02:00
|
|
|
|
|
|
|
meta.broken = scope.main.meta.broken;
|
2024-05-24 00:46:48 +02:00
|
|
|
};
|
2024-01-26 05:39:59 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages = {
|
2024-05-26 23:52:55 +02:00
|
|
|
default = scopeHost.main;
|
2024-07-25 01:17:37 +02:00
|
|
|
default-debug = scopeHost.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
};
|
2024-07-26 00:06:45 +02:00
|
|
|
default-test = scopeHost.main.override {
|
|
|
|
profile = "test";
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
};
|
2024-07-07 19:38:38 +02:00
|
|
|
all-features = scopeHost.main.override {
|
|
|
|
all_features = true;
|
2024-07-13 22:09:24 +02:00
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
2024-07-07 19:38:38 +02:00
|
|
|
};
|
2024-07-25 01:17:37 +02:00
|
|
|
all-features-debug = scopeHost.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
all_features = true;
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
|
|
|
};
|
2024-04-22 00:28:35 +02:00
|
|
|
hmalloc = scopeHost.main.override { features = ["hardened_malloc"]; };
|
|
|
|
|
|
|
|
oci-image = scopeHost.oci-image;
|
2024-07-07 08:47:07 +02:00
|
|
|
oci-image-all-features = scopeHost.oci-image.override {
|
|
|
|
main = scopeHost.main.override {
|
|
|
|
all_features = true;
|
2024-07-13 22:09:24 +02:00
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
2024-07-07 08:47:07 +02:00
|
|
|
};
|
|
|
|
};
|
2024-07-25 01:17:37 +02:00
|
|
|
oci-image-all-features-debug = scopeHost.oci-image.override {
|
|
|
|
main = scopeHost.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
all_features = true;
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-04-22 00:28:35 +02:00
|
|
|
oci-image-hmalloc = scopeHost.oci-image.override {
|
|
|
|
main = scopeHost.main.override {
|
|
|
|
features = ["hardened_malloc"];
|
|
|
|
};
|
|
|
|
};
|
2024-03-17 23:06:10 +01:00
|
|
|
|
2024-04-22 00:28:35 +02:00
|
|
|
book = scopeHost.book;
|
2024-03-17 23:06:10 +01:00
|
|
|
|
2024-04-22 00:28:35 +02:00
|
|
|
complement = scopeHost.complement;
|
2024-05-24 05:53:13 +02:00
|
|
|
static-complement = scopeHostStatic.complement;
|
2024-01-30 00:48:30 +01:00
|
|
|
}
|
|
|
|
//
|
|
|
|
builtins.listToAttrs
|
|
|
|
(builtins.concatLists
|
|
|
|
(builtins.map
|
|
|
|
(crossSystem:
|
|
|
|
let
|
|
|
|
binaryName = "static-${crossSystem}";
|
|
|
|
pkgsCrossStatic =
|
2024-04-22 00:33:54 +02:00
|
|
|
(import inputs.nixpkgs {
|
2024-01-30 00:48:30 +01:00
|
|
|
inherit system;
|
|
|
|
crossSystem = {
|
|
|
|
config = crossSystem;
|
|
|
|
};
|
|
|
|
}).pkgsStatic;
|
2024-05-24 00:46:48 +02:00
|
|
|
scopeCrossStatic = mkScope pkgsCrossStatic;
|
2024-01-30 00:48:30 +01:00
|
|
|
in
|
|
|
|
[
|
|
|
|
# An output for a statically-linked binary
|
|
|
|
{
|
|
|
|
name = binaryName;
|
2024-04-22 00:28:35 +02:00
|
|
|
value = scopeCrossStatic.main;
|
2024-01-30 00:48:30 +01:00
|
|
|
}
|
|
|
|
|
2024-07-25 01:17:37 +02:00
|
|
|
# An output for a statically-linked unstripped debug ("dev") binary
|
|
|
|
{
|
|
|
|
name = "${binaryName}-debug";
|
|
|
|
value = scopeCrossStatic.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-26 00:06:45 +02:00
|
|
|
# An output for a statically-linked unstripped debug binary with the
|
|
|
|
# "test" profile (for CI usage only)
|
|
|
|
{
|
|
|
|
name = "${binaryName}-test";
|
|
|
|
value = scopeCrossStatic.main.override {
|
|
|
|
profile = "test";
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-07 08:47:07 +02:00
|
|
|
# An output for a statically-linked binary with `--all-features`
|
|
|
|
{
|
|
|
|
name = "${binaryName}-all-features";
|
|
|
|
value = scopeCrossStatic.main.override {
|
|
|
|
all_features = true;
|
2024-07-13 22:09:24 +02:00
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
2024-07-07 08:47:07 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-25 01:17:37 +02:00
|
|
|
# An output for a statically-linked unstripped debug ("dev") binary with `--all-features`
|
|
|
|
{
|
|
|
|
name = "${binaryName}-all-features-debug";
|
|
|
|
value = scopeCrossStatic.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
all_features = true;
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-04-11 02:31:00 +02:00
|
|
|
# An output for a statically-linked binary with hardened_malloc
|
|
|
|
{
|
|
|
|
name = "${binaryName}-hmalloc";
|
2024-04-22 00:28:35 +02:00
|
|
|
value = scopeCrossStatic.main.override {
|
|
|
|
features = ["hardened_malloc"];
|
|
|
|
};
|
2024-04-11 02:31:00 +02:00
|
|
|
}
|
|
|
|
|
2024-01-30 00:48:30 +01:00
|
|
|
# An output for an OCI image based on that binary
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}";
|
2024-04-22 00:28:35 +02:00
|
|
|
value = scopeCrossStatic.oci-image;
|
2024-01-30 00:48:30 +01:00
|
|
|
}
|
2024-04-11 02:31:00 +02:00
|
|
|
|
2024-07-25 01:17:37 +02:00
|
|
|
# An output for an OCI image based on that unstripped debug ("dev") binary
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}-debug";
|
|
|
|
value = scopeCrossStatic.oci-image.override {
|
|
|
|
main = scopeCrossStatic.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-07 08:47:07 +02:00
|
|
|
# An output for an OCI image based on that binary with `--all-features`
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}-all-features";
|
|
|
|
value = scopeCrossStatic.oci-image.override {
|
|
|
|
main = scopeCrossStatic.main.override {
|
|
|
|
all_features = true;
|
2024-07-13 22:09:24 +02:00
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
2024-07-07 08:47:07 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-07-25 01:17:37 +02:00
|
|
|
# An output for an OCI image based on that unstripped debug ("dev") binary with `--all-features`
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}-all-features-debug";
|
|
|
|
value = scopeCrossStatic.oci-image.override {
|
|
|
|
main = scopeCrossStatic.main.override {
|
|
|
|
profile = "dev";
|
|
|
|
all_features = true;
|
|
|
|
# debug build users expect full logs
|
|
|
|
disable_release_max_log_level = true;
|
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-04-11 02:31:00 +02:00
|
|
|
# An output for an OCI image based on that binary with hardened_malloc
|
|
|
|
{
|
|
|
|
name = "oci-image-${crossSystem}-hmalloc";
|
2024-04-22 00:28:35 +02:00
|
|
|
value = scopeCrossStatic.oci-image.override {
|
|
|
|
main = scopeCrossStatic.main.override {
|
|
|
|
features = ["hardened_malloc"];
|
|
|
|
};
|
|
|
|
};
|
2024-04-11 02:31:00 +02:00
|
|
|
}
|
2024-01-30 00:48:30 +01:00
|
|
|
]
|
|
|
|
)
|
|
|
|
[
|
|
|
|
"x86_64-unknown-linux-musl"
|
|
|
|
"aarch64-unknown-linux-musl"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
2024-01-26 05:39:59 +01:00
|
|
|
|
2024-05-24 00:50:41 +02:00
|
|
|
devShells.default = mkDevShell scopeHostStatic;
|
2024-05-24 01:18:50 +02:00
|
|
|
devShells.all-features = mkDevShell
|
|
|
|
(scopeHostStatic.overrideScope (final: prev: {
|
2024-07-07 19:38:38 +02:00
|
|
|
main = prev.main.override {
|
|
|
|
all_features = true;
|
2024-07-13 22:09:24 +02:00
|
|
|
disable_features = [
|
|
|
|
# this is non-functional on nix for some reason
|
|
|
|
"hardened_malloc"
|
|
|
|
# dont include experimental features
|
|
|
|
"experimental"
|
|
|
|
];
|
2024-07-07 19:38:38 +02:00
|
|
|
};
|
2024-05-24 01:18:50 +02:00
|
|
|
}));
|
2024-05-24 01:31:06 +02:00
|
|
|
devShells.no-features = mkDevShell
|
|
|
|
(scopeHostStatic.overrideScope (final: prev: {
|
|
|
|
main = prev.main.override { default_features = false; };
|
|
|
|
}));
|
2024-05-24 05:41:23 +02:00
|
|
|
devShells.dynamic = mkDevShell scopeHost;
|
2023-04-05 01:56:51 +02:00
|
|
|
});
|
2022-10-15 22:02:13 +02:00
|
|
|
}
|