summary refs log tree commit diff
path: root/lib/default.nix
AgeCommit message (Collapse)AuthorFilesLines
2022-11-17lib/attrsets: add concatMapAttrsfigsoda1-1/+1
2022-10-23lib/strings: Refactor toInt into toInt and toIntBase10Jacob Abel1-1/+1
2022-09-21lib: Add lazyDerivationRobert Hensing1-0/+2
2022-06-21lib/options: Add showOptionWithDefLocsRobert Hensing1-1/+2
2022-06-12treewide: attempt at markdown option docspennae1-1/+2
2022-06-10Merge pull request #157480 from MatthewCroughan/in-pure-eval-modeRobert Hensing1-1/+1
lib: add inPureEvalMode
2022-05-30add mechanism for handling meta.sourceProvenance attributesRobert Scott1-0/+1
heavily based on patterns used by licenses infrastructure, so may appear overengineered for its initial level of use
2022-05-15Revert "lib: init flakes.nix"adisbladis1-4/+0
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-06lib: add inPureEvalModematthewcroughan1-1/+1
This makes a value that is true if builtins does not contain the currentSystem function, but false if it does.
2022-05-01Merge pull request #167947 from MatthewCroughan/mc/callLocklessFlakeArtturi1-0/+4
lib: add callLocklessFlake
2022-04-27Merge pull request #170583 from ncfavier/mkShellVarsRobert Hensing1-1/+2
lib/strings: add toShellVars
2022-04-27lib/strings: add toShellVarsNaïm Favier1-1/+2
A straightforward piece of plumbing to safely inject Nix variables into shell scripts: '' ${lib.toShellVars { inherit foo bar; }} cmd "$foo" --bar "$bar" ''
2022-04-24lib/meta: add getExe to get the main program of a drvArtturin1-1/+1
2022-04-12lib: init flakes.nixmatthewcroughan1-1/+5
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-12lib: add callLocklessFlakematthewcroughan1-1/+1
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-03-27lib/trivial: actually expose warnIfNot and throwIfNaïm Favier1-1/+1
2022-03-21Merge remote-tracking branch 'upstream/master' into tests-restrict-argumentsRobert Hensing1-4/+6
2022-03-21lib: Add toFunctionRobert Hensing1-1/+2
2022-03-21lib: applyIfFunction -> applyModuleArgsIfFunctionRobert Hensing1-1/+1
2022-03-21Merge pull request #163451 from hercules-ci/stop-premature-warningsKevin Cox1-2/+3
Stop premature warnings, including `nix.settings` migration
2022-03-18lib.attrsets: Introduce updateManyAttrsByPathSilvan Mosberger1-1/+2
2022-03-18lib.attrsets: Introduce showAttrPathSilvan Mosberger1-1/+1
2022-03-09lib: Add mkRenamedOptionModuleWithRobert Hensing1-2/+3
Adds support for sinceRelease
2022-02-28Merge pull request #157301 from pennae/lib-add-mkPackageOption0x4A6F1-1/+1
lib: add mkPackageOption to default.nix
2022-01-29lib: add mkPackageOption to default.nixpennae1-1/+1
this was forgotten in #155669
2022-01-27lib/modules: introduce setDefaultModuleLocationNaïm Favier1-2/+2
Wraps a module with a default location for reporting errors.
2022-01-24lib.types: Add unique like uniq, but custom errorsRobert Hensing1-2/+3
Couldn't extend types.uniq and it had a silly name anyway. Now we can have better error messages.
2022-01-09lib.checkListOfEnum: initJosé Romildo1-1/+1
2021-12-22lib.throwIfNot: initRobert Hensing1-1/+2
2021-12-02lib/meta: add getLicenseFromSpdxId functionShamrock Lee1-1/+1
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-11-15lib.modules: add mkDerivedConfigTaeer Bar-Yam1-1/+1
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-10-04Merge pull request #136909 from ncfavier/cleanup-defaults-examplesRobert Hensing1-2/+2
nixos/doc: clean up defaults and examples
2021-10-03lib/options: add literalExpression and literalDocBook, deprecate literalExampleNaïm Favier1-2/+2
2021-10-03lib: add function escapeXMLRobert Helgesson1-1/+1
Given a string, this function returns a string that can be inserted verbatim in an XML document.
2021-08-22lib: export strings/escapeRegexHarrison Houghton1-1/+1
I see no reason why I should be disallowed from using it.
2021-08-18lib: inherit mkImageMediaOverridelassulus1-1/+1
2021-07-12lib.mkFixStrictness: DeprecateRobert Hensing1-1/+1
2021-07-12Partially revert "lib/modules: Drop mkStrict and mkFixStrictness"Robert Hensing1-2/+2
mkFixStrictness was never properly deprecated and should only be removed after warning for some time. This partially reverts commit 8fb9984690c878fcd768e967190957441de05d11.
2021-06-06lib/modules: Drop mkStrict and mkFixStrictnessJanne Heß1-2/+2
This was deprecated in 2014 and is not used anywhere in the tree.
2021-04-28lib.trivial.warnIf: initAlyssa Ross1-2/+3
It's a common pattern in Nixpkgs to want to emit a warning in certain cases, but not actually change behaviours. This is often expressed as either if cond then lib.warn "Don't do that thing" x else x Or (if cond then lib.warn "Don't do that thing" else lib.id) x Neither of which really expresses the intent here, because it looks like 'x' is being chosen conditionally. To make this clearer, I introduce a "warnIf" function, which makes it clear that the only thing being affected by the condition is whether the warning is generated, not the value being returned.
2021-01-28lib/attrsets: add cartesianProductOfSets functionJacek Galowicz1-1/+1
2021-01-25lib/debug: add traceFnSeqNProfpatsch1-1/+1
Immensely helpful when you want to see the changes a function makes to its value as it passes through. Example: ``` $ nix-instantiate --strict --eval -E '(with import ./lib; traceFnSeqN 2 "id" (x: x) { a.b.c = 3; })' trace: { fn = "id"; from = { a = { b = {…}; }; }; to = { a = { b = {…}; }; }; } { a = { b = { c = 3; }; }; } ```
2020-11-19lib: Create `makeScopeWithSplicing`John Ericson1-1/+1
It's ugly as hell, but I suppose it is needed to codify how to make spliced package sets.
2020-11-13lib: Add composeManyExtensionsJoe Hermaszewski1-2/+2
2020-10-22lib: Add lib.trace for consistencyRobert Hensing1-1/+1
This puts it among the trace* family of functions derived from it.
2020-10-22lib: Add lib.isFloat for consistencyRobert Hensing1-1/+1
Unlike the other three is* functions in lib.trivial, it was only available as lib.trivial.isFloat
2020-10-22lib: Use Nix's static scope checking, fix error message, optimizeRobert Hensing1-18/+18
Nix can perform static scope checking, but whenever code is inside a `with` expression, the analysis breaks down, because it can't know statically what's in the attribute set whose attributes were brought into scope. In those cases, Nix has to assume that everything works out. Except it doesnt. Removing `with` from lib/ revealed an undefined variable in an error message. If that doesn't convince you that we're better off without `with`, I can tell you that this PR results in a 3% evaluation performance improvement because Nix can look up local variables by index. This adds up with applications like the module system. Furthermore, removing `with` makes the binding site of each variable obvious, which helps with comprehension.
2020-09-12lib: add importTOMLzimbatm1-1/+1
Complements the `lib.importJSON`. `builtins.readTOML` has been introduced in Nix 2.1.
2020-07-20lib: toHex -> toHexString & toBase -> toBaseDigitsBas van Dijk1-1/+1
This makes the type of these functions more apparent from the name.
2020-07-20lib: add the toHex and toBase utility functionsBas van Dijk1-1/+1
`toHex` converts the given positive integer to a string of the hexadecimal representation of that integer. For example: ``` toHex 0 => "0" toHex 16 => "10" toHex 250 => "FA" ``` `toBase base i` converts the positive integer `i` to a list of it digits in the given `base`. For example: ``` toBase 10 123 => [ 1 2 3 ] toBase 2 6 => [ 1 1 0 ] toBase 16 250 => [ 15 10 ] ```