about summary refs log tree commit diff
path: root/nix/utils/tests/default.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2022-05-28T11·49+0200
committerclbot <clbot@tvl.fyi>2022-05-28T12·01+0000
commit6813598c17959862734e5878d745e7dd8a197717 (patch)
treea5297d6d29f6ac19758e8687146c9b0449e227e5 /nix/utils/tests/default.nix
parent6c3465dc59b6447d275268d5acbc6b7f57d90865 (diff)
feat(nix/utils): add onlyDrvPath to get the drvPath w/o the outputs r/4175
I want to use this utility in a deploy script where the .drv is
nix-copy-closure-d to a remote host and realized there. Consequently it
doesn't make sense that the local deploy script depends on the
derivation's outputs which drvPath does by default.

This also came up when working on //nix/buildkite, although we didn't
end up using it there.

Change-Id: I952bbfd4d7e9de212569d5ee12182eb50d360f53
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5767
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'nix/utils/tests/default.nix')
-rw-r--r--nix/utils/tests/default.nix11
1 files changed, 11 insertions, 0 deletions
diff --git a/nix/utils/tests/default.nix b/nix/utils/tests/default.nix
index 344a1771d7..d5159a8433 100644
--- a/nix/utils/tests/default.nix
+++ b/nix/utils/tests/default.nix
@@ -15,6 +15,7 @@ let
     isSymlink
     pathType
     storePathName
+    onlyDrvPath
     ;
 
   assertUtilsPred = msg: act: exp: [
@@ -91,9 +92,19 @@ let
       (storePathName cleanedSource)
       cleanedSource.name)
   ];
+
+  onlyDrvPathTests = it "correctly updates the string context of drvPath" [
+    (assertEq "onlyDrvPath only produces path dependencies"
+      (builtins.all
+        (dep: dep.path or false)
+        (builtins.attrValues
+          (builtins.getContext (onlyDrvPath depot.tools.cheddar))))
+      true)
+  ];
 in
 
 runTestsuite "nix.utils" [
   pathPredicates
   storePathNameTests
+  onlyDrvPathTests
 ]