about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-09-14T10·56+0200
committersterni <sternenseemann@systemli.org>2021-09-14T14·02+0000
commit3a8e8120de2f0ac6188003b81efafa64d5bb6959 (patch)
treed2235d21f400ec235da06e3349529e6f4e882b69 /nix
parent1883159f921d6c25ae894c231cd8bee6b4370720 (diff)
feat(nix/tag): add functions for querying a tag's name and value r/2856
Both are just trivial wrappers around assertIsTag to make these lookups
more ergonomic. This also allows us to demote assertIsTag to an
implemtation detail.

Change-Id: Ib6ba2a858f4839354a57b660042b418976c4b1d9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3541
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'nix')
-rw-r--r--nix/tag/default.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/nix/tag/default.nix b/nix/tag/default.nix
index 4fe5898258..23f369c2b2 100644
--- a/nix/tag/default.nix
+++ b/nix/tag/default.nix
@@ -24,6 +24,18 @@ let
       val = null;
     };
 
+  # Returns the tag name of a given tag attribute set.
+  # Throws if the tag is invalid.
+  #
+  # Type: tag -> string
+  tagName = tag: (assertIsTag tag).name;
+
+  # Returns the tagged value of a given tag attribute set.
+  # Throws if the tag is invalid.
+  #
+  # Type: tag -> any
+  tagValue = tag: (assertIsTag tag).val;
+
   # like `verifyTag`, but throws the error message if it is not a tag.
   assertIsTag = tag:
     let res = verifyTag tag; in
@@ -139,7 +151,8 @@ let
 in {
    inherit
      verifyTag
-     assertIsTag
+     tagName
+     tagValue
      discr
      discrDef
      match