Compare commits

..

2 Commits

Author SHA1 Message Date
82378445b0
feat(hm/price): integrate sccache with rust build
Some checks failed
Check Formatting of Files / Check-Formatting (push) Failing after 35s
2024-12-22 23:00:14 -06:00
09cf72df32
feat(host/orion): enable services.memcached 2024-12-22 22:59:55 -06:00
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,7 @@
{ ... }:
{
services.memcached = {
enable = true;
maxMemory = 512;
};
}

View File

@ -1,8 +1,31 @@
{ {
config, config,
pkgs, pkgs,
osConfig,
... ...
}: }:
let
sccacheWrapped =
if osConfig.services.memcached.enable then
pkgs.symlinkJoin {
name = "sccache";
paths = [ pkgs.sccache ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/sccache \
--set SCCACHE_MEMCACHED_KEY_PREFIX "SCCACHE" \
--set SCCACHE_MEMCACHED_ENDPOINT "tcp://${builtins.toString osConfig.services.memcached.listen}:${builtins.toString osConfig.services.memcached.port}"
'';
}
else
# Symlinking this ensures that sccache can properly create temporary directories.
# This is because Nix wants to cause every sccache invocation to sandbox the build, by
# symlinking sccache instead, we can avoid the sandbox to some degree.
pkgs.symlinkJoin {
name = "sccache";
paths = [ pkgs.sccache ];
};
in
{ {
home = { home = {
sessionVariables = { sessionVariables = {
@ -26,12 +49,13 @@
rust-analyzer-nightly rust-analyzer-nightly
cargo-watch cargo-watch
cargo-nextest cargo-nextest
sccache sccacheWrapped
]; ];
file = { file = {
# NOTE: This improves the rust edit-build-run cycle. See https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html # NOTE: This improves the rust edit-build-run cycle. See https://davidlattimore.github.io/posts/2024/02/04/speeding-up-the-rust-edit-build-run-cycle.html
"${config.home.sessionVariables.CARGO_HOME}/config.toml".text = '' "${config.home.sessionVariables.CARGO_HOME}/config.toml".text = ''
[build] [build]
rustc-wrapper = "${sccacheWrapped}/bin/sccache"
rustflags = [ "-C", "linker=${pkgs.clang}/bin/clang", "-C", "link-arg=--ld-path=${pkgs.mold-wrapped}/bin/mold" ] rustflags = [ "-C", "linker=${pkgs.clang}/bin/clang", "-C", "link-arg=--ld-path=${pkgs.mold-wrapped}/bin/mold" ]
[profile.dev] [profile.dev]