about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorSomeone Serge2024-07-21 11:27:03 +0000
committerSomeone Serge2024-07-21 11:38:04 +0000
commit98384afab5a12447eda2daf1d432224650c18ed5 (patch)
tree1725c2025c5c7d5f7a0d26dbbcc409afd1dde02c /lib
parent76db6ba81a95254e54445efd970a76fbf0c24388 (diff)
lib: add getStatic
Diffstat (limited to 'lib')
-rw-r--r--lib/attrsets.nix29
-rw-r--r--lib/default.nix2
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 833fc5871486..8bb4ef972fd8 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -1901,6 +1901,35 @@ rec {
   */
   getLib = getOutput "lib";
 
+  /**
+    Get a package's `static` output.
+    If the output does not exist, fallback to `.lib`, then to `.out`, and then to the default.
+
+    # Inputs
+
+    `pkg`
+
+    : The package whose `static` output will be retrieved.
+
+    # Type
+
+    ```
+    getStatic :: Derivation -> Derivation
+    ```
+
+    # Examples
+    :::{.example}
+    ## `lib.attrsets.getStatic` usage example
+
+    ```nix
+    "${lib.getStatic pkgs.glibc}"
+    => "/nix/store/00000000000000000000000000000000-glibc-2.39-52-static"
+    ```
+
+    :::
+  */
+  getStatic = getFirstOutput [ "static" "lib" "out" ];
+
 
   /**
     Get a package's `dev` output.
diff --git a/lib/default.nix b/lib/default.nix
index adc7caa6bb9e..ecf4fbb75339 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -87,7 +87,7 @@ let
       mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
       zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
       recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput getFirstOutput
-      getBin getLib getDev getInclude getMan chooseDevOutputs zipWithNames zip
+      getBin getLib getStatic getDev getInclude getMan chooseDevOutputs zipWithNames zip
       recurseIntoAttrs dontRecurseIntoAttrs cartesianProduct cartesianProductOfSets
       mapCartesianProduct updateManyAttrsByPath listToAttrs hasAttr getAttr isAttrs intersectAttrs removeAttrs;
     inherit (self.lists) singleton forEach map foldr fold foldl foldl' imap0 imap1