mach-nix icon indicating copy to clipboard operation
mach-nix copied to clipboard

Slow evaluation time on second-time builds

Open bergkvist opened this issue 1 year ago • 0 comments

Using flakes is not an option for me.

I'm deploying to NixOS-machines, and want my build-pipelines to be faster when nothing has changed. It seems like mach-nix might be doing some extra (unnecessary?) work on second-time runs.

For example:

# shell.nix
let
  machNix = import (builtins.fetchTarball {
    name = "mach-nix";
    url = "https://github.com/DavHau/mach-nix/archive/refs/tags/3.5.0.tar.gz";
    sha256 = "185qf6d5xg8qk1hb1y0b5gggr71vdz8v9d5ga4zg7dmcb1aypxcg";
  }) {
    pypiDataRev = "1109d77c34289ec0996bb9f8d1c6f3ea13e33fd8";
    pypiDataSha256 = "sha256:0mv07ab987xdqdg45c2wrngkvkyx3sr625xpxiim9c84sypa7q9b";
  };
in
machNix.mkPython {
  python = "python39Full";
  requirements = ''
    flask
    msal
    httpx-oauth
  '';
}

Evaluating this the second time takes 5-6 seconds, and prints out several trace-messages:

$ time nix-shell --run "exit"
trace: 
applying fix 'remove-patches' (patches) for httpx:0.23.0

trace: removing dependency python3.9-packaging-21.3 from cryptography
trace: 
applying fix 'no-rust-build' (nativeBuildInputs) for cryptography:3.3.2

trace: removing dependency python3.9-setuptools-rust-0.12.1 from cryptography
nix-shell --run "exit"  2.58s user 0.45s system 55% cpu 5.416 total

Is there a way to prevent this patchwork/fixing from being repeated? Or to otherwise make the build fast when nothing has changed since the last evaluation?

bergkvist avatar Nov 15 '22 14:11 bergkvist