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

Type

addMetaAttrs :: AttrSet -> Derivation -> Derivation

Examples

Example

lib.meta.addMetaAttrs usage example

addMetaAttrs {description = "Bla blah";} somePkg

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

lib.meta.dontDistribute

Disable Hydra builds of given derivation.

Inputs

drv

1. Function argument

Type

dontDistribute :: Derivation -> Derivation

Located at lib/meta.nix:80 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

Type

setName :: String -> Derivation -> Derivation

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

lib.meta.updateName

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

Inputs

updater

1. Function argument

drv

2. Function argument

Type

updateName :: (String -> String) -> Derivation -> Derivation

Examples

Example

lib.meta.updateName usage example

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

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

lib.meta.appendToName

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

Inputs

suffix

1. Function argument

Type

appendToName :: String -> Derivation -> Derivation

Located at lib/meta.nix:154 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

Type

mapDerivationAttrset :: (Derivation -> a) -> AttrSet -> AttrSet

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

lib.meta.defaultPriority

The default priority of packages in Nix. See defaultPriority in src/nix/profile.cc.

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

lib.meta.setPrio

Set the nix-env priority of the package. Note that higher values are lower priority, and vice versa.

Inputs

priority : 1. The priority to set.

drv : 2. Function argument

Type

setPrio :: Int -> Derivation -> Derivation

Located at lib/meta.nix:208 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

Type

lowPrio :: Derivation -> Derivation

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

lib.meta.lowPrioSet

Apply lowPrio to an attrset with derivations.

Inputs

set

1. Function argument

Type

lowPrioSet :: { [String] :: Derivation } -> { [String] :: Derivation }

Located at lib/meta.nix:243 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

Type

hiPrio :: Derivation -> Derivation

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

lib.meta.hiPrioSet

Apply hiPrio to an attrset with derivations.

Inputs

set

1. Function argument

Type

hiPrioSet :: { [String] :: Derivation } -> { [String] :: Derivation }

Located at lib/meta.nix:278 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

Example

lib.meta.platformMatch usage example

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

Located at lib/meta.nix:316 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

Example

lib.meta.availableOn usage example

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

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

lib.meta.licensesSpdx

Mapping of SPDX ID to the attributes in lib.licenses.

For SPDX IDs, see https://spdx.org/licenses. Note that some SPDX licenses might be missing.

Examples

Example

lib.meta.licensesSpdx usage example

lib.licensesSpdx.MIT == lib.licenses.mit
=> true
lib.licensesSpdx."MY LICENSE"
=> error: attribute 'MY LICENSE' missing

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

lib.meta.getLicenseFromSpdxId

Get the corresponding attribute in lib.licenses from the SPDX ID or warn and fallback to { shortName = <license string>; }.

For SPDX IDs, see https://spdx.org/licenses. Note that some SPDX licenses might be missing.

Type

getLicenseFromSpdxId :: String -> {
  deprecated :: Bool;
  free :: Bool;
  fullName :: String;
  redistributable :: Bool;
  shortName :: String;
  spdxId :: String;
  url :: String;
}

Examples

Example

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:432 in <nixpkgs>.

lib.meta.getLicenseFromSpdxIdOr

Get the corresponding attribute in lib.licenses from the SPDX ID or fallback to the given default value.

For SPDX IDs, see https://spdx.org/licenses. Note that some SPDX licenses might be missing.

Inputs

licstr : 1. SPDX ID string to find a matching license

default : 2. Fallback value when a match is not found

Type

getLicenseFromSpdxIdOr :: String -> a -> ({
  deprecated :: Bool;
  free :: Bool;
  fullName :: String;
  redistributable :: Bool;
  shortName :: String;
  spdxId :: String;
  url :: String;
} | a)

Examples

Example

lib.meta.getLicenseFromSpdxIdOr usage example

lib.getLicenseFromSpdxIdOr "MIT" null == lib.licenses.mit
=> true
lib.getLicenseFromSpdxId "mIt" null == lib.licenses.mit
=> true
lib.getLicenseFromSpdxIdOr "MY LICENSE" lib.licenses.free == lib.licenses.free
=> true
lib.getLicenseFromSpdxIdOr "MY LICENSE" null
=> null
lib.getLicenseFromSpdxIdOr "MY LICENSE" (throw "No SPDX ID matches MY LICENSE")
=> error: No SPDX ID matches MY LICENSE

Located at lib/meta.nix:488 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 :: Derivation -> StorePath

Examples

Example

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:525 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 -> StorePath

Examples

Example

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:571 in <nixpkgs>.

lib.meta.cpeFullVersionWithVendor

Generate CPE parts from inputs. Copies vendor and version to the output, and sets update to *.

Inputs

vendor

package's vendor

version

package's version

Type

cpeFullVersionWithVendor :: String -> String -> { update :: String; vendor :: String; version :: String; }

Examples

Example

lib.meta.cpeFullVersionWithVendor usage example

lib.meta.cpeFullVersionWithVendor "gnu" "1.2.3"
=> {
  vendor = "gnu";
  version = "1.2.3";
  update = "*";
}

Example

lib.meta.cpeFullVersionWithVendor usage in derivations

mkDerivation rec {
  version = "1.2.3";
  # ...
  meta = {
    # ...
    identifiers.cpeParts = lib.meta.cpeFullVersionWithVendor "gnu" version;
  };
}

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