From fa8c65f3a25c68a289610ffc88d1e4df69240ecd Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Fri, 1 May 2026 11:49:25 +0200 Subject: [PATCH] feat: preferLocalBuild The apps exported like `write-flake` are written in a way that nix will first try to reach out to caches and remote builders before performing a local build. This is very annoying since it slows down the build a lot, especially if you have a lot of caches (nix-community.cachix.org, cache.garnix.io, etc.). But caches and remote builders will never be able to serve these, so it is pointless in even trying. This patch adds preferLocalBuild to all `runCommand`'s and `mkDerivation`'s I found with `rg`. --- modules/write-flake.nix | 3 ++- modules/write-inputs.nix | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/write-flake.nix b/modules/write-flake.nix index 8501a2f..33dc05d 100644 --- a/modules/write-flake.nix +++ b/modules/write-flake.nix @@ -89,6 +89,7 @@ let name = "flake-formatted"; passAsFile = [ "unformatted" ]; inherit unformatted; + preferLocalBuild = true; phases = [ "format" ]; format = '' cp $unformattedPath flake.nix @@ -126,7 +127,7 @@ let (lib.concatStringsSep "\n") ]; in - pkgs.runCommand "check-flake-file" + pkgs.runCommandLocal "check-flake-file" { nativeBuildInputs = [ pkgs.diffutils ]; } diff --git a/modules/write-inputs.nix b/modules/write-inputs.nix index a658f98..8c26890 100644 --- a/modules/write-inputs.nix +++ b/modules/write-inputs.nix @@ -20,6 +20,7 @@ let copy = '' cp $inputsStringPath $out ''; + preferLocalBuild = true; }; write-inputs =