ark/doc/outputs/pkgs.md

55 lines
1.3 KiB
Markdown
Raw Normal View History

2021-02-14 05:38:20 +03:00
# Packages
2021-04-19 05:26:27 +03:00
Similar to [modules](./modules.md), the pkgs directory mirrors the upstream
2021-02-14 05:38:20 +03:00
[nixpkgs/pkgs][pkgs], and for the same reason; if you ever want to upstream
your package, it's as simple as dropping it into the nixpkgs/pkgs directory.
The only minor difference is that, instead of adding the `callPackage` call to
`all-packages.nix`, you just add it the the _default.nix_ in this directory,
which is defined as a simple overlay.
2021-06-03 22:25:06 +03:00
All the packages are exported via `packages.<system>.<pkg-name>`, for all
2021-02-14 05:38:20 +03:00
the supported systems listed in the package's `meta.platforms` attribute.
And, as usual, every package in the overlay is also available to any NixOS
2021-04-19 05:26:27 +03:00
[host](../concepts/hosts.md).
2021-02-14 05:38:20 +03:00
## Example
pkgs/development/libraries/libinih/default.nix:
```nix
{ stdenv, meson, ninja, lib, srcs, ... }:
let inherit (srcs) libinih; in
2021-02-14 05:38:20 +03:00
stdenv.mkDerivation {
pname = "libinih";
# version will resolve to 53, as specified in the final example below
inherit (libinih) version;
2021-02-14 05:38:20 +03:00
src = libinih;
2021-02-14 05:38:20 +03:00
buildInputs = [ meson ninja ];
2021-02-14 05:38:20 +03:00
# ...
2021-02-14 05:38:20 +03:00
}
```
pkgs/default.nix:
```nix
final: prev: {
libinih = prev.callPackage ./development/libraries/libinih { };
}
```
pkgs/flake.nix:
```nix
{
description = "Package sources";
inputs = {
libinih.url = "github:benhoyt/inih/r53";
libinih.flake = false;
};
}
```
2021-02-14 05:38:20 +03:00
[pkgs]: https://github.com/NixOS/nixpkgs/tree/master/pkgs