Nixpkgs: Difference between revisions

From NixOS Wiki
imported>Profpatsch
m Crosslink to the git article
m link to on-wiki foundation page
 
(17 intermediate revisions by 9 users not shown)
Line 1: Line 1:
'''Nixpkgs''' is the largest repository of [[Nix]] packages and [[NixOS]] modules. The repository is [https://github.com/nixos/nixpkgs hosted on GitHub] and maintained by the community, with official backing from the [https://nixos.org NixOS Foundation].
'''Nixpkgs''' is the largest repository of [[Nix]] packages and [[NixOS]] modules. The repository is [https://github.com/nixos/nixpkgs hosted on GitHub] and maintained by the community, with official backing from the [[NixOS Foundation]].


== Channels ==
To search among available packages and options, see [[Searching packages]].
{{main|Nix Channels}}


The packages and modules hosted on Nixpkgs are sorted in various channels intended for various use-cases, and in practice are differentiated by the level of testing updates must pass on the official [https://nixos.org/hydra/manual/#idm140737315980672 nixos.org hydra instance] and the number of updates propagated to the channel.
As highlighted in [https://nixos.org/blog/announcements.html#21.05  the announcement] of the NixOS 21.05 release, ''"NixOS is already known as [https://repology.org/repositories/statistics/newest the most up to date distribution] and is [https://repology.org/repositories/statistics/total in the top three by total number of packages]."'' This is thanks to the community's continued dedication to making Nixpkgs the preeminent Linux package repository.


For [[Nix]] users, <code>nixpkgs-unstable</code> is the bleeding-edge, where packages pass only basic build tests and are upgraded continuously.
== Subpages ==


For [[NixOS]] users, <code>nixos-unstable</code> is the bleeding-edge, where packages pass build tests and integration tests on a VM, and are tested from the perspective of being an operative system (this means things like the X server, KDE, various servers, and lower level details like installing bootloaders and runnning the nixos installation steps are also tested).
There are a number of articles especially related to working with <tt>nixpkgs</tt>:
 
{{Special:PrefixIndex/{{FULLPAGENAME}}/ |hideredirects=1 |stripprefix=1}}
Both [[Nix]] and [[NixOS]] users can use stable channels - the latest being <code>nixos-18.03</code> - to receive only conservative updates for fixing critical bugs and security vulnerabilities.
 
For more information on channels and how to select the appropriate channel for your purposes, see the [[Nix Channels]] article.
 
== Contributing ==
 
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 nixpkgs issue-tracker [https://github.com/nixos/nixpkgs/issues 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 [[Contributing to Nixpkgs|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.
== Releases ==


Here's how to create a pull request on GitHub:
{{main|Channel branches}}


==== Fork Nixpkgs on Github ====
The packages and modules hosted on Nixpkgs are distributed through various [[channel branches]] intended for particular use-cases. In practice they are differentiated by the level of testing updates must pass on the official [https://nixos.org/hydra/manual/#idm140737315980672 nixos.org Hydra instance] and the number of updates they receive.


Create a GitHub account and fork nixpkgs/nixos/... repository.  
For [[NixOS]] users, <code>nixos-unstable</code> channel branch is the rolling release, where packages pass build tests and integration tests on a VM, and are tested from the perspective of being an operative system (this means things like the X server, KDE, various servers, and lower level details like installing bootloaders and runnning the NixOS installation steps are also tested).


==== Add a remote ====
For standalone [[Nix]] users, <code>nixpkgs-unstable</code> channel branch is the rolling release, where packages pass only basic build tests and are upgraded continuously.


On your host, create a new remote location:
Both [[NixOS]] and [[Nix]] users can use stable channel branches - the latest being {{nixos:latest}} - to receive only conservative updates for fixing critical bugs and security vulnerabilities. Stable channel branches are released bi-annually at the end of May and the end of November.  
<syntaxhighlight lang="bash">
# add your github clone as remote location:
YOUR_GITHUB_NAME=fill-in
git remote add $YOUR_GITHUB_NAME git@github.com:$YOUR_GITHUB_NAME/nixpkgs.git
</syntaxhighlight>


==== Hack Nixpkgs ====
Using stable channels on NixOS is comparable to the user experience on other Linux distributions.  
 
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>
 
The output of your build will be located under the <code>result/</code> subdirectory. Try running the freshly built binaries in <code>result/bin</code> and check that everything is OK.
 
To test the changes on a NixOS machine, rebuild the system using your newly hacked Nixpkgs by executing:
 
<syntaxhighlight lang="bash">
sudo nixos-rebuild switch -I nixpkgs=/path/to/local/nixpkgs
</syntaxhighlight>
 
==== Commit your change locally ====
 
Commit your change to your local clone of the repository:
<syntaxhighlight lang="bash">
git add FILE_LIST # use git add --patch as needed
git commit
 
==== Check status ====
 
Verify everything is ok - no unexpected dangling files git does not know about yet:
git status
</syntaxhighlight>
 
==== Push to your remote repository ====
 
Submitting your change, push to your repository:
 
<syntaxhighlight lang="bash">
# recommended: create a topic branch, so that this change
# can be submitted independently from other patches:
git checkout -tb submit/your-topic-name
git push $YOUR_GITHUB_NAME submit/your-topic-name
</syntaxhighlight>
 
Why create your own branch? You can follow upstream (master) by running <code>git merge master</code>.
You can <code>git commit --amend</code> fixes and <code>git push -f</code> your branch.
You can always switch back to master by <code>git checkout master</code>.
 
==== Create a pull request on GitHub ====
 
Go to [https://github.com/nixos/nixpkgs the Nixpkgs repository] and push the ''create pull request'' button. Add a description of your work and submit.
 
==== 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 ===
 
There are two types of maintainer: Members of the NixOS organization and package/module maintainer.
 
Members of the NixOS organization have direct access to the [https://github.com/Nixos/nixpkgs nixpkgs] and therefore can merge [[Create-pull-requests|pull requests]].
 
Everybody can become a package maintainer by adding to <code>maintainers</code> attribute in the meta section of a package. First add your nick handle (preferable your GitHub username) to [https://github.com/NixOS/nixpkgs/blob/master/maintainers/maintainer-list.nix maintainer-list.nix] and reference the said handle within the package:
 
<syntaxhighlight lang="nix">{ stdenv, fetchurl }:
stdenv.mkDerivation rec {
  name = "hello-2.10";
  # ....
  meta = with stdenv.lib; {
    # ...
    maintainers = with maintainers; [ eelco your-nick ]; # replace your-nick with your real nick
    platforms = platforms.all;
  };
}</syntaxhighlight>
There can be multiple maintainers per package. Maintainers will receive emails from [[Hydra|Hydra]] when package builds enters a failed state. They do not have special privileges as everybody can suggest updates and modifications to any package. However they might be consulted by NixOS members for testing and as a domain experts, when somebody else make a change to a package.


== Alternatives ==
== Alternatives ==
Due to the fact that nixpkgs is ''only'' a nix expression it is possible to extend or replace the logic with your own sources.
In fact, there are a number of extensions as well as complete replacements for '''Nixpkgs''', see the [[Alternative Package Sets]] article.
== Subpages ==
There are a number of articles especially related to working with <tt>nixpkgs</tt>:
{{Special:PrefixIndex/{{FULLPAGENAME}}/ |hideredirects=1 |stripprefix=1}}


Due to the fact that Nixpkgs is ''only'' a Nix expression, it is possible to extend or replace the logic with your own sources.
In fact, there are a number of extensions as well as complete replacements for Nixpkgs, see the [[Alternative Package Sets]] article.


[[Category:Discussion]]
[[Category:Pedias]]
[[Category:Nixpkgs]]
[[Category:Nixpkgs]]
[[Category:Nix]]
[[Category:Software]]

Latest revision as of 21:00, 22 June 2024

Nixpkgs is the largest repository of Nix packages and NixOS modules. The repository is hosted on GitHub and maintained by the community, with official backing from the NixOS Foundation.

To search among available packages and options, see Searching packages.

As highlighted in the announcement of the NixOS 21.05 release, "NixOS is already known as the most up to date distribution and is in the top three by total number of packages." This is thanks to the community's continued dedication to making Nixpkgs the preeminent Linux package repository.

Subpages

There are a number of articles especially related to working with nixpkgs:

Releases

Main article: Channel branches

The packages and modules hosted on Nixpkgs are distributed through various channel branches intended for particular use-cases. In practice they are differentiated by the level of testing updates must pass on the official nixos.org Hydra instance and the number of updates they receive.

For NixOS users, nixos-unstable channel branch is the rolling release, where packages pass build tests and integration tests on a VM, and are tested from the perspective of being an operative system (this means things like the X server, KDE, various servers, and lower level details like installing bootloaders and runnning the NixOS installation steps are also tested).

For standalone Nix users, nixpkgs-unstable channel branch is the rolling release, where packages pass only basic build tests and are upgraded continuously.

Both NixOS and Nix users can use stable channel branches - the latest being nixos-23.11 - to receive only conservative updates for fixing critical bugs and security vulnerabilities. Stable channel branches are released bi-annually at the end of May and the end of November.

Using stable channels on NixOS is comparable to the user experience on other Linux distributions.

Alternatives

Due to the fact that Nixpkgs is only a Nix expression, it is possible to extend or replace the logic with your own sources. In fact, there are a number of extensions as well as complete replacements for Nixpkgs, see the Alternative Package Sets article.