format flake, use rust-rocksdb fork

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-09 15:45:27 -05:00 committed by June
parent 4d4c2cf5f8
commit cd2f00e012

125
flake.nix
View file

@ -37,13 +37,19 @@
let let
pkgsHost = nixpkgs.legacyPackages.${system}; pkgsHost = nixpkgs.legacyPackages.${system};
rocksdb' = pkgs: pkgs.rocksdb.overrideAttrs (old: rocksdb' = pkgs:
{ let
version = "8.10.0"; version = "8.11.3";
src = old.src.override { in
hash = "sha256-KGsYDBc1fz/90YYNGwlZ0LUKXYsP1zyhP29TnRQwgjQ="; pkgs.rocksdb.overrideAttrs (old: {
}; inherit version;
}); src = pkgs.fetchFromGitHub {
owner = "facebook";
repo = "rocksdb";
rev = "v${version}";
hash = "sha256-KGsYDBc1fz/90YYNGwlZ0LUKXYsP1zyhP29TnRQwgjQ=";
};
});
# Nix-accessible `Cargo.toml` # Nix-accessible `Cargo.toml`
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
@ -75,38 +81,38 @@
} }
// { // {
CARGO_BUILD_RUSTFLAGS = let inherit (pkgs) lib stdenv; in CARGO_BUILD_RUSTFLAGS = let inherit (pkgs) lib stdenv; in
lib.concatStringsSep " " ([] lib.concatStringsSep " " ([ ]
++ lib.optionals ++ lib.optionals
# This disables PIE for static builds, which isn't great in terms # This disables PIE for static builds, which isn't great in terms
# of security. Unfortunately, my hand is forced because nixpkgs' # of security. Unfortunately, my hand is forced because nixpkgs'
# `libstdc++.a` is built without `-fPIE`, which precludes us from # `libstdc++.a` is built without `-fPIE`, which precludes us from
# leaving PIE enabled. # leaving PIE enabled.
stdenv.hostPlatform.isStatic stdenv.hostPlatform.isStatic
["-C" "relocation-model=static"] [ "-C" "relocation-model=static" ]
++ lib.optionals ++ lib.optionals
(stdenv.buildPlatform.config != stdenv.hostPlatform.config) (stdenv.buildPlatform.config != stdenv.hostPlatform.config)
["-l" "c"] [ "-l" "c" ]
++ lib.optionals ++ lib.optionals
# This check has to match the one [here][0]. We only need to set # 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, # 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. # 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 # [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 # Nixpkgs doesn't check for x86_64 here but we do, because I
# observed a failure building statically for x86_64 without # observed a failure building statically for x86_64 without
# including it here. Linkers are weird. # including it here. Linkers are weird.
(stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64) (stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isx86_64)
&& stdenv.hostPlatform.isStatic && stdenv.hostPlatform.isStatic
&& !stdenv.isDarwin && !stdenv.isDarwin
&& !stdenv.cc.bintools.isLLVM && !stdenv.cc.bintools.isLLVM
) )
[ [
"-l" "-l"
"stdc++" "stdc++"
"-L" "-L"
"${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib" "${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib"
] ]
); );
} }
@ -134,29 +140,30 @@
envVars.linkerForTarget; envVars.linkerForTarget;
} }
) )
// ( // (
let let
inherit (pkgs.stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget; inherit (pkgs.stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget;
in in
{ {
"CC_${cargoEnvVarTarget}" = envVars.ccForHost; "CC_${cargoEnvVarTarget}" = envVars.ccForHost;
"CXX_${cargoEnvVarTarget}" = envVars.cxxForHost; "CXX_${cargoEnvVarTarget}" = envVars.cxxForHost;
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForHost; "CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForHost;
CARGO_BUILD_TARGET = rustcTarget; CARGO_BUILD_TARGET = rustcTarget;
} }
) )
// ( // (
let let
inherit (pkgs.stdenv.buildPlatform.rust) cargoEnvVarTarget; inherit (pkgs.stdenv.buildPlatform.rust) cargoEnvVarTarget;
in in
{ {
"CC_${cargoEnvVarTarget}" = envVars.ccForBuild; "CC_${cargoEnvVarTarget}" = envVars.ccForBuild;
"CXX_${cargoEnvVarTarget}" = envVars.cxxForBuild; "CXX_${cargoEnvVarTarget}" = envVars.cxxForBuild;
"CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForBuild; "CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.linkerForBuild;
HOST_CC = "${pkgs.pkgsBuildHost.stdenv.cc}/bin/cc"; HOST_CC = "${pkgs.pkgsBuildHost.stdenv.cc}/bin/cc";
HOST_CXX = "${pkgs.pkgsBuildHost.stdenv.cc}/bin/c++"; HOST_CXX = "${pkgs.pkgsBuildHost.stdenv.cc}/bin/c++";
} }
)); )
);
package = pkgs: builder pkgs { package = pkgs: builder pkgs {
src = nix-filter { src = nix-filter {