From 422e21aaf1c9aa8c7078b04fe7168bf13f284b43 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 21 Mar 2026 15:38:04 +0300 Subject: [PATCH] nix: setup sccache Signed-off-by: NotAShelf Change-Id: I375e0d41d42939b63a01a59d41b3fd426a6a6964 --- nix/shell.nix | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/nix/shell.nix b/nix/shell.nix index ec76d19..dcff21d 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -26,18 +26,6 @@ in name = "pinakes-dev"; packages = [ - pkgs.taplo # TOML formatter - pkgs.lldb # debugger - pkgs.llvm - - # Modern, LLVM based linking pipelime - llvmPackages.lld - llvmPackages.clang - - # Additional Cargo Tooling - pkgs.cargo-nextest - pkgs.cargo-deny - # Build tools # We use the rust-overlay to get the stable Rust toolchain for various targets. # This is not exactly necessary, but it allows for compiling for various targets @@ -47,11 +35,43 @@ in targets = ["wasm32-unknown-unknown" "wasm32-wasip1"]; # web + plugins }) + # Modern, LLVM based linking pipeline + llvmPackages.lld + llvmPackages.clang + # Handy CLI for packaging Dioxus apps and such pkgs.dioxus-cli + + # Additional Cargo Tooling + pkgs.cargo-nextest + pkgs.cargo-deny + + # Other tools + pkgs.taplo # TOML formatter + pkgs.lldb # debugger + pkgs.sccache # distributed Rust cache ] ++ runtimeDeps; + # We could do this in the NixOS configuration via ~/.config/cargo.toml + # or something, but this is better because it lets everyone benefit + # from sccache while working with Pinakes. The reason those variables + # are not in 'env' are that we have to use Bash, which doesn't mix well + # with Nix strings. + shellHook = '' + if [ -n "$SCCACHE_BIN" ]; then + export RUSTC_WRAPPER="$SCCACHE_BIN" + export SCCACHE_DIR="''${HOME}/.cache/sccache" + export SCCACHE_CACHE_SIZE="50G" + mkdir -p "$SCCACHE_DIR" + + echo "sccache setup complete!" + fi + + # Start the daemon early for slightly faster startup. + "$SCCACHE_BIN" --start-server >/dev/null 2>&1 || true + ''; + env = { # Allow Cargo to use lld and clang properly LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; @@ -64,5 +84,8 @@ in # Runtime library path for GTK/WebKit/xdotool LD_LIBRARY_PATH = "${lib.makeLibraryPath runtimeDeps}"; + + # Enable sccache for local nix develop shell + SCCACHE_BIN = "${pkgs.sccache}/bin/sccache"; }; }