refactor(nix): move isPathLike utility into //nix/utils
Change-Id: I040fbcbf1eefa69a2e37bf6e40fa6bc453ea1c90 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13179 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
13723eb45f
commit
699826b831
2 changed files with 24 additions and 7 deletions
|
|
@ -1,12 +1,7 @@
|
|||
{ depot, lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib) fix pipe mapAttrsToList isAttrs concatLines isString isDerivation isPath;
|
||||
|
||||
# TODO(sterni): move to //nix/utils with clearer naming and alternative similar to lib.types.path
|
||||
isPathLike = value:
|
||||
isPath value
|
||||
|| isDerivation value
|
||||
|| (isString value && builtins.hasContext value);
|
||||
inherit (depot.nix.utils) isReferencablePath;
|
||||
|
||||
esc = s: lib.escapeShellArg /* ensure paths import into store */ "${s}";
|
||||
|
||||
|
|
@ -16,7 +11,7 @@ let
|
|||
''
|
||||
+ pipe tree [
|
||||
(mapAttrsToList (k: v:
|
||||
if isPathLike v then
|
||||
if isReferencablePath v then
|
||||
"cp -R --reflink=auto ${esc "${v}"} \"$out/\"${esc path}/${esc k}"
|
||||
else if lib.isAttrs v then
|
||||
writeTreeAtPath (path + "/" + k) v
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue