- Fork http://github.com/NixOS/nixpkgs
$ git clone --depth 1 https://github.com/<user>/nixpkgs
$ git branch -c <pkgname>
$ git checkout <pkgname>
- Not yet a maintainer?
- Add yourself to
nixpkgs/maintainers/maintainer-list.nix
- This will be a seperate commit from the packages
$ git commit -m "maintainers: add <user>"
- Find an appropriate location in
nixpkgs/pkgs/
$ mkdir <pkgsname>
$ touch <pkgsname>/default.nix
- Add the package to
nixpkgs/pkgs/top-level/
- Generic:
all-packages.nix
- Kernel:
linux-kernels.nix
- etc..
- Generic:
- In these modules you will create the options to set up the package in a system
$ touch nixpkgs/nixos/<subdir>/<pkgname>.nix
- Add module to
nixpkgs/nixos/modules/module-list.nix
Inside nixpkgs
$ nix-build -A <pkgsname>
$ ./result/bin/<pkgsname>
Recommended to do in virtual machine
- Add new package and/or module to general config
/etc/nixos/configuration.nix
$ sudo nixos-rebuild -I nixpkgs=$PWD switch
- Just find the package in the repo and edit
- Personally I use
$ grep -Frwl <pkgname>
to quickly find the package innixpkgs/pkgs/
- See paragraph packaging-maintainer. If you are not a maintainer yet, add yourself to the list and commit.
- Before committing, read https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md. Make needed changes.
- New package
$ git commit -m "<pkgsname>: init at <version>"
$ git push origin <branch (pkgsname)>
- Move to your github repo
- Create pull-request
- If changes are required, add new commits.
- When done, squash commits.
$ git rebase -i HEAD~<# prev commits>
- change
pick
tosquash
on all commits that need to be squash to initial commit. - change title at the top of next menu if needed. You can uncomment all other commit titles.
$ git push -f origin <branch (pkgsname)
- change
- After a merge to master, you can delete the branch.
- Propagation to nixos-unstable from master can take a while (multiple days). Sit back and relax!