From fcda0682357f1ec531c494dac5aa49ba8ae8851a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 14 Jul 2023 00:12:01 +0300 Subject: feat(nix/sparseTree): add optional `name` argument This allows pinning the name of the sparse tree derivation, which stops the continous rebuilding of tvix-store-proto dependents. I've opted to let the function take an attribute set instead and refactored the call sites appropriately. Change-Id: I3e57785094b1adbfffa24caf9f1c3384844fa200 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8965 Reviewed-by: grfn Tested-by: BuildkiteCI Reviewed-by: sterni --- nix/sparseTree/default.nix | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'nix/sparseTree/default.nix') diff --git a/nix/sparseTree/default.nix b/nix/sparseTree/default.nix index 7bfa47237869..35fa459e1c2f 100644 --- a/nix/sparseTree/default.nix +++ b/nix/sparseTree/default.nix @@ -2,22 +2,33 @@ # and directories if they are listed in a supplied list: # # # A very minimal depot -# sparseTree ./depot [ -# ./default.nix -# ./depot/nix/readTree/default.nix -# ./third_party/nixpkgs -# ./third_party/overlays -# ] +# sparseTree { +# root = ./depot; +# paths = [ +# ./default.nix +# ./depot/nix/readTree/default.nix +# ./third_party/nixpkgs +# ./third_party/overlays +# ]; +# } { pkgs, lib, ... }: -# root path to use as a reference point -root: -# list of paths below `root` that should be -# included in the resulting directory -# -# If path, need to refer to the actual file / directory to be included. -# If a string, it is treated as a string relative to the root. -paths: +{ + # root path to use as a reference point + root +, # list of paths below `root` that should be + # included in the resulting directory + # + # If path, need to refer to the actual file / directory to be included. + # If a string, it is treated as a string relative to the root. + paths +, # (optional) name to use for the derivation + # + # This should always be set when using roots that do not have + # controlled names, such as when passing the top-level of a git + # repository (e.g. `depot.path.origSrc`). + name ? builtins.baseNameOf root +}: let rootLength = builtins.stringLength (toString root); @@ -63,7 +74,7 @@ in # TODO(sterni): teach readTree to also read symlinked directories, # so we ln -sT instead of cp -aT. -pkgs.runCommand "sparse-${builtins.baseNameOf root}" { } ( +pkgs.runCommand "sparse-${name}" { } ( lib.concatMapStrings ({ src, dst }: '' mkdir -p "$(dirname "$out${dst}")" -- cgit 1.4.1