commit
e1ebe378ad
@ -0,0 +1,154 @@ |
||||
"6.topic: agda": |
||||
- doc/languages-frameworks/agda.section.md |
||||
- nixos/tests/agda.nix |
||||
- pkgs/build-support/agda/**/* |
||||
- pkgs/development/libraries/agda/**/* |
||||
- pkgs/top-level/agda-packages.nix |
||||
|
||||
"6.topic: bsd": |
||||
- pkgs/os-specific/bsd/**/* |
||||
- pkgs/stdenv/freebsd/**/* |
||||
|
||||
"6.topic: cinnamon": |
||||
- pkgs/desktops/cinnamon/**/* |
||||
|
||||
"6.topic: emacs": |
||||
- nixos/modules/services/editors/emacs.nix |
||||
- nixos/modules/services/editors/emacs.xml |
||||
- nixos/tests/emacs-daemon.nix |
||||
- pkgs/applications/editors/emacs-modes/**/* |
||||
- pkgs/applications/editors/emacs/**/* |
||||
- pkgs/build-support/emacs/**/* |
||||
- pkgs/top-level/emacs-packages.nix |
||||
|
||||
"6.topic: erlang": |
||||
- doc/languages-frameworks/beam.section.md |
||||
- pkgs/development/beam-modules/**/* |
||||
- pkgs/development/interpreters/elixir/**/* |
||||
- pkgs/development/interpreters/erlang/**/* |
||||
- pkgs/development/tools/build-managers/rebar/**/* |
||||
- pkgs/development/tools/build-managers/rebar3/**/* |
||||
- pkgs/development/tools/erlang/**/* |
||||
- pkgs/top-level/beam-packages.nix |
||||
|
||||
"6.topic: fetch": |
||||
- pkgs/build-support/fetch*/**/* |
||||
|
||||
"6.topic: GNOME": |
||||
- doc/languages-frameworks/gnome.section.md |
||||
- nixos/modules/services/desktops/gnome/**/* |
||||
- nixos/modules/services/x11/desktop-managers/gnome.nix |
||||
- nixos/tests/gnome-xorg.nix |
||||
- nixos/tests/gnome.nix |
||||
- pkgs/desktops/gnome/**/* |
||||
|
||||
"6.topic: golang": |
||||
- doc/languages-frameworks/go.section.md |
||||
- pkgs/development/compilers/go/**/* |
||||
- pkgs/development/go-modules/**/* |
||||
- pkgs/development/go-packages/**/* |
||||
|
||||
"6.topic: haskell": |
||||
- doc/languages-frameworks/haskell.section.md |
||||
- maintainers/scripts/haskell/**/* |
||||
- pkgs/development/compilers/ghc/**/* |
||||
- pkgs/development/haskell-modules/**/* |
||||
- pkgs/development/tools/haskell/**/* |
||||
- pkgs/test/haskell/**/* |
||||
- pkgs/top-level/haskell-packages.nix |
||||
- pkgs/top-level/release-haskell.nix |
||||
|
||||
"6.topic: kernel": |
||||
- pkgs/build-support/kernel/**/* |
||||
- pkgs/os-specific/linux/kernel/**/* |
||||
|
||||
"6.topic: lua": |
||||
- pkgs/development/interpreters/lua-5/**/* |
||||
- pkgs/development/interpreters/luajit/**/* |
||||
- pkgs/development/lua-modules/**/* |
||||
- pkgs/top-level/lua-packages.nix |
||||
|
||||
"6.topic: nixos": |
||||
- nixos/**/* |
||||
|
||||
"6.topic: ocaml": |
||||
- doc/languages-frameworks/ocaml.section.md |
||||
- pkgs/development/compilers/ocaml/**/* |
||||
- pkgs/development/compilers/reason/**/* |
||||
- pkgs/development/ocaml-modules/**/* |
||||
- pkgs/development/tools/ocaml/**/* |
||||
- pkgs/top-level/ocaml-packages.nix |
||||
|
||||
"6.topic: pantheon": |
||||
- nixos/modules/services/desktops/pantheon/**/* |
||||
- nixos/modules/services/x11/desktop-managers/pantheon.nix |
||||
- nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix |
||||
- nixos/tests/pantheon.nix |
||||
- pkgs/desktops/pantheon/**/* |
||||
|
||||
"6.topic: policy discussion": |
||||
- .github/**/* |
||||
|
||||
"6.topic: printing": |
||||
- nixos/modules/services/printing/cupsd.nix |
||||
- pkgs/misc/cups/**/* |
||||
|
||||
"6.topic: python": |
||||
- doc/languages-frameworks/python.section.md |
||||
- pkgs/development/interpreters/python/**/* |
||||
- pkgs/development/python-modules/**/* |
||||
- pkgs/top-level/python-packages.nix |
||||
|
||||
"6.topic: qt/kde": |
||||
- doc/languages-frameworks/qt.section.md |
||||
- nixos/modules/services/x11/desktop-managers/plasma5.nix |
||||
- nixos/tests/plasma5.nix |
||||
- pkgs/applications/kde/**/* |
||||
- pkgs/desktops/plasma-5/**/* |
||||
- pkgs/development/libraries/kde-frameworks/**/* |
||||
- pkgs/development/libraries/qt-5/**/* |
||||
|
||||
"6.topic: ruby": |
||||
- doc/languages-frameworks/ruby.section.md |
||||
- pkgs/development/interpreters/ruby/**/* |
||||
- pkgs/development/ruby-modules/**/* |
||||
|
||||
"6.topic: rust": |
||||
- doc/languages-frameworks/rust.section.md |
||||
- pkgs/build-support/rust/**/* |
||||
- pkgs/development/compilers/rust/**/* |
||||
|
||||
"6.topic: stdenv": |
||||
- pkgs/stdenv/**/* |
||||
|
||||
"6.topic: steam": |
||||
- pkgs/games/steam/**/* |
||||
|
||||
"6.topic: systemd": |
||||
- pkgs/os-specific/linux/systemd/**/* |
||||
- nixos/modules/system/boot/systemd*/**/* |
||||
|
||||
"6.topic: TeX": |
||||
- doc/languages-frameworks/texlive.section.md |
||||
- pkgs/tools/typesetting/tex/**/* |
||||
|
||||
"6.topic: vim": |
||||
- doc/languages-frameworks/vim.section.md |
||||
- pkgs/applications/editors/vim/**/* |
||||
- pkgs/misc/vim-plugins/**/* |
||||
|
||||
"6.topic: xfce": |
||||
- nixos/doc/manual/configuration/xfce.xml |
||||
- nixos/modules/services/x11/desktop-managers/xfce.nix |
||||
- nixos/tests/xfce.nix |
||||
- pkgs/desktops/xfce/**/* |
||||
|
||||
"8.has: changelog": |
||||
- nixos/doc/manual/release-notes/**/* |
||||
|
||||
"8.has: documentation": |
||||
- doc/**/* |
||||
- nixos/doc/**/* |
||||
|
||||
"8.has: module (update)": |
||||
- nixos/modules/**/* |
@ -0,0 +1,29 @@ |
||||
name: Backport |
||||
on: |
||||
pull_request_target: |
||||
types: [closed, labeled] |
||||
jobs: |
||||
backport: |
||||
name: Backport Pull Request |
||||
if: github.repository_owner == 'NixOS' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name)) |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
with: |
||||
# required to find all branches |
||||
fetch-depth: 0 |
||||
ref: ${{ github.event.pull_request.head.sha }} |
||||
- name: Create backport PRs |
||||
# should be kept in sync with `version` |
||||
uses: zeebe-io/backport-action@2b994724142df0774855690db56bc6308fb99ffa |
||||
with: |
||||
# Config README: https://github.com/zeebe-io/backport-action#backport-action |
||||
github_token: ${{ secrets.GITHUB_TOKEN }} |
||||
github_workspace: ${{ github.workspace }} |
||||
# should be kept in sync with `uses` |
||||
version: 2b994724142df0774855690db56bc6308fb99ffa |
||||
pull_description: |- |
||||
Bot-based backport to `${target_branch}`, triggered by a label in #${pull_number}. |
||||
|
||||
* [ ] Before merging, ensure that this backport complies with the [Criteria for Backporting](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#criteria-for-backporting-changes). |
||||
* Even as a non-commiter, if you find that it does not comply, leave a comment. |
@ -0,0 +1,20 @@ |
||||
name: Basic evaluation checks |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: |
||||
- master |
||||
- release-** |
||||
push: |
||||
branches: |
||||
- master |
||||
- release-** |
||||
jobs: |
||||
tests: |
||||
runs-on: ubuntu-latest |
||||
# we don't limit this action to only NixOS repo since the checks are cheap and useful developer feedback |
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
- uses: cachix/install-nix-action@v13 |
||||
# explicit list of supportedSystems is needed until aarch64-darwin becomes part of the trunk jobset |
||||
- run: nix-build pkgs/top-level/release.nix -A tarball.nixpkgs-basic-release-checks --arg supportedSystems '[ "aarch64-darwin" "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]' |
@ -0,0 +1,32 @@ |
||||
name: "Direct Push Warning" |
||||
on: |
||||
push: |
||||
branches: |
||||
- master |
||||
- release-** |
||||
jobs: |
||||
build: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository_owner == 'NixOS' |
||||
env: |
||||
GITHUB_SHA: ${{ github.sha }} |
||||
GITHUB_REPOSITORY: ${{ github.repository }} |
||||
steps: |
||||
- name: Check if commit is a merge commit |
||||
id: ismerge |
||||
run: | |
||||
ISMERGE=$(curl -H 'Accept: application/vnd.github.groot-preview+json' -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ env.GITHUB_REPOSITORY }}/commits/${{ env.GITHUB_SHA }}/pulls | jq -r '.[] | select(.merge_commit_sha == "${{ env.GITHUB_SHA }}") | any') |
||||
echo "::set-output name=ismerge::$ISMERGE" |
||||
# github events are eventually consistent, so wait until changes propagate to thier DB |
||||
- run: sleep 60 |
||||
if: steps.ismerge.outputs.ismerge != 'true' |
||||
- name: Warn if the commit was a direct push |
||||
if: steps.ismerge.outputs.ismerge != 'true' |
||||
uses: peter-evans/commit-comment@v1 |
||||
with: |
||||
body: | |
||||
@${{ github.actor }}, you pushed a commit directly to master/release branch |
||||
instead of going through a Pull Request. |
||||
|
||||
That's highly discouraged beyond the few exceptions listed |
||||
on https://github.com/NixOS/nixpkgs/issues/118661 |
@ -0,0 +1,19 @@ |
||||
name: "Label PR" |
||||
|
||||
on: |
||||
pull_request_target: |
||||
types: [edited, opened, synchronize, reopened] |
||||
|
||||
permissions: |
||||
contents: read |
||||
pull-requests: write |
||||
|
||||
jobs: |
||||
labels: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository_owner == 'NixOS' |
||||
steps: |
||||
- uses: actions/labeler@v3 |
||||
with: |
||||
repo-token: ${{ secrets.GITHUB_TOKEN }} |
||||
sync-labels: true |
@ -1,39 +0,0 @@ |
||||
name: "merge staging(-next)" |
||||
|
||||
on: |
||||
schedule: |
||||
# * is a special character in YAML so you have to quote this string |
||||
# Merge every 6 hours |
||||
- cron: '0 */6 * * *' |
||||
|
||||
jobs: |
||||
sync-branch: |
||||
if: github.repository == 'NixOS/nixpkgs' |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
|
||||
- name: Merge master into staging-next |
||||
uses: devmasx/merge-branch@v1.3.1 |
||||
with: |
||||
type: now |
||||
from_branch: master |
||||
target_branch: staging-next |
||||
github_token: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
- name: Merge staging-next into staging |
||||
uses: devmasx/merge-branch@v1.3.1 |
||||
with: |
||||
type: now |
||||
from_branch: staging-next |
||||
target_branch: staging |
||||
github_token: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
- name: Comment on failure |
||||
uses: peter-evans/create-or-update-comment@v1 |
||||
if: ${{ failure() }} |
||||
with: |
||||
issue-number: 105153 |
||||
body: | |
||||
An automatic merge [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}). |
||||
|
@ -0,0 +1,26 @@ |
||||
name: NixOS manual checks |
||||
|
||||
permissions: read-all |
||||
|
||||
on: |
||||
pull_request_target: |
||||
branches-ignore: |
||||
- 'release-**' |
||||
paths: |
||||
- 'nixos/**/*.xml' |
||||
- 'nixos/**/*.md' |
||||
|
||||
jobs: |
||||
tests: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository_owner == 'NixOS' |
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
with: |
||||
# pull_request_target checks out the base branch by default |
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge |
||||
- uses: cachix/install-nix-action@v12 |
||||
- name: Check DocBook files generated from Markdown are consistent |
||||
run: | |
||||
nixos/doc/manual/md-to-db.sh |
||||
git diff --exit-code |
@ -0,0 +1,21 @@ |
||||
name: "No channel PR" |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: |
||||
- 'nixos-**' |
||||
- 'nixpkgs-**' |
||||
|
||||
jobs: |
||||
fail: |
||||
name: "This PR is is targeting a channel branch" |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- run: | |
||||
cat <<EOF |
||||
The nixos-* and nixpkgs-* branches are pushed to by the channel |
||||
release script and should not be merged into directly. |
||||
|
||||
Please target the equivalent release-* branch or master instead. |
||||
EOF |
||||
exit 1 |
@ -0,0 +1,49 @@ |
||||
# This action periodically merges base branches into staging branches. |
||||
# This is done to |
||||
# * prevent conflicts or rather resolve them early |
||||
# * make all potential breakage happen on the staging branch |
||||
# * and make sure that all major rebuilds happen before the staging |
||||
# branch get’s merged back into its base branch. |
||||
|
||||
name: "Periodic Merges (24h)" |
||||
|
||||
|
||||
on: |
||||
schedule: |
||||
# * is a special character in YAML so you have to quote this string |
||||
# Merge every 24 hours |
||||
- cron: '0 0 * * *' |
||||
|
||||
jobs: |
||||
periodic-merge: |
||||
if: github.repository_owner == 'NixOS' |
||||
runs-on: ubuntu-latest |
||||
strategy: |
||||
# don't fail fast, so that all pairs are tried |
||||
fail-fast: false |
||||
# certain branches need to be merged in order, like master->staging-next->staging |
||||
# and disabling parallelism ensures the order of the pairs below. |
||||
max-parallel: 1 |
||||
matrix: |
||||
pairs: |
||||
- from: master |
||||
into: haskell-updates |
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} |
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} |
||||
uses: devmasx/merge-branch@v1.3.1 |
||||
with: |
||||
type: now |
||||
from_branch: ${{ matrix.pairs.from }} |
||||
target_branch: ${{ matrix.pairs.into }} |
||||
github_token: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
- name: Comment on failure |
||||
uses: peter-evans/create-or-update-comment@v1 |
||||
if: ${{ failure() }} |
||||
with: |
||||
issue-number: 105153 |
||||
body: | |
||||
Periodic merge from `${{ matrix.pairs.from }}` into `${{ matrix.pairs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}). |
@ -0,0 +1,55 @@ |
||||
# This action periodically merges base branches into staging branches. |
||||
# This is done to |
||||
# * prevent conflicts or rather resolve them early |
||||
# * make all potential breakage happen on the staging branch |
||||
# * and make sure that all major rebuilds happen before the staging |
||||
# branch get’s merged back into its base branch. |
||||
|
||||
name: "Periodic Merges (6h)" |
||||
|
||||
|
||||
on: |
||||
schedule: |
||||
# * is a special character in YAML so you have to quote this string |
||||
# Merge every 6 hours |
||||
- cron: '0 */6 * * *' |
||||
|
||||
jobs: |
||||
periodic-merge: |
||||
if: github.repository_owner == 'NixOS' |
||||
runs-on: ubuntu-latest |
||||
strategy: |
||||
# don't fail fast, so that all pairs are tried |
||||
fail-fast: false |
||||
# certain branches need to be merged in order, like master->staging-next->staging |
||||
# and disabling parallelism ensures the order of the pairs below. |
||||
max-parallel: 1 |
||||
matrix: |
||||
pairs: |
||||
- from: master |
||||
into: staging-next |
||||
- from: staging-next |
||||
into: staging |
||||
- from: release-21.05 |
||||
into: staging-next-21.05 |
||||
- from: staging-next-21.05 |
||||
into: staging-21.05 |
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} |
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }} |
||||
uses: devmasx/merge-branch@v1.3.1 |
||||
with: |
||||
type: now |
||||
from_branch: ${{ matrix.pairs.from }} |
||||
target_branch: ${{ matrix.pairs.into }} |
||||
github_token: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
- name: Comment on failure |
||||
uses: peter-evans/create-or-update-comment@v1 |
||||
if: ${{ failure() }} |
||||
with: |
||||
issue-number: 105153 |
||||
body: | |
||||
Periodic merge from `${{ matrix.pairs.from }}` into `${{ matrix.pairs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}). |
@ -1,134 +0,0 @@ |
||||
on: |
||||
issue_comment: |
||||
types: |
||||
- created |
||||
|
||||
# This action allows people with write access to the repo to rebase a PRs base branch |
||||
# by commenting `/rebase ${branch}` on the PR while avoiding CODEOWNER notifications. |
||||
|
||||
jobs: |
||||
rebase: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository_owner == 'NixOS' && github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') |
||||
steps: |
||||
- uses: peter-evans/create-or-update-comment@v1 |
||||
with: |
||||
comment-id: ${{ github.event.comment.id }} |
||||
reactions: eyes |
||||
- uses: scherermichael-oss/action-has-permission@1.0.6 |
||||
id: check-write-access |
||||
with: |
||||
required-permission: write |
||||
env: |
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
- name: check permissions |
||||
run: | |
||||
echo "Commenter doesn't have write access to the repo" |
||||
exit 1 |
||||
if: "! steps.check-write-access.outputs.has-permission" |
||||
- name: setup |
||||
run: | |
||||
curl "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}" 2>/dev/null >pr.json |
||||
cat <<EOF >>"$GITHUB_ENV" |
||||
CAN_MODIFY=$(jq -r '.maintainer_can_modify' pr.json) |
||||
COMMITS=$(jq -r '.commits' pr.json) |
||||
CURRENT_BASE=$(jq -r '.base.ref' pr.json) |
||||
PR_BRANCH=$(jq -r '.head.ref' pr.json) |
||||
COMMENT_BRANCH=$(echo ${{ github.event.comment.body }} | awk "/^\/rebase / {print \$2}") |
||||
PULL_REQUEST=${{ github.event.issue.number }} |
||||
EOF |
||||
rm pr.json |
||||
- name: check branch |
||||
env: |
||||
PERMANENT_BRANCHES: "haskell-updates|master|nixos|nixpkgs|python-unstable|release|staging" |
||||
VALID_BRANCHES: "haskell-updates|master|python-unstable|release-20.09|staging|staging-20.09|staging-next" |
||||
run: | |
||||
message() { |
||||
cat <<EOF |
||||
Can't rebase $PR_BRANCH from $CURRENT_BASE onto $COMMENT_BRANCH (PR:$PULL_REQUEST COMMITS:$COMMITS) |
||||
EOF |
||||
} |
||||
if ! [[ "$COMMENT_BRANCH" =~ ^($VALID_BRANCHES)$ ]]; then |
||||
cat <<EOF |
||||
Check that the branch from the comment is valid: |
||||
|
||||
$(message) |
||||
|
||||
This action can only rebase onto these branches: |
||||
|
||||
$VALID_BRANCHES |
||||
|
||||
\`/rebase \${branch}\` must be at the start of the line |
||||
EOF |
||||
exit 1 |
||||
fi |
||||
if [[ "$COMMENT_BRANCH" == "$CURRENT_BASE" ]]; then |
||||
cat <<EOF |
||||
Check that the branch from the comment isn't the current base branch: |
||||
|
||||
$(message) |
||||
EOF |
||||
exit 1 |
||||
fi |
||||
if [[ "$COMMENT_BRANCH" == "$PR_BRANCH" ]]; then |
||||
cat <<EOF |
||||
Check that the branch from the comment isn't the current branch: |
||||
|
||||
$(message) |
||||
EOF |
||||
exit 1 |
||||
fi |
||||
if [[ "$PR_BRANCH" =~ ^($PERMANENT_BRANCHES) ]]; then |
||||
cat <<EOF |
||||
Check that the PR branch isn't a permanent branch: |
||||
|
||||
$(message) |
||||
EOF |
||||
exit 1 |
||||
fi |
||||
if [[ "$CAN_MODIFY" != "true" ]]; then |
||||
cat <<EOF |
||||
Check that maintainers can edit the PR branch: |
||||
|
||||
$(message) |
||||
EOF |
||||
exit 1 |
||||
fi |
||||
- uses: actions/checkout@v2 |
||||
with: |
||||
fetch-depth: 0 |
||||
- name: rebase pull request |
||||
env: |
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
run: | |
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
||||
git config --global user.name "github-actions[bot]" |
||||
git fetch origin |
||||
gh pr checkout "$PULL_REQUEST" |
||||
git rebase \ |
||||
--onto="$(git merge-base origin/"$CURRENT_BASE" origin/"$COMMENT_BRANCH")" \ |
||||
"HEAD~$COMMITS" |
||||
git push --force |
||||
curl \ |
||||
-X POST \ |
||||
-H "Accept: application/vnd.github.v3+json" \ |
||||
-H "Authorization: token $GITHUB_TOKEN" \ |
||||
-d "{ \"base\": \"$COMMENT_BRANCH\" }" \ |
||||
"https://api.github.com/repos/${{ github.repository }}/pulls/$PULL_REQUEST" |
||||
curl \ |
||||
-X PATCH \ |
||||
-H "Accept: application/vnd.github.v3+json" \ |
||||
-H "Authorization: token $GITHUB_TOKEN" \ |
||||
-d '{ "state": "closed" }' \ |
||||
"https://api.github.com/repos/${{ github.repository }}/pulls/$PULL_REQUEST" |
||||
- uses: peter-evans/create-or-update-comment@v1 |
||||
with: |
||||
issue-number: ${{ github.event.issue.number }} |
||||
body: | |
||||
Rebased, please reopen the pull request to restart CI |
||||
- uses: peter-evans/create-or-update-comment@v1 |
||||
if: failure() |
||||
with: |
||||
issue-number: ${{ github.event.issue.number }} |
||||
body: | |
||||
[Failed to rebase](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
@ -1 +1 @@ |
||||
21.05 |
||||
21.11 |
@ -0,0 +1,12 @@ |
||||
|
||||
# Nixpkgs/doc |
||||
|
||||
This directory houses the sources files for the Nixpkgs manual. |
||||
|
||||
You can find the [rendered documentation for Nixpkgs `unstable` on nixos.org](https://nixos.org/manual/nixpkgs/unstable/). |
||||
|
||||
[Docs for Nixpkgs stable](https://nixos.org/manual/nixpkgs/stable/) are also available. |
||||
|
||||
If you want to contribute to the documentation, [here's how to do it](https://nixos.org/manual/nixpkgs/unstable/#chap-contributing). |
||||
|
||||
If you're only getting started with Nix, go to [nixos.org/learn](https://nixos.org/learn). |
@ -0,0 +1,48 @@ |
||||
# pkgs.appimageTools {#sec-pkgs-appimageTools} |
||||
|
||||
`pkgs.appimageTools` is a set of functions for extracting and wrapping [AppImage](https://appimage.org/) files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, `pkgs.appimage-run` can be used as well. |
||||
|
||||
::: {.warning} |
||||
The `appimageTools` API is unstable and may be subject to backwards-incompatible changes in the future. |
||||
::: |
||||
|
||||
## AppImage formats {#ssec-pkgs-appimageTools-formats} |
||||
|
||||
There are different formats for AppImages, see [the specification](https://github.com/AppImage/AppImageSpec/blob/74ad9ca2f94bf864a4a0dac1f369dd4f00bd1c28/draft.md#image-format) for details. |
||||
|
||||
- Type 1 images are ISO 9660 files that are also ELF executables. |
||||
- Type 2 images are ELF executables with an appended filesystem. |
||||
|
||||
They can be told apart with `file -k`: |
||||
|
||||
```ShellSession |
||||
$ file -k type1.AppImage |
||||
type1.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) ISO 9660 CD-ROM filesystem data 'AppImage' (Lepton 3.x), scale 0-0, |
||||
spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=d629f6099d2344ad82818172add1d38c5e11bc6d, stripped\012- data |
||||
|
||||
$ file -k type2.AppImage |
||||
type2.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) (Lepton 3.x), scale 232-60668, spot sensor temperature -4.187500, color scheme 15, show scale bar, calibration: offset -0.000000, slope 0.000000 (Lepton 2.x), scale 4111-45000, spot sensor temperature 412442.250000, color scheme 3, minimum point enabled, calibration: offset -75402534979642766821519867692934234112.000000, slope 5815371847733706829839455140374904832.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=79dcc4e55a61c293c5e19edbd8d65b202842579f, stripped\012- data |
||||
``` |
||||
|
||||
Note how the type 1 AppImage is described as an `ISO 9660 CD-ROM filesystem`, and the type 2 AppImage is not. |
||||
|
||||
## Wrapping {#ssec-pkgs-appimageTools-wrapping} |
||||
|
||||
Depending on the type of AppImage you're wrapping, you'll have to use `wrapType1` or `wrapType2`. |
||||
|
||||
```nix |
||||
appimageTools.wrapType2 { # or wrapType1 |
||||
name = "patchwork"; |
||||
src = fetchurl { |
||||
url = "https://github.com/ssbc/patchwork/releases/download/v3.11.4/Patchwork-3.11.4-linux-x86_64.AppImage"; |
||||
sha256 = "1blsprpkvm0ws9b96gb36f0rbf8f5jgmw4x6dsb1kswr4ysf591s"; |
||||
}; |
||||
extraPkgs = pkgs: with pkgs; [ ]; |
||||
} |
||||
``` |
||||
|
||||
- `name` specifies the name of the resulting image. |
||||
- `src` specifies the AppImage file to extract. |
||||
- `extraPkgs` allows you to pass a function to include additional packages inside the FHS environment your AppImage is going to run in. There are a few ways to learn which dependencies an application needs: |
||||
- Looking through the extracted AppImage files, reading its scripts and running `patchelf` and `ldd` on its executables. This can also be done in `appimage-run`, by setting `APPIMAGE_DEBUG_EXEC=bash`. |
||||
- Running `strace -vfefile` on the wrapped executable, looking for libraries that can't be found. |
@ -1,102 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
xml:id="sec-pkgs-appimageTools"> |
||||
<title>pkgs.appimageTools</title> |
||||
|
||||
<para> |
||||
<varname>pkgs.appimageTools</varname> is a set of functions for extracting and wrapping <link xlink:href="https://appimage.org/">AppImage</link> files. They are meant to be used if traditional packaging from source is infeasible, or it would take too long. To quickly run an AppImage file, <literal>pkgs.appimage-run</literal> can be used as well. |
||||
</para> |
||||
|
||||
<warning> |
||||
<para> |
||||
The <varname>appimageTools</varname> API is unstable and may be subject to backwards-incompatible changes in the future. |
||||
</para> |
||||
</warning> |
||||
|
||||
<section xml:id="ssec-pkgs-appimageTools-formats"> |
||||
<title>AppImage formats</title> |
||||
|
||||
<para> |
||||
There are different formats for AppImages, see <link xlink:href="https://github.com/AppImage/AppImageSpec/blob/74ad9ca2f94bf864a4a0dac1f369dd4f00bd1c28/draft.md#image-format">the specification</link> for details. |
||||
</para> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Type 1 images are ISO 9660 files that are also ELF executables. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Type 2 images are ELF executables with an appended filesystem. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
|
||||
<para> |
||||
They can be told apart with <command>file -k</command>: |
||||
</para> |
||||
|
||||
<screen> |
||||
<prompt>$ </prompt>file -k type1.AppImage |
||||
type1.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) ISO 9660 CD-ROM filesystem data 'AppImage' (Lepton 3.x), scale 0-0, |
||||
spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=d629f6099d2344ad82818172add1d38c5e11bc6d, stripped\012- data |
||||
|
||||
<prompt>$ </prompt>file -k type2.AppImage |
||||
type2.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) (Lepton 3.x), scale 232-60668, spot sensor temperature -4.187500, color scheme 15, show scale bar, calibration: offset -0.000000, slope 0.000000 (Lepton 2.x), scale 4111-45000, spot sensor temperature 412442.250000, color scheme 3, minimum point enabled, calibration: offset -75402534979642766821519867692934234112.000000, slope 5815371847733706829839455140374904832.000000, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=79dcc4e55a61c293c5e19edbd8d65b202842579f, stripped\012- data |
||||
</screen> |
||||
|
||||
<para> |
||||
Note how the type 1 AppImage is described as an <literal>ISO 9660 CD-ROM filesystem</literal>, and the type 2 AppImage is not. |
||||
</para> |
||||
</section> |
||||
|
||||
<section xml:id="ssec-pkgs-appimageTools-wrapping"> |
||||
<title>Wrapping</title> |
||||
|
||||
<para> |
||||
Depending on the type of AppImage you're wrapping, you'll have to use <varname>wrapType1</varname> or <varname>wrapType2</varname>. |
||||
</para> |
||||
|
||||
<programlisting> |
||||
appimageTools.wrapType2 { # or wrapType1 |
||||
name = "patchwork"; <co xml:id='ex-appimageTools-wrapping-1' /> |
||||
src = fetchurl { <co xml:id='ex-appimageTools-wrapping-2' /> |
||||
url = "https://github.com/ssbc/patchwork/releases/download/v3.11.4/Patchwork-3.11.4-linux-x86_64.AppImage"; |
||||
sha256 = "1blsprpkvm0ws9b96gb36f0rbf8f5jgmw4x6dsb1kswr4ysf591s"; |
||||
}; |
||||
extraPkgs = pkgs: with pkgs; [ ]; <co xml:id='ex-appimageTools-wrapping-3' /> |
||||
}</programlisting> |
||||
|
||||
<calloutlist> |
||||
<callout arearefs='ex-appimageTools-wrapping-1'> |
||||
<para> |
||||
<varname>name</varname> specifies the name of the resulting image. |
||||
</para> |
||||
</callout> |
||||
<callout arearefs='ex-appimageTools-wrapping-2'> |
||||
<para> |
||||
<varname>src</varname> specifies the AppImage file to extract. |
||||
</para> |
||||
</callout> |
||||
<callout arearefs='ex-appimageTools-wrapping-3'> |
||||
<para> |
||||
<varname>extraPkgs</varname> allows you to pass a function to include additional packages inside the FHS environment your AppImage is going to run in. There are a few ways to learn which dependencies an application needs: |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Looking through the extracted AppImage files, reading its scripts and running <command>patchelf</command> and <command>ldd</command> on its executables. This can also be done in <command>appimage-run</command>, by setting <command>APPIMAGE_DEBUG_EXEC=bash</command>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Running <command>strace -vfefile</command> on the wrapped executable, looking for libraries that can't be found. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</para> |
||||
</callout> |
||||
</calloutlist> |
||||
</section> |
||||
</section> |
@ -0,0 +1,37 @@ |
||||
# pkgs.ociTools {#sec-pkgs-ociTools} |
||||
|
||||
`pkgs.ociTools` is a set of functions for creating containers according to the [OCI container specification v1.0.0](https://github.com/opencontainers/runtime-spec). Beyond that it makes no assumptions about the container runner you choose to use to run the created container. |
||||
|
||||
## buildContainer {#ssec-pkgs-ociTools-buildContainer} |
||||
|
||||
This function creates a simple OCI container that runs a single command inside of it. An OCI container consists of a `config.json` and a rootfs directory.The nix store of the container will contain all referenced dependencies of the given command. |
||||
|
||||
The parameters of `buildContainer` with an example value are described below: |
||||
|
||||
```nix |
||||
buildContainer { |
||||
args = [ |
||||
(with pkgs; |
||||
writeScript "run.sh" '' |
||||
#!${bash}/bin/bash |
||||
exec ${bash}/bin/bash |
||||
'').outPath |
||||
]; |
||||
|
||||
mounts = { |
||||
"/data" = { |
||||
type = "none"; |
||||
source = "/var/lib/mydata"; |
||||
options = [ "bind" ]; |
||||
}; |
||||
}; |
||||
|
||||
readonly = false; |
||||
} |
||||
``` |
||||
|
||||
- `args` specifies a set of arguments to run inside the container. This is the only required argument for `buildContainer`. All referenced packages inside the derivation will be made available inside the container |
||||
|
||||
- `mounts` specifies additional mount points chosen by the user. By default only a minimal set of necessary filesystems are mounted into the container (e.g procfs, cgroupfs) |
||||
|
||||
- `readonly` makes the container\'s rootfs read-only if it is set to true. The default value is false `false`. |
@ -1,61 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
xml:id="sec-pkgs-ociTools"> |
||||
<title>pkgs.ociTools</title> |
||||
|
||||
<para> |
||||
<varname>pkgs.ociTools</varname> is a set of functions for creating containers according to the <link xlink:href="https://github.com/opencontainers/runtime-spec">OCI container specification v1.0.0</link>. Beyond that it makes no assumptions about the container runner you choose to use to run the created container. |
||||
</para> |
||||
|
||||
<section xml:id="ssec-pkgs-ociTools-buildContainer"> |
||||
<title>buildContainer</title> |
||||
|
||||
<para> |
||||
This function creates a simple OCI container that runs a single command inside of it. An OCI container consists of a <varname>config.json</varname> and a rootfs directory.The nix store of the container will contain all referenced dependencies of the given command. |
||||
</para> |
||||
|
||||
<para> |
||||
The parameters of <varname>buildContainer</varname> with an example value are described below: |
||||
</para> |
||||
|
||||
<example xml:id='ex-ociTools-buildContainer'> |
||||
<title>Build Container</title> |
||||
<programlisting> |
||||
buildContainer { |
||||
args = [ (with pkgs; writeScript "run.sh" '' |
||||
#!${bash}/bin/bash |
||||
exec ${bash}/bin/bash |
||||
'').outPath ]; <co xml:id='ex-ociTools-buildContainer-1' /> |
||||
|
||||
mounts = { |
||||
"/data" = { |
||||
type = "none"; |
||||
source = "/var/lib/mydata"; |
||||
options = [ "bind" ]; |
||||
}; |
||||
};<co xml:id='ex-ociTools-buildContainer-2' /> |
||||
|
||||
readonly = false; <co xml:id='ex-ociTools-buildContainer-3' /> |
||||
} |
||||
</programlisting> |
||||
<calloutlist> |
||||
<callout arearefs='ex-ociTools-buildContainer-1'> |
||||
<para> |
||||
<varname>args</varname> specifies a set of arguments to run inside the container. This is the only required argument for <varname>buildContainer</varname>. All referenced packages inside the derivation will be made available inside the container |
||||
</para> |
||||
</callout> |
||||
<callout arearefs='ex-ociTools-buildContainer-2'> |
||||
<para> |
||||
<varname>mounts</varname> specifies additional mount points chosen by the user. By default only a minimal set of necessary filesystems are mounted into the container (e.g procfs, cgroupfs) |
||||
</para> |
||||
</callout> |
||||
<callout arearefs='ex-ociTools-buildContainer-3'> |
||||
<para> |
||||
<varname>readonly</varname> makes the container's rootfs read-only if it is set to true. The default value is false <literal>false</literal>. |
||||
</para> |
||||
</callout> |
||||
</calloutlist> |
||||
</example> |
||||
</section> |
||||
</section> |
@ -1,28 +0,0 @@ |
||||
let |
||||
inherit (import <nixpkgs> { }) snapTools firefox; |
||||
in snapTools.makeSnap { |
||||
meta = { |
||||
name = "nix-example-firefox"; |
||||
summary = firefox.meta.description; |
||||
architectures = [ "amd64" ]; |
||||
apps.nix-example-firefox = { |
||||
command = "${firefox}/bin/firefox"; |
||||
plugs = [ |
||||
"pulseaudio" |
||||
"camera" |
||||
"browser-support" |
||||
"avahi-observe" |
||||
"cups-control" |
||||
"desktop" |
||||
"desktop-legacy" |
||||
"gsettings" |
||||
"home" |
||||
"network" |
||||
"mount-observe" |
||||
"removable-media" |
||||
"x11" |
||||
]; |
||||
}; |
||||
confinement = "strict"; |
||||
}; |
||||
} |
@ -1,12 +0,0 @@ |
||||
let |
||||
inherit (import <nixpkgs> { }) snapTools hello; |
||||
in snapTools.makeSnap { |
||||
meta = { |
||||
name = "hello"; |
||||
summary = hello.meta.description; |
||||
description = hello.meta.longDescription; |
||||
architectures = [ "amd64" ]; |
||||
confinement = "strict"; |
||||
apps.hello.command = "${hello}/bin/hello"; |
||||
}; |
||||
} |
@ -0,0 +1,71 @@ |
||||
# pkgs.snapTools {#sec-pkgs-snapTools} |
||||
|
||||
`pkgs.snapTools` is a set of functions for creating Snapcraft images. Snap and Snapcraft is not used to perform these operations. |
||||
|
||||
## The makeSnap Function {#ssec-pkgs-snapTools-makeSnap-signature} |
||||
|
||||
`makeSnap` takes a single named argument, `meta`. This argument mirrors [the upstream `snap.yaml` format](https://docs.snapcraft.io/snap-format) exactly. |
||||
|
||||
The `base` should not be specified, as `makeSnap` will force set it. |
||||
|
||||
Currently, `makeSnap` does not support creating GUI stubs. |
||||
|
||||
## Build a Hello World Snap {#ssec-pkgs-snapTools-build-a-snap-hello} |
||||
|
||||
The following expression packages GNU Hello as a Snapcraft snap. |
||||
|
||||
``` {#ex-snapTools-buildSnap-hello .nix} |
||||
let |
||||
inherit (import <nixpkgs> { }) snapTools hello; |
||||
in snapTools.makeSnap { |
||||
meta = { |
||||
name = "hello"; |
||||
summary = hello.meta.description; |
||||
description = hello.meta.longDescription; |
||||
architectures = [ "amd64" ]; |
||||
confinement = "strict"; |
||||
apps.hello.command = "${hello}/bin/hello"; |
||||
}; |
||||
} |
||||
``` |
||||
|
||||
`nix-build` this expression and install it with `snap install ./result --dangerous`. `hello` will now be the Snapcraft version of the package. |
||||
|
||||
## Build a Graphical Snap {#ssec-pkgs-snapTools-build-a-snap-firefox} |
||||
|
||||
Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package. |
||||
|
||||
``` {#ex-snapTools-buildSnap-firefox .nix} |
||||
let |
||||
inherit (import <nixpkgs> { }) snapTools firefox; |
||||
in snapTools.makeSnap { |
||||
meta = { |
||||
name = "nix-example-firefox"; |
||||
summary = firefox.meta.description; |
||||
architectures = [ "amd64" ]; |
||||
apps.nix-example-firefox = { |
||||
command = "${firefox}/bin/firefox"; |
||||
plugs = [ |
||||
"pulseaudio" |
||||
"camera" |
||||
"browser-support" |
||||
"avahi-observe" |
||||
"cups-control" |
||||
"desktop" |
||||
"desktop-legacy" |
||||
"gsettings" |
||||
"home" |
||||
"network" |
||||
"mount-observe" |
||||
"removable-media" |
||||
"x11" |
||||
]; |
||||
}; |
||||
confinement = "strict"; |
||||
}; |
||||
} |
||||
``` |
||||
|
||||
`nix-build` this expression and install it with `snap install ./result --dangerous`. `nix-example-firefox` will now be the Snapcraft version of the Firefox package. |
||||
|
||||
The specific meaning behind plugs can be looked up in the [Snapcraft interface documentation](https://docs.snapcraft.io/supported-interfaces). |
@ -1,59 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
xml:id="sec-pkgs-snapTools"> |
||||
<title>pkgs.snapTools</title> |
||||
|
||||
<para> |
||||
<varname>pkgs.snapTools</varname> is a set of functions for creating Snapcraft images. Snap and Snapcraft is not used to perform these operations. |
||||
</para> |
||||
|
||||
<section xml:id="ssec-pkgs-snapTools-makeSnap-signature"> |
||||
<title>The makeSnap Function</title> |
||||
|
||||
<para> |
||||
<function>makeSnap</function> takes a single named argument, <parameter>meta</parameter>. This argument mirrors <link xlink:href="https://docs.snapcraft.io/snap-format">the upstream <filename>snap.yaml</filename> format</link> exactly. |
||||
</para> |
||||
|
||||
<para> |
||||
The <parameter>base</parameter> should not be be specified, as <function>makeSnap</function> will force set it. |
||||
</para> |
||||
|
||||
<para> |
||||
Currently, <function>makeSnap</function> does not support creating GUI stubs. |
||||
</para> |
||||
</section> |
||||
|
||||
<section xml:id="ssec-pkgs-snapTools-build-a-snap-hello"> |
||||
<title>Build a Hello World Snap</title> |
||||
|
||||
<example xml:id="ex-snapTools-buildSnap-hello"> |
||||
<title>Making a Hello World Snap</title> |
||||
<para> |
||||
The following expression packages GNU Hello as a Snapcraft snap. |
||||
</para> |
||||
<programlisting><xi:include href="./snap/example-hello.nix" parse="text" /></programlisting> |
||||
<para> |
||||
<command>nix-build</command> this expression and install it with <command>snap install ./result --dangerous</command>. <command>hello</command> will now be the Snapcraft version of the package. |
||||
</para> |
||||
</example> |
||||
</section> |
||||
|
||||
<section xml:id="ssec-pkgs-snapTools-build-a-snap-firefox"> |
||||
<title>Build a Hello World Snap</title> |
||||
|
||||
<example xml:id="ex-snapTools-buildSnap-firefox"> |
||||
<title>Making a Graphical Snap</title> |
||||
<para> |
||||
Graphical programs require many more integrations with the host. This example uses Firefox as an example, because it is one of the most complicated programs we could package. |
||||
</para> |
||||
<programlisting><xi:include href="./snap/example-firefox.nix" parse="text" /></programlisting> |
||||
<para> |
||||
<command>nix-build</command> this expression and install it with <command>snap install ./result --dangerous</command>. <command>nix-example-firefox</command> will now be the Snapcraft version of the Firefox package. |
||||
</para> |
||||
<para> |
||||
The specific meaning behind plugs can be looked up in the <link xlink:href="https://docs.snapcraft.io/supported-interfaces">Snapcraft interface documentation</link>. |
||||
</para> |
||||
</example> |
||||
</section> |
||||
</section> |
@ -0,0 +1,32 @@ |
||||
# Citrix Workspace {#sec-citrix} |
||||
|
||||
The [Citrix Workspace App](https://www.citrix.com/products/workspace-app/) is a remote desktop viewer which provides access to [XenDesktop](https://www.citrix.com/products/xenapp-xendesktop/) installations. |
||||
|
||||
## Basic usage {#sec-citrix-base} |
||||
|
||||
The tarball archive needs to be downloaded manually as the license agreements of the vendor for [Citrix Workspace](https://www.citrix.de/downloads/workspace-app/linux/workspace-app-for-linux-latest.html) needs to be accepted first. Then run `nix-prefetch-url file://$PWD/linuxx64-$version.tar.gz`. With the archive available in the store the package can be built and installed with Nix. |
||||
|
||||
## Citrix Selfservice {#sec-citrix-selfservice} |
||||
|
||||
The [selfservice](https://support.citrix.com/article/CTX200337) is an application managing Citrix desktops and applications. Please note that this feature only works with at least citrix_workspace_20_06_0 and later versions. |
||||
|
||||
In order to set this up, you first have to [download the `.cr` file from the Netscaler Gateway](https://its.uiowa.edu/support/article/102186). After that you can configure the `selfservice` like this: |
||||
|
||||
```ShellSession |
||||
$ storebrowse -C ~/Downloads/receiverconfig.cr |
||||
$ selfservice |
||||
``` |
||||
|
||||
## Custom certificates {#sec-citrix-custom-certs} |
||||
|
||||
The `Citrix Workspace App` in `nixpkgs` trusts several certificates [from the Mozilla database](https://curl.haxx.se/docs/caextract.html) by default. However several companies using Citrix might require their own corporate certificate. On distros with imperative packaging these certs can be stored easily in [`$ICAROOT`](https://developer-docs.citrix.com/projects/receiver-for-linux-command-reference/en/13.7/), however this directory is a store path in `nixpkgs`. In order to work around this issue the package provides a simple mechanism to add custom certificates without rebuilding the entire package using `symlinkJoin`: |
||||
|
||||
```nix |
||||
with import <nixpkgs> { config.allowUnfree = true; }; |
||||
let |
||||
extraCerts = [ |
||||
./custom-cert-1.pem |
||||
./custom-cert-2.pem # ... |
||||
]; |
||||
in citrix_workspace.override { inherit extraCerts; } |
||||
``` |
@ -1,46 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xml:id="sec-citrix"> |
||||
<title>Citrix Workspace</title> |
||||
|
||||
<para> |
||||
The <link xlink:href="https://www.citrix.com/products/workspace-app/">Citrix Workspace App</link> is a remote desktop viewer which provides access to <link xlink:href="https://www.citrix.com/products/xenapp-xendesktop/">XenDesktop</link> installations. |
||||
</para> |
||||
|
||||
<section xml:id="sec-citrix-base"> |
||||
<title>Basic usage</title> |
||||
|
||||
<para> |
||||
The tarball archive needs to be downloaded manually as the license agreements of the vendor for <link xlink:href="https://www.citrix.de/downloads/workspace-app/linux/workspace-app-for-linux-latest.html">Citrix Workspace</link> needs to be accepted first. Then run <command>nix-prefetch-url file://$PWD/linuxx64-$version.tar.gz</command>. With the archive available in the store the package can be built and installed with Nix. |
||||
</para> |
||||
</section> |
||||
|
||||
<section xml:id="sec-citrix-selfservice"> |
||||
<title>Citrix Selfservice</title> |
||||
<para> |
||||
The <link xlink:href="https://support.citrix.com/article/CTX200337">selfservice</link> is an application managing Citrix desktops and applications. Please note that this feature only works with at least <package>citrix_workspace_20_06_0</package> and later versions. |
||||
</para> |
||||
<para> |
||||
In order to set this up, you first have to <link xlink:href="https://its.uiowa.edu/support/article/102186">download the <literal>.cr</literal> file from the Netscaler Gateway</link>. After that you can configure the <command>selfservice</command> like this: |
||||
<screen> |
||||
<prompt>$ </prompt>storebrowse -C ~/Downloads/receiverconfig.cr |
||||
<prompt>$ </prompt>selfservice |
||||
</screen> |
||||
</para> |
||||
</section> |
||||
|
||||
<section xml:id="sec-citrix-custom-certs"> |
||||
<title>Custom certificates</title> |
||||
|
||||
<para> |
||||
The <literal>Citrix Workspace App</literal> in <literal>nixpkgs</literal> trusts several certificates <link xlink:href="https://curl.haxx.se/docs/caextract.html">from the Mozilla database</link> by default. However several companies using Citrix might require their own corporate certificate. On distros with imperative packaging these certs can be stored easily in <link xlink:href="https://developer-docs.citrix.com/projects/receiver-for-linux-command-reference/en/13.7/"><literal>$ICAROOT</literal></link>, however this directory is a store path in <literal>nixpkgs</literal>. In order to work around this issue the package provides a simple mechanism to add custom certificates without rebuilding the entire package using <literal>symlinkJoin</literal>: |
||||
<programlisting> |
||||
<![CDATA[with import <nixpkgs> { config.allowUnfree = true; }; |
||||
let extraCerts = [ ./custom-cert-1.pem ./custom-cert-2.pem /* ... */ ]; in |
||||
citrix_workspace.override { |
||||
inherit extraCerts; |
||||
}]]> |
||||
</programlisting> |
||||
</para> |
||||
</section> |
||||
</section> |
@ -0,0 +1,13 @@ |
||||
# DLib {#dlib} |
||||
|
||||
[DLib](http://dlib.net/) is a modern, C++-based toolkit which provides several machine learning algorithms. |
||||
|
||||
## Compiling without AVX support {#compiling-without-avx-support} |
||||
|
||||
Especially older CPUs don\'t support [AVX](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) (Advanced Vector Extensions) instructions that are used by DLib to optimize their algorithms. |
||||
|
||||
On the affected hardware errors like `Illegal instruction` will occur. In those cases AVX support needs to be disabled: |
||||
|
||||
```nix |
||||
self: super: { dlib = super.dlib.override { avxSupport = false; }; } |
||||
``` |
@ -1,24 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xml:id="dlib"> |
||||
<title>DLib</title> |
||||
|
||||
<para> |
||||
<link xlink:href="http://dlib.net/">DLib</link> is a modern, C++-based toolkit which provides several machine learning algorithms. |
||||
</para> |
||||
|
||||
<section xml:id="compiling-without-avx-support"> |
||||
<title>Compiling without AVX support</title> |
||||
|
||||
<para> |
||||
Especially older CPUs don't support <link xlink:href="https://en.wikipedia.org/wiki/Advanced_Vector_Extensions">AVX</link> (<abbrev>Advanced Vector Extensions</abbrev>) instructions that are used by DLib to optimize their algorithms. |
||||
</para> |
||||
|
||||
<para> |
||||
On the affected hardware errors like <literal>Illegal instruction</literal> will occur. In those cases AVX support needs to be disabled: |
||||
<programlisting>self: super: { |
||||
dlib = super.dlib.override { avxSupport = false; }; |
||||
}</programlisting> |
||||
</para> |
||||
</section> |
||||
</section> |
@ -0,0 +1,45 @@ |
||||
# FUSE {#sec-fuse} |
||||
|
||||
Some packages rely on |
||||
[FUSE](https://www.kernel.org/doc/html/latest/filesystems/fuse.html) to provide |
||||
support for additional filesystems not supported by the kernel. |
||||
|
||||
In general, FUSE software are primarily developed for Linux but many of them can |
||||
also run on macOS. Nixpkgs supports FUSE packages on macOS, but it requires |
||||
[macFUSE](https://osxfuse.github.io) to be installed outside of Nix. macFUSE |
||||
currently isn't packaged in Nixpkgs mainly because it includes a kernel |
||||
extension, which isn't supported by Nix outside of NixOS. |
||||
|
||||
If a package fails to run on macOS with an error message similar to the |
||||
following, it's a likely sign that you need to have macFUSE installed. |
||||
|
||||
dyld: Library not loaded: /usr/local/lib/libfuse.2.dylib |
||||
Referenced from: /nix/store/w8bi72bssv0bnxhwfw3xr1mvn7myf37x-sshfs-fuse-2.10/bin/sshfs |
||||
Reason: image not found |
||||
[1] 92299 abort /nix/store/w8bi72bssv0bnxhwfw3xr1mvn7myf37x-sshfs-fuse-2.10/bin/sshfs |
||||
|
||||
Package maintainers may often encounter the following error when building FUSE |
||||
packages on macOS: |
||||
|
||||
checking for fuse.h... no |
||||
configure: error: No fuse.h found. |
||||
|
||||
This happens on autoconf based projects that uses `AC_CHECK_HEADERS` or |
||||
`AC_CHECK_LIBS` to detect libfuse, and will occur even when the `fuse` package |
||||
is included in `buildInputs`. It happens because libfuse headers throw an error |
||||
on macOS if the `FUSE_USE_VERSION` macro is undefined. Many proejcts do define |
||||
`FUSE_USE_VERSION`, but only inside C source files. This results in the above |
||||
error at configure time because the configure script would attempt to compile |
||||
sample FUSE programs without defining `FUSE_USE_VERSION`. |
||||
|
||||
There are two possible solutions for this problem in Nixpkgs: |
||||
|
||||
1. Pass `FUSE_USE_VERSION` to the configure script by adding |
||||
`CFLAGS=-DFUSE_USE_VERSION=25` in `configureFlags`. The actual value would |
||||
have to match the definition used in the upstream source code. |
||||
2. Remove `AC_CHECK_HEADERS` / `AC_CHECK_LIBS` for libfuse. |
||||
|
||||
However, a better solution might be to fix the build script upstream to use |
||||
`PKG_CHECK_MODULES` instead. This approach wouldn't suffer from the problem that |
||||
`AC_CHECK_HEADERS`/`AC_CHECK_LIBS` has at the price of introducing a dependency |
||||
on pkg-config. |
@ -0,0 +1,38 @@ |
||||
# ibus-engines.typing-booster {#sec-ibus-typing-booster} |
||||
|
||||
This package is an ibus-based completion method to speed up typing. |
||||
|
||||
## Activating the engine {#sec-ibus-typing-booster-activate} |
||||
|
||||
IBus needs to be configured accordingly to activate `typing-booster`. The configuration depends on the desktop manager in use. For detailed instructions, please refer to the [upstream docs](https://mike-fabian.github.io/ibus-typing-booster/documentation.html). |
||||
|
||||
On NixOS you need to explicitly enable `ibus` with given engines before customizing your desktop to use `typing-booster`. This can be achieved using the `ibus` module: |
||||
|
||||
```nix |
||||
{ pkgs, ... }: { |
||||
i18n.inputMethod = { |
||||
enabled = "ibus"; |
||||
ibus.engines = with pkgs.ibus-engines; [ typing-booster ]; |
||||
}; |
||||
} |
||||
``` |
||||
|
||||
## Using custom hunspell dictionaries {#sec-ibus-typing-booster-customize-hunspell} |
||||
|
||||
The IBus engine is based on `hunspell` to support completion in many languages. By default the dictionaries `de-de`, `en-us`, `fr-moderne` `es-es`, `it-it`, `sv-se` and `sv-fi` are in use. To add another dictionary, the package can be overridden like this: |
||||
|
||||
```nix |
||||
ibus-engines.typing-booster.override { langs = [ "de-at" "en-gb" ]; } |
||||
``` |
||||
|
||||
_Note: each language passed to `langs` must be an attribute name in `pkgs.hunspellDicts`._ |
||||
|
||||
## Built-in emoji picker {#sec-ibus-typing-booster-emoji-picker} |
||||
|
||||
The `ibus-engines.typing-booster` package contains a program named `emoji-picker`. To display all emojis correctly, a special font such as `noto-fonts-emoji` is needed: |
||||
|
||||
On NixOS it can be installed using the following expression: |
||||
|
||||
```nix |
||||
{ pkgs, ... }: { fonts.fonts = with pkgs; [ noto-fonts-emoji ]; } |
||||
``` |
@ -1,57 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xml:id="sec-ibus-typing-booster"> |
||||
<title>ibus-engines.typing-booster</title> |
||||
|
||||
<para> |
||||
This package is an ibus-based completion method to speed up typing. |
||||
</para> |
||||
|
||||
<section xml:id="sec-ibus-typing-booster-activate"> |
||||
<title>Activating the engine</title> |
||||
|
||||
<para> |
||||
IBus needs to be configured accordingly to activate <literal>typing-booster</literal>. The configuration depends on the desktop manager in use. For detailed instructions, please refer to the <link xlink:href="https://mike-fabian.github.io/ibus-typing-booster/documentation.html">upstream docs</link>. |
||||
</para> |
||||
|
||||
<para> |
||||
On NixOS you need to explicitly enable <literal>ibus</literal> with given engines before customizing your desktop to use <literal>typing-booster</literal>. This can be achieved using the <literal>ibus</literal> module: |
||||
<programlisting>{ pkgs, ... }: { |
||||
i18n.inputMethod = { |
||||
enabled = "ibus"; |
||||
ibus.engines = with pkgs.ibus-engines; [ typing-booster ]; |
||||
}; |
||||
}</programlisting> |
||||
</para> |
||||
</section> |
||||
|
||||
<section xml:id="sec-ibus-typing-booster-customize-hunspell"> |
||||
<title>Using custom hunspell dictionaries</title> |
||||
|
||||
<para> |
||||
The IBus engine is based on <literal>hunspell</literal> to support completion in many languages. By default the dictionaries <literal>de-de</literal>, <literal>en-us</literal>, <literal>fr-moderne</literal> <literal>es-es</literal>, <literal>it-it</literal>, <literal>sv-se</literal> and <literal>sv-fi</literal> are in use. To add another dictionary, the package can be overridden like this: |
||||
<programlisting>ibus-engines.typing-booster.override { |
||||
langs = [ "de-at" "en-gb" ]; |
||||
}</programlisting> |
||||
</para> |
||||
|
||||
<para> |
||||
<emphasis>Note: each language passed to <literal>langs</literal> must be an attribute name in <literal>pkgs.hunspellDicts</literal>.</emphasis> |
||||
</para> |
||||
</section> |
||||
|
||||
<section xml:id="sec-ibus-typing-booster-emoji-picker"> |
||||
<title>Built-in emoji picker</title> |
||||
|
||||
<para> |
||||
The <literal>ibus-engines.typing-booster</literal> package contains a program named <literal>emoji-picker</literal>. To display all emojis correctly, a special font such as <literal>noto-fonts-emoji</literal> is needed: |
||||
</para> |
||||
|
||||
<para> |
||||
On NixOS it can be installed using the following expression: |
||||
<programlisting>{ pkgs, ... }: { |
||||
fonts.fonts = with pkgs; [ noto-fonts-emoji ]; |
||||
}</programlisting> |
||||
</para> |
||||
</section> |
||||
</section> |
@ -1,15 +1,17 @@ |
||||
# pkgs.mkShell {#sec-pkgs-mkShell} |
||||
|
||||
`pkgs.mkShell` is a special kind of derivation that is only useful when using it combined with `nix-shell`. It will in fact fail to instantiate when invoked with `nix-build`. |
||||
`pkgs.mkShell` is a special kind of derivation that is only useful when using |
||||
it combined with `nix-shell`. It will in fact fail to instantiate when invoked |
||||
with `nix-build`. |
||||
|
||||
## Usage {#sec-pkgs-mkShell-usage} |
||||
|
||||
```nix |
||||
{ pkgs ? import <nixpkgs> {} }: |
||||
pkgs.mkShell { |
||||
# this will make all the build inputs from hello and gnutar |
||||
# available to the shell environment |
||||
# specify which packages to add to the shell environment |
||||
packages = [ pkgs.gnumake ]; |
||||
# add all the dependencies, of the given packages, to the shell environment |
||||
inputsFrom = with pkgs; [ hello gnutar ]; |
||||
buildInputs = [ pkgs.gnumake ]; |
||||
} |
||||
``` |
||||
|
@ -0,0 +1,604 @@ |
||||
# Coding conventions {#chap-conventions} |
||||
|
||||
## Syntax {#sec-syntax} |
||||
|
||||
- Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts. |
||||
|
||||
- Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use `(setq-default indent-tabs-mode nil)` in Emacs. Everybody has different tab settings so it’s asking for trouble. |
||||
|
||||
- Use `lowerCamelCase` for variable names, not `UpperCamelCase`. Note, this rule does not apply to package attribute names, which instead follow the rules in [](#sec-package-naming). |
||||
|
||||
- Function calls with attribute set arguments are written as |
||||
|
||||
```nix |
||||
foo { |
||||
arg = ...; |
||||
} |
||||
``` |
||||
|
||||
not |
||||
|
||||
```nix |
||||
foo |
||||
{ |
||||
arg = ...; |
||||
} |
||||
``` |
||||
|
||||
Also fine is |
||||
|
||||
```nix |
||||
foo { arg = ...; } |
||||
``` |
||||
|
||||
if it's a short call. |
||||
|
||||
- In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned: |
||||
|
||||
```nix |
||||
# A long list. |
||||
list = [ |
||||
elem1 |
||||
elem2 |
||||
elem3 |
||||
]; |
||||
|
||||
# A long attribute set. |
||||
attrs = { |
||||
attr1 = short_expr; |
||||
attr2 = |
||||
if true then big_expr else big_expr; |
||||
}; |
||||
|
||||
# Combined |
||||
listOfAttrs = [ |
||||
{ |
||||
attr1 = 3; |
||||
attr2 = "fff"; |
||||
} |
||||
{ |
||||
attr1 = 5; |
||||
attr2 = "ggg"; |
||||
} |
||||
]; |
||||
``` |
||||
|
||||
- Short lists or attribute sets can be written on one line: |
||||
|
||||
```nix |
||||
# A short list. |
||||
list = [ elem1 elem2 elem3 ]; |
||||
|
||||
# A short set. |
||||
attrs = { x = 1280; y = 1024; }; |
||||
``` |
||||
|
||||
- Breaking in the middle of a function argument can give hard-to-read code, like |
||||
|
||||
```nix |
||||
someFunction { x = 1280; |
||||
y = 1024; } otherArg |
||||
yetAnotherArg |
||||
``` |
||||
|
||||
(especially if the argument is very large, spanning multiple lines). |
||||
|
||||
Better: |
||||
|
||||
```nix |
||||
someFunction |
||||
{ x = 1280; y = 1024; } |
||||
otherArg |
||||
yetAnotherArg |
||||
``` |
||||
|
||||
or |
||||
|
||||
```nix |
||||
let res = { x = 1280; y = 1024; }; |
||||
in someFunction res otherArg yetAnotherArg |
||||
``` |
||||
|
||||
- The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e. |
||||
|
||||
```nix |
||||
{ arg1, arg2 }: |
||||
assert system == "i686-linux"; |
||||
stdenv.mkDerivation { ... |
||||
``` |
||||
|
||||
not |
||||
|
||||
```nix |
||||
{ arg1, arg2 }: |
||||
assert system == "i686-linux"; |
||||
stdenv.mkDerivation { ... |
||||
``` |
||||
|
||||
- Function formal arguments are written as: |
||||
|
||||
```nix |
||||
{ arg1, arg2, arg3 }: |
||||
``` |
||||
|
||||
but if they don't fit on one line they're written as: |
||||
|
||||
```nix |
||||
{ arg1, arg2, arg3 |
||||
, arg4, ... |
||||
, # Some comment... |
||||
argN |
||||
}: |
||||
``` |
||||
|
||||
- Functions should list their expected arguments as precisely as possible. That is, write |
||||
|
||||
```nix |
||||
{ stdenv, fetchurl, perl }: ... |
||||
``` |
||||
|
||||
instead of |
||||
|
||||
```nix |
||||
args: with args; ... |
||||
``` |
||||
|
||||
or |
||||
|
||||
```nix |
||||
{ stdenv, fetchurl, perl, ... }: ... |
||||
``` |
||||
|
||||
For functions that are truly generic in the number of arguments (such as wrappers around `mkDerivation`) that have some required arguments, you should write them using an `@`-pattern: |
||||
|
||||
```nix |
||||
{ stdenv, doCoverageAnalysis ? false, ... } @ args: |
||||
|
||||
stdenv.mkDerivation (args // { |
||||
... if doCoverageAnalysis then "bla" else "" ... |
||||
}) |
||||
``` |
||||
|
||||
instead of |
||||
|
||||
```nix |
||||
args: |
||||
|
||||
args.stdenv.mkDerivation (args // { |
||||
... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ... |
||||
}) |
||||
``` |
||||
|
||||
- Unnecessary string conversions should be avoided. Do |
||||
|
||||
```nix |
||||
rev = version; |
||||
``` |
||||
|
||||
instead of |
||||
|
||||
```nix |
||||
rev = "${version}"; |
||||
``` |
||||
|
||||
- Arguments should be listed in the order they are used, with the exception of `lib`, which always goes first. |
||||
|
||||
## Package naming {#sec-package-naming} |
||||
|
||||
The key words _must_, _must not_, _required_, _shall_, _shall not_, _should_, _should not_, _recommended_, _may_, and _optional_ in this section are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119). Only _emphasized_ words are to be interpreted in this way. |
||||
|
||||
In Nixpkgs, there are generally three different names associated with a package: |
||||
|
||||
- The `name` attribute of the derivation (excluding the version part). This is what most users see, in particular when using `nix-env`. |
||||
|
||||
- The variable name used for the instantiated package in `all-packages.nix`, and when passing it as a dependency to other functions. Typically this is called the _package attribute name_. This is what Nix expression authors see. It can also be used when installing using `nix-env -iA`. |
||||
|
||||
- The filename for (the directory containing) the Nix expression. |
||||
|
||||
Most of the time, these are the same. For instance, the package `e2fsprogs` has a `name` attribute `"e2fsprogs-version"`, is bound to the variable name `e2fsprogs` in `all-packages.nix`, and the Nix expression is in `pkgs/os-specific/linux/e2fsprogs/default.nix`. |
||||
|
||||
There are a few naming guidelines: |
||||
|
||||
- The `name` attribute _should_ be identical to the upstream package name. |
||||
|
||||
- The `name` attribute _must not_ contain uppercase letters — e.g., `"mplayer-1.0rc2"` instead of `"MPlayer-1.0rc2"`. |
||||
|
||||
- The version part of the `name` attribute _must_ start with a digit (following a dash) — e.g., `"hello-0.3.1rc2"`. |
||||
|
||||
- If a package is not a release but a commit from a repository, then the version part of the name _must_ be the date of that (fetched) commit. The date _must_ be in `"YYYY-MM-DD"` format. Also append `"unstable"` to the name - e.g., `"pkgname-unstable-2014-09-23"`. |
||||
|
||||
- Dashes in the package name _should_ be preserved in new variable names, rather than converted to underscores or camel cased — e.g., `http-parser` instead of `http_parser` or `httpParser`. The hyphenated style is preferred in all three package names. |
||||
|
||||
- If there are multiple versions of a package, this _should_ be reflected in the variable names in `all-packages.nix`, e.g. `json-c-0-9` and `json-c-0-11`. If there is an obvious “default” version, make an attribute like `json-c = json-c-0-9;`. See also [](#sec-versioning) |
||||
|
||||
## File naming and organisation {#sec-organisation} |
||||
|
||||
Names of files and directories should be in lowercase, with dashes between words — not in camel case. For instance, it should be `all-packages.nix`, not `allPackages.nix` or `AllPackages.nix`. |
||||
|
||||
### Hierarchy {#sec-hierarchy} |
||||
|
||||
Each package should be stored in its own directory somewhere in the `pkgs/` tree, i.e. in `pkgs/category/subcategory/.../pkgname`. Below are some rules for picking the right category for a package. Many packages fall under several categories; what matters is the _primary_ purpose of a package. For example, the `libxml2` package builds both a library and some tools; but it’s a library foremost, so it goes under `pkgs/development/libraries`. |
||||
|
||||
When in doubt, consider refactoring the `pkgs/` tree, e.g. creating new categories or splitting up an existing category. |
||||
|
||||
**If it’s used to support _software development_:** |
||||
|
||||
- **If it’s a _library_ used by other packages:** |
||||
|
||||
- `development/libraries` (e.g. `libxml2`) |
||||
|
||||
- **If it’s a _compiler_:** |
||||
|
||||
- `development/compilers` (e.g. `gcc`) |
||||
|
||||
- **If it’s an _interpreter_:** |
||||
|
||||
- `development/interpreters` (e.g. `guile`) |
||||
|
||||
- **If it’s a (set of) development _tool(s)_:** |
||||
|
||||
- **If it’s a _parser generator_ (including lexers):** |
||||
|
||||
- `development/tools/parsing` (e.g. `bison`, `flex`) |
||||
|
||||
- **If it’s a _build manager_:** |
||||
|
||||
- `development/tools/build-managers` (e.g. `gnumake`) |
||||
|
||||
- **Else:** |
||||
|
||||
- `development/tools/misc` (e.g. `binutils`) |
||||
|
||||
- **Else:** |
||||
|
||||
- `development/misc` |
||||
|
||||
**If it’s a (set of) _tool(s)_:** |
||||
|
||||
(A tool is a relatively small program, especially one intended to be used non-interactively.) |
||||
|
||||
- **If it’s for _networking_:** |
||||
|
||||
- `tools/networking` (e.g. `wget`) |
||||
|
||||
- **If it’s for _text processing_:** |
||||
|
||||
- `tools/text` (e.g. `diffutils`) |
||||
|
||||
- **If it’s a _system utility_, i.e., something related or essential to the operation of a system:** |
||||
|
||||
- `tools/system` (e.g. `cron`) |
||||
|
||||
- **If it’s an _archiver_ (which may include a compression function):** |
||||
|
||||
- `tools/archivers` (e.g. `zip`, `tar`) |
||||
|
||||
- **If it’s a _compression_ program:** |
||||
|
||||
- `tools/compression` (e.g. `gzip`, `bzip2`) |
||||
|
||||
- **If it’s a _security_-related program:** |
||||
|
||||
- `tools/security` (e.g. `nmap`, `gnupg`) |
||||
|
||||
- **Else:** |
||||
|
||||
- `tools/misc` |
||||
|
||||
**If it’s a _shell_:** |
||||
|
||||
- `shells` (e.g. `bash`) |
||||
|
||||
**If it’s a _server_:** |
||||
|
||||
- **If it’s a web server:** |
||||
|
||||
- `servers/http` (e.g. `apache-httpd`) |
||||
|
||||
- **If it’s an implementation of the X Windowing System:** |
||||
|
||||
- `servers/x11` (e.g. `xorg` — this includes the client libraries and programs) |
||||
|
||||
- **Else:** |
||||
|
||||
- `servers/misc` |
||||
|
||||
**If it’s a _desktop environment_:** |
||||
|
||||
- `desktops` (e.g. `kde`, `gnome`, `enlightenment`) |
||||
|
||||
**If it’s a _window manager_:** |
||||
|
||||
- `applications/window-managers` (e.g. `awesome`, `stumpwm`) |
||||
|
||||
**If it’s an _application_:** |
||||
|
||||
A (typically large) program with a distinct user interface, primarily used interactively. |
||||
|
||||
- **If it’s a _version management system_:** |
||||
|
||||
- `applications/version-management` (e.g. `subversion`) |
||||
|
||||
- **If it’s a _terminal emulator_:** |
||||
|
||||
- `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`) |
||||
|
||||
- **If it’s for _video playback / editing_:** |
||||
|
||||
- `applications/video` (e.g. `vlc`) |
||||
|
||||
- **If it’s for _graphics viewing / editing_:** |
||||
|
||||
- `applications/graphics` (e.g. `gimp`) |
||||
|
||||
- **If it’s for _networking_:** |
||||
|
||||
- **If it’s a _mailreader_:** |
||||
|
||||
- `applications/networking/mailreaders` (e.g. `thunderbird`) |
||||
|
||||
- **If it’s a _newsreader_:** |
||||
|
||||
- `applications/networking/newsreaders` (e.g. `pan`) |
||||
|
||||
- **If it’s a _web browser_:** |
||||
|
||||
- `applications/networking/browsers` (e.g. `firefox`) |
||||
|
||||
- **Else:** |
||||
|
||||
- `applications/networking/misc` |
||||
|
||||
- **Else:** |
||||
|
||||
- `applications/misc` |
||||
|
||||
**If it’s _data_ (i.e., does not have a straight-forward executable semantics):** |
||||
|
||||
- **If it’s a _font_:** |
||||
|
||||
- `data/fonts` |
||||
|
||||
- **If it’s an _icon theme_:** |
||||
|
||||
- `data/icons` |
||||
|
||||
- **If it’s related to _SGML/XML processing_:** |
||||
|
||||
- **If it’s an _XML DTD_:** |
||||
|
||||
- `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`) |
||||
|
||||
- **If it’s an _XSLT stylesheet_:** |
||||
|
||||
(Okay, these are executable...) |
||||
|
||||
- `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`) |
||||
|
||||
- **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:** |
||||
|
||||
- `data/themes` |
||||
|
||||
**If it’s a _game_:** |
||||
|
||||
- `games` |
||||
|
||||
**Else:** |
||||
|
||||
- `misc` |
||||
|
||||
### Versioning {#sec-versioning} |
||||
|
||||
Because every version of a package in Nixpkgs creates a potential maintenance burden, old versions of a package should not be kept unless there is a good reason to do so. For instance, Nixpkgs contains several versions of GCC because other packages don’t build with the latest version of GCC. Other examples are having both the latest stable and latest pre-release version of a package, or to keep several major releases of an application that differ significantly in functionality. |
||||
|
||||
If there is only one version of a package, its Nix expression should be named `e2fsprogs/default.nix`. If there are multiple versions, this should be reflected in the filename, e.g. `e2fsprogs/1.41.8.nix` and `e2fsprogs/1.41.9.nix`. The version in the filename should leave out unnecessary detail. For instance, if we keep the latest Firefox 2.0.x and 3.5.x versions in Nixpkgs, they should be named `firefox/2.0.nix` and `firefox/3.5.nix`, respectively (which, at a given point, might contain versions `2.0.0.20` and `3.5.4`). If a version requires many auxiliary files, you can use a subdirectory for each version, e.g. `firefox/2.0/default.nix` and `firefox/3.5/default.nix`. |
||||
|
||||
All versions of a package _must_ be included in `all-packages.nix` to make sure that they evaluate correctly. |
||||
|
||||
## Fetching Sources {#sec-sources} |
||||
|
||||
There are multiple ways to fetch a package source in nixpkgs. The general guideline is that you should package reproducible sources with a high degree of availability. Right now there is only one fetcher which has mirroring support and that is `fetchurl`. Note that you should also prefer protocols which have a corresponding proxy environment variable. |
||||
|
||||
You can find many source fetch helpers in `pkgs/build-support/fetch*`. |
||||
|
||||
In the file `pkgs/top-level/all-packages.nix` you can find fetch helpers, these have names on the form `fetchFrom*`. The intention of these are to provide snapshot fetches but using the same api as some of the version controlled fetchers from `pkgs/build-support/`. As an example going from bad to good: |
||||
|
||||
- Bad: Uses `git://` which won't be proxied. |
||||
|
||||
```nix |
||||
src = fetchgit { |
||||
url = "git://github.com/NixOS/nix.git"; |
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; |
||||
sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; |
||||
} |
||||
``` |
||||
|
||||
- Better: This is ok, but an archive fetch will still be faster. |
||||
|
||||
```nix |
||||
src = fetchgit { |
||||
url = "https://github.com/NixOS/nix.git"; |
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; |
||||
sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; |
||||
} |
||||
``` |
||||
|
||||
- Best: Fetches a snapshot archive and you get the rev you want. |
||||
|
||||
```nix |
||||
src = fetchFromGitHub { |
||||
owner = "NixOS"; |
||||
repo = "nix"; |
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; |
||||
sha256 = "1i2yxndxb6yc9l6c99pypbd92lfq5aac4klq7y2v93c9qvx2cgpc"; |
||||
} |
||||
``` |
||||
|
||||
Find the value to put as `sha256` by running `nix run -f '<nixpkgs>' nix-prefetch-github -c nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix` or `nix-prefetch-url --unpack https://github.com/NixOS/nix/archive/1f795f9f44607cc5bec70d1300150bfefcef2aae.tar.gz`. |
||||
|
||||
## Obtaining source hash {#sec-source-hashes} |
||||
|
||||
Preferred source hash type is sha256. There are several ways to get it. |
||||
|
||||
1. Prefetch URL (with `nix-prefetch-XXX URL`, where `XXX` is one of `url`, `git`, `hg`, `cvs`, `bzr`, `svn`). Hash is printed to stdout. |
||||
|
||||
2. Prefetch by package source (with `nix-prefetch-url '<nixpkgs>' -A PACKAGE.src`, where `PACKAGE` is package attribute name). Hash is printed to stdout. |
||||
|
||||
This works well when you've upgraded existing package version and want to find out new hash, but is useless if package can't be accessed by attribute or package has multiple sources (`.srcs`, architecture-dependent sources, etc). |
||||
|
||||
3. Upstream provided hash: use it when upstream provides `sha256` or `sha512` (when upstream provides `md5`, don't use it, compute `sha256` instead). |
||||
|
||||
A little nuance is that `nix-prefetch-*` tools produce hash encoded with `base32`, but upstream usually provides hexadecimal (`base16`) encoding. Fetchers understand both formats. Nixpkgs does not standardize on any one format. |
||||
|
||||
You can convert between formats with nix-hash, for example: |
||||
|
||||
```ShellSession |
||||
$ nix-hash --type sha256 --to-base32 HASH |
||||
``` |
||||
|
||||
4. Extracting hash from local source tarball can be done with `sha256sum`. Use `nix-prefetch-url file:///path/to/tarball` if you want base32 hash. |
||||
|
||||
5. Fake hash: set fake hash in package expression, perform build and extract correct hash from error Nix prints. |
||||
|
||||
For package updates it is enough to change one symbol to make hash fake. For new packages, you can use `lib.fakeSha256`, `lib.fakeSha512` or any other fake hash. |
||||
|
||||
This is last resort method when reconstructing source URL is non-trivial and `nix-prefetch-url -A` isn’t applicable (for example, [one of `kodi` dependencies](https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73)). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash. |
||||
|
||||
::: {.warning} |
||||
This method has security problems. Check below for details. |
||||
::: |
||||
|
||||
### Obtaining hashes securely {#sec-source-hashes-security} |
||||
|
||||
Let's say Man-in-the-Middle (MITM) sits close to your network. Then instead of fetching source you can fetch malware, and instead of source hash you get hash of malware. Here are security considerations for this scenario: |
||||
|
||||
- `http://` URLs are not secure to prefetch hash from; |
||||
|
||||
- hashes from upstream (in method 3) should be obtained via secure protocol; |
||||
|
||||
- `https://` URLs are secure in methods 1, 2, 3; |
||||
|
||||
- `https://` URLs are not secure in method 5. When obtaining hashes with fake hash method, TLS checks are disabled. So refetch source hash from several different networks to exclude MITM scenario. Alternatively, use fake hash method to make Nix error, but instead of extracting hash from error, extract `https://` URL and prefetch it with method 1. |
||||
|
||||
## Patches {#sec-patches} |
||||
|
||||
Patches available online should be retrieved using `fetchpatch`. |
||||
|
||||
```nix |
||||
patches = [ |
||||
(fetchpatch { |
||||
name = "fix-check-for-using-shared-freetype-lib.patch"; |
||||
url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285"; |
||||
sha256 = "1f0k043rng7f0rfl9hhb89qzvvksqmkrikmm38p61yfx51l325xr"; |
||||
}) |
||||
]; |
||||
``` |
||||
|
||||
Otherwise, you can add a `.patch` file to the `nixpkgs` repository. In the interest of keeping our maintenance burden to a minimum, only patches that are unique to `nixpkgs` should be added in this way. |
||||
|
||||
```nix |
||||
patches = [ ./0001-changes.patch ]; |
||||
``` |
||||
|
||||
If you do need to do create this sort of patch file, one way to do so is with git: |
||||
|
||||
1. Move to the root directory of the source code you're patching. |
||||
|
||||
```ShellSession |
||||
$ cd the/program/source |
||||
``` |
||||
|
||||
2. If a git repository is not already present, create one and stage all of the source files. |
||||
|
||||
```ShellSession |
||||
$ git init |
||||
$ git add . |
||||
``` |
||||
|
||||
3. Edit some files to make whatever changes need to be included in the patch. |
||||
|
||||
4. Use git to create a diff, and pipe the output to a patch file: |
||||
|
||||
```ShellSession |
||||
$ git diff > nixpkgs/pkgs/the/package/0001-changes.patch |
||||
``` |
||||
|
||||
If a patch is available online but does not cleanly apply, it can be modified in some fixed ways by using additional optional arguments for `fetchpatch`: |
||||
|
||||
- `stripLen`: Remove the first `stripLen` components of pathnames in the patch. |
||||
- `extraPrefix`: Prefix pathnames by this string. |
||||
- `excludes`: Exclude files matching this pattern. |
||||
- `includes`: Include only files matching this pattern. |
||||
- `revert`: Revert the patch. |
||||
|
||||
Note that because the checksum is computed after applying these effects, using or modifying these arguments will have no effect unless the `sha256` argument is changed as well. |
||||
|
||||
## Package tests {#sec-package-tests} |
||||
|
||||
Tests are important to ensure quality and make reviews and automatic updates easy. |
||||
|
||||
Nix package tests are a lightweight alternative to [NixOS module tests](https://nixos.org/manual/nixos/stable/#sec-nixos-tests). They can be used to create simple integration tests for packages while the module tests are used to test services or programs with a graphical user interface on a NixOS VM. Unittests that are included in the source code of a package should be executed in the `checkPhase`. |
||||
|
||||
### Writing package tests {#ssec-package-tests-writing} |
||||
|
||||
This is an example using the `phoronix-test-suite` package with the current best practices. |
||||
|
||||
Add the tests in `passthru.tests` to the package definition like this: |
||||
|
||||
```nix |
||||
{ stdenv, lib, fetchurl, callPackage }: |
||||
|
||||
stdenv.mkDerivation { |
||||
… |
||||
|
||||
passthru.tests = { |
||||
simple-execution = callPackage ./tests.nix { }; |
||||
}; |
||||
|
||||
meta = { … }; |
||||
} |
||||
``` |
||||
|
||||
Create `tests.nix` in the package directory: |
||||
|
||||
```nix |
||||
{ runCommand, phoronix-test-suite }: |
||||
|
||||
let |
||||
inherit (phoronix-test-suite) pname version; |
||||
in |
||||
|
||||
runCommand "${pname}-tests" { meta.timeout = 3; } |
||||
'' |
||||
# automatic initial setup to prevent interactive questions |
||||
${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null |
||||
# get version of installed program and compare with package version |
||||
if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then |
||||
echo "Error: program version does not match package version" |
||||
exit 1 |
||||
fi |
||||
# run dummy command |
||||
${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null |
||||
# needed for Nix to register the command as successful |
||||
touch $out |
||||
'' |
||||
``` |
||||
|
||||
### Running package tests {#ssec-package-tests-running} |
||||
|
||||
You can run these tests with: |
||||
|
||||
```ShellSession |
||||
$ cd path/to/nixpkgs |
||||
$ nix-build -A phoronix-test-suite.tests |
||||
``` |
||||
|
||||
### Examples of package tests {#ssec-package-tests-examples} |
||||
|
||||
Here are examples of package tests: |
||||
|
||||
- [Jasmin compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/jasmin/test-assemble-hello-world/default.nix) |
||||
- [Lobster compile test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/lobster/test-can-run-hello-world.nix) |
||||
- [Spacy annotation test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/spacy/annotation-test/default.nix) |
||||
- [Libtorch test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/science/math/libtorch/test/default.nix) |
||||
- [Multiple tests for nanopb](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/nanopb/default.nix) |
@ -1,949 +0,0 @@ |
||||
<chapter xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xml:id="chap-conventions"> |
||||
<title>Coding conventions</title> |
||||
<section xml:id="sec-syntax"> |
||||
<title>Syntax</title> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Use 2 spaces of indentation per indentation level in Nix expressions, 4 spaces in shell scripts. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Do not use tab characters, i.e. configure your editor to use soft tabs. For instance, use <literal>(setq-default indent-tabs-mode nil)</literal> in Emacs. Everybody has different tab settings so it’s asking for trouble. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Use <literal>lowerCamelCase</literal> for variable names, not <literal>UpperCamelCase</literal>. Note, this rule does not apply to package attribute names, which instead follow the rules in <xref linkend="sec-package-naming"/>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Function calls with attribute set arguments are written as |
||||
<programlisting> |
||||
foo { |
||||
arg = ...; |
||||
} |
||||
</programlisting> |
||||
not |
||||
<programlisting> |
||||
foo |
||||
{ |
||||
arg = ...; |
||||
} |
||||
</programlisting> |
||||
Also fine is |
||||
<programlisting> |
||||
foo { arg = ...; } |
||||
</programlisting> |
||||
if it's a short call. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
In attribute sets or lists that span multiple lines, the attribute names or list elements should be aligned: |
||||
<programlisting> |
||||
# A long list. |
||||
list = [ |
||||
elem1 |
||||
elem2 |
||||
elem3 |
||||
]; |
||||
|
||||
# A long attribute set. |
||||
attrs = { |
||||
attr1 = short_expr; |
||||
attr2 = |
||||
if true then big_expr else big_expr; |
||||
}; |
||||
|
||||
# Combined |
||||
listOfAttrs = [ |
||||
{ |
||||
attr1 = 3; |
||||
attr2 = "fff"; |
||||
} |
||||
{ |
||||
attr1 = 5; |
||||
attr2 = "ggg"; |
||||
} |
||||
]; |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Short lists or attribute sets can be written on one line: |
||||
<programlisting> |
||||
# A short list. |
||||
list = [ elem1 elem2 elem3 ]; |
||||
|
||||
# A short set. |
||||
attrs = { x = 1280; y = 1024; }; |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Breaking in the middle of a function argument can give hard-to-read code, like |
||||
<programlisting> |
||||
someFunction { x = 1280; |
||||
y = 1024; } otherArg |
||||
yetAnotherArg |
||||
</programlisting> |
||||
(especially if the argument is very large, spanning multiple lines). |
||||
</para> |
||||
<para> |
||||
Better: |
||||
<programlisting> |
||||
someFunction |
||||
{ x = 1280; y = 1024; } |
||||
otherArg |
||||
yetAnotherArg |
||||
</programlisting> |
||||
or |
||||
<programlisting> |
||||
let res = { x = 1280; y = 1024; }; |
||||
in someFunction res otherArg yetAnotherArg |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The bodies of functions, asserts, and withs are not indented to prevent a lot of superfluous indentation levels, i.e. |
||||
<programlisting> |
||||
{ arg1, arg2 }: |
||||
assert system == "i686-linux"; |
||||
stdenv.mkDerivation { ... |
||||
</programlisting> |
||||
not |
||||
<programlisting> |
||||
{ arg1, arg2 }: |
||||
assert system == "i686-linux"; |
||||
stdenv.mkDerivation { ... |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Function formal arguments are written as: |
||||
<programlisting> |
||||
{ arg1, arg2, arg3 }: |
||||
</programlisting> |
||||
but if they don't fit on one line they're written as: |
||||
<programlisting> |
||||
{ arg1, arg2, arg3 |
||||
, arg4, ... |
||||
, # Some comment... |
||||
argN |
||||
}: |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Functions should list their expected arguments as precisely as possible. That is, write |
||||
<programlisting> |
||||
{ stdenv, fetchurl, perl }: <replaceable>...</replaceable> |
||||
</programlisting> |
||||
instead of |
||||
<programlisting> |
||||
args: with args; <replaceable>...</replaceable> |
||||
</programlisting> |
||||
or |
||||
<programlisting> |
||||
{ stdenv, fetchurl, perl, ... }: <replaceable>...</replaceable> |
||||
</programlisting> |
||||
</para> |
||||
<para> |
||||
For functions that are truly generic in the number of arguments (such as wrappers around <varname>mkDerivation</varname>) that have some required arguments, you should write them using an <literal>@</literal>-pattern: |
||||
<programlisting> |
||||
{ stdenv, doCoverageAnalysis ? false, ... } @ args: |
||||
|
||||
stdenv.mkDerivation (args // { |
||||
<replaceable>...</replaceable> if doCoverageAnalysis then "bla" else "" <replaceable>...</replaceable> |
||||
}) |
||||
</programlisting> |
||||
instead of |
||||
<programlisting> |
||||
args: |
||||
|
||||
args.stdenv.mkDerivation (args // { |
||||
<replaceable>...</replaceable> if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" <replaceable>...</replaceable> |
||||
}) |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Arguments should be listed in the order they are used, with the |
||||
exception of <varname>lib</varname>, which always goes first. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Prefer using the top-level <varname>lib</varname> over its alias |
||||
<literal>stdenv.lib</literal>. <varname>lib</varname> is unrelated to |
||||
<varname>stdenv</varname>, and so <literal>stdenv.lib</literal> should only |
||||
be used as a convenience alias when developing to avoid having to modify |
||||
the function inputs just to test something out. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</section> |
||||
<section xml:id="sec-package-naming"> |
||||
<title>Package naming</title> |
||||
|
||||
<para> |
||||
The key words <emphasis>must</emphasis>, <emphasis>must not</emphasis>, <emphasis>required</emphasis>, <emphasis>shall</emphasis>, <emphasis>shall not</emphasis>, <emphasis>should</emphasis>, <emphasis>should not</emphasis>, <emphasis>recommended</emphasis>, <emphasis>may</emphasis>, and <emphasis>optional</emphasis> in this section are to be interpreted as described in <link xlink:href="https://tools.ietf.org/html/rfc2119">RFC 2119</link>. Only <emphasis>emphasized</emphasis> words are to be interpreted in this way. |
||||
</para> |
||||
|
||||
<para> |
||||
In Nixpkgs, there are generally three different names associated with a package: |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
The <varname>name</varname> attribute of the derivation (excluding the version part). This is what most users see, in particular when using <command>nix-env</command>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The variable name used for the instantiated package in <filename>all-packages.nix</filename>, and when passing it as a dependency to other functions. Typically this is called the <emphasis>package attribute name</emphasis>. This is what Nix expression authors see. It can also be used when installing using <command>nix-env -iA</command>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The filename for (the directory containing) the Nix expression. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
Most of the time, these are the same. For instance, the package <literal>e2fsprogs</literal> has a <varname>name</varname> attribute <literal>"e2fsprogs-<replaceable>version</replaceable>"</literal>, is bound to the variable name <varname>e2fsprogs</varname> in <filename>all-packages.nix</filename>, and the Nix expression is in <filename>pkgs/os-specific/linux/e2fsprogs/default.nix</filename>. |
||||
</para> |
||||
|
||||
<para> |
||||
There are a few naming guidelines: |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
The <literal>name</literal> attribute <emphasis>should</emphasis> be identical to the upstream package name. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The <literal>name</literal> attribute <emphasis>must not</emphasis> contain uppercase letters — e.g., <literal>"mplayer-1.0rc2"</literal> instead of <literal>"MPlayer-1.0rc2"</literal>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The version part of the <literal>name</literal> attribute <emphasis>must</emphasis> start with a digit (following a dash) — e.g., <literal>"hello-0.3.1rc2"</literal>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
If a package is not a release but a commit from a repository, then the version part of the name <emphasis>must</emphasis> be the date of that (fetched) commit. The date <emphasis>must</emphasis> be in <literal>"YYYY-MM-DD"</literal> format. Also append <literal>"unstable"</literal> to the name - e.g., <literal>"pkgname-unstable-2014-09-23"</literal>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Dashes in the package name <emphasis>should</emphasis> be preserved in new variable names, rather than converted to underscores or camel cased — e.g., <varname>http-parser</varname> instead of <varname>http_parser</varname> or <varname>httpParser</varname>. The hyphenated style is preferred in all three package names. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
If there are multiple versions of a package, this <emphasis>should</emphasis> be reflected in the variable names in <filename>all-packages.nix</filename>, e.g. <varname>json-c-0-9</varname> and <varname>json-c-0-11</varname>. If there is an obvious “default” version, make an attribute like <literal>json-c = json-c-0-9;</literal>. See also <xref linkend="sec-versioning" /> |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</para> |
||||
</section> |
||||
<section xml:id="sec-organisation"> |
||||
<title>File naming and organisation</title> |
||||
|
||||
<para> |
||||
Names of files and directories should be in lowercase, with dashes between words — not in camel case. For instance, it should be <filename>all-packages.nix</filename>, not <filename>allPackages.nix</filename> or <filename>AllPackages.nix</filename>. |
||||
</para> |
||||
|
||||
<section xml:id="sec-hierarchy"> |
||||
<title>Hierarchy</title> |
||||
|
||||
<para> |
||||
Each package should be stored in its own directory somewhere in the <filename>pkgs/</filename> tree, i.e. in <filename>pkgs/<replaceable>category</replaceable>/<replaceable>subcategory</replaceable>/<replaceable>...</replaceable>/<replaceable>pkgname</replaceable></filename>. Below are some rules for picking the right category for a package. Many packages fall under several categories; what matters is the <emphasis>primary</emphasis> purpose of a package. For example, the <literal>libxml2</literal> package builds both a library and some tools; but it’s a library foremost, so it goes under <filename>pkgs/development/libraries</filename>. |
||||
</para> |
||||
|
||||
<para> |
||||
When in doubt, consider refactoring the <filename>pkgs/</filename> tree, e.g. creating new categories or splitting up an existing category. |
||||
</para> |
||||
|
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s used to support <emphasis>software development</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>library</emphasis> used by other packages: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/libraries</filename> (e.g. <filename>libxml2</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>compiler</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/compilers</filename> (e.g. <filename>gcc</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an <emphasis>interpreter</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/interpreters</filename> (e.g. <filename>guile</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a (set of) development <emphasis>tool(s)</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>parser generator</emphasis> (including lexers): |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/tools/parsing</filename> (e.g. <filename>bison</filename>, <filename>flex</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>build manager</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/tools/build-managers</filename> (e.g. <filename>gnumake</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/tools/misc</filename> (e.g. <filename>binutils</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>development/misc</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a (set of) <emphasis>tool(s)</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
(A tool is a relatively small program, especially one intended to be used non-interactively.) |
||||
</para> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s for <emphasis>networking</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/networking</filename> (e.g. <filename>wget</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s for <emphasis>text processing</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/text</filename> (e.g. <filename>diffutils</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>system utility</emphasis>, i.e., something related or essential to the operation of a system: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/system</filename> (e.g. <filename>cron</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an <emphasis>archiver</emphasis> (which may include a compression function): |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/archivers</filename> (e.g. <filename>zip</filename>, <filename>tar</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>compression</emphasis> program: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/compression</filename> (e.g. <filename>gzip</filename>, <filename>bzip2</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>security</emphasis>-related program: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/security</filename> (e.g. <filename>nmap</filename>, <filename>gnupg</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>tools/misc</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>shell</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>shells</filename> (e.g. <filename>bash</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>server</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a web server: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>servers/http</filename> (e.g. <filename>apache-httpd</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an implementation of the X Windowing System: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>servers/x11</filename> (e.g. <filename>xorg</filename> — this includes the client libraries and programs) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>servers/misc</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>desktop environment</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>desktops</filename> (e.g. <filename>kde</filename>, <filename>gnome</filename>, <filename>enlightenment</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>window manager</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/window-managers</filename> (e.g. <filename>awesome</filename>, <filename>stumpwm</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an <emphasis>application</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
A (typically large) program with a distinct user interface, primarily used interactively. |
||||
</para> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>version management system</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/version-management</filename> (e.g. <filename>subversion</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>terminal emulator</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/terminal-emulators</filename> (e.g. <filename>alacritty</filename> or <filename>rxvt</filename> or <filename>termite</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s for <emphasis>video playback / editing</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/video</filename> (e.g. <filename>vlc</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s for <emphasis>graphics viewing / editing</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/graphics</filename> (e.g. <filename>gimp</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s for <emphasis>networking</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>mailreader</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/networking/mailreaders</filename> (e.g. <filename>thunderbird</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>newsreader</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/networking/newsreaders</filename> (e.g. <filename>pan</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>web browser</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/networking/browsers</filename> (e.g. <filename>firefox</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/networking/misc</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>applications/misc</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s <emphasis>data</emphasis> (i.e., does not have a straight-forward executable semantics): |
||||
</term> |
||||
<listitem> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>font</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>data/fonts</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an <emphasis>icon theme</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>data/icons</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s related to <emphasis>SGML/XML processing</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<variablelist> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an <emphasis>XML DTD</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>data/sgml+xml/schemas/xml-dtd</filename> (e.g. <filename>docbook</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s an <emphasis>XSLT stylesheet</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
(Okay, these are executable...) |
||||
</para> |
||||
<para> |
||||
<filename>data/sgml+xml/stylesheets/xslt</filename> (e.g. <filename>docbook-xsl</filename>) |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>theme</emphasis> for a <emphasis>desktop environment</emphasis>, |
||||
a <emphasis>window manager</emphasis> or a <emphasis>display manager</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>data/themes</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
If it’s a <emphasis>game</emphasis>: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>games</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
<varlistentry> |
||||
<term> |
||||
Else: |
||||
</term> |
||||
<listitem> |
||||
<para> |
||||
<filename>misc</filename> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
</variablelist> |
||||
</section> |
||||
|
||||
<section xml:id="sec-versioning"> |
||||
<title>Versioning</title> |
||||
|
||||
<para> |
||||
Because every version of a package in Nixpkgs creates a potential maintenance burden, old versions of a package should not be kept unless there is a good reason to do so. For instance, Nixpkgs contains several versions of GCC because other packages don’t build with the latest version of GCC. Other examples are having both the latest stable and latest pre-release version of a package, or to keep several major releases of an application that differ significantly in functionality. |
||||
</para> |
||||
|
||||
<para> |
||||
If there is only one version of a package, its Nix expression should be named <filename>e2fsprogs/default.nix</filename>. If there are multiple versions, this should be reflected in the filename, e.g. <filename>e2fsprogs/1.41.8.nix</filename> and <filename>e2fsprogs/1.41.9.nix</filename>. The version in the filename should leave out unnecessary detail. For instance, if we keep the latest Firefox 2.0.x and 3.5.x versions in Nixpkgs, they should be named <filename>firefox/2.0.nix</filename> and <filename>firefox/3.5.nix</filename>, respectively (which, at a given point, might contain versions <literal>2.0.0.20</literal> and <literal>3.5.4</literal>). If a version requires many auxiliary files, you can use a subdirectory for each version, e.g. <filename>firefox/2.0/default.nix</filename> and <filename>firefox/3.5/default.nix</filename>. |
||||
</para> |
||||
|
||||
<para> |
||||
All versions of a package <emphasis>must</emphasis> be included in <filename>all-packages.nix</filename> to make sure that they evaluate correctly. |
||||
</para> |
||||
</section> |
||||
</section> |
||||
<section xml:id="sec-sources"> |
||||
<title>Fetching Sources</title> |
||||
|
||||
<para> |
||||
There are multiple ways to fetch a package source in nixpkgs. The general guideline is that you should package reproducible sources with a high degree of availability. Right now there is only one fetcher which has mirroring support and that is <literal>fetchurl</literal>. Note that you should also prefer protocols which have a corresponding proxy environment variable. |
||||
</para> |
||||
|
||||
<para> |
||||
You can find many source fetch helpers in <literal>pkgs/build-support/fetch*</literal>. |
||||
</para> |
||||
|
||||
<para> |
||||
In the file <literal>pkgs/top-level/all-packages.nix</literal> you can find fetch helpers, these have names on the form <literal>fetchFrom*</literal>. The intention of these are to provide snapshot fetches but using the same api as some of the version controlled fetchers from <literal>pkgs/build-support/</literal>. As an example going from bad to good: |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Bad: Uses <literal>git://</literal> which won't be proxied. |
||||
<programlisting> |
||||
src = fetchgit { |
||||
url = "git://github.com/NixOS/nix.git"; |
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; |
||||
sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; |
||||
} |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Better: This is ok, but an archive fetch will still be faster. |
||||
<programlisting> |
||||
src = fetchgit { |
||||
url = "https://github.com/NixOS/nix.git"; |
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; |
||||
sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; |
||||
} |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Best: Fetches a snapshot archive and you get the rev you want. |
||||
<programlisting> |
||||
src = fetchFromGitHub { |
||||
owner = "NixOS"; |
||||
repo = "nix"; |
||||
rev = "1f795f9f44607cc5bec70d1300150bfefcef2aae"; |
||||
sha256 = "1i2yxndxb6yc9l6c99pypbd92lfq5aac4klq7y2v93c9qvx2cgpc"; |
||||
} |
||||
</programlisting> |
||||
Find the value to put as <literal>sha256</literal> by running <literal>nix run -f '<nixpkgs>' nix-prefetch-github -c nix-prefetch-github --rev 1f795f9f44607cc5bec70d1300150bfefcef2aae NixOS nix</literal> or <literal>nix-prefetch-url --unpack https://github.com/NixOS/nix/archive/1f795f9f44607cc5bec70d1300150bfefcef2aae.tar.gz</literal>. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</para> |
||||
</section> |
||||
<section xml:id="sec-source-hashes"> |
||||
<title>Obtaining source hash</title> |
||||
|
||||
<para> |
||||
Preferred source hash type is sha256. There are several ways to get it. |
||||
</para> |
||||
|
||||
<orderedlist> |
||||
<listitem> |
||||
<para> |
||||
Prefetch URL (with <literal>nix-prefetch-<replaceable>XXX</replaceable> <replaceable>URL</replaceable></literal>, where <replaceable>XXX</replaceable> is one of <literal>url</literal>, <literal>git</literal>, <literal>hg</literal>, <literal>cvs</literal>, <literal>bzr</literal>, <literal>svn</literal>). Hash is printed to stdout. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Prefetch by package source (with <literal>nix-prefetch-url '<nixpkgs>' -A <replaceable>PACKAGE</replaceable>.src</literal>, where <replaceable>PACKAGE</replaceable> is package attribute name). Hash is printed to stdout. |
||||
</para> |
||||
<para> |
||||
This works well when you've upgraded existing package version and want to find out new hash, but is useless if package can't be accessed by attribute or package has multiple sources (<literal>.srcs</literal>, architecture-dependent sources, etc). |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Upstream provided hash: use it when upstream provides <literal>sha256</literal> or <literal>sha512</literal> (when upstream provides <literal>md5</literal>, don't use it, compute <literal>sha256</literal> instead). |
||||
</para> |
||||
<para> |
||||
A little nuance is that <literal>nix-prefetch-*</literal> tools produce hash encoded with <literal>base32</literal>, but upstream usually provides hexadecimal (<literal>base16</literal>) encoding. Fetchers understand both formats. Nixpkgs does not standardize on any one format. |
||||
</para> |
||||
<para> |
||||
You can convert between formats with nix-hash, for example: |
||||
<screen> |
||||
<prompt>$ </prompt>nix-hash --type sha256 --to-base32 <replaceable>HASH</replaceable> |
||||
</screen> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Extracting hash from local source tarball can be done with <literal>sha256sum</literal>. Use <literal>nix-prefetch-url file:///path/to/tarball </literal> if you want base32 hash. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Fake hash: set fake hash in package expression, perform build and extract correct hash from error Nix prints. |
||||
</para> |
||||
<para> |
||||
For package updates it is enough to change one symbol to make hash fake. For new packages, you can use <literal>lib.fakeSha256</literal>, <literal>lib.fakeSha512</literal> or any other fake hash. |
||||
</para> |
||||
<para> |
||||
This is last resort method when reconstructing source URL is non-trivial and <literal>nix-prefetch-url -A</literal> isn't applicable (for example, <link xlink:href="https://github.com/NixOS/nixpkgs/blob/d2ab091dd308b99e4912b805a5eb088dd536adb9/pkgs/applications/video/kodi/default.nix#L73"> one of <literal>kodi</literal> dependencies</link>). The easiest way then would be replace hash with a fake one and rebuild. Nix build will fail and error message will contain desired hash. |
||||
</para> |
||||
<warning> |
||||
<para> |
||||
This method has security problems. Check below for details. |
||||
</para> |
||||
</warning> |
||||
</listitem> |
||||
</orderedlist> |
||||
|
||||
<section xml:id="sec-source-hashes-security"> |
||||
<title>Obtaining hashes securely</title> |
||||
|
||||
<para> |
||||
Let's say Man-in-the-Middle (MITM) sits close to your network. Then instead of fetching source you can fetch malware, and instead of source hash you get hash of malware. Here are security considerations for this scenario: |
||||
</para> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
<literal>http://</literal> URLs are not secure to prefetch hash from; |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
hashes from upstream (in method 3) should be obtained via secure protocol; |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
<literal>https://</literal> URLs are secure in methods 1, 2, 3; |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
<literal>https://</literal> URLs are not secure in method 5. When obtaining hashes with fake hash method, TLS checks are disabled. So refetch source hash from several different networks to exclude MITM scenario. Alternatively, use fake hash method to make Nix error, but instead of extracting hash from error, extract <literal>https://</literal> URL and prefetch it with method 1. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</section> |
||||
</section> |
||||
<section xml:id="sec-patches"> |
||||
<title>Patches</title> |
||||
|
||||
<para> |
||||
Patches available online should be retrieved using <literal>fetchpatch</literal>. |
||||
</para> |
||||
|
||||
<para> |
||||
<programlisting> |
||||
patches = [ |
||||
(fetchpatch { |
||||
name = "fix-check-for-using-shared-freetype-lib.patch"; |
||||
url = "http://git.ghostscript.com/?p=ghostpdl.git;a=patch;h=8f5d285"; |
||||
sha256 = "1f0k043rng7f0rfl9hhb89qzvvksqmkrikmm38p61yfx51l325xr"; |
||||
}) |
||||
]; |
||||
</programlisting> |
||||
</para> |
||||
|
||||
<para> |
||||
Otherwise, you can add a <literal>.patch</literal> file to the <literal>nixpkgs</literal> repository. In the interest of keeping our maintenance burden to a minimum, only patches that are unique to <literal>nixpkgs</literal> should be added in this way. |
||||
</para> |
||||
|
||||
<para> |
||||
<programlisting> |
||||
patches = [ ./0001-changes.patch ]; |
||||
</programlisting> |
||||
</para> |
||||
|
||||
<para> |
||||
If you do need to do create this sort of patch file, one way to do so is with git: |
||||
<orderedlist> |
||||
<listitem> |
||||
<para> |
||||
Move to the root directory of the source code you're patching. |
||||
<screen> |
||||
<prompt>$ </prompt>cd the/program/source</screen> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
If a git repository is not already present, create one and stage all of the source files. |
||||
<screen> |
||||
<prompt>$ </prompt>git init |
||||
<prompt>$ </prompt>git add .</screen> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Edit some files to make whatever changes need to be included in the patch. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Use git to create a diff, and pipe the output to a patch file: |
||||
<screen> |
||||
<prompt>$ </prompt>git diff > nixpkgs/pkgs/the/package/0001-changes.patch</screen> |
||||
</para> |
||||
</listitem> |
||||
</orderedlist> |
||||
</para> |
||||
</section> |
||||
</chapter> |
@ -0,0 +1,99 @@ |
||||
# Contributing to this documentation {#chap-contributing} |
||||
|
||||
The sources of the Nixpkgs manual are in the [doc](https://github.com/NixOS/nixpkgs/tree/master/doc) subdirectory of the Nixpkgs repository. The manual is still partially written in DocBook but it is progressively being converted to [Markdown](#sec-contributing-markup). |
||||
|
||||
You can quickly check your edits with `make`: |
||||
|
||||
```ShellSession |
||||
$ cd /path/to/nixpkgs/doc |
||||
$ nix-shell |
||||
[nix-shell]$ make |
||||
``` |
||||
|
||||
If you experience problems, run `make debug` to help understand the docbook errors. |
||||
|
||||
After making modifications to the manual, it's important to build it before committing. You can do that as follows: |
||||
|
||||
```ShellSession |
||||
$ cd /path/to/nixpkgs/doc |
||||
$ nix-shell |
||||
[nix-shell]$ make clean |
||||
[nix-shell]$ nix-build . |
||||
``` |
||||
|
||||
If the build succeeds, the manual will be in `./result/share/doc/nixpkgs/manual.html`. |
||||
|
||||
## Syntax {#sec-contributing-markup} |
||||
|
||||
As per [RFC 0072](https://github.com/NixOS/rfcs/pull/72), all new documentation content should be written in [CommonMark](https://commonmark.org/) Markdown dialect. |
||||
|
||||
Additionally, the following syntax extensions are currently used: |
||||
|
||||
- []{#ssec-contributing-markup-anchors} |
||||
Explicitly defined **anchors** on headings, to allow linking to sections. These should be always used, to ensure the anchors can be linked even when the heading text changes, and to prevent conflicts between [automatically assigned identifiers](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/auto_identifiers.md). |
||||
|
||||
It uses the widely compatible [header attributes](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md) syntax: |
||||
|
||||
```markdown |
||||
## Syntax {#sec-contributing-markup} |
||||
``` |
||||
|
||||
- []{#ssec-contributing-markup-anchors-inline} |
||||
**Inline anchors**, which allow linking arbitrary place in the text (e.g. individual list items, sentences…). |
||||
|
||||
They are defined using a hybrid of the link syntax with the attributes syntax known from headings, called [bracketed spans](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/bracketed_spans.md): |
||||
|
||||
```markdown |
||||
- []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`. |
||||
``` |
||||
|
||||
- []{#ssec-contributing-markup-automatic-links} |
||||
If you **omit a link text** for a link pointing to a section, the text will be substituted automatically. For example, `[](#chap-contributing)` will result in [](#chap-contributing). |
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing). |
||||
|
||||
- []{#ssec-contributing-markup-admonitions} |
||||
**Admonitions**, set off from the text to bring attention to something. |
||||
|
||||
It uses pandoc’s [fenced `div`s syntax](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/fenced_divs.md): |
||||
|
||||
```markdown |
||||
::: {.warning} |
||||
This is a warning |
||||
::: |
||||
``` |
||||
|
||||
which renders as |
||||
|
||||
> ::: {.warning} |
||||
> This is a warning. |
||||
> ::: |
||||
|
||||
The following are supported: |
||||
|
||||
- [`caution`](https://tdg.docbook.org/tdg/5.0/caution.html) |
||||
- [`important`](https://tdg.docbook.org/tdg/5.0/important.html) |
||||
- [`note`](https://tdg.docbook.org/tdg/5.0/note.html) |
||||
- [`tip`](https://tdg.docbook.org/tdg/5.0/tip.html) |
||||
- [`warning`](https://tdg.docbook.org/tdg/5.0/warning.html) |
||||
|
||||
- []{#ssec-contributing-markup-definition-lists} |
||||
[**Definition lists**](https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/definition_lists.md), for defining a group of terms: |
||||
|
||||
```markdown |
||||
pear |
||||
: green or yellow bulbous fruit |
||||
|
||||
watermelon |
||||
: green fruit with red flesh |
||||
``` |
||||
|
||||
which renders as |
||||
|
||||
> pear |
||||
> : green or yellow bulbous fruit |
||||
> |
||||
> watermelon |
||||
> : green fruit with red flesh |
||||
|
||||
For contributing to the legacy parts, please see [DocBook: The Definitive Guide](https://tdg.docbook.org/) or the [DocBook rocks! primer](https://web.archive.org/web/20200816233747/https://docbook.rocks/). |
@ -1,30 +0,0 @@ |
||||
<chapter xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xml:id="chap-contributing"> |
||||
<title>Contributing to this documentation</title> |
||||
<para> |
||||
The DocBook sources of the Nixpkgs manual are in the <filename |
||||
xlink:href="https://github.com/NixOS/nixpkgs/tree/master/doc">doc</filename> subdirectory of the Nixpkgs repository. |
||||
</para> |
||||
<para> |
||||
You can quickly check your edits with <command>make</command>: |
||||
</para> |
||||
<screen> |
||||
<prompt>$ </prompt>cd /path/to/nixpkgs/doc |
||||
<prompt>$ </prompt>nix-shell |
||||
<prompt>[nix-shell]$ </prompt>make $makeFlags |
||||
</screen> |
||||
<para> |
||||
If you experience problems, run <command>make debug</command> to help understand the docbook errors. |
||||
</para> |
||||
<para> |
||||
After making modifications to the manual, it's important to build it before committing. You can do that as follows: |
||||
<screen> |
||||
<prompt>$ </prompt>cd /path/to/nixpkgs/doc |
||||
<prompt>$ </prompt>nix-shell |
||||
<prompt>[nix-shell]$ </prompt>make clean |
||||
<prompt>[nix-shell]$ </prompt>nix-build . |
||||
</screen> |
||||
If the build succeeds, the manual will be in <filename>./result/share/doc/nixpkgs/manual.html</filename>. |
||||
</para> |
||||
</chapter> |
@ -0,0 +1,77 @@ |
||||
# Quick Start to Adding a Package {#chap-quick-start} |
||||
|
||||
To add a package to Nixpkgs: |
||||
|
||||
1. Checkout the Nixpkgs source tree: |
||||
|
||||
```ShellSession |
||||
$ git clone https://github.com/NixOS/nixpkgs |
||||
$ cd nixpkgs |
||||
``` |
||||
|
||||
2. Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into `pkgs/development/libraries/pkgname`, while a web browser goes into `pkgs/applications/networking/browsers/pkgname`. See [](#sec-organisation) for some hints on the tree organisation. Create a directory for your package, e.g. |
||||
|
||||
```ShellSession |
||||
$ mkdir pkgs/development/libraries/libfoo |
||||
``` |
||||
|
||||
3. In the package directory, create a Nix expression — a piece of code that describes how to build the package. In this case, it should be a _function_ that is called with the package dependencies as arguments, and returns a build of the package in the Nix store. The expression should usually be called `default.nix`. |
||||
|
||||
```ShellSession |
||||
$ emacs pkgs/development/libraries/libfoo/default.nix |
||||
$ git add pkgs/development/libraries/libfoo/default.nix |
||||
``` |
||||
|
||||
You can have a look at the existing Nix expressions under `pkgs/` to see how it’s done. Here are some good ones: |
||||
|
||||
- GNU Hello: [`pkgs/applications/misc/hello/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/hello/default.nix). Trivial package, which specifies some `meta` attributes which is good practice. |
||||
|
||||
- GNU cpio: [`pkgs/tools/archivers/cpio/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/archivers/cpio/default.nix). Also a simple package. The generic builder in `stdenv` does everything for you. It has no dependencies beyond `stdenv`. |
||||
|
||||
- GNU Multiple Precision arithmetic library (GMP): [`pkgs/development/libraries/gmp/5.1.x.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/gmp/5.1.x.nix). Also done by the generic builder, but has a dependency on `m4`. |
||||
|
||||
- Pan, a GTK-based newsreader: [`pkgs/applications/networking/newsreaders/pan/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/newsreaders/pan/default.nix). Has an optional dependency on `gtkspell`, which is only built if `spellCheck` is `true`. |
||||
|
||||
- Apache HTTPD: [`pkgs/servers/http/apache-httpd/2.4.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/http/apache-httpd/2.4.nix). A bunch of optional features, variable substitutions in the configure flags, a post-install hook, and miscellaneous hackery. |
||||
|
||||
- Thunderbird: [`pkgs/applications/networking/mailreaders/thunderbird/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/mailreaders/thunderbird/default.nix). Lots of dependencies. |
||||
|
||||
- JDiskReport, a Java utility: [`pkgs/tools/misc/jdiskreport/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/jdiskreport/default.nix). Nixpkgs doesn’t have a decent `stdenv` for Java yet so this is pretty ad-hoc. |
||||
|
||||
- XML::Simple, a Perl module: [`pkgs/top-level/perl-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/perl-packages.nix) (search for the `XMLSimple` attribute). Most Perl modules are so simple to build that they are defined directly in `perl-packages.nix`; no need to make a separate file for them. |
||||
|
||||
- Adobe Reader: [`pkgs/applications/misc/adobe-reader/default.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/adobe-reader/default.nix). Shows how binary-only packages can be supported. In particular the [builder](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/adobe-reader/builder.sh) uses `patchelf` to set the RUNPATH and ELF interpreter of the executables so that the right libraries are found at runtime. |
||||
|
||||
Some notes: |
||||
|
||||
- All [`meta`](#chap-meta) attributes are optional, but it’s still a good idea to provide at least the `description`, `homepage` and [`license`](#sec-meta-license). |
||||
|
||||
- You can use `nix-prefetch-url url` to get the SHA-256 hash of source distributions. There are similar commands as `nix-prefetch-git` and `nix-prefetch-hg` available in `nix-prefetch-scripts` package. |
||||
|
||||
- A list of schemes for `mirror://` URLs can be found in [`pkgs/build-support/fetchurl/mirrors.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/fetchurl/mirrors.nix). |
||||
|
||||
The exact syntax and semantics of the Nix expression language, including the built-in function, are described in the Nix manual in the [chapter on writing Nix expressions](https://hydra.nixos.org/job/nix/trunk/tarball/latest/download-by-type/doc/manual/#chap-writing-nix-expressions). |
||||
|
||||
4. Add a call to the function defined in the previous step to [`pkgs/top-level/all-packages.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix) with some descriptive name for the variable, e.g. `libfoo`. |
||||
|
||||
```ShellSession |
||||
$ emacs pkgs/top-level/all-packages.nix |
||||
``` |
||||
|
||||
The attributes in that file are sorted by category (like “Development / Libraries”) that more-or-less correspond to the directory structure of Nixpkgs, and then by attribute name. |
||||
|
||||
5. To test whether the package builds, run the following command from the root of the nixpkgs source tree: |
||||
|
||||
```ShellSession |
||||
$ nix-build -A libfoo |
||||
``` |
||||
|
||||
where `libfoo` should be the variable name defined in the previous step. You may want to add the flag `-K` to keep the temporary build directory in case something fails. If the build succeeds, a symlink `./result` to the package in the Nix store is created. |
||||
|
||||
6. If you want to install the package into your profile (optional), do |
||||
|
||||
```ShellSession |
||||
$ nix-env -f . -iA libfoo |
||||
``` |
||||
|
||||
7. Optionally commit the new package and open a pull request [to nixpkgs](https://github.com/NixOS/nixpkgs/pulls), or use [the Patches category](https://discourse.nixos.org/t/about-the-patches-category/477) on Discourse for sending a patch without a GitHub account. |
@ -1,152 +0,0 @@ |
||||
<chapter xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xml:id="chap-quick-start"> |
||||
<title>Quick Start to Adding a Package</title> |
||||
<para> |
||||
To add a package to Nixpkgs: |
||||
<orderedlist> |
||||
<listitem> |
||||
<para> |
||||
Checkout the Nixpkgs source tree: |
||||
<screen> |
||||
<prompt>$ </prompt>git clone https://github.com/NixOS/nixpkgs |
||||
<prompt>$ </prompt>cd nixpkgs</screen> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Find a good place in the Nixpkgs tree to add the Nix expression for your package. For instance, a library package typically goes into <filename>pkgs/development/libraries/<replaceable>pkgname</replaceable></filename>, while a web browser goes into <filename>pkgs/applications/networking/browsers/<replaceable>pkgname</replaceable></filename>. See <xref linkend="sec-organisation" /> for some hints on the tree organisation. Create a directory for your package, e.g. |
||||
<screen> |
||||
<prompt>$ </prompt>mkdir pkgs/development/libraries/libfoo</screen> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
In the package directory, create a Nix expression — a piece of code that describes how to build the package. In this case, it should be a <emphasis>function</emphasis> that is called with the package dependencies as arguments, and returns a build of the package in the Nix store. The expression should usually be called <filename>default.nix</filename>. |
||||
<screen> |
||||
<prompt>$ </prompt>emacs pkgs/development/libraries/libfoo/default.nix |
||||
<prompt>$ </prompt>git add pkgs/development/libraries/libfoo/default.nix</screen> |
||||
</para> |
||||
<para> |
||||
You can have a look at the existing Nix expressions under <filename>pkgs/</filename> to see how it’s done. Here are some good ones: |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
GNU Hello: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/hello/default.nix"><filename>pkgs/applications/misc/hello/default.nix</filename></link>. Trivial package, which specifies some <varname>meta</varname> attributes which is good practice. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
GNU cpio: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/archivers/cpio/default.nix"><filename>pkgs/tools/archivers/cpio/default.nix</filename></link>. Also a simple package. The generic builder in <varname>stdenv</varname> does everything for you. It has no dependencies beyond <varname>stdenv</varname>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
GNU Multiple Precision arithmetic library (GMP): <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/gmp/5.1.x.nix"><filename>pkgs/development/libraries/gmp/5.1.x.nix</filename></link>. Also done by the generic builder, but has a dependency on <varname>m4</varname>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Pan, a GTK-based newsreader: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/newsreaders/pan/default.nix"><filename>pkgs/applications/networking/newsreaders/pan/default.nix</filename></link>. Has an optional dependency on <varname>gtkspell</varname>, which is only built if <varname>spellCheck</varname> is <literal>true</literal>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Apache HTTPD: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/http/apache-httpd/2.4.nix"><filename>pkgs/servers/http/apache-httpd/2.4.nix</filename></link>. A bunch of optional features, variable substitutions in the configure flags, a post-install hook, and miscellaneous hackery. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Thunderbird: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/mailreaders/thunderbird/default.nix"><filename>pkgs/applications/networking/mailreaders/thunderbird/default.nix</filename></link>. Lots of dependencies. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
JDiskReport, a Java utility: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/jdiskreport/default.nix"><filename>pkgs/tools/misc/jdiskreport/default.nix</filename></link>. Nixpkgs doesn’t have a decent <varname>stdenv</varname> for Java yet so this is pretty ad-hoc. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
XML::Simple, a Perl module: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/perl-packages.nix"><filename>pkgs/top-level/perl-packages.nix</filename></link> (search for the <varname>XMLSimple</varname> attribute). Most Perl modules are so simple to build that they are defined directly in <filename>perl-packages.nix</filename>; no need to make a separate file for them. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Adobe Reader: <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/adobe-reader/default.nix"><filename>pkgs/applications/misc/adobe-reader/default.nix</filename></link>. Shows how binary-only packages can be supported. In particular the <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/adobe-reader/builder.sh">builder</link> uses <command>patchelf</command> to set the RUNPATH and ELF interpreter of the executables so that the right libraries are found at runtime. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</para> |
||||
<para> |
||||
Some notes: |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
All <varname linkend="chap-meta">meta</varname> attributes are optional, but it’s still a good idea to provide at least the <varname>description</varname>, <varname>homepage</varname> and <varname |
||||
linkend="sec-meta-license">license</varname>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
You can use <command>nix-prefetch-url</command> <replaceable>url</replaceable> to get the SHA-256 hash of source distributions. There are similar commands as <command>nix-prefetch-git</command> and <command>nix-prefetch-hg</command> available in <literal>nix-prefetch-scripts</literal> package. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
A list of schemes for <literal>mirror://</literal> URLs can be found in <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/fetchurl/mirrors.nix"><filename>pkgs/build-support/fetchurl/mirrors.nix</filename></link>. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</para> |
||||
<para> |
||||
The exact syntax and semantics of the Nix expression language, including the built-in function, are described in the Nix manual in the <link |
||||
xlink:href="https://hydra.nixos.org/job/nix/trunk/tarball/latest/download-by-type/doc/manual/#chap-writing-nix-expressions">chapter on writing Nix expressions</link>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Add a call to the function defined in the previous step to <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix"><filename>pkgs/top-level/all-packages.nix</filename></link> with some descriptive name for the variable, e.g. <varname>libfoo</varname>. |
||||
<screen> |
||||
<prompt>$ </prompt>emacs pkgs/top-level/all-packages.nix</screen> |
||||
</para> |
||||
<para> |
||||
The attributes in that file are sorted by category (like “Development / Libraries”) that more-or-less correspond to the directory structure of Nixpkgs, and then by attribute name. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
To test whether the package builds, run the following command from the root of the nixpkgs source tree: |
||||
<screen> |
||||
<prompt>$ </prompt>nix-build -A libfoo</screen> |
||||
where <varname>libfoo</varname> should be the variable name defined in the previous step. You may want to add the flag <option>-K</option> to keep the temporary build directory in case something fails. If the build succeeds, a symlink <filename>./result</filename> to the package in the Nix store is created. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
If you want to install the package into your profile (optional), do |
||||
<screen> |
||||
<prompt>$ </prompt>nix-env -f . -iA libfoo</screen> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Optionally commit the new package and open a pull request <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/pulls">to nixpkgs</link>, or use <link |
||||
xlink:href="https://discourse.nixos.org/t/about-the-patches-category/477"> the Patches category</link> on Discourse for sending a patch without a GitHub account. |
||||
</para> |
||||
</listitem> |
||||
</orderedlist> |
||||
</para> |
||||
</chapter> |
@ -0,0 +1,207 @@ |
||||
# Reviewing contributions {#chap-reviewing-contributions} |
||||
|
||||
::: {.warning} |
||||
The following section is a draft, and the policy for reviewing is still being discussed in issues such as [#11166](https://github.com/NixOS/nixpkgs/issues/11166) and [#20836](https://github.com/NixOS/nixpkgs/issues/20836). |
||||
::: |
||||
|
||||
The Nixpkgs project receives a fairly high number of contributions via GitHub pull requests. Reviewing and approving these is an important task and a way to contribute to the project. |
||||
|
||||
The high change rate of Nixpkgs makes any pull request that remains open for too long subject to conflicts that will require extra work from the submitter or the merger. Reviewing pull requests in a timely manner and being responsive to the comments is the key to avoid this issue. GitHub provides sort filters that can be used to see the [most recently](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc) and the [least recently](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc) updated pull requests. We highly encourage looking at [this list of ready to merge, unreviewed pull requests](https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone). |
||||
|
||||
When reviewing a pull request, please always be nice and polite. Controversial changes can lead to controversial opinions, but it is important to respect every community member and their work. |
||||
|
||||
GitHub provides reactions as a simple and quick way to provide feedback to pull requests or any comments. The thumb-down reaction should be used with care and if possible accompanied with some explanation so the submitter has directions to improve their contribution. |
||||
|
||||
pull request reviews should include a list of what has been reviewed in a comment, so other reviewers and mergers can know the state of the review. |
||||
|
||||
All the review template samples provided in this section are generic and meant as examples. Their usage is optional and the reviewer is free to adapt them to their liking. |
||||
|
||||
## Package updates {#reviewing-contributions-package-updates} |
||||
|
||||
A package update is the most trivial and common type of pull request. These pull requests mainly consist of updating the version part of the package name and the source hash. |
||||
|
||||
It can happen that non-trivial updates include patches or more complex changes. |
||||
|
||||
Reviewing process: |
||||
|
||||
- Ensure that the package versioning fits the guidelines. |
||||
- Ensure that the commit text fits the guidelines. |
||||
- Ensure that the package maintainers are notified. |
||||
- [CODEOWNERS](https://help.github.com/articles/about-codeowners) will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers. |
||||
- Ensure that the meta field information is correct. |
||||
- License can change with version updates, so it should be checked to match the upstream license. |
||||
- If the package has no maintainer, a maintainer must be set. This can be the update submitter or a community member that accepts to take maintainership of the package. |
||||
- Ensure that the code contains no typos. |
||||
- Building the package locally. |
||||
- pull requests are often targeted to the master or staging branch, and building the pull request locally when it is submitted can trigger many source builds. |
||||
- It is possible to rebase the changes on nixos-unstable or nixpkgs-unstable for easier review by running the following commands from a nixpkgs clone. |
||||
|
||||
```ShellSession |
||||
$ git fetch origin nixos-unstable |
||||
$ git fetch origin pull/PRNUMBER/head |
||||
$ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD |
||||
``` |
||||
|
||||
- The first command fetches the nixos-unstable branch. |
||||
- The second command fetches the pull request changes, `PRNUMBER` is the number at the end of the pull request title and `BASEBRANCH` the base branch of the pull request. |
||||
- The third command rebases the pull request changes to the nixos-unstable branch. |
||||
- The [nixpkgs-review](https://github.com/Mic92/nixpkgs-review) tool can be used to review a pull request content in a single command. `PRNUMBER` should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url. |
||||
|
||||
```ShellSession |
||||
$ nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER" |
||||
``` |
||||
- Running every binary. |
||||
|
||||
Sample template for a package update review is provided below. |
||||
|
||||
```markdown |
||||
##### Reviewed points |
||||
|
||||
- [ ] package name fits guidelines |
||||
- [ ] package version fits guidelines |
||||
- [ ] package build on ARCHITECTURE |
||||
- [ ] executables tested on ARCHITECTURE |
||||
- [ ] all depending packages build |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
``` |
||||
|
||||
## New packages {#reviewing-contributions-new-packages} |
||||
|
||||
New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package. |
||||
|
||||
Review process: |
||||
|
||||
- Ensure that the package versioning fits the guidelines. |
||||
- Ensure that the commit name fits the guidelines. |
||||
- Ensure that the meta fields contain correct information. |
||||
- License must match the upstream license. |
||||
- Platforms should be set (or the package will not get binary substitutes). |
||||
- Maintainers must be set. This can be the package submitter or a community member that accepts taking up maintainership of the package. |
||||
- Report detected typos. |
||||
- Ensure the package source: |
||||
- Uses mirror URLs when available. |
||||
- Uses the most appropriate functions (e.g. packages from GitHub should use `fetchFromGitHub`). |
||||
- Building the package locally. |
||||
- Running every binary. |
||||
|
||||
Sample template for a new package review is provided below. |
||||
|
||||
```markdown |
||||
##### Reviewed points |
||||
|
||||
- [ ] package path fits guidelines |
||||
- [ ] package name fits guidelines |
||||
- [ ] package version fits guidelines |
||||
- [ ] package build on ARCHITECTURE |
||||
- [ ] executables tested on ARCHITECTURE |
||||
- [ ] `meta.description` is set and fits guidelines |
||||
- [ ] `meta.license` fits upstream license |
||||
- [ ] `meta.platforms` is set |
||||
- [ ] `meta.maintainers` is set |
||||
- [ ] build time only dependencies are declared in `nativeBuildInputs` |
||||
- [ ] source is fetched using the appropriate function |
||||
- [ ] phases are respected |
||||
- [ ] patches that are remotely available are fetched with `fetchpatch` |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
``` |
||||
|
||||
## Module updates {#reviewing-contributions-module-updates} |
||||
|
||||
Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options. |
||||
|
||||
Reviewing process: |
||||
|
||||
- Ensure that the module maintainers are notified. |
||||
- [CODEOWNERS](https://help.github.com/articles/about-codeowners/) will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers. |
||||
- Ensure that the module tests, if any, are succeeding. |
||||
- Ensure that the introduced options are correct. |
||||
- Type should be appropriate (string related types differs in their merging capabilities, `optionSet` and `string` types are deprecated). |
||||
- Description, default and example should be provided. |
||||
- Ensure that option changes are backward compatible. |
||||
- `mkRenamedOptionModule` and `mkAliasOptionModule` functions provide way to make option changes backward compatible. |
||||
- Ensure that removed options are declared with `mkRemovedOptionModule` |
||||
- Ensure that changes that are not backward compatible are mentioned in release notes. |
||||
- Ensure that documentations affected by the change is updated. |
||||
|
||||
Sample template for a module update review is provided below. |
||||
|
||||
```markdown |
||||
##### Reviewed points |
||||
|
||||
- [ ] changes are backward compatible |
||||
- [ ] removed options are declared with `mkRemovedOptionModule` |
||||
- [ ] changes that are not backward compatible are documented in release notes |
||||
- [ ] module tests succeed on ARCHITECTURE |
||||
- [ ] options types are appropriate |
||||
- [ ] options description is set |
||||
- [ ] options example is provided |
||||
- [ ] documentation affected by the changes is updated |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
``` |
||||
|
||||
## New modules {#reviewing-contributions-new-modules} |
||||
|
||||
New modules submissions introduce a new module to NixOS. |
||||
|
||||
Reviewing process: |
||||
|
||||
- Ensure that the module tests, if any, are succeeding. |
||||
- Ensure that the introduced options are correct. |
||||
- Type should be appropriate (string related types differs in their merging capabilities, `optionSet` and `string` types are deprecated). |
||||
- Description, default and example should be provided. |
||||
- Ensure that module `meta` field is present |
||||
- Maintainers should be declared in `meta.maintainers`. |
||||
- Module documentation should be declared with `meta.doc`. |
||||
- Ensure that the module respect other modules functionality. |
||||
- For example, enabling a module should not open firewall ports by default. |
||||
|
||||
Sample template for a new module review is provided below. |
||||
|
||||
```markdown |
||||
##### Reviewed points |
||||
|
||||
- [ ] module path fits the guidelines |
||||
- [ ] module tests succeed on ARCHITECTURE |
||||
- [ ] options have appropriate types |
||||
- [ ] options have default |
||||
- [ ] options have example |
||||
- [ ] options have descriptions |
||||
- [ ] No unneeded package is added to environment.systemPackages |
||||
- [ ] meta.maintainers is set |
||||
- [ ] module documentation is declared in meta.doc |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
``` |
||||
|
||||
## Other submissions {#reviewing-contributions-other-submissions} |
||||
|
||||
Other type of submissions requires different reviewing steps. |
||||
|
||||
If you consider having enough knowledge and experience in a topic and would like to be a long-term reviewer for related submissions, please contact the current reviewers for that topic. They will give you information about the reviewing process. The main reviewers for a topic can be hard to find as there is no list, but checking past pull requests to see who reviewed or git-blaming the code to see who committed to that topic can give some hints. |
||||
|
||||
Container system, boot system and library changes are some examples of the pull requests fitting this category. |
||||
|
||||
## Merging pull requests {#reviewing-contributions--merging-pull-requests} |
||||
|
||||
It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests. |
||||
|
||||
<!-- |
||||
The following paragraphs about how to deal with unactive contributors is just a proposition and should be modified to what the community agrees to be the right policy. |
||||
|
||||
Please note that contributors with commit rights unactive for more than three months will have their commit rights revoked. |
||||
--> |
||||
|
||||
Please see the discussion in [GitHub nixpkgs issue #50105](https://github.com/NixOS/nixpkgs/issues/50105) for information on how to proceed to be granted this level of access. |
||||
|
||||
In a case a contributor definitively leaves the Nix community, they should create an issue or post on [Discourse](https://discourse.nixos.org) with references of packages and modules they maintain so the maintainership can be taken over by other contributors. |
@ -1,488 +0,0 @@ |
||||
<chapter xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
version="5.0" |
||||
xml:id="chap-reviewing-contributions"> |
||||
<title>Reviewing contributions</title> |
||||
<warning> |
||||
<para> |
||||
The following section is a draft, and the policy for reviewing is still being discussed in issues such as <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/11166">#11166 </link> and <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/issues/20836">#20836 </link>. |
||||
</para> |
||||
</warning> |
||||
<para> |
||||
The Nixpkgs project receives a fairly high number of contributions via GitHub pull requests. Reviewing and approving these is an important task and a way to contribute to the project. |
||||
</para> |
||||
<para> |
||||
The high change rate of Nixpkgs makes any pull request that remains open for too long subject to conflicts that will require extra work from the submitter or the merger. Reviewing pull requests in a timely manner and being responsive to the comments is the key to avoid this issue. GitHub provides sort filters that can be used to see the <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc">most recently</link> and the <link |
||||
xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-asc">least recently</link> updated pull requests. We highly encourage looking at <link xlink:href="https://github.com/NixOS/nixpkgs/pulls?q=is%3Apr+is%3Aopen+review%3Anone+status%3Asuccess+-label%3A%222.status%3A+work-in-progress%22+no%3Aproject+no%3Aassignee+no%3Amilestone"> this list of ready to merge, unreviewed pull requests</link>. |
||||
</para> |
||||
<para> |
||||
When reviewing a pull request, please always be nice and polite. Controversial changes can lead to controversial opinions, but it is important to respect every community member and their work. |
||||
</para> |
||||
<para> |
||||
GitHub provides reactions as a simple and quick way to provide feedback to pull requests or any comments. The thumb-down reaction should be used with care and if possible accompanied with some explanation so the submitter has directions to improve their contribution. |
||||
</para> |
||||
<para> |
||||
pull request reviews should include a list of what has been reviewed in a comment, so other reviewers and mergers can know the state of the review. |
||||
</para> |
||||
<para> |
||||
All the review template samples provided in this section are generic and meant as examples. Their usage is optional and the reviewer is free to adapt them to their liking. |
||||
</para> |
||||
<section xml:id="reviewing-contributions-package-updates"> |
||||
<title>Package updates</title> |
||||
|
||||
<para> |
||||
A package update is the most trivial and common type of pull request. These pull requests mainly consist of updating the version part of the package name and the source hash. |
||||
</para> |
||||
|
||||
<para> |
||||
It can happen that non-trivial updates include patches or more complex changes. |
||||
</para> |
||||
|
||||
<para> |
||||
Reviewing process: |
||||
</para> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the package versioning fits the guidelines. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the commit text fits the guidelines. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the package maintainers are notified. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
<link xlink:href="https://help.github.com/articles/about-codeowners/">CODEOWNERS</link> will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the meta field information is correct. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
License can change with version updates, so it should be checked to match the upstream license. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
If the package has no maintainer, a maintainer must be set. This can be the update submitter or a community member that accepts to take maintainership of the package. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the code contains no typos. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Building the package locally. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
pull requests are often targeted to the master or staging branch, and building the pull request locally when it is submitted can trigger many source builds. |
||||
</para> |
||||
<para> |
||||
It is possible to rebase the changes on nixos-unstable or nixpkgs-unstable for easier review by running the following commands from a nixpkgs clone. |
||||
<screen> |
||||
<prompt>$ </prompt>git fetch origin nixos-unstable <co xml:id='reviewing-rebase-2' /> |
||||
<prompt>$ </prompt>git fetch origin pull/PRNUMBER/head <co xml:id='reviewing-rebase-3' /> |
||||
<prompt>$ </prompt>git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD <co |
||||
xml:id='reviewing-rebase-4' /> |
||||
</screen> |
||||
<calloutlist> |
||||
<callout arearefs='reviewing-rebase-2'> |
||||
<para> |
||||
Fetching the nixos-unstable branch. |
||||
</para> |
||||
</callout> |
||||
<callout arearefs='reviewing-rebase-3'> |
||||
<para> |
||||
Fetching the pull request changes, <varname>PRNUMBER</varname> is the number at the end of the pull request title and <varname>BASEBRANCH</varname> the base branch of the pull request. |
||||
</para> |
||||
</callout> |
||||
<callout arearefs='reviewing-rebase-4'> |
||||
<para> |
||||
Rebasing the pull request changes to the nixos-unstable branch. |
||||
</para> |
||||
</callout> |
||||
</calloutlist> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The <link xlink:href="https://github.com/Mic92/nixpkgs-review">nixpkgs-review</link> tool can be used to review a pull request content in a single command. <varname>PRNUMBER</varname> should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url. |
||||
</para> |
||||
<screen> |
||||
<prompt>$ </prompt>nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER" |
||||
</screen> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Running every binary. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
|
||||
<example xml:id="reviewing-contributions-sample-package-update"> |
||||
<title>Sample template for a package update review</title> |
||||
<screen> |
||||
##### Reviewed points |
||||
|
||||
- [ ] package name fits guidelines |
||||
- [ ] package version fits guidelines |
||||
- [ ] package build on ARCHITECTURE |
||||
- [ ] executables tested on ARCHITECTURE |
||||
- [ ] all depending packages build |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
|
||||
</screen> |
||||
</example> |
||||
</section> |
||||
<section xml:id="reviewing-contributions-new-packages"> |
||||
<title>New packages</title> |
||||
|
||||
<para> |
||||
New packages are a common type of pull requests. These pull requests consists in adding a new nix-expression for a package. |
||||
</para> |
||||
|
||||
<para> |
||||
Reviewing process: |
||||
</para> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the package versioning is fitting the guidelines. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the commit name is fitting the guidelines. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the meta field contains correct information. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
License must be checked to be fitting upstream license. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Platforms should be set or the package will not get binary substitutes. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
A maintainer must be set. This can be the package submitter or a community member that accepts to take maintainership of the package. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the code contains no typos. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure the package source. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Mirrors urls should be used when available. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
The most appropriate function should be used (e.g. packages from GitHub should use <literal>fetchFromGitHub</literal>). |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Building the package locally. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Running every binary. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
|
||||
<example xml:id="reviewing-contributions-sample-new-package"> |
||||
<title>Sample template for a new package review</title> |
||||
<screen> |
||||
##### Reviewed points |
||||
|
||||
- [ ] package path fits guidelines |
||||
- [ ] package name fits guidelines |
||||
- [ ] package version fits guidelines |
||||
- [ ] package build on ARCHITECTURE |
||||
- [ ] executables tested on ARCHITECTURE |
||||
- [ ] `meta.description` is set and fits guidelines |
||||
- [ ] `meta.license` fits upstream license |
||||
- [ ] `meta.platforms` is set |
||||
- [ ] `meta.maintainers` is set |
||||
- [ ] build time only dependencies are declared in `nativeBuildInputs` |
||||
- [ ] source is fetched using the appropriate function |
||||
- [ ] phases are respected |
||||
- [ ] patches that are remotely available are fetched with `fetchpatch` |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
|
||||
</screen> |
||||
</example> |
||||
</section> |
||||
<section xml:id="reviewing-contributions-module-updates"> |
||||
<title>Module updates</title> |
||||
|
||||
<para> |
||||
Module updates are submissions changing modules in some ways. These often contains changes to the options or introduce new options. |
||||
</para> |
||||
|
||||
<para> |
||||
Reviewing process |
||||
</para> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the module maintainers are notified. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
<link xlink:href="https://help.github.com/articles/about-codeowners/">CODEOWNERS</link> will make GitHub notify users based on the submitted changes, but it can happen that it misses some of the package maintainers. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the module tests, if any, are succeeding. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the introduced options are correct. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Type should be appropriate (string related types differs in their merging capabilities, <literal>optionSet</literal> and <literal>string</literal> types are deprecated). |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Description, default and example should be provided. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that option changes are backward compatible. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
<literal>mkRenamedOptionModule</literal> and <literal>mkAliasOptionModule</literal> functions provide way to make option changes backward compatible. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that removed options are declared with <literal>mkRemovedOptionModule</literal> |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that changes that are not backward compatible are mentioned in release notes. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that documentations affected by the change is updated. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
|
||||
<example xml:id="reviewing-contributions-sample-module-update"> |
||||
<title>Sample template for a module update review</title> |
||||
<screen> |
||||
##### Reviewed points |
||||
|
||||
- [ ] changes are backward compatible |
||||
- [ ] removed options are declared with `mkRemovedOptionModule` |
||||
- [ ] changes that are not backward compatible are documented in release notes |
||||
- [ ] module tests succeed on ARCHITECTURE |
||||
- [ ] options types are appropriate |
||||
- [ ] options description is set |
||||
- [ ] options example is provided |
||||
- [ ] documentation affected by the changes is updated |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
|
||||
</screen> |
||||
</example> |
||||
</section> |
||||
<section xml:id="reviewing-contributions-new-modules"> |
||||
<title>New modules</title> |
||||
|
||||
<para> |
||||
New modules submissions introduce a new module to NixOS. |
||||
</para> |
||||
|
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the module tests, if any, are succeeding. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the introduced options are correct. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Type should be appropriate (string related types differs in their merging capabilities, <literal>optionSet</literal> and <literal>string</literal> types are deprecated). |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Description, default and example should be provided. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that module <literal>meta</literal> field is present |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
Maintainers should be declared in <literal>meta.maintainers</literal>. |
||||
</para> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Module documentation should be declared with <literal>meta.doc</literal>. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
<listitem> |
||||
<para> |
||||
Ensure that the module respect other modules functionality. |
||||
</para> |
||||
<itemizedlist> |
||||
<listitem> |
||||
<para> |
||||
For example, enabling a module should not open firewall ports by default. |
||||
</para> |
||||
</listitem> |
||||
</itemizedlist> |
||||
</listitem> |
||||
</itemizedlist> |
||||
|
||||
<example xml:id="reviewing-contributions-sample-new-module"> |
||||
<title>Sample template for a new module review</title> |
||||
<screen> |
||||
##### Reviewed points |
||||
|
||||
- [ ] module path fits the guidelines |
||||
- [ ] module tests succeed on ARCHITECTURE |
||||
- [ ] options have appropriate types |
||||
- [ ] options have default |
||||
- [ ] options have example |
||||
- [ ] options have descriptions |
||||
- [ ] No unneeded package is added to environment.systemPackages |
||||
- [ ] meta.maintainers is set |
||||
- [ ] module documentation is declared in meta.doc |
||||
|
||||
##### Possible improvements |
||||
|
||||
##### Comments |
||||
|
||||
</screen> |
||||
</example> |
||||
</section> |
||||
<section xml:id="reviewing-contributions-other-submissions"> |
||||
<title>Other submissions</title> |
||||
|
||||
<para> |
||||
Other type of submissions requires different reviewing steps. |
||||
</para> |
||||
|
||||
<para> |
||||
If you consider having enough knowledge and experience in a topic and would like to be a long-term reviewer for related submissions, please contact the current reviewers for that topic. They will give you information about the reviewing process. The main reviewers for a topic can be hard to find as there is no list, but checking past pull requests to see who reviewed or git-blaming the code to see who committed to that topic can give some hints. |
||||
</para> |
||||
|
||||
<para> |
||||
Container system, boot system and library changes are some examples of the pull requests fitting this category. |
||||
</para> |
||||
</section> |
||||
<section xml:id="reviewing-contributions--merging-pull-requests"> |
||||
<title>Merging pull requests</title> |
||||
|
||||
<para> |
||||
It is possible for community members that have enough knowledge and experience on a special topic to contribute by merging pull requests. |
||||
</para> |
||||
|
||||
<!-- |
||||
The following paragraphs about how to deal with unactive contributors is just a |
||||
proposition and should be modified to what the community agrees to be the right |
||||
policy. |
||||
|
||||
<para>Please note that contributors with commit rights unactive for more than |
||||
three months will have their commit rights revoked.</para> |
||||
--> |
||||
|
||||
<para> |
||||
Please see the discussion in <link xlink:href="https://github.com/NixOS/nixpkgs/issues/50105">GitHub nixpkgs issue #50105</link> for information on how to proceed to be granted this level of access. |
||||
</para> |
||||
|
||||
<para> |
||||
In a case a contributor definitively leaves the Nix community, they should create an issue or post on <link |
||||
xlink:href="https://discourse.nixos.org">Discourse</link> with references of packages and modules they maintain so the maintainership can be taken over by other contributors. |
||||
</para> |
||||
</section> |
||||
</chapter> |
@ -0,0 +1,45 @@ |
||||
# Vulnerability Roundup {#chap-vulnerability-roundup} |
||||
|
||||
## Issues {#vulnerability-roundup-issues} |
||||
|
||||
Vulnerable packages in Nixpkgs are managed using issues. |
||||
Currently opened ones can be found using the following: |
||||
|
||||
[github.com/NixOS/nixpkgs/issues?q=is:issue+is:open+"Vulnerability+roundup"](https://github.com/NixOS/nixpkgs/issues?q=is%3Aissue+is%3Aopen+%22Vulnerability+roundup%22) |
||||
|
||||
Each issue correspond to a vulnerable version of a package; As a consequence: |
||||
|
||||
- One issue can contain several CVEs; |
||||
- One CVE can be shared across several issues; |
||||
- A single package can be concerned by several issues. |
||||
|
||||
|
||||
A "Vulnerability roundup" issue usually respects the following format: |
||||
|
||||
```txt |
||||
<link to relevant package search on search.nix.gsc.io>, <link to relevant files in Nixpkgs on GitHub> |
||||
|
||||
<list of related CVEs, their CVSS score, and the impacted NixOS version> |
||||
|
||||
<list of the scanned Nixpkgs versions> |
||||
|
||||
<list of relevant contributors> |
||||
``` |
||||
|
||||
Note that there can be an extra comment containing links to previously reported (and still open) issues for the same package. |
||||
|
||||
|
||||
## Triaging and Fixing {#vulnerability-roundup-triaging-and-fixing} |
||||
|
||||
**Note**: An issue can be a "false positive" (i.e. automatically opened, but without the package it refers to being actually vulnerable). |
||||
If you find such a "false positive", comment on the issue an explanation of why it falls into this category, linking as much information as the necessary to help maintainers double check. |
||||
|
||||
If you are investigating a "true positive": |
||||
|
||||
- Find the earliest patched version or a code patch in the CVE details; |
||||
- Is the issue already patched (version up-to-date or patch applied manually) in Nixpkgs's `master` branch? |
||||
- **No**: |
||||
- [Submit a security fix](#submitting-changes-submitting-security-fixes); |
||||
- Once the fix is merged into `master`, [submit the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches); |
||||
- **Yes**: [Backport the change to the vulnerable release branch(es)](https://nixos.org/manual/nixpkgs/stable/#submitting-changes-stable-release-branches). |
||||
- When the patch has made it into all the relevant branches (`master`, and the vulnerable releases), close the relevant issue(s). |
@ -0,0 +1,5 @@ |
||||
# Debugging Nix Expressions {#sec-debug} |
||||
|
||||
Nix is a unityped, dynamic language, this means every value can potentially appear anywhere. Since it is also non-strict, evaluation order and what ultimately is evaluated might surprise you. Therefore it is important to be able to debug nix expressions. |
||||
|
||||
In the `lib/debug.nix` file you will find a number of functions that help (pretty-)printing values while evaluation is running. You can even specify how deep these values should be printed recursively, and transform them on the fly. Please consult the docstrings in `lib/debug.nix` for usage information. |
@ -1,14 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
xml:id="sec-debug"> |
||||
<title>Debugging Nix Expressions</title> |
||||
|
||||
<para> |
||||
Nix is a unityped, dynamic language, this means every value can potentially appear anywhere. Since it is also non-strict, evaluation order and what ultimately is evaluated might surprise you. Therefore it is important to be able to debug nix expressions. |
||||
</para> |
||||
|
||||
<para> |
||||
In the <literal>lib/debug.nix</literal> file you will find a number of functions that help (pretty-)printing values while evaluation is runnnig. You can even specify how deep these values should be printed recursively, and transform them on the fly. Please consult the docstrings in <literal>lib/debug.nix</literal> for usage information. |
||||
</para> |
||||
</section> |
@ -0,0 +1,49 @@ |
||||
# pkgs.nix-gitignore {#sec-pkgs-nix-gitignore} |
||||
|
||||
`pkgs.nix-gitignore` is a function that acts similarly to `builtins.filterSource` but also allows filtering with the help of the gitignore format. |
||||
|
||||
## Usage {#sec-pkgs-nix-gitignore-usage} |
||||
|
||||
`pkgs.nix-gitignore` exports a number of functions, but you\'ll most likely need either `gitignoreSource` or `gitignoreSourcePure`. As their first argument, they both accept either 1. a file with gitignore lines or 2. a string with gitignore lines, or 3. a list of either of the two. They will be concatenated into a single big string. |
||||
|
||||
```nix |
||||
{ pkgs ? import <nixpkgs> {} }: |
||||
|
||||
nix-gitignore.gitignoreSource [] ./source |
||||
# Simplest version |
||||
|
||||
nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source |
||||
# This one reads the ./source/.gitignore and concats the auxiliary ignores |
||||
|
||||
nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source |
||||
# Use this string as gitignore, don't read ./source/.gitignore. |
||||
|
||||
nix-gitignore.gitignoreSourcePure ["ignore-this\nignore-that\n", ~/.gitignore] ./source |
||||
# It also accepts a list (of strings and paths) that will be concatenated |
||||
# once the paths are turned to strings via readFile. |
||||
``` |
||||
|
||||
These functions are derived from the `Filter` functions by setting the first filter argument to `(_: _: true)`: |
||||
|
||||
```nix |
||||
gitignoreSourcePure = gitignoreFilterSourcePure (_: _: true); |
||||
gitignoreSource = gitignoreFilterSource (_: _: true); |
||||
``` |
||||
|
||||
Those filter functions accept the same arguments the `builtins.filterSource` function would pass to its filters, thus `fn: gitignoreFilterSourcePure fn ""` should be extensionally equivalent to `filterSource`. The file is blacklisted if it\'s blacklisted by either your filter or the gitignoreFilter. |
||||
|
||||
If you want to make your own filter from scratch, you may use |
||||
|
||||
```nix |
||||
gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root; |
||||
``` |
||||
|
||||
## gitignore files in subdirectories {#sec-pkgs-nix-gitignore-usage-recursive} |
||||
|
||||
If you wish to use a filter that would search for .gitignore files in subdirectories, just like git does by default, use this function: |
||||
|
||||
```nix |
||||
gitignoreFilterRecursiveSource = filter: patterns: root: |
||||
# OR |
||||
gitignoreRecursiveSource = gitignoreFilterSourcePure (_: _: true); |
||||
``` |
@ -1,70 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/XInclude" |
||||
xml:id="sec-pkgs-nix-gitignore"> |
||||
<title>pkgs.nix-gitignore</title> |
||||
|
||||
<para> |
||||
<function>pkgs.nix-gitignore</function> is a function that acts similarly to <literal>builtins.filterSource</literal> but also allows filtering with the help of the gitignore format. |
||||
</para> |
||||
|
||||
<section xml:id="sec-pkgs-nix-gitignore-usage"> |
||||
<title>Usage</title> |
||||
|
||||
<para> |
||||
<literal>pkgs.nix-gitignore</literal> exports a number of functions, but you'll most likely need either <literal>gitignoreSource</literal> or <literal>gitignoreSourcePure</literal>. As their first argument, they both accept either 1. a file with gitignore lines or 2. a string with gitignore lines, or 3. a list of either of the two. They will be concatenated into a single big string. |
||||
</para> |
||||
|
||||
<programlisting><![CDATA[ |
||||
{ pkgs ? import <nixpkgs> {} }: |
||||
|
||||
nix-gitignore.gitignoreSource [] ./source |
||||
# Simplest version |
||||
|
||||
nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source |
||||
# This one reads the ./source/.gitignore and concats the auxiliary ignores |
||||
|
||||
nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source |
||||
# Use this string as gitignore, don't read ./source/.gitignore. |
||||
|
||||
nix-gitignore.gitignoreSourcePure ["ignore-this\nignore-that\n", ~/.gitignore] ./source |
||||
# It also accepts a list (of strings and paths) that will be concatenated |
||||
# once the paths are turned to strings via readFile. |
||||
]]></programlisting> |
||||
|
||||
<para> |
||||
These functions are derived from the <literal>Filter</literal> functions by setting the first filter argument to <literal>(_: _: true)</literal>: |
||||
</para> |
||||
|
||||
<programlisting><![CDATA[ |
||||
gitignoreSourcePure = gitignoreFilterSourcePure (_: _: true); |
||||
gitignoreSource = gitignoreFilterSource (_: _: true); |
||||
]]></programlisting> |
||||
|
||||
<para> |
||||
Those filter functions accept the same arguments the <literal>builtins.filterSource</literal> function would pass to its filters, thus <literal>fn: gitignoreFilterSourcePure fn ""</literal> should be extensionally equivalent to <literal>filterSource</literal>. The file is blacklisted iff it's blacklisted by either your filter or the gitignoreFilter. |
||||
</para> |
||||
|
||||
<para> |
||||
If you want to make your own filter from scratch, you may use |
||||
</para> |
||||
|
||||
<programlisting><![CDATA[ |
||||
gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root; |
||||
]]></programlisting> |
||||
</section> |
||||
|
||||
<section xml:id="sec-pkgs-nix-gitignore-usage-recursive"> |
||||
<title>gitignore files in subdirectories</title> |
||||
|
||||
<para> |
||||
If you wish to use a filter that would search for .gitignore files in subdirectories, just like git does by default, use this function: |
||||
</para> |
||||
|
||||
<programlisting><![CDATA[ |
||||
gitignoreFilterRecursiveSource = filter: patterns: root: |
||||
# OR |
||||
gitignoreRecursiveSource = gitignoreFilterSourcePure (_: _: true); |
||||
]]></programlisting> |
||||
</section> |
||||
</section> |
@ -0,0 +1,17 @@ |
||||
# prefer-remote-fetch overlay {#sec-prefer-remote-fetch} |
||||
|
||||
`prefer-remote-fetch` is an overlay that download sources on remote builder. This is useful when the evaluating machine has a slow upload while the builder can fetch faster directly from the source. To use it, put the following snippet as a new overlay: |
||||
|
||||
```nix |
||||
self: super: |
||||
(super.prefer-remote-fetch self super) |
||||
``` |
||||
|
||||
A full configuration example for that sets the overlay up for your own account, could look like this |
||||
|
||||
```ShellSession |
||||
$ mkdir ~/.config/nixpkgs/overlays/ |
||||
$ cat > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix <<EOF |
||||
self: super: super.prefer-remote-fetch self super |
||||
EOF |
||||
``` |
@ -1,21 +0,0 @@ |
||||
<section xmlns="http://docbook.org/ns/docbook" |
||||
xmlns:xlink="http://www.w3.org/1999/xlink" |
||||
xmlns:xi="http://www.w3.org/2001/xinclude" |
||||
xml:id="sec-prefer-remote-fetch"> |
||||
<title>prefer-remote-fetch overlay</title> |
||||
|
||||
<para> |
||||
<function>prefer-remote-fetch</function> is an overlay that download sources on remote builder. This is useful when the evaluating machine has a slow upload while the builder can fetch faster directly from the source. To use it, put the following snippet as a new overlay: |
||||
<programlisting> |
||||
self: super: |
||||
(super.prefer-remote-fetch self super) |
||||
</programlisting> |
||||
A full configuration example for that sets the overlay up for your own account, could look like this |
||||
<screen> |
||||
<prompt>$ </prompt>mkdir ~/.config/nixpkgs/overlays/ |
||||
<prompt>$ </prompt>cat > ~/.config/nixpkgs/overlays/prefer-remote-fetch.nix <<EOF |
||||
self: super: super.prefer-remote-fetch self super |
||||
EOF |
||||
</screen> |
||||
</para> |
||||
</section> |
@ -0,0 +1,24 @@ |
||||
local function starts_with(start, str) |
||||
return str:sub(1, #start) == start |
||||
end |
||||
|
||||
local function escape_xml_arg(arg) |
||||
amps = arg:gsub('&', '&') |
||||
amps_quotes = amps:gsub('"', '"') |
||||
amps_quotes_lt = amps_quotes:gsub('<', '<') |
||||
|
||||
return amps_quotes_lt |
||||
end |
||||
|
||||
function Link(elem) |
||||
has_no_content = #elem.content == 0 |
||||
targets_anchor = starts_with('#', elem.target) |
||||
has_no_attributes = elem.title == '' and elem.identifier == '' and #elem.classes == 0 and #elem.attributes == 0 |
||||
|
||||
if has_no_content and targets_anchor and has_no_attributes then |
||||
-- xref expects idref without the pound-sign |
||||
target_without_hash = elem.target:sub(2, #elem.target) |
||||
|
||||
return pandoc.RawInline('docbook', '<xref linkend="' .. escape_xml_arg(target_without_hash) .. '" />') |
||||
end |
||||
end |
@ -0,0 +1,31 @@ |
||||
# Hy {#sec-language-hy} |
||||
|
||||
## Installation {#ssec-hy-installation} |
||||
|
||||
### Installation without packages {#installation-without-packages} |
||||
|
||||
You can install `hy` via nix-env or by adding it to `configuration.nix` by reffering to it as a `hy` attribute. This kind of installation adds `hy` to your environment and it succesfully works with `python3`. |
||||
|
||||
::: {.caution} |
||||
Packages that are installed with your python derivation, are not accesible by `hy` this way. |
||||
::: |
||||
|
||||
### Installation with packages {#installation-with-packages} |
||||
|
||||
Creating `hy` derivation with custom `python` packages is really simple and similar to the way that python does it. Attribute `hy` provides function `withPackages` that creates custom `hy` derivation with specified packages. |
||||
|
||||
For example if you want to create shell with `matplotlib` and `numpy`, you can do it like so: |
||||
|
||||
```ShellSession |
||||
$ nix-shell -p "hy.withPackages (ps: with ps; [ numpy matplotlib ])" |
||||
``` |
||||
|
||||
Or if you want to extend your `configuration.nix`: |
||||
```nix |
||||
{ # ... |
||||
|
||||
environment.systemPackages = with pkgs; [ |
||||
(hy.withPackages (py-packages: with py-packages; [ numpy matplotlib ])) |
||||
]; |
||||
} |
||||
``` |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue