Nixpkgs/Contributing: Difference between revisions
imported>Milahu + Run tests locally |
No edit summary |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Development in NixOS primarily driven by the work in [https://github.com/nixos/nixpkgs nixpkgs on GitHub]. This repository contains both all packages available in your NixOS channel and all the options you can use for configuring your system with your <code>configuration.nix</code>. To get your text editor to recognize Nix expressions, consider installing a Nix [[Editor Modes for Nix Files]]. | Development in NixOS primarily driven by the work in [https://github.com/nixos/nixpkgs nixpkgs on GitHub]. This repository contains both all packages available in your NixOS channel and all the options you can use for configuring your system with your <code>configuration.nix</code>. To get your text editor to recognize Nix expressions, consider installing a Nix [[Editor Modes for Nix Files]]. | ||
== Report issues == | |||
Any issue can be reported in the [https://github.com/nixos/nixpkgs/issues nixpkgs issue tracker] on GitHub. Keep in mind that all work on nixpkgs is being done by volunteers and you cannot expect a quick response and solution for all problems you may face. In general Pull Requests have a much shorter round-trip-time. | Any issue can be reported in the [https://github.com/nixos/nixpkgs/issues nixpkgs issue tracker] on GitHub. Keep in mind that all work on nixpkgs is being done by volunteers and you cannot expect a quick response and solution for all problems you may face. In general Pull Requests have a much shorter round-trip-time. | ||
== Create pull requests == | |||
If you want to see your package being provided by a channel, creating an issue will most likely not enough. It is up to you to create a nix package description in Nixpkgs and create a pull request in the Nixpkgs repository. Pull requests are a way to tell a GitHub project that you've created some changes, which maintainers can easily review, comment on and, and finally merge into the repository. | |||
See [https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#how-to-create-pull-requests How to create pull requests] in nixpkgs CONTRIBUTING.md. | |||
=== Hack Nixpkgs === | |||
Make any modifications you want to your local copy of the repository, then build the package from the root of the <code>nixpkgs</code> directory with: <syntaxhighlight lang="bash">nix-build -A $yourpackage</syntaxhighlight> | Make any modifications you want to your local copy of the repository, then build the package from the root of the <code>nixpkgs</code> directory with: <syntaxhighlight lang="bash">nix-build -A $yourpackage</syntaxhighlight> | ||
Line 38: | Line 23: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Run tests locally === | |||
Pushing commits to Github will run tests on Github.<br> | Pushing commits to Github will run tests on Github.<br> | ||
Line 77: | Line 49: | ||
* [https://github.com/NixOS/ofborg#how-does-ofborg-call-nix-build ofborg-eval] will call <code>nix-build -A $yourpackage</code> | * [https://github.com/NixOS/ofborg#how-does-ofborg-call-nix-build ofborg-eval] will call <code>nix-build -A $yourpackage</code> | ||
==== | ==== Called without required argument ==== | ||
This error is produced by <code>nixpkgs-basic-release-checks</code> (Basic evaluation checks) | |||
<pre> | |||
anonymous function at /path/to/your-package.nix called without required argument 'some-dependency' | |||
</pre> | |||
Usually, a dependency (some-dependency) is not available on a certain platform, | |||
for example on <code>aarch64-darwin</code> | |||
To see how other packages handle this dependency: | |||
<pre> | |||
cd nixpkgs/pkgs | |||
grep -r some-dependency | |||
# -r = --recursive | |||
</pre> | |||
===== Avoid alias ===== | |||
Solution 1: Replace alias names with the real package names. For example: | |||
* utillinux → util-linux | |||
* double_conversion → double-conversion | |||
===== Make optional ===== | |||
Solution 2: Make it an optional dependency: | |||
<pre> | |||
{ lib | |||
, stdenv | |||
, some-dependency ? null | |||
, another-dependency | |||
}: | |||
= | stdenv.mkDerivation { | ||
buildInputs = | |||
[ another-dependency ] | |||
++ lib.optionals (!stdenv.isDarwin) [ some-dependency ] | |||
# some-dependency is missing on darwin | |||
; | |||
} | |||
</pre> | |||
=== Manage your local repository === | |||
Tips & tricks for managing your <code>nixpkgs</code> checkout are kept in the [[Git#Management_of_the_nixpkgs_git_repository|page on git]]. | |||
== Becoming a Nixpkgs maintainer == | |||
See [https://github.com/NixOS/nixpkgs/tree/master/maintainers maintainers] in nixpkgs | |||
=== Building all of the packages you maintain === | === Building all of the packages you maintain === | ||
Line 141: | Line 124: | ||
git checkout master #1 | git checkout master #1 | ||
git fetch upstream | git fetch upstream | ||
git | git branch -u upstream/master | ||
</syntaxhighlight> | </syntaxhighlight> | ||
1. make sure you're on the master branch | 1. make sure you're on the master branch | ||
after the above steps you only have to <code>git pull</code> to update the master branch | |||
[https://stackoverflow.com/a/7244456 source] | [https://stackoverflow.com/a/7244456 source] | ||
[[Category:Community]] |