From ea927a8c3416fdce2539eb3a500f12f756ed1224 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sun, 28 Mar 2021 01:14:59 +0000 Subject: [PATCH] depot: make version build faster We don't need the entire depot to get the build version. --- version.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/version.nix b/version.nix index f82fb62102..1f0d103a9e 100644 --- a/version.nix +++ b/version.nix @@ -5,7 +5,20 @@ { pkgs, ... }: let - hgRepo = builtins.path { path = ./.hg; name = "depot-hg"; }; + inherit (pkgs) lib; + inherit (builtins) elemAt match length; + hgRelativePath = path: elemAt (match ".*/\\.hg/(.*)$" path) 0; + hgDepth = path: length (lib.splitString "/" (hgRelativePath path)); + hgRepo = builtins.path { + path = ./.hg; + name = "depot-hg"; + filter = path: type: (type == "directory" && ( + hgRelativePath path == "store" || + hgRelativePath path == "merge" || + hgRelativePath path == "cache")) || + (type == "regular" && hgDepth path == 1) || + (type == "regular" && hgDepth path == 2); + }; changesetDeriv = pkgs.runCommandLocal "depot-version" { HG_REPO = hgRepo; MERCURIAL = pkgs.mercurial;