diff --git a/default.nix b/default.nix index f620865d..1d976a35 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +1,11 @@ -(import - ( - let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in - fetchTarball { - url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; - } - ) - { src = ./.; } -).defaultNix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = + lock.nodes.flake-compat.locked.url + or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).defaultNix diff --git a/flake.lock b/flake.lock index 51a04c6c..be0bf3de 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1751403276, - "narHash": "sha256-V0EPQNsQko1a8OqIWc2lLviLnMpR1m08Ej00z5RVTfs=", + "lastModified": 1748532342, + "narHash": "sha256-CvaKOUq8G10sghKpZhEB2UYjJoWhEkrDFggDgi7piUI=", "owner": "zhaofengli", "repo": "attic", - "rev": "896ad88fa57ad5dbcd267c0ac51f1b71ccfcb4dd", + "rev": "ce9373715fe3fac7a174a65a7e6d6baeba8cb4f9", "type": "github" }, "original": { @@ -147,17 +147,15 @@ }, "fenix": { "inputs": { - "nixpkgs": [ - "nixpkgs" - ], + "nixpkgs": "nixpkgs_5", "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1751525020, - "narHash": "sha256-oDO6lCYS5Bf4jUITChj9XV7k3TP38DE0Ckz5n5ORCME=", + "lastModified": 1751352216, + "narHash": "sha256-dJj8TUoZGj55Ttro37vvFGF2L+xlYNfspQ9u4BfqTFw=", "owner": "nix-community", "repo": "fenix", - "rev": "a1a5f92f47787e7df9f30e5e5ac13e679215aa1e", + "rev": "61b4f1e21bd631da91981f1ed74c959d6993f554", "type": "github" }, "original": { @@ -499,11 +497,27 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1751498133, - "narHash": "sha256-QWJ+NQbMU+NcU2xiyo7SNox1fAuwksGlQhpzBl76g1I=", + "lastModified": 1751271578, + "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1751285371, + "narHash": "sha256-/hDU+2AUeFFu5qGHO/UyFMc4UG/x5Cw5uXO36KGTk6c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d55716bb59b91ae9d1ced4b1ccdea7a442ecbfdb", + "rev": "b9c03fbbaf84d85bb28eee530c7e9edc4021ca1b", "type": "github" }, "original": { @@ -539,18 +553,18 @@ "flake-compat": "flake-compat_3", "flake-utils": "flake-utils", "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_6", "rocksdb": "rocksdb" } }, "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1751433876, - "narHash": "sha256-IsdwOcvLLDDlkFNwhdD5BZy20okIQL01+UQ7Kxbqh8s=", + "lastModified": 1751296293, + "narHash": "sha256-oaGMVdCcI32y6jQ7RE0+CqshZngfI19XnY31eYjdinI=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "11d45c881389dae90b0da5a94cde52c79d0fc7ef", + "rev": "eaf37e2c98b66ff7f7a0ac04e4cada39e51fde4b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 564cd479..bc46f953 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,6 @@ }; fenix = { url = "github:nix-community/fenix?ref=main"; - inputs.nixpkgs.follows = "nixpkgs"; }; flake-compat = { url = "github:edolstra/flake-compat?ref=master"; @@ -31,7 +30,6 @@ inherit system; }; - # The Rust toolchain to use toolchain = inputs.fenix.packages.${system}.fromToolchainFile { file = ./rust-toolchain.toml; @@ -54,67 +52,66 @@ ]; buildFlags = [ "library" ]; }; - rocksdb = - (pkgs.rocksdb_9_10.override { - # Override the liburing input for the build with our own so - # we have it built with the library flag - inherit (self) liburing; - }).overrideAttrs - (old: { - src = inputs.rocksdb; - version = "v9.11.1"; - cmakeFlags = - pkgs.lib.subtractLists [ - # No real reason to have snappy or zlib, no one uses this - "-DWITH_SNAPPY=1" - "-DZLIB=1" - "-DWITH_ZLIB=1" - # We don't need to use ldb or sst_dump (core_tools) - "-DWITH_CORE_TOOLS=1" - # We don't need to build rocksdb tests - "-DWITH_TESTS=1" - # We use rust-rocksdb via C interface and don't need C++ RTTI - "-DUSE_RTTI=1" - # This doesn't exist in RocksDB, and USE_SSE is deprecated for - # PORTABLE=$(march) - "-DFORCE_SSE42=1" - # PORTABLE will get set in main/default.nix - "-DPORTABLE=1" - ] old.cmakeFlags - ++ [ - # No real reason to have snappy, no one uses this - "-DWITH_SNAPPY=0" - "-DZLIB=0" - "-DWITH_ZLIB=0" - # We don't need to use ldb or sst_dump (core_tools) - "-DWITH_CORE_TOOLS=0" - # We don't need trace tools - "-DWITH_TRACE_TOOLS=0" - # We don't need to build rocksdb tests - "-DWITH_TESTS=0" - # We use rust-rocksdb via C interface and don't need C++ RTTI - "-DUSE_RTTI=0" - ]; + rocksdb-custom = pkgs.rocksdb_9_10.overrideAttrs (oldAttrs: { + version = "v9.11.1"; + src = inputs.rocksdb; - # outputs has "tools" which we don't need or use - outputs = [ "out" ]; + cmakeFlags = + pkgs.lib.subtractLists [ + # No real reason to have snappy or zlib, no one uses this + "-DWITH_SNAPPY=1" + "-DZLIB=1" + "-DWITH_ZLIB=1" + # We don't need to use ldb or sst_dump (core_tools) + "-DWITH_CORE_TOOLS=1" + # We don't need to build rocksdb tests + "-DWITH_TESTS=1" + # We use rust-rocksdb via C interface and don't need C++ RTTI + "-DUSE_RTTI=1" + # This doesn't exist in RocksDB, and USE_SSE is deprecated for + # PORTABLE=$(march) + "-DFORCE_SSE42=1" + # PORTABLE will get set in main/default.nix + "-DPORTABLE=1" + ] oldAttrs.cmakeFlags + ++ [ + # No real reason to have snappy, no one uses this + "-DWITH_SNAPPY=0" + "-DZLIB=0" + "-DWITH_ZLIB=0" + # We don't need to use ldb or sst_dump (core_tools) + "-DWITH_CORE_TOOLS=0" + # We don't need trace tools + "-DWITH_TRACE_TOOLS=0" + # We don't need to build rocksdb tests + "-DWITH_TESTS=0" + # We use rust-rocksdb via C interface and don't need C++ RTTI + "-DUSE_RTTI=0" + ]; - # preInstall hooks has stuff for messing with ldb/sst_dump which we don't need or use - preInstall = ""; + propagatedBuildInputs = with pkgs; [ + bzip2 + lz4 + zstd + ]; - # We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155 - # Unsetting this so we don't have to revert it and make this nix exclusive - patches = [ ]; + # Has "tools" which we don't need or use + outputs = [ "out" ]; - postPatch = '' - # Fix gcc-13 build failures due to missing and - # includes, fixed upstream since 8.x - sed -e '1i #include ' -i db/compaction/compaction_iteration_stats.h - sed -e '1i #include ' -i table/block_based/data_block_hash_index.h - sed -e '1i #include ' -i util/string_util.h - sed -e '1i #include ' -i include/rocksdb/utilities/checkpoint.h - ''; - }); + # preInstall hooks has stuff for messing with ldb/sst_dump which we don't need or use + preInstall = ""; + + # We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155 + patches = [ ]; + postPatch = '' + # Fix gcc-13 build failures due to missing and + # includes, fixed upstream since 8.x + sed -e '1i #include ' -i db/compaction/compaction_iteration_stats.h + sed -e '1i #include ' -i table/block_based/data_block_hash_index.h + sed -e '1i #include ' -i util/string_util.h + sed -e '1i #include ' -i include/rocksdb/utilities/checkpoint.h + ''; + }); }); scopeHost = mkScope pkgsHost; @@ -130,20 +127,19 @@ }).pkgsStatic; in mkScope pkgsCrossStatic; - in { packages = { default = scopeHost.main.override { disable_features = [ - # Don't include experimental features + # dont include experimental features "experimental" # jemalloc profiling/stats features are expensive and shouldn't # be expected on non-debug builds. "jemalloc_prof" "jemalloc_stats" - # This is non-functional on nix for some reason + # this is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -151,23 +147,10 @@ }; default-debug = scopeHost.main.override { profile = "dev"; - # Debug build users expect full logs + # debug build users expect full logs disable_release_max_log_level = true; disable_features = [ - # Don't include experimental features - "experimental" - # This is non-functional on nix for some reason - "hardened_malloc" - # conduwuit_mods is a development-only hot reload feature - "conduwuit_mods" - ]; - }; - # Just a test profile used for things like CI and complement - default-test = scopeHost.main.override { - profile = "test"; - disable_release_max_log_level = true; - disable_features = [ - # Don't include experimental features + # dont include experimental features "experimental" # this is non-functional on nix for some reason "hardened_malloc" @@ -178,13 +161,13 @@ all-features = scopeHost.main.override { all_features = true; disable_features = [ - # Don't include experimental features + # dont include experimental features "experimental" # jemalloc profiling/stats features are expensive and shouldn't # be expected on non-debug builds. "jemalloc_prof" "jemalloc_stats" - # This is non-functional on nix for some reason + # this is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -193,12 +176,12 @@ all-features-debug = scopeHost.main.override { profile = "dev"; all_features = true; - # Debug build users expect full logs + # debug build users expect full logs disable_release_max_log_level = true; disable_features = [ - # Don't include experimental features + # dont include experimental features "experimental" - # This is non-functional on nix for some reason + # this is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -250,9 +233,9 @@ profile = "test"; disable_release_max_log_level = true; disable_features = [ - # dont include experimental features + # Don't include experimental features "experimental" - # this is non-functional on nix for some reason + # This is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -266,13 +249,13 @@ value = scopeCrossStatic.main.override { all_features = true; disable_features = [ - # dont include experimental features + # Don't include experimental features "experimental" # jemalloc profiling/stats features are expensive and shouldn't # be expected on non-debug builds. "jemalloc_prof" "jemalloc_stats" - # this is non-functional on nix for some reason + # This is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -287,13 +270,13 @@ value = scopeCrossStatic.main.override { all_features = true; disable_features = [ - # dont include experimental features + # Don't include experimental features "experimental" # jemalloc profiling/stats features are expensive and shouldn't # be expected on non-debug builds. "jemalloc_prof" "jemalloc_stats" - # this is non-functional on nix for some reason + # This is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -312,9 +295,9 @@ # debug build users expect full logs disable_release_max_log_level = true; disable_features = [ - # dont include experimental features + # Don't include experimental features "experimental" - # this is non-functional on nix for some reason + # This is non-functional on nix for some reason "hardened_malloc" # conduwuit_mods is a development-only hot reload feature "conduwuit_mods" @@ -332,8 +315,6 @@ ] ) [ - #"x86_64-apple-darwin" - #"aarch64-apple-darwin" "x86_64-linux-gnu" "x86_64-linux-musl" "aarch64-linux-musl" diff --git a/nix/pkgs/main/cross-compilation-env.nix b/nix/pkgs/main/cross-compilation-env.nix index 3e993bba..642bdd0b 100644 --- a/nix/pkgs/main/cross-compilation-env.nix +++ b/nix/pkgs/main/cross-compilation-env.nix @@ -2,33 +2,30 @@ , pkgsBuildHost , rust , stdenv +, }: lib.optionalAttrs stdenv.hostPlatform.isStatic { ROCKSDB_STATIC = ""; } -// -{ - CARGO_BUILD_RUSTFLAGS = - lib.concatStringsSep - " " - (lib.optionals - stdenv.hostPlatform.isStatic - [ "-C" "relocation-model=static" ] - ++ lib.optionals - (stdenv.buildPlatform.config != stdenv.hostPlatform.config) - [ - "-l" - "c" +// { + CARGO_BUILD_RUSTFLAGS = lib.concatStringsSep " " ( + lib.optionals stdenv.hostPlatform.isStatic [ + "-C" + "relocation-model=static" + ] + ++ lib.optionals (stdenv.buildPlatform.config != stdenv.hostPlatform.config) [ + "-l" + "c" - "-l" - "stdc++" + "-l" + "stdc++" - "-L" - "${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib" - ] - ); + "-L" + "${stdenv.cc.cc.lib}/${stdenv.hostPlatform.config}/lib" + ] + ); } # What follows is stolen from [here][0]. Its purpose is to properly @@ -37,14 +34,11 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic # 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 - // -( + // ( let inherit (rust.lib) envVars; in - lib.optionalAttrs - (stdenv.targetPlatform.rust.rustcTarget - != stdenv.hostPlatform.rust.rustcTarget) + lib.optionalAttrs (stdenv.targetPlatform.rust.rustcTarget != stdenv.hostPlatform.rust.rustcTarget) ( let inherit (stdenv.targetPlatform.rust) cargoEnvVarTarget; @@ -55,8 +49,7 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic "CARGO_TARGET_${cargoEnvVarTarget}_LINKER" = envVars.ccForTarget; } ) - // - ( + // ( let inherit (stdenv.hostPlatform.rust) cargoEnvVarTarget rustcTarget; in @@ -67,8 +60,7 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic CARGO_BUILD_TARGET = rustcTarget; } ) - // - ( + // ( let inherit (stdenv.buildPlatform.rust) cargoEnvVarTarget; in diff --git a/nix/pkgs/main/default.nix b/nix/pkgs/main/default.nix index 01fb8e40..59a2e574 100644 --- a/nix/pkgs/main/default.nix +++ b/nix/pkgs/main/default.nix @@ -7,7 +7,6 @@ , liburing , pkgsBuildHost , rocksdb -, removeReferencesTo , rust , rust-jemalloc-sys , stdenv @@ -143,8 +142,6 @@ let " -Ctarget-cpu=haswell"; }; - - commonAttrs = { inherit (craneLib.crateNameFromCargoToml {