Skip to content

lib.meta: functions for derivation metadata

Some functions for manipulating meta attributes, as well as the name attribute.

lib.meta.addMetaAttrs

Add to or override the meta attributes of the given derivation.

Inputs

newAttrs

: 1. Function argument

drv

: 2. Function argument

Examples

lib.meta.addMetaAttrs usage example

addMetaAttrs {description = "Bla blah";} somePkg

Located at lib/meta.nix:41 in <nixpkgs>.

lib.meta.dontDistribute

Disable Hydra builds of given derivation.

Inputs

drv

: 1. Function argument

Located at lib/meta.nix:54 in <nixpkgs>.

lib.meta.setName

Change the symbolic name of a derivation.

Warning

Dependent derivations will be rebuilt when the symbolic name is changed.

Inputs

name

: 1. Function argument

drv

: 2. Function argument

Located at lib/meta.nix:74 in <nixpkgs>.

lib.meta.updateName

Like setName, but takes the previous name as an argument.

Inputs

updater

: 1. Function argument

drv

: 2. Function argument

Examples

lib.meta.updateName usage example

updateName (oldName: oldName + "-experimental") somePkg

Located at lib/meta.nix:101 in <nixpkgs>.

lib.meta.appendToName

Append a suffix to the name of a package (before the version part).

Inputs

suffix

: 1. Function argument

Located at lib/meta.nix:114 in <nixpkgs>.

lib.meta.mapDerivationAttrset

Apply a function to each derivation and only to derivations in an attrset.

Inputs

f

: 1. Function argument

set

: 2. Function argument

Located at lib/meta.nix:132 in <nixpkgs>.

lib.meta.setPrio

Set the nix-env priority of the package.

Inputs

priority : 1. Function argument

drv : 2. Function argument

Located at lib/meta.nix:145 in <nixpkgs>.

lib.meta.lowPrio

Decrease the nix-env priority of the package, i.e., other versions/variants of the package will be preferred.

Inputs

drv

: 1. Function argument

Located at lib/meta.nix:158 in <nixpkgs>.

lib.meta.lowPrioSet

Apply lowPrio to an attrset with derivations

Inputs

set

: 1. Function argument

Located at lib/meta.nix:170 in <nixpkgs>.

lib.meta.hiPrio

Increase the nix-env priority of the package, i.e., this version/variant of the package will be preferred.

Inputs

drv

: 1. Function argument

Located at lib/meta.nix:183 in <nixpkgs>.

lib.meta.hiPrioSet

Apply hiPrio to an attrset with derivations

Inputs

set

: 1. Function argument

Located at lib/meta.nix:195 in <nixpkgs>.

lib.meta.platformMatch

Check to see if a platform is matched by the given meta.platforms element.

A meta.platform pattern is either

  1. (legacy) a system string.

  2. (modern) a pattern for the entire platform structure (see lib.systems.inspect.platformPatterns).

  3. (modern) a pattern for the platform parsed field (see lib.systems.inspect.patterns).

We can inject these into a pattern for the whole of a structured platform, and then match that.

Inputs

platform

: 1. Function argument

elem

: 2. Function argument

Examples

lib.meta.platformMatch usage example

lib.meta.platformMatch { system = "aarch64-darwin"; } "aarch64-darwin"
=> true

Located at lib/meta.nix:236 in <nixpkgs>.

lib.meta.availableOn

Check if a package is available on a given platform.

A package is available on a platform if both

  1. One of meta.platforms pattern matches the given platform, or meta.platforms is not present.

  2. None of meta.badPlatforms pattern matches the given platform.

Inputs

platform

: 1. Function argument

pkg

: 2. Function argument

Examples

lib.meta.availableOn usage example

lib.meta.availableOn { system = "aarch64-darwin"; } pkg.zsh
=> true

Located at lib/meta.nix:285 in <nixpkgs>.

lib.meta.getLicenseFromSpdxId

Get the corresponding attribute in lib.licenses from the SPDX ID. For SPDX IDs, see https://spdx.org/licenses

Type

getLicenseFromSpdxId :: str -> AttrSet

Examples

lib.meta.getLicenseFromSpdxId usage example

lib.getLicenseFromSpdxId "MIT" == lib.licenses.mit
=> true
lib.getLicenseFromSpdxId "mIt" == lib.licenses.mit
=> true
lib.getLicenseFromSpdxId "MY LICENSE"
=> trace: warning: getLicenseFromSpdxId: No license matches the given SPDX ID: MY LICENSE
=> { shortName = "MY LICENSE"; }

Located at lib/meta.nix:317 in <nixpkgs>.

lib.meta.getExe

Get the path to the main program of a package based on meta.mainProgram

Inputs

x

: 1. Function argument

Type

getExe :: package -> string

Examples

lib.meta.getExe usage example

getExe pkgs.hello
=> "/nix/store/g124820p9hlv4lj8qplzxw1c44dxaw1k-hello-2.12/bin/hello"
getExe pkgs.mustache-go
=> "/nix/store/am9ml4f4ywvivxnkiaqwr0hyxka1xjsf-mustache-go-1.3.0/bin/mustache"

Located at lib/meta.nix:356 in <nixpkgs>.

lib.meta.getExe'

Get the path of a program of a derivation.

Inputs

x

: 1. Function argument

y

: 2. Function argument

Type

getExe' :: derivation -> string -> string

Examples

lib.meta.getExe' usage example

getExe' pkgs.hello "hello"
=> "/nix/store/g124820p9hlv4lj8qplzxw1c44dxaw1k-hello-2.12/bin/hello"
getExe' pkgs.imagemagick "convert"
=> "/nix/store/5rs48jamq7k6sal98ymj9l4k2bnwq515-imagemagick-7.1.1-15/bin/convert"

Located at lib/meta.nix:396 in <nixpkgs>.