Silvan Mosberger
00972297be
lib.substring: inherit from lib.strings
2024-06-20 22:45:50 +02:00
Silvan Mosberger
f6cbaeca60
lib.head: inherit from lib.lists
2024-06-20 22:45:50 +02:00
Silvan Mosberger
0a162f4dcd
lib.tail: inherit from lib.lists
2024-06-20 22:45:50 +02:00
Silvan Mosberger
6e98b0c0c6
lib.stringLength: inherit from lib.strings
2024-06-20 22:45:50 +02:00
Silvan Mosberger
357e954198
lib.length: inherit from lib.lists
2024-06-20 22:45:50 +02:00
Silvan Mosberger
d81f4e5eba
lib.genList: inherit from lib.lists
2024-06-20 22:45:50 +02:00
Silvan Mosberger
30def45e47
lib.filter: inherit from lib.lists
2024-06-20 22:45:48 +02:00
Silvan Mosberger
c60c3baf23
lib.attrNames: inherit from lib.attrsets
2024-06-20 21:06:21 +02:00
Silvan Mosberger
69f84db442
lib: inherit concatLists via lib.lists
2024-06-20 21:06:21 +02:00
Silvan Mosberger
89f6418908
lib.split: Export from lib.strings.split
2024-06-20 17:59:37 +02:00
Silvan Mosberger
6c6244c37f
lib.match: Export from lib.strings.match
2024-06-20 17:59:37 +02:00
Silvan Mosberger
18382c2ec8
lib.removeAttrs: Export from lib.attrsets.removeAttrs
2024-06-20 17:59:36 +02:00
Silvan Mosberger
56535c832f
lib.intersectAttrs: Export from builtins
2024-06-20 17:59:36 +02:00
Silvan Mosberger
4413a877bb
lib.map: Export from lib.lists.map
2024-06-20 17:59:21 +02:00
Silvan Mosberger
24af4c04ee
Merge pull request #214021 from tweag/ifilter0
...
lib.lists.ifilter0: init
2024-04-22 22:18:34 +02:00
Silvan Mosberger
6861ef7707
lib.lists.ifilter0: init
2024-04-22 18:33:14 +02:00
Robert Hensing
33e02424d2
lib: Document status of deprecated.nix and move it
...
This is all I could find after co-maintaining lib for a long time.
I've had the fortune of basically not really noticing this file,
because it has had very few interactions until the confusion in
https://github.com/NixOS/nixpkgs/pull/304277
It seems to be a state of limbo, which would be nice to resolve
(with great care), but this is not urgent, and first we should
document its status.
2024-04-21 16:04:35 +02:00
Rick van Schijndel
e00a40a257
Merge pull request #298680 from gvolpe/lib/transposeMap
...
lib/attrsets: add mapCartesianProduct function
2024-04-19 08:26:09 +02:00
éclairevoyant
bb4e822d1f
lib: add mdDoc back in to provide proper warning
2024-04-15 14:16:31 -04:00
Gabriel Volpe
fe2bead78b
lib/attrsets: introduce mapCartesianProduct
2024-04-15 19:16:15 +02:00
Gabriel Volpe
228621e42d
lib/attrsets: rename cartesianProductOfSets to cartesianProduct
2024-04-15 19:03:54 +02:00
stuebinm
46456a929b
lib: remove all uses of lib.mdDoc
...
this change is otherwise a no-op, as lib.mdDoc is already defined to be
the identity function.
2024-04-13 10:07:35 -07:00
Silvan Mosberger
4f1d724b82
Merge pull request #284551 from hercules-ci/types-attrTag
...
Add `types.attrTag`
2024-04-09 20:48:44 +02:00
edef
725bb4e48c
lib: add xor
...
This gets clumsily reimplemented in various places, to no useful end.
2024-04-04 19:46:58 +00:00
Robert Hensing
2e1d470569
lib.modules.evalOptionValue: Undeprecate for lib.types
...
lib.types.attrTag needs it.
2024-04-04 11:54:46 +02:00
Florian Richer
3b883d3cdf
lib/strings: Add makeIncludePath ( #296237 )
...
* Update strings.nix
* Fix typo in docs
* Update lib/strings.nix
Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com>
* Update lib/strings.nix
Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com>
* Add unit test with strings
* Move test to strings
* Add unit test with package structure
* testMakeIncludePathWithPkgs: use real pkgs
* Revert "testMakeIncludePathWithPkgs: use real pkgs"
This reverts commit fb1850c069 .
* Update lib/tests/misc.nix
Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com>
* Update lib/tests/misc.nix
Co-authored-by: Silvan Mosberger <github@infinisil.com>
---------
Co-authored-by: lolbinarycat <dogedoge61+github@gmail.com>
Co-authored-by: Silvan Mosberger <github@infinisil.com>
2024-04-02 19:01:05 +02:00
Sandro
e426a8f097
lib: export attrsets.mergeAttrsList
2024-02-26 15:49:25 +01:00
Shea Levy
ca1262a483
lib: Add optionalDrvAttr to conditionally set drv attributes.
...
This allows for adding new, conditionally set, derivation attributes
to an existing derivation without changing any output paths in the
case where the condition is not met.
2024-02-02 16:27:30 -05:00
Silvan Mosberger
cf47b9a5c0
Merge pull request #270537 from 9999years/packagesFromDirectory
...
lib.packagesFromDirectoryRecursive: init
2023-12-19 22:03:01 +01:00
Rebecca Turner
090b929b8a
lib.packagesFromDirectoryRecursive: init
...
Co-authored-by: Gabriella Gonzalez <GenuineGabriella@gmail.com>
2023-12-19 09:48:17 -08:00
Robert Hensing
67cc78643d
lib.sortOn: init
...
A more efficient sort in some cases, and often convenient.
This exposes `lib.lists.sortOn` immediately on `lib`, because it is
a sibling of `sort`, which is already present there.
Omitting it would lead to more confusion, and worse outcomes.
There's no confusion about the types `sort` or `sortOn` operate on.
Haskell agrees about the type for `sortOn`, and it is in its `base`.
2023-12-08 22:15:29 +01:00
Silvan Mosberger
b04b7d64f7
Merge pull request #239722 from Stunkymonkey/lib-allUnique
...
lib.lists.allUnique: init
2023-11-15 04:37:39 +01:00
Felix Buehler
66261e9961
lib.lists.allUnique: init
2023-11-14 19:52:32 +01:00
Yueh-Shun Li
a16319908e
lib.mirrorFunctionArgs: init
...
Co-authored-by: Silvan Mosberger <github@infinisil.com>
2023-11-07 01:58:04 +00:00
Silvan Mosberger
5323fbf703
Merge pull request #254452 from flyingcircusio/lib-attrsToList
...
lib.attrsets.attrsToList: add function
2023-10-10 19:49:17 +02:00
Oliver Schmidt
d70633f91c
lib.attrsets.attrsToList: add function
...
For transforming back between lists and attrsets, it makes sense to have
a quasi-inverse of `builtins.listToAttrs` available as a library
function.
Co-authored-by: Silvan Mosberger <github@infinisil.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-10-10 16:11:01 +02:00
Anderson Torres
cc3383d12b
lib: add cmakeOptionType, cmakeBool and cmakeFeature
2023-09-27 20:49:38 -03:00
Silvan Mosberger
d66929b7b1
Merge pull request #245623 from tweag/fileset.toSource
...
File set combinators base: `lib.fileset.toSource`
2023-09-02 04:07:02 +02:00
Silvan Mosberger
465e05c0c5
lib.fileset.toSource: init
2023-09-01 15:46:04 +02:00
Jan Tojnar
434d160d7c
Merge pull request #234615 from linsui/dconf
...
nixos/dconf: support generating from attrs
2023-08-28 18:31:52 +02:00
Artturi
bde196dde9
Merge pull request #245957 from amjoseph-nixpkgs/pr/lib/customization/makeScopeWithSplicing2
2023-08-20 18:57:05 +03:00
linsui
da614d98e9
lib/gvariant: init
2023-08-15 19:20:39 +08:00
Adam Joseph
a1fdbae706
lib.customisation: add uncurried form of makeScopeWithSplicing
...
Deeply-curried functions are pretty error-prone in untyped languages
like Nix. This is a particularly bad case because
`top-level/splice.nix` *also* declares a makeScopeWithSplicing, but
it takes *two fewer arguments*.
Let's add a version that uses attrset-passing form, to provide some
minimal level of sanity-checking.
This also provides defaults for keep and extra (these are often
unneeded by the user).
2023-08-14 02:50:32 +03:00
Sefa Eyeoglu
3036465760
lib/meta.nix: introduce getExe'
...
getExe' can be used to get a binary other than the mainProgram from a
derivation.
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2023-08-13 15:45:37 +02:00
pennae
7542a1aa8f
lib/options: remove literalDocBook
...
no longer supported. warning when used would not be appropriate, and
docbook has been on the way out for long enough that throwing an error
should not be necessary either.
2023-06-13 16:56:30 +02:00
Silvan Mosberger
c701a4dd29
lib.sources.pathType and co.: Move to lib.filesystem
...
These functions only work with the filesystem, they don't import
anything as sources
2023-04-05 17:18:10 +02:00
hsjobeki
15a8d05ba5
init: lib.foldlAttrs
...
- provide comprehensive example
- add unit test
2023-03-11 10:42:00 +01:00
pennae
61852b7faa
lib: remove deprecated functions
...
all of these have been deprecated and raising warnings since 18.09. it's
about time we actually made good on "will be removed in the next release".
2023-03-08 03:57:38 +01:00
Patrick Widmer
7089294f10
strings: add escapeQuery for url encoding
2023-03-03 20:48:55 +01:00
Silvan Mosberger
0a60663e67
Merge pull request #206611 from h7x4/lib-lists-add-repeat
...
lib.lists: add `replicate`
2023-02-07 06:16:09 +01:00
h7x4
7c4abbf80e
lib.lists: add replicate
...
`replicate` returns n copies of an element as a list.
Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
2023-02-06 20:40:47 +01:00
Silvan Mosberger
50e4dbf35b
Merge pull request #205557 from ncfavier/concatLines
...
lib/strings: add `concatLines`
2023-01-31 18:05:53 +01:00
Silvan Mosberger
d35cae9696
Merge pull request #208674 from YoshiRulz/yoshi-lib-docs
...
lib: Fix mismatched quotes in `lib.*` doc comments
2023-01-05 19:00:38 +01:00
pennae
9da5f12ecf
modules: add mkPackageOptionMD
...
another transitional option factory, like mkAliasOptionModuleMD.
2023-01-05 02:33:13 +01:00
pennae
4c1cfbdb84
modules: add mkAliasOptionModuleMD
...
mkAliasOptionModule should not default to mdDoc descriptions because
that can break out-of-tree users of documentation infrastructure. add an
explicitly-MD variant for now, to be removed some time after the MD
transition is complete.
2023-01-05 02:33:13 +01:00
Robert Hensing
f61d4d346b
Merge pull request #205190 from NixOS/lib.path.relativeNormalise
...
lib.path.subpath.{isValid,normalise}: init
2023-01-03 13:46:11 +01:00
Silvan Mosberger
98fbcf1788
lib.path.subpath.isValid: init
...
The first path library function
2023-01-03 13:20:36 +01:00
YoshiRulz
7fba83890c
lib: Fix mismatched quotes in lib.* doc comments
...
caused problems for automated rich text generation such as
https://teu5us.github.io/nix-lib.html#customisation-functions
2023-01-02 08:25:17 +10:00
Robert Hensing
cb98e26aaf
lib: Add isStringLike
2022-12-31 01:47:28 +01:00
Robert Hensing
d0d0f7d0aa
lib: Add isPath
...
Available since Nix 2.3, which is the Nixpkgs minimum version.
Thanks zimbatm!
2022-12-31 01:33:47 +01:00
Naïm Favier
ed0b8c26f1
lib/strings: add concatLines
...
Like `unlines` from Haskell.
The aim is to replace the `concatStringsSep "\n"` pattern for generated
files, which doesn't add a final newline.
2022-12-10 15:56:30 +01:00
AndersonTorres
85b6175ccb
lib/default.nix: include mesonOption-related functions
...
To bring them to the scope when calling `lib`.
2022-12-06 23:09:36 -03:00
figsoda
f993f8a186
lib/attrsets: add concatMapAttrs
2022-11-17 10:41:53 -05:00
Jacob Abel
39a4ab78a1
lib/strings: Refactor toInt into toInt and toIntBase10
2022-10-23 17:50:24 -04:00
Robert Hensing
fce8b018f0
lib: Add lazyDerivation
2022-09-21 10:55:07 +01:00
Robert Hensing
89b4bd8b24
lib/options: Add showOptionWithDefLocs
2022-06-21 14:22:33 +02:00
pennae
320aa2a791
treewide: attempt at markdown option docs
2022-06-12 12:44:38 +02:00
Robert Hensing
b37801bc3f
Merge pull request #157480 from MatthewCroughan/in-pure-eval-mode
...
lib: add inPureEvalMode
2022-06-10 16:31:31 +02:00
Robert Scott
da9162f667
add mechanism for handling meta.sourceProvenance attributes
...
heavily based on patterns used by licenses infrastructure, so may
appear overengineered for its initial level of use
2022-05-30 16:27:34 +08:00
adisbladis
161776ec1e
Revert "lib: init flakes.nix"
...
This reverts commit PR #167947 .
Flakes aren't standardised and the `lib` namespace shouldn't be
polluted with utilities that serve only experimental uses.
2022-05-15 22:39:46 +12:00
matthewcroughan
4d9801a78f
lib: add inPureEvalMode
...
This makes a value that is true if builtins does not contain the
currentSystem function, but false if it does.
2022-05-06 15:42:52 +01:00
Artturi
a5357d06e4
Merge pull request #167947 from MatthewCroughan/mc/callLocklessFlake
...
lib: add callLocklessFlake
2022-05-01 23:06:17 +03:00
Robert Hensing
5f8cb21011
Merge pull request #170583 from ncfavier/mkShellVars
...
lib/strings: add toShellVars
2022-04-27 23:33:28 +02:00
Naïm Favier
226bc99659
lib/strings: add toShellVars
...
A straightforward piece of plumbing to safely inject Nix variables into
shell scripts:
''
${lib.toShellVars { inherit foo bar; }}
cmd "$foo" --bar "$bar"
''
2022-04-27 16:04:17 +02:00
Artturin
379b9c8be3
lib/meta: add getExe to get the main program of a drv
2022-04-24 04:19:49 +03:00
matthewcroughan
cad8bbe589
lib: init flakes.nix
...
This commit creates flakes.nix, which is a library containing functions
which relate to interacting with flakes. It also moves related functions
from trivial.nix into it.
2022-04-12 19:28:23 +01:00
matthewcroughan
c190b08bb7
lib: add callLocklessFlake
...
This is essentially a copy of the function of the same name, from
flake-compat. callLocklessFlake is useful when trying to utilise a
flake.nix without a lock file, often for when you want to create a
subflake from within a parent flake.
Co-authored-by: Tom Bereknyei <tomberek@gmail.com>
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-04-12 19:27:24 +01:00
Naïm Favier
9f5796be49
lib/trivial: actually expose warnIfNot and throwIf
2022-03-27 16:48:33 +02:00
Robert Hensing
6c469679f6
Merge remote-tracking branch 'upstream/master' into tests-restrict-arguments
2022-03-21 23:17:17 +01:00
Robert Hensing
84274cbc95
lib: Add toFunction
2022-03-21 23:14:10 +01:00
Robert Hensing
6a0b24b276
lib: applyIfFunction -> applyModuleArgsIfFunction
2022-03-21 23:14:10 +01:00
Kevin Cox
8ce16fcf62
Merge pull request #163451 from hercules-ci/stop-premature-warnings
...
Stop premature warnings, including `nix.settings` migration
2022-03-21 10:10:40 -04:00
Silvan Mosberger
85003ecdbb
lib.attrsets: Introduce updateManyAttrsByPath
2022-03-18 00:08:29 +01:00
Silvan Mosberger
71b130c581
lib.attrsets: Introduce showAttrPath
2022-03-18 00:05:08 +01:00
Robert Hensing
7377ea57ff
lib: Add mkRenamedOptionModuleWith
...
Adds support for sinceRelease
2022-03-09 14:50:51 +01:00
0x4A6F
3362ff0f7b
Merge pull request #157301 from pennae/lib-add-mkPackageOption
...
lib: add mkPackageOption to default.nix
2022-02-28 20:37:59 +01:00
pennae
1c0918d828
lib: add mkPackageOption to default.nix
...
this was forgotten in #155669
2022-01-29 18:28:20 +01:00
Naïm Favier
5a07097772
lib/modules: introduce setDefaultModuleLocation
...
Wraps a module with a default location for reporting errors.
2022-01-27 22:12:53 +01:00
Robert Hensing
ba3e91ed43
lib.types: Add unique like uniq, but custom errors
...
Couldn't extend types.uniq and it had a silly name anyway.
Now we can have better error messages.
2022-01-24 16:14:55 +01:00
José Romildo
4fc67da841
lib.checkListOfEnum: init
2022-01-09 19:21:08 -03:00
Robert Hensing
f2c5c706f4
lib.throwIfNot: init
2021-12-22 13:13:50 +01:00
Shamrock Lee
60950f739e
lib/meta: add getLicenseFromSpdxId function
...
Move function spdxLicense, internally used in yarn2nix
to lib/meta.nix, and
rename to getLicenseFromSpdxId
A similar function is implemented in poetry2nix,
but the one originally in yarn2nix seems beter.
since it falls back to an license-like attrset
for mismatched case
instead of a plain string
2021-12-02 18:33:48 +08:00
Taeer Bar-Yam
0bef0c38f7
lib.modules: add mkDerivedConfig
...
mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
Create config definitions with the same priority as the definition of another option.
This should be used for option definitions where one option sets the value of another as a convenience.
For instance a config file could be set with a `text` or `source` option, where text translates to a `source`
value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`.
It takes care of setting the right priority using `mkOverride`.
2021-11-15 07:03:41 -05:00
Robert Hensing
0699530f08
Merge pull request #136909 from ncfavier/cleanup-defaults-examples
...
nixos/doc: clean up defaults and examples
2021-10-04 20:37:42 +02:00
Naïm Favier
52a2e4136e
lib/options: add literalExpression and literalDocBook, deprecate literalExample
2021-10-03 17:19:19 +02:00
Robert Helgesson
e75f346aa3
lib: add function escapeXML
...
Given a string, this function returns a string that can be inserted
verbatim in an XML document.
2021-10-03 11:28:03 +02:00
Harrison Houghton
9d71711aec
lib: export strings/escapeRegex
...
I see no reason why I should be disallowed from using it.
2021-08-22 00:01:38 -04:00
lassulus
229ff549e6
lib: inherit mkImageMediaOverride
2021-08-18 14:21:16 +02:00
Robert Hensing
cad20d8983
lib.mkFixStrictness: Deprecate
2021-07-12 07:31:29 +02:00
Robert Hensing
99bc203025
Partially revert "lib/modules: Drop mkStrict and mkFixStrictness"
...
mkFixStrictness was never properly deprecated and should only be
removed after warning for some time.
This partially reverts commit 8fb9984690 .
2021-07-12 07:25:52 +02:00