mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-08 22:33:52 +00:00
Compare commits
3 Commits
build-vm-w
...
netboot-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95582ade4c | ||
|
|
fd110f5fea | ||
|
|
5c0bc727e6 |
@@ -17,10 +17,6 @@ end_of_line = unset
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
# We want readFile .version to return the version without a newline.
|
||||
[.version]
|
||||
insert_final_newline = false
|
||||
|
||||
# see https://nixos.org/nixpkgs/manual/#chap-conventions
|
||||
|
||||
# Match json/lockfiles/markdown/nix/perl/python/ruby/shell/docbook files, set indent to spaces
|
||||
@@ -112,7 +108,3 @@ charset = unset
|
||||
[lib/tests/*.plist]
|
||||
indent_style = tab
|
||||
insert_final_newline = unset
|
||||
|
||||
[pkgs/kde/generated/**]
|
||||
insert_final_newline = unset
|
||||
end_of_line = unset
|
||||
|
||||
@@ -96,9 +96,3 @@ fb0e5be84331188a69b3edd31679ca6576edb75a
|
||||
|
||||
# nixos/*: add trivial defaultText for options with simple defaults
|
||||
25124556397ba17bfd70297000270de1e6523b0a
|
||||
|
||||
# systemd: rewrite comments
|
||||
92dfeb7b3dab820ae307c56c216d175c69ee93cd
|
||||
|
||||
# systemd: break too long lines of Nix code
|
||||
67643f8ec84bef1482204709073e417c9f07eb87
|
||||
|
||||
62
.github/CODEOWNERS
vendored
62
.github/CODEOWNERS
vendored
@@ -52,7 +52,6 @@
|
||||
/pkgs/pkgs-lib @infinisil
|
||||
## Format generators/serializers
|
||||
/pkgs/pkgs-lib/formats/libconfig @ckiee @h7x4
|
||||
/pkgs/pkgs-lib/formats/hocon @h7x4
|
||||
|
||||
# pkgs/by-name
|
||||
/pkgs/test/nixpkgs-check-by-name @infinisil
|
||||
@@ -68,8 +67,8 @@
|
||||
/nixos/lib/make-disk-image.nix @raitobezarius
|
||||
|
||||
# Nix, the package manager
|
||||
pkgs/tools/package-management/nix/ @raitobezarius @ma27
|
||||
nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius @ma27
|
||||
pkgs/tools/package-management/nix/ @raitobezarius
|
||||
nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius
|
||||
|
||||
# Nixpkgs documentation
|
||||
/maintainers/scripts/db-to-md.sh @jtojnar @ryantm
|
||||
@@ -131,13 +130,13 @@ nixos/modules/installer/tools/nix-fallback-paths.nix @raitobezarius @ma27
|
||||
/pkgs/development/interpreters/python/hooks @FRidh @jonringer
|
||||
|
||||
# Haskell
|
||||
/doc/languages-frameworks/haskell.section.md @sternenseemann @maralorn @ncfavier
|
||||
/maintainers/scripts/haskell @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/development/compilers/ghc @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/development/haskell-modules @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/test/haskell @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/top-level/release-haskell.nix @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/top-level/haskell-packages.nix @sternenseemann @maralorn @ncfavier
|
||||
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/maintainers/scripts/haskell @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/development/compilers/ghc @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/development/haskell-modules @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/test/haskell @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/top-level/release-haskell.nix @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
/pkgs/top-level/haskell-packages.nix @cdepillabout @sternenseemann @maralorn @ncfavier
|
||||
|
||||
# Perl
|
||||
/pkgs/development/interpreters/perl @stigtsp @zakame @dasJ
|
||||
@@ -185,18 +184,11 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
# Licenses
|
||||
/lib/licenses.nix @alyssais
|
||||
|
||||
# Qt
|
||||
/pkgs/development/libraries/qt-5 @NixOS/qt-kde
|
||||
/pkgs/development/libraries/qt-6 @NixOS/qt-kde
|
||||
|
||||
# KDE / Plasma 5
|
||||
/pkgs/applications/kde @NixOS/qt-kde
|
||||
/pkgs/desktops/plasma-5 @NixOS/qt-kde
|
||||
/pkgs/development/libraries/kde-frameworks @NixOS/qt-kde
|
||||
|
||||
# KDE / Plasma 6
|
||||
/pkgs/kde @NixOS/qt-kde
|
||||
/maintainers/scripts/kde @NixOS/qt-kde
|
||||
# Qt / KDE
|
||||
/pkgs/applications/kde @ttuegel
|
||||
/pkgs/desktops/plasma-5 @ttuegel
|
||||
/pkgs/development/libraries/kde-frameworks @ttuegel
|
||||
/pkgs/development/libraries/qt-5 @ttuegel
|
||||
|
||||
# PostgreSQL and related stuff
|
||||
/pkgs/servers/sql/postgresql @thoughtpolice @marsam
|
||||
@@ -204,10 +196,6 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
/nixos/modules/services/databases/postgresql.nix @thoughtpolice
|
||||
/nixos/tests/postgresql.nix @thoughtpolice
|
||||
|
||||
# Linux kernel
|
||||
/pkgs/os-specific/linux/kernel @raitobezarius
|
||||
/pkgs/top-level/linux-kernels.nix @raitobezarius
|
||||
|
||||
# Hardened profile & related modules
|
||||
/nixos/modules/profiles/hardened.nix @joachifm
|
||||
/nixos/modules/security/hidepid.nix @joachifm
|
||||
@@ -278,13 +266,13 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
||||
/pkgs/applications/editors/vscode/extensions @jonringer
|
||||
|
||||
# PHP interpreter, packages, extensions, tests and documentation
|
||||
/doc/languages-frameworks/php.section.md @aanderse @drupol @globin @ma27 @talyz
|
||||
/nixos/tests/php @aanderse @drupol @globin @ma27 @talyz
|
||||
/pkgs/build-support/php/build-pecl.nix @aanderse @drupol @globin @ma27 @talyz
|
||||
/pkgs/build-support/php @drupol
|
||||
/pkgs/development/interpreters/php @jtojnar @aanderse @drupol @globin @ma27 @talyz
|
||||
/pkgs/development/php-packages @aanderse @drupol @globin @ma27 @talyz
|
||||
/pkgs/top-level/php-packages.nix @jtojnar @aanderse @drupol @globin @ma27 @talyz
|
||||
/doc/languages-frameworks/php.section.md @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/nixos/tests/php @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/build-support/php/build-pecl.nix @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/build-support/php @drupol @etu
|
||||
/pkgs/development/interpreters/php @jtojnar @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/development/php-packages @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
/pkgs/top-level/php-packages.nix @jtojnar @aanderse @drupol @etu @globin @ma27 @talyz
|
||||
|
||||
# Docker tools
|
||||
/pkgs/build-support/docker @roberth
|
||||
@@ -337,9 +325,6 @@ pkgs/applications/version-management/forgejo @bendlas @emilylange
|
||||
/pkgs/build-support/node/fetch-npm-deps @lilyinstarlight @winterqt
|
||||
/doc/languages-frameworks/javascript.section.md @lilyinstarlight @winterqt
|
||||
|
||||
# environment.noXlibs option aka NoX
|
||||
/nixos/modules/config/no-x-libs.nix @SuperSandro2000
|
||||
|
||||
# OCaml
|
||||
/pkgs/build-support/ocaml @ulrikstrid
|
||||
/pkgs/development/compilers/ocaml @ulrikstrid
|
||||
@@ -359,8 +344,3 @@ nixos/tests/zfs.nix @raitobezarius
|
||||
nixos/modules/services/continuous-integration/buildbot @Mic92 @zowoq
|
||||
nixos/tests/buildbot.nix @Mic92 @zowoq
|
||||
pkgs/development/tools/continuous-integration/buildbot @Mic92 @zowoq
|
||||
|
||||
# Pretix
|
||||
pkgs/by-name/pr/pretix/ @mweinelt
|
||||
nixos/modules/services/web-apps/pretix.nix @mweinelt
|
||||
nixos/tests/web-apps/pretix.nix @mweinelt
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -38,7 +38,7 @@ Reviewing helps to reduce the average time-to-merge for everyone.
|
||||
Thanks a lot if you do!
|
||||
|
||||
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
|
||||
Reviewing guidelines: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#reviewing-contributions
|
||||
Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
|
||||
-->
|
||||
|
||||
---
|
||||
|
||||
420
.github/labeler.yml
vendored
420
.github/labeler.yml
vendored
@@ -1,362 +1,216 @@
|
||||
"6.topic: agda":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/agda.section.md
|
||||
- nixos/tests/agda.nix
|
||||
- pkgs/build-support/agda/**/*
|
||||
- pkgs/development/libraries/agda/**/*
|
||||
- pkgs/top-level/agda-packages.nix
|
||||
- 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: cinnamon":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/desktops/cinnamon/**/*
|
||||
- nixos/modules/services/x11/desktop-managers/cinnamon.nix
|
||||
- nixos/tests/cinnamon.nix
|
||||
- pkgs/desktops/cinnamon/**/*
|
||||
- nixos/modules/services/x11/desktop-managers/cinnamon.nix
|
||||
- nixos/tests/cinnamon.nix
|
||||
|
||||
"6.topic: emacs":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/services/editors/emacs.nix
|
||||
- nixos/modules/services/editors/emacs.xml
|
||||
- nixos/tests/emacs-daemon.nix
|
||||
- pkgs/applications/editors/emacs/elisp-packages/**/*
|
||||
- pkgs/applications/editors/emacs/**/*
|
||||
- pkgs/build-support/emacs/**/*
|
||||
- pkgs/top-level/emacs-packages.nix
|
||||
- nixos/modules/services/editors/emacs.nix
|
||||
- nixos/modules/services/editors/emacs.xml
|
||||
- nixos/tests/emacs-daemon.nix
|
||||
- pkgs/applications/editors/emacs/elisp-packages/**/*
|
||||
- pkgs/applications/editors/emacs/**/*
|
||||
- pkgs/build-support/emacs/**/*
|
||||
- pkgs/top-level/emacs-packages.nix
|
||||
|
||||
"6.topic: Enlightenment DE":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/services/x11/desktop-managers/enlightenment.nix
|
||||
- pkgs/desktops/enlightenment/**/*
|
||||
- pkgs/development/python-modules/python-efl/*
|
||||
- nixos/modules/services/x11/desktop-managers/enlightenment.nix
|
||||
- pkgs/desktops/enlightenment/**/*
|
||||
- pkgs/development/python-modules/python-efl/*
|
||||
|
||||
"6.topic: erlang":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 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
|
||||
- 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":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/build-support/fetch*/**/*
|
||||
- pkgs/build-support/fetch*/**/*
|
||||
|
||||
"6.topic: flakes":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- '**/flake.nix'
|
||||
- lib/systems/flake-systems.nix
|
||||
- nixos/modules/config/nix-flakes.nix
|
||||
- '**/flake.nix'
|
||||
- lib/systems/flake-systems.nix
|
||||
- nixos/modules/config/nix-flakes.nix
|
||||
|
||||
"6.topic: GNOME":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 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/**/*
|
||||
- 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":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/go.section.md
|
||||
- pkgs/build-support/go/**/*
|
||||
- pkgs/development/compilers/go/**/*
|
||||
- doc/languages-frameworks/go.section.md
|
||||
- pkgs/build-support/go/**/*
|
||||
- pkgs/development/compilers/go/**/*
|
||||
|
||||
"6.topic: haskell":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 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
|
||||
- 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: jupyter":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/development/python-modules/jupyter*/**/*
|
||||
- pkgs/development/python-modules/mkdocs-jupyter/*
|
||||
- nixos/modules/services/development/jupyter/**/*
|
||||
- pkgs/applications/editors/jupyter-kernels/**/*
|
||||
- pkgs/applications/editors/jupyter/**/*
|
||||
- pkgs/development/python-modules/jupyter*/**/*
|
||||
- pkgs/development/python-modules/mkdocs-jupyter/*
|
||||
- nixos/modules/services/development/jupyter/**/*
|
||||
- pkgs/applications/editors/jupyter-kernels/**/*
|
||||
- pkgs/applications/editors/jupyter/**/*
|
||||
|
||||
"6.topic: kernel":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/build-support/kernel/**/*
|
||||
- pkgs/os-specific/linux/kernel/**/*
|
||||
- pkgs/build-support/kernel/**/*
|
||||
- pkgs/os-specific/linux/kernel/**/*
|
||||
|
||||
"6.topic: lib":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- lib/**
|
||||
- lib/**
|
||||
|
||||
"6.topic: lua":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/development/interpreters/lua-5/**/*
|
||||
- pkgs/development/interpreters/luajit/**/*
|
||||
- pkgs/development/lua-modules/**/*
|
||||
- pkgs/top-level/lua-packages.nix
|
||||
- pkgs/development/interpreters/lua-5/**/*
|
||||
- pkgs/development/interpreters/luajit/**/*
|
||||
- pkgs/development/lua-modules/**/*
|
||||
- pkgs/top-level/lua-packages.nix
|
||||
|
||||
"6.topic: Lumina DE":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/services/x11/desktop-managers/lumina.nix
|
||||
- pkgs/desktops/lumina/**/*
|
||||
- nixos/modules/services/x11/desktop-managers/lumina.nix
|
||||
- pkgs/desktops/lumina/**/*
|
||||
|
||||
"6.topic: LXQt":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/services/x11/desktop-managers/lxqt.nix
|
||||
- pkgs/desktops/lxqt/**/*
|
||||
- nixos/modules/services/x11/desktop-managers/lxqt.nix
|
||||
- pkgs/desktops/lxqt/**/*
|
||||
|
||||
"6.topic: mate":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/services/x11/desktop-managers/mate.nix
|
||||
- nixos/tests/mate.nix
|
||||
- pkgs/desktops/mate/**/*
|
||||
- nixos/modules/services/x11/desktop-managers/mate.nix
|
||||
- nixos/tests/mate.nix
|
||||
- pkgs/desktops/mate/**/*
|
||||
|
||||
"6.topic: module system":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- lib/modules.nix
|
||||
- lib/types.nix
|
||||
- lib/options.nix
|
||||
- lib/tests/modules.sh
|
||||
- lib/tests/modules/**
|
||||
- lib/modules.nix
|
||||
- lib/types.nix
|
||||
- lib/options.nix
|
||||
- lib/tests/modules.sh
|
||||
- lib/tests/modules/**
|
||||
|
||||
"6.topic: nixos":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/**/*
|
||||
- pkgs/os-specific/linux/nixos-rebuild/**/*
|
||||
- nixos/**/*
|
||||
- pkgs/os-specific/linux/nixos-rebuild/**/*
|
||||
|
||||
"6.topic: nim":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/nim.section.md
|
||||
- pkgs/development/compilers/nim/*
|
||||
- pkgs/development/nim-packages/**/*
|
||||
- pkgs/top-level/nim-packages.nix
|
||||
- doc/languages-frameworks/nim.section.md
|
||||
- pkgs/development/compilers/nim/*
|
||||
- pkgs/development/nim-packages/**/*
|
||||
- pkgs/top-level/nim-packages.nix
|
||||
|
||||
"6.topic: nodejs":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/javascript.section.md
|
||||
- pkgs/build-support/node/**/*
|
||||
- pkgs/development/node-packages/**/*
|
||||
- pkgs/development/tools/yarn/*
|
||||
- pkgs/development/tools/yarn2nix-moretea/**/*
|
||||
- pkgs/development/web/nodejs/*
|
||||
- doc/languages-frameworks/javascript.section.md
|
||||
- pkgs/build-support/node/**/*
|
||||
- pkgs/development/node-packages/**/*
|
||||
- pkgs/development/tools/yarn/*
|
||||
- pkgs/development/tools/yarn2nix-moretea/**/*
|
||||
- pkgs/development/web/nodejs/*
|
||||
|
||||
"6.topic: ocaml":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 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
|
||||
- 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":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 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: php":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/php.section.md
|
||||
- pkgs/build-support/php/**/*
|
||||
- pkgs/development/interpreters/php/*
|
||||
- pkgs/development/php-packages/**/*
|
||||
- pkgs/test/php/default.nix
|
||||
- pkgs/top-level/php-packages.nix
|
||||
- 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":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- .github/**/*
|
||||
- .github/**/*
|
||||
|
||||
"6.topic: printing":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/services/printing/cupsd.nix
|
||||
- pkgs/misc/cups/**/*
|
||||
- nixos/modules/services/printing/cupsd.nix
|
||||
- pkgs/misc/cups/**/*
|
||||
|
||||
"6.topic: python":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/python.section.md
|
||||
- pkgs/development/interpreters/python/**/*
|
||||
- pkgs/development/python-modules/**/*
|
||||
- pkgs/top-level/python-packages.nix
|
||||
- doc/languages-frameworks/python.section.md
|
||||
- pkgs/development/interpreters/python/**/*
|
||||
- pkgs/development/python-modules/**/*
|
||||
- pkgs/top-level/python-packages.nix
|
||||
|
||||
"6.topic: qt/kde":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 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/**/*
|
||||
- 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":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/ruby.section.md
|
||||
- pkgs/development/interpreters/ruby/**/*
|
||||
- pkgs/development/ruby-modules/**/*
|
||||
- doc/languages-frameworks/ruby.section.md
|
||||
- pkgs/development/interpreters/ruby/**/*
|
||||
- pkgs/development/ruby-modules/**/*
|
||||
|
||||
"6.topic: rust":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/rust.section.md
|
||||
- pkgs/build-support/rust/**/*
|
||||
- pkgs/development/compilers/rust/**/*
|
||||
- doc/languages-frameworks/rust.section.md
|
||||
- pkgs/build-support/rust/**/*
|
||||
- pkgs/development/compilers/rust/**/*
|
||||
|
||||
"6.topic: stdenv":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/stdenv/**/*
|
||||
- pkgs/stdenv/**/*
|
||||
|
||||
"6.topic: steam":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/games/steam/**/*
|
||||
- pkgs/games/steam/**/*
|
||||
|
||||
"6.topic: systemd":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/os-specific/linux/systemd/**/*
|
||||
- nixos/modules/system/boot/systemd*/**/*
|
||||
- pkgs/os-specific/linux/systemd/**/*
|
||||
- nixos/modules/system/boot/systemd*/**/*
|
||||
|
||||
"6.topic: TeX":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/texlive.section.md
|
||||
- pkgs/test/texlive/**
|
||||
- pkgs/tools/typesetting/tex/**/*
|
||||
|
||||
"6.topic: testing":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
# NOTE: Let's keep the scope limited to test frameworks that are
|
||||
# *developed in this repo*;
|
||||
# - not individual tests
|
||||
# - not packages for test frameworks
|
||||
- nixos/lib/testing/**
|
||||
- nixos/lib/test-driver/**
|
||||
- nixos/tests/nixos-test-driver/**
|
||||
- nixos/lib/testing-python.nix # legacy
|
||||
- nixos/tests/make-test-python.nix # legacy
|
||||
# lib/debug.nix has a test framework (runTests) but it's not the main focus
|
||||
- doc/languages-frameworks/texlive.section.md
|
||||
- pkgs/test/texlive/**
|
||||
- pkgs/tools/typesetting/tex/**/*
|
||||
|
||||
"6.topic: vim":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/languages-frameworks/vim.section.md
|
||||
- pkgs/applications/editors/vim/**/*
|
||||
- pkgs/applications/editors/vim/plugins/**/*
|
||||
- nixos/modules/programs/neovim.nix
|
||||
- pkgs/applications/editors/neovim/**/*
|
||||
- doc/languages-frameworks/vim.section.md
|
||||
- pkgs/applications/editors/vim/**/*
|
||||
- pkgs/applications/editors/vim/plugins/**/*
|
||||
- nixos/modules/programs/neovim.nix
|
||||
- pkgs/applications/editors/neovim/**/*
|
||||
|
||||
"6.topic: vscode":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/applications/editors/vscode/**/*
|
||||
- pkgs/applications/editors/vscode/**/*
|
||||
|
||||
"6.topic: xfce":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/doc/manual/configuration/xfce.xml
|
||||
- nixos/modules/services/x11/desktop-managers/xfce.nix
|
||||
- nixos/tests/xfce.nix
|
||||
- pkgs/desktops/xfce/**/*
|
||||
- nixos/doc/manual/configuration/xfce.xml
|
||||
- nixos/modules/services/x11/desktop-managers/xfce.nix
|
||||
- nixos/tests/xfce.nix
|
||||
- pkgs/desktops/xfce/**/*
|
||||
|
||||
"6.topic: zig":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- pkgs/development/compilers/zig/**/*
|
||||
- doc/hooks/zig.section.md
|
||||
- pkgs/development/compilers/zig/**/*
|
||||
- doc/hooks/zig.section.md
|
||||
|
||||
"8.has: changelog":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/doc/manual/release-notes/**/*
|
||||
- nixos/doc/manual/release-notes/**/*
|
||||
|
||||
"8.has: documentation":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- doc/**/*
|
||||
- nixos/doc/**/*
|
||||
- doc/**/*
|
||||
- nixos/doc/**/*
|
||||
|
||||
"8.has: module (update)":
|
||||
- any:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- nixos/modules/**/*
|
||||
- nixos/modules/**/*
|
||||
|
||||
4
.github/workflows/backport.yml
vendored
4
.github/workflows/backport.yml
vendored
@@ -20,11 +20,11 @@ jobs:
|
||||
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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Create backport PRs
|
||||
uses: korthout/backport-action@e8161d6a0dbfa2651b7daa76cbb75bc7c925bbf3 # v2.4.1
|
||||
uses: korthout/backport-action@08bafb375e6e9a9a2b53a744b987e5d81a133191 # v2.1.1
|
||||
with:
|
||||
# Config README: https://github.com/korthout/backport-action#backport-action
|
||||
copy_labels_pattern: 'severity:\ssecurity'
|
||||
|
||||
4
.github/workflows/basic-eval.yml
vendored
4
.github/workflows/basic-eval.yml
vendored
@@ -18,8 +18,8 @@ jobs:
|
||||
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@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
- uses: cachix/cachix-action@18cf96c7c98e048e10a83abd92116114cd8504be # v14
|
||||
with:
|
||||
# This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere.
|
||||
|
||||
14
.github/workflows/check-by-name.yml
vendored
14
.github/workflows/check-by-name.yml
vendored
@@ -8,15 +8,7 @@ name: Check pkgs/by-name
|
||||
# see pkgs/test/nixpkgs-check-by-name/scripts/README.md
|
||||
on:
|
||||
# Using pull_request_target instead of pull_request avoids having to approve first time contributors
|
||||
pull_request_target:
|
||||
# This workflow depends on the base branch of the PR,
|
||||
# but changing the base branch is not included in the default trigger events,
|
||||
# which would be `opened`, `synchronize` or `reopened`.
|
||||
# Instead it causes an `edited` event, so we need to add it explicitly here
|
||||
# While `edited` is also triggered when the PR title/body is changed,
|
||||
# this PR action is fairly quick, and PR's don't get edited that often,
|
||||
# so it shouldn't be a problem
|
||||
types: [opened, synchronize, reopened, edited]
|
||||
pull_request_target
|
||||
|
||||
permissions:
|
||||
# We need this permission to cancel the workflow run if there's a merge conflict
|
||||
@@ -87,7 +79,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
echo "mergedSha=$mergedSha" >> "$GITHUB_ENV"
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: ${{ env.mergedSha }}
|
||||
@@ -98,7 +90,7 @@ jobs:
|
||||
base=$(mktemp -d)
|
||||
git worktree add "$base" "$(git rev-parse HEAD^1)"
|
||||
echo "base=$base" >> "$GITHUB_ENV"
|
||||
- uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
- name: Fetching the pinned tool
|
||||
# Update the pinned version using pkgs/test/nixpkgs-check-by-name/scripts/update-pinned-tool.sh
|
||||
run: |
|
||||
|
||||
@@ -12,11 +12,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
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@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
4
.github/workflows/editorconfig.yml
vendored
4
.github/workflows/editorconfig.yml
vendored
@@ -24,11 +24,11 @@ jobs:
|
||||
- name: print list of changed files
|
||||
run: |
|
||||
cat "$HOME/changed_files"
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
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@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
with:
|
||||
# nixpkgs commit is pinned so that it doesn't break
|
||||
# editorconfig-checker 2.4.0
|
||||
|
||||
2
.github/workflows/labels.yml
vendored
2
.github/workflows/labels.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: "github.repository_owner == 'NixOS' && !contains(github.event.pull_request.title, '[skip treewide]')"
|
||||
steps:
|
||||
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
|
||||
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4.3.0
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
sync-labels: true
|
||||
|
||||
4
.github/workflows/manual-nixos.yml
vendored
4
.github/workflows/manual-nixos.yml
vendored
@@ -14,11 +14,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
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@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
4
.github/workflows/manual-nixpkgs.yml
vendored
4
.github/workflows/manual-nixpkgs.yml
vendored
@@ -15,11 +15,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'NixOS'
|
||||
steps:
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
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@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
with:
|
||||
# explicitly enable sandbox
|
||||
extra_nix_config: sandbox = true
|
||||
|
||||
4
.github/workflows/nix-parse.yml
vendored
4
.github/workflows/nix-parse.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
||||
if [[ -s "$HOME/changed_files" ]]; then
|
||||
echo "CHANGED_FILES=$HOME/changed_files" > "$GITHUB_ENV"
|
||||
fi
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
# pull_request_target checks out the base branch by default
|
||||
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
if: ${{ env.CHANGED_FILES && env.CHANGED_FILES != '' }}
|
||||
- uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
- name: Parse all changed or added nix files
|
||||
|
||||
8
.github/workflows/periodic-merge-24h.yml
vendored
8
.github/workflows/periodic-merge-24h.yml
vendored
@@ -35,13 +35,17 @@ jobs:
|
||||
pairs:
|
||||
- from: master
|
||||
into: haskell-updates
|
||||
- from: release-23.05
|
||||
into: staging-next-23.05
|
||||
- from: staging-next-23.05
|
||||
into: staging-23.05
|
||||
- from: release-23.11
|
||||
into: staging-next-23.11
|
||||
- from: staging-next-23.11
|
||||
into: staging-23.11
|
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
steps:
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0
|
||||
@@ -52,7 +56,7 @@ jobs:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
|
||||
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
|
||||
4
.github/workflows/periodic-merge-6h.yml
vendored
4
.github/workflows/periodic-merge-6h.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
||||
into: staging
|
||||
name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
steps:
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- name: ${{ matrix.pairs.from }} → ${{ matrix.pairs.into }}
|
||||
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Comment on failure
|
||||
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
|
||||
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
issue-number: 105153
|
||||
|
||||
@@ -16,8 +16,8 @@ jobs:
|
||||
if: github.repository_owner == 'NixOS' && github.ref == 'refs/heads/master' # ensure workflow_dispatch only runs on master
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
- uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: cachix/install-nix-action@6004951b182f8860210c8d6f0d808ec5b1a33d28 # v25
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
- name: setup
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
run: |
|
||||
git clean -f
|
||||
- name: create PR
|
||||
uses: peter-evans/create-pull-request@70a41aba780001da0a30141984ae2a0c95d8704e # v6.0.2
|
||||
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
|
||||
with:
|
||||
body: |
|
||||
Automatic update by [update-terraform-providers](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/update-terraform-providers.yml) action.
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,12 +11,12 @@ outputs/
|
||||
result-*
|
||||
result
|
||||
repl-result-*
|
||||
tags
|
||||
!pkgs/development/python-modules/result
|
||||
/doc/NEWS.html
|
||||
/doc/NEWS.txt
|
||||
/doc/manual.html
|
||||
/doc/manual.pdf
|
||||
/result
|
||||
/source/
|
||||
.version-suffix
|
||||
|
||||
|
||||
@@ -129,17 +129,19 @@ When a PR is created, it will be pre-populated with some checkboxes detailed bel
|
||||
|
||||
#### Tested using sandboxing
|
||||
|
||||
When sandbox builds are enabled, Nix will set up an isolated environment for each build process.
|
||||
It is used to remove further hidden dependencies set by the build environment to improve reproducibility.
|
||||
This includes access to the network during the build outside of `fetch*` functions and files outside the Nix store.
|
||||
Depending on the operating system, access to other resources is blocked as well (e.g., inter-process communication is isolated on Linux); see [sandbox](https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-sandbox) in the Nix manual for details.
|
||||
When sandbox builds are enabled, Nix will setup an isolated environment for each build process. It is used to remove further hidden dependencies set by the build environment to improve reproducibility. This includes access to the network during the build outside of `fetch*` functions and files outside the Nix store. Depending on the operating system access to other resources are blocked as well (ex. inter process communication is isolated on Linux); see [sandbox](https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-sandbox) in the Nix manual for details.
|
||||
|
||||
In pull requests for [nixpkgs](https://github.com/NixOS/nixpkgs/) people are asked to test builds with sandboxing enabled (see `Tested using sandboxing` in the pull request template) because in [Hydra](https://nixos.org/hydra/) sandboxing is also used.
|
||||
Sandboxing is not enabled by default in Nix due to a small performance hit on each build. In pull requests for [nixpkgs](https://github.com/NixOS/nixpkgs/) people are asked to test builds with sandboxing enabled (see `Tested using sandboxing` in the pull request template) because in [Hydra](https://nixos.org/hydra/) sandboxing is also used.
|
||||
|
||||
If you are on Linux, sandboxing is enabled by default.
|
||||
On other platforms, sandboxing is disabled by default due to a small performance hit on each build.
|
||||
Depending if you use NixOS or other platforms you can use one of the following methods to enable sandboxing **before** building the package:
|
||||
|
||||
Please enable sandboxing **before** building the package by adding the following to: `/etc/nix/nix.conf`:
|
||||
- **Globally enable sandboxing on NixOS**: add the following to `configuration.nix`
|
||||
|
||||
```nix
|
||||
nix.settings.sandbox = true;
|
||||
```
|
||||
|
||||
- **Globally enable sandboxing on non-NixOS platforms**: add the following to: `/etc/nix/nix.conf`
|
||||
|
||||
```ini
|
||||
sandbox = true
|
||||
@@ -439,14 +441,14 @@ gitGraph
|
||||
|
||||
Here's an overview of the different branches:
|
||||
|
||||
| branch | `master` | `staging-next` | `staging` |
|
||||
| branch | `master` | `staging` | `staging-next` |
|
||||
| --- | --- | --- | --- |
|
||||
| Used for development | ✔️ | ❌ | ✔️ |
|
||||
| Built by Hydra | ✔️ | ✔️ | ❌ |
|
||||
| [Mass rebuilds][mass-rebuild] | ❌ | ⚠️ Only to fix Hydra builds | ✔️ |
|
||||
| Critical security fixes | ✔️ for non-mass-rebuilds | ✔️ for mass-rebuilds | ❌ |
|
||||
| Automatically merged into | `staging-next` | `staging` | - |
|
||||
| Manually merged into | - | `master` | `staging-next` |
|
||||
| Used for development | ✔️ | ✔️ | ❌ |
|
||||
| Built by Hydra | ✔️ | ❌ | ✔️ |
|
||||
| [Mass rebuilds][mass-rebuild] | ❌ | ✔️ | ⚠️ Only to fix Hydra builds |
|
||||
| Critical security fixes | ✔️ for non-mass-rebuilds | ❌ | ✔️ for mass-rebuilds |
|
||||
| Automatically merged into | `staging-next` | - | `staging` |
|
||||
| Manually merged into | - | `staging-next` | `master` |
|
||||
|
||||
The staging workflow is used for all main branches, `master` and `release-YY.MM`, with corresponding names:
|
||||
- `master`/`release-YY.MM`
|
||||
|
||||
2
COPYING
2
COPYING
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2003-2024 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
||||
Copyright (c) 2003-2023 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
11
README.md
11
README.md
@@ -1,10 +1,9 @@
|
||||
<p align="center">
|
||||
<a href="https://nixos.org">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/NixOS/nixos-homepage/master/logo/nixos-hires.png">
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/NixOS/nixos-artwork/master/logo/nixos-white.png">
|
||||
<img src="https://raw.githubusercontent.com/NixOS/nixos-homepage/master/logo/nixos-hires.png" width="500px" alt="NixOS logo">
|
||||
</picture>
|
||||
<a href="https://nixos.org#gh-light-mode-only">
|
||||
<img src="https://raw.githubusercontent.com/NixOS/nixos-homepage/master/logo/nixos-hires.png" width="500px" alt="NixOS logo"/>
|
||||
</a>
|
||||
<a href="https://nixos.org#gh-dark-mode-only">
|
||||
<img src="https://raw.githubusercontent.com/NixOS/nixos-artwork/master/logo/nixos-white.png" width="500px" alt="NixOS logo"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
145
doc/README.md
145
doc/README.md
@@ -71,11 +71,6 @@ If you **omit a link text** for a link pointing to a section, the text will be s
|
||||
|
||||
This syntax is taken from [MyST](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
|
||||
|
||||
|
||||
#### HTML
|
||||
|
||||
Inlining HTML is not allowed. Parts of the documentation gets rendered to various non-HTML formats, such as man pages in the case of NixOS manual.
|
||||
|
||||
#### Roles
|
||||
|
||||
If you want to link to a man page, you can use `` {manpage}`nix.conf(5)` ``. The references will turn into links when a mapping exists in [`doc/manpage-urls.json`](./manpage-urls.json).
|
||||
@@ -162,9 +157,6 @@ watermelon
|
||||
|
||||
In an effort to keep the Nixpkgs manual in a consistent style, please follow the conventions below, unless they prevent you from properly documenting something.
|
||||
In that case, please open an issue about the particular documentation convention and tag it with a "needs: documentation" label.
|
||||
When needed, each convention explain why it exists, so you can make a decision whether to follow it or not based on your particular case.
|
||||
Note that these conventions are about the **structure** of the manual (and its source files), not about the content that goes in it.
|
||||
You, as the writer of documentation, are still in charge of its content.
|
||||
|
||||
- Put each sentence in its own line.
|
||||
This makes reviews and suggestions much easier, since GitHub's review system is based on lines.
|
||||
@@ -196,153 +188,26 @@ You, as the writer of documentation, are still in charge of its content.
|
||||
}
|
||||
```
|
||||
|
||||
- When showing inputs/outputs of any [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop), such as a shell or the Nix REPL, use a format as you'd see in the REPL, while trying to visually separate inputs from outputs.
|
||||
This means that for a shell, you should use a format like the following:
|
||||
```shell
|
||||
$ nix-build -A hello '<nixpkgs>' \
|
||||
--option require-sigs false \
|
||||
--option trusted-substituters file:///tmp/hello-cache \
|
||||
--option substituters file:///tmp/hello-cache
|
||||
/nix/store/zhl06z4lrfrkw5rp0hnjjfrgsclzvxpm-hello-2.12.1
|
||||
```
|
||||
Note how the input is preceded by `$` on the first line and indented on subsequent lines, and how the output is provided as you'd see on the shell.
|
||||
|
||||
For the Nix REPL, you should use a format like the following:
|
||||
```shell
|
||||
nix-repl> builtins.attrNames { a = 1; b = 2; }
|
||||
[ "a" "b" ]
|
||||
```
|
||||
Note how the input is preceded by `nix-repl>` and the output is provided as you'd see on the Nix REPL.
|
||||
|
||||
- When documenting functions or anything that has inputs/outputs and example usage, use nested headings to clearly separate inputs, outputs, and examples.
|
||||
Keep examples as the last nested heading, and link to the examples wherever applicable in the documentation.
|
||||
|
||||
The purpose of this convention is to provide a familiar structure for navigating the manual, so any reader can expect to find content related to inputs in an "inputs" heading, examples in an "examples" heading, and so on.
|
||||
An example:
|
||||
```
|
||||
## buildImage
|
||||
|
||||
Some explanation about the function here.
|
||||
Describe a particular scenario, and point to [](#ex-dockerTools-buildImage), which is an example demonstrating it.
|
||||
|
||||
### Inputs
|
||||
|
||||
Documentation for the inputs of `buildImage`.
|
||||
Perhaps even point to [](#ex-dockerTools-buildImage) again when talking about something specifically linked to it.
|
||||
|
||||
### Passthru outputs
|
||||
|
||||
Documentation for any passthru outputs of `buildImage`.
|
||||
|
||||
### Examples
|
||||
|
||||
Note that this is the last nested heading in the `buildImage` section.
|
||||
|
||||
:::{.example #ex-dockerTools-buildImage}
|
||||
|
||||
# Using `buildImage`
|
||||
|
||||
Example of how to use `buildImage` goes here.
|
||||
|
||||
:::
|
||||
```
|
||||
|
||||
- Use [definition lists](#definition-lists) to document function arguments, and the attributes of such arguments as well as their [types](https://nixos.org/manual/nix/stable/language/values).
|
||||
For example:
|
||||
- Use [definition lists](#definition-lists) to document function arguments, and the attributes of such arguments. For example:
|
||||
|
||||
```markdown
|
||||
# pkgs.coolFunction
|
||||
|
||||
Description of what `coolFunction` does.
|
||||
|
||||
## Inputs
|
||||
|
||||
`coolFunction` expects a single argument which should be an attribute set, with the following possible attributes:
|
||||
|
||||
`name` (String)
|
||||
`name`
|
||||
|
||||
: The name of the resulting image.
|
||||
|
||||
`tag` (String; _optional_)
|
||||
`tag` _optional_
|
||||
|
||||
: Tag of the generated image.
|
||||
|
||||
_Default:_ the output path's hash.
|
||||
_Default value:_ the output path's hash.
|
||||
|
||||
```
|
||||
|
||||
#### Examples
|
||||
|
||||
To define a referenceable figure use the following fencing:
|
||||
|
||||
```markdown
|
||||
:::{.example #an-attribute-set-example}
|
||||
# An attribute set example
|
||||
|
||||
You can add text before
|
||||
|
||||
```nix
|
||||
{ a = 1; b = 2;}
|
||||
```
|
||||
|
||||
and after code fencing
|
||||
:::
|
||||
```
|
||||
|
||||
Defining examples through the `example` fencing class adds them to a "List of Examples" section after the Table of Contents.
|
||||
Though this is not shown in the rendered documentation on nixos.org.
|
||||
|
||||
#### Figures
|
||||
|
||||
To define a referencable figure use the following fencing:
|
||||
|
||||
```markdown
|
||||
::: {.figure #nixos-logo}
|
||||
# NixOS Logo
|
||||

|
||||
:::
|
||||
```
|
||||
|
||||
Defining figures through the `figure` fencing class adds them to a `List of Figures` after the `Table of Contents`.
|
||||
Though this is not shown in the rendered documentation on nixos.org.
|
||||
|
||||
#### Footnotes
|
||||
|
||||
To add a foonote explanation, use the following syntax:
|
||||
|
||||
```markdown
|
||||
Sometimes it's better to add context [^context] in a footnote.
|
||||
|
||||
[^context]: This explanation will be rendered at the end of the chapter.
|
||||
```
|
||||
|
||||
#### Inline comments
|
||||
|
||||
Inline comments are supported with following syntax:
|
||||
|
||||
```markdown
|
||||
<!-- This is an inline comment -->
|
||||
```
|
||||
|
||||
The comments will not be rendered in the rendered HTML.
|
||||
|
||||
#### Link reference definitions
|
||||
|
||||
Links can reference a label, for example, to make the link target reusable:
|
||||
|
||||
```markdown
|
||||
::: {.note}
|
||||
Reference links can also be used to [shorten URLs][url-id] and keep the markdown readable.
|
||||
:::
|
||||
|
||||
[url-id]: https://github.com/NixOS/nixpkgs/blob/19d4f7dc485f74109bd66ef74231285ff797a823/doc/README.md
|
||||
```
|
||||
|
||||
This syntax is taken from [CommonMark](https://spec.commonmark.org/0.30/#link-reference-definitions).
|
||||
|
||||
#### Typographic replacements
|
||||
|
||||
Typographic replacements are enabled. Check the [list of possible replacement patterns check](https://github.com/executablebooks/markdown-it-py/blob/3613e8016ecafe21709471ee0032a90a4157c2d1/markdown_it/rules_core/replacements.py#L1-L15).
|
||||
|
||||
## Getting help
|
||||
|
||||
If you need documentation-specific help or reviews, ping [@NixOS/documentation-reviewers](https://github.com/orgs/nixos/teams/documentation-reviewers) on your pull request.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', function(event) {
|
||||
anchors.add('h1[id]:not(div.note h1, div.warning h1, div.tip h1, div.caution h1, div.important h1), h2[id]:not(div.note h2, div.warning h2, div.tip h2, div.caution h2, div.important h2), h3[id]:not(div.note h3, div.warning h3, div.tip h3, div.caution h3, div.important h3), h4[id]:not(div.note h4, div.warning h4, div.tip h4, div.caution h4, div.important h4), h5[id]:not(div.note h5, div.warning h5, div.tip h5, div.caution h5, div.important h5), h6[id]:not(div.note h6, div.warning h6, div.tip h6, div.caution h6, div.important h6)');
|
||||
});
|
||||
9
doc/anchor.min.js
vendored
9
doc/anchor.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -80,10 +80,6 @@ stdenv.mkDerivation {
|
||||
|
||||
The main difference between `fetchurl` and `fetchzip` is in how they store the contents. `fetchurl` will store the unaltered contents of the URL within the Nix store. `fetchzip` on the other hand, will decompress the archive for you, making files and directories directly accessible in the future. `fetchzip` can only be used with archives. Despite the name, `fetchzip` is not limited to .zip files and can also be used with any tarball.
|
||||
|
||||
Additional parameters to `fetchurl`:
|
||||
- `downloadToTemp`: Defaults to `false`. If `true`, saves the source to `$downloadedFile`, to be used in conjunction with `postFetch`
|
||||
- `postFetch`: Shell code executed after the file has been fetched successfully. Use it for postprocessing, to check or transform the file.
|
||||
|
||||
## `fetchpatch` {#fetchpatch}
|
||||
|
||||
`fetchpatch` works very similarly to `fetchurl` with the same arguments expected. It expects patch files as a source and performs normalization on them before computing the checksum. For example, it will remove comments or other unstable parts that are sometimes added by version control systems and can change over time.
|
||||
@@ -262,10 +258,6 @@ or
|
||||
|
||||
***
|
||||
```
|
||||
|
||||
This function should only be used by non-redistributable software with an unfree license that we need to require the user to download manually.
|
||||
It produces packages that cannot be built automatically.
|
||||
|
||||
## `fetchtorrent` {#fetchtorrent}
|
||||
|
||||
`fetchtorrent` expects two arguments. `url` which can either be a Magnet URI (Magnet Link) such as `magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c` or an HTTP URL pointing to a `.torrent` file. It can also take a `config` argument which will craft a `settings.json` configuration file and give it to `transmission`, the underlying program that is performing the fetch. The available config options for `transmission` can be found [here](https://github.com/transmission/transmission/blob/main/docs/Editing-Configuration-Files.md#options)
|
||||
|
||||
@@ -6,6 +6,7 @@ This chapter describes tools for creating various types of images.
|
||||
images/appimagetools.section.md
|
||||
images/dockertools.section.md
|
||||
images/ocitools.section.md
|
||||
images/snaptools.section.md
|
||||
images/portableservice.section.md
|
||||
images/makediskimage.section.md
|
||||
images/binarycache.section.md
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,104 +1,37 @@
|
||||
# pkgs.ociTools {#sec-pkgs-ociTools}
|
||||
|
||||
`pkgs.ociTools` is a set of functions for creating runtime container bundles according to the [OCI runtime specification v1.0.0](https://github.com/opencontainers/runtime-spec/blob/v1.0.0/spec.md).
|
||||
It makes no assumptions about the container runner you choose to use to run the created container.
|
||||
|
||||
The set of functions in `pkgs.ociTools` currently does not handle the [OCI image specification](https://github.com/opencontainers/image-spec).
|
||||
|
||||
At a high-level an OCI implementation would download an OCI Image then unpack that image into an OCI Runtime filesystem bundle.
|
||||
At this point the OCI Runtime Bundle would be run by an OCI Runtime.
|
||||
`pkgs.ociTools` provides utilities to create OCI Runtime bundles.
|
||||
`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 an OCI runtime container (consisting of a `config.json` and a root filesystem directory) that runs a single command inside of it.
|
||||
The nix store of the container will contain all referenced dependencies of the given command.
|
||||
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.
|
||||
|
||||
This function has an assumption that the container will run on POSIX platforms, and sets configurations (such as the user running the process or certain mounts) according to this assumption.
|
||||
Because of this, a container built with `buildContainer` will not work on Windows or other non-POSIX platforms without modifications to the container configuration.
|
||||
These modifications aren't supported by `buildContainer`.
|
||||
|
||||
For `linux` platforms, `buildContainer` also configures the following namespaces (see {manpage}`unshare(1)`) to isolate the OCI container from the global namespace:
|
||||
PID, network, mount, IPC, and UTS.
|
||||
|
||||
Note that no user namespace is created, which means that you won't be able to run the container unless you are the `root` user.
|
||||
|
||||
### Inputs {#ssec-pkgs-ociTools-buildContainer-inputs}
|
||||
|
||||
`buildContainer` expects an argument with the following attributes:
|
||||
|
||||
`args` (List of String)
|
||||
|
||||
: Specifies a set of arguments to run inside the container.
|
||||
Any packages referenced by `args` will be made available inside the container.
|
||||
|
||||
`mounts` (Attribute Set; _optional_)
|
||||
|
||||
: Would specify additional mounts that the runtime must make available to the container.
|
||||
|
||||
:::{.warning}
|
||||
As explained in [issue #290879](https://github.com/NixOS/nixpkgs/issues/290879), this attribute is currently ignored.
|
||||
:::
|
||||
|
||||
:::{.note}
|
||||
`buildContainer` includes a minimal set of necessary filesystems to be mounted into the container, and this set can't be changed with the `mounts` attribute.
|
||||
:::
|
||||
|
||||
_Default value:_ `{}`.
|
||||
|
||||
`readonly` (Boolean; _optional_)
|
||||
|
||||
: If `true`, sets the container's root filesystem as read-only.
|
||||
|
||||
_Default value:_ `false`.
|
||||
|
||||
`os` **DEPRECATED**
|
||||
|
||||
: Specifies the operating system on which the container filesystem is based on.
|
||||
If specified, its value should follow the [OCI Image Configuration Specification](https://github.com/opencontainers/image-spec/blob/main/config.md#properties).
|
||||
According to the linked specification, all possible values for `$GOOS` in [the Go docs](https://go.dev/doc/install/source#environment) should be valid, but will commonly be one of `darwin` or `linux`.
|
||||
|
||||
_Default value:_ `"linux"`.
|
||||
|
||||
`arch` **DEPRECATED**
|
||||
|
||||
: Used to specify the architecture for which the binaries in the container filesystem have been compiled.
|
||||
If specified, its value should follow the [OCI Image Configuration Specification](https://github.com/opencontainers/image-spec/blob/main/config.md#properties).
|
||||
According to the linked specification, all possible values for `$GOARCH` in [the Go docs](https://go.dev/doc/install/source#environment) should be valid, but will commonly be one of `386`, `amd64`, `arm`, or `arm64`.
|
||||
|
||||
_Default value:_ `x86_64`.
|
||||
|
||||
### Examples {#ssec-pkgs-ociTools-buildContainer-examples}
|
||||
|
||||
::: {.example #ex-ociTools-buildContainer-bash}
|
||||
# Creating an OCI runtime container that runs `bash`
|
||||
|
||||
This example uses `ociTools.buildContainer` to create a simple container that runs `bash`.
|
||||
The parameters of `buildContainer` with an example value are described below:
|
||||
|
||||
```nix
|
||||
{ ociTools, lib, bash }:
|
||||
ociTools.buildContainer {
|
||||
buildContainer {
|
||||
args = [
|
||||
(lib.getExe bash)
|
||||
(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;
|
||||
}
|
||||
```
|
||||
|
||||
As an example of how to run the container generated by this package, we'll use `runc` to start the container.
|
||||
Any other tool that supports OCI containers could be used instead.
|
||||
- `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.
|
||||
|
||||
```shell
|
||||
$ nix-build
|
||||
(some output removed for clarity)
|
||||
/nix/store/7f9hgx0arvhzp2a3qphp28rxbn748l25-join
|
||||
- `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)
|
||||
|
||||
$ cd /nix/store/7f9hgx0arvhzp2a3qphp28rxbn748l25-join
|
||||
$ nix-shell -p runc
|
||||
[nix-shell:/nix/store/7f9hgx0arvhzp2a3qphp28rxbn748l25-join]$ sudo runc run ocitools-example
|
||||
help
|
||||
GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)
|
||||
(some output removed for clarity)
|
||||
```
|
||||
:::
|
||||
- `readonly` makes the container's rootfs read-only if it is set to true. The default value is false `false`.
|
||||
|
||||
@@ -1,174 +1,81 @@
|
||||
# pkgs.portableService {#sec-pkgs-portableService}
|
||||
|
||||
`pkgs.portableService` is a function to create [Portable Services](https://systemd.io/PORTABLE_SERVICES/) in a read-only, immutable, `squashfs` raw disk image.
|
||||
This lets you use Nix to build images which can be run on many recent Linux distributions.
|
||||
`pkgs.portableService` is a function to create _portable service images_,
|
||||
as read-only, immutable, `squashfs` archives.
|
||||
|
||||
systemd supports a concept of [Portable Services](https://systemd.io/PORTABLE_SERVICES/).
|
||||
Portable Services are a delivery method for system services that uses two specific features of container management:
|
||||
|
||||
* Applications are bundled. I.e. multiple services, their binaries and
|
||||
all their dependencies are packaged in an image, and are run directly from it.
|
||||
* Stricter default security policies, i.e. sandboxing of applications.
|
||||
|
||||
This allows using Nix to build images which can be run on many recent Linux distributions.
|
||||
|
||||
The primary tool for interacting with Portable Services is `portablectl`,
|
||||
and they are managed by the `systemd-portabled` system service.
|
||||
|
||||
::: {.note}
|
||||
Portable services are supported starting with systemd 239 (released on 2018-06-22).
|
||||
:::
|
||||
|
||||
The generated image will contain the file system structure as required by the Portable Services specification, along with the packages given to `portableService` and all of their dependencies.
|
||||
When generated, the image will exist in the Nix store with the `.raw` file extension, as required by the specification.
|
||||
See [](#ex-portableService-hello) to understand how to use the output of `portableService`.
|
||||
|
||||
## Inputs {#ssec-pkgs-portableService-inputs}
|
||||
|
||||
`portableService` expects one argument with the following attributes:
|
||||
|
||||
`pname` (String)
|
||||
|
||||
: The name of the portable service.
|
||||
The generated image will be named according to the template `$pname_$version.raw`, which is supported by the Portable Services specification.
|
||||
|
||||
`version` (String)
|
||||
|
||||
: The version of the portable service.
|
||||
The generated image will be named according to the template `$pname_$version.raw`, which is supported by the Portable Services specification.
|
||||
|
||||
`units` (List of Attribute Set)
|
||||
|
||||
: A list of derivations for systemd unit files.
|
||||
Each derivation must produce a single file, and must have a name that starts with the value of `pname` and ends with the suffix of the unit type (e.g. ".service", ".socket", ".timer", and so on).
|
||||
See [](#ex-portableService-hello) to better understand this naming constraint.
|
||||
|
||||
`description` (String or Null; _optional_)
|
||||
|
||||
: If specified, the value is added as `PORTABLE_PRETTY_NAME` to the `/etc/os-release` file in the generated image.
|
||||
This could be used to provide more information to anyone inspecting the image.
|
||||
|
||||
_Default value:_ `null`.
|
||||
|
||||
`homepage` (String or Null; _optional_)
|
||||
|
||||
: If specified, the value is added as `HOME_URL` to the `/etc/os-release` file in the generated image.
|
||||
This could be used to provide more information to anyone inspecting the image.
|
||||
|
||||
_Default value:_ `null`.
|
||||
|
||||
`symlinks` (List of Attribute Set; _optional_)
|
||||
|
||||
: A list of attribute sets in the format `{object, symlink}`.
|
||||
For each item in the list, `portableService` will create a symlink in the path specified by `symlink` (relative to the root of the image) that points to `object`.
|
||||
|
||||
All packages that `object` depends on and their dependencies are automatically copied into the image.
|
||||
|
||||
This can be used to create symlinks for applications that assume some files to exist globally (`/etc/ssl` or `/bin/bash`, for example).
|
||||
See [](#ex-portableService-symlinks) to understand how to do that.
|
||||
|
||||
_Default value:_ `[]`.
|
||||
|
||||
`contents` (List of Attribute Set; _optional_)
|
||||
|
||||
: A list of additional derivations to be included as-is in the image.
|
||||
These derivations will be included directly in a `/nix/store` directory inside the image.
|
||||
|
||||
_Default value:_ `[]`.
|
||||
|
||||
`squashfsTools` (Attribute Set; _optional_)
|
||||
|
||||
: Allows you to override the package that provides {manpage}`mksquashfs(1)`, which is used internally by `portableService`.
|
||||
|
||||
_Default value:_ `pkgs.squashfsTools`.
|
||||
|
||||
`squash-compression` (String; _optional_)
|
||||
|
||||
: Passed as the compression option to {manpage}`mksquashfs(1)`, which is used internally by `portableService`.
|
||||
|
||||
_Default value:_ `"xz -Xdict-size 100%"`.
|
||||
|
||||
`squash-block-size` (String; _optional_)
|
||||
|
||||
: Passed as the block size option to {manpage}`mksquashfs(1)`, which is used internally by `portableService`.
|
||||
|
||||
_Default value:_ `"1M"`.
|
||||
|
||||
## Examples {#ssec-pkgs-portableService-examples}
|
||||
A very simple example of using `portableService` is described below:
|
||||
|
||||
[]{#ex-pkgs-portableService}
|
||||
:::{.example #ex-portableService-hello}
|
||||
# Building a Portable Service image
|
||||
|
||||
The following example builds a Portable Service image with the `hello` package, along with a service unit that runs it.
|
||||
|
||||
```nix
|
||||
{ lib, writeText, portableService, hello }:
|
||||
let
|
||||
hello-service = writeText "hello.service" ''
|
||||
[Unit]
|
||||
Description=Hello world service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=${lib.getExe hello}
|
||||
'';
|
||||
in
|
||||
portableService {
|
||||
pname = "hello";
|
||||
inherit (hello) version;
|
||||
units = [ hello-service ];
|
||||
pkgs.portableService {
|
||||
pname = "demo";
|
||||
version = "1.0";
|
||||
units = [ demo-service demo-socket ];
|
||||
}
|
||||
```
|
||||
|
||||
After building the package, the generated image can be loaded into a system through {manpage}`portablectl(1)`:
|
||||
The above example will build an squashfs archive image in `result/$pname_$version.raw`. The image will contain the
|
||||
file system structure as required by the portable service specification, and a subset of the Nix store with all the
|
||||
dependencies of the two derivations in the `units` list.
|
||||
`units` must be a list of derivations, and their names must be prefixed with the service name (`"demo"` in this case).
|
||||
Otherwise `systemd-portabled` will ignore them.
|
||||
|
||||
```shell
|
||||
$ nix-build
|
||||
(some output removed for clarity)
|
||||
/nix/store/8c20z1vh7z8w8dwagl8w87b45dn5k6iq-hello-img-2.12.1
|
||||
|
||||
$ portablectl attach /nix/store/8c20z1vh7z8w8dwagl8w87b45dn5k6iq-hello-img-2.12.1/hello_2.12.1.raw
|
||||
Created directory /etc/systemd/system.attached.
|
||||
Created directory /etc/systemd/system.attached/hello.service.d.
|
||||
Written /etc/systemd/system.attached/hello.service.d/20-portable.conf.
|
||||
Created symlink /etc/systemd/system.attached/hello.service.d/10-profile.conf → /usr/lib/systemd/portable/profile/default/service.conf.
|
||||
Copied /etc/systemd/system.attached/hello.service.
|
||||
Created symlink /etc/portables/hello_2.12.1.raw → /nix/store/8c20z1vh7z8w8dwagl8w87b45dn5k6iq-hello-img-2.12.1/hello_2.12.1.raw.
|
||||
|
||||
$ systemctl start hello
|
||||
$ journalctl -u hello
|
||||
Feb 28 22:39:16 hostname systemd[1]: Starting Hello world service...
|
||||
Feb 28 22:39:16 hostname hello[102887]: Hello, world!
|
||||
Feb 28 22:39:16 hostname systemd[1]: hello.service: Deactivated successfully.
|
||||
Feb 28 22:39:16 hostname systemd[1]: Finished Hello world service.
|
||||
|
||||
$ portablectl detach hello_2.12.1
|
||||
Removed /etc/systemd/system.attached/hello.service.
|
||||
Removed /etc/systemd/system.attached/hello.service.d/10-profile.conf.
|
||||
Removed /etc/systemd/system.attached/hello.service.d/20-portable.conf.
|
||||
Removed /etc/systemd/system.attached/hello.service.d.
|
||||
Removed /etc/portables/hello_2.12.1.raw.
|
||||
Removed /etc/systemd/system.attached.
|
||||
```
|
||||
::: {.note}
|
||||
The `.raw` file extension of the image is required by the portable services specification.
|
||||
:::
|
||||
|
||||
:::{.example #ex-portableService-symlinks}
|
||||
# Specifying symlinks when building a Portable Service image
|
||||
Some other options available are:
|
||||
- `description`, `homepage`
|
||||
|
||||
Some services may expect files or directories to be available globally.
|
||||
An example is a service which expects all trusted SSL certificates to exist in a specific location by default.
|
||||
Are added to the `/etc/os-release` in the image and are shown by the portable services tooling.
|
||||
Default to empty values, not added to os-release.
|
||||
- `symlinks`
|
||||
|
||||
To make things available globally, you must specify the `symlinks` attribute when using `portableService`.
|
||||
The following package builds on the package from [](#ex-portableService-hello) to make `/etc/ssl` available globally (this is only for illustrative purposes, because `hello` doesn't use `/etc/ssl`).
|
||||
A list of attribute sets {object, symlink}. Symlinks will be created in the root filesystem of the image to
|
||||
objects in the Nix store. Defaults to an empty list.
|
||||
- `contents`
|
||||
|
||||
A list of additional derivations to be included in the image Nix store, as-is. Defaults to an empty list.
|
||||
- `squashfsTools`
|
||||
|
||||
Defaults to `pkgs.squashfsTools`, allows you to override the package that provides `mksquashfs`.
|
||||
- `squash-compression`, `squash-block-size`
|
||||
|
||||
Options to `mksquashfs`. Default to `"xz -Xdict-size 100%"` and `"1M"` respectively.
|
||||
|
||||
A typical usage of `symlinks` would be:
|
||||
```nix
|
||||
{ lib, writeText, portableService, hello, cacert }:
|
||||
let
|
||||
hello-service = writeText "hello.service" ''
|
||||
[Unit]
|
||||
Description=Hello world service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=${lib.getExe hello}
|
||||
'';
|
||||
in
|
||||
portableService {
|
||||
pname = "hello";
|
||||
inherit (hello) version;
|
||||
units = [ hello-service ];
|
||||
symlinks = [
|
||||
{ object = "${cacert}/etc/ssl"; symlink = "/etc/ssl"; }
|
||||
{ object = "${pkgs.cacert}/etc/ssl"; symlink = "/etc/ssl"; }
|
||||
{ object = "${pkgs.bash}/bin/bash"; symlink = "/bin/sh"; }
|
||||
{ object = "${pkgs.php}/bin/php"; symlink = "/usr/bin/php"; }
|
||||
];
|
||||
}
|
||||
```
|
||||
to create these symlinks for legacy applications that assume them existing globally.
|
||||
|
||||
Once the image is created, and deployed on a host in `/var/lib/portables/`, you can attach the image and run the service. As root run:
|
||||
```console
|
||||
portablectl attach demo_1.0.raw
|
||||
systemctl enable --now demo.socket
|
||||
systemctl enable --now demo.service
|
||||
```
|
||||
::: {.note}
|
||||
See the [man page](https://www.freedesktop.org/software/systemd/man/portablectl.html) of `portablectl` for more info on its usage.
|
||||
:::
|
||||
|
||||
71
doc/build-helpers/images/snaptools.section.md
Normal file
71
doc/build-helpers/images/snaptools.section.md
Normal file
@@ -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).
|
||||
@@ -3,7 +3,6 @@
|
||||
This chapter describes several special build helpers.
|
||||
|
||||
```{=include=} sections
|
||||
special/fakenss.section.md
|
||||
special/fhs-environments.section.md
|
||||
special/makesetuphook.section.md
|
||||
special/mkshell.section.md
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
# fakeNss {#sec-fakeNss}
|
||||
|
||||
Provides `/etc/passwd` and `/etc/group` files that contain `root` and `nobody`, allowing user/group lookups to work in binaries that insist on doing those.
|
||||
This might be a better choice than a custom script running `useradd` and related utilities if you only need those files to exist with some entries.
|
||||
|
||||
`fakeNss` also provides `/etc/nsswitch.conf`, configuring NSS host resolution to first check `/etc/hosts` before checking DNS, since the default in the absence of a config file (`dns [!UNAVAIL=return] files`) is quite unexpected.
|
||||
|
||||
It also creates an empty directory at `/var/empty` because it uses that as the home directory for the `root` and `nobody` users.
|
||||
The `/var/empty` directory can also be used as a `chroot` target to prevent file access in processes that do not need to access files, if your container runs such processes.
|
||||
|
||||
The user entries created by `fakeNss` use the `/bin/sh` shell, which is not provided by `fakeNss` because in most cases it won't be used.
|
||||
If you need that to be available, see [`dockerTools.binSh`](#sssec-pkgs-dockerTools-helpers-binSh) or provide your own.
|
||||
|
||||
## Inputs {#sec-fakeNss-inputs}
|
||||
|
||||
`fakeNss` is made available in Nixpkgs as a package rather than a function, but it has two attributes that can be overridden and might be useful in particular cases.
|
||||
For more details on how overriding works, see [](#ex-fakeNss-overriding) and [](#sec-pkg-override).
|
||||
|
||||
`extraPasswdLines` (List of Strings; _optional_)
|
||||
|
||||
: A list of lines that will be added to `/etc/passwd`.
|
||||
Useful if extra users need to exist in the output of `fakeNss`.
|
||||
If `extraPasswdLines` is specified, it will **not** override the `root` and `nobody` entries created by `fakeNss`.
|
||||
Those entries will always exist.
|
||||
|
||||
Lines specified here must follow the format in {manpage}`passwd(5)`.
|
||||
|
||||
_Default value:_ `[]`.
|
||||
|
||||
`extraGroupLines` (List of Strings; _optional_)
|
||||
|
||||
: A list of lines that will be added to `/etc/group`.
|
||||
Useful if extra groups need to exist in the output of `fakeNss`.
|
||||
If `extraGroupLines` is specified, it will **not** override the `root` and `nobody` entries created by `fakeNss`.
|
||||
Those entries will always exist.
|
||||
|
||||
Lines specified here must follow the format in {manpage}`group(5)`.
|
||||
|
||||
_Default value:_ `[]`.
|
||||
|
||||
## Examples {#sec-fakeNss-examples}
|
||||
|
||||
:::{.example #ex-fakeNss-dockerTools-buildImage}
|
||||
# Using `fakeNss` with `dockerTools.buildImage`
|
||||
|
||||
This example shows how to use `fakeNss` as-is.
|
||||
It is useful with functions in `dockerTools` to allow building Docker images that have the `/etc/passwd` and `/etc/group` files.
|
||||
This example includes the `hello` binary in the image so it can do something besides just have the extra files.
|
||||
|
||||
```nix
|
||||
{ dockerTools, fakeNss, hello }:
|
||||
dockerTools.buildImage {
|
||||
name = "image-with-passwd";
|
||||
tag = "latest";
|
||||
|
||||
copyToRoot = [ fakeNss hello ];
|
||||
|
||||
config = {
|
||||
Cmd = [ "/bin/hello" ];
|
||||
};
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
:::{.example #ex-fakeNss-overriding}
|
||||
# Using `fakeNss` with an override to add extra lines
|
||||
|
||||
The following code uses `override` to add extra lines to `/etc/passwd` and `/etc/group` to create another user and group entry.
|
||||
|
||||
```nix
|
||||
{ fakeNss }:
|
||||
fakeNss.override {
|
||||
extraPasswdLines = ["newuser:x:9001:9001:new user:/var/empty:/bin/sh"];
|
||||
extraGroupLines = ["newuser:x:9001:"];
|
||||
}
|
||||
```
|
||||
:::
|
||||
@@ -7,9 +7,7 @@ Like [`stdenv.mkDerivation`](#sec-using-stdenv), each of these build helpers cre
|
||||
|
||||
`runCommand :: String -> AttrSet -> String -> Derivation`
|
||||
|
||||
The result of `runCommand name drvAttrs buildCommand` is a derivation that is built by running the specified shell commands.
|
||||
|
||||
By default `runCommand` runs in a stdenv with no compiler environment, whereas [`runCommandCC`](#trivial-builder-runCommandCC) uses the default stdenv, `pkgs.stdenv`.
|
||||
`runCommand name drvAttrs buildCommand` returns a derivation that is built by running the specified shell commands.
|
||||
|
||||
`name :: String`
|
||||
: The name that Nix will append to the store path in the same way that `stdenv.mkDerivation` uses its `name` attribute.
|
||||
@@ -94,107 +92,6 @@ writeShellScript "evaluate-my-file.sh" ''
|
||||
```
|
||||
::::
|
||||
|
||||
### `makeDesktopItem` {#trivial-builder-makeDesktopItem}
|
||||
|
||||
Write an [XDG desktop file](https://specifications.freedesktop.org/desktop-entry-spec/1.4/) to the Nix store.
|
||||
|
||||
This function is usually used to add desktop items to a package through the `copyDesktopItems` hook.
|
||||
|
||||
`makeDesktopItem` adheres to version 1.4 of the specification.
|
||||
|
||||
#### Inputs {#trivial-builder-makeDesktopItem-inputs}
|
||||
|
||||
`makeDesktopItem` takes an attribute set that accepts most values from the [XDG specification](https://specifications.freedesktop.org/desktop-entry-spec/1.4/ar01s06.html).
|
||||
|
||||
All recognised keys from the specification are supported with the exception of the "Hidden" field. The keys are converted into camelCase format, but correspond 1:1 to their equivalent in the specification: `genericName`, `noDisplay`, `comment`, `icon`, `onlyShowIn`, `notShowIn`, `dbusActivatable`, `tryExec`, `exec`, `path`, `terminal`, `mimeTypes`, `categories`, `implements`, `keywords`, `startupNotify`, `startupWMClass`, `url`, `prefersNonDefaultGPU`.
|
||||
|
||||
The "Version" field is hardcoded to the version `makeDesktopItem` currently adheres to.
|
||||
|
||||
The following fields are either required, are of a different type than in the specification, carry specific default values, or are additional fields supported by `makeDesktopItem`:
|
||||
|
||||
`name` (String)
|
||||
|
||||
: The name of the desktop file in the Nix store.
|
||||
|
||||
`type` (String; _optional_)
|
||||
|
||||
: Default value: `"Application"`
|
||||
|
||||
`desktopName` (String)
|
||||
|
||||
: Corresponds to the "Name" field of the specification.
|
||||
|
||||
`actions` (List of Attribute set; _optional_)
|
||||
|
||||
: A list of attribute sets {name, exec?, icon?}
|
||||
|
||||
`extraConfig` (Attribute set; _optional_)
|
||||
|
||||
: Additional key/value pairs to be added verbatim to the desktop file. Attributes need to be prefixed with 'X-'.
|
||||
|
||||
#### Examples {#trivial-builder-makeDesktopItem-examples}
|
||||
|
||||
::: {.example #ex-makeDesktopItem}
|
||||
# Usage 1 of `makeDesktopItem`
|
||||
|
||||
Write a desktop file `/nix/store/<store path>/my-program.desktop` to the Nix store.
|
||||
|
||||
```nix
|
||||
{makeDesktopItem}:
|
||||
makeDesktopItem {
|
||||
name = "my-program";
|
||||
desktopName = "My Program";
|
||||
genericName = "Video Player";
|
||||
noDisplay = false;
|
||||
comment = "Cool video player";
|
||||
icon = "/path/to/icon";
|
||||
onlyShowIn = [ "KDE" ];
|
||||
dbusActivatable = true;
|
||||
tryExec = "my-program";
|
||||
exec = "my-program --someflag";
|
||||
path = "/some/working/path";
|
||||
terminal = false;
|
||||
actions.example = {
|
||||
name = "New Window";
|
||||
exec = "my-program --new-window";
|
||||
icon = "/some/icon";
|
||||
};
|
||||
mimeTypes = [ "video/mp4" ];
|
||||
categories = [ "Utility" ];
|
||||
implements = [ "org.my-program" ];
|
||||
keywords = [ "Video" "Player" ];
|
||||
startupNotify = false;
|
||||
startupWMClass = "MyProgram";
|
||||
prefersNonDefaultGPU = false;
|
||||
extraConfig.X-SomeExtension = "somevalue";
|
||||
}
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::: {.example #ex2-makeDesktopItem}
|
||||
# Usage 2 of `makeDesktopItem`
|
||||
|
||||
Override the `hello` package to add a desktop item.
|
||||
|
||||
```nix
|
||||
{ copyDesktopItems
|
||||
, hello
|
||||
, makeDesktopItem }:
|
||||
|
||||
hello.overrideAttrs {
|
||||
nativeBuildInputs = [ copyDesktopItems ];
|
||||
|
||||
desktopItems = [(makeDesktopItem {
|
||||
name = "hello";
|
||||
desktopName = "Hello";
|
||||
exec = "hello";
|
||||
})];
|
||||
}
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### `writeTextFile` {#trivial-builder-writeTextFile}
|
||||
|
||||
Write a text file to the Nix store.
|
||||
@@ -256,12 +153,6 @@ Write a text file to the Nix store.
|
||||
|
||||
Default: `true`
|
||||
|
||||
`derivationArgs` (Attribute set, _optional_)
|
||||
|
||||
: Extra arguments to pass to the underlying call to `stdenv.mkDerivation`.
|
||||
|
||||
Default: `{}`
|
||||
|
||||
The resulting store path will include some variation of the name, and it will be a file unless `destination` is used, in which case it will be a directory.
|
||||
|
||||
::: {.example #ex-writeTextFile}
|
||||
@@ -488,7 +379,7 @@ writeTextFile {
|
||||
echo "hi"
|
||||
'';
|
||||
executable = true;
|
||||
destination = "bin/my-script";
|
||||
destination = "bin/my-script"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -576,7 +467,7 @@ writeTextFile {
|
||||
echo "hi"
|
||||
'';
|
||||
executable = true;
|
||||
destination = "bin/my-script";
|
||||
destination = "bin/my-script"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -611,14 +502,9 @@ concatScript "my-file" [ file1 file2 ]
|
||||
|
||||
## `writeShellApplication` {#trivial-builder-writeShellApplication}
|
||||
|
||||
`writeShellApplication` is similar to `writeShellScriptBin` and `writeScriptBin` but supports runtime dependencies with `runtimeInputs`.
|
||||
Writes an executable shell script to `/nix/store/<store path>/bin/<name>` and checks its syntax with [`shellcheck`](https://github.com/koalaman/shellcheck) and the `bash`'s `-n` option.
|
||||
Some basic Bash options are set by default (`errexit`, `nounset`, and `pipefail`), but can be overridden with `bashOptions`.
|
||||
This can be used to easily produce a shell script that has some dependencies (`runtimeInputs`). It automatically sets the `PATH` of the script to contain all of the listed inputs, sets some sanity shellopts (`errexit`, `nounset`, `pipefail`), and checks the resulting script with [`shellcheck`](https://github.com/koalaman/shellcheck).
|
||||
|
||||
Extra arguments may be passed to `stdenv.mkDerivation` by setting `derivationArgs`; note that variables set in this manner will be set when the shell script is _built,_ not when it's run.
|
||||
Runtime environment variables can be set with the `runtimeEnv` argument.
|
||||
|
||||
For example, the following shell application can refer to `curl` directly, rather than needing to write `${curl}/bin/curl`:
|
||||
For example, look at the following code:
|
||||
|
||||
```nix
|
||||
writeShellApplication {
|
||||
@@ -632,6 +518,10 @@ writeShellApplication {
|
||||
}
|
||||
```
|
||||
|
||||
Unlike with normal `writeShellScriptBin`, there is no need to manually write out `${curl}/bin/curl`, setting the PATH
|
||||
was handled by `writeShellApplication`. Moreover, the script is being checked with `shellcheck` for more strict
|
||||
validation.
|
||||
|
||||
## `symlinkJoin` {#trivial-builder-symlinkJoin}
|
||||
|
||||
This can be used to put many derivations into the same directory structure. It works by creating a new derivation and adding symlinks to each of the paths listed. It expects two arguments, `name`, and `paths`. `name` is the name used in the Nix store path for the created derivation. `paths` is a list of paths that will be symlinked. These paths can be to Nix store derivations or any other subdirectory contained within.
|
||||
@@ -658,18 +548,14 @@ This creates a derivation with a directory structure like the following:
|
||||
|
||||
## `writeReferencesToFile` {#trivial-builder-writeReferencesToFile}
|
||||
|
||||
Deprecated. Use [`writeClosure`](#trivial-builder-writeClosure) instead.
|
||||
Writes the closure of transitive dependencies to a file.
|
||||
|
||||
## `writeClosure` {#trivial-builder-writeClosure}
|
||||
|
||||
Given a list of [store paths](https://nixos.org/manual/nix/stable/glossary#gloss-store-path) (or string-like expressions coercible to store paths), write their collective [closure](https://nixos.org/manual/nix/stable/glossary#gloss-closure) to a text file.
|
||||
|
||||
The result is equivalent to the output of `nix-store -q --requisites`.
|
||||
This produces the equivalent of `nix-store -q --requisites`.
|
||||
|
||||
For example,
|
||||
|
||||
```nix
|
||||
writeClosure [ (writeScriptBin "hi" ''${hello}/bin/hello'') ]
|
||||
writeReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
|
||||
```
|
||||
|
||||
produces an output path `/nix/store/<hash>-runtime-deps` containing
|
||||
|
||||
@@ -25,7 +25,6 @@ let
|
||||
{ name = "gvariant"; description = "GVariant formatted string serialization functions"; }
|
||||
{ name = "customisation"; description = "Functions to customise (derivation-related) functions, derivatons, or attribute sets"; }
|
||||
{ name = "meta"; description = "functions for derivation metadata"; }
|
||||
{ name = "derivations"; description = "miscellaneous derivation-specific functions"; }
|
||||
];
|
||||
};
|
||||
|
||||
@@ -122,17 +121,16 @@ in pkgs.stdenv.mkDerivation {
|
||||
${pkgs.documentation-highlighter}/mono-blue.css \
|
||||
${pkgs.documentation-highlighter}/loader.js
|
||||
|
||||
cp -t out ./style.css ./anchor.min.js ./anchor-use.js
|
||||
cp -t out ./overrides.css ./style.css
|
||||
|
||||
nixos-render-docs manual html \
|
||||
--manpage-urls ./manpage-urls.json \
|
||||
--revision ${pkgs.lib.trivial.revisionWithDefault (pkgs.rev or "master")} \
|
||||
--stylesheet style.css \
|
||||
--stylesheet overrides.css \
|
||||
--stylesheet highlightjs/mono-blue.css \
|
||||
--script ./highlightjs/highlight.pack.js \
|
||||
--script ./highlightjs/loader.js \
|
||||
--script ./anchor.min.js \
|
||||
--script ./anchor-use.js \
|
||||
--toc-depth 1 \
|
||||
--section-toc-depth 1 \
|
||||
manual.md \
|
||||
|
||||
@@ -29,7 +29,7 @@ stdenv.mkDerivation {
|
||||
mkdir -p "$out"
|
||||
|
||||
cat > "$out/index.md" << 'EOF'
|
||||
```{=include=} sections auto-id-prefix=auto-generated
|
||||
```{=include=} sections
|
||||
EOF
|
||||
|
||||
${lib.concatMapStrings ({ name, baseName ? name, description }: ''
|
||||
|
||||
@@ -6,9 +6,8 @@ All generators follow a similar call interface: `generatorName configFunctions d
|
||||
Generators can be fine-tuned to produce exactly the file format required by your application/service. One example is an INI-file format which uses `: ` as separator, the strings `"yes"`/`"no"` as boolean values and requires all string values to be quoted:
|
||||
|
||||
```nix
|
||||
with lib;
|
||||
let
|
||||
inherit (lib) generators isString;
|
||||
|
||||
customToINI = generators.toINI {
|
||||
# specifies how to format a key/value pair
|
||||
mkKeyValue = generators.mkKeyValueDefault {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This hook helps with installing manpages and shell completion files. It exposes 2 shell functions `installManPage` and `installShellCompletion` that can be used from your `postInstall` hook.
|
||||
|
||||
The `installManPage` function takes one or more paths to manpages to install. The manpages must have a section suffix, and may optionally be compressed (with `.gz` suffix). This function will place them into the correct `share/man/man<section>/` directory, in [`outputMan`](#outputman).
|
||||
The `installManPage` function takes one or more paths to manpages to install. The manpages must have a section suffix, and may optionally be compressed (with `.gz` suffix). This function will place them into the correct directory.
|
||||
|
||||
The `installShellCompletion` function takes one or more paths to shell completion files. By default it will autodetect the shell type from the completion file extension, but you may also specify it by passing one of `--bash`, `--fish`, or `--zsh`. These flags apply to all paths listed after them (up until another shell flag is given). Each path may also have a custom installation name provided by providing a flag `--name NAME` before the path. If this flag is not provided, zsh completions will be renamed automatically such that `foobar.zsh` becomes `_foobar`. A root name may be provided for all paths using the flag `--cmd NAME`; this synthesizes the appropriate name depending on the shell (e.g. `--cmd foo` will synthesize the name `foo.bash` for bash and `_foo` for zsh). The path may also be a fifo or named fd (such as produced by `<(cmd)`), in which case the shell and name must be provided.
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ Bash-only variables:
|
||||
- `postgresqlTestSetupCommands`: bash commands to run after database start, defaults to running `$postgresqlTestSetupSQL` as database administrator.
|
||||
- `postgresqlEnableTCP`: set to `1` to enable TCP listening. Flaky; not recommended.
|
||||
- `postgresqlStartCommands`: defaults to `pg_ctl start`.
|
||||
- `postgresqlExtraSettings`: Additional configuration to add to `postgresql.conf`
|
||||
|
||||
## Hooks {#sec-postgresqlTestHook-hooks}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Python {#setup-hook-python}
|
||||
|
||||
Adds the `python.sitePackages` subdirectory (i.e. `lib/pythonX.Y/site-packages`) of each build input to the `PYTHONPATH` environment variable.
|
||||
Adds the `lib/${python.libPrefix}/site-packages` subdirectory of each build input to the `PYTHONPATH` environment variable.
|
||||
|
||||
@@ -216,7 +216,7 @@ in packages.mixRelease {
|
||||
Setup will require the following steps:
|
||||
|
||||
- Move your secrets to runtime environment variables. For more information refer to the [runtime.exs docs](https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-runtime-configuration). On a fresh Phoenix build that would mean that both `DATABASE_URL` and `SECRET_KEY` need to be moved to `runtime.exs`.
|
||||
- `cd assets` and `nix-shell -p node2nix --run "node2nix --development"` will generate a Nix expression containing your frontend dependencies
|
||||
- `cd assets` and `nix-shell -p node2nix --run node2nix --development` will generate a Nix expression containing your frontend dependencies
|
||||
- commit and push those changes
|
||||
- you can now `nix-build .`
|
||||
- To run the release, set the `RELEASE_TMP` environment variable to a directory that your program has write access to. It will be used to store the BEAM settings.
|
||||
|
||||
@@ -55,13 +55,7 @@ Here is a simple package example. It is a pure Coq library, thus it depends on C
|
||||
```nix
|
||||
{ lib, mkCoqDerivation, version ? null
|
||||
, coq, mathcomp, mathcomp-finmap, mathcomp-bigenough }:
|
||||
|
||||
let
|
||||
inherit (lib) licenses maintainers switch;
|
||||
inherit (lib.versions) range;
|
||||
in
|
||||
|
||||
mkCoqDerivation {
|
||||
with lib; mkCoqDerivation {
|
||||
/* namePrefix leads to e.g. `name = coq8.11-mathcomp1.11-multinomials-1.5.2` */
|
||||
namePrefix = [ "coq" "mathcomp" ];
|
||||
pname = "multinomials";
|
||||
|
||||
@@ -144,4 +144,4 @@ All new projects should use the CUDA redistributables available in [`cudaPackage
|
||||
| Find libraries | `configurePhase` | Missing dependency on a `dev` output | Add the missing dependency | The `dev` output typically contain CMake configuration files |
|
||||
| Find libraries | `buildPhase` or `patchelf` | Missing dependency on a `lib` or `static` output | Add the missing dependency | The `lib` or `static` output typically contain the libraries |
|
||||
|
||||
In the scenario you are unable to run the resulting binary: this is arguably the most complicated as it could be any combination of the previous reasons. This type of failure typically occurs when a library attempts to load or open a library it depends on that it does not declare in its `DT_NEEDED` section. As a first step, ensure that dependencies are patched with [`cudaPackages.autoAddDriverRunpath`](https://search.nixos.org/packages?channel=unstable&type=packages&query=cudaPackages.autoAddDriverRunpath). Failing that, try running the application with [`nixGL`](https://github.com/guibou/nixGL) or a similar wrapper tool. If that works, it likely means that the application is attempting to load a library that is not in the `RPATH` or `RUNPATH` of the binary.
|
||||
In the scenario you are unable to run the resulting binary: this is arguably the most complicated as it could be any combination of the previous reasons. This type of failure typically occurs when a library attempts to load or open a library it depends on that it does not declare in its `DT_NEEDED` section. As a first step, ensure that dependencies are patched with [`cudaPackages.autoAddOpenGLRunpath`](https://search.nixos.org/packages?channel=unstable&type=packages&query=cudaPackages.autoAddOpenGLRunpath). Failing that, try running the application with [`nixGL`](https://github.com/guibou/nixGL) or a similar wrapper tool. If that works, it likely means that the application is attempting to load a library that is not in the `RPATH` or `RUNPATH` of the binary.
|
||||
|
||||
@@ -103,7 +103,7 @@ See the [Dart documentation](#ssec-dart-applications) for more details on requir
|
||||
|
||||
flutter.buildFlutterApplication {
|
||||
pname = "firmware-updater";
|
||||
version = "0-unstable-2023-04-30";
|
||||
version = "unstable-2023-04-30";
|
||||
|
||||
# To build for the Web, use the targetFlutterPlatform argument.
|
||||
# targetFlutterPlatform = "web";
|
||||
|
||||
@@ -93,11 +93,7 @@ The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given
|
||||
To package Dotnet applications, you can use `buildDotnetModule`. This has similar arguments to `stdenv.mkDerivation`, with the following additions:
|
||||
|
||||
* `projectFile` is used for specifying the dotnet project file, relative to the source root. These have `.sln` (entire solution) or `.csproj` (single project) file extensions. This can be a list of multiple projects as well. When omitted, will attempt to find and build the solution (`.sln`). If running into problems, make sure to set it to a file (or a list of files) with the `.csproj` extension - building applications as entire solutions is not fully supported by the .NET CLI.
|
||||
* `nugetDeps` takes either a path to a `deps.nix` file, or a derivation. The `deps.nix` file can be generated using the script attached to `passthru.fetch-deps`. If the argument is a derivation, it will be used directly and assume it has the same output as `mkNugetDeps`.
|
||||
::: {.note}
|
||||
For more detail about managing the `deps.nix` file, see [Generating and updating NuGet dependencies](#generating-and-updating-nuget-dependencies)
|
||||
:::
|
||||
|
||||
* `nugetDeps` takes either a path to a `deps.nix` file, or a derivation. The `deps.nix` file can be generated using the script attached to `passthru.fetch-deps`. This file can also be generated manually using `nuget-to-nix` tool, which is available in nixpkgs. If the argument is a derivation, it will be used directly and assume it has the same output as `mkNugetDeps`.
|
||||
* `packNupkg` is used to pack project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`.
|
||||
* `projectReferences` can be used to resolve `ProjectReference` project items. Referenced projects can be packed with `buildDotnetModule` by setting the `packNupkg = true` attribute and passing a list of derivations to `projectReferences`. Since we are sharing referenced projects as NuGets they must be added to csproj/fsproj files as `PackageReference` as well.
|
||||
For example, your project has a local dependency:
|
||||
@@ -148,7 +144,7 @@ in buildDotnetModule rec {
|
||||
|
||||
projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
|
||||
|
||||
dotnet-sdk = dotnetCorePackages.sdk_6_0;
|
||||
dotnet-sdk = dotnetCorePackages.sdk_6.0;
|
||||
dotnet-runtime = dotnetCorePackages.runtime_6_0;
|
||||
|
||||
executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`.
|
||||
@@ -160,8 +156,6 @@ in buildDotnetModule rec {
|
||||
}
|
||||
```
|
||||
|
||||
Keep in mind that you can tag the [`@NixOS/dotnet`](https://github.com/orgs/nixos/teams/dotnet) team for help and code review.
|
||||
|
||||
## Dotnet global tools {#dotnet-global-tools}
|
||||
|
||||
[.NET Global tools](https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools) are a mechanism provided by the dotnet CLI to install .NET binaries from Nuget packages.
|
||||
@@ -210,51 +204,13 @@ buildDotnetGlobalTool {
|
||||
|
||||
nugetSha256 = "sha256-ZG2HFyKYhVNVYd2kRlkbAjZJq88OADe3yjxmLuxXDUo=";
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
homepage = "https://cmd.petabridge.com/index.html";
|
||||
changelog = "https://cmd.petabridge.com/articles/RELEASE_NOTES.html";
|
||||
license = lib.licenses.unfree;
|
||||
platforms = lib.platforms.linux;
|
||||
license = licenses.unfree;
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
```
|
||||
## Generating and updating NuGet dependencies {#generating-and-updating-nuget-dependencies}
|
||||
|
||||
First, restore the packages to the `out` directory, ensure you have cloned
|
||||
the upstream repository and you are inside it.
|
||||
|
||||
```bash
|
||||
$ dotnet restore --packages out
|
||||
Determining projects to restore...
|
||||
Restored /home/lychee/Celeste64/Celeste64.csproj (in 1.21 sec).
|
||||
```
|
||||
|
||||
Next, use `nuget-to-nix` tool provided in nixpkgs to generate a lockfile to `deps.nix` from
|
||||
the packages inside the `out` directory.
|
||||
|
||||
```bash
|
||||
$ nuget-to-nix out > deps.nix
|
||||
```
|
||||
Which `nuget-to-nix` will generate an output similar to below
|
||||
```
|
||||
{ fetchNuGet }: [
|
||||
(fetchNuGet { pname = "FosterFramework"; version = "0.1.15-alpha"; sha256 = "0pzsdfbsfx28xfqljcwy100xhbs6wyx0z1d5qxgmv3l60di9xkll"; })
|
||||
(fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1gjz379y61ag9whi78qxx09bwkwcznkx2mzypgycibxk61g11da1"; })
|
||||
(fetchNuGet { pname = "Microsoft.NET.ILLink.Tasks"; version = "8.0.1"; sha256 = "1drbgqdcvbpisjn8mqfgba1pwb6yri80qc4mfvyczqwrcsj5k2ja"; })
|
||||
(fetchNuGet { pname = "Microsoft.NETCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1g5b30f4l8a1zjjr3b8pk9mcqxkxqwa86362f84646xaj4iw3a4d"; })
|
||||
(fetchNuGet { pname = "SharpGLTF.Core"; version = "1.0.0-alpha0031"; sha256 = "0ln78mkhbcxqvwnf944hbgg24vbsva2jpih6q3x82d3h7rl1pkh6"; })
|
||||
(fetchNuGet { pname = "SharpGLTF.Runtime"; version = "1.0.0-alpha0031"; sha256 = "0lvb3asi3v0n718qf9y367km7qpkb9wci38y880nqvifpzllw0jg"; })
|
||||
(fetchNuGet { pname = "Sledge.Formats"; version = "1.2.2"; sha256 = "1y0l66m9rym0p1y4ifjlmg3j9lsmhkvbh38frh40rpvf1axn2dyh"; })
|
||||
(fetchNuGet { pname = "Sledge.Formats.Map"; version = "1.1.5"; sha256 = "1bww60hv9xcyxpvkzz5q3ybafdxxkw6knhv97phvpkw84pd0jil6"; })
|
||||
(fetchNuGet { pname = "System.Numerics.Vectors"; version = "4.5.0"; sha256 = "1kzrj37yzawf1b19jq0253rcs8hsq1l2q8g69d7ipnhzb0h97m59"; })
|
||||
]
|
||||
```
|
||||
|
||||
Finally, you move the `deps.nix` file to the appropriate location to be used by `nugetDeps`, then you're all set!
|
||||
|
||||
If you ever need to update the dependencies of a package, you instead do
|
||||
|
||||
* `nix-build -A package.fetch-deps` to generate the update script for `package`
|
||||
* Run `./result deps.nix` to regenerate the lockfile to `deps.nix`, keep in mind if a location isn't provided, it will write to a temporary path instead
|
||||
* Finally, move the file where needed and look at its contents to confirm it has updated the dependencies.
|
||||
|
||||
When packaging a new .NET application in nixpkgs, you can tag the [`@NixOS/dotnet`](https://github.com/orgs/nixos/teams/dotnet) team for help and code review.
|
||||
|
||||
@@ -86,9 +86,9 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update
|
||||
|
||||
postPatch = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
||||
substituteInPlace configure \
|
||||
--replace-fail '/usr/bin/libtool' 'ar' \
|
||||
--replace-fail 'AR="libtool"' 'AR="ar"' \
|
||||
--replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"'
|
||||
--replace '/usr/bin/libtool' 'ar' \
|
||||
--replace 'AR="libtool"' 'AR="ar"' \
|
||||
--replace 'ARFLAGS="-o"' 'ARFLAGS="-r"'
|
||||
'';
|
||||
})
|
||||
```
|
||||
|
||||
@@ -51,11 +51,11 @@ pet = buildGoModule rec {
|
||||
|
||||
vendorHash = "sha256-ciBIR+a1oaYH+H1PcC8cD8ncfJczk1IiJ8iYNM+R6aA=";
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "Simple command-line snippet manager, written in Go";
|
||||
homepage = "https://github.com/knqyf263/pet";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ kalbasit ];
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ kalbasit ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -70,42 +70,39 @@ compilers like this:
|
||||
```console
|
||||
$ nix-env -f '<nixpkgs>' -qaP -A haskell.compiler
|
||||
haskell.compiler.ghc810 ghc-8.10.7
|
||||
haskell.compiler.ghc88 ghc-8.8.4
|
||||
haskell.compiler.ghc90 ghc-9.0.2
|
||||
haskell.compiler.ghc924 ghc-9.2.4
|
||||
haskell.compiler.ghc925 ghc-9.2.5
|
||||
haskell.compiler.ghc926 ghc-9.2.6
|
||||
haskell.compiler.ghc927 ghc-9.2.7
|
||||
haskell.compiler.ghc92 ghc-9.2.8
|
||||
haskell.compiler.ghc945 ghc-9.4.5
|
||||
haskell.compiler.ghc946 ghc-9.4.6
|
||||
haskell.compiler.ghc947 ghc-9.4.7
|
||||
haskell.compiler.ghc94 ghc-9.4.8
|
||||
haskell.compiler.ghc963 ghc-9.6.3
|
||||
haskell.compiler.ghc96 ghc-9.6.4
|
||||
haskell.compiler.ghc98 ghc-9.8.1
|
||||
haskell.compiler.ghcHEAD ghc-9.9.20231121
|
||||
haskell.compiler.ghc92 ghc-9.2.7
|
||||
haskell.compiler.ghc942 ghc-9.4.2
|
||||
haskell.compiler.ghc943 ghc-9.4.3
|
||||
haskell.compiler.ghc94 ghc-9.4.4
|
||||
haskell.compiler.ghcHEAD ghc-9.7.20221224
|
||||
haskell.compiler.ghc8102Binary ghc-binary-8.10.2
|
||||
haskell.compiler.ghc8102BinaryMinimal ghc-binary-8.10.2
|
||||
haskell.compiler.ghc8107BinaryMinimal ghc-binary-8.10.7
|
||||
haskell.compiler.ghc8107Binary ghc-binary-8.10.7
|
||||
haskell.compiler.ghc865Binary ghc-binary-8.6.5
|
||||
haskell.compiler.ghc924Binary ghc-binary-9.2.4
|
||||
haskell.compiler.integer-simple.ghc8107 ghc-integer-simple-8.10.7
|
||||
haskell.compiler.ghc924BinaryMinimal ghc-binary-9.2.4
|
||||
haskell.compiler.integer-simple.ghc810 ghc-integer-simple-8.10.7
|
||||
haskell.compiler.integer-simple.ghc8107 ghc-integer-simple-8.10.7
|
||||
haskell.compiler.integer-simple.ghc88 ghc-integer-simple-8.8.4
|
||||
haskell.compiler.integer-simple.ghc884 ghc-integer-simple-8.8.4
|
||||
haskell.compiler.native-bignum.ghc90 ghc-native-bignum-9.0.2
|
||||
haskell.compiler.native-bignum.ghc902 ghc-native-bignum-9.0.2
|
||||
haskell.compiler.native-bignum.ghc924 ghc-native-bignum-9.2.4
|
||||
haskell.compiler.native-bignum.ghc925 ghc-native-bignum-9.2.5
|
||||
haskell.compiler.native-bignum.ghc926 ghc-native-bignum-9.2.6
|
||||
haskell.compiler.native-bignum.ghc92 ghc-native-bignum-9.2.7
|
||||
haskell.compiler.native-bignum.ghc927 ghc-native-bignum-9.2.7
|
||||
haskell.compiler.native-bignum.ghc92 ghc-native-bignum-9.2.8
|
||||
haskell.compiler.native-bignum.ghc928 ghc-native-bignum-9.2.8
|
||||
haskell.compiler.native-bignum.ghc945 ghc-native-bignum-9.4.5
|
||||
haskell.compiler.native-bignum.ghc946 ghc-native-bignum-9.4.6
|
||||
haskell.compiler.native-bignum.ghc947 ghc-native-bignum-9.4.7
|
||||
haskell.compiler.native-bignum.ghc94 ghc-native-bignum-9.4.8
|
||||
haskell.compiler.native-bignum.ghc948 ghc-native-bignum-9.4.8
|
||||
haskell.compiler.native-bignum.ghc963 ghc-native-bignum-9.6.3
|
||||
haskell.compiler.native-bignum.ghc96 ghc-native-bignum-9.6.4
|
||||
haskell.compiler.native-bignum.ghc964 ghc-native-bignum-9.6.4
|
||||
haskell.compiler.native-bignum.ghc98 ghc-native-bignum-9.8.1
|
||||
haskell.compiler.native-bignum.ghc981 ghc-native-bignum-9.8.1
|
||||
haskell.compiler.native-bignum.ghcHEAD ghc-native-bignum-9.9.20231121
|
||||
haskell.compiler.native-bignum.ghc942 ghc-native-bignum-9.4.2
|
||||
haskell.compiler.native-bignum.ghc943 ghc-native-bignum-9.4.3
|
||||
haskell.compiler.native-bignum.ghc94 ghc-native-bignum-9.4.4
|
||||
haskell.compiler.native-bignum.ghc944 ghc-native-bignum-9.4.4
|
||||
haskell.compiler.native-bignum.ghcHEAD ghc-native-bignum-9.7.20221224
|
||||
haskell.compiler.ghcjs ghcjs-8.10.7
|
||||
```
|
||||
|
||||
@@ -113,7 +110,7 @@ Each of those compiler versions has a corresponding attribute set built using
|
||||
it. However, the non-standard package sets are not tested regularly and, as a
|
||||
result, contain fewer working packages. The corresponding package set for GHC
|
||||
9.4.5 is `haskell.packages.ghc945`. In fact `haskellPackages` is just an alias
|
||||
for `haskell.packages.ghc964`:
|
||||
for `haskell.packages.ghc927`:
|
||||
|
||||
```console
|
||||
$ nix-env -f '<nixpkgs>' -qaP -A haskell.packages.ghc927
|
||||
@@ -1020,11 +1017,6 @@ failing because of e.g. a syntax error in the Haddock documentation.
|
||||
: Sets `doCheck` to `false` for `drv`. Useful if a package has a broken,
|
||||
flaky or otherwise problematic test suite breaking the build.
|
||||
|
||||
`dontCheckIf condition drv`
|
||||
: Sets `doCheck` to `false` for `drv`, but only if `condition` applies.
|
||||
Otherwise it's a no-op. Useful to conditionally disable tests for a package
|
||||
without interfering with previous overrides or default values.
|
||||
|
||||
<!-- Purposefully omitting the non-list variants here. They are a bit
|
||||
ugly, and we may want to deprecate them at some point. -->
|
||||
|
||||
@@ -1234,12 +1226,10 @@ in
|
||||
in
|
||||
|
||||
{
|
||||
haskell = prev.haskell // {
|
||||
compiler = prev.haskell.compiler // {
|
||||
${ghcName} = prev.haskell.compiler.${ghcName}.override {
|
||||
# Unfortunately, the GHC setting is named differently for historical reasons
|
||||
enableProfiledLibs = enableProfiling;
|
||||
};
|
||||
haskell = lib.recursiveUpdate prev.haskell {
|
||||
compiler.${ghcName} = prev.haskell.compiler.${ghcName}.override {
|
||||
# Unfortunately, the GHC setting is named differently for historical reasons
|
||||
enableProfiledLibs = enableProfiling;
|
||||
};
|
||||
};
|
||||
})
|
||||
@@ -1251,33 +1241,31 @@ in
|
||||
in
|
||||
|
||||
{
|
||||
haskell = prev.haskell // {
|
||||
packages = prev.haskell.packages // {
|
||||
${ghcName} = prev.haskell.packages.${ghcName}.override {
|
||||
overrides = hfinal: hprev: {
|
||||
mkDerivation = args: hprev.mkDerivation (args // {
|
||||
# Since we are forcing our ideas upon mkDerivation, this change will
|
||||
# affect every package in the package set.
|
||||
enableLibraryProfiling = enableProfiling;
|
||||
haskell = lib.recursiveUpdate prev.haskell {
|
||||
packages.${ghcName} = prev.haskell.packages.${ghcName}.override {
|
||||
overrides = hfinal: hprev: {
|
||||
mkDerivation = args: hprev.mkDerivation (args // {
|
||||
# Since we are forcing our ideas upon mkDerivation, this change will
|
||||
# affect every package in the package set.
|
||||
enableLibraryProfiling = enableProfiling;
|
||||
|
||||
# To actually use profiling on an executable, executable profiling
|
||||
# needs to be enabled for the executable you want to profile. You
|
||||
# can either do this globally or…
|
||||
enableExecutableProfiling = enableProfiling;
|
||||
});
|
||||
# To actually use profiling on an executable, executable profiling
|
||||
# needs to be enabled for the executable you want to profile. You
|
||||
# can either do this globally or…
|
||||
enableExecutableProfiling = enableProfiling;
|
||||
});
|
||||
|
||||
# …only for the package that contains an executable you want to profile.
|
||||
# That saves on unnecessary rebuilds for packages that you only depend
|
||||
# on for their library, but also contain executables (e.g. pandoc).
|
||||
my-executable = haskellLib.enableExecutableProfiling hprev.my-executable;
|
||||
# …only for the package that contains an executable you want to profile.
|
||||
# That saves on unnecessary rebuilds for packages that you only depend
|
||||
# on for their library, but also contain executables (e.g. pandoc).
|
||||
my-executable = haskellLib.enableExecutableProfiling hprev.my-executable;
|
||||
|
||||
# If you are disabling profiling to save on build time, but want to
|
||||
# retain the ability to substitute from the binary cache. Drop the
|
||||
# override for mkDerivation above and instead have an override like
|
||||
# this for the specific packages you are building locally and want
|
||||
# to make cheaper to build.
|
||||
my-library = haskellLib.disableLibraryProfiling hprev.my-library;
|
||||
};
|
||||
# If you are disabling profiling to save on build time, but want to
|
||||
# retain the ability to substitute from the binary cache. Drop the
|
||||
# override for mkDerivation above and instead have an override like
|
||||
# this for the specific packages you are building locally and want
|
||||
# to make cheaper to build.
|
||||
my-library = haskellLib.disableLibraryProfiling hprev.my-library;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -93,11 +93,11 @@ build-idris-package {
|
||||
hash = "sha256-h28F9EEPuvab6zrfeE+0k1XGQJGwINnsJEG8yjWIl7w=";
|
||||
};
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "Idris YAML lib";
|
||||
homepage = "https://github.com/Heather/Idris.Yaml";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = [ lib.maintainers.brainrape ];
|
||||
license = licenses.mit;
|
||||
maintainers = [ maintainers.brainrape ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
In addition to exposing the Idris2 compiler itself, Nixpkgs exposes an `idris2Packages.buildIdris` helper to make it a bit more ergonomic to build Idris2 executables or libraries.
|
||||
|
||||
The `buildIdris` function takes an attribute set that defines at a minimum the `src` and `ipkgName` of the package to be built and any `idrisLibraries` required to build it. The `src` is the same source you're familiar with and the `ipkgName` must be the name of the `ipkg` file for the project (omitting the `.ipkg` extension). The `idrisLibraries` is a list of other library derivations created with `buildIdris`. You can optionally specify other derivation properties as needed but sensible defaults for `configurePhase`, `buildPhase`, and `installPhase` are provided.
|
||||
The `buildIdris` function takes a package set that defines at a minimum the `src` and `projectName` of the package to be built and any `idrisLibraries` required to build it. The `src` is the same source you're familiar with but the `projectName` must be the name of the `ipkg` file for the project (omitting the `.ipkg` extension). The `idrisLibraries` is a list of other library derivations created with `buildIdris`. You can optionally specify other derivation properties as needed but sensible defaults for `configurePhase`, `buildPhase`, and `installPhase` are provided.
|
||||
|
||||
Importantly, `buildIdris` does not create a single derivation but rather an attribute set with two properties: `executable` and `library`. The `executable` property is a derivation and the `library` property is a function that will return a derivation for the library with or without source code included. Source code need not be included unless you are aiming to use IDE or LSP features that are able to jump to definitions within an editor.
|
||||
|
||||
@@ -10,7 +10,7 @@ A simple example of a fully packaged library would be the [`LSP-lib`](https://gi
|
||||
```nix
|
||||
{ fetchFromGitHub, idris2Packages }:
|
||||
let lspLibPkg = idris2Packages.buildIdris {
|
||||
ipkgName = "lsp-lib";
|
||||
projectName = "lsp-lib";
|
||||
src = fetchFromGitHub {
|
||||
owner = "idris-community";
|
||||
repo = "LSP-lib";
|
||||
@@ -31,7 +31,7 @@ A slightly more involved example of a fully packaged executable would be the [`i
|
||||
# Assuming the previous example lives in `lsp-lib.nix`:
|
||||
let lspLib = callPackage ./lsp-lib.nix { };
|
||||
lspPkg = idris2Packages.buildIdris {
|
||||
ipkgName = "idris2-lsp";
|
||||
projectName = "idris2-lsp";
|
||||
src = fetchFromGitHub {
|
||||
owner = "idris-community";
|
||||
repo = "idris2-lsp";
|
||||
|
||||
@@ -4,31 +4,12 @@ Ant-based Java packages are typically built from source as follows:
|
||||
|
||||
```nix
|
||||
stdenv.mkDerivation {
|
||||
pname = "...";
|
||||
version = "...";
|
||||
|
||||
name = "...";
|
||||
src = fetchurl { ... };
|
||||
|
||||
nativeBuildInputs = [
|
||||
ant
|
||||
jdk
|
||||
stripJavaArchivesHook # removes timestamp metadata from jar files
|
||||
];
|
||||
nativeBuildInputs = [ jdk ant ];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
ant # build the project using ant
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# copy generated jar file(s) to an appropriate location in $out
|
||||
install -Dm644 build/foo.jar $out/share/java/foo.jar
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
buildPhase = "ant";
|
||||
}
|
||||
```
|
||||
|
||||
@@ -36,10 +17,6 @@ Note that `jdk` is an alias for the OpenJDK (self-built where available,
|
||||
or pre-built via Zulu). Platforms with OpenJDK not (yet) in Nixpkgs
|
||||
(`Aarch32`, `Aarch64`) point to the (unfree) `oraclejdk`.
|
||||
|
||||
Also note that not using `stripJavaArchivesHook` will likely cause the
|
||||
generated `.jar` files to be non-deterministic, which is not optimal.
|
||||
Using it, however, does not always guarantee reproducibility.
|
||||
|
||||
JAR files that are intended to be used by other packages should be
|
||||
installed in `$out/share/java`. JDKs have a stdenv setup hook that add
|
||||
any JARs in the `share/java` directories of the build inputs to the
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
|
||||
This contains instructions on how to package javascript applications.
|
||||
|
||||
The various tools available will be listed in the [tools-overview](#javascript-tools-overview).
|
||||
Some general principles for packaging will follow.
|
||||
Finally some tool specific instructions will be given.
|
||||
The various tools available will be listed in the [tools-overview](#javascript-tools-overview). Some general principles for packaging will follow. Finally some tool specific instructions will be given.
|
||||
|
||||
## Getting unstuck / finding code examples {#javascript-finding-examples}
|
||||
|
||||
If you find you are lacking inspiration for packaging javascript applications, the links below might prove useful.
|
||||
Searching online for prior art can be helpful if you are running into solved problems.
|
||||
If you find you are lacking inspiration for packing javascript applications, the links below might prove useful. Searching online for prior art can be helpful if you are running into solved problems.
|
||||
|
||||
### Github {#javascript-finding-examples-github}
|
||||
|
||||
@@ -33,23 +30,17 @@ The following principles are given in order of importance with potential excepti
|
||||
|
||||
It is often not documented which node version is used upstream, but if it is, try to use the same version when packaging.
|
||||
|
||||
This can be a problem if upstream is using the latest and greatest and you are trying to use an earlier version of node.
|
||||
Some cryptic errors regarding V8 may appear.
|
||||
This can be a problem if upstream is using the latest and greatest and you are trying to use an earlier version of node. Some cryptic errors regarding V8 may appear.
|
||||
|
||||
### Try to respect the package manager originally used by upstream (and use the upstream lock file) {#javascript-upstream-package-manager}
|
||||
|
||||
A lock file (package-lock.json, yarn.lock...) is supposed to make reproducible installations of `node_modules` for each tool.
|
||||
A lock file (package-lock.json, yarn.lock...) is supposed to make reproducible installations of node_modules for each tool.
|
||||
|
||||
Guidelines of package managers, recommend to commit those lock files to the repos.
|
||||
If a particular lock file is present, it is a strong indication of which package manager is used upstream.
|
||||
Guidelines of package managers, recommend to commit those lock files to the repos. If a particular lock file is present, it is a strong indication of which package manager is used upstream.
|
||||
|
||||
It's better to try to use a Nix tool that understand the lock file.
|
||||
Using a different tool might give you hard to understand error because different packages have been installed.
|
||||
An example of problems that could arise can be found [here](https://github.com/NixOS/nixpkgs/pull/126629).
|
||||
Upstream use NPM, but this is an attempt to package it with `yarn2nix` (that uses yarn.lock).
|
||||
It's better to try to use a Nix tool that understand the lock file. Using a different tool might give you hard to understand error because different packages have been installed. An example of problems that could arise can be found [here](https://github.com/NixOS/nixpkgs/pull/126629). Upstream use NPM, but this is an attempt to package it with `yarn2nix` (that uses yarn.lock).
|
||||
|
||||
Using a different tool forces to commit a lock file to the repository.
|
||||
Those files are fairly large, so when packaging for nixpkgs, this approach does not scale well.
|
||||
Using a different tool forces to commit a lock file to the repository. Those files are fairly large, so when packaging for nixpkgs, this approach does not scale well.
|
||||
|
||||
Exceptions to this rule are:
|
||||
|
||||
@@ -87,23 +78,17 @@ Exceptions to this rule are:
|
||||
|
||||
### Using node_modules directly {#javascript-using-node_modules}
|
||||
|
||||
Each tool has an abstraction to just build the node_modules (dependencies) directory.
|
||||
You can always use the `stdenv.mkDerivation` with the node_modules to build the package (symlink the node_modules directory and then use the package build command).
|
||||
The node_modules abstraction can be also used to build some web framework frontends.
|
||||
For an example of this see how [plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix) is built. `mkYarnModules` to make the derivation containing node_modules.
|
||||
Then when building the frontend you can just symlink the node_modules directory.
|
||||
Each tool has an abstraction to just build the node_modules (dependencies) directory. You can always use the `stdenv.mkDerivation` with the node_modules to build the package (symlink the node_modules directory and then use the package build command). The node_modules abstraction can be also used to build some web framework frontends. For an example of this see how [plausible](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/web-apps/plausible/default.nix) is built. `mkYarnModules` to make the derivation containing node_modules. Then when building the frontend you can just symlink the node_modules directory.
|
||||
|
||||
## Javascript packages inside nixpkgs {#javascript-packages-nixpkgs}
|
||||
|
||||
The [pkgs/development/node-packages](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages) folder contains a generated collection of [NPM packages](https://npmjs.com/) that can be installed with the Nix package manager.
|
||||
|
||||
As a rule of thumb, the package set should only provide _end user_ software packages, such as command-line utilities.
|
||||
Libraries should only be added to the package set if there is a non-NPM package that requires it.
|
||||
As a rule of thumb, the package set should only provide _end user_ software packages, such as command-line utilities. Libraries should only be added to the package set if there is a non-NPM package that requires it.
|
||||
|
||||
When it is desired to use NPM libraries in a development project, use the `node2nix` generator directly on the `package.json` configuration file of the project.
|
||||
|
||||
The package set provides support for the official stable Node.js versions.
|
||||
The latest stable LTS release in `nodePackages`, as well as the latest stable current release in `nodePackages_latest`.
|
||||
The package set provides support for the official stable Node.js versions. The latest stable LTS release in `nodePackages`, as well as the latest stable current release in `nodePackages_latest`.
|
||||
|
||||
If your package uses native addons, you need to examine what kind of native build system it uses. Here are some examples:
|
||||
|
||||
@@ -111,8 +96,7 @@ If your package uses native addons, you need to examine what kind of native buil
|
||||
- `node-gyp-builder`
|
||||
- `node-pre-gyp`
|
||||
|
||||
After you have identified the correct system, you need to override your package expression while adding in build system as a build input.
|
||||
For example, `dat` requires `node-gyp-build`, so we override its expression in [pkgs/development/node-packages/overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/overrides.nix):
|
||||
After you have identified the correct system, you need to override your package expression while adding in build system as a build input. For example, `dat` requires `node-gyp-build`, so we override its expression in [pkgs/development/node-packages/overrides.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/node-packages/overrides.nix):
|
||||
|
||||
```nix
|
||||
dat = prev.dat.override (oldAttrs: {
|
||||
@@ -175,8 +159,7 @@ git config --global url."https://github.com/".insteadOf git://github.com/
|
||||
|
||||
### buildNpmPackage {#javascript-buildNpmPackage}
|
||||
|
||||
`buildNpmPackage` allows you to package npm-based projects in Nixpkgs without the use of an auto-generated dependencies file (as used in [node2nix](#javascript-node2nix)).
|
||||
It works by utilizing npm's cache functionality -- creating a reproducible cache that contains the dependencies of a project, and pointing npm to it.
|
||||
`buildNpmPackage` allows you to package npm-based projects in Nixpkgs without the use of an auto-generated dependencies file (as used in [node2nix](#javascript-node2nix)). It works by utilizing npm's cache functionality -- creating a reproducible cache that contains the dependencies of a project, and pointing npm to it.
|
||||
|
||||
Here's an example:
|
||||
|
||||
@@ -201,18 +184,16 @@ buildNpmPackage rec {
|
||||
|
||||
NODE_OPTIONS = "--openssl-legacy-provider";
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "A modern web UI for various torrent clients with a Node.js backend and React frontend";
|
||||
homepage = "https://flood.js.org";
|
||||
license = lib.licenses.gpl3Only;
|
||||
maintainers = with lib.maintainers; [ winter ];
|
||||
license = licenses.gpl3Only;
|
||||
maintainers = with maintainers; [ winter ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`.
|
||||
Additionally, the `bin` and `man` keys in the source's `package.json` are used to decide what binaries and manpages are supposed to be installed.
|
||||
If these are not defined, `npm pack` may miss some files, and no binaries will be produced.
|
||||
In the default `installPhase` set by `buildNpmPackage`, it uses `npm pack --json --dry-run` to decide what files to install in `$out/lib/node_modules/$name/`, where `$name` is the `name` string defined in the package's `package.json`. Additionally, the `bin` and `man` keys in the source's `package.json` are used to decide what binaries and manpages are supposed to be installed. If these are not defined, `npm pack` may miss some files, and no binaries will be produced.
|
||||
|
||||
#### Arguments {#javascript-buildNpmPackage-arguments}
|
||||
|
||||
@@ -252,37 +233,6 @@ sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
|
||||
|
||||
It returns a derivation with all `package-lock.json` dependencies downloaded into `$out/`, usable as an npm cache.
|
||||
|
||||
#### importNpmLock {#javascript-buildNpmPackage-importNpmLock}
|
||||
|
||||
`importNpmLock` is a Nix function that requires the following optional arguments:
|
||||
|
||||
- `npmRoot`: Path to package directory containing the source tree
|
||||
- `package`: Parsed contents of `package.json`
|
||||
- `packageLock`: Parsed contents of `package-lock.json`
|
||||
- `pname`: Package name
|
||||
- `version`: Package version
|
||||
|
||||
It returns a derivation with a patched `package.json` & `package-lock.json` with all dependencies resolved to Nix store paths.
|
||||
|
||||
This function is analogous to using `fetchNpmDeps`, but instead of specifying `hash` it uses metadata from `package.json` & `package-lock.json`.
|
||||
|
||||
Note that `npmHooks.npmConfigHook` cannot be used with `importNpmLock`. You will instead need to use `importNpmLock.npmConfigHook`:
|
||||
|
||||
```nix
|
||||
{ buildNpmPackage, importNpmLock }:
|
||||
|
||||
buildNpmPackage {
|
||||
pname = "hello";
|
||||
version = "0.1.0";
|
||||
|
||||
npmDeps = importNpmLock {
|
||||
npmRoot = ./.;
|
||||
};
|
||||
|
||||
npmConfigHook = importNpmLock.npmConfigHook;
|
||||
}
|
||||
```
|
||||
|
||||
### corepack {#javascript-corepack}
|
||||
|
||||
This package puts the corepack wrappers for pnpm and yarn in your PATH, and they will honor the `packageManager` setting in the `package.json`.
|
||||
@@ -334,10 +284,10 @@ buildPhase = ''
|
||||
'';
|
||||
```
|
||||
|
||||
The `distPhase` is packing the package's dependencies in a tarball using `yarn pack`. You can disable it using:
|
||||
The dist phase is also trying to build a binary, the only way to override it is with:
|
||||
|
||||
```nix
|
||||
doDist = false;
|
||||
distPhase = "true";
|
||||
```
|
||||
|
||||
The configure phase can sometimes fail because it makes many assumptions which may not always apply. One common override is:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Lua {#lua}
|
||||
# User’s Guide to Lua Infrastructure {#users-guide-to-lua-infrastructure}
|
||||
|
||||
## Using Lua {#lua-userguide}
|
||||
## Using Lua {#using-lua}
|
||||
|
||||
### Overview of Lua {#lua-overview}
|
||||
### Overview of Lua {#overview-of-lua}
|
||||
|
||||
Several versions of the Lua interpreter are available: luajit, lua 5.1, 5.2, 5.3.
|
||||
The attribute `lua` refers to the default interpreter, it is also possible to refer to specific versions, e.g. `lua5_2` refers to Lua 5.2.
|
||||
@@ -118,7 +118,7 @@ Again, it is possible to launch the interpreter from the shell.
|
||||
The Lua interpreter has the attribute `pkgs` which contains all Lua libraries for that specific interpreter.
|
||||
|
||||
|
||||
## Developing with lua {#lua-developing}
|
||||
## Developing with Lua {#developing-with-lua}
|
||||
|
||||
Now that you know how to get a working Lua environment with Nix, it is time
|
||||
to go forward and start actually developing with Lua. There are two ways to
|
||||
@@ -193,10 +193,10 @@ luaposix = buildLuarocksPackage {
|
||||
disabled = (luaOlder "5.1") || (luaAtLeast "5.4");
|
||||
propagatedBuildInputs = [ bit32 lua std_normalize ];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/luaposix/luaposix/";
|
||||
description = "Lua bindings for POSIX";
|
||||
maintainers = with lib.maintainers; [ vyp lblasc ];
|
||||
maintainers = with maintainers; [ vyp lblasc ];
|
||||
license.fullName = "MIT/X11";
|
||||
};
|
||||
};
|
||||
@@ -215,11 +215,6 @@ install the package
|
||||
environment variable and add dependent libraries to script's `LUA_PATH` and
|
||||
`LUA_CPATH`.
|
||||
|
||||
It accepts as arguments:
|
||||
|
||||
* 'luarocksConfig': a nix value that directly maps to the luarocks config used during
|
||||
the installation
|
||||
|
||||
By default `meta.platforms` is set to the same value as the interpreter unless overridden otherwise.
|
||||
|
||||
#### `buildLuaApplication` function {#buildluaapplication-function}
|
||||
@@ -234,20 +229,30 @@ The `lua.withPackages` takes a function as an argument that is passed the set of
|
||||
Using the `withPackages` function, the previous example for the luafilesystem environment can be written like this:
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
|
||||
lua.withPackages (ps: [ps.luafilesystem])
|
||||
```
|
||||
|
||||
`withPackages` passes the correct package set for the specific interpreter version as an argument to the function. In the above example, `ps` equals `luaPackages`.
|
||||
But you can also easily switch to using `lua5_1`:
|
||||
But you can also easily switch to using `lua5_2`:
|
||||
|
||||
```nix
|
||||
lua5_1.withPackages (ps: [ps.lua])
|
||||
with import <nixpkgs> {};
|
||||
|
||||
lua5_2.withPackages (ps: [ps.lua])
|
||||
```
|
||||
|
||||
Now, `ps` is set to `lua5_1.pkgs`, matching the version of the interpreter.
|
||||
Now, `ps` is set to `lua52Packages`, matching the version of the interpreter.
|
||||
|
||||
### Lua Contributing guidelines {#lua-contributing}
|
||||
### Possible Todos {#possible-todos}
|
||||
|
||||
* export/use version specific variables such as `LUA_PATH_5_2`/`LUAROCKS_CONFIG_5_2`
|
||||
* let luarocks check for dependencies via exporting the different rocktrees in temporary config
|
||||
|
||||
### Lua Contributing guidelines {#lua-contributing-guidelines}
|
||||
|
||||
Following rules should be respected:
|
||||
|
||||
* Make sure libraries build for all Lua interpreters.
|
||||
* Commit names of Lua libraries should reflect that they are Lua libraries, so write for example `luaPackages.luafilesystem: 1.11 -> 1.12`.
|
||||
|
||||
@@ -34,11 +34,11 @@ maven.buildMavenPackage rec {
|
||||
--add-flags "-jar $out/share/jd-cli/jd-cli.jar"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "Simple command line wrapper around JD Core Java Decompiler project";
|
||||
homepage = "https://github.com/intoolswetrust/jd-cli";
|
||||
license = lib.licenses.gpl3Plus;
|
||||
maintainers = with lib.maintainers; [ majiir ];
|
||||
license = licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ majiir ];
|
||||
};
|
||||
}:
|
||||
```
|
||||
|
||||
@@ -110,11 +110,11 @@ buildDunePackage rec {
|
||||
hash = "sha256-d5/3KUBAWRj8tntr4RkJ74KWW7wvn/B/m1nx0npnzyc=";
|
||||
};
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/flowtype/ocaml-wtf8";
|
||||
description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = [ lib.maintainers.eqyiel ];
|
||||
license = licenses.mit;
|
||||
maintainers = [ maintainers.eqyiel ];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
| Package | Aliases | Interpreter |
|
||||
|------------|-----------------|-------------|
|
||||
| python27 | python2, python | CPython 2.7 |
|
||||
| python38 | | CPython 3.8 |
|
||||
| python39 | | CPython 3.9 |
|
||||
| python310 | | CPython 3.10 |
|
||||
| python311 | python3 | CPython 3.11 |
|
||||
@@ -59,6 +60,7 @@ sets are
|
||||
|
||||
* `pkgs.python27Packages`
|
||||
* `pkgs.python3Packages`
|
||||
* `pkgs.python38Packages`
|
||||
* `pkgs.python39Packages`
|
||||
* `pkgs.python310Packages`
|
||||
* `pkgs.python311Packages`
|
||||
@@ -74,9 +76,8 @@ and the aliases
|
||||
|
||||
#### `buildPythonPackage` function {#buildpythonpackage-function}
|
||||
|
||||
The `buildPythonPackage` function has its name binding in
|
||||
`pkgs/development/interpreters/python/python-packages-base.nix` and is
|
||||
implemented in `pkgs/development/interpreters/python/mk-python-derivation.nix`
|
||||
The `buildPythonPackage` function is implemented in
|
||||
`pkgs/development/interpreters/python/mk-python-derivation.nix`
|
||||
using setup hooks.
|
||||
|
||||
The following is an example:
|
||||
@@ -115,11 +116,11 @@ buildPythonPackage rec {
|
||||
rm testing/test_argcomplete.py
|
||||
'';
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
setuptools-scm
|
||||
];
|
||||
|
||||
dependencies = [
|
||||
propagatedBuildInputs = [
|
||||
attrs
|
||||
py
|
||||
setuptools
|
||||
@@ -131,12 +132,12 @@ buildPythonPackage rec {
|
||||
hypothesis
|
||||
];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
|
||||
description = "Framework for writing tests";
|
||||
homepage = "https://github.com/pytest-dev/pytest";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ domenkozar lovek323 madjar lsix ];
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ domenkozar lovek323 madjar lsix ];
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -171,10 +172,10 @@ following are specific to `buildPythonPackage`:
|
||||
variable in wrapped programs.
|
||||
* `pyproject`: Whether the pyproject format should be used. When set to `true`,
|
||||
`pypaBuildHook` will be used, and you can add the required build dependencies
|
||||
from `build-system.requires` to `build-system`. Note that the pyproject
|
||||
from `build-system.requires` to `nativeBuildInputs`. Note that the pyproject
|
||||
format falls back to using `setuptools`, so you can use `pyproject = true`
|
||||
even if the package only has a `setup.py`. When set to `false`, you can
|
||||
use the existing [hooks](#setup-hooks) or provide your own logic to build the
|
||||
use the existing [hooks](#setup-hooks0 or provide your own logic to build the
|
||||
package. This can be useful for packages that don't support the pyproject
|
||||
format. When unset, the legacy `setuptools` hooks are used for backwards
|
||||
compatibility.
|
||||
@@ -205,22 +206,17 @@ build inputs (see "Specifying dependencies"). The following are of special
|
||||
interest for Python packages, either because these are primarily used, or
|
||||
because their behaviour is different:
|
||||
|
||||
* `nativeBuildInputs ? []`: Build-time only dependencies. Typically executables.
|
||||
* `build-system ? []`: Build-time only Python dependencies. Items listed in `build-system.requires`/`setup_requires`.
|
||||
* `nativeBuildInputs ? []`: Build-time only dependencies. Typically executables
|
||||
as well as the items listed in `setup_requires`.
|
||||
* `buildInputs ? []`: Build and/or run-time dependencies that need to be
|
||||
compiled for the host machine. Typically non-Python libraries which are being
|
||||
linked.
|
||||
* `nativeCheckInputs ? []`: Dependencies needed for running the [`checkPhase`](#ssec-check-phase). These
|
||||
are added to [`nativeBuildInputs`](#var-stdenv-nativeBuildInputs) when [`doCheck = true`](#var-stdenv-doCheck). Items listed in
|
||||
`tests_require` go here.
|
||||
* `dependencies ? []`: Aside from propagating dependencies,
|
||||
* `propagatedBuildInputs ? []`: Aside from propagating dependencies,
|
||||
`buildPythonPackage` also injects code into and wraps executables with the
|
||||
paths included in this list. Items listed in `install_requires` go here.
|
||||
* `optional-dependencies ? { }`: Optional feature flagged dependencies. Items listed in `extras_requires` go here.
|
||||
|
||||
Aside from propagating dependencies,
|
||||
`buildPythonPackage` also injects code into and wraps executables with the
|
||||
paths included in this list. Items listed in `extras_requires` go here.
|
||||
|
||||
##### Overriding Python packages {#overriding-python-packages}
|
||||
|
||||
@@ -303,17 +299,16 @@ python3Packages.buildPythonApplication rec {
|
||||
hash = "sha256-Pe229rT0aHwA98s+nTHQMEFKZPo/yw6sot8MivFDvAw=";
|
||||
};
|
||||
|
||||
build-system = with python3Packages; [
|
||||
nativeBuildInputs = with python3Packages; [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
|
||||
dependencies = with python3Packages; [
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
tornado
|
||||
python-daemon
|
||||
];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
# ...
|
||||
};
|
||||
}
|
||||
@@ -467,14 +462,14 @@ are used in [`buildPythonPackage`](#buildpythonpackage-function).
|
||||
- `eggBuildHook` to skip building for eggs.
|
||||
- `eggInstallHook` to install eggs.
|
||||
- `pipBuildHook` to build a wheel using `pip` and PEP 517. Note a build system
|
||||
(e.g. `setuptools` or `flit`) should still be added as `build-system`.
|
||||
(e.g. `setuptools` or `flit`) should still be added as `nativeBuildInput`.
|
||||
- `pypaBuildHook` to build a wheel using
|
||||
[`pypa/build`](https://pypa-build.readthedocs.io/en/latest/index.html) and
|
||||
PEP 517/518. Note a build system (e.g. `setuptools` or `flit`) should still
|
||||
be added as `build-system`.
|
||||
be added as `nativeBuildInput`.
|
||||
- `pipInstallHook` to install wheels.
|
||||
- `pytestCheckHook` to run tests with `pytest`. See [example usage](#using-pytestcheckhook).
|
||||
- `pythonCatchConflictsHook` to fail if the package depends on two different versions of the same dependency.
|
||||
- `pythonCatchConflictsHook` to check whether a Python package is not already existing.
|
||||
- `pythonImportsCheckHook` to check whether importing the listed modules works.
|
||||
- `pythonRelaxDepsHook` will relax Python dependencies restrictions for the package.
|
||||
See [example usage](#using-pythonrelaxdepshook).
|
||||
@@ -886,7 +881,7 @@ buildPythonPackage rec {
|
||||
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
@@ -900,12 +895,12 @@ buildPythonPackage rec {
|
||||
"toolz.dicttoolz"
|
||||
];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
|
||||
homepage = "https://github.com/pytoolz/toolz";
|
||||
description = "List processing tools and functional utilities";
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = with lib.maintainers; [ fridh ];
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ fridh ];
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -946,7 +941,7 @@ with import <nixpkgs> {};
|
||||
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
python311.pkgs.setuptools
|
||||
python311.pkgs.wheel
|
||||
];
|
||||
@@ -982,15 +977,13 @@ that we introduced with the `let` expression.
|
||||
|
||||
#### Handling dependencies {#handling-dependencies}
|
||||
|
||||
Our example, `toolz`, does not have any dependencies on other Python packages or system libraries.
|
||||
[`buildPythonPackage`](#buildpythonpackage-function) uses the the following arguments in the following circumstances:
|
||||
|
||||
- `dependencies` - For Python runtime dependencies.
|
||||
- `build-system` - For Python build-time requirements.
|
||||
- [`buildInputs`](#var-stdenv-buildInputs) - For non-Python build-time requirements.
|
||||
- [`nativeCheckInputs`](#var-stdenv-nativeCheckInputs) - For test dependencies
|
||||
|
||||
Dependencies can belong to multiple arguments, for example if something is both a build time requirement & a runtime dependency.
|
||||
Our example, `toolz`, does not have any dependencies on other Python packages or
|
||||
system libraries. According to the manual, [`buildPythonPackage`](#buildpythonpackage-function) uses the
|
||||
arguments [`buildInputs`](#var-stdenv-buildInputs) and [`propagatedBuildInputs`](#var-stdenv-propagatedBuildInputs) to specify dependencies. If
|
||||
something is exclusively a build-time dependency, then the dependency should be
|
||||
included in [`buildInputs`](#var-stdenv-buildInputs), but if it is (also) a runtime dependency, then it
|
||||
should be added to [`propagatedBuildInputs`](#var-stdenv-propagatedBuildInputs). Test dependencies are considered
|
||||
build-time dependencies and passed to [`nativeCheckInputs`](#var-stdenv-nativeCheckInputs).
|
||||
|
||||
The following example shows which arguments are given to [`buildPythonPackage`](#buildpythonpackage-function) in
|
||||
order to build [`datashape`](https://github.com/blaze/datashape).
|
||||
@@ -1020,12 +1013,12 @@ buildPythonPackage rec {
|
||||
hash = "sha256-FLLvdm1MllKrgTGC6Gb0k0deZeVYvtCCLji/B7uhong=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
|
||||
dependencies = [
|
||||
propagatedBuildInputs = [
|
||||
multipledispatch
|
||||
numpy
|
||||
python-dateutil
|
||||
@@ -1035,12 +1028,12 @@ buildPythonPackage rec {
|
||||
pytest
|
||||
];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/blaze/datashape/releases/tag/${version}";
|
||||
homepage = "https://github.com/ContinuumIO/datashape";
|
||||
description = "A data description language";
|
||||
license = lib.licenses.bsd2;
|
||||
maintainers = with lib.maintainers; [ fridh ];
|
||||
license = licenses.bsd2;
|
||||
maintainers = with maintainers; [ fridh ];
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -1048,7 +1041,7 @@ buildPythonPackage rec {
|
||||
We can see several runtime dependencies, `numpy`, `multipledispatch`, and
|
||||
`python-dateutil`. Furthermore, we have [`nativeCheckInputs`](#var-stdenv-nativeCheckInputs) with `pytest`.
|
||||
`pytest` is a test runner and is only used during the [`checkPhase`](#ssec-check-phase) and is
|
||||
therefore not added to `dependencies`.
|
||||
therefore not added to [`propagatedBuildInputs`](#var-stdenv-propagatedBuildInputs).
|
||||
|
||||
In the previous case we had only dependencies on other Python packages to consider.
|
||||
Occasionally you have also system libraries to consider. E.g., `lxml` provides
|
||||
@@ -1075,7 +1068,7 @@ buildPythonPackage rec {
|
||||
hash = "sha256-s9NiusRxFydHzaNRMjjxFcvWxfi45jGb9ql6eJJyQJk=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
@@ -1085,12 +1078,12 @@ buildPythonPackage rec {
|
||||
libxslt
|
||||
];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/lxml/lxml/releases/tag/lxml-${version}";
|
||||
description = "Pythonic binding for the libxml2 and libxslt libraries";
|
||||
homepage = "https://lxml.de";
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = with lib.maintainers; [ sjourdois ];
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ sjourdois ];
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -1132,7 +1125,7 @@ buildPythonPackage rec {
|
||||
hash = "sha256-9ru2r6kwhUCaskiFoaPNuJCfCVoUL01J40byvRt4kHQ=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
@@ -1143,7 +1136,7 @@ buildPythonPackage rec {
|
||||
fftwLongDouble
|
||||
];
|
||||
|
||||
dependencies = [
|
||||
propagatedBuildInputs = [
|
||||
numpy
|
||||
scipy
|
||||
];
|
||||
@@ -1156,12 +1149,12 @@ buildPythonPackage rec {
|
||||
# Tests cannot import pyfftw. pyfftw works fine though.
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/pyFFTW/pyFFTW/releases/tag/v${version}";
|
||||
description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms";
|
||||
homepage = "http://hgomersall.github.com/pyFFTW";
|
||||
license = with lib.licenses; [ bsd2 bsd3 ];
|
||||
maintainers = with lib.maintainers; [ fridh ];
|
||||
license = with licenses; [ bsd2 bsd3 ];
|
||||
maintainers = with maintainers; [ fridh ];
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -1466,7 +1459,9 @@ mode is activated.
|
||||
|
||||
In the following example, we create a simple environment that has a Python 3.11
|
||||
version of our package in it, as well as its dependencies and other packages we
|
||||
like to have in the environment, all specified with `dependencies`.
|
||||
like to have in the environment, all specified with [`propagatedBuildInputs`](#var-stdenv-propagatedBuildInputs).
|
||||
Indeed, we can just add any package we like to have in our environment to
|
||||
[`propagatedBuildInputs`](#var-stdenv-propagatedBuildInputs).
|
||||
|
||||
```nix
|
||||
with import <nixpkgs> {};
|
||||
@@ -1475,11 +1470,9 @@ with python311Packages;
|
||||
buildPythonPackage rec {
|
||||
name = "mypackage";
|
||||
src = ./path/to/package/source;
|
||||
dependencies = [
|
||||
propagatedBuildInputs = [
|
||||
pytest
|
||||
numpy
|
||||
];
|
||||
propagatedBuildInputs = [
|
||||
pkgs.libsndfile
|
||||
];
|
||||
}
|
||||
@@ -1526,17 +1519,17 @@ buildPythonPackage rec {
|
||||
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
||||
};
|
||||
|
||||
build-system = [
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
|
||||
homepage = "https://github.com/pytoolz/toolz/";
|
||||
description = "List processing tools and functional utilities";
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = with lib.maintainers; [ fridh ];
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ fridh ];
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -1910,8 +1903,8 @@ configure alternatives](#sec-overlays-alternatives-blas-lapack)".
|
||||
|
||||
In a `setup.py` or `setup.cfg` it is common to declare dependencies:
|
||||
|
||||
* `setup_requires` corresponds to `build-system`
|
||||
* `install_requires` corresponds to `dependencies`
|
||||
* `setup_requires` corresponds to [`nativeBuildInputs`](#var-stdenv-nativeBuildInputs)
|
||||
* `install_requires` corresponds to [`propagatedBuildInputs`](#var-stdenv-propagatedBuildInputs)
|
||||
* `tests_require` corresponds to [`nativeCheckInputs`](#var-stdenv-nativeCheckInputs)
|
||||
|
||||
### How to enable interpreter optimizations? {#optimizations}
|
||||
@@ -1935,10 +1928,12 @@ in mypython
|
||||
|
||||
Some packages define optional dependencies for additional features. With
|
||||
`setuptools` this is called `extras_require` and `flit` calls it
|
||||
`extras-require`, while PEP 621 calls these `optional-dependencies`.
|
||||
`extras-require`, while PEP 621 calls these `optional-dependencies`. A
|
||||
method for supporting this is by declaring the extras of a package in its
|
||||
`passthru`, e.g. in case of the package `dask`
|
||||
|
||||
```nix
|
||||
optional-dependencies = {
|
||||
passthru.optional-dependencies = {
|
||||
complete = [ distributed ];
|
||||
};
|
||||
```
|
||||
@@ -1946,13 +1941,11 @@ optional-dependencies = {
|
||||
and letting the package requiring the extra add the list to its dependencies
|
||||
|
||||
```nix
|
||||
dependencies = [
|
||||
propagatedBuildInputs = [
|
||||
...
|
||||
] ++ dask.optional-dependencies.complete;
|
||||
```
|
||||
|
||||
This method is using `passthru`, meaning that changing `optional-dependencies` of a package won't cause it to rebuild.
|
||||
|
||||
Note this method is preferred over adding parameters to builders, as that can
|
||||
result in packages depending on different variants and thereby causing
|
||||
collisions.
|
||||
@@ -2015,10 +2008,6 @@ example of such a situation is when `py.test` is used.
|
||||
|
||||
* Tests that attempt to access `$HOME` can be fixed by using the following
|
||||
work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)`
|
||||
* Compiling with Cython causes tests to fail with a `ModuleNotLoadedError`.
|
||||
This can be fixed with two changes in the derivation: 1) replacing `pytest` with
|
||||
`pytestCheckHook` and 2) adding a `preCheck` containing `cd $out` to run
|
||||
tests within the built output.
|
||||
|
||||
## Contributing {#contributing}
|
||||
|
||||
|
||||
@@ -3,63 +3,72 @@
|
||||
Writing Nix expressions for Qt libraries and applications is largely similar as for other C++ software.
|
||||
This section assumes some knowledge of the latter.
|
||||
|
||||
The major caveat with Qt applications is that Qt uses a plugin system to load additional modules at runtime.
|
||||
In Nixpkgs, we wrap Qt applications to inject environment variables telling Qt where to discover the required plugins and QML modules.
|
||||
|
||||
This effectively makes the runtime dependencies pure and explicit at build-time, at the cost of introducing
|
||||
an extra indirection.
|
||||
The major caveat with Qt applications is that Qt uses a plugin system to load additional modules at runtime,
|
||||
from a list of well-known locations. In Nixpkgs, we patch QtCore to instead use an environment variable,
|
||||
and wrap Qt applications to set it to the right paths. This effectively makes the runtime dependencies
|
||||
pure and explicit at build-time, at the cost of introducing an extra indirection.
|
||||
|
||||
## Nix expression for a Qt package (default.nix) {#qt-default-nix}
|
||||
|
||||
```nix
|
||||
{ stdenv, qt6 }:
|
||||
{ stdenv, lib, qtbase, wrapQtAppsHook }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "myapp";
|
||||
version = "1.0";
|
||||
|
||||
buildInputs = [ qt6.qtbase ];
|
||||
nativeBuildInputs = [ qt6.wrapQtAppsHook ];
|
||||
buildInputs = [ qtbase ];
|
||||
nativeBuildInputs = [ wrapQtAppsHook ];
|
||||
}
|
||||
```
|
||||
|
||||
The same goes for Qt 5 where libraries and tools are under `libsForQt5`.
|
||||
It is important to import Qt modules directly, that is: `qtbase`, `qtdeclarative`, etc. *Do not* import Qt package sets such as `qt5` because the Qt versions of dependencies may not be coherent, causing build and runtime failures.
|
||||
|
||||
Any Qt package should include `wrapQtAppsHook` in `nativeBuildInputs`, or explicitly set `dontWrapQtApps` to bypass generating the wrappers.
|
||||
Additionally all Qt packages must include `wrapQtAppsHook` in `nativeBuildInputs`, or you must explicitly set `dontWrapQtApps`.
|
||||
|
||||
::: {.note}
|
||||
Qt 6 graphical applications should also include `qtwayland` in `buildInputs` on Linux (but not on platforms e.g. Darwin, where `qtwayland` is not available), to ensure the Wayland platform plugin is available.
|
||||
`pkgs.callPackage` does not provide injections for `qtbase` or the like.
|
||||
Instead you want to either use `pkgs.libsForQt5.callPackage`, or `pkgs.qt6Packages.callPackage`, depending on the Qt version you want to use.
|
||||
|
||||
This may become default in the future, see [NixOS/nixpkgs#269674](https://github.com/NixOS/nixpkgs/pull/269674).
|
||||
:::
|
||||
For example (from [here](https://github.com/NixOS/nixpkgs/blob/2f9286912cb215969ece465147badf6d07aa43fe/pkgs/top-level/all-packages.nix#L30106))
|
||||
|
||||
## Packages supporting multiple Qt versions {#qt-versions}
|
||||
```nix
|
||||
zeal-qt5 = libsForQt5.callPackage ../data/documentation/zeal { };
|
||||
zeal-qt6 = qt6Packages.callPackage ../data/documentation/zeal { };
|
||||
zeal = zeal-qt5;
|
||||
```
|
||||
|
||||
If your package is a library that can be built with multiple Qt versions, you may want to take Qt modules as separate arguments (`qtbase`, `qtdeclarative` etc.), and invoke the package from `pkgs/top-level/qt5-packages.nix` or `pkgs/top-level/qt6-packages.nix` using the respective `callPackage` functions.
|
||||
## Locating runtime dependencies {#qt-runtime-dependencies}
|
||||
|
||||
Applications should generally be built with upstream's preferred Qt version.
|
||||
Qt applications must be wrapped to find runtime dependencies.
|
||||
Include `wrapQtAppsHook` in `nativeBuildInputs`:
|
||||
|
||||
## Locating additional runtime dependencies {#qt-runtime-dependencies}
|
||||
```nix
|
||||
{ stdenv, wrapQtAppsHook }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
# ...
|
||||
nativeBuildInputs = [ wrapQtAppsHook ];
|
||||
}
|
||||
```
|
||||
|
||||
Add entries to `qtWrapperArgs` are to modify the wrappers created by
|
||||
`wrapQtAppsHook`:
|
||||
|
||||
```nix
|
||||
{ stdenv, qt6 }:
|
||||
{ stdenv, wrapQtAppsHook }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
# ...
|
||||
nativeBuildInputs = [ qt6.wrapQtAppsHook ];
|
||||
nativeBuildInputs = [ wrapQtAppsHook ];
|
||||
qtWrapperArgs = [ ''--prefix PATH : /path/to/bin'' ];
|
||||
}
|
||||
```
|
||||
|
||||
The entries are passed as arguments to [wrapProgram](#fun-wrapProgram).
|
||||
|
||||
If you need more control over the wrapping process, set `dontWrapQtApps` to disable automatic wrapper generation,
|
||||
and then create wrappers manually in `fixupPhase`, using `wrapQtApp`, which itself is a small wrapper over [wrapProgram](#fun-wrapProgram):
|
||||
|
||||
The `makeWrapper` arguments required for Qt are also exposed in the environment as `$qtWrapperArgs`.
|
||||
Set `dontWrapQtApps` to stop applications from being wrapped automatically.
|
||||
Wrap programs manually with `wrapQtApp`, using the syntax of
|
||||
[wrapProgram](#fun-wrapProgram):
|
||||
|
||||
```nix
|
||||
{ stdenv, lib, wrapQtAppsHook }:
|
||||
|
||||
@@ -35,20 +35,20 @@ rustPlatform.buildRustPackage rec {
|
||||
|
||||
cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts=";
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "A fast line-oriented regex search tool, similar to ag and ack";
|
||||
homepage = "https://github.com/BurntSushi/ripgrep";
|
||||
license = lib.licenses.unlicense;
|
||||
license = licenses.unlicense;
|
||||
maintainers = [];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
`buildRustPackage` requires either a `cargoHash` (preferred) or a
|
||||
`cargoSha256` attribute, computed over all crate sources of this package.
|
||||
`cargoHash` supports [SRI](https://www.w3.org/TR/SRI/) hashes and should be
|
||||
preferred over `cargoSha256` which was used for traditional Nix SHA-256 hashes.
|
||||
For example:
|
||||
`buildRustPackage` requires either the `cargoHash` or the `cargoSha256`
|
||||
attribute which is computed over all crate sources of this package.
|
||||
`cargoSha256` is used for traditional Nix SHA-256 hashes. `cargoHash` should
|
||||
instead be used for [SRI](https://www.w3.org/TR/SRI/) hashes and should be
|
||||
preferred. For example:
|
||||
|
||||
```nix
|
||||
cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8=";
|
||||
@@ -64,18 +64,18 @@ Both types of hashes are permitted when contributing to nixpkgs. The
|
||||
Cargo hash is obtained by inserting a fake checksum into the
|
||||
expression and building the package once. The correct checksum can
|
||||
then be taken from the failed build. A fake hash can be used for
|
||||
`cargoHash` as follows:
|
||||
|
||||
```nix
|
||||
cargoHash = lib.fakeHash;
|
||||
```
|
||||
|
||||
For `cargoSha256` you can use:
|
||||
`cargoSha256` as follows:
|
||||
|
||||
```nix
|
||||
cargoSha256 = lib.fakeSha256;
|
||||
```
|
||||
|
||||
For `cargoHash` you can use:
|
||||
|
||||
```nix
|
||||
cargoHash = lib.fakeHash;
|
||||
```
|
||||
|
||||
Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
|
||||
best practices guide, Rust applications should always commit the `Cargo.lock`
|
||||
file in git to ensure a reproducible build. However, a few packages do not, and
|
||||
@@ -90,7 +90,7 @@ directory into a tar.gz archive.
|
||||
The tarball with vendored dependencies contains a directory with the
|
||||
package's `name`, which is normally composed of `pname` and
|
||||
`version`. This means that the vendored dependencies hash
|
||||
(`cargoHash`/`cargoSha256`) is dependent on the package name and
|
||||
(`cargoSha256`/`cargoHash`) is dependent on the package name and
|
||||
version. The `cargoDepsName` attribute can be used to use another name
|
||||
for the directory of vendored dependencies. For example, the hash can
|
||||
be made invariant to the version by setting `cargoDepsName` to
|
||||
@@ -115,7 +115,7 @@ rustPlatform.buildRustPackage rec {
|
||||
|
||||
### Importing a `Cargo.lock` file {#importing-a-cargo.lock-file}
|
||||
|
||||
Using a vendored hash (`cargoHash`/`cargoSha256`) is tedious when using
|
||||
Using `cargoSha256` or `cargoHash` is tedious when using
|
||||
`buildRustPackage` within a project, since it requires that the hash
|
||||
is updated after every change to `Cargo.lock`. Therefore,
|
||||
`buildRustPackage` also supports vendoring dependencies directly from
|
||||
@@ -651,66 +651,6 @@ buildPythonPackage rec {
|
||||
}
|
||||
```
|
||||
|
||||
#### Rust package built with `meson` {#rust-package-built-with-meson}
|
||||
|
||||
Some projects, especially GNOME applications, are built with the Meson Build System instead of calling Cargo directly. Using `rustPlatform.buildRustPackage` may successfully build the main program, but related files will be missing. Instead, you need to set up Cargo dependencies with `fetchCargoTarball` and `cargoSetupHook` and leave the rest to Meson. `rust` and `cargo` are still needed in `nativeBuildInputs` for Meson to use.
|
||||
|
||||
```nix
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitLab
|
||||
, meson
|
||||
, ninja
|
||||
, pkg-config
|
||||
, rustPlatform
|
||||
, rustc
|
||||
, cargo
|
||||
, wrapGAppsHook4
|
||||
, blueprint-compiler
|
||||
, libadwaita
|
||||
, libsecret
|
||||
, tracker
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "health";
|
||||
version = "0.95.0";
|
||||
|
||||
src = fetchFromGitLab {
|
||||
domain = "gitlab.gnome.org";
|
||||
owner = "World";
|
||||
repo = "health";
|
||||
rev = version;
|
||||
hash = "sha256-PrNPprSS98yN8b8yw2G6hzTSaoE65VbsM3q7FVB4mds=";
|
||||
};
|
||||
|
||||
cargoDeps = rustPlatform.fetchCargoTarball {
|
||||
inherit src;
|
||||
name = "${pname}-${version}";
|
||||
hash = "sha256-8fa3fa+sFi5H+49B5sr2vYPkp9C9s6CcE0zv4xB8gww=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
rustPlatform.cargoSetupHook
|
||||
rustc
|
||||
cargo
|
||||
wrapGAppsHook4
|
||||
blueprint-compiler
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
libadwaita
|
||||
libsecret
|
||||
tracker
|
||||
];
|
||||
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
## `buildRustCrate`: Compiling Rust crates using Nix instead of Cargo {#compiling-rust-crates-using-nix-instead-of-cargo}
|
||||
|
||||
### Simple operation {#simple-operation}
|
||||
@@ -761,7 +701,7 @@ with import <nixpkgs> {};
|
||||
hello = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "1.0") {
|
||||
postPatch = ''
|
||||
substituteInPlace lib/zoneinfo.rs \
|
||||
--replace-fail "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
|
||||
--replace "/usr/share/zoneinfo" "${tzdata}/share/zoneinfo"
|
||||
'';
|
||||
};
|
||||
};
|
||||
@@ -963,8 +903,8 @@ with import <nixpkgs>
|
||||
};
|
||||
let
|
||||
rustPlatform = makeRustPlatform {
|
||||
cargo = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
||||
rustc = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
||||
cargo = rust-bin.stable.latest.minimal;
|
||||
rustc = rust-bin.stable.latest.minimal;
|
||||
};
|
||||
in
|
||||
|
||||
@@ -983,11 +923,11 @@ rustPlatform.buildRustPackage rec {
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "A fast line-oriented regex search tool, similar to ag and ack";
|
||||
homepage = "https://github.com/BurntSushi/ripgrep";
|
||||
license = with lib.licenses; [ mit unlicense ];
|
||||
maintainers = with lib.maintainers; [];
|
||||
license = with licenses; [ mit unlicense ];
|
||||
maintainers = with maintainers; [];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -181,11 +181,11 @@ let
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "A LaTeX2e class for overhead transparencies";
|
||||
license = lib.licenses.unfreeRedistributable;
|
||||
maintainers = with lib.maintainers; [ veprbl ];
|
||||
platforms = lib.platforms.all;
|
||||
license = licenses.unfreeRedistributable;
|
||||
maintainers = with maintainers; [ veprbl ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -314,11 +314,5 @@
|
||||
"systemd-veritysetup@.service(8)": "https://www.freedesktop.org/software/systemd/man/systemd-veritysetup@.service.html",
|
||||
"systemd-volatile-root(8)": "https://www.freedesktop.org/software/systemd/man/systemd-volatile-root.html",
|
||||
"systemd-xdg-autostart-generator(8)": "https://www.freedesktop.org/software/systemd/man/systemd-xdg-autostart-generator.html",
|
||||
"udevadm(8)": "https://www.freedesktop.org/software/systemd/man/udevadm.html",
|
||||
"passwd(5)": "https://man.archlinux.org/man/passwd.5",
|
||||
"group(5)": "https://man.archlinux.org/man/group.5",
|
||||
"login.defs(5)": "https://man.archlinux.org/man/login.defs.5",
|
||||
"unshare(1)": "https://man.archlinux.org/man/unshare.1.en",
|
||||
"nix-shell(1)": "https://nixos.org/manual/nix/stable/command-ref/nix-shell.html",
|
||||
"mksquashfs(1)": "https://man.archlinux.org/man/extra/squashfs-tools/mksquashfs.1.en"
|
||||
"udevadm(8)": "https://www.freedesktop.org/software/systemd/man/udevadm.html"
|
||||
}
|
||||
|
||||
22
doc/overrides.css
Normal file
22
doc/overrides.css
Normal file
@@ -0,0 +1,22 @@
|
||||
.docbook .xref img[src^=images\/callouts\/],
|
||||
.screen img,
|
||||
.programlisting img,
|
||||
.literallayout img,
|
||||
.synopsis img {
|
||||
width: 1em;
|
||||
}
|
||||
|
||||
.calloutlist img {
|
||||
width: 1.5em;
|
||||
}
|
||||
|
||||
.prompt,
|
||||
.screen img,
|
||||
.programlisting img,
|
||||
.literallayout img,
|
||||
.synopsis img {
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
@@ -1,12 +1,5 @@
|
||||
# darwin.linux-builder {#sec-darwin-builder}
|
||||
|
||||
:::{.warning}
|
||||
By default, `darwin.linux-builder` uses a publicly-known private SSH **host key** (this is different from the SSH key used by the user that connects to the builder).
|
||||
|
||||
Given the intended use case for it (a Linux builder that runs **on the same machine**), this shouldn't be an issue.
|
||||
However, if you plan to deviate from this use case in any way (e.g. by exposing this builder to remote machines), you should understand the security implications of doing so and take any appropriate measures.
|
||||
:::
|
||||
|
||||
`darwin.linux-builder` provides a way to bootstrap a Linux remote builder on a macOS machine.
|
||||
|
||||
This requires macOS version 12.4 or later.
|
||||
@@ -104,9 +97,8 @@ $ sudo launchctl kickstart -k system/org.nixos.nix-daemon
|
||||
{ virtualisation = {
|
||||
host.pkgs = pkgs;
|
||||
darwin-builder.workingDirectory = "/var/lib/darwin-builder";
|
||||
darwin-builder.hostPort = 22;
|
||||
};
|
||||
}
|
||||
};
|
||||
];
|
||||
};
|
||||
in {
|
||||
@@ -118,9 +110,7 @@ $ sudo launchctl kickstart -k system/org.nixos.nix-daemon
|
||||
{
|
||||
nix.distributedBuilds = true;
|
||||
nix.buildMachines = [{
|
||||
hostName = "localhost";
|
||||
sshUser = "builder";
|
||||
sshKey = "/etc/nix/builder_ed25519";
|
||||
hostName = "ssh://builder@localhost";
|
||||
system = linuxSystem;
|
||||
maxJobs = 4;
|
||||
supportedFeatures = [ "kvm" "benchmark" "big-parallel" ];
|
||||
|
||||
@@ -27,18 +27,18 @@ With these expressions the Nix package manager can build binary packages.
|
||||
Packages, including the Nix packages collection, are distributed through
|
||||
[channels](https://nixos.org/nix/manual/#sec-channels). The collection is
|
||||
distributed for users of Nix on non-NixOS distributions through the channel
|
||||
`nixpkgs-unstable`. Users of NixOS generally use one of the `nixos-*` channels,
|
||||
e.g. `nixos-22.11`, which includes all packages and modules for the stable NixOS
|
||||
`nixpkgs`. Users of NixOS generally use one of the `nixos-*` channels, e.g.
|
||||
`nixos-22.11`, which includes all packages and modules for the stable NixOS
|
||||
22.11. Stable NixOS releases are generally only given
|
||||
security updates. More up to date packages and modules are available via the
|
||||
`nixos-unstable` channel.
|
||||
|
||||
Both `nixos-unstable` and `nixpkgs-unstable` follow the `master` branch of the
|
||||
nixpkgs repository, although both do lag the `master` branch by generally
|
||||
Both `nixos-unstable` and `nixpkgs` follow the `master` branch of the Nixpkgs
|
||||
repository, although both do lag the `master` branch by generally
|
||||
[a couple of days](https://status.nixos.org/). Updates to a channel are
|
||||
distributed as soon as all tests for that channel pass, e.g.
|
||||
[this table](https://hydra.nixos.org/job/nixpkgs/trunk/unstable#tabs-constituents)
|
||||
shows the status of tests for the `nixpkgs-unstable` channel.
|
||||
shows the status of tests for the `nixpkgs` channel.
|
||||
|
||||
The tests are conducted by a cluster called [Hydra](https://nixos.org/hydra/),
|
||||
which also builds binary packages from the Nix expressions in Nixpkgs for
|
||||
@@ -46,5 +46,5 @@ which also builds binary packages from the Nix expressions in Nixpkgs for
|
||||
The binaries are made available via a [binary cache](https://cache.nixos.org).
|
||||
|
||||
The current Nix expressions of the channels are available in the
|
||||
[nixpkgs repository](https://github.com/NixOS/nixpkgs) in branches
|
||||
[`nixpkgs`](https://github.com/NixOS/nixpkgs) repository in branches
|
||||
that correspond to the channel names (e.g. `nixos-22.11-small`).
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
Nix packages can declare *meta-attributes* that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a `meta` declaration like this:
|
||||
|
||||
```nix
|
||||
meta = {
|
||||
meta = with lib; {
|
||||
description = "A program that produces a familiar, friendly greeting";
|
||||
longDescription = ''
|
||||
GNU Hello is a program that prints "Hello, world!" when you run it.
|
||||
It is fully customizable.
|
||||
'';
|
||||
homepage = "https://www.gnu.org/software/hello/manual/";
|
||||
license = lib.licenses.gpl3Plus;
|
||||
maintainers = with lib.maintainers; [ eelco ];
|
||||
platforms = lib.platforms.all;
|
||||
license = licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ eelco ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ Some common issues when packaging software for Darwin:
|
||||
# ...
|
||||
prePatch = ''
|
||||
substituteInPlace Makefile \
|
||||
--replace-fail '/usr/bin/xcrun clang' clang
|
||||
--replace '/usr/bin/xcrun clang' clang
|
||||
'';
|
||||
}
|
||||
```
|
||||
|
||||
@@ -230,9 +230,9 @@ stdenv.mkDerivation rec {
|
||||
|
||||
postInstall = ''
|
||||
substituteInPlace $out/bin/solo5-virtio-mkimage \
|
||||
--replace-fail "/usr/lib/syslinux" "${syslinux}/share/syslinux" \
|
||||
--replace-fail "/usr/share/syslinux" "${syslinux}/share/syslinux" \
|
||||
--replace-fail "cp " "cp --no-preserve=mode "
|
||||
--replace "/usr/lib/syslinux" "${syslinux}/share/syslinux" \
|
||||
--replace "/usr/share/syslinux" "${syslinux}/share/syslinux" \
|
||||
--replace "cp " "cp --no-preserve=mode "
|
||||
|
||||
wrapProgram $out/bin/solo5-virtio-mkimage \
|
||||
--prefix PATH : ${lib.makeBinPath [ dosfstools mtools parted syslinux ]}
|
||||
@@ -1253,20 +1253,9 @@ postInstall = ''
|
||||
|
||||
Performs string substitution on the contents of \<infile\>, writing the result to \<outfile\>. The substitutions in \<subs\> are of the following form:
|
||||
|
||||
#### `--replace-fail` \<s1\> \<s2\> {#fun-substitute-replace-fail}
|
||||
#### `--replace` \<s1\> \<s2\> {#fun-substitute-replace}
|
||||
|
||||
Replace every occurrence of the string \<s1\> by \<s2\>.
|
||||
Will error if no change is made.
|
||||
|
||||
#### `--replace-warn` \<s1\> \<s2\> {#fun-substitute-replace-warn}
|
||||
|
||||
Replace every occurrence of the string \<s1\> by \<s2\>.
|
||||
Will print a warning if no change is made.
|
||||
|
||||
#### `--replace-quiet` \<s1\> \<s2\> {#fun-substitute-replace-quiet}
|
||||
|
||||
Replace every occurrence of the string \<s1\> by \<s2\>.
|
||||
Will do nothing if no change can be made.
|
||||
|
||||
#### `--subst-var` \<varName\> {#fun-substitute-subst-var}
|
||||
|
||||
@@ -1280,8 +1269,8 @@ Example:
|
||||
|
||||
```shell
|
||||
substitute ./foo.in ./foo.out \
|
||||
--replace-fail /usr/bin/bar $bar/bin/bar \
|
||||
--replace-fail "a string containing spaces" "some other text" \
|
||||
--replace /usr/bin/bar $bar/bin/bar \
|
||||
--replace "a string containing spaces" "some other text" \
|
||||
--subst-var someVar
|
||||
```
|
||||
|
||||
|
||||
623
doc/style.css
623
doc/style.css
@@ -1,416 +1,291 @@
|
||||
html {
|
||||
line-height: 1.15;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
/* Copied from http://bakefile.sourceforge.net/, which appears
|
||||
licensed under the GNU GPL. */
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.book {
|
||||
margin: auto;
|
||||
width: 100%;
|
||||
}
|
||||
/***************************************************************************
|
||||
Basic headers and text:
|
||||
***************************************************************************/
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.book {
|
||||
max-width: 46rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 992px) {
|
||||
.book {
|
||||
max-width: 60rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1200px) {
|
||||
.book {
|
||||
max-width: 73rem;
|
||||
}
|
||||
}
|
||||
|
||||
.book .list-of-examples {
|
||||
display: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
hr {
|
||||
box-sizing: content-box;
|
||||
height: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace;
|
||||
body
|
||||
{
|
||||
font-family: "Nimbus Sans L", sans-serif;
|
||||
font-size: 1em;
|
||||
background: white;
|
||||
margin: 2em 1em 2em 1em;
|
||||
}
|
||||
|
||||
a {
|
||||
background-color: transparent;
|
||||
h1, h2, h3, h4
|
||||
{
|
||||
color: #005aa0;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: monospace, monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
pre {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-size: 100%;
|
||||
line-height: 1.77777778;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 4000px) {
|
||||
html {
|
||||
background: #000;
|
||||
}
|
||||
|
||||
html body {
|
||||
margin: auto;
|
||||
max-width: 250rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 320px) {
|
||||
html {
|
||||
font-size: calc(16 / 320 * 100vw);
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 1rem;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-weight: 300;
|
||||
color: #000000;
|
||||
background-color: #ffffff;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 767.9px) {
|
||||
body {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid;
|
||||
color: #405d99;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding: 0;
|
||||
margin-top: 0;
|
||||
margin-right: 0;
|
||||
margin-bottom: 1rem;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
thead th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: 800;
|
||||
line-height: 110%;
|
||||
h1 /* title */
|
||||
{
|
||||
font-size: 200%;
|
||||
margin-bottom: 1rem;
|
||||
color: #6586c8;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-weight: 800;
|
||||
line-height: 110%;
|
||||
font-size: 170%;
|
||||
margin-bottom: 0.625rem;
|
||||
color: #6586c8;
|
||||
h2 /* chapters, appendices, subtitle */
|
||||
{
|
||||
font-size: 180%;
|
||||
}
|
||||
|
||||
h2:not(:first-child) {
|
||||
margin-top: 1rem;
|
||||
div.book
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-weight: 800;
|
||||
line-height: 110%;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 150%;
|
||||
color: #6586c8;
|
||||
div.book > div
|
||||
{
|
||||
/*
|
||||
* based on https://medium.com/@zkareemz/golden-ratio-62b3b6d4282a
|
||||
* we do 70 characters per line to fit code listings better
|
||||
* 70 * (font-size / 1.618)
|
||||
* expression for emacs:
|
||||
* (* 70 (/ 1 1.618))
|
||||
*/
|
||||
max-width: 43.2em;
|
||||
text-align: left;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.note h3,
|
||||
.tip h3,
|
||||
.warning h3,
|
||||
.caution h3,
|
||||
.important h3 {
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-weight: 800;
|
||||
line-height: 110%;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 140%;
|
||||
color: #6586c8;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-weight: 800;
|
||||
line-height: 110%;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 130%;
|
||||
color: #6a6a6a;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-weight: 800;
|
||||
line-height: 110%;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 120%
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
dt>*:first-child,
|
||||
dd>*:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
dt>*:last-child,
|
||||
dd>*:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
pre,
|
||||
code {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
code {
|
||||
color: #ff8657;
|
||||
background: #f4f4f4;
|
||||
display: inline-block;
|
||||
padding: 0 0.5rem;
|
||||
border: 1px solid #d8d8d8;
|
||||
border-radius: 0.5rem;
|
||||
line-height: 1.57777778;
|
||||
}
|
||||
|
||||
div.book .programlisting,
|
||||
div.appendix .programlisting {
|
||||
border-radius: 0.5rem;
|
||||
padding: 1rem;
|
||||
overflow: auto;
|
||||
background: #f2f8fd;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
div.book .note,
|
||||
div.book .tip,
|
||||
div.book .warning,
|
||||
div.book .caution,
|
||||
div.book .important,
|
||||
div.appendix .note,
|
||||
div.appendix .tip,
|
||||
div.appendix .warning,
|
||||
div.appendix .caution,
|
||||
div.appendix .important {
|
||||
margin-bottom: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
padding: 1.5rem;
|
||||
overflow: auto;
|
||||
background: #f4f4f4;
|
||||
}
|
||||
|
||||
div.book .note>.title,
|
||||
div.book .tip>.title,
|
||||
div.book .warning>.title,
|
||||
div.book .caution>.title,
|
||||
div.book .important>.title,
|
||||
div.appendix .note>.title,
|
||||
div.appendix .tip>.title,
|
||||
div.appendix .warning>.title,
|
||||
div.appendix .caution>.title,
|
||||
div.appendix .important>.title {
|
||||
font-weight: 800;
|
||||
/* font-family: 'Overpass', serif; */
|
||||
line-height: 110%;
|
||||
margin-bottom: 1rem;
|
||||
color: inherit;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.book .note> :first-child,
|
||||
div.book .tip> :first-child,
|
||||
div.book .warning> :first-child,
|
||||
div.book .caution> :first-child,
|
||||
div.book .important> :first-child,
|
||||
div.appendix .note> :first-child,
|
||||
div.appendix .tip> :first-child,
|
||||
div.appendix .warning> :first-child,
|
||||
div.appendix .caution> :first-child,
|
||||
div.appendix .important> :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.book .note> :last-child,
|
||||
div.book .tip> :last-child,
|
||||
div.book .warning> :last-child,
|
||||
div.book .caution> :last-child,
|
||||
div.book .important> :last-child,
|
||||
div.appendix .note> :last-child,
|
||||
div.appendix .tip> :last-child,
|
||||
div.appendix .warning> :last-child,
|
||||
div.appendix .caution> :last-child,
|
||||
div.appendix .important> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.book .note,
|
||||
div.book .tip,
|
||||
div.appendix .note,
|
||||
div.appendix .tip {
|
||||
color: #5277c3;
|
||||
background: #f2f8fd;
|
||||
}
|
||||
|
||||
div.book .warning,
|
||||
div.book .caution,
|
||||
div.appendix .warning,
|
||||
div.appendix .caution {
|
||||
color: #cc3900;
|
||||
background-color: #fff5e1;
|
||||
}
|
||||
|
||||
div.book .section,
|
||||
div.appendix .section {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
div.book div.example,
|
||||
div.appendix div.example {
|
||||
/* Extra space between chapters, appendices. */
|
||||
div.chapter > div.titlepage h2, div.appendix > div.titlepage h2
|
||||
{
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
div.book br.example-break,
|
||||
div.appendix br.example-break {
|
||||
display: none;
|
||||
div.section > div.titlepage h2 /* sections */
|
||||
{
|
||||
font-size: 150%;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
div.book div.footnotes>hr,
|
||||
div.appendix div.footnotes>hr {
|
||||
border-color: #d8d8d8;
|
||||
h3 /* subsections */
|
||||
{
|
||||
font-size: 125%;
|
||||
}
|
||||
|
||||
div.book div.footnotes>br,
|
||||
div.appendix div.footnotes>br {
|
||||
display: none;
|
||||
div.simplesect h2
|
||||
{
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
div.book dt,
|
||||
div.appendix dt {
|
||||
margin-top: 1em;
|
||||
div.appendix h3
|
||||
{
|
||||
font-size: 150%;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
div.book .toc dt,
|
||||
div.appendix .toc dt {
|
||||
margin-top: 0;
|
||||
div.refnamediv h2, div.refsynopsisdiv h2, div.refsection h2 /* refentry parts */
|
||||
{
|
||||
margin-top: 1.4em;
|
||||
font-size: 125%;
|
||||
}
|
||||
|
||||
div.book .list-of-examples dt,
|
||||
div.appendix .list-of-examples dt {
|
||||
margin-top: 0;
|
||||
div.refsection h3
|
||||
{
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
div.book code,
|
||||
div.appendix code {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background-color: inherit;
|
||||
color: inherit;
|
||||
font-size: 100%;
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
hyphens: none;
|
||||
|
||||
/***************************************************************************
|
||||
Examples:
|
||||
***************************************************************************/
|
||||
|
||||
div.example
|
||||
{
|
||||
border: 1px solid #b0b0b0;
|
||||
padding: 6px 6px;
|
||||
margin-left: 1.5em;
|
||||
margin-right: 1.5em;
|
||||
background: #f4f4f8;
|
||||
border-radius: 0.4em;
|
||||
box-shadow: 0.4em 0.4em 0.5em #e0e0e0;
|
||||
}
|
||||
|
||||
div.book div.toc,
|
||||
div.appendix div.toc {
|
||||
margin-bottom: 3em;
|
||||
border-bottom: 0.0625rem solid #d8d8d8;
|
||||
div.example p.title
|
||||
{
|
||||
margin-top: 0em;
|
||||
}
|
||||
|
||||
div.book div.toc dd,
|
||||
div.appendix div.toc dd {
|
||||
margin-left: 2em;
|
||||
div.example pre
|
||||
{
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
div.book span.command,
|
||||
div.appendix span.command {
|
||||
|
||||
/***************************************************************************
|
||||
Screen dumps:
|
||||
***************************************************************************/
|
||||
|
||||
pre.screen, pre.programlisting
|
||||
{
|
||||
border: 1px solid #b0b0b0;
|
||||
padding: 3px 3px;
|
||||
margin-left: 0.5em;
|
||||
margin-right: 0.5em;
|
||||
|
||||
background: #f4f4f8;
|
||||
font-family: monospace;
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
hyphens: none;
|
||||
border-radius: 0.4em;
|
||||
box-shadow: 0.4em 0.4em 0.5em #e0e0e0;
|
||||
}
|
||||
|
||||
div.book .informaltable th,
|
||||
div.book .informaltable td,
|
||||
div.appendix .informaltable th,
|
||||
div.appendix .informaltable td {
|
||||
padding: 0.5rem;
|
||||
div.example pre.programlisting
|
||||
{
|
||||
border: 0px;
|
||||
padding: 0 0;
|
||||
margin: 0 0 0 0;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
Notes, warnings etc:
|
||||
***************************************************************************/
|
||||
|
||||
.note, .warning
|
||||
{
|
||||
border: 1px solid #b0b0b0;
|
||||
padding: 3px 3px;
|
||||
margin-left: 1.5em;
|
||||
margin-right: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
padding: 0.3em 0.3em 0.3em 0.3em;
|
||||
background: #fffff5;
|
||||
border-radius: 0.4em;
|
||||
box-shadow: 0.4em 0.4em 0.5em #e0e0e0;
|
||||
}
|
||||
|
||||
div.note, div.warning
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.note h3, div.warning h3
|
||||
{
|
||||
color: red;
|
||||
font-size: 100%;
|
||||
padding-right: 0.5em;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.note p, div.warning p
|
||||
{
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
div.note h3 + p, div.warning h3 + p
|
||||
{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
div.note h3
|
||||
{
|
||||
color: blue;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
div.navfooter *
|
||||
{
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Links colors and highlighting:
|
||||
***************************************************************************/
|
||||
|
||||
a { text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
a:link { color: #0048b3; }
|
||||
a:visited { color: #002a6a; }
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Table of contents:
|
||||
***************************************************************************/
|
||||
|
||||
div.toc
|
||||
{
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
div.toc dl
|
||||
{
|
||||
margin-top: 0em;
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
Special elements:
|
||||
***************************************************************************/
|
||||
|
||||
tt, code
|
||||
{
|
||||
color: #400000;
|
||||
}
|
||||
|
||||
.term
|
||||
{
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
div.variablelist dd p, div.glosslist dd p
|
||||
{
|
||||
margin-top: 0em;
|
||||
}
|
||||
|
||||
div.variablelist dd, div.glosslist dd
|
||||
{
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
div.glosslist dt
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.varname
|
||||
{
|
||||
color: #400000;
|
||||
}
|
||||
|
||||
span.command strong
|
||||
{
|
||||
font-weight: normal;
|
||||
color: #400000;
|
||||
}
|
||||
|
||||
div.calloutlist table
|
||||
{
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
table
|
||||
{
|
||||
border-collapse: collapse;
|
||||
box-shadow: 0.4em 0.4em 0.5em #e0e0e0;
|
||||
}
|
||||
|
||||
table.simplelist
|
||||
{
|
||||
text-align: left;
|
||||
color: #005aa0;
|
||||
border: 0;
|
||||
padding: 5px;
|
||||
background: #fffff5;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
box-shadow: none;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
div.navheader table, div.navfooter table {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
div.affiliation
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
14
flake.nix
14
flake.nix
@@ -27,19 +27,7 @@
|
||||
# We set it to null, to remove the "legacy" entrypoint's
|
||||
# non-hermetic default.
|
||||
system = null;
|
||||
|
||||
modules = args.modules ++ [
|
||||
# This module is injected here since it exposes the nixpkgs self-path in as
|
||||
# constrained of contexts as possible to avoid more things depending on it and
|
||||
# introducing unnecessary potential fragility to changes in flakes itself.
|
||||
#
|
||||
# See: failed attempt to make pkgs.path not copy when using flakes:
|
||||
# https://github.com/NixOS/nixpkgs/pull/153594#issuecomment-1023287913
|
||||
({ config, pkgs, lib, ... }: {
|
||||
config.nixpkgs.flake.source = self.outPath;
|
||||
})
|
||||
];
|
||||
} // builtins.removeAttrs args [ "modules" ]
|
||||
} // args
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
24.05
|
||||
146
lib/asserts.nix
146
lib/asserts.nix
@@ -2,87 +2,47 @@
|
||||
|
||||
rec {
|
||||
|
||||
/**
|
||||
Throw if pred is false, else return pred.
|
||||
Intended to be used to augment asserts with helpful error messages.
|
||||
/* Throw if pred is false, else return pred.
|
||||
Intended to be used to augment asserts with helpful error messages.
|
||||
|
||||
# Inputs
|
||||
Example:
|
||||
assertMsg false "nope"
|
||||
stderr> error: nope
|
||||
|
||||
`pred`
|
||||
assert assertMsg ("foo" == "bar") "foo is not bar, silly"; ""
|
||||
stderr> error: foo is not bar, silly
|
||||
|
||||
: Predicate that needs to succeed, otherwise `msg` is thrown
|
||||
|
||||
`msg`
|
||||
|
||||
: Message to throw in case `pred` fails
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
assertMsg :: Bool -> String -> Bool
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `lib.asserts.assertMsg` usage example
|
||||
|
||||
```nix
|
||||
assertMsg false "nope"
|
||||
stderr> error: nope
|
||||
assert assertMsg ("foo" == "bar") "foo is not bar, silly"; ""
|
||||
stderr> error: foo is not bar, silly
|
||||
```
|
||||
|
||||
:::
|
||||
Type:
|
||||
assertMsg :: Bool -> String -> Bool
|
||||
*/
|
||||
# TODO(Profpatsch): add tests that check stderr
|
||||
assertMsg =
|
||||
# Predicate that needs to succeed, otherwise `msg` is thrown
|
||||
pred:
|
||||
# Message to throw in case `pred` fails
|
||||
msg:
|
||||
pred || builtins.throw msg;
|
||||
|
||||
/**
|
||||
Specialized `assertMsg` for checking if `val` is one of the elements
|
||||
of the list `xs`. Useful for checking enums.
|
||||
/* Specialized `assertMsg` for checking if `val` is one of the elements
|
||||
of the list `xs`. Useful for checking enums.
|
||||
|
||||
# Inputs
|
||||
Example:
|
||||
let sslLibrary = "libressl";
|
||||
in assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ]
|
||||
stderr> error: sslLibrary must be one of [
|
||||
stderr> "openssl"
|
||||
stderr> "bearssl"
|
||||
stderr> ], but is: "libressl"
|
||||
|
||||
`name`
|
||||
|
||||
: The name of the variable the user entered `val` into, for inclusion in the error message
|
||||
|
||||
`val`
|
||||
|
||||
: The value of what the user provided, to be compared against the values in `xs`
|
||||
|
||||
`xs`
|
||||
|
||||
: The list of valid values
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `lib.asserts.assertOneOf` usage example
|
||||
|
||||
```nix
|
||||
let sslLibrary = "libressl";
|
||||
in assertOneOf "sslLibrary" sslLibrary [ "openssl" "bearssl" ]
|
||||
stderr> error: sslLibrary must be one of [
|
||||
stderr> "openssl"
|
||||
stderr> "bearssl"
|
||||
stderr> ], but is: "libressl"
|
||||
```
|
||||
|
||||
:::
|
||||
Type:
|
||||
assertOneOf :: String -> ComparableVal -> List ComparableVal -> Bool
|
||||
*/
|
||||
assertOneOf =
|
||||
# The name of the variable the user entered `val` into, for inclusion in the error message
|
||||
name:
|
||||
# The value of what the user provided, to be compared against the values in `xs`
|
||||
val:
|
||||
# The list of valid values
|
||||
xs:
|
||||
assertMsg
|
||||
(lib.elem val xs)
|
||||
@@ -90,51 +50,29 @@ rec {
|
||||
lib.generators.toPretty {} xs}, but is: ${
|
||||
lib.generators.toPretty {} val}";
|
||||
|
||||
/**
|
||||
Specialized `assertMsg` for checking if every one of `vals` is one of the elements
|
||||
of the list `xs`. Useful for checking lists of supported attributes.
|
||||
/* Specialized `assertMsg` for checking if every one of `vals` is one of the elements
|
||||
of the list `xs`. Useful for checking lists of supported attributes.
|
||||
|
||||
# Inputs
|
||||
Example:
|
||||
let sslLibraries = [ "libressl" "bearssl" ];
|
||||
in assertEachOneOf "sslLibraries" sslLibraries [ "openssl" "bearssl" ]
|
||||
stderr> error: each element in sslLibraries must be one of [
|
||||
stderr> "openssl"
|
||||
stderr> "bearssl"
|
||||
stderr> ], but is: [
|
||||
stderr> "libressl"
|
||||
stderr> "bearssl"
|
||||
stderr> ]
|
||||
|
||||
`name`
|
||||
|
||||
: The name of the variable the user entered `val` into, for inclusion in the error message
|
||||
|
||||
`vals`
|
||||
|
||||
: The list of values of what the user provided, to be compared against the values in `xs`
|
||||
|
||||
`xs`
|
||||
|
||||
: The list of valid values
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
assertEachOneOf :: String -> List ComparableVal -> List ComparableVal -> Bool
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `lib.asserts.assertEachOneOf` usage example
|
||||
|
||||
```nix
|
||||
let sslLibraries = [ "libressl" "bearssl" ];
|
||||
in assertEachOneOf "sslLibraries" sslLibraries [ "openssl" "bearssl" ]
|
||||
stderr> error: each element in sslLibraries must be one of [
|
||||
stderr> "openssl"
|
||||
stderr> "bearssl"
|
||||
stderr> ], but is: [
|
||||
stderr> "libressl"
|
||||
stderr> "bearssl"
|
||||
stderr> ]
|
||||
```
|
||||
|
||||
:::
|
||||
Type:
|
||||
assertEachOneOf :: String -> List ComparableVal -> List ComparableVal -> Bool
|
||||
*/
|
||||
assertEachOneOf =
|
||||
# The name of the variable the user entered `val` into, for inclusion in the error message
|
||||
name:
|
||||
# The list of values of what the user provided, to be compared against the values in `xs`
|
||||
vals:
|
||||
# The list of valid values
|
||||
xs:
|
||||
assertMsg
|
||||
(lib.all (val: lib.elem val xs) vals)
|
||||
|
||||
1939
lib/attrsets.nix
1939
lib/attrsets.nix
File diff suppressed because it is too large
Load Diff
87
lib/cli.nix
87
lib/cli.nix
@@ -1,64 +1,43 @@
|
||||
{ lib }:
|
||||
|
||||
rec {
|
||||
/**
|
||||
Automatically convert an attribute set to command-line options.
|
||||
/* Automatically convert an attribute set to command-line options.
|
||||
|
||||
This helps protect against malformed command lines and also to reduce
|
||||
boilerplate related to command-line construction for simple use cases.
|
||||
This helps protect against malformed command lines and also to reduce
|
||||
boilerplate related to command-line construction for simple use cases.
|
||||
|
||||
`toGNUCommandLine` returns a list of nix strings.
|
||||
`toGNUCommandLine` returns a list of nix strings.
|
||||
`toGNUCommandLineShell` returns an escaped shell string.
|
||||
|
||||
`toGNUCommandLineShell` returns an escaped shell string.
|
||||
Example:
|
||||
cli.toGNUCommandLine {} {
|
||||
data = builtins.toJSON { id = 0; };
|
||||
X = "PUT";
|
||||
retry = 3;
|
||||
retry-delay = null;
|
||||
url = [ "https://example.com/foo" "https://example.com/bar" ];
|
||||
silent = false;
|
||||
verbose = true;
|
||||
}
|
||||
=> [
|
||||
"-X" "PUT"
|
||||
"--data" "{\"id\":0}"
|
||||
"--retry" "3"
|
||||
"--url" "https://example.com/foo"
|
||||
"--url" "https://example.com/bar"
|
||||
"--verbose"
|
||||
]
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`options`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`attrs`
|
||||
|
||||
: 2\. Function argument
|
||||
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `lib.cli.toGNUCommandLineShell` usage example
|
||||
|
||||
```nix
|
||||
cli.toGNUCommandLine {} {
|
||||
data = builtins.toJSON { id = 0; };
|
||||
X = "PUT";
|
||||
retry = 3;
|
||||
retry-delay = null;
|
||||
url = [ "https://example.com/foo" "https://example.com/bar" ];
|
||||
silent = false;
|
||||
verbose = true;
|
||||
}
|
||||
=> [
|
||||
"-X" "PUT"
|
||||
"--data" "{\"id\":0}"
|
||||
"--retry" "3"
|
||||
"--url" "https://example.com/foo"
|
||||
"--url" "https://example.com/bar"
|
||||
"--verbose"
|
||||
]
|
||||
|
||||
cli.toGNUCommandLineShell {} {
|
||||
data = builtins.toJSON { id = 0; };
|
||||
X = "PUT";
|
||||
retry = 3;
|
||||
retry-delay = null;
|
||||
url = [ "https://example.com/foo" "https://example.com/bar" ];
|
||||
silent = false;
|
||||
verbose = true;
|
||||
}
|
||||
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
|
||||
```
|
||||
|
||||
:::
|
||||
cli.toGNUCommandLineShell {} {
|
||||
data = builtins.toJSON { id = 0; };
|
||||
X = "PUT";
|
||||
retry = 3;
|
||||
retry-delay = null;
|
||||
url = [ "https://example.com/foo" "https://example.com/bar" ];
|
||||
silent = false;
|
||||
verbose = true;
|
||||
}
|
||||
=> "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
|
||||
*/
|
||||
toGNUCommandLineShell =
|
||||
options: attrs: lib.escapeShellArgs (toGNUCommandLine options attrs);
|
||||
|
||||
@@ -15,64 +15,42 @@ in
|
||||
rec {
|
||||
|
||||
|
||||
/**
|
||||
`overrideDerivation drv f` takes a derivation (i.e., the result
|
||||
of a call to the builtin function `derivation`) and returns a new
|
||||
derivation in which the attributes of the original are overridden
|
||||
according to the function `f`. The function `f` is called with
|
||||
the original derivation attributes.
|
||||
/* `overrideDerivation drv f` takes a derivation (i.e., the result
|
||||
of a call to the builtin function `derivation`) and returns a new
|
||||
derivation in which the attributes of the original are overridden
|
||||
according to the function `f`. The function `f` is called with
|
||||
the original derivation attributes.
|
||||
|
||||
`overrideDerivation` allows certain "ad-hoc" customisation
|
||||
scenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance,
|
||||
if you want to "patch" the derivation returned by a package
|
||||
function in Nixpkgs to build another version than what the
|
||||
function itself provides.
|
||||
`overrideDerivation` allows certain "ad-hoc" customisation
|
||||
scenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance,
|
||||
if you want to "patch" the derivation returned by a package
|
||||
function in Nixpkgs to build another version than what the
|
||||
function itself provides.
|
||||
|
||||
For another application, see build-support/vm, where this
|
||||
function is used to build arbitrary derivations inside a QEMU
|
||||
virtual machine.
|
||||
For another application, see build-support/vm, where this
|
||||
function is used to build arbitrary derivations inside a QEMU
|
||||
virtual machine.
|
||||
|
||||
Note that in order to preserve evaluation errors, the new derivation's
|
||||
outPath depends on the old one's, which means that this function cannot
|
||||
be used in circular situations when the old derivation also depends on the
|
||||
new one.
|
||||
Note that in order to preserve evaluation errors, the new derivation's
|
||||
outPath depends on the old one's, which means that this function cannot
|
||||
be used in circular situations when the old derivation also depends on the
|
||||
new one.
|
||||
|
||||
You should in general prefer `drv.overrideAttrs` over this function;
|
||||
see the nixpkgs manual for more information on overriding.
|
||||
You should in general prefer `drv.overrideAttrs` over this function;
|
||||
see the nixpkgs manual for more information on overriding.
|
||||
|
||||
Example:
|
||||
mySed = overrideDerivation pkgs.gnused (oldAttrs: {
|
||||
name = "sed-4.2.2-pre";
|
||||
src = fetchurl {
|
||||
url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
|
||||
hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY=";
|
||||
};
|
||||
patches = [];
|
||||
});
|
||||
|
||||
# Inputs
|
||||
|
||||
`drv`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`f`
|
||||
|
||||
: 2\. Function argument
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
overrideDerivation :: Derivation -> ( Derivation -> AttrSet ) -> Derivation
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `lib.customisation.overrideDerivation` usage example
|
||||
|
||||
```nix
|
||||
mySed = overrideDerivation pkgs.gnused (oldAttrs: {
|
||||
name = "sed-4.2.2-pre";
|
||||
src = fetchurl {
|
||||
url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2;
|
||||
hash = "sha256-MxBJRcM2rYzQYwJ5XKxhXTQByvSg5jZc5cSHEZoB2IY=";
|
||||
};
|
||||
patches = [];
|
||||
});
|
||||
```
|
||||
|
||||
:::
|
||||
Type:
|
||||
overrideDerivation :: Derivation -> ( Derivation -> AttrSet ) -> Derivation
|
||||
*/
|
||||
overrideDerivation = drv: f:
|
||||
let
|
||||
@@ -89,44 +67,26 @@ rec {
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
`makeOverridable` takes a function from attribute set to attribute set and
|
||||
injects `override` attribute which can be used to override arguments of
|
||||
the function.
|
||||
/* `makeOverridable` takes a function from attribute set to attribute set and
|
||||
injects `override` attribute which can be used to override arguments of
|
||||
the function.
|
||||
|
||||
Please refer to documentation on [`<pkg>.overrideDerivation`](#sec-pkg-overrideDerivation) to learn about `overrideDerivation` and caveats
|
||||
related to its use.
|
||||
Please refer to documentation on [`<pkg>.overrideDerivation`](#sec-pkg-overrideDerivation) to learn about `overrideDerivation` and caveats
|
||||
related to its use.
|
||||
|
||||
Example:
|
||||
nix-repl> x = {a, b}: { result = a + b; }
|
||||
|
||||
# Inputs
|
||||
nix-repl> y = lib.makeOverridable x { a = 1; b = 2; }
|
||||
|
||||
`f`
|
||||
nix-repl> y
|
||||
{ override = «lambda»; overrideDerivation = «lambda»; result = 3; }
|
||||
|
||||
: 1\. Function argument
|
||||
nix-repl> y.override { a = 10; }
|
||||
{ override = «lambda»; overrideDerivation = «lambda»; result = 12; }
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
makeOverridable :: (AttrSet -> a) -> AttrSet -> a
|
||||
```
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## `lib.customisation.makeOverridable` usage example
|
||||
|
||||
```nix
|
||||
nix-repl> x = {a, b}: { result = a + b; }
|
||||
|
||||
nix-repl> y = lib.makeOverridable x { a = 1; b = 2; }
|
||||
|
||||
nix-repl> y
|
||||
{ override = «lambda»; overrideDerivation = «lambda»; result = 3; }
|
||||
|
||||
nix-repl> y.override { a = 10; }
|
||||
{ override = «lambda»; overrideDerivation = «lambda»; result = 12; }
|
||||
```
|
||||
|
||||
:::
|
||||
Type:
|
||||
makeOverridable :: (AttrSet -> a) -> AttrSet -> a
|
||||
*/
|
||||
makeOverridable = f:
|
||||
let
|
||||
@@ -160,8 +120,7 @@ rec {
|
||||
else result);
|
||||
|
||||
|
||||
/**
|
||||
Call the package function in the file `fn` with the required
|
||||
/* Call the package function in the file `fn` with the required
|
||||
arguments automatically. The function is called with the
|
||||
arguments `args`, but any missing arguments are obtained from
|
||||
`autoArgs`. This function is intended to be partially
|
||||
@@ -188,26 +147,8 @@ rec {
|
||||
|
||||
<!-- TODO: Apply "Example:" tag to the examples above -->
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`autoArgs`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`fn`
|
||||
|
||||
: 2\. Function argument
|
||||
|
||||
`args`
|
||||
|
||||
: 3\. Function argument
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
callPackageWith :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a
|
||||
```
|
||||
Type:
|
||||
callPackageWith :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a
|
||||
*/
|
||||
callPackageWith = autoArgs: fn: args:
|
||||
let
|
||||
@@ -269,40 +210,20 @@ rec {
|
||||
else abort "lib.customisation.callPackageWith: ${error}";
|
||||
|
||||
|
||||
/**
|
||||
Like callPackage, but for a function that returns an attribute
|
||||
set of derivations. The override function is added to the
|
||||
individual attributes.
|
||||
/* Like callPackage, but for a function that returns an attribute
|
||||
set of derivations. The override function is added to the
|
||||
individual attributes.
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`autoArgs`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`fn`
|
||||
|
||||
: 2\. Function argument
|
||||
|
||||
`args`
|
||||
|
||||
: 3\. Function argument
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
callPackagesWith :: AttrSet -> ((AttrSet -> AttrSet) | Path) -> AttrSet -> AttrSet
|
||||
```
|
||||
Type:
|
||||
callPackagesWith :: AttrSet -> ((AttrSet -> AttrSet) | Path) -> AttrSet -> AttrSet
|
||||
*/
|
||||
callPackagesWith = autoArgs: fn: args:
|
||||
let
|
||||
f = if isFunction fn then fn else import fn;
|
||||
auto = intersectAttrs (functionArgs f) autoArgs;
|
||||
mirrorArgs = mirrorFunctionArgs f;
|
||||
origArgs = auto // args;
|
||||
pkgs = f origArgs;
|
||||
mkAttrOverridable = name: _: makeOverridable (mirrorArgs (newArgs: (f newArgs).${name})) origArgs;
|
||||
mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
|
||||
in
|
||||
if isDerivation pkgs then throw
|
||||
("function `callPackages` was called on a *single* derivation "
|
||||
@@ -311,30 +232,11 @@ rec {
|
||||
else mapAttrs mkAttrOverridable pkgs;
|
||||
|
||||
|
||||
/**
|
||||
Add attributes to each output of a derivation without changing
|
||||
the derivation itself and check a given condition when evaluating.
|
||||
/* Add attributes to each output of a derivation without changing
|
||||
the derivation itself and check a given condition when evaluating.
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`condition`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`passthru`
|
||||
|
||||
: 2\. Function argument
|
||||
|
||||
`drv`
|
||||
|
||||
: 3\. Function argument
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
extendDerivation :: Bool -> Any -> Derivation -> Derivation
|
||||
```
|
||||
Type:
|
||||
extendDerivation :: Bool -> Any -> Derivation -> Derivation
|
||||
*/
|
||||
extendDerivation = condition: passthru: drv:
|
||||
let
|
||||
@@ -366,24 +268,13 @@ rec {
|
||||
outPath = assert condition; drv.outPath;
|
||||
};
|
||||
|
||||
/**
|
||||
Strip a derivation of all non-essential attributes, returning
|
||||
only those needed by hydra-eval-jobs. Also strictly evaluate the
|
||||
result to ensure that there are no thunks kept alive to prevent
|
||||
garbage collection.
|
||||
/* Strip a derivation of all non-essential attributes, returning
|
||||
only those needed by hydra-eval-jobs. Also strictly evaluate the
|
||||
result to ensure that there are no thunks kept alive to prevent
|
||||
garbage collection.
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`drv`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
hydraJob :: (Derivation | Null) -> (Derivation | Null)
|
||||
```
|
||||
Type:
|
||||
hydraJob :: (Derivation | Null) -> (Derivation | Null)
|
||||
*/
|
||||
hydraJob = drv:
|
||||
let
|
||||
@@ -414,129 +305,18 @@ rec {
|
||||
in if drv == null then null else
|
||||
deepSeq drv' drv';
|
||||
|
||||
/**
|
||||
Make an attribute set (a "scope") from functions that take arguments from that same attribute set.
|
||||
See [](#ex-makeScope) for how to use it.
|
||||
/* Make a set of packages with a common scope. All packages called
|
||||
with the provided `callPackage` will be evaluated with the same
|
||||
arguments. Any package in the set may depend on any other. The
|
||||
`overrideScope'` function allows subsequent modification of the package
|
||||
set in a consistent way, i.e. all packages in the set will be
|
||||
called with the overridden packages. The package sets may be
|
||||
hierarchical: the packages in the set are called with the scope
|
||||
provided by `newScope` and the set provides a `newScope` attribute
|
||||
which can form the parent scope for later package sets.
|
||||
|
||||
# Inputs
|
||||
|
||||
1. `newScope` (`AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a`)
|
||||
|
||||
A function that takes an attribute set `attrs` and returns what ends up as `callPackage` in the output.
|
||||
|
||||
Typical values are `callPackageWith` or the output attribute `newScope`.
|
||||
|
||||
2. `f` (`AttrSet -> AttrSet`)
|
||||
|
||||
A function that takes an attribute set as returned by `makeScope newScope f` (a "scope") and returns any attribute set.
|
||||
|
||||
This function is used to compute the fixpoint of the resulting scope using `callPackage`.
|
||||
Its argument is the lazily evaluated reference to the value of that fixpoint, and is typically called `self` or `final`.
|
||||
|
||||
See [](#ex-makeScope) for how to use it.
|
||||
See [](#sec-functions-library-fixedPoints) for details on fixpoint computation.
|
||||
|
||||
# Output
|
||||
|
||||
`makeScope` returns an attribute set of a form called `scope`, which also contains the final attributes produced by `f`:
|
||||
|
||||
```
|
||||
scope :: {
|
||||
callPackage :: ((AttrSet -> a) | Path) -> AttrSet -> a
|
||||
newScope = AttrSet -> scope
|
||||
overrideScope = (scope -> scope -> AttrSet) -> scope
|
||||
packages :: AttrSet -> AttrSet
|
||||
}
|
||||
```
|
||||
|
||||
- `callPackage` (`((AttrSet -> a) | Path) -> AttrSet -> a`)
|
||||
|
||||
A function that
|
||||
|
||||
1. Takes a function `p`, or a path to a Nix file that contains a function `p`, which takes an attribute set and returns value of arbitrary type `a`,
|
||||
2. Takes an attribute set `args` with explicit attributes to pass to `p`,
|
||||
3. Calls `f` with attributes from the original attribute set `attrs` passed to `newScope` updated with `args, i.e. `attrs // args`, if they match the attributes in the argument of `p`.
|
||||
|
||||
All such functions `p` will be called with the same value for `attrs`.
|
||||
|
||||
See [](#ex-makeScope-callPackage) for how to use it.
|
||||
|
||||
- `newScope` (`AttrSet -> scope`)
|
||||
|
||||
Takes an attribute set `attrs` and returns a scope that extends the original scope.
|
||||
|
||||
- `overrideScope` (`(scope -> scope -> AttrSet) -> scope`)
|
||||
|
||||
Takes a function `g` of the form `final: prev: { # attributes }` to act as an overlay on `f`, and returns a new scope with values determined by `extends g f`.
|
||||
See [](https://nixos.org/manual/nixpkgs/unstable/#function-library-lib.fixedPoints.extends) for details.
|
||||
|
||||
This allows subsequent modification of the final attribute set in a consistent way, i.e. all functions `p` invoked with `callPackage` will be called with the modified values.
|
||||
|
||||
- `packages` (`AttrSet -> AttrSet`)
|
||||
|
||||
The value of the argument `f` to `makeScope`.
|
||||
|
||||
- final attributes
|
||||
|
||||
The final values returned by `f`.
|
||||
|
||||
# Examples
|
||||
|
||||
:::{#ex-makeScope .example}
|
||||
# Create an interdependent package set on top of `pkgs`
|
||||
|
||||
The functions in `foo.nix` and `bar.nix` can depend on each other, in the sense that `foo.nix` can contain a function that expects `bar` as an attribute in its argument.
|
||||
|
||||
```nix
|
||||
let
|
||||
pkgs = import <nixpkgs> { };
|
||||
in
|
||||
pkgs.lib.makeScope pkgs.newScope (self: {
|
||||
foo = self.callPackage ./foo.nix { };
|
||||
bar = self.callPackage ./bar.nix { };
|
||||
})
|
||||
```
|
||||
|
||||
evaluates to
|
||||
|
||||
```nix
|
||||
{
|
||||
callPackage = «lambda»;
|
||||
newScope = «lambda»;
|
||||
overrideScope = «lambda»;
|
||||
packages = «lambda»;
|
||||
foo = «derivation»;
|
||||
bar = «derivation»;
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
:::{#ex-makeScope-callPackage .example}
|
||||
# Using `callPackage` from a scope
|
||||
|
||||
```nix
|
||||
let
|
||||
pkgs = import <nixpkgs> { };
|
||||
inherit (pkgs) lib;
|
||||
scope = lib.makeScope lib.callPackageWith (self: { a = 1; b = 2; });
|
||||
three = scope.callPackage ({ a, b }: a + b) { };
|
||||
four = scope.callPackage ({ a, b }: a + b) { a = 2; };
|
||||
in
|
||||
[ three four ]
|
||||
```
|
||||
|
||||
evaluates to
|
||||
|
||||
```nix
|
||||
[ 3 4 ]
|
||||
```
|
||||
:::
|
||||
|
||||
# Type
|
||||
|
||||
```
|
||||
makeScope :: (AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a) -> (AttrSet -> AttrSet) -> scope
|
||||
```
|
||||
Type:
|
||||
makeScope :: (AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a) -> (AttrSet -> AttrSet) -> AttrSet
|
||||
*/
|
||||
makeScope = newScope: f:
|
||||
let self = f self // {
|
||||
@@ -551,65 +331,32 @@ rec {
|
||||
};
|
||||
in self;
|
||||
|
||||
/**
|
||||
backward compatibility with old uncurried form; deprecated
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`splicePackages`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`newScope`
|
||||
|
||||
: 2\. Function argument
|
||||
|
||||
`otherSplices`
|
||||
|
||||
: 3\. Function argument
|
||||
|
||||
`keep`
|
||||
|
||||
: 4\. Function argument
|
||||
|
||||
`extra`
|
||||
|
||||
: 5\. Function argument
|
||||
|
||||
`f`
|
||||
|
||||
: 6\. Function argument
|
||||
*/
|
||||
/* backward compatibility with old uncurried form; deprecated */
|
||||
makeScopeWithSplicing =
|
||||
splicePackages: newScope: otherSplices: keep: extra: f:
|
||||
makeScopeWithSplicing'
|
||||
{ inherit splicePackages newScope; }
|
||||
{ inherit otherSplices keep extra f; };
|
||||
|
||||
/**
|
||||
Like makeScope, but aims to support cross compilation. It's still ugly, but
|
||||
hopefully it helps a little bit.
|
||||
/* Like makeScope, but aims to support cross compilation. It's still ugly, but
|
||||
hopefully it helps a little bit.
|
||||
|
||||
# Type
|
||||
Type:
|
||||
makeScopeWithSplicing' ::
|
||||
{ splicePackages :: Splice -> AttrSet
|
||||
, newScope :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a
|
||||
}
|
||||
-> { otherSplices :: Splice, keep :: AttrSet -> AttrSet, extra :: AttrSet -> AttrSet }
|
||||
-> AttrSet
|
||||
|
||||
```
|
||||
makeScopeWithSplicing' ::
|
||||
{ splicePackages :: Splice -> AttrSet
|
||||
, newScope :: AttrSet -> ((AttrSet -> a) | Path) -> AttrSet -> a
|
||||
}
|
||||
-> { otherSplices :: Splice, keep :: AttrSet -> AttrSet, extra :: AttrSet -> AttrSet }
|
||||
-> AttrSet
|
||||
|
||||
Splice ::
|
||||
{ pkgsBuildBuild :: AttrSet
|
||||
, pkgsBuildHost :: AttrSet
|
||||
, pkgsBuildTarget :: AttrSet
|
||||
, pkgsHostHost :: AttrSet
|
||||
, pkgsHostTarget :: AttrSet
|
||||
, pkgsTargetTarget :: AttrSet
|
||||
}
|
||||
```
|
||||
Splice ::
|
||||
{ pkgsBuildBuild :: AttrSet
|
||||
, pkgsBuildHost :: AttrSet
|
||||
, pkgsBuildTarget :: AttrSet
|
||||
, pkgsHostHost :: AttrSet
|
||||
, pkgsHostTarget :: AttrSet
|
||||
, pkgsTargetTarget :: AttrSet
|
||||
}
|
||||
*/
|
||||
makeScopeWithSplicing' =
|
||||
{ splicePackages
|
||||
|
||||
@@ -84,8 +84,8 @@ let
|
||||
mapAttrs' mapAttrsToList attrsToList concatMapAttrs mapAttrsRecursive
|
||||
mapAttrsRecursiveCond genAttrs isDerivation toDerivation optionalAttrs
|
||||
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
||||
recursiveUpdate matchAttrs mergeAttrsList overrideExisting showAttrPath getOutput
|
||||
getBin getLib getDev getMan chooseDevOutputs zipWithNames zip
|
||||
recursiveUpdate matchAttrs overrideExisting showAttrPath getOutput getBin
|
||||
getLib getDev getMan chooseDevOutputs zipWithNames zip
|
||||
recurseIntoAttrs dontRecurseIntoAttrs cartesianProductOfSets
|
||||
updateManyAttrsByPath;
|
||||
inherit (self.lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
||||
@@ -116,7 +116,7 @@ let
|
||||
inherit (self.customisation) overrideDerivation makeOverridable
|
||||
callPackageWith callPackagesWith extendDerivation hydraJob
|
||||
makeScope makeScopeWithSplicing makeScopeWithSplicing';
|
||||
inherit (self.derivations) lazyDerivation optionalDrvAttr;
|
||||
inherit (self.derivations) lazyDerivation;
|
||||
inherit (self.meta) addMetaAttrs dontDistribute setName updateName
|
||||
appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
|
||||
hiPrioSet getLicenseFromSpdxId getExe getExe';
|
||||
|
||||
@@ -1,37 +1,14 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
and
|
||||
any
|
||||
attrByPath
|
||||
attrNames
|
||||
compare
|
||||
concat
|
||||
concatMap
|
||||
elem
|
||||
filter
|
||||
foldl
|
||||
foldr
|
||||
genericClosure
|
||||
head
|
||||
imap1
|
||||
init
|
||||
isAttrs
|
||||
isFunction
|
||||
isInt
|
||||
isList
|
||||
lists
|
||||
listToAttrs
|
||||
mapAttrs
|
||||
mergeAttrs
|
||||
meta
|
||||
nameValuePair
|
||||
tail
|
||||
toList
|
||||
;
|
||||
inherit (builtins) head tail isList isAttrs isInt attrNames;
|
||||
|
||||
inherit (lib.attrsets) removeAttrs;
|
||||
in
|
||||
|
||||
with lib.lists;
|
||||
with lib.attrsets;
|
||||
with lib.strings;
|
||||
|
||||
rec {
|
||||
|
||||
# returns default if env var is not set
|
||||
maybeEnv = name: default:
|
||||
@@ -49,7 +26,7 @@ let
|
||||
base = (setAttrMerge "passthru" {} (f arg)
|
||||
( z: z // {
|
||||
function = foldArgs merger f arg;
|
||||
args = (attrByPath ["passthru" "args"] {} z) // x;
|
||||
args = (lib.attrByPath ["passthru" "args"] {} z) // x;
|
||||
} ));
|
||||
withStdOverrides = base // {
|
||||
override = base.passthru.function;
|
||||
@@ -100,11 +77,11 @@ let
|
||||
# Output : are reqs satisfied? It's asserted.
|
||||
checkReqs = attrSet: argList: condList:
|
||||
(
|
||||
foldr and true
|
||||
foldr lib.and true
|
||||
(map (x: let name = (head x); in
|
||||
|
||||
((checkFlag attrSet name) ->
|
||||
(foldr and true
|
||||
(foldr lib.and true
|
||||
(map (y: let val=(getValue attrSet argList y); in
|
||||
(val!=null) && (val!=false))
|
||||
(tail x))))) condList));
|
||||
@@ -182,11 +159,11 @@ let
|
||||
|
||||
closePropagationSlow = list: (uniqList {inputList = (innerClosePropagation [] list);});
|
||||
|
||||
# This is an optimisation of closePropagation which avoids the O(n^2) behavior
|
||||
# This is an optimisation of lib.closePropagation which avoids the O(n^2) behavior
|
||||
# Using a list of derivations, it generates the full closure of the propagatedXXXBuildInputs
|
||||
# The ordering / sorting / comparison is done based on the `outPath`
|
||||
# attribute of each derivation.
|
||||
# On some benchmarks, it performs up to 15 times faster than closePropagation.
|
||||
# On some benchmarks, it performs up to 15 times faster than lib.closePropagation.
|
||||
# See https://github.com/NixOS/nixpkgs/pull/194391 for details.
|
||||
closePropagationFast = list:
|
||||
builtins.map (x: x.val) (builtins.genericClosure {
|
||||
@@ -273,10 +250,10 @@ let
|
||||
# foldArgs, composedArgsAndFun or applyAndFun. Example: composableDerivation in all-packages.nix
|
||||
mergeAttrByFunc = x: y:
|
||||
let
|
||||
mergeAttrBy2 = { mergeAttrBy = mergeAttrs; }
|
||||
mergeAttrBy2 = { mergeAttrBy = lib.mergeAttrs; }
|
||||
// (maybeAttr "mergeAttrBy" {} x)
|
||||
// (maybeAttr "mergeAttrBy" {} y); in
|
||||
foldr mergeAttrs {} [
|
||||
foldr lib.mergeAttrs {} [
|
||||
x y
|
||||
(mapAttrs ( a: v: # merge special names using given functions
|
||||
if x ? ${a}
|
||||
@@ -296,9 +273,9 @@ let
|
||||
|
||||
# sane defaults (same name as attr name so that inherit can be used)
|
||||
mergeAttrBy = # { buildInputs = concatList; [...]; passthru = mergeAttr; [..]; }
|
||||
listToAttrs (map (n: nameValuePair n concat)
|
||||
listToAttrs (map (n: nameValuePair n lib.concat)
|
||||
[ "nativeBuildInputs" "buildInputs" "propagatedBuildInputs" "configureFlags" "prePhases" "postAll" "patches" ])
|
||||
// listToAttrs (map (n: nameValuePair n mergeAttrs) [ "passthru" "meta" "cfg" "flags" ])
|
||||
// listToAttrs (map (n: nameValuePair n lib.mergeAttrs) [ "passthru" "meta" "cfg" "flags" ])
|
||||
// listToAttrs (map (n: nameValuePair n (a: b: "${a}\n${b}") ) [ "preConfigure" "postInstall" ])
|
||||
;
|
||||
|
||||
@@ -306,7 +283,7 @@ let
|
||||
if isAttrs x then
|
||||
if x ? outPath then "derivation"
|
||||
else "attrs"
|
||||
else if isFunction x then "function"
|
||||
else if lib.isFunction x then "function"
|
||||
else if isList x then "list"
|
||||
else if x == true then "bool"
|
||||
else if x == false then "bool"
|
||||
@@ -327,47 +304,4 @@ let
|
||||
fakeHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
fakeSha256 = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
fakeSha512 = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
in
|
||||
|
||||
# Everything in this attrset is the public interface of the file.
|
||||
{
|
||||
inherit
|
||||
checkFlag
|
||||
checkReqs
|
||||
closePropagation
|
||||
closePropagationFast
|
||||
closePropagationSlow
|
||||
condConcat
|
||||
defaultMerge
|
||||
defaultMergeArg
|
||||
fakeHash
|
||||
fakeSha256
|
||||
fakeSha512
|
||||
foldArgs
|
||||
getValue
|
||||
ifEnable
|
||||
imap
|
||||
innerClosePropagation
|
||||
innerModifySumArgs
|
||||
lazyGenericClosure
|
||||
mapAttrsFlatten
|
||||
maybeAttr
|
||||
maybeAttrNullable
|
||||
maybeEnv
|
||||
mergeAttrBy
|
||||
mergeAttrByFunc
|
||||
mergeAttrsByFuncDefaults
|
||||
mergeAttrsByFuncDefaultsClean
|
||||
mergeAttrsConcatenateValues
|
||||
mergeAttrsNoOverride
|
||||
mergeAttrsWithFunc
|
||||
modifySumArgs
|
||||
nixType
|
||||
nvs
|
||||
setAttr
|
||||
setAttrMerge
|
||||
uniqList
|
||||
uniqListExt
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
genAttrs
|
||||
isString
|
||||
throwIfNot
|
||||
;
|
||||
|
||||
showMaybeAttrPosPre = prefix: attrName: v:
|
||||
let pos = builtins.unsafeGetAttrPos attrName v;
|
||||
in if pos == null then "" else "${prefix}${pos.file}:${toString pos.line}:${toString pos.column}";
|
||||
|
||||
showMaybePackagePosPre = prefix: pkg:
|
||||
if pkg?meta.position && isString pkg.meta.position
|
||||
then "${prefix}${pkg.meta.position}"
|
||||
else "";
|
||||
inherit (lib) throwIfNot;
|
||||
in
|
||||
{
|
||||
/*
|
||||
@@ -77,11 +64,6 @@ in
|
||||
#
|
||||
# This can be used for adding package attributes, such as `tests`.
|
||||
passthru ? { }
|
||||
, # Optional list of assumed outputs. Default: ["out"]
|
||||
#
|
||||
# This must match the set of outputs that the returned derivation has.
|
||||
# You must use this when the derivation has multiple outputs.
|
||||
outputs ? [ "out" ]
|
||||
}:
|
||||
let
|
||||
# These checks are strict in `drv` and some `drv` attributes, but the
|
||||
@@ -89,40 +71,11 @@ in
|
||||
# Instead, the individual derivation attributes do depend on it.
|
||||
checked =
|
||||
throwIfNot (derivation.type or null == "derivation")
|
||||
"lazyDerivation: input must be a derivation."
|
||||
"lazySimpleDerivation: input must be a derivation."
|
||||
throwIfNot
|
||||
# NOTE: Technically we could require our outputs to be a subset of the
|
||||
# actual ones, or even leave them unchecked and fail on a lazy basis.
|
||||
# However, consider the case where an output is added in the underlying
|
||||
# derivation, such as dev. lazyDerivation would remove it and cause it
|
||||
# to fail as a buildInputs item, without any indication as to what
|
||||
# happened. Hence the more stringent condition. We could consider
|
||||
# adding a flag to control this behavior if there's a valid case for it,
|
||||
# but the documentation must have a note like this.
|
||||
(derivation.outputs == outputs)
|
||||
''
|
||||
lib.lazyDerivation: The derivation ${derivation.name or "<unknown>"} has outputs that don't match the assumed outputs.
|
||||
|
||||
Assumed outputs passed to lazyDerivation${showMaybeAttrPosPre ",\n at " "outputs" args}:
|
||||
${lib.generators.toPretty { multiline = false; } outputs};
|
||||
|
||||
Actual outputs of the derivation${showMaybePackagePosPre ",\n defined at " derivation}:
|
||||
${lib.generators.toPretty { multiline = false; } derivation.outputs}
|
||||
|
||||
If the outputs are known ahead of evaluating the derivation,
|
||||
then update the lazyDerivation call to match the actual outputs, in the same order.
|
||||
If lazyDerivation is passed a literal value, just change it to the actual outputs.
|
||||
As a result it will work as before / as intended.
|
||||
|
||||
Otherwise, when the outputs are dynamic and can't be known ahead of time, it won't
|
||||
be possible to add laziness, but lib.lazyDerivation may still be useful for trimming
|
||||
the attributes.
|
||||
If you want to keep trimming the attributes, make sure that the package is in a
|
||||
variable (don't evaluate it twice!) and pass the variable and its outputs attribute
|
||||
to lib.lazyDerivation. This largely defeats laziness, but keeps the trimming.
|
||||
If none of the above works for you, replace the lib.lazyDerivation call by the
|
||||
expression in the derivation argument.
|
||||
''
|
||||
(derivation.outputs == [ "out" ])
|
||||
# Supporting multiple outputs should be a matter of inheriting more attrs.
|
||||
"The derivation ${derivation.name or "<unknown>"} has multiple outputs. This is not supported by lazySimpleDerivation yet. Support could be added, and be useful as long as the set of outputs is known in advance, without evaluating the actual derivation."
|
||||
derivation;
|
||||
in
|
||||
{
|
||||
@@ -139,39 +92,10 @@ in
|
||||
# A fixed set of derivation values, so that `lazyDerivation` can return
|
||||
# its attrset before evaluating `derivation`.
|
||||
# This must only list attributes that are available on _all_ derivations.
|
||||
inherit (checked) outPath outputName drvPath name system;
|
||||
inherit outputs;
|
||||
inherit (checked) outputs out outPath outputName drvPath name system;
|
||||
|
||||
# The meta attribute can either be taken from the derivation, or if the
|
||||
# `lazyDerivation` caller knew a shortcut, be taken from there.
|
||||
meta = args.meta or checked.meta;
|
||||
}
|
||||
// genAttrs outputs (outputName: checked.${outputName})
|
||||
// passthru;
|
||||
|
||||
/* Conditionally set a derivation attribute.
|
||||
|
||||
Because `mkDerivation` sets `__ignoreNulls = true`, a derivation
|
||||
attribute set to `null` will not impact the derivation output hash.
|
||||
Thus, this function passes through its `value` argument if the `cond`
|
||||
is `true`, but returns `null` if not.
|
||||
|
||||
Type: optionalDrvAttr :: Bool -> a -> a | Null
|
||||
|
||||
Example:
|
||||
(stdenv.mkDerivation {
|
||||
name = "foo";
|
||||
x = optionalDrvAttr true 1;
|
||||
y = optionalDrvAttr false 1;
|
||||
}).drvPath == (stdenv.mkDerivation {
|
||||
name = "foo";
|
||||
x = 1;
|
||||
}).drvPath
|
||||
=> true
|
||||
*/
|
||||
optionalDrvAttr =
|
||||
# Condition
|
||||
cond:
|
||||
# Attribute value
|
||||
value: if cond then value else null;
|
||||
} // passthru;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
|
||||
Add files in file sets to the store to use as derivation sources.
|
||||
|
||||
- [`lib.fileset.toList`](#function-library-lib.fileset.toList):
|
||||
|
||||
The list of files contained in a file set.
|
||||
|
||||
Combinators:
|
||||
- [`lib.fileset.union`](#function-library-lib.fileset.union)/[`lib.fileset.unions`](#function-library-lib.fileset.unions):
|
||||
|
||||
@@ -106,7 +102,6 @@ let
|
||||
_coerceMany
|
||||
_toSourceFilter
|
||||
_fromSourceFilter
|
||||
_toList
|
||||
_unionMany
|
||||
_fileFilter
|
||||
_printFileset
|
||||
@@ -417,38 +412,6 @@ in {
|
||||
filter = sourceFilter;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
The list of file paths contained in the given file set.
|
||||
|
||||
:::{.note}
|
||||
This function is strict in the entire file set.
|
||||
This is in contrast with combinators [`lib.fileset.union`](#function-library-lib.fileset.union),
|
||||
[`lib.fileset.intersection`](#function-library-lib.fileset.intersection) and [`lib.fileset.difference`](#function-library-lib.fileset.difference).
|
||||
|
||||
Thus it is recommended to call `toList` on file sets created using the combinators,
|
||||
instead of doing list processing on the result of `toList`.
|
||||
:::
|
||||
|
||||
The resulting list of files can be turned back into a file set using [`lib.fileset.unions`](#function-library-lib.fileset.unions).
|
||||
|
||||
Type:
|
||||
toList :: FileSet -> [ Path ]
|
||||
|
||||
Example:
|
||||
toList ./.
|
||||
[ ./README.md ./Makefile ./src/main.c ./src/main.h ]
|
||||
|
||||
toList (difference ./. ./src)
|
||||
[ ./README.md ./Makefile ]
|
||||
*/
|
||||
toList =
|
||||
# The file set whose file paths to return.
|
||||
# This argument can also be a path,
|
||||
# which gets [implicitly coerced to a file set](#sec-fileset-path-coercion).
|
||||
fileset:
|
||||
_toList (_coerce "lib.fileset.toList: Argument" fileset);
|
||||
|
||||
/*
|
||||
The file set containing all files that are in either of two given file sets.
|
||||
This is the same as [`unions`](#function-library-lib.fileset.unions),
|
||||
|
||||
@@ -5,7 +5,6 @@ let
|
||||
isAttrs
|
||||
isPath
|
||||
isString
|
||||
nixVersion
|
||||
pathExists
|
||||
readDir
|
||||
split
|
||||
@@ -18,8 +17,6 @@ let
|
||||
attrNames
|
||||
attrValues
|
||||
mapAttrs
|
||||
mapAttrsToList
|
||||
optionalAttrs
|
||||
zipAttrsWith
|
||||
;
|
||||
|
||||
@@ -30,7 +27,6 @@ let
|
||||
inherit (lib.lists)
|
||||
all
|
||||
commonPrefix
|
||||
concatLists
|
||||
elemAt
|
||||
filter
|
||||
findFirst
|
||||
@@ -60,7 +56,6 @@ let
|
||||
substring
|
||||
stringLength
|
||||
hasSuffix
|
||||
versionAtLeast
|
||||
;
|
||||
|
||||
inherit (lib.trivial)
|
||||
@@ -541,27 +536,6 @@ rec {
|
||||
${baseNameOf root} = rootPathType;
|
||||
};
|
||||
|
||||
# Turns a file set into the list of file paths it includes.
|
||||
# Type: fileset -> [ Path ]
|
||||
_toList = fileset:
|
||||
let
|
||||
recurse = path: tree:
|
||||
if isAttrs tree then
|
||||
concatLists (mapAttrsToList (name: value:
|
||||
recurse (path + "/${name}") value
|
||||
) tree)
|
||||
else if tree == "directory" then
|
||||
recurse path (readDir path)
|
||||
else if tree == null then
|
||||
[ ]
|
||||
else
|
||||
[ path ];
|
||||
in
|
||||
if fileset._internalIsEmptyWithoutBase then
|
||||
[ ]
|
||||
else
|
||||
recurse fileset._internalBase fileset._internalTree;
|
||||
|
||||
# Transforms the filesetTree of a file set to a shorter base path, e.g.
|
||||
# _shortenTreeBase [ "foo" ] (_create /foo/bar null)
|
||||
# => { bar = null; }
|
||||
@@ -866,10 +840,6 @@ rec {
|
||||
# https://github.com/NixOS/nix/commit/55cefd41d63368d4286568e2956afd535cb44018
|
||||
_fetchGitSubmodulesMinver = "2.4";
|
||||
|
||||
# Support for `builtins.fetchGit` with `shallow = true` was introduced in 2.4
|
||||
# https://github.com/NixOS/nix/commit/d1165d8791f559352ff6aa7348e1293b2873db1c
|
||||
_fetchGitShallowMinver = "2.4";
|
||||
|
||||
# Mirrors the contents of a Nix store path relative to a local path as a file set.
|
||||
# Some notes:
|
||||
# - The store path is read at evaluation time.
|
||||
@@ -924,17 +894,7 @@ rec {
|
||||
# However a simpler alternative still would be [a builtins.gitLsFiles](https://github.com/NixOS/nix/issues/2944).
|
||||
fetchResult = fetchGit ({
|
||||
url = path;
|
||||
}
|
||||
# In older Nix versions, repositories were always assumed to be deep clones, which made `fetchGit` fail for shallow clones
|
||||
# For newer versions this was fixed, but the `shallow` flag is required.
|
||||
# The only behavioral difference is that for shallow clones, `fetchGit` doesn't return a `revCount`,
|
||||
# which we don't need here, so it's fine to always pass it.
|
||||
|
||||
# Unfortunately this means older Nix versions get a poor error message for shallow repositories, and there's no good way to improve that.
|
||||
# Checking for `.git/shallow` doesn't seem worth it, especially since that's more of an implementation detail,
|
||||
# and would also require more code to handle worktrees where `.git` is a file.
|
||||
// optionalAttrs (versionAtLeast nixVersion _fetchGitShallowMinver) { shallow = true; }
|
||||
// extraFetchGitAttrs);
|
||||
} // extraFetchGitAttrs);
|
||||
in
|
||||
# We can identify local working directories by checking for .git,
|
||||
# see https://git-scm.com/docs/gitrepository-layout#_description.
|
||||
|
||||
@@ -275,6 +275,7 @@ createTree() {
|
||||
# )
|
||||
# checkFileset './a' # Pass the fileset as the argument
|
||||
checkFileset() {
|
||||
# New subshell so that we can have a separate trap handler, see `trap` below
|
||||
local fileset=$1
|
||||
|
||||
# Create the tree
|
||||
@@ -282,20 +283,16 @@ checkFileset() {
|
||||
|
||||
# Process the tree into separate arrays for included paths, excluded paths and excluded files.
|
||||
local -a included=()
|
||||
local -a includedFiles=()
|
||||
local -a excluded=()
|
||||
local -a excludedFiles=()
|
||||
for p in "${!tree[@]}"; do
|
||||
case "${tree[$p]}" in
|
||||
1)
|
||||
included+=("$p")
|
||||
# If keys end with a `/` we treat them as directories, otherwise files
|
||||
if [[ ! "$p" =~ /$ ]]; then
|
||||
includedFiles+=("$p")
|
||||
fi
|
||||
;;
|
||||
0)
|
||||
excluded+=("$p")
|
||||
# If keys end with a `/` we treat them as directories, otherwise files
|
||||
if [[ ! "$p" =~ /$ ]]; then
|
||||
excludedFiles+=("$p")
|
||||
fi
|
||||
@@ -305,10 +302,6 @@ checkFileset() {
|
||||
esac
|
||||
done
|
||||
|
||||
# Test that lib.fileset.toList contains exactly the included files.
|
||||
# The /#/./ part prefixes each element with `./`
|
||||
expectEqual "toList ($fileset)" "sort lessThan [ ${includedFiles[*]/#/./} ]"
|
||||
|
||||
expression="toSource { root = ./.; fileset = $fileset; }"
|
||||
|
||||
# We don't have lambda's in bash unfortunately,
|
||||
@@ -345,17 +338,13 @@ checkFileset() {
|
||||
|
||||
#### Error messages #####
|
||||
|
||||
# We're using [[:blank:]] here instead of \s, because only the former is POSIX
|
||||
# (see https://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html#tag_007_003_005).
|
||||
# And indeed, Darwin's bash only supports the former
|
||||
|
||||
# Absolute paths in strings cannot be passed as `root`
|
||||
expectFailure 'toSource { root = "/nix/store/foobar"; fileset = ./.; }' 'lib.fileset.toSource: `root` \(/nix/store/foobar\) is a string-like value, but it should be a path instead.
|
||||
[[:blank:]]*Paths in strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.'
|
||||
\s*Paths in strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.'
|
||||
|
||||
expectFailure 'toSource { root = cleanSourceWith { src = ./.; }; fileset = ./.; }' 'lib.fileset.toSource: `root` is a `lib.sources`-based value, but it should be a path instead.
|
||||
[[:blank:]]*To use a `lib.sources`-based value, convert it to a file set using `lib.fileset.fromSource` and pass it as `fileset`.
|
||||
[[:blank:]]*Note that this only works for sources created from paths.'
|
||||
\s*To use a `lib.sources`-based value, convert it to a file set using `lib.fileset.fromSource` and pass it as `fileset`.
|
||||
\s*Note that this only works for sources created from paths.'
|
||||
|
||||
# Only paths are accepted as `root`
|
||||
expectFailure 'toSource { root = 10; fileset = ./.; }' 'lib.fileset.toSource: `root` is of type int, but it should be a path instead.'
|
||||
@@ -365,9 +354,9 @@ mkdir -p {foo,bar}/mock-root
|
||||
expectFailure 'with ((import <nixpkgs/lib>).extend (import <nixpkgs/lib/fileset/mock-splitRoot.nix>)).fileset;
|
||||
toSource { root = ./foo/mock-root; fileset = ./bar/mock-root; }
|
||||
' 'lib.fileset.toSource: Filesystem roots are not the same for `fileset` and `root` \('"$work"'/foo/mock-root\):
|
||||
[[:blank:]]*`root`: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
[[:blank:]]*`fileset`: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
[[:blank:]]*Different filesystem roots are not supported.'
|
||||
\s*`root`: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
\s*`fileset`: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
\s*Different filesystem roots are not supported.'
|
||||
rm -rf -- *
|
||||
|
||||
# `root` needs to exist
|
||||
@@ -376,8 +365,8 @@ expectFailure 'toSource { root = ./a; fileset = ./.; }' 'lib.fileset.toSource: `
|
||||
# `root` needs to be a file
|
||||
touch a
|
||||
expectFailure 'toSource { root = ./a; fileset = ./a; }' 'lib.fileset.toSource: `root` \('"$work"'/a\) is a file, but it should be a directory instead. Potential solutions:
|
||||
[[:blank:]]*- If you want to import the file into the store _without_ a containing directory, use string interpolation or `builtins.path` instead of this function.
|
||||
[[:blank:]]*- If you want to import the file into the store _with_ a containing directory, set `root` to the containing directory, such as '"$work"', and set `fileset` to the file path.'
|
||||
\s*- If you want to import the file into the store _without_ a containing directory, use string interpolation or `builtins.path` instead of this function.
|
||||
\s*- If you want to import the file into the store _with_ a containing directory, set `root` to the containing directory, such as '"$work"', and set `fileset` to the file path.'
|
||||
rm -rf -- *
|
||||
|
||||
# The fileset argument should be evaluated, even if the directory is empty
|
||||
@@ -386,36 +375,36 @@ expectFailure 'toSource { root = ./.; fileset = abort "This should be evaluated"
|
||||
# Only paths under `root` should be able to influence the result
|
||||
mkdir a
|
||||
expectFailure 'toSource { root = ./a; fileset = ./.; }' 'lib.fileset.toSource: `fileset` could contain files in '"$work"', which is not under the `root` \('"$work"'/a\). Potential solutions:
|
||||
[[:blank:]]*- Set `root` to '"$work"' or any directory higher up. This changes the layout of the resulting store path.
|
||||
[[:blank:]]*- Set `fileset` to a file set that cannot contain files outside the `root` \('"$work"'/a\). This could change the files included in the result.'
|
||||
\s*- Set `root` to '"$work"' or any directory higher up. This changes the layout of the resulting store path.
|
||||
\s*- Set `fileset` to a file set that cannot contain files outside the `root` \('"$work"'/a\). This could change the files included in the result.'
|
||||
rm -rf -- *
|
||||
|
||||
# non-regular and non-symlink files cannot be added to the Nix store
|
||||
mkfifo a
|
||||
expectFailure 'toSource { root = ./.; fileset = ./a; }' 'lib.fileset.toSource: `fileset` contains a file that cannot be added to the store: '"$work"'/a
|
||||
[[:blank:]]*This file is neither a regular file nor a symlink, the only file types supported by the Nix store.
|
||||
[[:blank:]]*Therefore the file set cannot be added to the Nix store as is. Make sure to not include that file to avoid this error.'
|
||||
\s*This file is neither a regular file nor a symlink, the only file types supported by the Nix store.
|
||||
\s*Therefore the file set cannot be added to the Nix store as is. Make sure to not include that file to avoid this error.'
|
||||
rm -rf -- *
|
||||
|
||||
# Path coercion only works for paths
|
||||
expectFailure 'toSource { root = ./.; fileset = 10; }' 'lib.fileset.toSource: `fileset` is of type int, but it should be a file set or a path instead.'
|
||||
expectFailure 'toSource { root = ./.; fileset = "/some/path"; }' 'lib.fileset.toSource: `fileset` \("/some/path"\) is a string-like value, but it should be a file set or a path instead.
|
||||
[[:blank:]]*Paths represented as strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.'
|
||||
\s*Paths represented as strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.'
|
||||
expectFailure 'toSource { root = ./.; fileset = cleanSourceWith { src = ./.; }; }' 'lib.fileset.toSource: `fileset` is a `lib.sources`-based value, but it should be a file set or a path instead.
|
||||
[[:blank:]]*To convert a `lib.sources`-based value to a file set you can use `lib.fileset.fromSource`.
|
||||
[[:blank:]]*Note that this only works for sources created from paths.'
|
||||
\s*To convert a `lib.sources`-based value to a file set you can use `lib.fileset.fromSource`.
|
||||
\s*Note that this only works for sources created from paths.'
|
||||
|
||||
# Path coercion errors for non-existent paths
|
||||
expectFailure 'toSource { root = ./.; fileset = ./a; }' 'lib.fileset.toSource: `fileset` \('"$work"'/a\) is a path that does not exist.
|
||||
[[:blank:]]*To create a file set from a path that may not exist, use `lib.fileset.maybeMissing`.'
|
||||
\s*To create a file set from a path that may not exist, use `lib.fileset.maybeMissing`.'
|
||||
|
||||
# File sets cannot be evaluated directly
|
||||
expectFailure 'union ./. ./.' 'lib.fileset: Directly evaluating a file set is not supported.
|
||||
[[:blank:]]*To turn it into a usable source, use `lib.fileset.toSource`.
|
||||
[[:blank:]]*To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.'
|
||||
\s*To turn it into a usable source, use `lib.fileset.toSource`.
|
||||
\s*To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.'
|
||||
expectFailure '_emptyWithoutBase' 'lib.fileset: Directly evaluating a file set is not supported.
|
||||
[[:blank:]]*To turn it into a usable source, use `lib.fileset.toSource`.
|
||||
[[:blank:]]*To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.'
|
||||
\s*To turn it into a usable source, use `lib.fileset.toSource`.
|
||||
\s*To pretty-print the contents, use `lib.fileset.trace` or `lib.fileset.traceVal`.'
|
||||
|
||||
# Past versions of the internal representation are supported
|
||||
expectEqual '_coerce "<tests>: value" { _type = "fileset"; _internalVersion = 0; _internalBase = ./.; }' \
|
||||
@@ -427,9 +416,9 @@ expectEqual '_coerce "<tests>: value" { _type = "fileset"; _internalVersion = 2;
|
||||
|
||||
# Future versions of the internal representation are unsupported
|
||||
expectFailure '_coerce "<tests>: value" { _type = "fileset"; _internalVersion = 4; }' '<tests>: value is a file set created from a future version of the file set library with a different internal representation:
|
||||
[[:blank:]]*- Internal version of the file set: 4
|
||||
[[:blank:]]*- Internal version of the library: 3
|
||||
[[:blank:]]*Make sure to update your Nixpkgs to have a newer version of `lib.fileset`.'
|
||||
\s*- Internal version of the file set: 4
|
||||
\s*- Internal version of the library: 3
|
||||
\s*Make sure to update your Nixpkgs to have a newer version of `lib.fileset`.'
|
||||
|
||||
# _create followed by _coerce should give the inputs back without any validation
|
||||
expectEqual '{
|
||||
@@ -522,19 +511,6 @@ expectEqual '_toSourceFilter (_create /. { foo = "regular"; }) "/foo" ""' 'true'
|
||||
expectEqual '_toSourceFilter (_create /. { foo = null; }) "/foo" ""' 'false'
|
||||
|
||||
|
||||
## lib.fileset.toList
|
||||
# This function is mainly tested in checkFileset
|
||||
|
||||
# The error context for an invalid argument must be correct
|
||||
expectFailure 'toList null' 'lib.fileset.toList: Argument is of type null, but it should be a file set or a path instead.'
|
||||
|
||||
# Works for the empty fileset
|
||||
expectEqual 'toList _emptyWithoutBase' '[ ]'
|
||||
|
||||
# Works on empty paths
|
||||
expectEqual 'toList ./.' '[ ]'
|
||||
|
||||
|
||||
## lib.fileset.union, lib.fileset.unions
|
||||
|
||||
|
||||
@@ -543,16 +519,16 @@ mkdir -p {foo,bar}/mock-root
|
||||
expectFailure 'with ((import <nixpkgs/lib>).extend (import <nixpkgs/lib/fileset/mock-splitRoot.nix>)).fileset;
|
||||
toSource { root = ./.; fileset = union ./foo/mock-root ./bar/mock-root; }
|
||||
' 'lib.fileset.union: Filesystem roots are not the same:
|
||||
[[:blank:]]*First argument: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
[[:blank:]]*Second argument: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
[[:blank:]]*Different filesystem roots are not supported.'
|
||||
\s*First argument: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
\s*Second argument: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
\s*Different filesystem roots are not supported.'
|
||||
|
||||
expectFailure 'with ((import <nixpkgs/lib>).extend (import <nixpkgs/lib/fileset/mock-splitRoot.nix>)).fileset;
|
||||
toSource { root = ./.; fileset = unions [ ./foo/mock-root ./bar/mock-root ]; }
|
||||
' 'lib.fileset.unions: Filesystem roots are not the same:
|
||||
[[:blank:]]*Element 0: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
[[:blank:]]*Element 1: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
[[:blank:]]*Different filesystem roots are not supported.'
|
||||
\s*Element 0: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
\s*Element 1: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
\s*Different filesystem roots are not supported.'
|
||||
rm -rf -- *
|
||||
|
||||
# Coercion errors show the correct context
|
||||
@@ -656,9 +632,9 @@ mkdir -p {foo,bar}/mock-root
|
||||
expectFailure 'with ((import <nixpkgs/lib>).extend (import <nixpkgs/lib/fileset/mock-splitRoot.nix>)).fileset;
|
||||
toSource { root = ./.; fileset = intersection ./foo/mock-root ./bar/mock-root; }
|
||||
' 'lib.fileset.intersection: Filesystem roots are not the same:
|
||||
[[:blank:]]*First argument: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
[[:blank:]]*Second argument: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
[[:blank:]]*Different filesystem roots are not supported.'
|
||||
\s*First argument: Filesystem root is "'"$work"'/foo/mock-root"
|
||||
\s*Second argument: Filesystem root is "'"$work"'/bar/mock-root"
|
||||
\s*Different filesystem roots are not supported.'
|
||||
rm -rf -- *
|
||||
|
||||
# Coercion errors show the correct context
|
||||
@@ -765,8 +741,8 @@ rm -rf -- *
|
||||
# Also not the other way around
|
||||
mkdir a
|
||||
expectFailure 'toSource { root = ./a; fileset = difference ./. ./a; }' 'lib.fileset.toSource: `fileset` could contain files in '"$work"', which is not under the `root` \('"$work"'/a\). Potential solutions:
|
||||
[[:blank:]]*- Set `root` to '"$work"' or any directory higher up. This changes the layout of the resulting store path.
|
||||
[[:blank:]]*- Set `fileset` to a file set that cannot contain files outside the `root` \('"$work"'/a\). This could change the files included in the result.'
|
||||
\s*- Set `root` to '"$work"' or any directory higher up. This changes the layout of the resulting store path.
|
||||
\s*- Set `fileset` to a file set that cannot contain files outside the `root` \('"$work"'/a\). This could change the files included in the result.'
|
||||
rm -rf -- *
|
||||
|
||||
# Difference actually works
|
||||
@@ -843,7 +819,7 @@ expectFailure 'fileFilter null (abort "this is not needed")' 'lib.fileset.fileFi
|
||||
|
||||
# The second argument needs to be an existing path
|
||||
expectFailure 'fileFilter (file: abort "this is not needed") _emptyWithoutBase' 'lib.fileset.fileFilter: Second argument is a file set, but it should be a path instead.
|
||||
[[:blank:]]*If you need to filter files in a file set, use `intersection fileset \(fileFilter pred \./\.\)` instead.'
|
||||
\s*If you need to filter files in a file set, use `intersection fileset \(fileFilter pred \./\.\)` instead.'
|
||||
expectFailure 'fileFilter (file: abort "this is not needed") null' 'lib.fileset.fileFilter: Second argument is of type null, but it should be a path instead.'
|
||||
expectFailure 'fileFilter (file: abort "this is not needed") ./a' 'lib.fileset.fileFilter: Second argument \('"$work"'/a\) is a path that does not exist.'
|
||||
|
||||
@@ -1107,7 +1083,7 @@ rm -rf -- *
|
||||
|
||||
# String-like values are not supported
|
||||
expectFailure 'fromSource (lib.cleanSource "")' 'lib.fileset.fromSource: The source origin of the argument is a string-like value \(""\), but it should be a path instead.
|
||||
[[:blank:]]*Sources created from paths in strings cannot be turned into file sets, use `lib.sources` or derivations instead.'
|
||||
\s*Sources created from paths in strings cannot be turned into file sets, use `lib.sources` or derivations instead.'
|
||||
|
||||
# Wrong type
|
||||
expectFailure 'fromSource null' 'lib.fileset.fromSource: The source origin of the argument is of type null, but it should be a path instead.'
|
||||
@@ -1424,10 +1400,10 @@ expectEqual '(import '"$storePath"' { fs = lib.fileset; }).outPath' \""$storePat
|
||||
|
||||
## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}")
|
||||
expectFailure 'import "${./.}" { fs = lib.fileset; }' 'lib.fileset.gitTracked: The argument \(.*\) is a store path within a working tree of a Git repository.
|
||||
[[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.
|
||||
[[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.
|
||||
[[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.
|
||||
[[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'
|
||||
\s*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.
|
||||
\s*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.
|
||||
\s*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.
|
||||
\s*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'
|
||||
|
||||
## Even with submodules
|
||||
if [[ -n "$fetchGitSupportsSubmodules" ]]; then
|
||||
@@ -1451,31 +1427,18 @@ if [[ -n "$fetchGitSupportsSubmodules" ]]; then
|
||||
|
||||
## But it fails if the path is imported with a fetcher that doesn't remove .git (like just using "${./.}")
|
||||
expectFailure 'import "${./.}" { fs = lib.fileset; }' 'lib.fileset.gitTrackedWith: The second argument \(.*\) is a store path within a working tree of a Git repository.
|
||||
[[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.
|
||||
[[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.
|
||||
[[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.
|
||||
[[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'
|
||||
\s*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.
|
||||
\s*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.
|
||||
\s*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.
|
||||
\s*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'
|
||||
expectFailure 'import "${./.}/sub" { fs = lib.fileset; }' 'lib.fileset.gitTracked: The argument \(.*/sub\) is a store path within a working tree of a Git repository.
|
||||
[[:blank:]]*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.
|
||||
[[:blank:]]*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.
|
||||
[[:blank:]]*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.
|
||||
[[:blank:]]*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'
|
||||
\s*This indicates that a source directory was imported into the store using a method such as `import "\$\{./.\}"` or `path:.`.
|
||||
\s*This function currently does not support such a use case, since it currently relies on `builtins.fetchGit`.
|
||||
\s*You could make this work by using a fetcher such as `fetchGit` instead of copying the whole repository.
|
||||
\s*If you can'\''t avoid copying the repo to the store, see https://github.com/NixOS/nix/issues/9292.'
|
||||
fi
|
||||
rm -rf -- *
|
||||
|
||||
# shallow = true is not supported on all Nix versions
|
||||
# and older versions don't support shallow clones at all
|
||||
if [[ "$(nix-instantiate --eval --expr "$prefixExpression (versionAtLeast builtins.nixVersion _fetchGitShallowMinver)")" == true ]]; then
|
||||
createGitRepo full
|
||||
# Extra commit such that there's a commit that won't be in the shallow clone
|
||||
git -C full commit --allow-empty -q -m extra
|
||||
git clone -q --depth 1 "file://${PWD}/full" shallow
|
||||
cd shallow
|
||||
checkGitTracked
|
||||
cd ..
|
||||
rm -rf -- *
|
||||
fi
|
||||
|
||||
# Go through all stages of Git files
|
||||
# See https://www.git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
|
||||
|
||||
|
||||
@@ -145,12 +145,6 @@ rec {
|
||||
in fix g
|
||||
```
|
||||
|
||||
:::{.note}
|
||||
The argument to the given fixed-point function after applying an overlay will *not* refer to its own return value, but rather to the value after evaluating the overlay function.
|
||||
|
||||
The given fixed-point function is called with a separate argument than if it was evaluated with `lib.fix`.
|
||||
:::
|
||||
|
||||
:::{.example}
|
||||
|
||||
# Extend a fixed-point function with an overlay
|
||||
@@ -236,6 +230,13 @@ rec {
|
||||
|
||||
fix (extends (final: prev: { c = final.a + final.b; }) f)
|
||||
=> { a = 1; b = 3; c = 4; }
|
||||
|
||||
:::{.note}
|
||||
The argument to the given fixed-point function after applying an overlay will *not* refer to its own return value, but rather to the value after evaluating the overlay function.
|
||||
|
||||
The given fixed-point function is called with a separate argument than if it was evaluated with `lib.fix`.
|
||||
The new argument
|
||||
:::
|
||||
*/
|
||||
extends =
|
||||
# The overlay to apply to the fixed-point function
|
||||
|
||||
@@ -14,58 +14,15 @@
|
||||
* Documentation in the manual, #sec-generators
|
||||
*/
|
||||
{ lib }:
|
||||
|
||||
with (lib).trivial;
|
||||
let
|
||||
inherit (lib)
|
||||
addErrorContext
|
||||
assertMsg
|
||||
attrNames
|
||||
concatLists
|
||||
concatMapStringsSep
|
||||
concatStrings
|
||||
concatStringsSep
|
||||
const
|
||||
elem
|
||||
escape
|
||||
filter
|
||||
flatten
|
||||
foldl
|
||||
functionArgs # Note: not the builtin; considers `__functor` in attrsets.
|
||||
gvariant
|
||||
hasInfix
|
||||
head
|
||||
id
|
||||
init
|
||||
isAttrs
|
||||
isBool
|
||||
isDerivation
|
||||
isFloat
|
||||
isFunction # Note: not the builtin; considers `__functor` in attrsets.
|
||||
isInt
|
||||
isList
|
||||
isPath
|
||||
isString
|
||||
last
|
||||
length
|
||||
mapAttrs
|
||||
mapAttrsToList
|
||||
optionals
|
||||
recursiveUpdate
|
||||
replaceStrings
|
||||
reverseList
|
||||
splitString
|
||||
tail
|
||||
toList
|
||||
;
|
||||
libStr = lib.strings;
|
||||
libAttr = lib.attrsets;
|
||||
|
||||
inherit (lib.strings)
|
||||
escapeNixIdentifier
|
||||
floatToString
|
||||
match
|
||||
split
|
||||
toJSON
|
||||
typeOf
|
||||
;
|
||||
inherit (lib) isFunction;
|
||||
in
|
||||
|
||||
rec {
|
||||
|
||||
## -- HELPER FUNCTIONS & DEFAULTS --
|
||||
|
||||
@@ -73,13 +30,13 @@ let
|
||||
* The builtin `toString` function has some strange defaults,
|
||||
* suitable for bash scripts but not much else.
|
||||
*/
|
||||
mkValueStringDefault = {}: v:
|
||||
mkValueStringDefault = {}: v: with builtins;
|
||||
let err = t: v: abort
|
||||
("generators.mkValueStringDefault: " +
|
||||
"${t} not supported: ${toPretty {} v}");
|
||||
in if isInt v then toString v
|
||||
# convert derivations to store paths
|
||||
else if isDerivation v then toString v
|
||||
else if lib.isDerivation v then toString v
|
||||
# we default to not quoting strings
|
||||
else if isString v then v
|
||||
# isString returns "1", which is not a good default
|
||||
@@ -96,7 +53,7 @@ let
|
||||
# Floats currently can't be converted to precise strings,
|
||||
# condition warning on nix version once this isn't a problem anymore
|
||||
# See https://github.com/NixOS/nix/pull/3480
|
||||
else if isFloat v then floatToString v
|
||||
else if isFloat v then libStr.floatToString v
|
||||
else err "this value is" (toString v);
|
||||
|
||||
|
||||
@@ -112,7 +69,7 @@ let
|
||||
mkKeyValueDefault = {
|
||||
mkValueString ? mkValueStringDefault {}
|
||||
}: sep: k: v:
|
||||
"${escape [sep] k}${sep}${mkValueString v}";
|
||||
"${libStr.escape [sep] k}${sep}${mkValueString v}";
|
||||
|
||||
|
||||
## -- FILE FORMAT GENERATORS --
|
||||
@@ -129,9 +86,9 @@ let
|
||||
}:
|
||||
let mkLine = k: v: indent + mkKeyValue k v + "\n";
|
||||
mkLines = if listsAsDuplicateKeys
|
||||
then k: v: map (mkLine k) (if isList v then v else [v])
|
||||
then k: v: map (mkLine k) (if lib.isList v then v else [v])
|
||||
else k: v: [ (mkLine k v) ];
|
||||
in attrs: concatStrings (concatLists (mapAttrsToList mkLines attrs));
|
||||
in attrs: libStr.concatStrings (lib.concatLists (libAttr.mapAttrsToList mkLines attrs));
|
||||
|
||||
|
||||
/* Generate an INI-style config file from an
|
||||
@@ -156,7 +113,7 @@ let
|
||||
*/
|
||||
toINI = {
|
||||
# apply transformations (e.g. escapes) to section names
|
||||
mkSectionName ? (name: escape [ "[" "]" ] name),
|
||||
mkSectionName ? (name: libStr.escape [ "[" "]" ] name),
|
||||
# format a setting line from key and value
|
||||
mkKeyValue ? mkKeyValueDefault {} "=",
|
||||
# allow lists as values for duplicate keys
|
||||
@@ -165,8 +122,8 @@ let
|
||||
let
|
||||
# map function to string for each key val
|
||||
mapAttrsToStringsSep = sep: mapFn: attrs:
|
||||
concatStringsSep sep
|
||||
(mapAttrsToList mapFn attrs);
|
||||
libStr.concatStringsSep sep
|
||||
(libAttr.mapAttrsToList mapFn attrs);
|
||||
mkSection = sectName: sectValues: ''
|
||||
[${mkSectionName sectName}]
|
||||
'' + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues;
|
||||
@@ -207,7 +164,7 @@ let
|
||||
*/
|
||||
toINIWithGlobalSection = {
|
||||
# apply transformations (e.g. escapes) to section names
|
||||
mkSectionName ? (name: escape [ "[" "]" ] name),
|
||||
mkSectionName ? (name: libStr.escape [ "[" "]" ] name),
|
||||
# format a setting line from key and value
|
||||
mkKeyValue ? mkKeyValueDefault {} "=",
|
||||
# allow lists as values for duplicate keys
|
||||
@@ -238,11 +195,12 @@ let
|
||||
*> name = "edolstra"
|
||||
*/
|
||||
toGitINI = attrs:
|
||||
with builtins;
|
||||
let
|
||||
mkSectionName = name:
|
||||
let
|
||||
containsQuote = hasInfix ''"'' name;
|
||||
sections = splitString "." name;
|
||||
containsQuote = libStr.hasInfix ''"'' name;
|
||||
sections = libStr.splitString "." name;
|
||||
section = head sections;
|
||||
subsections = tail sections;
|
||||
subsection = concatStringsSep "." subsections;
|
||||
@@ -262,19 +220,19 @@ let
|
||||
# generation for multiple ini values
|
||||
mkKeyValue = k: v:
|
||||
let mkKeyValue = mkKeyValueDefault { inherit mkValueString; } " = " k;
|
||||
in concatStringsSep "\n" (map (kv: "\t" + mkKeyValue kv) (toList v));
|
||||
in concatStringsSep "\n" (map (kv: "\t" + mkKeyValue kv) (lib.toList v));
|
||||
|
||||
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
|
||||
gitFlattenAttrs = let
|
||||
recurse = path: value:
|
||||
if isAttrs value && !isDerivation value then
|
||||
mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value
|
||||
if isAttrs value && !lib.isDerivation value then
|
||||
lib.mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value
|
||||
else if length path > 1 then {
|
||||
${concatStringsSep "." (reverseList (tail path))}.${head path} = value;
|
||||
${concatStringsSep "." (lib.reverseList (tail path))}.${head path} = value;
|
||||
} else {
|
||||
${head path} = value;
|
||||
};
|
||||
in attrs: foldl recursiveUpdate { } (flatten (recurse [ ] attrs));
|
||||
in attrs: lib.foldl lib.recursiveUpdate { } (lib.flatten (recurse [ ] attrs));
|
||||
|
||||
toINI_ = toINI { inherit mkKeyValue mkSectionName; };
|
||||
in
|
||||
@@ -282,12 +240,25 @@ let
|
||||
|
||||
# mkKeyValueDefault wrapper that handles dconf INI quirks.
|
||||
# The main differences of the format is that it requires strings to be quoted.
|
||||
mkDconfKeyValue = mkKeyValueDefault { mkValueString = v: toString (gvariant.mkValue v); } "=";
|
||||
mkDconfKeyValue = mkKeyValueDefault { mkValueString = v: toString (lib.gvariant.mkValue v); } "=";
|
||||
|
||||
# Generates INI in dconf keyfile style. See https://help.gnome.org/admin/system-admin-guide/stable/dconf-keyfiles.html.en
|
||||
# for details.
|
||||
toDconfINI = toINI { mkKeyValue = mkDconfKeyValue; };
|
||||
|
||||
/* Generates JSON from an arbitrary (non-function) value.
|
||||
* For more information see the documentation of the builtin.
|
||||
*/
|
||||
toJSON = {}: builtins.toJSON;
|
||||
|
||||
|
||||
/* YAML has been a strict superset of JSON since 1.2, so we
|
||||
* use toJSON. Before it only had a few differences referring
|
||||
* to implicit typing rules, so it should work with older
|
||||
* parsers as well.
|
||||
*/
|
||||
toYAML = toJSON;
|
||||
|
||||
withRecursion =
|
||||
{
|
||||
/* If this option is not null, the given value will stop evaluating at a certain depth */
|
||||
@@ -295,7 +266,7 @@ let
|
||||
/* If this option is true, an error will be thrown, if a certain given depth is exceeded */
|
||||
, throwOnDepthLimit ? true
|
||||
}:
|
||||
assert isInt depthLimit;
|
||||
assert builtins.isInt depthLimit;
|
||||
let
|
||||
specialAttrs = [
|
||||
"__functor"
|
||||
@@ -304,7 +275,7 @@ let
|
||||
"__pretty"
|
||||
];
|
||||
stepIntoAttr = evalNext: name:
|
||||
if elem name specialAttrs
|
||||
if builtins.elem name specialAttrs
|
||||
then id
|
||||
else evalNext;
|
||||
transform = depth:
|
||||
@@ -313,7 +284,7 @@ let
|
||||
then throw "Exceeded maximum eval-depth limit of ${toString depthLimit} while trying to evaluate with `generators.withRecursion'!"
|
||||
else const "<unevaluated>"
|
||||
else id;
|
||||
mapAny = depth: v:
|
||||
mapAny = with builtins; depth: v:
|
||||
let
|
||||
evalNext = x: mapAny (depth + 1) (transform (depth + 1) x);
|
||||
in
|
||||
@@ -340,8 +311,9 @@ let
|
||||
indent ? ""
|
||||
}:
|
||||
let
|
||||
go = indent: v:
|
||||
let introSpace = if multiline then "\n${indent} " else " ";
|
||||
go = indent: v: with builtins;
|
||||
let isPath = v: typeOf v == "path";
|
||||
introSpace = if multiline then "\n${indent} " else " ";
|
||||
outroSpace = if multiline then "\n${indent}" else " ";
|
||||
in if isInt v then toString v
|
||||
# toString loses precision on floats, so we use toJSON instead. This isn't perfect
|
||||
@@ -350,16 +322,16 @@ let
|
||||
else if isFloat v then builtins.toJSON v
|
||||
else if isString v then
|
||||
let
|
||||
lines = filter (v: ! isList v) (split "\n" v);
|
||||
escapeSingleline = escape [ "\\" "\"" "\${" ];
|
||||
escapeMultiline = replaceStrings [ "\${" "''" ] [ "''\${" "'''" ];
|
||||
lines = filter (v: ! isList v) (builtins.split "\n" v);
|
||||
escapeSingleline = libStr.escape [ "\\" "\"" "\${" ];
|
||||
escapeMultiline = libStr.replaceStrings [ "\${" "''" ] [ "''\${" "'''" ];
|
||||
singlelineResult = "\"" + concatStringsSep "\\n" (map escapeSingleline lines) + "\"";
|
||||
multilineResult = let
|
||||
escapedLines = map escapeMultiline lines;
|
||||
# The last line gets a special treatment: if it's empty, '' is on its own line at the "outer"
|
||||
# indentation level. Otherwise, '' is appended to the last line.
|
||||
lastLine = last escapedLines;
|
||||
in "''" + introSpace + concatStringsSep introSpace (init escapedLines)
|
||||
lastLine = lib.last escapedLines;
|
||||
in "''" + introSpace + concatStringsSep introSpace (lib.init escapedLines)
|
||||
+ (if lastLine == "" then outroSpace else introSpace + lastLine) + "''";
|
||||
in
|
||||
if multiline && length lines > 1 then multilineResult else singlelineResult
|
||||
@@ -370,11 +342,11 @@ let
|
||||
else if isList v then
|
||||
if v == [] then "[ ]"
|
||||
else "[" + introSpace
|
||||
+ concatMapStringsSep introSpace (go (indent + " ")) v
|
||||
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
|
||||
+ outroSpace + "]"
|
||||
else if isFunction v then
|
||||
let fna = functionArgs v;
|
||||
showFnas = concatStringsSep ", " (mapAttrsToList
|
||||
let fna = lib.functionArgs v;
|
||||
showFnas = concatStringsSep ", " (libAttr.mapAttrsToList
|
||||
(name: hasDefVal: if hasDefVal then name + "?" else name)
|
||||
fna);
|
||||
in if fna == {} then "<function>"
|
||||
@@ -387,10 +359,10 @@ let
|
||||
else if v ? type && v.type == "derivation" then
|
||||
"<derivation ${v.name or "???"}>"
|
||||
else "{" + introSpace
|
||||
+ concatStringsSep introSpace (mapAttrsToList
|
||||
+ libStr.concatStringsSep introSpace (libAttr.mapAttrsToList
|
||||
(name: value:
|
||||
"${escapeNixIdentifier name} = ${
|
||||
addErrorContext "while evaluating an attribute `${name}`"
|
||||
"${libStr.escapeNixIdentifier name} = ${
|
||||
builtins.addErrorContext "while evaluating an attribute `${name}`"
|
||||
(go (indent + " ") value)
|
||||
};") v)
|
||||
+ outroSpace + "}"
|
||||
@@ -399,7 +371,9 @@ let
|
||||
|
||||
# PLIST handling
|
||||
toPlist = {}: v: let
|
||||
expr = ind: x:
|
||||
isFloat = builtins.isFloat or (x: false);
|
||||
isPath = x: builtins.typeOf x == "path";
|
||||
expr = ind: x: with builtins;
|
||||
if x == null then "" else
|
||||
if isBool x then bool ind x else
|
||||
if isInt x then int ind x else
|
||||
@@ -420,23 +394,23 @@ let
|
||||
|
||||
indent = ind: expr "\t${ind}";
|
||||
|
||||
item = ind: concatMapStringsSep "\n" (indent ind);
|
||||
item = ind: libStr.concatMapStringsSep "\n" (indent ind);
|
||||
|
||||
list = ind: x: concatStringsSep "\n" [
|
||||
list = ind: x: libStr.concatStringsSep "\n" [
|
||||
(literal ind "<array>")
|
||||
(item ind x)
|
||||
(literal ind "</array>")
|
||||
];
|
||||
|
||||
attrs = ind: x: concatStringsSep "\n" [
|
||||
attrs = ind: x: libStr.concatStringsSep "\n" [
|
||||
(literal ind "<dict>")
|
||||
(attr ind x)
|
||||
(literal ind "</dict>")
|
||||
];
|
||||
|
||||
attr = let attrFilter = name: value: name != "_module" && value != null;
|
||||
in ind: x: concatStringsSep "\n" (flatten (mapAttrsToList
|
||||
(name: value: optionals (attrFilter name value) [
|
||||
in ind: x: libStr.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList
|
||||
(name: value: lib.optionals (attrFilter name value) [
|
||||
(key "\t${ind}" name)
|
||||
(expr "\t${ind}" value)
|
||||
]) x));
|
||||
@@ -452,10 +426,11 @@ ${expr "" v}
|
||||
* the Natural type.
|
||||
*/
|
||||
toDhall = { }@args: v:
|
||||
let concatItems = concatStringsSep ", ";
|
||||
with builtins;
|
||||
let concatItems = lib.strings.concatStringsSep ", ";
|
||||
in if isAttrs v then
|
||||
"{ ${
|
||||
concatItems (mapAttrsToList
|
||||
concatItems (lib.attrsets.mapAttrsToList
|
||||
(key: value: "${key} = ${toDhall args value}") v)
|
||||
} }"
|
||||
else if isList v then
|
||||
@@ -469,7 +444,7 @@ ${expr "" v}
|
||||
else if v == null then
|
||||
abort "generators.toDhall: cannot convert a null to Dhall"
|
||||
else
|
||||
toJSON v;
|
||||
builtins.toJSON v;
|
||||
|
||||
/*
|
||||
Translate a simple Nix expression to Lua representation with occasional
|
||||
@@ -513,6 +488,7 @@ ${expr "" v}
|
||||
/* Interpret as variable bindings */
|
||||
asBindings ? false,
|
||||
}@args: v:
|
||||
with builtins;
|
||||
let
|
||||
innerIndent = "${indent} ";
|
||||
introSpace = if multiline then "\n${innerIndent}" else " ";
|
||||
@@ -525,9 +501,9 @@ ${expr "" v}
|
||||
isLuaInline = { _type ? null, ... }: _type == "lua-inline";
|
||||
|
||||
generatedBindings =
|
||||
assert assertMsg (badVarNames == []) "Bad Lua var names: ${toPretty {} badVarNames}";
|
||||
concatStrings (
|
||||
mapAttrsToList (key: value: "${indent}${key} = ${toLua innerArgs value}\n") v
|
||||
assert lib.assertMsg (badVarNames == []) "Bad Lua var names: ${toPretty {} badVarNames}";
|
||||
libStr.concatStrings (
|
||||
lib.attrsets.mapAttrsToList (key: value: "${indent}${key} = ${toLua innerArgs value}\n") v
|
||||
);
|
||||
|
||||
# https://en.wikibooks.org/wiki/Lua_Programming/variable#Variable_names
|
||||
@@ -539,7 +515,7 @@ ${expr "" v}
|
||||
else if v == null then
|
||||
"nil"
|
||||
else if isInt v || isFloat v || isString v || isBool v then
|
||||
toJSON v
|
||||
builtins.toJSON v
|
||||
else if isList v then
|
||||
(if v == [ ] then "{}" else
|
||||
"{${introSpace}${concatItems (map (value: "${toLua innerArgs value}") v)}${outroSpace}}")
|
||||
@@ -549,11 +525,11 @@ ${expr "" v}
|
||||
"(${v.expr})"
|
||||
else if v == { } then
|
||||
"{}"
|
||||
else if isDerivation v then
|
||||
else if libAttr.isDerivation v then
|
||||
''"${toString v}"''
|
||||
else
|
||||
"{${introSpace}${concatItems (
|
||||
mapAttrsToList (key: value: "[${toJSON key}] = ${toLua innerArgs value}") v
|
||||
lib.attrsets.mapAttrsToList (key: value: "[${builtins.toJSON key}] = ${toLua innerArgs value}") v
|
||||
)}${outroSpace}}"
|
||||
)
|
||||
else
|
||||
@@ -566,37 +542,4 @@ ${expr "" v}
|
||||
mkLuaInline :: String -> AttrSet
|
||||
*/
|
||||
mkLuaInline = expr: { _type = "lua-inline"; inherit expr; };
|
||||
|
||||
in
|
||||
|
||||
# Everything in this attrset is the public interface of the file.
|
||||
{
|
||||
inherit
|
||||
mkDconfKeyValue
|
||||
mkKeyValueDefault
|
||||
mkLuaInline
|
||||
mkValueStringDefault
|
||||
toDconfINI
|
||||
toDhall
|
||||
toGitINI
|
||||
toINI
|
||||
toINIWithGlobalSection
|
||||
toKeyValue
|
||||
toLua
|
||||
toPlist
|
||||
toPretty
|
||||
withRecursion
|
||||
;
|
||||
|
||||
/* Generates JSON from an arbitrary (non-function) value.
|
||||
* For more information see the documentation of the builtin.
|
||||
*/
|
||||
toJSON = {}: toJSON;
|
||||
|
||||
/* YAML has been a strict superset of JSON since 1.2, so we
|
||||
* use toJSON. Before it only had a few differences referring
|
||||
* to implicit typing rules, so it should work with older
|
||||
* parsers as well.
|
||||
*/
|
||||
toYAML = {}: toJSON;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf versionAtLeast versionOlder;
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -337,11 +337,6 @@ in mkLicense lset) ({
|
||||
fullName = "Creative Commons Attribution 1.0";
|
||||
};
|
||||
|
||||
cc-by-20 = {
|
||||
spdxId = "CC-BY-2.0";
|
||||
fullName = "Creative Commons Attribution 2.0";
|
||||
};
|
||||
|
||||
cc-by-30 = {
|
||||
spdxId = "CC-BY-3.0";
|
||||
fullName = "Creative Commons Attribution 3.0";
|
||||
@@ -392,12 +387,6 @@ in mkLicense lset) ({
|
||||
fullName = "Common Public Attribution License 1.0";
|
||||
};
|
||||
|
||||
commons-clause = {
|
||||
fullName = "Commons Clause License";
|
||||
url = "https://commonsclause.com/";
|
||||
free = false;
|
||||
};
|
||||
|
||||
cpl10 = {
|
||||
spdxId = "CPL-1.0";
|
||||
fullName = "Common Public License 1.0";
|
||||
@@ -418,11 +407,6 @@ in mkLicense lset) ({
|
||||
fullName = "Detection Rule License 1.0";
|
||||
};
|
||||
|
||||
dtoa = {
|
||||
spdxId = "dtoa";
|
||||
fullName = "dtoa License";
|
||||
};
|
||||
|
||||
eapl = {
|
||||
fullName = "EPSON AVASYS PUBLIC LICENSE";
|
||||
url = "https://avasys.jp/hp/menu000000700/hpg000000603.htm";
|
||||
@@ -605,11 +589,6 @@ in mkLicense lset) ({
|
||||
url = "https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception";
|
||||
};
|
||||
|
||||
giftware = {
|
||||
spdxId = "Giftware";
|
||||
fullName = "Giftware License";
|
||||
};
|
||||
|
||||
hpnd = {
|
||||
spdxId = "HPND";
|
||||
fullName = "Historic Permission Notice and Disclaimer";
|
||||
@@ -620,11 +599,6 @@ in mkLicense lset) ({
|
||||
spdxId = "HPND-sell-variant";
|
||||
};
|
||||
|
||||
hpndUc = {
|
||||
spdxId = "HPND-UC";
|
||||
fullName = "Historical Permission Notice and Disclaimer - University of California variant";
|
||||
};
|
||||
|
||||
# Intel's license, seems free
|
||||
iasl = {
|
||||
spdxId = "Intel-ACPI";
|
||||
@@ -875,11 +849,6 @@ in mkLicense lset) ({
|
||||
fullName = "Mozilla Public License 2.0";
|
||||
};
|
||||
|
||||
mplus = {
|
||||
spdxId = "mplus";
|
||||
fullName = "M+ Font License";
|
||||
};
|
||||
|
||||
mspl = {
|
||||
spdxId = "MS-PL";
|
||||
fullName = "Microsoft Public License";
|
||||
@@ -910,11 +879,6 @@ in mkLicense lset) ({
|
||||
url = "https://raw.githubusercontent.com/netdata/netdata/master/web/gui/v2/LICENSE.md";
|
||||
};
|
||||
|
||||
nistSoftware = {
|
||||
spdxId = "NIST-Software";
|
||||
fullName = "NIST Software License";
|
||||
};
|
||||
|
||||
nlpl = {
|
||||
spdxId = "NLPL";
|
||||
fullName = "No Limit Public License";
|
||||
@@ -1092,11 +1056,6 @@ in mkLicense lset) ({
|
||||
url = "https://sources.debian.org/copyright/license/debianutils/4.9.1/";
|
||||
};
|
||||
|
||||
smlnj = {
|
||||
spdxId = "SMLNJ";
|
||||
fullName = "Standard ML of New Jersey License";
|
||||
};
|
||||
|
||||
sspl = {
|
||||
shortName = "SSPL";
|
||||
fullName = "Server Side Public License";
|
||||
@@ -1246,11 +1205,6 @@ in mkLicense lset) ({
|
||||
url = "https://mcj.sourceforge.net/authors.html#xfig";
|
||||
};
|
||||
|
||||
xinetd = {
|
||||
spdxId = "xinetd";
|
||||
fullName = "xinetd License";
|
||||
};
|
||||
|
||||
zlib = {
|
||||
spdxId = "Zlib";
|
||||
fullName = "zlib License";
|
||||
@@ -1265,13 +1219,13 @@ in mkLicense lset) ({
|
||||
spdxId = "ZPL-2.1";
|
||||
fullName = "Zope Public License 2.1";
|
||||
};
|
||||
|
||||
xskat = {
|
||||
spdxId = "XSkat";
|
||||
fullName = "XSkat License";
|
||||
};
|
||||
} // {
|
||||
# TODO: remove legacy aliases
|
||||
agpl3 = {
|
||||
spdxId = "AGPL-3.0";
|
||||
fullName = "GNU Affero General Public License v3.0";
|
||||
deprecated = true;
|
||||
};
|
||||
gpl2 = {
|
||||
spdxId = "GPL-2.0";
|
||||
fullName = "GNU General Public License v2.0";
|
||||
|
||||
1741
lib/lists.nix
1741
lib/lists.nix
File diff suppressed because it is too large
Load Diff
@@ -87,10 +87,6 @@ rec {
|
||||
|
||||
We can inject these into a pattern for the whole of a structured platform,
|
||||
and then match that.
|
||||
|
||||
Example:
|
||||
lib.meta.platformMatch { system = "aarch64-darwin"; } "aarch64-darwin"
|
||||
=> true
|
||||
*/
|
||||
platformMatch = platform: elem: (
|
||||
# Check with simple string comparison if elem was a string.
|
||||
@@ -116,10 +112,6 @@ rec {
|
||||
platform, or `meta.platforms` is not present.
|
||||
|
||||
2. None of `meta.badPlatforms` pattern matches the given platform.
|
||||
|
||||
Example:
|
||||
lib.meta.availableOn { system = "aarch64-darwin"; } pkg.zsh
|
||||
=> true
|
||||
*/
|
||||
availableOn = platform: pkg:
|
||||
((!pkg?meta.platforms) || any (platformMatch platform) pkg.meta.platforms) &&
|
||||
|
||||
@@ -81,9 +81,9 @@ let
|
||||
, # `class`:
|
||||
# A nominal type for modules. When set and non-null, this adds a check to
|
||||
# make sure that only compatible modules are imported.
|
||||
# This would be remove in the future, Prefer _module.args option instead.
|
||||
class ? null
|
||||
, # This would be remove in the future, Prefer _module.args option instead.
|
||||
args ? {}
|
||||
, args ? {}
|
||||
, # This would be remove in the future, Prefer _module.check option instead.
|
||||
check ? true
|
||||
}:
|
||||
@@ -1256,78 +1256,7 @@ let
|
||||
(opt.highestPrio or defaultOverridePriority)
|
||||
(f opt.value);
|
||||
|
||||
/*
|
||||
Return a module that help declares an option that has been renamed.
|
||||
When a value is defined for the old option, it is forwarded to the `to` option.
|
||||
*/
|
||||
doRename = {
|
||||
# List of strings representing the attribute path of the old option.
|
||||
from,
|
||||
# List of strings representing the attribute path of the new option.
|
||||
to,
|
||||
# Boolean, whether the old option is to be included in documentation.
|
||||
visible,
|
||||
# Whether to warn when a value is defined for the old option.
|
||||
# NOTE: This requires the NixOS assertions module to be imported, so
|
||||
# - this generally does not work in submodules
|
||||
# - this may or may not work outside NixOS
|
||||
warn,
|
||||
# A function that is applied to the option value, to form the value
|
||||
# of the old `from` option.
|
||||
#
|
||||
# For example, the identity function can be passed, to return the option value unchanged.
|
||||
# ```nix
|
||||
# use = x: x;
|
||||
# ```
|
||||
#
|
||||
# To add a warning, you can pass the partially applied `warn` function.
|
||||
# ```nix
|
||||
# use = lib.warn "Obsolete option `${opt.old}' is used. Use `${opt.to}' instead.";
|
||||
# ```
|
||||
use,
|
||||
# Legacy option, enabled by default: whether to preserve the priority of definitions in `old`.
|
||||
withPriority ? true,
|
||||
# A boolean that defines the `mkIf` condition for `to`.
|
||||
# If the condition evaluates to `true`, and the `to` path points into an
|
||||
# `attrsOf (submodule ...)`, then `doRename` would cause an empty module to
|
||||
# be created, even if the `from` option is undefined.
|
||||
# By setting this to an expression that may return `false`, you can inhibit
|
||||
# this undesired behavior.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# ```nix
|
||||
# { config, lib, ... }:
|
||||
# let
|
||||
# inherit (lib) mkOption mkEnableOption types doRename;
|
||||
# in
|
||||
# {
|
||||
# options = {
|
||||
#
|
||||
# # Old service
|
||||
# services.foo.enable = mkEnableOption "foo";
|
||||
#
|
||||
# # New multi-instance service
|
||||
# services.foos = mkOption {
|
||||
# type = types.attrsOf (types.submodule …);
|
||||
# };
|
||||
# };
|
||||
# imports = [
|
||||
# (doRename {
|
||||
# from = [ "services" "foo" "bar" ];
|
||||
# to = [ "services" "foos" "" "bar" ];
|
||||
# visible = true;
|
||||
# warn = false;
|
||||
# use = x: x;
|
||||
# withPriority = true;
|
||||
# # Only define services.foos."" if needed. (It's not just about `bar`)
|
||||
# condition = config.services.foo.enable;
|
||||
# })
|
||||
# ];
|
||||
# }
|
||||
# ```
|
||||
condition ? true
|
||||
}:
|
||||
doRename = { from, to, visible, warn, use, withPriority ? true }:
|
||||
{ config, options, ... }:
|
||||
let
|
||||
fromOpt = getAttrFromPath from options;
|
||||
@@ -1343,7 +1272,7 @@ let
|
||||
} // optionalAttrs (toType != null) {
|
||||
type = toType;
|
||||
});
|
||||
config = mkIf condition (mkMerge [
|
||||
config = mkMerge [
|
||||
(optionalAttrs (options ? warnings) {
|
||||
warnings = optional (warn && fromOpt.isDefined)
|
||||
"The option `${showOption from}' defined in ${showFiles fromOpt.files} has been renamed to `${showOption to}'.";
|
||||
@@ -1351,7 +1280,7 @@ let
|
||||
(if withPriority
|
||||
then mkAliasAndWrapDefsWithPriority (setAttrByPath to) fromOpt
|
||||
else mkAliasAndWrapDefinitions (setAttrByPath to) fromOpt)
|
||||
]);
|
||||
];
|
||||
};
|
||||
|
||||
/* Use this function to import a JSON file as NixOS configuration.
|
||||
|
||||
@@ -254,31 +254,13 @@ rec {
|
||||
else if all isInt list && all (x: x == head list) list then head list
|
||||
else throw "Cannot merge definitions of `${showOption loc}'. Definition values:${showDefs defs}";
|
||||
|
||||
/*
|
||||
Require a single definition.
|
||||
|
||||
WARNING: Does not perform nested checks, as this does not run the merge function!
|
||||
*/
|
||||
mergeOneOption = mergeUniqueOption { message = ""; };
|
||||
|
||||
/*
|
||||
Require a single definition.
|
||||
|
||||
NOTE: When the type is not checked completely by check, pass a merge function for further checking (of sub-attributes, etc).
|
||||
*/
|
||||
mergeUniqueOption = args@{
|
||||
message,
|
||||
# WARNING: the default merge function assumes that the definition is a valid (option) value. You MUST pass a merge function if the return value needs to be
|
||||
# - type checked beyond what .check does (which should be very litte; only on the value head; not attribute values, etc)
|
||||
# - if you want attribute values to be checked, or list items
|
||||
# - if you want coercedTo-like behavior to work
|
||||
merge ? loc: defs: (head defs).value }:
|
||||
loc: defs:
|
||||
if length defs == 1
|
||||
then merge loc defs
|
||||
else
|
||||
assert length defs > 1;
|
||||
throw "The option `${showOption loc}' is defined multiple times while it's expected to be unique.\n${message}\nDefinition values:${showDefs defs}\n${prioritySuggestion}";
|
||||
mergeUniqueOption = { message }: loc: defs:
|
||||
if length defs == 1
|
||||
then (head defs).value
|
||||
else assert length defs > 1;
|
||||
throw "The option `${showOption loc}' is defined multiple times while it's expected to be unique.\n${message}\nDefinition values:${showDefs defs}\n${prioritySuggestion}";
|
||||
|
||||
/* "Merge" option definitions by checking that they all have the same value. */
|
||||
mergeEqualOption = loc: defs:
|
||||
@@ -397,7 +379,7 @@ rec {
|
||||
if ! isString text then throw "literalExpression expects a string."
|
||||
else { _type = "literalExpression"; inherit text; };
|
||||
|
||||
literalExample = lib.warn "lib.literalExample is deprecated, use lib.literalExpression instead, or use lib.literalMD for a non-Nix description." literalExpression;
|
||||
literalExample = lib.warn "literalExample is deprecated, use literalExpression instead, or use literalMD for a non-Nix description." literalExpression;
|
||||
|
||||
/* Transition marker for documentation that's already migrated to markdown
|
||||
syntax. This is a no-op and no longer needed.
|
||||
|
||||
@@ -95,7 +95,8 @@ rec {
|
||||
concatStringsSep "/" ["usr" "local" "bin"]
|
||||
=> "usr/local/bin"
|
||||
*/
|
||||
concatStringsSep = builtins.concatStringsSep;
|
||||
concatStringsSep = builtins.concatStringsSep or (separator: list:
|
||||
lib.foldl' (x: y: x + y) "" (intersperse separator list));
|
||||
|
||||
/* Maps a function over a list of strings and then concatenates the
|
||||
result with the specified separator interspersed between
|
||||
@@ -560,7 +561,7 @@ rec {
|
||||
[""" "'" "<" ">" "&"];
|
||||
|
||||
# warning added 12-12-2022
|
||||
replaceChars = lib.warn "lib.replaceChars is a deprecated alias of lib.replaceStrings." builtins.replaceStrings;
|
||||
replaceChars = lib.warn "replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings." builtins.replaceStrings;
|
||||
|
||||
# Case conversion utilities.
|
||||
lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
|
||||
@@ -1038,32 +1039,30 @@ rec {
|
||||
toInt "3.14"
|
||||
=> error: floating point JSON numbers are not supported
|
||||
*/
|
||||
toInt =
|
||||
let
|
||||
matchStripInput = match "[[:space:]]*(-?[[:digit:]]+)[[:space:]]*";
|
||||
matchLeadingZero = match "0[[:digit:]]+";
|
||||
in
|
||||
str:
|
||||
toInt = str:
|
||||
let
|
||||
# RegEx: Match any leading whitespace, possibly a '-', one or more digits,
|
||||
# and finally match any trailing whitespace.
|
||||
strippedInput = matchStripInput str;
|
||||
strippedInput = match "[[:space:]]*(-?[[:digit:]]+)[[:space:]]*" str;
|
||||
|
||||
# RegEx: Match a leading '0' then one or more digits.
|
||||
isLeadingZero = matchLeadingZero (head strippedInput) == [];
|
||||
isLeadingZero = match "0[[:digit:]]+" (head strippedInput) == [];
|
||||
|
||||
# Attempt to parse input
|
||||
parsedInput = fromJSON (head strippedInput);
|
||||
|
||||
generalError = "toInt: Could not convert ${escapeNixString str} to int.";
|
||||
|
||||
octalAmbigError = "toInt: Ambiguity in interpretation of ${escapeNixString str}"
|
||||
+ " between octal and zero padded integer.";
|
||||
|
||||
in
|
||||
# Error on presence of non digit characters.
|
||||
if strippedInput == null
|
||||
then throw generalError
|
||||
# Error on presence of leading zero/octal ambiguity.
|
||||
else if isLeadingZero
|
||||
then throw "toInt: Ambiguity in interpretation of ${escapeNixString str} between octal and zero padded integer."
|
||||
then throw octalAmbigError
|
||||
# Error if parse function fails.
|
||||
else if !isInt parsedInput
|
||||
then throw generalError
|
||||
@@ -1091,20 +1090,15 @@ rec {
|
||||
toIntBase10 "3.14"
|
||||
=> error: floating point JSON numbers are not supported
|
||||
*/
|
||||
toIntBase10 =
|
||||
let
|
||||
matchStripInput = match "[[:space:]]*0*(-?[[:digit:]]+)[[:space:]]*";
|
||||
matchZero = match "0+";
|
||||
in
|
||||
str:
|
||||
toIntBase10 = str:
|
||||
let
|
||||
# RegEx: Match any leading whitespace, then match any zero padding,
|
||||
# capture possibly a '-' followed by one or more digits,
|
||||
# and finally match any trailing whitespace.
|
||||
strippedInput = matchStripInput str;
|
||||
strippedInput = match "[[:space:]]*0*(-?[[:digit:]]+)[[:space:]]*" str;
|
||||
|
||||
# RegEx: Match at least one '0'.
|
||||
isZero = matchZero (head strippedInput) == [];
|
||||
isZero = match "0+" (head strippedInput) == [];
|
||||
|
||||
# Attempt to parse input
|
||||
parsedInput = fromJSON (head strippedInput);
|
||||
@@ -1139,7 +1133,7 @@ rec {
|
||||
"/prefix/nix-profiles-library-paths.patch"
|
||||
"/prefix/compose-search-path.patch" ]
|
||||
*/
|
||||
readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead."
|
||||
readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead"
|
||||
(rootPath: file:
|
||||
let
|
||||
lines = lib.splitString "\n" (readFile file);
|
||||
|
||||
@@ -1,25 +1,7 @@
|
||||
{ lib }:
|
||||
let inherit (lib.attrsets) mapAttrs; in
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
any
|
||||
filterAttrs
|
||||
foldl
|
||||
hasInfix
|
||||
isFunction
|
||||
isList
|
||||
isString
|
||||
mapAttrs
|
||||
optional
|
||||
optionalAttrs
|
||||
optionalString
|
||||
removeSuffix
|
||||
replaceStrings
|
||||
toUpper
|
||||
;
|
||||
|
||||
inherit (lib.strings) toJSON;
|
||||
|
||||
rec {
|
||||
doubles = import ./doubles.nix { inherit lib; };
|
||||
parse = import ./parse.nix { inherit lib; };
|
||||
inspect = import ./inspect.nix { inherit lib; };
|
||||
@@ -42,7 +24,7 @@ let
|
||||
both arguments have been `elaborate`-d.
|
||||
*/
|
||||
equals =
|
||||
let removeFunctions = a: filterAttrs (_: v: !isFunction v) a;
|
||||
let removeFunctions = a: lib.filterAttrs (_: v: !builtins.isFunction v) a;
|
||||
in a: b: removeFunctions a == removeFunctions b;
|
||||
|
||||
/* List of all Nix system doubles the nixpkgs flake will expose the package set
|
||||
@@ -59,7 +41,7 @@ let
|
||||
# clearly preferred, and to prevent cycles. A simpler fixed point where the RHS
|
||||
# always just used `final.*` would fail on both counts.
|
||||
elaborate = args': let
|
||||
args = if isString args' then { system = args'; }
|
||||
args = if lib.isString args' then { system = args'; }
|
||||
else args';
|
||||
|
||||
# TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL.
|
||||
@@ -114,7 +96,7 @@ let
|
||||
then "lib64"
|
||||
else "lib"
|
||||
else null;
|
||||
extensions = optionalAttrs final.hasSharedLibraries {
|
||||
extensions = lib.optionalAttrs final.hasSharedLibraries {
|
||||
sharedLibrary =
|
||||
if final.isDarwin then ".dylib"
|
||||
else if final.isWindows then ".dll"
|
||||
@@ -152,9 +134,9 @@ let
|
||||
# uname -m
|
||||
processor =
|
||||
if final.isPower64
|
||||
then "ppc64${optionalString final.isLittleEndian "le"}"
|
||||
then "ppc64${lib.optionalString final.isLittleEndian "le"}"
|
||||
else if final.isPower
|
||||
then "ppc${optionalString final.isLittleEndian "le"}"
|
||||
then "ppc${lib.optionalString final.isLittleEndian "le"}"
|
||||
else if final.isMips64
|
||||
then "mips64" # endianness is *not* included on mips64
|
||||
else final.parsed.cpu.name;
|
||||
@@ -220,8 +202,8 @@ let
|
||||
else if final.isS390 && !final.isS390x then null
|
||||
else if final.isx86_64 then "x86_64"
|
||||
else if final.isx86 then "i386"
|
||||
else if final.isMips64n32 then "mipsn32${optionalString final.isLittleEndian "el"}"
|
||||
else if final.isMips64 then "mips64${optionalString final.isLittleEndian "el"}"
|
||||
else if final.isMips64n32 then "mipsn32${lib.optionalString final.isLittleEndian "el"}"
|
||||
else if final.isMips64 then "mips64${lib.optionalString final.isLittleEndian "el"}"
|
||||
else final.uname.processor;
|
||||
|
||||
# Name used by UEFI for architectures.
|
||||
@@ -261,14 +243,10 @@ let
|
||||
vncSupport = false;
|
||||
gtkSupport = false;
|
||||
sdlSupport = false;
|
||||
alsaSupport = false;
|
||||
pulseSupport = false;
|
||||
pipewireSupport = false;
|
||||
jackSupport = false;
|
||||
smbdSupport = false;
|
||||
seccompSupport = false;
|
||||
tpmSupport = false;
|
||||
capstoneSupport = false;
|
||||
enableDocs = false;
|
||||
hostCpuTargets = [ "${final.qemuArch}-linux-user" ];
|
||||
};
|
||||
@@ -277,7 +255,7 @@ let
|
||||
if pkgs.stdenv.hostPlatform.canExecute final
|
||||
then "${pkgs.runtimeShell} -c '\"$@\"' --"
|
||||
else if final.isWindows
|
||||
then "${wine}/bin/wine${optionalString (final.parsed.cpu.bits == 64) "64"}"
|
||||
then "${wine}/bin/wine${lib.optionalString (final.parsed.cpu.bits == 64) "64"}"
|
||||
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux && final.qemuArch != null
|
||||
then "${qemu-user}/bin/qemu-${final.qemuArch}"
|
||||
else if final.isWasi
|
||||
@@ -328,10 +306,10 @@ let
|
||||
let
|
||||
f = args.rustc.platform.target-family;
|
||||
in
|
||||
if isList f then f else [ f ]
|
||||
if builtins.isList f then f else [ f ]
|
||||
)
|
||||
else optional final.isUnix "unix"
|
||||
++ optional final.isWindows "windows";
|
||||
else lib.optional final.isUnix "unix"
|
||||
++ lib.optional final.isWindows "windows";
|
||||
|
||||
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_vendor
|
||||
vendor = let
|
||||
@@ -355,13 +333,13 @@ let
|
||||
vendor_ = final.rust.platform.vendor;
|
||||
# TODO: deprecate args.rustc in favour of args.rust after 23.05 is EOL.
|
||||
in args.rust.rustcTarget or args.rustc.config
|
||||
or "${cpu_}-${vendor_}-${kernel.name}${optionalString (abi.name != "unknown") "-${abi.name}"}";
|
||||
or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
|
||||
|
||||
# The name of the rust target if it is standard, or the json file
|
||||
# containing the custom target spec.
|
||||
rustcTargetSpec = rust.rustcTargetSpec or (
|
||||
/**/ if rust ? platform
|
||||
then builtins.toFile (final.rust.rustcTarget + ".json") (toJSON rust.platform)
|
||||
then builtins.toFile (final.rust.rustcTarget + ".json") (builtins.toJSON rust.platform)
|
||||
else final.rust.rustcTarget);
|
||||
|
||||
# The name of the rust target if it is standard, or the
|
||||
@@ -370,7 +348,7 @@ let
|
||||
#
|
||||
# This is the name used by Cargo for target subdirectories.
|
||||
cargoShortTarget =
|
||||
removeSuffix ".json" (baseNameOf "${final.rust.rustcTargetSpec}");
|
||||
lib.removeSuffix ".json" (baseNameOf "${final.rust.rustcTargetSpec}");
|
||||
|
||||
# When used as part of an environment variable name, triples are
|
||||
# uppercased and have all hyphens replaced by underscores:
|
||||
@@ -378,17 +356,17 @@ let
|
||||
# https://github.com/rust-lang/cargo/pull/9169
|
||||
# https://github.com/rust-lang/cargo/issues/8285#issuecomment-634202431
|
||||
cargoEnvVarTarget =
|
||||
replaceStrings ["-"] ["_"]
|
||||
(toUpper final.rust.cargoShortTarget);
|
||||
lib.strings.replaceStrings ["-"] ["_"]
|
||||
(lib.strings.toUpper final.rust.cargoShortTarget);
|
||||
|
||||
# True if the target is no_std
|
||||
# https://github.com/rust-lang/rust/blob/2e44c17c12cec45b6a682b1e53a04ac5b5fcc9d2/src/bootstrap/config.rs#L415-L421
|
||||
isNoStdTarget =
|
||||
any (t: hasInfix t final.rust.rustcTarget) ["-none" "nvptx" "switch" "-uefi"];
|
||||
builtins.any (t: lib.hasInfix t final.rust.rustcTarget) ["-none" "nvptx" "switch" "-uefi"];
|
||||
};
|
||||
};
|
||||
in assert final.useAndroidPrebuilt -> final.isAndroid;
|
||||
assert foldl
|
||||
assert lib.foldl
|
||||
(pass: { assertion, message }:
|
||||
if assertion final
|
||||
then pass
|
||||
@@ -396,20 +374,4 @@ let
|
||||
true
|
||||
(final.parsed.abi.assertions or []);
|
||||
final;
|
||||
|
||||
in
|
||||
|
||||
# Everything in this attrset is the public interface of the file.
|
||||
{
|
||||
inherit
|
||||
architectures
|
||||
doubles
|
||||
elaborate
|
||||
equals
|
||||
examples
|
||||
flakeExposed
|
||||
inspect
|
||||
parse
|
||||
platforms
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,10 @@
|
||||
{ lib }:
|
||||
with import ./parse.nix { inherit lib; };
|
||||
with lib.attrsets;
|
||||
with lib.lists;
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
any
|
||||
attrValues
|
||||
concatMap
|
||||
filter
|
||||
hasPrefix
|
||||
isList
|
||||
mapAttrs
|
||||
matchAttrs
|
||||
recursiveUpdateUntil
|
||||
toList
|
||||
;
|
||||
|
||||
inherit (lib.strings) toJSON;
|
||||
|
||||
inherit (lib.systems.parse)
|
||||
kernels
|
||||
kernelFamilies
|
||||
significantBytes
|
||||
cpuTypes
|
||||
execFormats
|
||||
;
|
||||
|
||||
abis = mapAttrs (_: abi: removeAttrs abi [ "assertions" ]) lib.systems.parse.abis;
|
||||
in
|
||||
let abis_ = abis; in
|
||||
let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in
|
||||
|
||||
rec {
|
||||
# these patterns are to be matched against {host,build,target}Platform.parsed
|
||||
@@ -53,8 +32,8 @@ rec {
|
||||
isx86 = { cpu = { family = "x86"; }; };
|
||||
isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
|
||||
isArmv7 = map ({ arch, ... }: { cpu = { inherit arch; }; })
|
||||
(filter (cpu: hasPrefix "armv7" cpu.arch or "")
|
||||
(attrValues cpuTypes));
|
||||
(lib.filter (cpu: lib.hasPrefix "armv7" cpu.arch or "")
|
||||
(lib.attrValues cpuTypes));
|
||||
isAarch64 = { cpu = { family = "arm"; bits = 64; }; };
|
||||
isAarch = { cpu = { family = "arm"; }; };
|
||||
isMicroBlaze = { cpu = { family = "microblaze"; }; };
|
||||
@@ -69,7 +48,6 @@ rec {
|
||||
isRiscV64 = { cpu = { family = "riscv"; bits = 64; }; };
|
||||
isRx = { cpu = { family = "rx"; }; };
|
||||
isSparc = { cpu = { family = "sparc"; }; };
|
||||
isSparc64 = { cpu = { family = "sparc"; bits = 64; }; };
|
||||
isWasm = { cpu = { family = "wasm"; }; };
|
||||
isMsp430 = { cpu = { family = "msp430"; }; };
|
||||
isVc4 = { cpu = { family = "vc4"; }; };
|
||||
@@ -132,19 +110,19 @@ rec {
|
||||
let
|
||||
# patterns can be either a list or a (bare) singleton; turn
|
||||
# them into singletons for uniform handling
|
||||
pat1 = toList pat1_;
|
||||
pat2 = toList pat2_;
|
||||
pat1 = lib.toList pat1_;
|
||||
pat2 = lib.toList pat2_;
|
||||
in
|
||||
concatMap (attr1:
|
||||
lib.concatMap (attr1:
|
||||
map (attr2:
|
||||
recursiveUpdateUntil
|
||||
lib.recursiveUpdateUntil
|
||||
(path: subattr1: subattr2:
|
||||
if (builtins.intersectAttrs subattr1 subattr2) == {} || subattr1 == subattr2
|
||||
then true
|
||||
else throw ''
|
||||
pattern conflict at path ${toString path}:
|
||||
${toJSON subattr1}
|
||||
${toJSON subattr2}
|
||||
${builtins.toJSON subattr1}
|
||||
${builtins.toJSON subattr2}
|
||||
'')
|
||||
attr1
|
||||
attr2
|
||||
@@ -153,7 +131,7 @@ rec {
|
||||
pat1;
|
||||
|
||||
matchAnyAttrs = patterns:
|
||||
if isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
|
||||
if builtins.isList patterns then attrs: any (pattern: matchAttrs pattern attrs) patterns
|
||||
else matchAttrs patterns;
|
||||
|
||||
predicates = mapAttrs (_: matchAnyAttrs) patterns;
|
||||
|
||||
@@ -15,45 +15,14 @@
|
||||
# systems that overlap with existing ones and won't notice something amiss.
|
||||
#
|
||||
{ lib }:
|
||||
with lib.lists;
|
||||
with lib.types;
|
||||
with lib.attrsets;
|
||||
with lib.strings;
|
||||
with (import ./inspect.nix { inherit lib; }).predicates;
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
all
|
||||
any
|
||||
attrValues
|
||||
elem
|
||||
elemAt
|
||||
hasPrefix
|
||||
id
|
||||
length
|
||||
mapAttrs
|
||||
mergeOneOption
|
||||
optionalString
|
||||
splitString
|
||||
versionAtLeast
|
||||
;
|
||||
|
||||
inherit (lib.strings) match;
|
||||
|
||||
inherit (lib.systems.inspect.predicates)
|
||||
isAarch32
|
||||
isBigEndian
|
||||
isDarwin
|
||||
isLinux
|
||||
isPower64
|
||||
isWindows
|
||||
;
|
||||
|
||||
inherit (lib.types)
|
||||
enum
|
||||
float
|
||||
isType
|
||||
mkOptionType
|
||||
number
|
||||
setType
|
||||
string
|
||||
types
|
||||
;
|
||||
inherit (lib.options) mergeOneOption;
|
||||
|
||||
setTypes = type:
|
||||
mapAttrs (name: value:
|
||||
@@ -64,10 +33,10 @@ let
|
||||
# regex `e?abi.*$` when determining the validity of a triple. In
|
||||
# other words, `i386-linuxabichickenlips` is a valid triple.
|
||||
removeAbiSuffix = x:
|
||||
let found = match "(.*)e?abi.*" x;
|
||||
in if found == null
|
||||
let match = builtins.match "(.*)e?abi.*" x;
|
||||
in if match==null
|
||||
then x
|
||||
else elemAt found 0;
|
||||
else lib.elemAt match 0;
|
||||
|
||||
in
|
||||
|
||||
@@ -107,7 +76,7 @@ rec {
|
||||
|
||||
types.cpuType = enum (attrValues cpuTypes);
|
||||
|
||||
cpuTypes = let inherit (significantBytes) bigEndian littleEndian; in setTypes types.openCpuType {
|
||||
cpuTypes = with significantBytes; setTypes types.openCpuType {
|
||||
arm = { bits = 32; significantByte = littleEndian; family = "arm"; };
|
||||
armv5tel = { bits = 32; significantByte = littleEndian; family = "arm"; version = "5"; arch = "armv5t"; };
|
||||
armv6m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "6"; arch = "armv6-m"; };
|
||||
@@ -197,7 +166,7 @@ rec {
|
||||
# Note: Since 22.11 the archs of a mode switching CPU are no longer considered
|
||||
# pairwise compatible. Mode switching implies that binaries built for A
|
||||
# and B respectively can't be executed at the same time.
|
||||
isCompatible = with cpuTypes; a: b: any id [
|
||||
isCompatible = a: b: with cpuTypes; lib.any lib.id [
|
||||
# x86
|
||||
(b == i386 && isCompatible a i486)
|
||||
(b == i486 && isCompatible a i586)
|
||||
@@ -318,10 +287,7 @@ rec {
|
||||
|
||||
types.kernel = enum (attrValues kernels);
|
||||
|
||||
kernels = let
|
||||
inherit (execFormats) elf pe wasm unknown macho;
|
||||
inherit (kernelFamilies) bsd darwin;
|
||||
in setTypes types.openKernel {
|
||||
kernels = with execFormats; with kernelFamilies; setTypes types.openKernel {
|
||||
# TODO(@Ericson2314): Don't want to mass-rebuild yet to keeping 'darwin' as
|
||||
# the normalized name for macOS.
|
||||
macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; };
|
||||
@@ -393,7 +359,7 @@ rec {
|
||||
The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead.
|
||||
'';
|
||||
}
|
||||
{ assertion = platform: !(platform.isPower64 && platform.isBigEndian);
|
||||
{ assertion = platform: with platform; !(isPower64 && isBigEndian);
|
||||
message = ''
|
||||
The "gnu" ABI is ambiguous on big-endian 64-bit PowerPC. Use "gnuabielfv2" or "gnuabielfv1" instead.
|
||||
'';
|
||||
@@ -514,7 +480,7 @@ rec {
|
||||
/**/ if args ? abi then getAbi args.abi
|
||||
else if isLinux parsed || isWindows parsed then
|
||||
if isAarch32 parsed then
|
||||
if versionAtLeast (parsed.cpu.version or "0") "6"
|
||||
if lib.versionAtLeast (parsed.cpu.version or "0") "6"
|
||||
then abis.gnueabihf
|
||||
else abis.gnueabi
|
||||
# Default ppc64 BE to ELFv2
|
||||
@@ -525,7 +491,7 @@ rec {
|
||||
|
||||
in mkSystem parsed;
|
||||
|
||||
mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (splitString "-" s));
|
||||
mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
|
||||
|
||||
kernelName = kernel:
|
||||
kernel.name + toString (kernel.version or "");
|
||||
@@ -537,10 +503,10 @@ rec {
|
||||
|
||||
tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let
|
||||
optExecFormat =
|
||||
optionalString (kernel.name == "netbsd" &&
|
||||
lib.optionalString (kernel.name == "netbsd" &&
|
||||
gnuNetBSDDefaultExecFormat cpu != kernel.execFormat)
|
||||
kernel.execFormat.name;
|
||||
optAbi = optionalString (abi != abis.unknown) "-${abi.name}";
|
||||
optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";
|
||||
in "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}";
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -13,96 +13,9 @@ Alternatively, to run all `lib` tests:
|
||||
|
||||
[nixpkgs]$ nix-build lib/tests/release.nix
|
||||
*/
|
||||
with import ../default.nix;
|
||||
|
||||
let
|
||||
lib = import ../default.nix;
|
||||
|
||||
inherit (lib)
|
||||
allUnique
|
||||
and
|
||||
attrNames
|
||||
attrsets
|
||||
attrsToList
|
||||
bitAnd
|
||||
bitOr
|
||||
bitXor
|
||||
boolToString
|
||||
callPackagesWith
|
||||
callPackageWith
|
||||
cartesianProductOfSets
|
||||
cli
|
||||
composeExtensions
|
||||
composeManyExtensions
|
||||
concatLines
|
||||
concatMapAttrs
|
||||
concatMapStrings
|
||||
concatStrings
|
||||
concatStringsSep
|
||||
const
|
||||
escapeXML
|
||||
evalModules
|
||||
filter
|
||||
fix
|
||||
fold
|
||||
foldAttrs
|
||||
foldl
|
||||
foldl'
|
||||
foldlAttrs
|
||||
foldr
|
||||
functionArgs
|
||||
generators
|
||||
genList
|
||||
getExe
|
||||
getExe'
|
||||
groupBy
|
||||
groupBy'
|
||||
hasAttrByPath
|
||||
hasInfix
|
||||
id
|
||||
isStorePath
|
||||
lazyDerivation
|
||||
lists
|
||||
listToAttrs
|
||||
makeExtensible
|
||||
makeOverridable
|
||||
mapAttrs
|
||||
matchAttrs
|
||||
mergeAttrs
|
||||
meta
|
||||
mkOption
|
||||
mod
|
||||
nameValuePair
|
||||
optionalDrvAttr
|
||||
optionAttrSetToDocList
|
||||
overrideExisting
|
||||
packagesFromDirectoryRecursive
|
||||
pipe
|
||||
range
|
||||
recursiveUpdateUntil
|
||||
removePrefix
|
||||
replicate
|
||||
runTests
|
||||
setFunctionArgs
|
||||
showAttrPath
|
||||
sort
|
||||
sortOn
|
||||
stringLength
|
||||
strings
|
||||
stringToCharacters
|
||||
systems
|
||||
tail
|
||||
take
|
||||
testAllTrue
|
||||
toBaseDigits
|
||||
toHexString
|
||||
toInt
|
||||
toIntBase10
|
||||
toShellVars
|
||||
types
|
||||
updateManyAttrsByPath
|
||||
versions
|
||||
;
|
||||
|
||||
testingThrow = expr: {
|
||||
expr = (builtins.tryEval (builtins.seq expr "didn't throw"));
|
||||
expected = { success = false; value = false; };
|
||||
@@ -142,24 +55,6 @@ runTests {
|
||||
expected = { a = false; b = false; c = true; };
|
||||
};
|
||||
|
||||
testCallPackageWithOverridePreservesArguments =
|
||||
let
|
||||
f = { a ? 0, b }: {};
|
||||
f' = callPackageWith { a = 1; b = 2; } f {};
|
||||
in {
|
||||
expr = functionArgs f'.override;
|
||||
expected = functionArgs f;
|
||||
};
|
||||
|
||||
testCallPackagesWithOverridePreservesArguments =
|
||||
let
|
||||
f = { a ? 0, b }: { nested = {}; };
|
||||
f' = callPackagesWith { a = 1; b = 2; } f {};
|
||||
in {
|
||||
expr = functionArgs f'.nested.override;
|
||||
expected = functionArgs f;
|
||||
};
|
||||
|
||||
# TRIVIAL
|
||||
|
||||
testId = {
|
||||
@@ -2007,7 +1902,7 @@ runTests {
|
||||
expected = true;
|
||||
};
|
||||
|
||||
# DERIVATIONS
|
||||
# lazyDerivation
|
||||
|
||||
testLazyDerivationIsLazyInDerivationForAttrNames = {
|
||||
expr = attrNames (lazyDerivation {
|
||||
@@ -2060,42 +1955,6 @@ runTests {
|
||||
expected = derivation;
|
||||
};
|
||||
|
||||
testOptionalDrvAttr = let
|
||||
mkDerivation = args: derivation (args // {
|
||||
builder = "builder";
|
||||
system = "system";
|
||||
__ignoreNulls = true;
|
||||
});
|
||||
in {
|
||||
expr = (mkDerivation {
|
||||
name = "foo";
|
||||
x = optionalDrvAttr true 1;
|
||||
y = optionalDrvAttr false 1;
|
||||
}).drvPath;
|
||||
expected = (mkDerivation {
|
||||
name = "foo";
|
||||
x = 1;
|
||||
}).drvPath;
|
||||
};
|
||||
|
||||
testLazyDerivationMultiOutputReturnsDerivationAttrs = let
|
||||
derivation = {
|
||||
type = "derivation";
|
||||
outputs = ["out" "dev"];
|
||||
dev = "test dev";
|
||||
out = "test out";
|
||||
outPath = "test outPath";
|
||||
outputName = "out";
|
||||
drvPath = "test drvPath";
|
||||
name = "test name";
|
||||
system = "test system";
|
||||
meta.position = "/hi:23";
|
||||
};
|
||||
in {
|
||||
expr = lazyDerivation { inherit derivation; outputs = ["out" "dev"]; passthru.meta.position = "/hi:23"; };
|
||||
expected = derivation;
|
||||
};
|
||||
|
||||
testTypeDescriptionInt = {
|
||||
expr = (with types; int).description;
|
||||
expected = "signed integer";
|
||||
|
||||
@@ -101,7 +101,6 @@ checkConfigError 'It seems as if you.re trying to declare an option by placing i
|
||||
checkConfigError 'It seems as if you.re trying to declare an option by placing it into .config. rather than .options.' config.nest.wrong2 ./error-mkOption-in-config.nix
|
||||
checkConfigError 'The option .sub.wrong2. does not exist. Definition values:' config.sub ./error-mkOption-in-submodule-config.nix
|
||||
checkConfigError '.*This can happen if you e.g. declared your options in .types.submodule.' config.sub ./error-mkOption-in-submodule-config.nix
|
||||
checkConfigError '.*A definition for option .bad. is not of type .non-empty .list of .submodule...\.' config.bad ./error-nonEmptyListOf-submodule.nix
|
||||
|
||||
# types.pathInStore
|
||||
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
|
||||
@@ -407,16 +406,6 @@ checkConfigOutput "{}" config.submodule.a ./emptyValues.nix
|
||||
checkConfigError 'The option .int.a. is used but not defined' config.int.a ./emptyValues.nix
|
||||
checkConfigError 'The option .nonEmptyList.a. is used but not defined' config.nonEmptyList.a ./emptyValues.nix
|
||||
|
||||
# types.unique
|
||||
# requires a single definition
|
||||
checkConfigError 'The option .examples\.merged. is defined multiple times while it.s expected to be unique' config.examples.merged.a ./types-unique.nix
|
||||
# user message is printed
|
||||
checkConfigError 'We require a single definition, because seeing the whole value at once helps us maintain critical invariants of our system.' config.examples.merged.a ./types-unique.nix
|
||||
# let the inner merge function check the values (on demand)
|
||||
checkConfigError 'A definition for option .examples\.badLazyType\.a. is not of type .string.' config.examples.badLazyType.a ./types-unique.nix
|
||||
# overriding still works (unlike option uniqueness)
|
||||
checkConfigOutput '^"bee"$' config.examples.override.b ./types-unique.nix
|
||||
|
||||
## types.raw
|
||||
checkConfigOutput '^true$' config.unprocessedNestingEvaluates.success ./raw.nix
|
||||
checkConfigOutput "10" config.processedToplevel ./raw.nix
|
||||
@@ -475,9 +464,6 @@ checkConfigOutput '^1234$' config.c.d.e ./doRename-basic.nix
|
||||
checkConfigOutput '^"The option `a\.b. defined in `.*/doRename-warnings\.nix. has been renamed to `c\.d\.e.\."$' \
|
||||
config.result \
|
||||
./doRename-warnings.nix
|
||||
checkConfigOutput "^true$" config.result ./doRename-condition.nix ./doRename-condition-enable.nix
|
||||
checkConfigOutput "^true$" config.result ./doRename-condition.nix ./doRename-condition-no-enable.nix
|
||||
checkConfigOutput "^true$" config.result ./doRename-condition.nix ./doRename-condition-migrated.nix
|
||||
|
||||
# Anonymous modules get deduplicated by key
|
||||
checkConfigOutput '^"pear"$' config.once.raw ./merge-module-with-key.nix
|
||||
|
||||
@@ -6,19 +6,12 @@
|
||||
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkAliasOptionModule
|
||||
mkForce
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
in
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
# A simple boolean option that can be enabled or disabled.
|
||||
enable = mkOption {
|
||||
enable = lib.mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
example = true;
|
||||
@@ -48,7 +41,7 @@ in
|
||||
# should override the next import.
|
||||
( { config, lib, ... }:
|
||||
{
|
||||
enableAlias = mkForce false;
|
||||
enableAlias = lib.mkForce false;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -6,19 +6,12 @@
|
||||
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkAliasOptionModule
|
||||
mkDefault
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
in
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
# A simple boolean option that can be enabled or disabled.
|
||||
enable = mkOption {
|
||||
enable = lib.mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
default = null;
|
||||
example = true;
|
||||
@@ -48,7 +41,7 @@ in
|
||||
# should be able to be overridden by the next import.
|
||||
( { config, lib, ... }:
|
||||
{
|
||||
enableAlias = mkDefault false;
|
||||
enableAlias = lib.mkDefault false;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
config = {
|
||||
services.foo.enable = true;
|
||||
services.foo.bar = "baz";
|
||||
result =
|
||||
assert config.services.foos == { "" = { bar = "baz"; }; };
|
||||
true;
|
||||
};
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
config = {
|
||||
services.foos."".bar = "baz";
|
||||
result =
|
||||
assert config.services.foos == { "" = { bar = "baz"; }; };
|
||||
assert config.services.foo.bar == "baz";
|
||||
true;
|
||||
};
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{ config, lib, options, ... }:
|
||||
{
|
||||
config = {
|
||||
result =
|
||||
assert config.services.foos == { };
|
||||
assert ! options.services.foo.bar.isDefined;
|
||||
true;
|
||||
};
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
Simulate a migration from a single-instance `services.foo` to a multi instance
|
||||
`services.foos.<name>` module, where `name = ""` serves as the legacy /
|
||||
compatibility instance.
|
||||
|
||||
- No instances must exist, unless one is defined in the multi-instance module,
|
||||
or if the legacy enable option is set to true.
|
||||
- The legacy instance options must be renamed to the new instance, if it exists.
|
||||
|
||||
The relevant scenarios are tested in separate files:
|
||||
- ./doRename-condition-enable.nix
|
||||
- ./doRename-condition-no-enable.nix
|
||||
*/
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types doRename;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.foo.enable = mkEnableOption "foo";
|
||||
services.foos = mkOption {
|
||||
type = types.attrsOf (types.submodule {
|
||||
options = {
|
||||
bar = mkOption { type = types.str; };
|
||||
};
|
||||
});
|
||||
default = { };
|
||||
};
|
||||
result = mkOption {};
|
||||
};
|
||||
imports = [
|
||||
(doRename {
|
||||
from = [ "services" "foo" "bar" ];
|
||||
to = [ "services" "foos" "" "bar" ];
|
||||
visible = true;
|
||||
warn = false;
|
||||
use = x: x;
|
||||
withPriority = true;
|
||||
condition = config.services.foo.enable;
|
||||
})
|
||||
];
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user