Merge branch 'updateSettings' into vscode-utils/vscodeEnv
This commit is contained in:
commit
4d58f006ff
37
.github/CODEOWNERS
vendored
37
.github/CODEOWNERS
vendored
@ -11,10 +11,12 @@
|
|||||||
/.github/CODEOWNERS @edolstra
|
/.github/CODEOWNERS @edolstra
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
/lib @edolstra @nbp
|
/lib @edolstra @nbp @infinisil
|
||||||
/lib/systems @nbp @ericson2314 @matthewbauer
|
/lib/systems @nbp @ericson2314 @matthewbauer
|
||||||
/lib/generators.nix @edolstra @nbp @Profpatsch
|
/lib/generators.nix @edolstra @nbp @Profpatsch
|
||||||
|
/lib/cli.nix @edolstra @nbp @Profpatsch
|
||||||
/lib/debug.nix @edolstra @nbp @Profpatsch
|
/lib/debug.nix @edolstra @nbp @Profpatsch
|
||||||
|
/lib/asserts.nix @edolstra @nbp @Profpatsch
|
||||||
|
|
||||||
# Nixpkgs Internals
|
# Nixpkgs Internals
|
||||||
/default.nix @nbp
|
/default.nix @nbp
|
||||||
@ -29,10 +31,13 @@
|
|||||||
/pkgs/build-support/bintools-wrapper @Ericson2314 @orivej
|
/pkgs/build-support/bintools-wrapper @Ericson2314 @orivej
|
||||||
/pkgs/build-support/setup-hooks @Ericson2314
|
/pkgs/build-support/setup-hooks @Ericson2314
|
||||||
|
|
||||||
|
# Nixpkgs build-support
|
||||||
|
/pkgs/build-support/writers @lassulus @Profpatsch
|
||||||
|
|
||||||
# NixOS Internals
|
# NixOS Internals
|
||||||
/nixos/default.nix @nbp
|
/nixos/default.nix @nbp @infinisil
|
||||||
/nixos/lib/from-env.nix @nbp
|
/nixos/lib/from-env.nix @nbp @infinisil
|
||||||
/nixos/lib/eval-config.nix @nbp
|
/nixos/lib/eval-config.nix @nbp @infinisil
|
||||||
/nixos/doc/manual/configuration/abstractions.xml @nbp
|
/nixos/doc/manual/configuration/abstractions.xml @nbp
|
||||||
/nixos/doc/manual/configuration/config-file.xml @nbp
|
/nixos/doc/manual/configuration/config-file.xml @nbp
|
||||||
/nixos/doc/manual/configuration/config-syntax.xml @nbp
|
/nixos/doc/manual/configuration/config-syntax.xml @nbp
|
||||||
@ -61,11 +66,11 @@
|
|||||||
/doc/languages-frameworks/python.section.md @FRidh
|
/doc/languages-frameworks/python.section.md @FRidh
|
||||||
|
|
||||||
# Haskell
|
# Haskell
|
||||||
/pkgs/development/compilers/ghc @basvandijk @cdepillabout
|
/pkgs/development/compilers/ghc @cdepillabout
|
||||||
/pkgs/development/haskell-modules @basvandijk @cdepillabout
|
/pkgs/development/haskell-modules @cdepillabout @infinisil
|
||||||
/pkgs/development/haskell-modules/default.nix @basvandijk @cdepillabout
|
/pkgs/development/haskell-modules/default.nix @cdepillabout
|
||||||
/pkgs/development/haskell-modules/generic-builder.nix @basvandijk @cdepillabout
|
/pkgs/development/haskell-modules/generic-builder.nix @cdepillabout
|
||||||
/pkgs/development/haskell-modules/hoogle.nix @basvandijk @cdepillabout
|
/pkgs/development/haskell-modules/hoogle.nix @cdepillabout
|
||||||
|
|
||||||
# Perl
|
# Perl
|
||||||
/pkgs/development/interpreters/perl @volth
|
/pkgs/development/interpreters/perl @volth
|
||||||
@ -77,11 +82,12 @@
|
|||||||
/pkgs/development/r-modules @peti
|
/pkgs/development/r-modules @peti
|
||||||
|
|
||||||
# Ruby
|
# Ruby
|
||||||
/pkgs/development/interpreters/ruby @alyssais @zimbatm
|
/pkgs/development/interpreters/ruby @alyssais
|
||||||
/pkgs/development/ruby-modules @alyssais @zimbatm
|
/pkgs/development/ruby-modules @alyssais
|
||||||
|
|
||||||
# Rust
|
# Rust
|
||||||
/pkgs/development/compilers/rust @Mic92 @LnL7
|
/pkgs/development/compilers/rust @Mic92 @LnL7
|
||||||
|
/pkgs/build-support/rust @andir
|
||||||
|
|
||||||
# Darwin-related
|
# Darwin-related
|
||||||
/pkgs/stdenv/darwin @NixOS/darwin-maintainers
|
/pkgs/stdenv/darwin @NixOS/darwin-maintainers
|
||||||
@ -161,7 +167,7 @@
|
|||||||
/pkgs/top-level/emacs-packages.nix @adisbladis
|
/pkgs/top-level/emacs-packages.nix @adisbladis
|
||||||
|
|
||||||
# VimPlugins
|
# VimPlugins
|
||||||
/pkgs/misc/vim-plugins @jonringer
|
/pkgs/misc/vim-plugins @jonringer @softinio
|
||||||
|
|
||||||
# VsCode Extensions
|
# VsCode Extensions
|
||||||
/pkgs/misc/vscode-extensions @jonringer
|
/pkgs/misc/vscode-extensions @jonringer
|
||||||
@ -172,6 +178,7 @@
|
|||||||
/nixos/tests/prometheus-exporters.nix @WilliButz
|
/nixos/tests/prometheus-exporters.nix @WilliButz
|
||||||
|
|
||||||
# PHP
|
# PHP
|
||||||
/pkgs/development/interpreters/php @etu
|
/doc/languages-frameworks/php.section.md @etu
|
||||||
/pkgs/top-level/php-packages.nix @etu
|
/pkgs/development/interpreters/php @etu
|
||||||
/pkgs/build-support/build-pecl.nix @etu
|
/pkgs/top-level/php-packages.nix @etu
|
||||||
|
/pkgs/build-support/build-pecl.nix @etu
|
||||||
|
9
.github/CONTRIBUTING.md
vendored
9
.github/CONTRIBUTING.md
vendored
@ -48,6 +48,15 @@ In addition to writing properly formatted commit messages, it's important to inc
|
|||||||
|
|
||||||
For package version upgrades and such a one-line commit message is usually sufficient.
|
For package version upgrades and such a one-line commit message is usually sufficient.
|
||||||
|
|
||||||
|
## Backporting changes
|
||||||
|
|
||||||
|
To [backport a change into a release branch](https://nixos.org/nixpkgs/manual/#submitting-changes-stable-release-branches):
|
||||||
|
|
||||||
|
1. Take note of the commit in which the change was introduced into `master`.
|
||||||
|
2. Check out the target _release branch_, e.g. `release-19.09`. Do not use a _channel branch_ like `nixos-19.09` or `nixpkgs-19.09`.
|
||||||
|
3. Use `git cherry-pick -x <original commit>`.
|
||||||
|
4. Open your backport PR. Make sure to select the release branch (e.g. `release-19.09`) as the target branch of the PR, and link to the PR in which the original change was made to `master`.
|
||||||
|
|
||||||
## Reviewing contributions
|
## Reviewing contributions
|
||||||
|
|
||||||
See the nixpkgs manual for more details on how to [Review contributions](https://nixos.org/nixpkgs/manual/#chap-reviewing-contributions).
|
See the nixpkgs manual for more details on how to [Review contributions](https://nixos.org/nixpkgs/manual/#chap-reviewing-contributions).
|
||||||
|
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@ -8,4 +8,4 @@
|
|||||||
|
|
||||||
## Technical details
|
## Technical details
|
||||||
|
|
||||||
Please run `nix run nixpkgs.nix-info -c nix-info -m` and paste the result.
|
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
|
||||||
|
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -25,8 +25,14 @@ If applicable, add screenshots to help explain your problem.
|
|||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
**Notify maintainers**
|
||||||
|
<!--
|
||||||
|
Please @ people who are in the `meta.maintainers` list of the offending package or module.
|
||||||
|
If in doubt, check `git blame` for whoever last touched something.
|
||||||
|
-->
|
||||||
|
|
||||||
**Metadata**
|
**Metadata**
|
||||||
Please run `nix run nixpkgs.nix-info -c nix-info -m` and paste the result.
|
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
|
||||||
|
|
||||||
Maintainer information:
|
Maintainer information:
|
||||||
```yaml
|
```yaml
|
||||||
|
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -12,12 +12,8 @@
|
|||||||
- [ ] macOS
|
- [ ] macOS
|
||||||
- [ ] other Linux distributions
|
- [ ] other Linux distributions
|
||||||
- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
|
- [ ] Tested via one or more NixOS test(s) if existing and applicable for the change (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
|
||||||
- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nix-review --run "nix-review wip"`
|
- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review wip"`
|
||||||
- [ ] Tested execution of all binary files (usually in `./result/bin/`)
|
- [ ] Tested execution of all binary files (usually in `./result/bin/`)
|
||||||
- [ ] Determined the impact on package closure size (by running `nix path-info -S` before and after)
|
- [ ] Determined the impact on package closure size (by running `nix path-info -S` before and after)
|
||||||
- [ ] Ensured that relevant documentation is up to date
|
- [ ] Ensured that relevant documentation is up to date
|
||||||
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).
|
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).
|
||||||
|
|
||||||
###### Notify maintainers
|
|
||||||
|
|
||||||
cc @
|
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -11,7 +11,11 @@ result-*
|
|||||||
.version-suffix
|
.version-suffix
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.mypy_cache
|
||||||
|
|
||||||
/pkgs/development/libraries/qt-5/*/tmp/
|
/pkgs/development/libraries/qt-5/*/tmp/
|
||||||
/pkgs/desktops/kde-5/*/tmp/
|
/pkgs/desktops/kde-5/*/tmp/
|
||||||
/pkgs/development/mobile/androidenv/xml/*
|
/pkgs/development/mobile/androidenv/xml/*
|
||||||
|
|
||||||
|
# generated by pkgs/common-updater/update-script.nix
|
||||||
|
update-git-commits.txt
|
||||||
|
2
COPYING
2
COPYING
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2003-2019 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
Copyright (c) 2003-2020 Eelco Dolstra and the Nixpkgs/NixOS contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
* [NixOS Manual](https://nixos.org/nixos/manual) - how to install, configure, and maintain a purely-functional Linux distribution
|
* [NixOS Manual](https://nixos.org/nixos/manual) - how to install, configure, and maintain a purely-functional Linux distribution
|
||||||
* [Nixpkgs Manual](https://nixos.org/nixpkgs/manual/) - contributing to Nixpkgs and using programming-language-specific Nix expressions
|
* [Nixpkgs Manual](https://nixos.org/nixpkgs/manual/) - contributing to Nixpkgs and using programming-language-specific Nix expressions
|
||||||
* [Nix Package Manager Manual](https://nixos.org/nix/manual) - how to write Nix expresssions (programs), and how to use Nix command line tools
|
* [Nix Package Manager Manual](https://nixos.org/nix/manual) - how to write Nix expressions (programs), and how to use Nix command line tools
|
||||||
|
|
||||||
# Community
|
# Community
|
||||||
|
|
||||||
@ -24,10 +24,11 @@
|
|||||||
* [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
* [IRC - #nixos on freenode.net](irc://irc.freenode.net/#nixos)
|
||||||
* [NixOS Weekly](https://weekly.nixos.org/)
|
* [NixOS Weekly](https://weekly.nixos.org/)
|
||||||
* [Community-maintained wiki](https://nixos.wiki/)
|
* [Community-maintained wiki](https://nixos.wiki/)
|
||||||
|
* [Community-maintained list of ways to get in touch](https://nixos.wiki/wiki/Get_In_Touch#Chat) (Discord, Matrix, Telegram, other IRC channels, etc.)
|
||||||
|
|
||||||
# Other Project Repositories
|
# Other Project Repositories
|
||||||
|
|
||||||
The sources of all offical Nix-related projects are in the [NixOS
|
The sources of all official Nix-related projects are in the [NixOS
|
||||||
organization on GitHub](https://github.com/NixOS/). Here are some of
|
organization on GitHub](https://github.com/NixOS/). Here are some of
|
||||||
the main ones:
|
the main ones:
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ functions/library/generated: doc-support/result
|
|||||||
ln -rfs ./doc-support/result/function-docs functions/library/generated
|
ln -rfs ./doc-support/result/function-docs functions/library/generated
|
||||||
|
|
||||||
%.section.xml: %.section.md
|
%.section.xml: %.section.md
|
||||||
pandoc $^ -w docbook+smart \
|
pandoc $^ -w docbook \
|
||||||
-f markdown+smart \
|
-f markdown+smart \
|
||||||
| sed -e 's|<ulink url=|<link xlink:href=|' \
|
| sed -e 's|<ulink url=|<link xlink:href=|' \
|
||||||
-e 's|</ulink>|</link>|' \
|
-e 's|</ulink>|</link>|' \
|
||||||
@ -98,7 +98,7 @@ functions/library/generated: doc-support/result
|
|||||||
| cat > $@
|
| cat > $@
|
||||||
|
|
||||||
%.chapter.xml: %.chapter.md
|
%.chapter.xml: %.chapter.md
|
||||||
pandoc $^ -w docbook+smart \
|
pandoc $^ -w docbook \
|
||||||
--top-level-division=chapter \
|
--top-level-division=chapter \
|
||||||
-f markdown+smart \
|
-f markdown+smart \
|
||||||
| sed -e 's|<ulink url=|<link xlink:href=|' \
|
| sed -e 's|<ulink url=|<link xlink:href=|' \
|
||||||
|
@ -63,7 +63,7 @@ type2.AppImage: ELF 64-bit LSB executable, x86-64, version 1 (SYSV) (Lepton 3.x)
|
|||||||
appimageTools.wrapType2 { # or wrapType1
|
appimageTools.wrapType2 { # or wrapType1
|
||||||
name = "patchwork"; <co xml:id='ex-appimageTools-wrapping-1' />
|
name = "patchwork"; <co xml:id='ex-appimageTools-wrapping-1' />
|
||||||
src = fetchurl { <co xml:id='ex-appimageTools-wrapping-2' />
|
src = fetchurl { <co xml:id='ex-appimageTools-wrapping-2' />
|
||||||
url = https://github.com/ssbc/patchwork/releases/download/v3.11.4/Patchwork-3.11.4-linux-x86_64.AppImage;
|
url = "https://github.com/ssbc/patchwork/releases/download/v3.11.4/Patchwork-3.11.4-linux-x86_64.AppImage";
|
||||||
sha256 = "1blsprpkvm0ws9b96gb36f0rbf8f5jgmw4x6dsb1kswr4ysf591s";
|
sha256 = "1blsprpkvm0ws9b96gb36f0rbf8f5jgmw4x6dsb1kswr4ysf591s";
|
||||||
};
|
};
|
||||||
extraPkgs = pkgs: with pkgs; [ ]; <co xml:id='ex-appimageTools-wrapping-3' />
|
extraPkgs = pkgs: with pkgs; [ ]; <co xml:id='ex-appimageTools-wrapping-3' />
|
||||||
@ -80,7 +80,7 @@ appimageTools.wrapType2 { # or wrapType1
|
|||||||
<varname>src</varname> specifies the AppImage file to extract.
|
<varname>src</varname> specifies the AppImage file to extract.
|
||||||
</para>
|
</para>
|
||||||
</callout>
|
</callout>
|
||||||
<callout arearefs='ex-appimageTools-wrapping-2'>
|
<callout arearefs='ex-appimageTools-wrapping-3'>
|
||||||
<para>
|
<para>
|
||||||
<varname>extraPkgs</varname> allows you to pass a function to include additional packages inside the FHS environment your AppImage is going to run in. There are a few ways to learn which dependencies an application needs:
|
<varname>extraPkgs</varname> allows you to pass a function to include additional packages inside the FHS environment your AppImage is going to run in. There are a few ways to learn which dependencies an application needs:
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
buildContainer {
|
buildContainer {
|
||||||
args = [ (with pkgs; writeScript "run.sh" ''
|
args = [ (with pkgs; writeScript "run.sh" ''
|
||||||
#!${bash}/bin/bash
|
#!${bash}/bin/bash
|
||||||
${coreutils}/bin/exec ${bash}/bin/bash
|
exec ${bash}/bin/bash
|
||||||
'').outPath ]; <co xml:id='ex-ociTools-buildContainer-1' />
|
'').outPath ]; <co xml:id='ex-ociTools-buildContainer-1' />
|
||||||
|
|
||||||
mounts = {
|
mounts = {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<xi:include href="opengl.xml" />
|
<xi:include href="opengl.xml" />
|
||||||
<xi:include href="shell-helpers.xml" />
|
<xi:include href="shell-helpers.xml" />
|
||||||
<xi:include href="steam.xml" />
|
<xi:include href="steam.xml" />
|
||||||
|
<xi:include href="urxvt.xml" />
|
||||||
<xi:include href="weechat.xml" />
|
<xi:include href="weechat.xml" />
|
||||||
<xi:include href="xorg.xml" />
|
<xi:include href="xorg.xml" />
|
||||||
</chapter>
|
</chapter>
|
||||||
|
101
doc/builders/packages/urxvt.xml
Normal file
101
doc/builders/packages/urxvt.xml
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<section xmlns="http://docbook.org/ns/docbook"
|
||||||
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
xml:id="sec-urxvt">
|
||||||
|
<title>Urxvt</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Urxvt, also known as rxvt-unicode, is a highly customizable terminal emulator.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<section xml:id="sec-urxvt-conf">
|
||||||
|
|
||||||
|
<title>Configuring urxvt</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In <literal>nixpkgs</literal>, urxvt is provided by the package
|
||||||
|
<literal>rxvt-unicode</literal>. It can be configured to include your choice
|
||||||
|
of plugins, reducing its closure size from the default configuration which
|
||||||
|
includes all available plugins. To make use of this functionality, use an
|
||||||
|
overlay or directly install an expression that overrides its configuration,
|
||||||
|
such as
|
||||||
|
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: {
|
||||||
|
plugins = with availablePlugins; [ perls resize-font vtwheel ];
|
||||||
|
}
|
||||||
|
}</programlisting>
|
||||||
|
If the <literal>configure</literal> function returns an attrset without the
|
||||||
|
<literal>plugins</literal> attribute, <literal>availablePlugins</literal>
|
||||||
|
will be used automatically.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In order to add plugins but also keep all default plugins installed, it is
|
||||||
|
possible to use the following method:
|
||||||
|
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: {
|
||||||
|
plugins = (builtins.attrValues availablePlugins) ++ [ custom-plugin ];
|
||||||
|
};
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To get a list of all the plugins available, open the Nix REPL and run
|
||||||
|
<programlisting>$ nix repl
|
||||||
|
:l <nixpkgs>
|
||||||
|
map (p: p.name) pkgs.rxvt-unicode.plugins
|
||||||
|
</programlisting>
|
||||||
|
Alternatively, if your shell is bash or zsh and have completion enabled,
|
||||||
|
simply type <literal>nixpkgs.rxvt-unicode.plugins.<tab></literal>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
In addition to <literal>plugins</literal> the options
|
||||||
|
<literal>extraDeps</literal> and <literal>perlDeps</literal> can be used
|
||||||
|
to install extra packages.
|
||||||
|
<literal>extraDeps</literal> can be used, for example, to provide
|
||||||
|
<literal>xsel</literal> (a clipboard manager) to the clipboard plugin,
|
||||||
|
without installing it globally:
|
||||||
|
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: {
|
||||||
|
pluginsDeps = [ xsel ];
|
||||||
|
}
|
||||||
|
}</programlisting>
|
||||||
|
|
||||||
|
<literal>perlDeps</literal> is a handy way to provide Perl packages to
|
||||||
|
your custom plugins (in <literal>$HOME/.urxvt/ext</literal>). For example,
|
||||||
|
if you need <literal>AnyEvent</literal> you can do:
|
||||||
|
<programlisting>rxvt-unicode.override { configure = { availablePlugins, ... }: {
|
||||||
|
perlDeps = with perlPackages; [ AnyEvent ];
|
||||||
|
}
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-urxvt-pkg">
|
||||||
|
|
||||||
|
<title>Packaging urxvt plugins</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Urxvt plugins resides in
|
||||||
|
<literal>pkgs/applications/misc/rxvt-unicode-plugins</literal>.
|
||||||
|
To add a new plugin create an expression in a subdirectory and add the
|
||||||
|
package to the set in
|
||||||
|
<literal>pkgs/applications/misc/rxvt-unicode-plugins/default.nix</literal>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
A plugin can be any kind of derivation, the only requirement is that it
|
||||||
|
should always install perl scripts in <literal>$out/lib/urxvt/perl</literal>.
|
||||||
|
Look for existing plugins for examples.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If the plugin is itself a perl package that needs to be imported from
|
||||||
|
other plugins or scripts, add the following passthrough:
|
||||||
|
<programlisting>passthru.perlPackages = [ "self" ];
|
||||||
|
</programlisting>
|
||||||
|
This will make the urxvt wrapper pick up the dependency and set up the perl
|
||||||
|
path accordingly.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</section>
|
@ -69,8 +69,7 @@
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
JDiskReport, a Java utility: <link
|
JDiskReport, a Java utility: <link
|
||||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/jdiskreport/default.nix"><filename>pkgs/tools/misc/jdiskreport/default.nix</filename></link> (and the <link
|
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/jdiskreport/default.nix"><filename>pkgs/tools/misc/jdiskreport/default.nix</filename></link>. Nixpkgs doesn’t have a decent <varname>stdenv</varname> for Java yet so this is pretty ad-hoc.
|
||||||
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/jdiskreport/builder.sh">builder</link>). Nixpkgs doesn’t have a decent <varname>stdenv</varname> for Java yet so this is pretty ad-hoc.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -141,10 +141,10 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The <link xlink:href="https://github.com/Mic92/nix-review">nix-review</link> tool can be used to review a pull request content in a single command. <varname>PRNUMBER</varname> should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url.
|
The <link xlink:href="https://github.com/Mic92/nixpkgs-review">nixpkgs-review</link> tool can be used to review a pull request content in a single command. <varname>PRNUMBER</varname> should be replaced by the number at the end of the pull request title. You can also provide the full github pull request url.
|
||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
<prompt>$ </prompt>nix-shell -p nix-review --run "nix-review pr PRNUMBER"
|
<prompt>$ </prompt>nix-shell -p nixpkgs-review --run "nixpkgs-review pr PRNUMBER"
|
||||||
</screen>
|
</screen>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Fork the repository on GitHub.
|
Fork <link xlink:href="https://github.com/nixos/nixpkgs/">the Nixpkgs repository</link> on GitHub.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -22,15 +22,10 @@
|
|||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
You can make branch from a commit of your local <command>nixos-version</command>. That will help you to avoid additional local compilations. Because you will receive packages from binary cache.
|
You can make branch from a commit of your local <command>nixos-version</command>. That will help you to avoid additional local compilations. Because you will receive packages from binary cache. For example
|
||||||
<itemizedlist>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
For example: <command>nixos-version</command> returns <command>15.05.git.0998212 (Dingo)</command>. So you can do:
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
<screen>
|
<screen>
|
||||||
|
<prompt>$ </prompt>nixos-version --hash
|
||||||
|
0998212
|
||||||
<prompt>$ </prompt>git checkout 0998212
|
<prompt>$ </prompt>git checkout 0998212
|
||||||
<prompt>$ </prompt>git checkout -b 'fix/pkg-name-update'
|
<prompt>$ </prompt>git checkout -b 'fix/pkg-name-update'
|
||||||
</screen>
|
</screen>
|
||||||
@ -47,13 +42,11 @@
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Make commits of logical units.
|
Make commits of logical units.
|
||||||
<itemizedlist>
|
</para>
|
||||||
<listitem>
|
</listitem>
|
||||||
<para>
|
<listitem>
|
||||||
If you removed pkgs, made some major NixOS changes etc., write about them in <command>nixos/doc/manual/release-notes/rl-unstable.xml</command>.
|
<para>
|
||||||
</para>
|
If you removed pkgs or made some major NixOS changes, write about it in the release notes for the next stable release. For example <command>nixos/doc/manual/release-notes/rl-2003.xml</command>.
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -178,7 +171,7 @@ Additional information.
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Rebase you branch against current <command>master</command>.
|
<link xlink:href="https://git-scm.com/book/en/v2/Git-Branching-Rebasing">Rebase</link> your branch against current <command>master</command>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@ -194,36 +187,12 @@ Additional information.
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Create pull request:
|
Create the pull request
|
||||||
<itemizedlist>
|
</para>
|
||||||
<listitem>
|
</listitem>
|
||||||
<para>
|
<listitem>
|
||||||
Write the title in format <command>(pkg-name | nixos/<module>): improvement</command>.
|
<para>
|
||||||
<itemizedlist>
|
Follow <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md#submitting-changes">the contribution guidelines</link>.
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If you update the pkg, write versions <command>from -> to</command>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Write in comment if you have tested your patch. Do not rely much on <command>TravisCI</command>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
If you make an improvement, write about your motivation.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Notify maintainers of the package. For example add to the message: <command>cc @jagajaga @domenkozar</command>.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@ -317,25 +286,25 @@ Additional information.
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section xml:id="submitting-changes-tested-compilation">
|
<section xml:id="submitting-changes-tested-compilation">
|
||||||
<title>Tested compilation of all pkgs that depend on this change using <command>nix-review</command></title>
|
<title>Tested compilation of all pkgs that depend on this change using <command>nixpkgs-review</command></title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
If you are updating a package's version, you can use nix-review to make sure all packages that depend on the updated package still compile correctly. The <command>nix-review</command> utility can look for and build all dependencies either based on uncommited changes with the <literal>wip</literal> option or specifying a github pull request number.
|
If you are updating a package's version, you can use nixpkgs-review to make sure all packages that depend on the updated package still compile correctly. The <command>nixpkgs-review</command> utility can look for and build all dependencies either based on uncommited changes with the <literal>wip</literal> option or specifying a github pull request number.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
review changes from pull request number 12345:
|
review changes from pull request number 12345:
|
||||||
<screen>nix run nixpkgs.nix-review -c nix-review pr 12345</screen>
|
<screen>nix run nixpkgs.nixpkgs-review -c nixpkgs-review pr 12345</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
review uncommitted changes:
|
review uncommitted changes:
|
||||||
<screen>nix run nixpkgs.nix-review -c nix-review wip</screen>
|
<screen>nix run nixpkgs.nixpkgs-review -c nixpkgs-review wip</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
review changes from last commit:
|
review changes from last commit:
|
||||||
<screen>nix run nixpkgs.nix-review -c nix-review rev HEAD</screen>
|
<screen>nix run nixpkgs.nixpkgs-review -c nixpkgs-review rev HEAD</screen>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -408,7 +377,7 @@ Additional information.
|
|||||||
<section xml:id="submitting-changes-master-branch">
|
<section xml:id="submitting-changes-master-branch">
|
||||||
<title>Master branch</title>
|
<title>Master branch</title>
|
||||||
<para>
|
<para>
|
||||||
The <literal>master</literal> branch is the main development branch.
|
The <literal>master</literal> branch is the main development branch.
|
||||||
It should only see non-breaking commits that do not cause mass rebuilds.
|
It should only see non-breaking commits that do not cause mass rebuilds.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@ -416,8 +385,8 @@ Additional information.
|
|||||||
<section xml:id="submitting-changes-staging-branch">
|
<section xml:id="submitting-changes-staging-branch">
|
||||||
<title>Staging branch</title>
|
<title>Staging branch</title>
|
||||||
<para>
|
<para>
|
||||||
The <literal>staging</literal> branch is a development branch where mass-rebuilds go.
|
The <literal>staging</literal> branch is a development branch where mass-rebuilds go.
|
||||||
It should only see non-breaking mass-rebuild commits.
|
It should only see non-breaking mass-rebuild commits.
|
||||||
That means it is not to be used for testing, and changes must have been well tested already.
|
That means it is not to be used for testing, and changes must have been well tested already.
|
||||||
If the branch is already in a broken state, please refrain from adding extra new breakages.
|
If the branch is already in a broken state, please refrain from adding extra new breakages.
|
||||||
</para>
|
</para>
|
||||||
@ -426,10 +395,10 @@ Additional information.
|
|||||||
<section xml:id="submitting-changes-staging-next-branch">
|
<section xml:id="submitting-changes-staging-next-branch">
|
||||||
<title>Staging-next branch</title>
|
<title>Staging-next branch</title>
|
||||||
<para>
|
<para>
|
||||||
The <literal>staging-next</literal> branch is for stabilizing mass-rebuilds submitted to the <literal>staging</literal> branch prior to merging them into <literal>master</literal>.
|
The <literal>staging-next</literal> branch is for stabilizing mass-rebuilds submitted to the <literal>staging</literal> branch prior to merging them into <literal>master</literal>.
|
||||||
Mass-rebuilds should go via the <literal>staging</literal> branch.
|
Mass-rebuilds should go via the <literal>staging</literal> branch.
|
||||||
It should only see non-breaking commits that are fixing issues blocking it from being merged into the <literal>master </literal> branch.
|
It should only see non-breaking commits that are fixing issues blocking it from being merged into the <literal>master </literal> branch.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If the branch is already in a broken state, please refrain from adding extra new breakages. Stabilize it for a few days and then merge into master.
|
If the branch is already in a broken state, please refrain from adding extra new breakages. Stabilize it for a few days and then merge into master.
|
||||||
</para>
|
</para>
|
||||||
|
@ -302,7 +302,7 @@ lib.attrsets.attrValues { a = 1; b = 2; c = 3; }
|
|||||||
<section xml:id="function-library-lib.attrsets.catAttrs">
|
<section xml:id="function-library-lib.attrsets.catAttrs">
|
||||||
<title><function>lib.attrsets.catAttrs</function></title>
|
<title><function>lib.attrsets.catAttrs</function></title>
|
||||||
|
|
||||||
<subtitle><literal>catAttrs :: String -> AttrSet -> [Any]</literal>
|
<subtitle><literal>catAttrs :: String -> [AttrSet] -> [Any]</literal>
|
||||||
</subtitle>
|
</subtitle>
|
||||||
|
|
||||||
<xi:include href="./locations.xml" xpointer="lib.attrsets.catAttrs" />
|
<xi:include href="./locations.xml" xpointer="lib.attrsets.catAttrs" />
|
||||||
@ -1667,4 +1667,48 @@ recursiveUpdate
|
|||||||
]]></programlisting>
|
]]></programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="function-library-lib.attrsets.recurseIntoAttrs">
|
||||||
|
<title><function>lib.attrsets.recurseIntoAttrs</function></title>
|
||||||
|
|
||||||
|
<subtitle><literal>recurseIntoAttrs :: AttrSet -> AttrSet</literal>
|
||||||
|
</subtitle>
|
||||||
|
|
||||||
|
<xi:include href="./locations.xml" xpointer="lib.attrsets.recurseIntoAttrs" />
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Make various Nix tools consider the contents of the resulting
|
||||||
|
attribute set when looking for what to build, find, etc.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This function only affects a single attribute set; it does not apply itself recursively for nested attribute sets.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<varname>attrs</varname>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
An attribute set to scan for derivations.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<example xml:id="function-library-lib.attrsets.recurseIntoAttrs-example">
|
||||||
|
<title>Making Nix look inside an attribute set</title>
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
{
|
||||||
|
myTools = pkgs.lib.recurseIntoAttrs {
|
||||||
|
inherit (pkgs) hello figlet;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]]></programlisting>
|
||||||
|
</example>
|
||||||
|
</section>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
@ -186,7 +186,7 @@ with import <nixpkgs> {};
|
|||||||
androidenv.emulateApp {
|
androidenv.emulateApp {
|
||||||
name = "emulate-MyAndroidApp";
|
name = "emulate-MyAndroidApp";
|
||||||
platformVersion = "28";
|
platformVersion = "28";
|
||||||
abiVersion = "x86_64"; # armeabi-v7a, mips, x86
|
abiVersion = "x86"; # armeabi-v7a, mips, x86_64
|
||||||
systemImageType = "google_apis_playstore";
|
systemImageType = "google_apis_playstore";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -235,5 +235,5 @@ package manager uses. To update the expressions run the `generate.sh` script
|
|||||||
that is stored in the `pkgs/development/mobile/androidenv/` sub directory:
|
that is stored in the `pkgs/development/mobile/androidenv/` sub directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sh ./generate.sh
|
./generate.sh
|
||||||
```
|
```
|
||||||
|
@ -66,6 +66,6 @@ crystal.buildCrystalPackage rec {
|
|||||||
shardsFile = ./shards.nix;
|
shardsFile = ./shards.nix;
|
||||||
crystalBinaries.mint.src = "src/mint.cr";
|
crystalBinaries.mint.src = "src/mint.cr";
|
||||||
|
|
||||||
buildInputs = [ openssl_1_0_2 ];
|
buildInputs = [ openssl ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
75
doc/languages-frameworks/dotnet.section.md
Normal file
75
doc/languages-frameworks/dotnet.section.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# Dotnet
|
||||||
|
|
||||||
|
## Local Development Workflow
|
||||||
|
|
||||||
|
For local development, it's recommended to use nix-shell to create a dotnet environment:
|
||||||
|
|
||||||
|
```
|
||||||
|
# shell.nix
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
mkShell {
|
||||||
|
name = "dotnet-env";
|
||||||
|
buildInputs = [
|
||||||
|
dotnet-sdk_3
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using many sdks in a workflow
|
||||||
|
|
||||||
|
It's very likely that more than one sdk will be needed on a given project. Dotnet provides several different frameworks (E.g dotnetcore, aspnetcore, etc.) as well as many versions for a given framework. Normally, dotnet is able to fetch a framework and install it relative to the executable. However, this would mean writing to the nix store in nixpkgs, which is read-only. To support the many-sdk use case, one can compose an environment using `dotnetCorePackages.combinePackages`:
|
||||||
|
|
||||||
|
```
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
mkShell {
|
||||||
|
name = "dotnet-env";
|
||||||
|
buildInputs = [
|
||||||
|
(with dotnetCorePackages; combinePackages [
|
||||||
|
sdk_3_1
|
||||||
|
sdk_3_0
|
||||||
|
sdk_2_1
|
||||||
|
])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This will produce a dotnet installation that has the dotnet 3.1, 3.0, and 2.1 sdk. The first sdk listed will have it's cli utility present in the resulting environment. Example info output:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ dotnet --info
|
||||||
|
.NET Core SDK (reflecting any global.json):
|
||||||
|
Version: 3.1.101
|
||||||
|
Commit: b377529961
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
.NET Core SDKs installed:
|
||||||
|
2.1.803 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/sdk]
|
||||||
|
3.0.102 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/sdk]
|
||||||
|
3.1.101 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/sdk]
|
||||||
|
|
||||||
|
.NET Core runtimes installed:
|
||||||
|
Microsoft.AspNetCore.All 2.1.15 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.All]
|
||||||
|
Microsoft.AspNetCore.App 2.1.15 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||||
|
Microsoft.AspNetCore.App 3.0.2 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||||
|
Microsoft.AspNetCore.App 3.1.1 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
|
||||||
|
Microsoft.NETCore.App 2.1.15 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||||
|
Microsoft.NETCore.App 3.0.2 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||||
|
Microsoft.NETCore.App 3.1.1 [/nix/store/iiv98i2jdi226dgh4jzkkj2ww7f8jgpd-dotnet-core-combined/shared/Microsoft.NETCore.App]
|
||||||
|
```
|
||||||
|
|
||||||
|
## dotnet-sdk vs dotnetCorePackages.sdk
|
||||||
|
|
||||||
|
The `dotnetCorePackages.sdk_X_Y` is preferred over the old dotnet-sdk as both major and minor version are very important for a dotnet environment. If a given minor version isn't present (or was changed), then this will likely break your ability to build a project.
|
||||||
|
|
||||||
|
## dotnetCorePackages.sdk vs dotnetCorePackages.netcore vs dotnetCorePackages.aspnetcore
|
||||||
|
|
||||||
|
The `dotnetCorePackages.sdk` contains both a runtime and the full sdk of a given version. The `netcore` and `aspnetcore` packages are meant to serve as minimal runtimes to deploy alongside already built applications.
|
||||||
|
|
||||||
|
## Packaging a Dotnet Application
|
||||||
|
|
||||||
|
Ideally, we would like to build against the sdk, then only have the dotnet runtime available in the runtime closure.
|
||||||
|
|
||||||
|
TODO: Create closure-friendly way to package dotnet applications
|
@ -233,7 +233,7 @@ mkDerivation {
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
You can rely on applications depending on the library set the necessary environment variables but that it often easy to miss. Instead we recommend to patch the paths in the source code whenever possible. Here are some examples:
|
You can rely on applications depending on the library setting the necessary environment variables but that is often easy to miss. Instead we recommend to patch the paths in the source code whenever possible. Here are some examples:
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem xml:id="ssec-gnome-common-issues-unwrappable-package-gnome-shell-ext">
|
<listitem xml:id="ssec-gnome-common-issues-unwrappable-package-gnome-shell-ext">
|
||||||
<para>
|
<para>
|
||||||
|
@ -42,7 +42,7 @@ pet = buildGoModule rec {
|
|||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Simple command-line snippet manager, written in Go";
|
description = "Simple command-line snippet manager, written in Go";
|
||||||
homepage = https://github.com/knqyf263/pet;
|
homepage = "https://github.com/knqyf263/pet";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ kalbasit ];
|
maintainers = with maintainers; [ kalbasit ];
|
||||||
platforms = platforms.linux ++ platforms.darwin;
|
platforms = platforms.linux ++ platforms.darwin;
|
||||||
@ -66,6 +66,15 @@ pet = buildGoModule rec {
|
|||||||
</callout>
|
</callout>
|
||||||
</calloutlist>
|
</calloutlist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<varname>modSha256</varname> can also take <varname>null</varname> as an input.
|
||||||
|
|
||||||
|
When `null` is used as a value, the derivation won't be a
|
||||||
|
fixed-output derivation but disable the build sandbox instead. This can be useful outside
|
||||||
|
of nixpkgs where re-generating the modSha256 on each mod.sum changes is cumbersome,
|
||||||
|
but will fail to build by Hydra, as builds with a disabled sandbox are discouraged.
|
||||||
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section xml:id="ssec-go-legacy">
|
<section xml:id="ssec-go-legacy">
|
||||||
@ -94,7 +103,7 @@ deis = buildGoPackage rec {
|
|||||||
|
|
||||||
goDeps = ./deps.nix; <co xml:id='ex-buildGoPackage-3' />
|
goDeps = ./deps.nix; <co xml:id='ex-buildGoPackage-3' />
|
||||||
|
|
||||||
buildFlags = "--tags release"; <co xml:id='ex-buildGoPackage-4' />
|
buildFlags = [ "--tags" "release" ]; <co xml:id='ex-buildGoPackage-4' />
|
||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@ -84,37 +84,38 @@ nix-env -qaP -A nixos.haskellPackages
|
|||||||
nix-env -iA nixos.haskellPackages.cabal-install
|
nix-env -iA nixos.haskellPackages.cabal-install
|
||||||
```
|
```
|
||||||
|
|
||||||
Our current default compiler is GHC 7.10.x and the `haskellPackages` set
|
Our current default compiler is GHC 8.8.x and the `haskellPackages` set
|
||||||
contains packages built with that particular version. Nixpkgs contains the
|
contains packages built with that particular version. Nixpkgs contains the last
|
||||||
latest major release of every GHC since 6.10.4, however, and there is a whole
|
three major releases of GHC and there is a whole family of package sets
|
||||||
family of package sets available that defines Hackage packages built with each
|
available that defines Hackage packages built with each of those compilers,
|
||||||
of those compilers, too:
|
too:
|
||||||
```shell
|
```shell
|
||||||
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc6123
|
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc865
|
||||||
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc763
|
nix-env -f "<nixpkgs>" -qaP -A haskell.packages.ghc8101
|
||||||
```
|
```
|
||||||
|
|
||||||
The name `haskellPackages` is really just a synonym for
|
The name `haskellPackages` is really just a synonym for
|
||||||
`haskell.packages.ghc7102`, because we prefer that package set internally and
|
`haskell.packages.ghc882`, because we prefer that package set internally and
|
||||||
recommend it to our users as their default choice, but ultimately you are free
|
recommend it to our users as their default choice, but ultimately you are free
|
||||||
to compile your Haskell packages with any GHC version you please. The following
|
to compile your Haskell packages with any GHC version you please. The following
|
||||||
command displays the complete list of available compilers:
|
command displays the complete list of available compilers:
|
||||||
```
|
```
|
||||||
$ nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
|
$ nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
|
||||||
haskell.compiler.ghc822 ghc-8.2.2
|
haskell.compiler.ghc8101 ghc-8.10.1
|
||||||
haskell.compiler.integer-simple.ghc822 ghc-8.2.2
|
haskell.compiler.integer-simple.ghc8101 ghc-8.10.1
|
||||||
|
haskell.compiler.ghcHEAD ghc-8.11.20200403
|
||||||
|
haskell.compiler.integer-simple.ghcHEAD ghc-8.11.20200403
|
||||||
haskell.compiler.ghc822Binary ghc-8.2.2-binary
|
haskell.compiler.ghc822Binary ghc-8.2.2-binary
|
||||||
haskell.compiler.ghc844 ghc-8.4.4
|
haskell.compiler.ghc844 ghc-8.4.4
|
||||||
haskell.compiler.ghc863Binary ghc-8.6.3-binary
|
haskell.compiler.ghc863Binary ghc-8.6.3-binary
|
||||||
haskell.compiler.ghc864 ghc-8.6.4
|
|
||||||
haskell.compiler.integer-simple.ghc864 ghc-8.6.4
|
|
||||||
haskell.compiler.ghc865 ghc-8.6.5
|
haskell.compiler.ghc865 ghc-8.6.5
|
||||||
haskell.compiler.integer-simple.ghc865 ghc-8.6.5
|
haskell.compiler.integer-simple.ghc865 ghc-8.6.5
|
||||||
haskell.compiler.ghc881 ghc-8.8.1
|
haskell.compiler.ghc881 ghc-8.8.1
|
||||||
haskell.compiler.integer-simple.ghc881 ghc-8.8.1
|
haskell.compiler.integer-simple.ghc881 ghc-8.8.1
|
||||||
haskell.compiler.ghcHEAD ghc-8.9.20190601
|
haskell.compiler.ghc882 ghc-8.8.2
|
||||||
haskell.compiler.integer-simple.ghcHEAD ghc-8.9.20190601
|
haskell.compiler.integer-simple.ghc882 ghc-8.8.2
|
||||||
haskell.compiler.ghcjs84 ghcjs-8.4.0.1
|
haskell.compiler.ghc883 ghc-8.8.3
|
||||||
|
haskell.compiler.integer-simple.ghc883 ghc-8.8.3
|
||||||
haskell.compiler.ghcjs ghcjs-8.6.0.1
|
haskell.compiler.ghcjs ghcjs-8.6.0.1
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -368,7 +369,7 @@ automatically select the right version of GHC and other build tools to build,
|
|||||||
test and execute apps in an existing project downloaded from somewhere on the
|
test and execute apps in an existing project downloaded from somewhere on the
|
||||||
Internet. Pass the `--nix` flag to any `stack` command to do so, e.g.
|
Internet. Pass the `--nix` flag to any `stack` command to do so, e.g.
|
||||||
```shell
|
```shell
|
||||||
git clone --recursive https://github.com/yesodweb/wai
|
git clone --recurse-submodules https://github.com/yesodweb/wai.git
|
||||||
cd wai
|
cd wai
|
||||||
stack --nix build
|
stack --nix build
|
||||||
```
|
```
|
||||||
|
@ -96,7 +96,7 @@ build-idris-package {
|
|||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Idris YAML lib";
|
description = "Idris YAML lib";
|
||||||
homepage = https://github.com/Heather/Idris.Yaml;
|
homepage = "https://github.com/Heather/Idris.Yaml";
|
||||||
license = lib.licenses.mit;
|
license = lib.licenses.mit;
|
||||||
maintainers = [ lib.maintainers.brainrape ];
|
maintainers = [ lib.maintainers.brainrape ];
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ buildDunePackage rec {
|
|||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
homepage = https://github.com/inhabitedtype/angstrom;
|
homepage = "https://github.com/inhabitedtype/angstrom";
|
||||||
description = "OCaml parser combinators built for speed and memory efficiency";
|
description = "OCaml parser combinators built for speed and memory efficiency";
|
||||||
license = stdenv.lib.licenses.bsd3;
|
license = stdenv.lib.licenses.bsd3;
|
||||||
maintainers = with stdenv.lib.maintainers; [ sternenseemann ];
|
maintainers = with stdenv.lib.maintainers; [ sternenseemann ];
|
||||||
@ -63,7 +63,7 @@ buildDunePackage rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
homepage = https://github.com/flowtype/ocaml-wtf8;
|
homepage = "https://github.com/flowtype/ocaml-wtf8";
|
||||||
description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
|
description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = [ maintainers.eqyiel ];
|
maintainers = [ maintainers.eqyiel ];
|
||||||
|
112
doc/languages-frameworks/php.section.md
Normal file
112
doc/languages-frameworks/php.section.md
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
# PHP
|
||||||
|
|
||||||
|
## User Guide
|
||||||
|
|
||||||
|
### Using PHP
|
||||||
|
|
||||||
|
#### Overview
|
||||||
|
|
||||||
|
Several versions of PHP are available on Nix, each of which having a
|
||||||
|
wide variety of extensions and libraries available.
|
||||||
|
|
||||||
|
The attribute `php` refers to the version of PHP considered most
|
||||||
|
stable and thoroughly tested in nixpkgs for any given release of
|
||||||
|
NixOS. Note that while this version of PHP may not be the latest major
|
||||||
|
release from upstream, any version of PHP supported in nixpkgs may be
|
||||||
|
utilized by specifying the desired attribute by version, such as
|
||||||
|
`php74`.
|
||||||
|
|
||||||
|
Only versions of PHP that are supported by upstream for the entirety
|
||||||
|
of a given NixOS release will be included in that release of
|
||||||
|
NixOS. See [PHP Supported
|
||||||
|
Versions](https://www.php.net/supported-versions.php).
|
||||||
|
|
||||||
|
Interactive tools built on PHP are put in `php.packages`; composer is
|
||||||
|
for example available at `php.packages.composer`.
|
||||||
|
|
||||||
|
Most extensions that come with PHP, as well as some popular
|
||||||
|
third-party ones, are available in `php.extensions`; for example, the
|
||||||
|
opcache extension shipped with PHP is available at
|
||||||
|
`php.extensions.opcache` and the third-party ImageMagick extension at
|
||||||
|
`php.extensions.imagick`.
|
||||||
|
|
||||||
|
The different versions of PHP that nixpkgs provides is located under
|
||||||
|
attributes named based on major and minor version number; e.g.,
|
||||||
|
`php74` is PHP 7.4 with commonly used extensions installed,
|
||||||
|
`php74base` is the same PHP runtime without extensions.
|
||||||
|
|
||||||
|
#### Installing PHP with packages
|
||||||
|
|
||||||
|
A PHP package with specific extensions enabled can be built using
|
||||||
|
`php.withExtensions`. This is a function which accepts an anonymous
|
||||||
|
function as its only argument; the function should take one argument,
|
||||||
|
the set of all extensions, and return a list of wanted extensions. For
|
||||||
|
example, a PHP package with the opcache and ImageMagick extensions
|
||||||
|
enabled:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
php.withExtensions (e: with e; [ imagick opcache ])
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that this will give you a package with _only_ opcache and
|
||||||
|
ImageMagick, none of the other extensions which are enabled by default
|
||||||
|
in the `php` package will be available.
|
||||||
|
|
||||||
|
To enable building on a previous PHP package, the currently enabled
|
||||||
|
extensions are made available in its `enabledExtensions`
|
||||||
|
attribute. For example, to generate a package with all default
|
||||||
|
extensions enabled, except opcache, but with ImageMagick:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
php.withExtensions (e:
|
||||||
|
(lib.filter (e: e != php.extensions.opcache) php.enabledExtensions)
|
||||||
|
++ [ e.imagick ])
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want a PHP build with extra configuration in the `php.ini`
|
||||||
|
file, you can use `php.buildEnv`. This function takes two named and
|
||||||
|
optional parameters: `extensions` and `extraConfig`. `extensions`
|
||||||
|
takes an extension specification equivalent to that of
|
||||||
|
`php.withExtensions`, `extraConfig` a string of additional `php.ini`
|
||||||
|
configuration parameters. For example, a PHP package with the opcache
|
||||||
|
and ImageMagick extensions enabled, and `memory_limit` set to `256M`:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
php.buildEnv {
|
||||||
|
extensions = e: with e; [ imagick opcache ];
|
||||||
|
extraConfig = "memory_limit=256M";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Example setup for `phpfpm`
|
||||||
|
|
||||||
|
You can use the previous examples in a `phpfpm` pool called `foo` as
|
||||||
|
follows:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
let
|
||||||
|
myPhp = php.withExtensions (e: with e; [ imagick opcache ]);
|
||||||
|
in {
|
||||||
|
services.phpfpm.pools."foo".phpPackage = myPhp;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
```nix
|
||||||
|
let
|
||||||
|
myPhp = php.buildEnv {
|
||||||
|
extensions = e: with e; [ imagick opcache ];
|
||||||
|
extraConfig = "memory_limit=256M";
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
services.phpfpm.pools."foo".phpPackage = myPhp;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Example usage with `nix-shell`
|
||||||
|
|
||||||
|
This brings up a temporary environment that contains a PHP interpreter
|
||||||
|
with the extensions `imagick` and `opcache` enabled.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nix-shell -p 'php.buildEnv { extensions = e: with e; [ imagick opcache ]; }'
|
||||||
|
```
|
@ -72,8 +72,9 @@ Now you can use the Python interpreter, as well as the extra packages (`numpy`,
|
|||||||
|
|
||||||
##### Environment defined in `~/.config/nixpkgs/config.nix`
|
##### Environment defined in `~/.config/nixpkgs/config.nix`
|
||||||
|
|
||||||
If you prefer to, you could also add the environment as a package override to the Nixpkgs set, e.g.
|
If you prefer you could also add the environment as a package override to the
|
||||||
using `config.nix`,
|
Nixpkgs set, e.g. using `config.nix`,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ # ...
|
{ # ...
|
||||||
|
|
||||||
@ -83,15 +84,18 @@ using `config.nix`,
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
and install it in your profile with
|
and install it in your profile with
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-env -iA nixpkgs.myEnv
|
nix-env -iA nixpkgs.myEnv
|
||||||
```
|
```
|
||||||
|
|
||||||
The environment is is installed by referring to the attribute, and considering
|
The environment is is installed by referring to the attribute, and considering
|
||||||
the `nixpkgs` channel was used.
|
the `nixpkgs` channel was used.
|
||||||
|
|
||||||
##### Environment defined in `/etc/nixos/configuration.nix`
|
##### Environment defined in `/etc/nixos/configuration.nix`
|
||||||
|
|
||||||
For the sake of completeness, here's another example how to install the environment system-wide.
|
For the sake of completeness, here's another example how to install the
|
||||||
|
environment system-wide.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ # ...
|
{ # ...
|
||||||
@ -109,40 +113,56 @@ into a profile. For development you may need to use multiple environments.
|
|||||||
`nix-shell` gives the possibility to temporarily load another environment, akin
|
`nix-shell` gives the possibility to temporarily load another environment, akin
|
||||||
to `virtualenv`.
|
to `virtualenv`.
|
||||||
|
|
||||||
There are two methods for loading a shell with Python packages. The first and recommended method
|
There are two methods for loading a shell with Python packages. The first and
|
||||||
is to create an environment with `python.buildEnv` or `python.withPackages` and load that. E.g.
|
recommended method is to create an environment with `python.buildEnv` or
|
||||||
|
`python.withPackages` and load that. E.g.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nix-shell -p 'python35.withPackages(ps: with ps; [ numpy toolz ])'
|
$ nix-shell -p 'python35.withPackages(ps: with ps; [ numpy toolz ])'
|
||||||
```
|
```
|
||||||
|
|
||||||
opens a shell from which you can launch the interpreter
|
opens a shell from which you can launch the interpreter
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
[nix-shell:~] python3
|
[nix-shell:~] python3
|
||||||
```
|
```
|
||||||
The other method, which is not recommended, does not create an environment and requires you to list the packages directly,
|
|
||||||
|
The other method, which is not recommended, does not create an environment and
|
||||||
|
requires you to list the packages directly,
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nix-shell -p python35.pkgs.numpy python35.pkgs.toolz
|
$ nix-shell -p python35.pkgs.numpy python35.pkgs.toolz
|
||||||
```
|
```
|
||||||
Again, it is possible to launch the interpreter from the shell.
|
|
||||||
The Python interpreter has the attribute `pkgs` which contains all Python libraries for that specific interpreter.
|
Again, it is possible to launch the interpreter from the shell. The Python
|
||||||
|
interpreter has the attribute `pkgs` which contains all Python libraries for
|
||||||
|
that specific interpreter.
|
||||||
|
|
||||||
##### Load environment from `.nix` expression
|
##### Load environment from `.nix` expression
|
||||||
As explained in the Nix manual, `nix-shell` can also load an
|
As explained in the Nix manual, `nix-shell` can also load an
|
||||||
expression from a `.nix` file. Say we want to have Python 3.5, `numpy`
|
expression from a `.nix` file. Say we want to have Python 3.5, `numpy`
|
||||||
and `toolz`, like before, in an environment. Consider a `shell.nix` file
|
and `toolz`, like before, in an environment. Consider a `shell.nix` file
|
||||||
with
|
with
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
(python35.withPackages (ps: [ps.numpy ps.toolz])).env
|
(python35.withPackages (ps: [ps.numpy ps.toolz])).env
|
||||||
```
|
```
|
||||||
|
|
||||||
Executing `nix-shell` gives you again a Nix shell from which you can run Python.
|
Executing `nix-shell` gives you again a Nix shell from which you can run Python.
|
||||||
|
|
||||||
What's happening here?
|
What's happening here?
|
||||||
|
|
||||||
1. We begin with importing the Nix Packages collections. `import <nixpkgs>` imports the `<nixpkgs>` function, `{}` calls it and the `with` statement brings all attributes of `nixpkgs` in the local scope. These attributes form the main package set.
|
1. We begin with importing the Nix Packages collections. `import <nixpkgs>`
|
||||||
|
imports the `<nixpkgs>` function, `{}` calls it and the `with` statement
|
||||||
|
brings all attributes of `nixpkgs` in the local scope. These attributes form
|
||||||
|
the main package set.
|
||||||
2. Then we create a Python 3.5 environment with the `withPackages` function.
|
2. Then we create a Python 3.5 environment with the `withPackages` function.
|
||||||
3. The `withPackages` function expects us to provide a function as an argument that takes the set of all python packages and returns a list of packages to include in the environment. Here, we select the packages `numpy` and `toolz` from the package set.
|
3. The `withPackages` function expects us to provide a function as an argument
|
||||||
|
that takes the set of all python packages and returns a list of packages to
|
||||||
|
include in the environment. Here, we select the packages `numpy` and `toolz`
|
||||||
|
from the package set.
|
||||||
|
|
||||||
To combine this with `mkShell` you can:
|
To combine this with `mkShell` you can:
|
||||||
|
|
||||||
@ -166,20 +186,23 @@ in mkShell {
|
|||||||
A convenient option with `nix-shell` is the `--run`
|
A convenient option with `nix-shell` is the `--run`
|
||||||
option, with which you can execute a command in the `nix-shell`. We can
|
option, with which you can execute a command in the `nix-shell`. We can
|
||||||
e.g. directly open a Python shell
|
e.g. directly open a Python shell
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nix-shell -p python35Packages.numpy python35Packages.toolz --run "python3"
|
$ nix-shell -p python35Packages.numpy python35Packages.toolz --run "python3"
|
||||||
```
|
```
|
||||||
|
|
||||||
or run a script
|
or run a script
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nix-shell -p python35Packages.numpy python35Packages.toolz --run "python3 myscript.py"
|
$ nix-shell -p python35Packages.numpy python35Packages.toolz --run "python3 myscript.py"
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `nix-shell` as shebang
|
##### `nix-shell` as shebang
|
||||||
In fact, for the second use case, there is a more convenient method. You can
|
In fact, for the second use case, there is a more convenient method. You can add
|
||||||
add a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) to your script
|
a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) to your script
|
||||||
specifying which dependencies `nix-shell` needs. With the following shebang, you
|
specifying which dependencies `nix-shell` needs. With the following shebang, you
|
||||||
can just execute `./myscript.py`, and it will make available all dependencies and
|
can just execute `./myscript.py`, and it will make available all dependencies
|
||||||
run the script in the `python3` shell.
|
and run the script in the `python3` shell.
|
||||||
|
|
||||||
```py
|
```py
|
||||||
#! /usr/bin/env nix-shell
|
#! /usr/bin/env nix-shell
|
||||||
@ -218,7 +241,7 @@ buildPythonPackage rec {
|
|||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = https://github.com/pytoolz/toolz;
|
homepage = "https://github.com/pytoolz/toolz";
|
||||||
description = "List processing tools and functional utilities";
|
description = "List processing tools and functional utilities";
|
||||||
license = licenses.bsd3;
|
license = licenses.bsd3;
|
||||||
maintainers = with maintainers; [ fridh ];
|
maintainers = with maintainers; [ fridh ];
|
||||||
@ -270,6 +293,7 @@ with import <nixpkgs> {};
|
|||||||
in python35.withPackages (ps: [ps.numpy my_toolz])
|
in python35.withPackages (ps: [ps.numpy my_toolz])
|
||||||
).env
|
).env
|
||||||
```
|
```
|
||||||
|
|
||||||
Executing `nix-shell` will result in an environment in which you can use
|
Executing `nix-shell` will result in an environment in which you can use
|
||||||
Python 3.5 and the `toolz` package. As you can see we had to explicitly mention
|
Python 3.5 and the `toolz` package. As you can see we had to explicitly mention
|
||||||
for which Python version we want to build a package.
|
for which Python version we want to build a package.
|
||||||
@ -311,7 +335,7 @@ buildPythonPackage rec {
|
|||||||
propagatedBuildInputs = [ numpy multipledispatch dateutil ];
|
propagatedBuildInputs = [ numpy multipledispatch dateutil ];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = https://github.com/ContinuumIO/datashape;
|
homepage = "https://github.com/ContinuumIO/datashape";
|
||||||
description = "A data description language";
|
description = "A data description language";
|
||||||
license = licenses.bsd2;
|
license = licenses.bsd2;
|
||||||
maintainers = with maintainers; [ fridh ];
|
maintainers = with maintainers; [ fridh ];
|
||||||
@ -345,7 +369,7 @@ buildPythonPackage rec {
|
|||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Pythonic binding for the libxml2 and libxslt libraries";
|
description = "Pythonic binding for the libxml2 and libxslt libraries";
|
||||||
homepage = https://lxml.de;
|
homepage = "https://lxml.de";
|
||||||
license = licenses.bsd3;
|
license = licenses.bsd3;
|
||||||
maintainers = with maintainers; [ sjourdois ];
|
maintainers = with maintainers; [ sjourdois ];
|
||||||
};
|
};
|
||||||
@ -355,12 +379,12 @@ buildPythonPackage rec {
|
|||||||
In this example `lxml` and Nix are able to work out exactly where the relevant
|
In this example `lxml` and Nix are able to work out exactly where the relevant
|
||||||
files of the dependencies are. This is not always the case.
|
files of the dependencies are. This is not always the case.
|
||||||
|
|
||||||
The example below shows bindings to The Fastest Fourier Transform in the West, commonly known as
|
The example below shows bindings to The Fastest Fourier Transform in the West,
|
||||||
FFTW. On Nix we have separate packages of FFTW for the different types of floats
|
commonly known as FFTW. On Nix we have separate packages of FFTW for the
|
||||||
(`"single"`, `"double"`, `"long-double"`). The bindings need all three types,
|
different types of floats (`"single"`, `"double"`, `"long-double"`). The
|
||||||
and therefore we add all three as `buildInputs`. The bindings don't expect to
|
bindings need all three types, and therefore we add all three as `buildInputs`.
|
||||||
find each of them in a different folder, and therefore we have to set `LDFLAGS`
|
The bindings don't expect to find each of them in a different folder, and
|
||||||
and `CFLAGS`.
|
therefore we have to set `LDFLAGS` and `CFLAGS`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ lib, pkgs, buildPythonPackage, fetchPypi, numpy, scipy }:
|
{ lib, pkgs, buildPythonPackage, fetchPypi, numpy, scipy }:
|
||||||
@ -388,7 +412,7 @@ buildPythonPackage rec {
|
|||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms";
|
description = "A pythonic wrapper around FFTW, the FFT library, presenting a unified interface for all the supported transforms";
|
||||||
homepage = http://hgomersall.github.com/pyFFTW;
|
homepage = "http://hgomersall.github.com/pyFFTW";
|
||||||
license = with licenses; [ bsd2 bsd3 ];
|
license = with licenses; [ bsd2 bsd3 ];
|
||||||
maintainers = with maintainers; [ fridh ];
|
maintainers = with maintainers; [ fridh ];
|
||||||
};
|
};
|
||||||
@ -404,17 +428,18 @@ instead of installing the package this command creates a special link to the pro
|
|||||||
That way, you can run updated code without having to reinstall after each and every change you make.
|
That way, you can run updated code without having to reinstall after each and every change you make.
|
||||||
Development mode is also available. Let's see how you can use it.
|
Development mode is also available. Let's see how you can use it.
|
||||||
|
|
||||||
In the previous Nix expression the source was fetched from an url. We can also refer to a local source instead using
|
In the previous Nix expression the source was fetched from an url. We can also
|
||||||
`src = ./path/to/source/tree;`
|
refer to a local source instead using `src = ./path/to/source/tree;`
|
||||||
|
|
||||||
If we create a `shell.nix` file which calls `buildPythonPackage`, and if `src`
|
If we create a `shell.nix` file which calls `buildPythonPackage`, and if `src`
|
||||||
is a local source, and if the local source has a `setup.py`, then development
|
is a local source, and if the local source has a `setup.py`, then development
|
||||||
mode is activated.
|
mode is activated.
|
||||||
|
|
||||||
In the following example we create a simple environment that
|
In the following example we create a simple environment that has a Python 3.5
|
||||||
has a Python 3.5 version of our package in it, as well as its dependencies and
|
version of our package in it, as well as its dependencies and other packages we
|
||||||
other packages we like to have in the environment, all specified with `propagatedBuildInputs`.
|
like to have in the environment, all specified with `propagatedBuildInputs`.
|
||||||
Indeed, we can just add any package we like to have in our environment to `propagatedBuildInputs`.
|
Indeed, we can just add any package we like to have in our environment to
|
||||||
|
`propagatedBuildInputs`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
@ -427,7 +452,8 @@ buildPythonPackage rec {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
It is important to note that due to how development mode is implemented on Nix it is not possible to have multiple packages simultaneously in development mode.
|
It is important to note that due to how development mode is implemented on Nix
|
||||||
|
it is not possible to have multiple packages simultaneously in development mode.
|
||||||
|
|
||||||
|
|
||||||
### Organising your packages
|
### Organising your packages
|
||||||
@ -496,14 +522,14 @@ and in this case the `python35` interpreter is automatically used.
|
|||||||
|
|
||||||
### Interpreters
|
### Interpreters
|
||||||
|
|
||||||
Versions 2.7, 3.5, 3.6 and 3.7 of the CPython interpreter are available as
|
Versions 2.7, 3.5, 3.6, 3.7 and 3.8 of the CPython interpreter are available as
|
||||||
respectively `python27`, `python35`, `python36` and `python37`. The aliases
|
respectively `python27`, `python35`, `python36`, `python37` and `python38`. The
|
||||||
`python2` and `python3` correspond to respectively `python27` and
|
aliases `python2` and `python3` correspond to respectively `python27` and
|
||||||
`python37`. The default interpreter, `python`, maps to `python2`. The PyPy
|
`python37`. The default interpreter, `python`, maps to `python2`. The PyPy
|
||||||
interpreters compatible with Python 2.7 and 3 are available as `pypy27` and
|
interpreters compatible with Python 2.7 and 3 are available as `pypy27` and
|
||||||
`pypy3`, with aliases `pypy2` mapping to `pypy27` and `pypy` mapping to
|
`pypy3`, with aliases `pypy2` mapping to `pypy27` and `pypy` mapping to `pypy2`.
|
||||||
`pypy2`. The Nix expressions for the interpreters can be
|
The Nix expressions for the interpreters can be found in
|
||||||
found in `pkgs/development/interpreters/python`.
|
`pkgs/development/interpreters/python`.
|
||||||
|
|
||||||
All packages depending on any Python interpreter get appended
|
All packages depending on any Python interpreter get appended
|
||||||
`out/{python.sitePackages}` to `$PYTHONPATH` if such directory
|
`out/{python.sitePackages}` to `$PYTHONPATH` if such directory
|
||||||
@ -532,9 +558,10 @@ Python libraries and applications that use `setuptools` or
|
|||||||
`buildPythonApplication` functions. These two functions also support installing a `wheel`.
|
`buildPythonApplication` functions. These two functions also support installing a `wheel`.
|
||||||
|
|
||||||
All Python packages reside in `pkgs/top-level/python-packages.nix` and all
|
All Python packages reside in `pkgs/top-level/python-packages.nix` and all
|
||||||
applications elsewhere. In case a package is used as both a library and an application,
|
applications elsewhere. In case a package is used as both a library and an
|
||||||
then the package should be in `pkgs/top-level/python-packages.nix` since only those packages are made
|
application, then the package should be in `pkgs/top-level/python-packages.nix`
|
||||||
available for all interpreter versions. The preferred location for library expressions is in
|
since only those packages are made available for all interpreter versions. The
|
||||||
|
preferred location for library expressions is in
|
||||||
`pkgs/development/python-modules`. It is important that these packages are
|
`pkgs/development/python-modules`. It is important that these packages are
|
||||||
called from `pkgs/top-level/python-packages.nix` and not elsewhere, to guarantee
|
called from `pkgs/top-level/python-packages.nix` and not elsewhere, to guarantee
|
||||||
the right version of the package is built.
|
the right version of the package is built.
|
||||||
@ -562,6 +589,7 @@ The `buildPythonPackage` function is implemented in
|
|||||||
using setup hooks.
|
using setup hooks.
|
||||||
|
|
||||||
The following is an example:
|
The following is an example:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ lib, buildPythonPackage, fetchPypi, hypothesis, setuptools_scm, attrs, py, setuptools, six, pluggy }:
|
{ lib, buildPythonPackage, fetchPypi, hypothesis, setuptools_scm, attrs, py, setuptools, six, pluggy }:
|
||||||
|
|
||||||
@ -608,38 +636,67 @@ as the interpreter unless overridden otherwise.
|
|||||||
|
|
||||||
##### `buildPythonPackage` parameters
|
##### `buildPythonPackage` parameters
|
||||||
|
|
||||||
All parameters from `stdenv.mkDerivation` function are still supported. The following are specific to `buildPythonPackage`:
|
All parameters from `stdenv.mkDerivation` function are still supported. The
|
||||||
|
following are specific to `buildPythonPackage`:
|
||||||
|
|
||||||
* `catchConflicts ? true`: If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`.
|
* `catchConflicts ? true`: If `true`, abort package build if a package name
|
||||||
* `disabled` ? false: If `true`, package is not built for the particular Python interpreter version.
|
appears more than once in dependency tree. Default is `true`.
|
||||||
|
* `disabled` ? false: If `true`, package is not built for the particular Python
|
||||||
|
interpreter version.
|
||||||
* `dontWrapPythonPrograms ? false`: Skip wrapping of python programs.
|
* `dontWrapPythonPrograms ? false`: Skip wrapping of python programs.
|
||||||
* `permitUserSite ? false`: Skip setting the `PYTHONNOUSERSITE` environment variable in wrapped programs.
|
* `permitUserSite ? false`: Skip setting the `PYTHONNOUSERSITE` environment
|
||||||
* `installFlags ? []`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"]`.
|
variable in wrapped programs.
|
||||||
* `format ? "setuptools"`: Format of the source. Valid options are `"setuptools"`, `"pyproject"`, `"flit"`, `"wheel"`, and `"other"`. `"setuptools"` is for when the source has a `setup.py` and `setuptools` is used to build a wheel, `flit`, in case `flit` should be used to build a wheel, and `wheel` in case a wheel is provided. Use `other` when a custom `buildPhase` and/or `installPhase` is needed.
|
* `installFlags ? []`: A list of strings. Arguments to be passed to `pip
|
||||||
* `makeWrapperArgs ? []`: A list of strings. Arguments to be passed to `makeWrapper`, which wraps generated binaries. By default, the arguments to `makeWrapper` set `PATH` and `PYTHONPATH` environment variables before calling the binary. Additional arguments here can allow a developer to set environment variables which will be available when the binary is run. For example, `makeWrapperArgs = ["--set FOO BAR" "--set BAZ QUX"]`.
|
install`. To pass options to `python setup.py install`, use
|
||||||
* `namePrefix`: Prepends text to `${name}` parameter. In case of libraries, this defaults to `"python3.5-"` for Python 3.5, etc., and in case of applications to `""`.
|
`--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"]`.
|
||||||
* `pythonPath ? []`: List of packages to be added into `$PYTHONPATH`. Packages in `pythonPath` are not propagated (contrary to `propagatedBuildInputs`).
|
* `format ? "setuptools"`: Format of the source. Valid options are
|
||||||
|
`"setuptools"`, `"pyproject"`, `"flit"`, `"wheel"`, and `"other"`.
|
||||||
|
`"setuptools"` is for when the source has a `setup.py` and `setuptools` is
|
||||||
|
used to build a wheel, `flit`, in case `flit` should be used to build a wheel,
|
||||||
|
and `wheel` in case a wheel is provided. Use `other` when a custom
|
||||||
|
`buildPhase` and/or `installPhase` is needed.
|
||||||
|
* `makeWrapperArgs ? []`: A list of strings. Arguments to be passed to
|
||||||
|
`makeWrapper`, which wraps generated binaries. By default, the arguments to
|
||||||
|
`makeWrapper` set `PATH` and `PYTHONPATH` environment variables before calling
|
||||||
|
the binary. Additional arguments here can allow a developer to set environment
|
||||||
|
variables which will be available when the binary is run. For example,
|
||||||
|
`makeWrapperArgs = ["--set FOO BAR" "--set BAZ QUX"]`.
|
||||||
|
* `namePrefix`: Prepends text to `${name}` parameter. In case of libraries, this
|
||||||
|
defaults to `"python3.5-"` for Python 3.5, etc., and in case of applications
|
||||||
|
to `""`.
|
||||||
|
* `pythonPath ? []`: List of packages to be added into `$PYTHONPATH`. Packages
|
||||||
|
in `pythonPath` are not propagated (contrary to `propagatedBuildInputs`).
|
||||||
* `preShellHook`: Hook to execute commands before `shellHook`.
|
* `preShellHook`: Hook to execute commands before `shellHook`.
|
||||||
* `postShellHook`: Hook to execute commands after `shellHook`.
|
* `postShellHook`: Hook to execute commands after `shellHook`.
|
||||||
* `removeBinByteCode ? true`: Remove bytecode from `/bin`. Bytecode is only created when the filenames end with `.py`.
|
* `removeBinByteCode ? true`: Remove bytecode from `/bin`. Bytecode is only
|
||||||
|
created when the filenames end with `.py`.
|
||||||
* `setupPyGlobalFlags ? []`: List of flags passed to `setup.py` command.
|
* `setupPyGlobalFlags ? []`: List of flags passed to `setup.py` command.
|
||||||
* `setupPyBuildFlags ? []`: List of flags passed to `setup.py build_ext` command.
|
* `setupPyBuildFlags ? []`: List of flags passed to `setup.py build_ext` command.
|
||||||
|
|
||||||
The `stdenv.mkDerivation` function accepts various parameters for describing build inputs (see "Specifying dependencies"). The following are of special
|
The `stdenv.mkDerivation` function accepts various parameters for describing
|
||||||
interest for Python packages, either because these are primarily used, or because their behaviour is different:
|
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 as well as the items listed in `setup_requires`.
|
* `nativeBuildInputs ? []`: Build-time only dependencies. Typically executables
|
||||||
* `buildInputs ? []`: Build and/or run-time dependencies that need to be be compiled for the host machine. Typically non-Python libraries which are being linked.
|
as well as the items listed in `setup_requires`.
|
||||||
* `checkInputs ? []`: Dependencies needed for running the `checkPhase`. These are added to `nativeBuildInputs` when `doCheck = true`. Items listed in `tests_require` go here.
|
* `buildInputs ? []`: Build and/or run-time dependencies that need to be be
|
||||||
* `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.
|
compiled for the host machine. Typically non-Python libraries which are being
|
||||||
|
linked.
|
||||||
|
* `checkInputs ? []`: Dependencies needed for running the `checkPhase`. These
|
||||||
|
are added to `nativeBuildInputs` when `doCheck = true`. Items listed in
|
||||||
|
`tests_require` go here.
|
||||||
|
* `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.
|
||||||
|
|
||||||
##### Overriding Python packages
|
##### Overriding Python packages
|
||||||
|
|
||||||
The `buildPythonPackage` function has a `overridePythonAttrs` method that
|
The `buildPythonPackage` function has a `overridePythonAttrs` method that can be
|
||||||
can be used to override the package. In the following example we create an
|
used to override the package. In the following example we create an environment
|
||||||
environment where we have the `blaze` package using an older version of `pandas`.
|
where we have the `blaze` package using an older version of `pandas`. We
|
||||||
We override first the Python interpreter and pass
|
override first the Python interpreter and pass `packageOverrides` which contains
|
||||||
`packageOverrides` which contains the overrides for packages in the package set.
|
the overrides for packages in the package set.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
@ -725,15 +782,18 @@ youtube-dl = with pythonPackages; toPythonApplication youtube-dl;
|
|||||||
#### `toPythonModule` function
|
#### `toPythonModule` function
|
||||||
|
|
||||||
In some cases, such as bindings, a package is created using
|
In some cases, such as bindings, a package is created using
|
||||||
`stdenv.mkDerivation` and added as attribute in `all-packages.nix`.
|
`stdenv.mkDerivation` and added as attribute in `all-packages.nix`. The Python
|
||||||
The Python bindings should be made available from `python-packages.nix`.
|
bindings should be made available from `python-packages.nix`. The
|
||||||
The `toPythonModule` function takes a derivation and makes certain Python-specific modifications.
|
`toPythonModule` function takes a derivation and makes certain Python-specific
|
||||||
|
modifications.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
opencv = toPythonModule (pkgs.opencv.override {
|
opencv = toPythonModule (pkgs.opencv.override {
|
||||||
enablePython = true;
|
enablePython = true;
|
||||||
pythonPackages = self;
|
pythonPackages = self;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Do pay attention to passing in the right Python version!
|
Do pay attention to passing in the right Python version!
|
||||||
|
|
||||||
#### `python.buildEnv` function
|
#### `python.buildEnv` function
|
||||||
@ -741,6 +801,7 @@ Do pay attention to passing in the right Python version!
|
|||||||
Python environments can be created using the low-level `pkgs.buildEnv` function.
|
Python environments can be created using the low-level `pkgs.buildEnv` function.
|
||||||
This example shows how to create an environment that has the Pyramid Web Framework.
|
This example shows how to create an environment that has the Pyramid Web Framework.
|
||||||
Saving the following as `default.nix`
|
Saving the following as `default.nix`
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
@ -751,6 +812,7 @@ python.buildEnv.override {
|
|||||||
```
|
```
|
||||||
|
|
||||||
and running `nix-build` will create
|
and running `nix-build` will create
|
||||||
|
|
||||||
```
|
```
|
||||||
/nix/store/cf1xhjwzmdki7fasgr4kz6di72ykicl5-python-2.7.8-env
|
/nix/store/cf1xhjwzmdki7fasgr4kz6di72ykicl5-python-2.7.8-env
|
||||||
```
|
```
|
||||||
@ -760,6 +822,7 @@ with wrapped binaries in `bin/`.
|
|||||||
You can also use the `env` attribute to create local environments with needed
|
You can also use the `env` attribute to create local environments with needed
|
||||||
packages installed. This is somewhat comparable to `virtualenv`. For example,
|
packages installed. This is somewhat comparable to `virtualenv`. For example,
|
||||||
running `nix-shell` with the following `shell.nix`
|
running `nix-shell` with the following `shell.nix`
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
@ -777,7 +840,8 @@ specified packages in its path.
|
|||||||
* `extraLibs`: List of packages installed inside the environment.
|
* `extraLibs`: List of packages installed inside the environment.
|
||||||
* `postBuild`: Shell command executed after the build of environment.
|
* `postBuild`: Shell command executed after the build of environment.
|
||||||
* `ignoreCollisions`: Ignore file collisions inside the environment (default is `false`).
|
* `ignoreCollisions`: Ignore file collisions inside the environment (default is `false`).
|
||||||
* `permitUserSite`: Skip setting the `PYTHONNOUSERSITE` environment variable in wrapped binaries in the environment.
|
* `permitUserSite`: Skip setting the `PYTHONNOUSERSITE` environment variable in
|
||||||
|
wrapped binaries in the environment.
|
||||||
|
|
||||||
#### `python.withPackages` function
|
#### `python.withPackages` function
|
||||||
|
|
||||||
@ -785,15 +849,17 @@ The `python.withPackages` function provides a simpler interface to the `python.b
|
|||||||
It takes a function as an argument that is passed the set of python packages and returns the list
|
It takes a function as an argument that is passed the set of python packages and returns the list
|
||||||
of the packages to be included in the environment. Using the `withPackages` function, the previous
|
of the packages to be included in the environment. Using the `withPackages` function, the previous
|
||||||
example for the Pyramid Web Framework environment can be written like this:
|
example for the Pyramid Web Framework environment can be written like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
python.withPackages (ps: [ps.pyramid])
|
python.withPackages (ps: [ps.pyramid])
|
||||||
```
|
```
|
||||||
|
|
||||||
`withPackages` passes the correct package set for the specific interpreter version as an
|
`withPackages` passes the correct package set for the specific interpreter
|
||||||
argument to the function. In the above example, `ps` equals `pythonPackages`.
|
version as an argument to the function. In the above example, `ps` equals
|
||||||
But you can also easily switch to using python3:
|
`pythonPackages`. But you can also easily switch to using python3:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
@ -802,27 +868,35 @@ python3.withPackages (ps: [ps.pyramid])
|
|||||||
|
|
||||||
Now, `ps` is set to `python3Packages`, matching the version of the interpreter.
|
Now, `ps` is set to `python3Packages`, matching the version of the interpreter.
|
||||||
|
|
||||||
As `python.withPackages` simply uses `python.buildEnv` under the hood, it also supports the `env`
|
As `python.withPackages` simply uses `python.buildEnv` under the hood, it also
|
||||||
attribute. The `shell.nix` file from the previous section can thus be also written like this:
|
supports the `env` attribute. The `shell.nix` file from the previous section can
|
||||||
|
thus be also written like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
(python36.withPackages (ps: [ps.numpy ps.requests])).env
|
(python36.withPackages (ps: [ps.numpy ps.requests])).env
|
||||||
```
|
```
|
||||||
|
|
||||||
In contrast to `python.buildEnv`, `python.withPackages` does not support the more advanced options
|
In contrast to `python.buildEnv`, `python.withPackages` does not support the
|
||||||
such as `ignoreCollisions = true` or `postBuild`. If you need them, you have to use `python.buildEnv`.
|
more advanced options such as `ignoreCollisions = true` or `postBuild`. If you
|
||||||
|
need them, you have to use `python.buildEnv`.
|
||||||
|
|
||||||
Python 2 namespace packages may provide `__init__.py` that collide. In that case `python.buildEnv`
|
Python 2 namespace packages may provide `__init__.py` that collide. In that case
|
||||||
should be used with `ignoreCollisions = true`.
|
`python.buildEnv` should be used with `ignoreCollisions = true`.
|
||||||
|
|
||||||
#### Setup hooks
|
#### Setup hooks
|
||||||
|
|
||||||
The following are setup hooks specifically for Python packages. Most of these are
|
The following are setup hooks specifically for Python packages. Most of these
|
||||||
used in `buildPythonPackage`.
|
are used in `buildPythonPackage`.
|
||||||
|
|
||||||
|
- `eggUnpackhook` to move an egg to the correct folder so it can be installed
|
||||||
|
with the `eggInstallHook`
|
||||||
|
- `eggBuildHook` to skip building for eggs.
|
||||||
|
- `eggInstallHook` to install eggs.
|
||||||
- `flitBuildHook` to build a wheel using `flit`.
|
- `flitBuildHook` to build a wheel using `flit`.
|
||||||
- `pipBuildHook` to build a wheel using `pip` and PEP 517. Note a build system (e.g. `setuptools` or `flit`) should still be added as `nativeBuildInput`.
|
- `pipBuildHook` to build a wheel using `pip` and PEP 517. Note a build system
|
||||||
|
(e.g. `setuptools` or `flit`) should still be added as `nativeBuildInput`.
|
||||||
- `pipInstallHook` to install wheels.
|
- `pipInstallHook` to install wheels.
|
||||||
- `pytestCheckHook` to run tests with `pytest`.
|
- `pytestCheckHook` to run tests with `pytest`.
|
||||||
- `pythonCatchConflictsHook` to check whether a Python package is not already existing.
|
- `pythonCatchConflictsHook` to check whether a Python package is not already existing.
|
||||||
@ -830,7 +904,10 @@ used in `buildPythonPackage`.
|
|||||||
- `pythonRemoveBinBytecode` to remove bytecode from the `/bin` folder.
|
- `pythonRemoveBinBytecode` to remove bytecode from the `/bin` folder.
|
||||||
- `setuptoolsBuildHook` to build a wheel using `setuptools`.
|
- `setuptoolsBuildHook` to build a wheel using `setuptools`.
|
||||||
- `setuptoolsCheckHook` to run tests with `python setup.py test`.
|
- `setuptoolsCheckHook` to run tests with `python setup.py test`.
|
||||||
- `wheelUnpackHook` to move a wheel to the correct folder so it can be installed with the `pipInstallHook`.
|
- `venvShellHook` to source a Python 3 `venv` at the `venvDir` location. A
|
||||||
|
`venv` is created if it does not yet exist.
|
||||||
|
- `wheelUnpackHook` to move a wheel to the correct folder so it can be installed
|
||||||
|
with the `pipInstallHook`.
|
||||||
|
|
||||||
### Development mode
|
### Development mode
|
||||||
|
|
||||||
@ -852,11 +929,11 @@ pythonPackages.buildPythonPackage {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Running `nix-shell` with no arguments should give you
|
Running `nix-shell` with no arguments should give you the environment in which
|
||||||
the environment in which the package would be built with
|
the package would be built with `nix-build`.
|
||||||
`nix-build`.
|
|
||||||
|
|
||||||
Shortcut to setup environments with C headers/libraries and python packages:
|
Shortcut to setup environments with C headers/libraries and python packages:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-shell -p pythonPackages.pyramid zlib libjpeg git
|
nix-shell -p pythonPackages.pyramid zlib libjpeg git
|
||||||
```
|
```
|
||||||
@ -868,19 +945,22 @@ Note: There is a boolean value `lib.inNixShell` set to `true` if nix-shell is in
|
|||||||
Packages inside nixpkgs are written by hand. However many tools exist in
|
Packages inside nixpkgs are written by hand. However many tools exist in
|
||||||
community to help save time. No tool is preferred at the moment.
|
community to help save time. No tool is preferred at the moment.
|
||||||
|
|
||||||
- [pypi2nix](https://github.com/nix-community/pypi2nix): Generate Nix expressions for your Python project. Note that [sharing derivations from pypi2nix with nixpkgs is possible but not encouraged](https://github.com/nix-community/pypi2nix/issues/222#issuecomment-443497376).
|
- [pypi2nix](https://github.com/nix-community/pypi2nix): Generate Nix
|
||||||
|
expressions for your Python project. Note that [sharing derivations from
|
||||||
|
pypi2nix with nixpkgs is possible but not
|
||||||
|
encouraged](https://github.com/nix-community/pypi2nix/issues/222#issuecomment-443497376).
|
||||||
- [python2nix](https://github.com/proger/python2nix) by Vladimir Kirillov.
|
- [python2nix](https://github.com/proger/python2nix) by Vladimir Kirillov.
|
||||||
|
|
||||||
### Deterministic builds
|
### Deterministic builds
|
||||||
|
|
||||||
The Python interpreters are now built deterministically.
|
The Python interpreters are now built deterministically. Minor modifications had
|
||||||
Minor modifications had to be made to the interpreters in order to generate
|
to be made to the interpreters in order to generate deterministic bytecode. This
|
||||||
deterministic bytecode. This has security implications and is relevant for
|
has security implications and is relevant for those using Python in a
|
||||||
those using Python in a `nix-shell`.
|
`nix-shell`.
|
||||||
|
|
||||||
When the environment variable `DETERMINISTIC_BUILD` is set, all bytecode will have timestamp 1.
|
When the environment variable `DETERMINISTIC_BUILD` is set, all bytecode will
|
||||||
The `buildPythonPackage` function sets `DETERMINISTIC_BUILD=1` and
|
have timestamp 1. The `buildPythonPackage` function sets `DETERMINISTIC_BUILD=1`
|
||||||
[PYTHONHASHSEED=0](https://docs.python.org/3.5/using/cmdline.html#envvar-PYTHONHASHSEED).
|
and [PYTHONHASHSEED=0](https://docs.python.org/3.5/using/cmdline.html#envvar-PYTHONHASHSEED).
|
||||||
Both are also exported in `nix-shell`.
|
Both are also exported in `nix-shell`.
|
||||||
|
|
||||||
|
|
||||||
@ -895,9 +975,10 @@ example of such a situation is when `py.test` is used.
|
|||||||
|
|
||||||
#### Common issues
|
#### Common issues
|
||||||
|
|
||||||
- Non-working tests can often be deselected. By default `buildPythonPackage` runs `python setup.py test`.
|
* Non-working tests can often be deselected. By default `buildPythonPackage`
|
||||||
Most python modules follows the standard test protocol where the pytest runner can be used instead.
|
runs `python setup.py test`. Most python modules follows the standard test
|
||||||
`py.test` supports a `-k` parameter to ignore test methods or classes:
|
protocol where the pytest runner can be used instead. `py.test` supports a
|
||||||
|
`-k` parameter to ignore test methods or classes:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
buildPythonPackage {
|
buildPythonPackage {
|
||||||
@ -909,7 +990,8 @@ 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)`
|
* 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)`
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
@ -921,8 +1003,9 @@ should also be done when packaging `A`.
|
|||||||
|
|
||||||
### How to override a Python package?
|
### How to override a Python package?
|
||||||
|
|
||||||
We can override the interpreter and pass `packageOverrides`.
|
We can override the interpreter and pass `packageOverrides`. In the following
|
||||||
In the following example we rename the `pandas` package and build it.
|
example we rename the `pandas` package and build it.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
@ -935,14 +1018,16 @@ with import <nixpkgs> {};
|
|||||||
|
|
||||||
in python.withPackages(ps: [ps.pandas])).env
|
in python.withPackages(ps: [ps.pandas])).env
|
||||||
```
|
```
|
||||||
|
|
||||||
Using `nix-build` on this expression will build an environment that contains the
|
Using `nix-build` on this expression will build an environment that contains the
|
||||||
package `pandas` but with the new name `foo`.
|
package `pandas` but with the new name `foo`.
|
||||||
|
|
||||||
All packages in the package set will use the renamed package.
|
All packages in the package set will use the renamed package. A typical use case
|
||||||
A typical use case is to switch to another version of a certain package.
|
is to switch to another version of a certain package. For example, in the
|
||||||
For example, in the Nixpkgs repository we have multiple versions of `django` and `scipy`.
|
Nixpkgs repository we have multiple versions of `django` and `scipy`. In the
|
||||||
In the following example we use a different version of `scipy` and create an environment that uses it.
|
following example we use a different version of `scipy` and create an
|
||||||
All packages in the Python package set will now use the updated `scipy` version.
|
environment that uses it. All packages in the Python package set will now use
|
||||||
|
the updated `scipy` version.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> {};
|
||||||
@ -954,10 +1039,13 @@ with import <nixpkgs> {};
|
|||||||
in (pkgs.python35.override {inherit packageOverrides;}).withPackages (ps: [ps.blaze])
|
in (pkgs.python35.override {inherit packageOverrides;}).withPackages (ps: [ps.blaze])
|
||||||
).env
|
).env
|
||||||
```
|
```
|
||||||
|
|
||||||
The requested package `blaze` depends on `pandas` which itself depends on `scipy`.
|
The requested package `blaze` depends on `pandas` which itself depends on `scipy`.
|
||||||
|
|
||||||
If you want the whole of Nixpkgs to use your modifications, then you can use `overlays`
|
If you want the whole of Nixpkgs to use your modifications, then you can use
|
||||||
as explained in this manual. In the following example we build a `inkscape` using a different version of `numpy`.
|
`overlays` as explained in this manual. In the following example we build a
|
||||||
|
`inkscape` using a different version of `numpy`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> {};
|
pkgs = import <nixpkgs> {};
|
||||||
@ -978,19 +1066,28 @@ Executing `python setup.py bdist_wheel` in a `nix-shell `fails with
|
|||||||
ValueError: ZIP does not support timestamps before 1980
|
ValueError: ZIP does not support timestamps before 1980
|
||||||
```
|
```
|
||||||
|
|
||||||
This is because files from the Nix store (which have a timestamp of the UNIX epoch of January 1, 1970) are included in the .ZIP, but .ZIP archives follow the DOS convention of counting timestamps from 1980.
|
This is because files from the Nix store (which have a timestamp of the UNIX
|
||||||
|
epoch of January 1, 1970) are included in the .ZIP, but .ZIP archives follow the
|
||||||
|
DOS convention of counting timestamps from 1980.
|
||||||
|
|
||||||
The command `bdist_wheel` reads the `SOURCE_DATE_EPOCH` environment variable, which `nix-shell` sets to 1. Unsetting this variable or giving it a value corresponding to 1980 or later enables building wheels.
|
The command `bdist_wheel` reads the `SOURCE_DATE_EPOCH` environment variable,
|
||||||
|
which `nix-shell` sets to 1. Unsetting this variable or giving it a value
|
||||||
|
corresponding to 1980 or later enables building wheels.
|
||||||
|
|
||||||
Use 1980 as timestamp:
|
Use 1980 as timestamp:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-shell --run "SOURCE_DATE_EPOCH=315532800 python3 setup.py bdist_wheel"
|
nix-shell --run "SOURCE_DATE_EPOCH=315532800 python3 setup.py bdist_wheel"
|
||||||
```
|
```
|
||||||
|
|
||||||
or the current time:
|
or the current time:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-shell --run "SOURCE_DATE_EPOCH=$(date +%s) python3 setup.py bdist_wheel"
|
nix-shell --run "SOURCE_DATE_EPOCH=$(date +%s) python3 setup.py bdist_wheel"
|
||||||
```
|
```
|
||||||
|
|
||||||
or unset `SOURCE_DATE_EPOCH`:
|
or unset `SOURCE_DATE_EPOCH`:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-shell --run "unset SOURCE_DATE_EPOCH; python3 setup.py bdist_wheel"
|
nix-shell --run "unset SOURCE_DATE_EPOCH; python3 setup.py bdist_wheel"
|
||||||
```
|
```
|
||||||
@ -998,13 +1095,18 @@ nix-shell --run "unset SOURCE_DATE_EPOCH; python3 setup.py bdist_wheel"
|
|||||||
### `install_data` / `data_files` problems
|
### `install_data` / `data_files` problems
|
||||||
|
|
||||||
If you get the following error:
|
If you get the following error:
|
||||||
|
|
||||||
```
|
```
|
||||||
could not create '/nix/store/6l1bvljpy8gazlsw2aw9skwwp4pmvyxw-python-2.7.8/etc':
|
could not create '/nix/store/6l1bvljpy8gazlsw2aw9skwwp4pmvyxw-python-2.7.8/etc':
|
||||||
Permission denied
|
Permission denied
|
||||||
```
|
```
|
||||||
This is a [known bug](https://github.com/pypa/setuptools/issues/130) in `setuptools`.
|
|
||||||
Setuptools `install_data` does not respect `--prefix`. An example of such package using the feature is `pkgs/tools/X11/xpra/default.nix`.
|
This is a [known bug](https://github.com/pypa/setuptools/issues/130) in
|
||||||
|
`setuptools`. Setuptools `install_data` does not respect `--prefix`. An example
|
||||||
|
of such package using the feature is `pkgs/tools/X11/xpra/default.nix`.
|
||||||
|
|
||||||
As workaround install it as an extra `preInstall` step:
|
As workaround install it as an extra `preInstall` step:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
${python.interpreter} setup.py install_data --install-dir=$out --root=$out
|
${python.interpreter} setup.py install_data --install-dir=$out --root=$out
|
||||||
sed -i '/ = data\_files/d' setup.py
|
sed -i '/ = data\_files/d' setup.py
|
||||||
@ -1025,36 +1127,44 @@ If you want to create a Python environment for development, then the recommended
|
|||||||
method is to use `nix-shell`, either with or without the `python.buildEnv`
|
method is to use `nix-shell`, either with or without the `python.buildEnv`
|
||||||
function.
|
function.
|
||||||
|
|
||||||
### How to consume python modules using pip in a virtualenv like I am used to on other Operating Systems ?
|
### How to consume python modules using pip in a virtual environment like I am used to on other Operating Systems?
|
||||||
|
|
||||||
This is an example of a `default.nix` for a `nix-shell`, which allows to consume a `virtualenv` environment,
|
While this approach is not very idiomatic from Nix perspective, it can still be
|
||||||
and install python modules through `pip` the traditional way.
|
useful when dealing with pre-existing projects or in situations where it's not
|
||||||
|
feasible or desired to write derivations for all required dependencies.
|
||||||
|
|
||||||
Create this `default.nix` file, together with a `requirements.txt` and simply execute `nix-shell`.
|
This is an example of a `default.nix` for a `nix-shell`, which allows to consume
|
||||||
|
a virtual environment created by `venv`, and install python modules through
|
||||||
|
`pip` the traditional way.
|
||||||
|
|
||||||
|
Create this `default.nix` file, together with a `requirements.txt` and simply
|
||||||
|
execute `nix-shell`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {};
|
with import <nixpkgs> { };
|
||||||
|
|
||||||
let
|
let
|
||||||
pythonPackages = python27Packages;
|
pythonPackages = python3Packages;
|
||||||
in
|
in pkgs.mkShell rec {
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "impurePythonEnv";
|
name = "impurePythonEnv";
|
||||||
|
venvDir = "./.venv";
|
||||||
src = null;
|
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
# these packages are required for virtualenv and pip to work:
|
# A python interpreter including the 'venv' module is required to bootstrap
|
||||||
#
|
# the environment.
|
||||||
pythonPackages.virtualenv
|
pythonPackages.python
|
||||||
pythonPackages.pip
|
|
||||||
# the following packages are related to the dependencies of your python
|
# This execute some shell code to initialize a venv in $venvDir before
|
||||||
# project.
|
# dropping into the shell
|
||||||
# In this particular example the python modules listed in the
|
pythonPackages.venvShellHook
|
||||||
# requirements.txt require the following packages to be installed locally
|
|
||||||
# in order to compile any binary extensions they may require.
|
# Those are dependencies that we would like to use from nixpkgs, which will
|
||||||
#
|
# add them to PYTHONPATH and thus make them accessible from within the venv.
|
||||||
|
pythonPackages.numpy
|
||||||
|
pythonPackages.requests
|
||||||
|
|
||||||
|
# In this particular example, in order to compile any binary extensions they may
|
||||||
|
# require, the python modules listed in the hypothetical requirements.txt need
|
||||||
|
# the following packages to be installed locally:
|
||||||
taglib
|
taglib
|
||||||
openssl
|
openssl
|
||||||
git
|
git
|
||||||
@ -1064,11 +1174,55 @@ stdenv.mkDerivation {
|
|||||||
zlib
|
zlib
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Now we can execute any commands within the virtual environment.
|
||||||
|
# This is optional and can be left out to run pip manually.
|
||||||
|
postShellHook = ''
|
||||||
|
pip install -r requirements.txt
|
||||||
|
'';
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In case the supplied venvShellHook is insufficient, or when python 2 support is
|
||||||
|
needed, you can define your own shell hook and adapt to your needs like in the
|
||||||
|
following example:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
with import <nixpkgs> { };
|
||||||
|
|
||||||
|
let
|
||||||
|
venvDir = "./.venv";
|
||||||
|
pythonPackages = python3Packages;
|
||||||
|
in pkgs.mkShell rec {
|
||||||
|
name = "impurePythonEnv";
|
||||||
|
buildInputs = [
|
||||||
|
pythonPackages.python
|
||||||
|
# Needed when using python 2.7
|
||||||
|
# pythonPackages.virtualenv
|
||||||
|
# ...
|
||||||
|
];
|
||||||
|
|
||||||
|
# This is very close to how venvShellHook is implemented, but
|
||||||
|
# adapted to use 'virtualenv'
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
# set SOURCE_DATE_EPOCH so that we can use python wheels
|
|
||||||
SOURCE_DATE_EPOCH=$(date +%s)
|
SOURCE_DATE_EPOCH=$(date +%s)
|
||||||
virtualenv --python=${pythonPackages.python.interpreter} --no-setuptools venv
|
|
||||||
export PATH=$PWD/venv/bin:$PATH
|
if [ -d "${venvDir}" ]; then
|
||||||
|
echo "Skipping venv creation, '${venvDir}' already exists"
|
||||||
|
else
|
||||||
|
echo "Creating new venv environment in path: '${venvDir}'"
|
||||||
|
# Note that the module venv was only introduced in python 3, so for 2.7
|
||||||
|
# this needs to be replaced with a call to virtualenv
|
||||||
|
${pythonPackages.python.interpreter} -m venv "${venvDir}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Under some circumstances it might be necessary to add your virtual
|
||||||
|
# environment to PYTHONPATH, which you can do here too;
|
||||||
|
# PYTHONPATH=$PWD/${venvDir}/${pythonPackages.python.sitePackages}/:$PYTHONPATH
|
||||||
|
|
||||||
|
source "${venvDir}/bin/activate"
|
||||||
|
|
||||||
|
# As in the previous example, this is optional.
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@ -1100,11 +1254,11 @@ If you need to change a package's attribute(s) from `configuration.nix` you coul
|
|||||||
```
|
```
|
||||||
|
|
||||||
`pythonPackages.zerobin` is now globally overridden. All packages and also the
|
`pythonPackages.zerobin` is now globally overridden. All packages and also the
|
||||||
`zerobin` NixOS service use the new definition.
|
`zerobin` NixOS service use the new definition. Note that `python-super` refers
|
||||||
Note that `python-super` refers to the old package set and `python-self`
|
to the old package set and `python-self` to the new, overridden version.
|
||||||
to the new, overridden version.
|
|
||||||
|
|
||||||
To modify only a Python package set instead of a whole Python derivation, use this snippet:
|
To modify only a Python package set instead of a whole Python derivation, use
|
||||||
|
this snippet:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
myPythonPackages = pythonPackages.override {
|
myPythonPackages = pythonPackages.override {
|
||||||
@ -1136,11 +1290,12 @@ self: super: {
|
|||||||
|
|
||||||
### How to use Intel's MKL with numpy and scipy?
|
### How to use Intel's MKL with numpy and scipy?
|
||||||
|
|
||||||
A `site.cfg` is created that configures BLAS based on the `blas` parameter
|
A `site.cfg` is created that configures BLAS based on the `blas` parameter of
|
||||||
of the `numpy` derivation. By passing in `mkl`, `numpy` and packages depending
|
the `numpy` derivation. By passing in `mkl`, `numpy` and packages depending on
|
||||||
on `numpy` will be built with `mkl`.
|
`numpy` will be built with `mkl`.
|
||||||
|
|
||||||
The following is an overlay that configures `numpy` to use `mkl`:
|
The following is an overlay that configures `numpy` to use `mkl`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
self: super: {
|
self: super: {
|
||||||
python37 = super.python37.override {
|
python37 = super.python37.override {
|
||||||
@ -1176,10 +1331,21 @@ In a `setup.py` or `setup.cfg` it is common to declare dependencies:
|
|||||||
|
|
||||||
Following rules are desired to be respected:
|
Following rules are desired to be respected:
|
||||||
|
|
||||||
* Python libraries are called from `python-packages.nix` and packaged with `buildPythonPackage`. The expression of a library should be in `pkgs/development/python-modules/<name>/default.nix`. Libraries in `pkgs/top-level/python-packages.nix` are sorted quasi-alphabetically to avoid merge conflicts.
|
* Python libraries are called from `python-packages.nix` and packaged with
|
||||||
* Python applications live outside of `python-packages.nix` and are packaged with `buildPythonApplication`.
|
`buildPythonPackage`. The expression of a library should be in
|
||||||
|
`pkgs/development/python-modules/<name>/default.nix`. Libraries in
|
||||||
|
`pkgs/top-level/python-packages.nix` are sorted quasi-alphabetically to avoid
|
||||||
|
merge conflicts.
|
||||||
|
* Python applications live outside of `python-packages.nix` and are packaged
|
||||||
|
with `buildPythonApplication`.
|
||||||
* Make sure libraries build for all Python interpreters.
|
* Make sure libraries build for all Python interpreters.
|
||||||
* By default we enable tests. Make sure the tests are found and, in the case of libraries, are passing for all interpreters. If certain tests fail they can be disabled individually. Try to avoid disabling the tests altogether. In any case, when you disable tests, leave a comment explaining why.
|
* By default we enable tests. Make sure the tests are found and, in the case of
|
||||||
* Commit names of Python libraries should reflect that they are Python libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
|
libraries, are passing for all interpreters. If certain tests fail they can be
|
||||||
* Attribute names in `python-packages.nix` should be normalized according to [PEP 0503](https://www.python.org/dev/peps/pep-0503/#normalized-names).
|
disabled individually. Try to avoid disabling the tests altogether. In any
|
||||||
This means that characters should be converted to lowercase and `.` and `_` should be replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz )
|
case, when you disable tests, leave a comment explaining why.
|
||||||
|
* Commit names of Python libraries should reflect that they are Python
|
||||||
|
libraries, so write for example `pythonPackages.numpy: 1.11 -> 1.12`.
|
||||||
|
* Attribute names in `python-packages.nix` should be normalized according to
|
||||||
|
[PEP 0503](https://www.python.org/dev/peps/pep-0503/#normalized-names). This
|
||||||
|
means that characters should be converted to lowercase and `.` and `_` should
|
||||||
|
be replaced by a single `-` (foo-bar-baz instead of Foo__Bar.baz )
|
||||||
|
@ -32,7 +32,7 @@ bundlerEnv rec {
|
|||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A monitoring framework that aims to be simple, malleable, and scalable";
|
description = "A monitoring framework that aims to be simple, malleable, and scalable";
|
||||||
homepage = http://sensuapp.org/;
|
homepage = "http://sensuapp.org/";
|
||||||
license = with licenses; mit;
|
license = with licenses; mit;
|
||||||
maintainers = with maintainers; [ theuni ];
|
maintainers = with maintainers; [ theuni ];
|
||||||
platforms = platforms.unix;
|
platforms = platforms.unix;
|
||||||
@ -69,7 +69,7 @@ bundlerApp {
|
|||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Tool and libraries for maintaining Ruby gems.";
|
description = "Tool and libraries for maintaining Ruby gems.";
|
||||||
homepage = https://github.com/nyarly/corundum;
|
homepage = "https://github.com/nyarly/corundum";
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = [ maintainers.nyarly ];
|
maintainers = [ maintainers.nyarly ];
|
||||||
platforms = platforms.unix;
|
platforms = platforms.unix;
|
||||||
|
@ -16,12 +16,6 @@ cargo
|
|||||||
into the `environment.systemPackages` or bring them into
|
into the `environment.systemPackages` or bring them into
|
||||||
scope with `nix-shell -p rustc cargo`.
|
scope with `nix-shell -p rustc cargo`.
|
||||||
|
|
||||||
> If you are using NixOS and you want to use rust without a nix expression you
|
|
||||||
> probably want to add the following in your `configuration.nix` to build
|
|
||||||
> crates with C dependencies.
|
|
||||||
>
|
|
||||||
> environment.systemPackages = [binutils gcc gnumake openssl pkgconfig]
|
|
||||||
|
|
||||||
For daily builds (beta and nightly) use either rustup from
|
For daily builds (beta and nightly) use either rustup from
|
||||||
nixpkgs or use the [Rust nightlies
|
nixpkgs or use the [Rust nightlies
|
||||||
overlay](#using-the-rust-nightlies-overlay).
|
overlay](#using-the-rust-nightlies-overlay).
|
||||||
@ -32,22 +26,21 @@ Rust applications are packaged by using the `buildRustPackage` helper from `rust
|
|||||||
|
|
||||||
```
|
```
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
name = "ripgrep-${version}";
|
pname = "ripgrep";
|
||||||
version = "0.4.0";
|
version = "11.0.2";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "BurntSushi";
|
owner = "BurntSushi";
|
||||||
repo = "ripgrep";
|
repo = pname;
|
||||||
rev = "${version}";
|
rev = version;
|
||||||
sha256 = "0y5d1n6hkw85jb3rblcxqas2fp82h3nghssa4xqrhqnz25l799pj";
|
sha256 = "1iga3320mgi7m853la55xip514a3chqsdi1a1rwv25lr9b1p7vd3";
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoSha256 = "0q68qyl2h6i0qsz82z840myxlnjay8p1w5z7hfyr8fqp7wgwa9cx";
|
cargoSha256 = "17ldqr3asrdcsh4l29m3b5r37r5d0b3npq1lrgjmxb6vlx6a36qh";
|
||||||
verifyCargoDeps = true;
|
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "A fast line-oriented regex search tool, similar to ag and ack";
|
description = "A fast line-oriented regex search tool, similar to ag and ack";
|
||||||
homepage = https://github.com/BurntSushi/ripgrep;
|
homepage = "https://github.com/BurntSushi/ripgrep";
|
||||||
license = licenses.unlicense;
|
license = licenses.unlicense;
|
||||||
maintainers = [ maintainers.tailhook ];
|
maintainers = [ maintainers.tailhook ];
|
||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
@ -60,13 +53,16 @@ all crate sources of this package. Currently it is obtained by inserting a
|
|||||||
fake checksum into the expression and building the package once. The correct
|
fake checksum into the expression and building the package once. The correct
|
||||||
checksum can be then take from the failed build.
|
checksum can be then take from the failed build.
|
||||||
|
|
||||||
When the `Cargo.lock`, provided by upstream, is not in sync with the
|
Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
|
||||||
`Cargo.toml`, it is possible to use `cargoPatches` to update it. All patches
|
best practices guide, Rust applications should always commit the `Cargo.lock`
|
||||||
added in `cargoPatches` will also be prepended to the patches in `patches` at
|
file in git to ensure a reproducible build. However, a few packages do not, and
|
||||||
build-time.
|
Nix depends on this file, so if it missing you can use `cargoPatches` to apply
|
||||||
|
it in the `patchPhase`. Consider sending a PR upstream with a note to the
|
||||||
|
maintainer describing why it's important to include in the application.
|
||||||
|
|
||||||
When `verifyCargoDeps` is set to `true`, the build will also verify that the
|
The fetcher will verify that the `Cargo.lock` file is in sync with the `src`
|
||||||
`cargoSha256` is not out of date by comparing the `Cargo.lock` file in both the `cargoDeps` and `src`. Note that this option changes the value of `cargoSha256` since it also copies the `Cargo.lock` in it. To avoid breaking backward-compatibility this option is not enabled by default but hopefully will be in the future.
|
attribute, and fail the build if not. It will also will compress the vendor
|
||||||
|
directory into a tar.gz archive.
|
||||||
|
|
||||||
### Building a crate for a different target
|
### Building a crate for a different target
|
||||||
|
|
||||||
|
@ -59,6 +59,97 @@ nix-repl> texlive.collection-<TAB>
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-language-texlive-custom-packages">
|
||||||
|
<title>Custom packages</title>
|
||||||
|
<para>
|
||||||
|
You may find that you need to use an external TeX package. A derivation for such package has to provide contents of the "texmf" directory in its output and provide the <varname>tlType</varname> attribute. Here is a (very verbose) example:
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
let
|
||||||
|
foiltex_run = stdenvNoCC.mkDerivation {
|
||||||
|
pname = "latex-foiltex";
|
||||||
|
version = "2.1.4b";
|
||||||
|
passthru.tlType = "run";
|
||||||
|
|
||||||
|
srcs = [
|
||||||
|
(fetchurl {
|
||||||
|
url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.dtx";
|
||||||
|
sha256 = "07frz0krpz7kkcwlayrwrj2a2pixmv0icbngyw92srp9fp23cqpz";
|
||||||
|
})
|
||||||
|
(fetchurl {
|
||||||
|
url = "http://mirrors.ctan.org/macros/latex/contrib/foiltex/foiltex.ins";
|
||||||
|
sha256 = "09wkyidxk3n3zvqxfs61wlypmbhi1pxmjdi1kns9n2ky8ykbff99";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
unpackPhase = ''
|
||||||
|
runHook preUnpack
|
||||||
|
|
||||||
|
for _src in $srcs; do
|
||||||
|
cp "$_src" $(stripHash "$_src")
|
||||||
|
done
|
||||||
|
|
||||||
|
runHook postUnpack
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [ texlive.combined.scheme-small ];
|
||||||
|
|
||||||
|
dontConfigure = true;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
# Generate the style files
|
||||||
|
latex foiltex.ins
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
path="$out/tex/latex/foiltex"
|
||||||
|
mkdir -p "$path"
|
||||||
|
cp *.{cls,def,clo} "$path/"
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "A LaTeX2e class for overhead transparencies";
|
||||||
|
license = licenses.unfreeRedistributable;
|
||||||
|
maintainers = with maintainers; [ veprbl ];
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
foiltex = { pkgs = [ foiltex_run ]; };
|
||||||
|
|
||||||
|
latex_with_foiltex = texlive.combine {
|
||||||
|
inherit (texlive) scheme-small;
|
||||||
|
inherit foiltex;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
runCommand "test.pdf" {
|
||||||
|
nativeBuildInputs = [ latex_with_foiltex ];
|
||||||
|
} ''
|
||||||
|
cat >test.tex <<EOF
|
||||||
|
\documentclass{foils}
|
||||||
|
|
||||||
|
\title{Presentation title}
|
||||||
|
\date{}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\maketitle
|
||||||
|
\end{document}
|
||||||
|
EOF
|
||||||
|
pdflatex test.tex
|
||||||
|
cp test.pdf $out
|
||||||
|
''
|
||||||
|
]]></programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section xml:id="sec-language-texlive-known-problems">
|
<section xml:id="sec-language-texlive-known-problems">
|
||||||
<title>Known problems</title>
|
<title>Known problems</title>
|
||||||
|
|
||||||
|
@ -261,12 +261,7 @@ deoplete-fish = super.deoplete-fish.overrideAttrs(old: {
|
|||||||
|
|
||||||
Sometimes plugins require an override that must be changed when the plugin is updated. This can cause issues when Vim plugins are auto-updated but the associated override isn't updated. For these plugins, the override should be written so that it specifies all information required to install the plugin, and running `./update.py` doesn't change the derivation for the plugin. Manually updating the override is required to update these types of plugins. An example of such a plugin is `LanguageClient-neovim`.
|
Sometimes plugins require an override that must be changed when the plugin is updated. This can cause issues when Vim plugins are auto-updated but the associated override isn't updated. For these plugins, the override should be written so that it specifies all information required to install the plugin, and running `./update.py` doesn't change the derivation for the plugin. Manually updating the override is required to update these types of plugins. An example of such a plugin is `LanguageClient-neovim`.
|
||||||
|
|
||||||
To add a new plugin:
|
To add a new plugin, run `./update.py --add "[owner]/[name]"`. **NOTE**: This script automatically commits to your git repository. Be sure to check out a fresh branch before running.
|
||||||
|
|
||||||
1. run `./update.py` and create a commit named "vimPlugins: Update",
|
|
||||||
2. add the new plugin to [vim-plugin-names](/pkgs/misc/vim-plugins/vim-plugin-names) and add overrides if required to [overrides.nix](/pkgs/misc/vim-plugins/overrides.nix),
|
|
||||||
3. run `./update.py` again and create a commit named "vimPlugins.[name]: init at [version]" (where `name` and `version` can be found in [generated.nix](/pkgs/misc/vim-plugins/generated.nix)), and
|
|
||||||
4. create a pull request.
|
|
||||||
|
|
||||||
## Important repositories
|
## Important repositories
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ stdenv.mkDerivation {
|
|||||||
name = "binutils-2.16.1-arm";
|
name = "binutils-2.16.1-arm";
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = http://ftp.nluug.nl/gnu/binutils/binutils-2.16.1.tar.bz2;
|
url = "http://ftp.nluug.nl/gnu/binutils/binutils-2.16.1.tar.bz2";
|
||||||
sha256 = "1ian3kwh2vg6hr3ymrv48s04gijs539vzrq62xr76bxbhbwnz2np";
|
sha256 = "1ian3kwh2vg6hr3ymrv48s04gijs539vzrq62xr76bxbhbwnz2np";
|
||||||
};
|
};
|
||||||
inherit noSysDirs;
|
inherit noSysDirs;
|
||||||
@ -84,7 +84,7 @@ stdenv.mkDerivation {
|
|||||||
name = "linux-headers-2.6.13.1-arm";
|
name = "linux-headers-2.6.13.1-arm";
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.13.1.tar.bz2;
|
url = "http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.13.1.tar.bz2";
|
||||||
sha256 = "12qxmc827fjhaz53kjy7vyrzsaqcg78amiqsb3qm20z26w705lma";
|
sha256 = "12qxmc827fjhaz53kjy7vyrzsaqcg78amiqsb3qm20z26w705lma";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,22 @@
|
|||||||
.docbook .xref img[src^=images\/callouts\/],
|
.docbook .xref img[src^=images\/callouts\/],
|
||||||
.screen img,
|
.screen img,
|
||||||
.programlisting img {
|
.programlisting img,
|
||||||
|
.literallayout img,
|
||||||
|
.synopsis img {
|
||||||
width: 1em;
|
width: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.calloutlist img {
|
.calloutlist img {
|
||||||
width: 1.5em;
|
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;
|
||||||
|
}
|
||||||
|
@ -37,7 +37,7 @@ security updates. More up to date packages and modules are available via the
|
|||||||
|
|
||||||
Both `nixos-unstable` and `nixpkgs` follow the `master` branch of the Nixpkgs
|
Both `nixos-unstable` and `nixpkgs` follow the `master` branch of the Nixpkgs
|
||||||
repository, although both do lag the `master` branch by generally
|
repository, although both do lag the `master` branch by generally
|
||||||
[a couple of days](https://howoldis.herokuapp.com/). Updates to a channel are
|
[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.
|
distributed as soon as all tests for that channel pass, e.g.
|
||||||
[this table](https://hydra.nixos.org/job/nixpkgs/trunk/unstable#tabs-constituents)
|
[this table](https://hydra.nixos.org/job/nixpkgs/trunk/unstable#tabs-constituents)
|
||||||
shows the status of tests for the `nixpkgs` channel.
|
shows the status of tests for the `nixpkgs` channel.
|
||||||
|
@ -190,7 +190,7 @@ preConfigure = "configureFlagsArray=(\"CFLAGS=-O0 -g\")";</programlisting>
|
|||||||
The function <function>fetchurl</function> now has support for two different kinds of mirroring of files. First, it has support for <emphasis>content-addressable mirrors</emphasis>. For example, given the <function>fetchurl</function> call
|
The function <function>fetchurl</function> now has support for two different kinds of mirroring of files. First, it has support for <emphasis>content-addressable mirrors</emphasis>. For example, given the <function>fetchurl</function> call
|
||||||
<programlisting>
|
<programlisting>
|
||||||
fetchurl {
|
fetchurl {
|
||||||
url = http://releases.mozilla.org/<replaceable>...</replaceable>/firefox-2.0.0.6-source.tar.bz2;
|
url = "http://releases.mozilla.org/<replaceable>...</replaceable>/firefox-2.0.0.6-source.tar.bz2";
|
||||||
sha1 = "eb72f55e4a8bf08e8c6ef227c0ade3d068ba1082";
|
sha1 = "eb72f55e4a8bf08e8c6ef227c0ade3d068ba1082";
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
<function>fetchurl</function> will first try to download this file from <link
|
<function>fetchurl</function> will first try to download this file from <link
|
||||||
|
@ -256,7 +256,7 @@
|
|||||||
</question>
|
</question>
|
||||||
<answer>
|
<answer>
|
||||||
<para>
|
<para>
|
||||||
<programlisting>doCheck = stdenv.hostPlatform != stdenv.buildPlatfrom;</programlisting>
|
<programlisting>doCheck = stdenv.hostPlatform == stdenv.buildPlatfrom;</programlisting>
|
||||||
Add it to your <function>mkDerivation</function> invocation.
|
Add it to your <function>mkDerivation</function> invocation.
|
||||||
</para>
|
</para>
|
||||||
</answer>
|
</answer>
|
||||||
|
@ -11,7 +11,7 @@ meta = with stdenv.lib; {
|
|||||||
GNU Hello is a program that prints "Hello, world!" when you run it.
|
GNU Hello is a program that prints "Hello, world!" when you run it.
|
||||||
It is fully customizable.
|
It is fully customizable.
|
||||||
'';
|
'';
|
||||||
homepage = https://www.gnu.org/software/hello/manual/;
|
homepage = "https://www.gnu.org/software/hello/manual/";
|
||||||
license = licenses.gpl3Plus;
|
license = licenses.gpl3Plus;
|
||||||
maintainers = [ maintainers.eelco ];
|
maintainers = [ maintainers.eelco ];
|
||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The reason for why <literal>glibc</literal> deviates from the convention is because referencing a library provided by <literal>glibc</literal> is a very common operation among Nix packages. For instance, third-party executables packaged by Nix are typically patched and relinked with the relevant version of <literal>glibc</literal> libraries from Nix packages (please see the documentation on <link xlink:href="https://nixos.org/patchelf.html">patchelf</link> for more details).
|
The reason for why <literal>glibc</literal> deviates from the convention is because referencing a library provided by <literal>glibc</literal> is a very common operation among Nix packages. For instance, third-party executables packaged by Nix are typically patched and relinked with the relevant version of <literal>glibc</literal> libraries from Nix packages (please see the documentation on <link xlink:href="https://github.com/NixOS/patchelf/blob/master/README">patchelf</link> for more details).
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "libfoo-1.2.3";
|
name = "libfoo-1.2.3";
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = http://example.org/libfoo-1.2.3.tar.bz2;
|
url = "http://example.org/libfoo-1.2.3.tar.bz2";
|
||||||
sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
|
sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m";
|
||||||
};
|
};
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
@ -1295,7 +1295,7 @@ installTargets = "install-bin install-doc";</programlisting>
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to <literal>lib bin sbin</literal>.
|
List of directories to search for libraries and executables from which only debugging-related symbols should be stripped. It defaults to <literal>lib lib32 lib64 libexec bin sbin</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
50
flake.nix
Normal file
50
flake.nix
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Experimental flake interface to Nixpkgs.
|
||||||
|
# See https://github.com/NixOS/rfcs/pull/49 for details.
|
||||||
|
{
|
||||||
|
edition = 201909;
|
||||||
|
|
||||||
|
description = "A collection of packages for the Nix package manager";
|
||||||
|
|
||||||
|
outputs = { self }:
|
||||||
|
let
|
||||||
|
|
||||||
|
jobs = import ./pkgs/top-level/release.nix {
|
||||||
|
nixpkgs = self;
|
||||||
|
};
|
||||||
|
|
||||||
|
lib = import ./lib;
|
||||||
|
|
||||||
|
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
|
||||||
|
|
||||||
|
forAllSystems = f: lib.genAttrs systems (system: f system);
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
lib = lib // {
|
||||||
|
nixosSystem = { modules, ... } @ args:
|
||||||
|
import ./nixos/lib/eval-config.nix (args // {
|
||||||
|
modules = modules ++
|
||||||
|
[ { system.nixos.versionSuffix =
|
||||||
|
".${lib.substring 0 8 (self.lastModifiedDate or self.lastModified)}.${self.shortRev or "dirty"}";
|
||||||
|
system.nixos.revision = lib.mkIf (self ? rev) self.rev;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
checks.x86_64-linux.tarball = jobs.tarball;
|
||||||
|
|
||||||
|
htmlDocs = {
|
||||||
|
nixpkgsManual = jobs.manual;
|
||||||
|
nixosManual = (import ./nixos/release-small.nix {
|
||||||
|
nixpkgs = self;
|
||||||
|
}).nixos.manual.x86_64-linux;
|
||||||
|
};
|
||||||
|
|
||||||
|
legacyPackages = forAllSystems (system: import ./. { inherit system; });
|
||||||
|
|
||||||
|
nixosModules = {
|
||||||
|
notDetected = import ./nixos/modules/installer/scan/not-detected.nix;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
let
|
let
|
||||||
inherit (builtins) head tail length;
|
inherit (builtins) head tail length;
|
||||||
inherit (lib.trivial) and;
|
inherit (lib.trivial) and;
|
||||||
inherit (lib.strings) concatStringsSep;
|
inherit (lib.strings) concatStringsSep sanitizeDerivationName;
|
||||||
inherit (lib.lists) fold concatMap concatLists;
|
inherit (lib.lists) fold concatMap concatLists;
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ rec {
|
|||||||
[ { name = head attrPath; value = setAttrByPath (tail attrPath) value; } ];
|
[ { name = head attrPath; value = setAttrByPath (tail attrPath) value; } ];
|
||||||
|
|
||||||
|
|
||||||
/* Like `getAttrPath' without a default value. If it doesn't find the
|
/* Like `attrByPath' without a default value. If it doesn't find the
|
||||||
path it will throw.
|
path it will throw.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
@ -310,7 +310,7 @@ rec {
|
|||||||
path' = builtins.storePath path;
|
path' = builtins.storePath path;
|
||||||
res =
|
res =
|
||||||
{ type = "derivation";
|
{ type = "derivation";
|
||||||
name = builtins.unsafeDiscardStringContext (builtins.substring 33 (-1) (baseNameOf path'));
|
name = sanitizeDerivationName (builtins.substring 33 (-1) (baseNameOf path'));
|
||||||
outPath = path';
|
outPath = path';
|
||||||
outputs = [ "out" ];
|
outputs = [ "out" ];
|
||||||
out = res;
|
out = res;
|
||||||
@ -473,6 +473,20 @@ rec {
|
|||||||
/* Pick the outputs of packages to place in buildInputs */
|
/* Pick the outputs of packages to place in buildInputs */
|
||||||
chooseDevOutputs = drvs: builtins.map getDev drvs;
|
chooseDevOutputs = drvs: builtins.map getDev drvs;
|
||||||
|
|
||||||
|
/* Make various Nix tools consider the contents of the resulting
|
||||||
|
attribute set when looking for what to build, find, etc.
|
||||||
|
|
||||||
|
This function only affects a single attribute set; it does not
|
||||||
|
apply itself recursively for nested attribute sets.
|
||||||
|
*/
|
||||||
|
recurseIntoAttrs =
|
||||||
|
attrs: attrs // { recurseForDerivations = true; };
|
||||||
|
|
||||||
|
/* Undo the effect of recurseIntoAttrs.
|
||||||
|
*/
|
||||||
|
dontRecurseIntoAttrs =
|
||||||
|
attrs: attrs // { recurseForDerivations = false; };
|
||||||
|
|
||||||
/*** deprecated stuff ***/
|
/*** deprecated stuff ***/
|
||||||
|
|
||||||
zipWithNames = zipAttrsWithNames;
|
zipWithNames = zipAttrsWithNames;
|
||||||
|
83
lib/cli.nix
Normal file
83
lib/cli.nix
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
{ lib }:
|
||||||
|
|
||||||
|
rec {
|
||||||
|
/* 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.
|
||||||
|
|
||||||
|
`toGNUCommandLine` returns a list of nix strings.
|
||||||
|
`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"
|
||||||
|
]
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
toGNUCommandLine = {
|
||||||
|
# how to string-format the option name;
|
||||||
|
# by default one character is a short option (`-`),
|
||||||
|
# more than one characters a long option (`--`).
|
||||||
|
mkOptionName ?
|
||||||
|
k: if builtins.stringLength k == 1
|
||||||
|
then "-${k}"
|
||||||
|
else "--${k}",
|
||||||
|
|
||||||
|
# how to format a boolean value to a command list;
|
||||||
|
# by default it’s a flag option
|
||||||
|
# (only the option name if true, left out completely if false).
|
||||||
|
mkBool ? k: v: lib.optional v (mkOptionName k),
|
||||||
|
|
||||||
|
# how to format a list value to a command list;
|
||||||
|
# by default the option name is repeated for each value
|
||||||
|
# and `mkOption` is applied to the values themselves.
|
||||||
|
mkList ? k: v: lib.concatMap (mkOption k) v,
|
||||||
|
|
||||||
|
# how to format any remaining value to a command list;
|
||||||
|
# on the toplevel, booleans and lists are handled by `mkBool` and `mkList`,
|
||||||
|
# though they can still appear as values of a list.
|
||||||
|
# By default, everything is printed verbatim and complex types
|
||||||
|
# are forbidden (lists, attrsets, functions). `null` values are omitted.
|
||||||
|
mkOption ?
|
||||||
|
k: v: if v == null
|
||||||
|
then []
|
||||||
|
else [ (mkOptionName k) (lib.generators.mkValueStringDefault {} v) ]
|
||||||
|
}:
|
||||||
|
options:
|
||||||
|
let
|
||||||
|
render = k: v:
|
||||||
|
if builtins.isBool v then mkBool k v
|
||||||
|
else if builtins.isList v then mkList k v
|
||||||
|
else mkOption k v;
|
||||||
|
|
||||||
|
in
|
||||||
|
builtins.concatLists (lib.mapAttrsToList render options);
|
||||||
|
}
|
@ -131,7 +131,12 @@ rec {
|
|||||||
origArgs = auto // args;
|
origArgs = auto // args;
|
||||||
pkgs = f origArgs;
|
pkgs = f origArgs;
|
||||||
mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
|
mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
|
||||||
in lib.mapAttrs mkAttrOverridable pkgs;
|
in
|
||||||
|
if lib.isDerivation pkgs then throw
|
||||||
|
("function `callPackages` was called on a *single* derivation "
|
||||||
|
+ ''"${pkgs.name or "<unknown-name>"}";''
|
||||||
|
+ " did you mean to use `callPackage` instead?")
|
||||||
|
else lib.mapAttrs mkAttrOverridable pkgs;
|
||||||
|
|
||||||
|
|
||||||
/* Add attributes to each output of a derivation without changing
|
/* Add attributes to each output of a derivation without changing
|
||||||
|
@ -24,6 +24,7 @@ let
|
|||||||
# packaging
|
# packaging
|
||||||
customisation = callLibs ./customisation.nix;
|
customisation = callLibs ./customisation.nix;
|
||||||
maintainers = import ../maintainers/maintainer-list.nix;
|
maintainers = import ../maintainers/maintainer-list.nix;
|
||||||
|
teams = callLibs ../maintainers/team-list.nix;
|
||||||
meta = callLibs ./meta.nix;
|
meta = callLibs ./meta.nix;
|
||||||
sources = callLibs ./sources.nix;
|
sources = callLibs ./sources.nix;
|
||||||
versions = callLibs ./versions.nix;
|
versions = callLibs ./versions.nix;
|
||||||
@ -37,10 +38,13 @@ let
|
|||||||
licenses = callLibs ./licenses.nix;
|
licenses = callLibs ./licenses.nix;
|
||||||
systems = callLibs ./systems;
|
systems = callLibs ./systems;
|
||||||
|
|
||||||
|
# serialization
|
||||||
|
cli = callLibs ./cli.nix;
|
||||||
|
generators = callLibs ./generators.nix;
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
asserts = callLibs ./asserts.nix;
|
asserts = callLibs ./asserts.nix;
|
||||||
debug = callLibs ./debug.nix;
|
debug = callLibs ./debug.nix;
|
||||||
generators = callLibs ./generators.nix;
|
|
||||||
misc = callLibs ./deprecated.nix;
|
misc = callLibs ./deprecated.nix;
|
||||||
|
|
||||||
# domain-specific
|
# domain-specific
|
||||||
@ -52,6 +56,9 @@ let
|
|||||||
# back-compat aliases
|
# back-compat aliases
|
||||||
platforms = systems.doubles;
|
platforms = systems.doubles;
|
||||||
|
|
||||||
|
# linux kernel configuration
|
||||||
|
kernel = callLibs ./kernel.nix;
|
||||||
|
|
||||||
inherit (builtins) add addErrorContext attrNames concatLists
|
inherit (builtins) add addErrorContext attrNames concatLists
|
||||||
deepSeq elem elemAt filter genericClosure genList getAttr
|
deepSeq elem elemAt filter genericClosure genList getAttr
|
||||||
hasAttr head isAttrs isBool isInt isList isString length
|
hasAttr head isAttrs isBool isInt isList isString length
|
||||||
@ -70,7 +77,8 @@ let
|
|||||||
genAttrs isDerivation toDerivation optionalAttrs
|
genAttrs isDerivation toDerivation optionalAttrs
|
||||||
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
zipAttrsWithNames zipAttrsWith zipAttrs recursiveUpdateUntil
|
||||||
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
recursiveUpdate matchAttrs overrideExisting getOutput getBin
|
||||||
getLib getDev chooseDevOutputs zipWithNames zip;
|
getLib getDev chooseDevOutputs zipWithNames zip
|
||||||
|
recurseIntoAttrs dontRecurseIntoAttrs;
|
||||||
inherit (lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
inherit (lists) singleton forEach foldr fold foldl foldl' imap0 imap1
|
||||||
concatMap flatten remove findSingle findFirst any all count
|
concatMap flatten remove findSingle findFirst any all count
|
||||||
optional optionals toList range partition zipListsWith zipLists
|
optional optionals toList range partition zipListsWith zipLists
|
||||||
@ -100,9 +108,9 @@ let
|
|||||||
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
inherit (sources) pathType pathIsDirectory cleanSourceFilter
|
||||||
cleanSource sourceByRegex sourceFilesBySuffices
|
cleanSource sourceByRegex sourceFilesBySuffices
|
||||||
commitIdFromGitRepo cleanSourceWith pathHasContext
|
commitIdFromGitRepo cleanSourceWith pathHasContext
|
||||||
canCleanSource;
|
canCleanSource pathIsRegularFile pathIsGitRepo;
|
||||||
inherit (modules) evalModules closeModules unifyModuleSyntax
|
inherit (modules) evalModules unifyModuleSyntax
|
||||||
applyIfFunction unpackSubmodule packSubmodule mergeModules
|
applyIfFunction mergeModules
|
||||||
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
mergeModules' mergeOptionDecls evalOptionValue mergeDefinitions
|
||||||
pushDownProperties dischargeProperties filterOverrides
|
pushDownProperties dischargeProperties filterOverrides
|
||||||
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
sortProperties fixupOptionType mkIf mkAssert mkMerge mkOverride
|
||||||
@ -110,7 +118,7 @@ let
|
|||||||
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
||||||
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
||||||
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
||||||
mkAliasOptionModule doRename filterModules;
|
mkAliasOptionModule doRename;
|
||||||
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||||
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
||||||
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
||||||
@ -133,7 +141,7 @@ let
|
|||||||
mergeAttrsWithFunc mergeAttrsConcatenateValues
|
mergeAttrsWithFunc mergeAttrsConcatenateValues
|
||||||
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
|
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
|
||||||
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
mergeAttrsByFuncDefaultsClean mergeAttrBy
|
||||||
fakeSha256 fakeSha512
|
fakeSri fakeSha256 fakeSha512
|
||||||
nixType imap;
|
nixType imap;
|
||||||
inherit (versions)
|
inherit (versions)
|
||||||
splitVersion;
|
splitVersion;
|
||||||
|
@ -272,6 +272,7 @@ rec {
|
|||||||
imap = imap1;
|
imap = imap1;
|
||||||
|
|
||||||
# Fake hashes. Can be used as hash placeholders, when computing hash ahead isn't trivial
|
# Fake hashes. Can be used as hash placeholders, when computing hash ahead isn't trivial
|
||||||
|
fakeSri = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||||
fakeSha256 = "0000000000000000000000000000000000000000000000000000000000000000";
|
fakeSha256 = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||||
fakeSha512 = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
fakeSha512 = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,10 @@ rec {
|
|||||||
else if isList v then err "lists" v
|
else if isList v then err "lists" v
|
||||||
# same as for lists, might want to replace
|
# same as for lists, might want to replace
|
||||||
else if isAttrs v then err "attrsets" v
|
else if isAttrs v then err "attrsets" v
|
||||||
|
# functions can’t be printed of course
|
||||||
else if isFunction v then err "functions" v
|
else if isFunction v then err "functions" v
|
||||||
|
# let’s not talk about floats. There is no sensible `toString` for them.
|
||||||
|
else if isFloat v then err "floats" v
|
||||||
else err "this value is" (toString v);
|
else err "this value is" (toString v);
|
||||||
|
|
||||||
|
|
||||||
@ -73,10 +76,14 @@ rec {
|
|||||||
* mkKeyValue is the same as in toINI.
|
* mkKeyValue is the same as in toINI.
|
||||||
*/
|
*/
|
||||||
toKeyValue = {
|
toKeyValue = {
|
||||||
mkKeyValue ? mkKeyValueDefault {} "="
|
mkKeyValue ? mkKeyValueDefault {} "=",
|
||||||
}: attrs:
|
listsAsDuplicateKeys ? false
|
||||||
let mkLine = k: v: mkKeyValue k v + "\n";
|
}:
|
||||||
in libStr.concatStrings (libAttr.mapAttrsToList mkLine attrs);
|
let mkLine = k: v: mkKeyValue k v + "\n";
|
||||||
|
mkLines = if listsAsDuplicateKeys
|
||||||
|
then k: v: map (mkLine k) (if lib.isList v then v else [v])
|
||||||
|
else k: v: [ (mkLine k v) ];
|
||||||
|
in attrs: libStr.concatStrings (lib.concatLists (libAttr.mapAttrsToList mkLines attrs));
|
||||||
|
|
||||||
|
|
||||||
/* Generate an INI-style config file from an
|
/* Generate an INI-style config file from an
|
||||||
@ -103,7 +110,9 @@ rec {
|
|||||||
# apply transformations (e.g. escapes) to section names
|
# apply transformations (e.g. escapes) to section names
|
||||||
mkSectionName ? (name: libStr.escape [ "[" "]" ] name),
|
mkSectionName ? (name: libStr.escape [ "[" "]" ] name),
|
||||||
# format a setting line from key and value
|
# format a setting line from key and value
|
||||||
mkKeyValue ? mkKeyValueDefault {} "="
|
mkKeyValue ? mkKeyValueDefault {} "=",
|
||||||
|
# allow lists as values for duplicate keys
|
||||||
|
listsAsDuplicateKeys ? false
|
||||||
}: attrsOfAttrs:
|
}: attrsOfAttrs:
|
||||||
let
|
let
|
||||||
# map function to string for each key val
|
# map function to string for each key val
|
||||||
@ -112,11 +121,64 @@ rec {
|
|||||||
(libAttr.mapAttrsToList mapFn attrs);
|
(libAttr.mapAttrsToList mapFn attrs);
|
||||||
mkSection = sectName: sectValues: ''
|
mkSection = sectName: sectValues: ''
|
||||||
[${mkSectionName sectName}]
|
[${mkSectionName sectName}]
|
||||||
'' + toKeyValue { inherit mkKeyValue; } sectValues;
|
'' + toKeyValue { inherit mkKeyValue listsAsDuplicateKeys; } sectValues;
|
||||||
in
|
in
|
||||||
# map input to ini sections
|
# map input to ini sections
|
||||||
mapAttrsToStringsSep "\n" mkSection attrsOfAttrs;
|
mapAttrsToStringsSep "\n" mkSection attrsOfAttrs;
|
||||||
|
|
||||||
|
/* Generate a git-config file from an attrset.
|
||||||
|
*
|
||||||
|
* It has two major differences from the regular INI format:
|
||||||
|
*
|
||||||
|
* 1. values are indented with tabs
|
||||||
|
* 2. sections can have sub-sections
|
||||||
|
*
|
||||||
|
* generators.toGitINI {
|
||||||
|
* url."ssh://git@github.com/".insteadOf = "https://github.com";
|
||||||
|
* user.name = "edolstra";
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*> [url "ssh://git@github.com/"]
|
||||||
|
*> insteadOf = https://github.com/
|
||||||
|
*>
|
||||||
|
*> [user]
|
||||||
|
*> name = edolstra
|
||||||
|
*/
|
||||||
|
toGitINI = attrs:
|
||||||
|
with builtins;
|
||||||
|
let
|
||||||
|
mkSectionName = name:
|
||||||
|
let
|
||||||
|
containsQuote = libStr.hasInfix ''"'' name;
|
||||||
|
sections = libStr.splitString "." name;
|
||||||
|
section = head sections;
|
||||||
|
subsections = tail sections;
|
||||||
|
subsection = concatStringsSep "." subsections;
|
||||||
|
in if containsQuote || subsections == [ ] then
|
||||||
|
name
|
||||||
|
else
|
||||||
|
''${section} "${subsection}"'';
|
||||||
|
|
||||||
|
# generation for multiple ini values
|
||||||
|
mkKeyValue = k: v:
|
||||||
|
let mkKeyValue = mkKeyValueDefault { } " = " k;
|
||||||
|
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 then
|
||||||
|
lib.mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value
|
||||||
|
else if length path > 1 then {
|
||||||
|
${concatStringsSep "." (lib.reverseList (tail path))}.${head path} = value;
|
||||||
|
} else {
|
||||||
|
${head path} = value;
|
||||||
|
};
|
||||||
|
in attrs: lib.foldl lib.recursiveUpdate { } (lib.flatten (recurse [ ] attrs));
|
||||||
|
|
||||||
|
toINI_ = toINI { inherit mkKeyValue mkSectionName; };
|
||||||
|
in
|
||||||
|
toINI_ (gitFlattenAttrs attrs);
|
||||||
|
|
||||||
/* Generates JSON from an arbitrary (non-function) value.
|
/* Generates JSON from an arbitrary (non-function) value.
|
||||||
* For more information see the documentation of the builtin.
|
* For more information see the documentation of the builtin.
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
{ lib, version }:
|
{ lib }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
{
|
{
|
||||||
# Common patterns/legacy
|
|
||||||
whenAtLeast = ver: mkIf (versionAtLeast version ver);
|
|
||||||
whenOlder = ver: mkIf (versionOlder version ver);
|
|
||||||
# range is (inclusive, exclusive)
|
|
||||||
whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh);
|
|
||||||
|
|
||||||
|
|
||||||
# Keeping these around in case we decide to change this horrible implementation :)
|
# Keeping these around in case we decide to change this horrible implementation :)
|
||||||
@ -18,4 +13,14 @@ with lib;
|
|||||||
module = { tristate = "m"; };
|
module = { tristate = "m"; };
|
||||||
freeform = x: { freeform = x; };
|
freeform = x: { freeform = x; };
|
||||||
|
|
||||||
|
/*
|
||||||
|
Common patterns/legacy used in common-config/hardened-config.nix
|
||||||
|
*/
|
||||||
|
whenHelpers = version: {
|
||||||
|
whenAtLeast = ver: mkIf (versionAtLeast version ver);
|
||||||
|
whenOlder = ver: mkIf (versionOlder version ver);
|
||||||
|
# range is (inclusive, exclusive)
|
||||||
|
whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
let
|
let
|
||||||
|
|
||||||
spdx = lic: lic // {
|
spdx = lic: lic // {
|
||||||
url = "http://spdx.org/licenses/${lic.spdxId}.html";
|
url = "https://spdx.org/licenses/${lic.spdxId}.html";
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
@ -40,13 +40,13 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
amazonsl = {
|
amazonsl = {
|
||||||
fullName = "Amazon Software License";
|
fullName = "Amazon Software License";
|
||||||
url = http://aws.amazon.com/asl/;
|
url = "https://aws.amazon.com/asl/";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
amd = {
|
amd = {
|
||||||
fullName = "AMD License Agreement";
|
fullName = "AMD License Agreement";
|
||||||
url = http://developer.amd.com/amd-license-agreement/;
|
url = "https://developer.amd.com/amd-license-agreement/";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
arphicpl = {
|
arphicpl = {
|
||||||
fullName = "Arphic Public License";
|
fullName = "Arphic Public License";
|
||||||
url = https://www.freedesktop.org/wiki/Arphic_Public_License/;
|
url = "https://www.freedesktop.org/wiki/Arphic_Public_License/";
|
||||||
};
|
};
|
||||||
|
|
||||||
artistic1 = spdx {
|
artistic1 = spdx {
|
||||||
@ -107,7 +107,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
bsl11 = {
|
bsl11 = {
|
||||||
fullName = "Business Source License 1.1";
|
fullName = "Business Source License 1.1";
|
||||||
url = https://mariadb.com/bsl11;
|
url = "https://mariadb.com/bsl11";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
eapl = {
|
eapl = {
|
||||||
fullName = "EPSON AVASYS PUBLIC LICENSE";
|
fullName = "EPSON AVASYS PUBLIC LICENSE";
|
||||||
url = http://avasys.jp/hp/menu000000700/hpg000000603.htm;
|
url = "https://avasys.jp/hp/menu000000700/hpg000000603.htm";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
elastic = {
|
elastic = {
|
||||||
fullName = "ELASTIC LICENSE";
|
fullName = "ELASTIC LICENSE";
|
||||||
url = https://github.com/elastic/elasticsearch/blob/master/licenses/ELASTIC-LICENSE.txt;
|
url = "https://github.com/elastic/elasticsearch/blob/master/licenses/ELASTIC-LICENSE.txt";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
epson = {
|
epson = {
|
||||||
fullName = "Seiko Epson Corporation Software License Agreement for Linux";
|
fullName = "Seiko Epson Corporation Software License Agreement for Linux";
|
||||||
url = https://download.ebz.epson.net/dsc/du/02/eula/global/LINUX_EN.html;
|
url = "https://download.ebz.epson.net/dsc/du/02/eula/global/LINUX_EN.html";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
ffsl = {
|
ffsl = {
|
||||||
fullName = "Floodgap Free Software License";
|
fullName = "Floodgap Free Software License";
|
||||||
url = http://www.floodgap.com/software/ffsl/license.html;
|
url = "https://www.floodgap.com/software/ffsl/license.html";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -303,12 +303,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
g4sl = {
|
g4sl = {
|
||||||
fullName = "Geant4 Software License";
|
fullName = "Geant4 Software License";
|
||||||
url = https://geant4.web.cern.ch/geant4/license/LICENSE.html;
|
url = "https://geant4.web.cern.ch/geant4/license/LICENSE.html";
|
||||||
};
|
};
|
||||||
|
|
||||||
geogebra = {
|
geogebra = {
|
||||||
fullName = "GeoGebra Non-Commercial License Agreement";
|
fullName = "GeoGebra Non-Commercial License Agreement";
|
||||||
url = https://www.geogebra.org/license;
|
url = "https://www.geogebra.org/license";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -334,12 +334,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
gpl2ClasspathPlus = {
|
gpl2ClasspathPlus = {
|
||||||
fullName = "GNU General Public License v2.0 or later (with Classpath exception)";
|
fullName = "GNU General Public License v2.0 or later (with Classpath exception)";
|
||||||
url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
|
url = "https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception";
|
||||||
};
|
};
|
||||||
|
|
||||||
gpl2Oss = {
|
gpl2Oss = {
|
||||||
fullName = "GNU General Public License version 2 only (with OSI approved licenses linking exception)";
|
fullName = "GNU General Public License version 2 only (with OSI approved licenses linking exception)";
|
||||||
url = https://www.mysql.com/about/legal/licensing/foss-exception;
|
url = "https://www.mysql.com/about/legal/licensing/foss-exception";
|
||||||
};
|
};
|
||||||
|
|
||||||
gpl2Plus = spdx {
|
gpl2Plus = spdx {
|
||||||
@ -359,7 +359,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
gpl3ClasspathPlus = {
|
gpl3ClasspathPlus = {
|
||||||
fullName = "GNU General Public License v3.0 or later (with Classpath exception)";
|
fullName = "GNU General Public License v3.0 or later (with Classpath exception)";
|
||||||
url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
|
url = "https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception";
|
||||||
};
|
};
|
||||||
|
|
||||||
hpnd = spdx {
|
hpnd = spdx {
|
||||||
@ -370,7 +370,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
# Intel's license, seems free
|
# Intel's license, seems free
|
||||||
iasl = {
|
iasl = {
|
||||||
fullName = "iASL";
|
fullName = "iASL";
|
||||||
url = http://www.calculate-linux.org/packages/licenses/iASL;
|
url = "https://old.calculate-linux.org/packages/licenses/iASL";
|
||||||
};
|
};
|
||||||
|
|
||||||
ijg = spdx {
|
ijg = spdx {
|
||||||
@ -385,13 +385,13 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
inria-compcert = {
|
inria-compcert = {
|
||||||
fullName = "INRIA Non-Commercial License Agreement for the CompCert verified compiler";
|
fullName = "INRIA Non-Commercial License Agreement for the CompCert verified compiler";
|
||||||
url = "http://compcert.inria.fr/doc/LICENSE";
|
url = "http://compcert.inria.fr/doc/LICENSE"; # https is broken
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
inria-icesl = {
|
inria-icesl = {
|
||||||
fullName = "INRIA Non-Commercial License Agreement for IceSL";
|
fullName = "INRIA Non-Commercial License Agreement for IceSL";
|
||||||
url = "http://shapeforge.loria.fr/icesl/EULA_IceSL_binary.pdf";
|
url = "http://shapeforge.loria.fr/icesl/EULA_IceSL_binary.pdf"; # https is broken
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
# Proprietary binaries; free to redistribute without modification.
|
# Proprietary binaries; free to redistribute without modification.
|
||||||
issl = {
|
issl = {
|
||||||
fullName = "Intel Simplified Software License";
|
fullName = "Intel Simplified Software License";
|
||||||
url = https://software.intel.com/en-us/license/intel-simplified-software-license;
|
url = "https://software.intel.com/en-us/license/intel-simplified-software-license";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
llgpl21 = {
|
llgpl21 = {
|
||||||
fullName = "Lisp LGPL; GNU Lesser General Public License version 2.1 with Franz Inc. preamble for clarification of LGPL terms in context of Lisp";
|
fullName = "Lisp LGPL; GNU Lesser General Public License version 2.1 with Franz Inc. preamble for clarification of LGPL terms in context of Lisp";
|
||||||
url = http://opensource.franz.com/preamble.html;
|
url = "https://opensource.franz.com/preamble.html";
|
||||||
};
|
};
|
||||||
|
|
||||||
lppl12 = spdx {
|
lppl12 = spdx {
|
||||||
@ -489,11 +489,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
miros = {
|
miros = {
|
||||||
fullName = "MirOS License";
|
fullName = "MirOS License";
|
||||||
url = https://opensource.org/licenses/MirOS;
|
url = "https://opensource.org/licenses/MirOS";
|
||||||
};
|
};
|
||||||
|
|
||||||
# spdx.org does not (yet) differentiate between the X11 and Expat versions
|
# spdx.org does not (yet) differentiate between the X11 and Expat versions
|
||||||
# for details see http://en.wikipedia.org/wiki/MIT_License#Various_versions
|
# for details see https://en.wikipedia.org/wiki/MIT_License#Various_versions
|
||||||
mit = spdx {
|
mit = spdx {
|
||||||
spdxId = "MIT";
|
spdxId = "MIT";
|
||||||
fullName = "MIT License";
|
fullName = "MIT License";
|
||||||
@ -536,11 +536,6 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
fullName = "University of Illinois/NCSA Open Source License";
|
fullName = "University of Illinois/NCSA Open Source License";
|
||||||
};
|
};
|
||||||
|
|
||||||
notion_lgpl = {
|
|
||||||
url = "https://raw.githubusercontent.com/raboof/notion/master/LICENSE";
|
|
||||||
fullName = "Notion modified LGPL";
|
|
||||||
};
|
|
||||||
|
|
||||||
nposl3 = spdx {
|
nposl3 = spdx {
|
||||||
spdxId = "NPOSL-3.0";
|
spdxId = "NPOSL-3.0";
|
||||||
fullName = "Non-Profit Open Software License 3.0";
|
fullName = "Non-Profit Open Software License 3.0";
|
||||||
@ -594,14 +589,14 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
postman = {
|
postman = {
|
||||||
fullName = "Postman EULA";
|
fullName = "Postman EULA";
|
||||||
url = https://www.getpostman.com/licenses/postman_base_app;
|
url = "https://www.getpostman.com/licenses/postman_base_app";
|
||||||
free = false;
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
psfl = spdx {
|
psfl = spdx {
|
||||||
spdxId = "Python-2.0";
|
spdxId = "Python-2.0";
|
||||||
fullName = "Python Software Foundation License version 2";
|
fullName = "Python Software Foundation License version 2";
|
||||||
#url = http://docs.python.org/license.html;
|
url = "https://docs.python.org/license.html";
|
||||||
};
|
};
|
||||||
|
|
||||||
publicDomain = {
|
publicDomain = {
|
||||||
@ -610,7 +605,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
purdueBsd = {
|
purdueBsd = {
|
||||||
fullName = " Purdue BSD-Style License"; # also know as lsof license
|
fullName = " Purdue BSD-Style License"; # also know as lsof license
|
||||||
url = https://enterprise.dejacode.com/licenses/public/purdue-bsd;
|
url = "https://enterprise.dejacode.com/licenses/public/purdue-bsd";
|
||||||
};
|
};
|
||||||
|
|
||||||
qhull = spdx {
|
qhull = spdx {
|
||||||
@ -625,7 +620,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
qwt = {
|
qwt = {
|
||||||
fullName = "Qwt License, Version 1.0";
|
fullName = "Qwt License, Version 1.0";
|
||||||
url = http://qwt.sourceforge.net/qwtlicense.html;
|
url = "https://qwt.sourceforge.io/qwtlicense.html";
|
||||||
};
|
};
|
||||||
|
|
||||||
ruby = spdx {
|
ruby = spdx {
|
||||||
@ -651,7 +646,14 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
smail = {
|
smail = {
|
||||||
shortName = "smail";
|
shortName = "smail";
|
||||||
fullName = "SMAIL General Public License";
|
fullName = "SMAIL General Public License";
|
||||||
url = http://metadata.ftp-master.debian.org/changelogs/main/d/debianutils/debianutils_4.8.1_copyright;
|
url = "https://sources.debian.org/copyright/license/debianutils/4.9.1/";
|
||||||
|
};
|
||||||
|
|
||||||
|
sspl = {
|
||||||
|
shortName = "SSPL";
|
||||||
|
fullName = "Server Side Public License";
|
||||||
|
url = "https://www.mongodb.com/licensing/server-side-public-license";
|
||||||
|
free = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
tcltk = spdx {
|
tcltk = spdx {
|
||||||
@ -661,7 +663,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
ufl = {
|
ufl = {
|
||||||
fullName = "Ubuntu Font License 1.0";
|
fullName = "Ubuntu Font License 1.0";
|
||||||
url = http://font.ubuntu.com/ufl/ubuntu-font-licence-1.0.txt;
|
url = "https://ubuntu.com/legal/font-licence";
|
||||||
};
|
};
|
||||||
|
|
||||||
unfree = {
|
unfree = {
|
||||||
@ -680,6 +682,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
# channel and NixOS images.
|
# channel and NixOS images.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unicode-dfs-2016 = spdx {
|
||||||
|
spdxId = "Unicode-DFS-2016";
|
||||||
|
fullName = "Unicode License Agreement - Data Files and Software (2016)";
|
||||||
|
};
|
||||||
|
|
||||||
unlicense = spdx {
|
unlicense = spdx {
|
||||||
spdxId = "Unlicense";
|
spdxId = "Unlicense";
|
||||||
fullName = "The Unlicense";
|
fullName = "The Unlicense";
|
||||||
@ -718,7 +725,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
wadalab = {
|
wadalab = {
|
||||||
fullName = "Wadalab Font License";
|
fullName = "Wadalab Font License";
|
||||||
url = https://fedoraproject.org/wiki/Licensing:Wadalab?rd=Licensing/Wadalab;
|
url = "https://fedoraproject.org/wiki/Licensing:Wadalab?rd=Licensing/Wadalab";
|
||||||
};
|
};
|
||||||
|
|
||||||
wtfpl = spdx {
|
wtfpl = spdx {
|
||||||
@ -733,7 +740,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
|
|||||||
|
|
||||||
xfig = {
|
xfig = {
|
||||||
fullName = "xfig";
|
fullName = "xfig";
|
||||||
url = "http://mcj.sourceforge.net/authors.html#xfig";
|
url = "http://mcj.sourceforge.net/authors.html#xfig"; # https is broken
|
||||||
};
|
};
|
||||||
|
|
||||||
zlib = spdx {
|
zlib = spdx {
|
||||||
|
195
lib/modules.nix
195
lib/modules.nix
@ -41,7 +41,13 @@ rec {
|
|||||||
|
|
||||||
options = {
|
options = {
|
||||||
_module.args = mkOption {
|
_module.args = mkOption {
|
||||||
type = types.attrsOf types.unspecified;
|
# Because things like `mkIf` are entirely useless for
|
||||||
|
# `_module.args` (because there's no way modules can check which
|
||||||
|
# arguments were passed), we'll use `lazyAttrsOf` which drops
|
||||||
|
# support for that, in turn it's lazy in its values. This means e.g.
|
||||||
|
# a `_module.args.pkgs = import (fetchTarball { ... }) {}` won't
|
||||||
|
# start a download when `pkgs` wasn't evaluated.
|
||||||
|
type = types.lazyAttrsOf types.unspecified;
|
||||||
internal = true;
|
internal = true;
|
||||||
description = "Arguments passed to each module.";
|
description = "Arguments passed to each module.";
|
||||||
};
|
};
|
||||||
@ -59,9 +65,12 @@ rec {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
closed = closeModules (modules ++ [ internalModule ]) ({ inherit config options lib; } // specialArgs);
|
collected = collectModules
|
||||||
|
(specialArgs.modulesPath or "")
|
||||||
|
(modules ++ [ internalModule ])
|
||||||
|
({ inherit config options lib; } // specialArgs);
|
||||||
|
|
||||||
options = mergeModules prefix (reverseList (filterModules (specialArgs.modulesPath or "") closed));
|
options = mergeModules prefix (reverseList collected);
|
||||||
|
|
||||||
# Traverse options and extract the option values into the final
|
# Traverse options and extract the option values into the final
|
||||||
# config set. At the same time, check whether all option
|
# config set. At the same time, check whether all option
|
||||||
@ -84,61 +93,110 @@ rec {
|
|||||||
res set._definedNames
|
res set._definedNames
|
||||||
else
|
else
|
||||||
res;
|
res;
|
||||||
result = { inherit options config; };
|
result = {
|
||||||
|
inherit options;
|
||||||
|
config = removeAttrs config [ "_module" ];
|
||||||
|
inherit (config) _module;
|
||||||
|
};
|
||||||
in result;
|
in result;
|
||||||
|
|
||||||
|
# collectModules :: (modulesPath: String) -> (modules: [ Module ]) -> (args: Attrs) -> [ Module ]
|
||||||
|
#
|
||||||
|
# Collects all modules recursively through `import` statements, filtering out
|
||||||
|
# all modules in disabledModules.
|
||||||
|
collectModules = let
|
||||||
|
|
||||||
# Filter disabled modules. Modules can be disabled allowing
|
# Like unifyModuleSyntax, but also imports paths and calls functions if necessary
|
||||||
# their implementation to be replaced.
|
loadModule = args: fallbackFile: fallbackKey: m:
|
||||||
filterModules = modulesPath: modules:
|
if isFunction m || isAttrs m then
|
||||||
let
|
unifyModuleSyntax fallbackFile fallbackKey (applyIfFunction fallbackKey m args)
|
||||||
moduleKey = m: if isString m then toString modulesPath + "/" + m else toString m;
|
else unifyModuleSyntax (toString m) (toString m) (applyIfFunction (toString m) (import m) args);
|
||||||
disabledKeys = map moduleKey (concatMap (m: m.disabledModules) modules);
|
|
||||||
in
|
|
||||||
filter (m: !(elem m.key disabledKeys)) modules;
|
|
||||||
|
|
||||||
/* Close a set of modules under the ‘imports’ relation. */
|
/*
|
||||||
closeModules = modules: args:
|
Collects all modules recursively into the form
|
||||||
let
|
|
||||||
toClosureList = file: parentKey: imap1 (n: x:
|
{
|
||||||
if isAttrs x || isFunction x then
|
disabled = [ <list of disabled modules> ];
|
||||||
let key = "${parentKey}:anon-${toString n}"; in
|
# All modules of the main module list
|
||||||
unifyModuleSyntax file key (unpackSubmodule (applyIfFunction key) x args)
|
modules = [
|
||||||
else
|
{
|
||||||
let file = toString x; key = toString x; in
|
key = <key1>;
|
||||||
unifyModuleSyntax file key (applyIfFunction key (import x) args));
|
module = <module for key1>;
|
||||||
in
|
# All modules imported by the module for key1
|
||||||
builtins.genericClosure {
|
modules = [
|
||||||
startSet = toClosureList unknownModule "" modules;
|
{
|
||||||
operator = m: toClosureList m.file m.key m.imports;
|
key = <key1-1>;
|
||||||
};
|
module = <module for key1-1>;
|
||||||
|
# All modules imported by the module for key1-1
|
||||||
|
modules = [ ... ];
|
||||||
|
}
|
||||||
|
...
|
||||||
|
];
|
||||||
|
}
|
||||||
|
...
|
||||||
|
];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
collectStructuredModules =
|
||||||
|
let
|
||||||
|
collectResults = modules: {
|
||||||
|
disabled = concatLists (catAttrs "disabled" modules);
|
||||||
|
inherit modules;
|
||||||
|
};
|
||||||
|
in parentFile: parentKey: initialModules: args: collectResults (imap1 (n: x:
|
||||||
|
let
|
||||||
|
module = loadModule args parentFile "${parentKey}:anon-${toString n}" x;
|
||||||
|
collectedImports = collectStructuredModules module._file module.key module.imports args;
|
||||||
|
in {
|
||||||
|
key = module.key;
|
||||||
|
module = module;
|
||||||
|
modules = collectedImports.modules;
|
||||||
|
disabled = module.disabledModules ++ collectedImports.disabled;
|
||||||
|
}) initialModules);
|
||||||
|
|
||||||
|
# filterModules :: String -> { disabled, modules } -> [ Module ]
|
||||||
|
#
|
||||||
|
# Filters a structure as emitted by collectStructuredModules by removing all disabled
|
||||||
|
# modules recursively. It returns the final list of unique-by-key modules
|
||||||
|
filterModules = modulesPath: { disabled, modules }:
|
||||||
|
let
|
||||||
|
moduleKey = m: if isString m then toString modulesPath + "/" + m else toString m;
|
||||||
|
disabledKeys = map moduleKey disabled;
|
||||||
|
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
|
||||||
|
in map (attrs: attrs.module) (builtins.genericClosure {
|
||||||
|
startSet = keyFilter modules;
|
||||||
|
operator = attrs: keyFilter attrs.modules;
|
||||||
|
});
|
||||||
|
|
||||||
|
in modulesPath: initialModules: args:
|
||||||
|
filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
|
||||||
|
|
||||||
/* Massage a module into canonical form, that is, a set consisting
|
/* Massage a module into canonical form, that is, a set consisting
|
||||||
of ‘options’, ‘config’ and ‘imports’ attributes. */
|
of ‘options’, ‘config’ and ‘imports’ attributes. */
|
||||||
unifyModuleSyntax = file: key: m:
|
unifyModuleSyntax = file: key: m:
|
||||||
let metaSet = if m ? meta
|
let addMeta = config: if m ? meta
|
||||||
then { meta = m.meta; }
|
then mkMerge [ config { meta = m.meta; } ]
|
||||||
else {};
|
else config;
|
||||||
in
|
in
|
||||||
if m ? config || m ? options then
|
if m ? config || m ? options then
|
||||||
let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta"]; in
|
let badAttrs = removeAttrs m ["_file" "key" "disabledModules" "imports" "options" "config" "meta"]; in
|
||||||
if badAttrs != {} then
|
if badAttrs != {} then
|
||||||
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by assignments to the top-level attributes `config' or `options'."
|
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: ${toString (attrNames badAttrs)}) into the explicit `config' attribute."
|
||||||
else
|
else
|
||||||
{ file = m._file or file;
|
{ _file = m._file or file;
|
||||||
key = toString m.key or key;
|
key = toString m.key or key;
|
||||||
disabledModules = m.disabledModules or [];
|
disabledModules = m.disabledModules or [];
|
||||||
imports = m.imports or [];
|
imports = m.imports or [];
|
||||||
options = m.options or {};
|
options = m.options or {};
|
||||||
config = mkMerge [ (m.config or {}) metaSet ];
|
config = addMeta (m.config or {});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ file = m._file or file;
|
{ _file = m._file or file;
|
||||||
key = toString m.key or key;
|
key = toString m.key or key;
|
||||||
disabledModules = m.disabledModules or [];
|
disabledModules = m.disabledModules or [];
|
||||||
imports = m.require or [] ++ m.imports or [];
|
imports = m.require or [] ++ m.imports or [];
|
||||||
options = {};
|
options = {};
|
||||||
config = mkMerge [ (removeAttrs m ["_file" "key" "disabledModules" "require" "imports"]) metaSet ];
|
config = addMeta (removeAttrs m ["_file" "key" "disabledModules" "require" "imports"]);
|
||||||
};
|
};
|
||||||
|
|
||||||
applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
|
applyIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
|
||||||
@ -171,17 +229,6 @@ rec {
|
|||||||
else
|
else
|
||||||
f;
|
f;
|
||||||
|
|
||||||
/* We have to pack and unpack submodules. We cannot wrap the expected
|
|
||||||
result of the function as we would no longer be able to list the arguments
|
|
||||||
of the submodule. (see applyIfFunction) */
|
|
||||||
unpackSubmodule = unpack: m: args:
|
|
||||||
if isType "submodule" m then
|
|
||||||
{ _file = m.file; } // (unpack m.submodule args)
|
|
||||||
else unpack m args;
|
|
||||||
|
|
||||||
packSubmodule = file: m:
|
|
||||||
{ _type = "submodule"; file = file; submodule = m; };
|
|
||||||
|
|
||||||
/* Merge a list of modules. This will recurse over the option
|
/* Merge a list of modules. This will recurse over the option
|
||||||
declarations in all modules, combining them into a single set.
|
declarations in all modules, combining them into a single set.
|
||||||
At the same time, for each option declaration, it will merge the
|
At the same time, for each option declaration, it will merge the
|
||||||
@ -189,7 +236,7 @@ rec {
|
|||||||
in the ‘value’ attribute of each option. */
|
in the ‘value’ attribute of each option. */
|
||||||
mergeModules = prefix: modules:
|
mergeModules = prefix: modules:
|
||||||
mergeModules' prefix modules
|
mergeModules' prefix modules
|
||||||
(concatMap (m: map (config: { inherit (m) file; inherit config; }) (pushDownProperties m.config)) modules);
|
(concatMap (m: map (config: { file = m._file; inherit config; }) (pushDownProperties m.config)) modules);
|
||||||
|
|
||||||
mergeModules' = prefix: options: configs:
|
mergeModules' = prefix: options: configs:
|
||||||
let
|
let
|
||||||
@ -223,7 +270,7 @@ rec {
|
|||||||
) {} modules;
|
) {} modules;
|
||||||
# an attrset 'name' => list of submodules that declare ‘name’.
|
# an attrset 'name' => list of submodules that declare ‘name’.
|
||||||
declsByName = byName "options" (module: option:
|
declsByName = byName "options" (module: option:
|
||||||
[{ inherit (module) file; options = option; }]
|
[{ inherit (module) _file; options = option; }]
|
||||||
) options;
|
) options;
|
||||||
# an attrset 'name' => list of submodules that define ‘name’.
|
# an attrset 'name' => list of submodules that define ‘name’.
|
||||||
defnsByName = byName "config" (module: value:
|
defnsByName = byName "config" (module: value:
|
||||||
@ -250,7 +297,7 @@ rec {
|
|||||||
firstOption = findFirst (m: isOption m.options) "" decls;
|
firstOption = findFirst (m: isOption m.options) "" decls;
|
||||||
firstNonOption = findFirst (m: !isOption m.options) "" decls;
|
firstNonOption = findFirst (m: !isOption m.options) "" decls;
|
||||||
in
|
in
|
||||||
throw "The option `${showOption loc}' in `${firstOption.file}' is a prefix of options in `${firstNonOption.file}'."
|
throw "The option `${showOption loc}' in `${firstOption._file}' is a prefix of options in `${firstNonOption._file}'."
|
||||||
else
|
else
|
||||||
mergeModules' loc decls defns
|
mergeModules' loc decls defns
|
||||||
))
|
))
|
||||||
@ -267,7 +314,14 @@ rec {
|
|||||||
|
|
||||||
'opts' is a list of modules. Each module has an options attribute which
|
'opts' is a list of modules. Each module has an options attribute which
|
||||||
correspond to the definition of 'loc' in 'opt.file'. */
|
correspond to the definition of 'loc' in 'opt.file'. */
|
||||||
mergeOptionDecls = loc: opts:
|
mergeOptionDecls =
|
||||||
|
let
|
||||||
|
packSubmodule = file: m:
|
||||||
|
{ _file = file; imports = [ m ]; };
|
||||||
|
coerceOption = file: opt:
|
||||||
|
if isFunction opt then packSubmodule file opt
|
||||||
|
else packSubmodule file { options = opt; };
|
||||||
|
in loc: opts:
|
||||||
foldl' (res: opt:
|
foldl' (res: opt:
|
||||||
let t = res.type;
|
let t = res.type;
|
||||||
t' = opt.options.type;
|
t' = opt.options.type;
|
||||||
@ -284,7 +338,7 @@ rec {
|
|||||||
bothHave "apply" ||
|
bothHave "apply" ||
|
||||||
(bothHave "type" && (! typesMergeable))
|
(bothHave "type" && (! typesMergeable))
|
||||||
then
|
then
|
||||||
throw "The option `${showOption loc}' in `${opt.file}' is already declared in ${showFiles res.declarations}."
|
throw "The option `${showOption loc}' in `${opt._file}' is already declared in ${showFiles res.declarations}."
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
/* Add the modules of the current option to the list of modules
|
/* Add the modules of the current option to the list of modules
|
||||||
@ -293,16 +347,14 @@ rec {
|
|||||||
current option declaration as the file use for the submodule. If the
|
current option declaration as the file use for the submodule. If the
|
||||||
submodule defines any filename, then we ignore the enclosing option file. */
|
submodule defines any filename, then we ignore the enclosing option file. */
|
||||||
options' = toList opt.options.options;
|
options' = toList opt.options.options;
|
||||||
coerceOption = file: opt:
|
|
||||||
if isFunction opt then packSubmodule file opt
|
|
||||||
else packSubmodule file { options = opt; };
|
|
||||||
getSubModules = opt.options.type.getSubModules or null;
|
getSubModules = opt.options.type.getSubModules or null;
|
||||||
submodules =
|
submodules =
|
||||||
if getSubModules != null then map (packSubmodule opt.file) getSubModules ++ res.options
|
if getSubModules != null then map (packSubmodule opt._file) getSubModules ++ res.options
|
||||||
else if opt.options ? options then map (coerceOption opt.file) options' ++ res.options
|
else if opt.options ? options then map (coerceOption opt._file) options' ++ res.options
|
||||||
else res.options;
|
else res.options;
|
||||||
in opt.options // res //
|
in opt.options // res //
|
||||||
{ declarations = res.declarations ++ [opt.file];
|
{ declarations = res.declarations ++ [opt._file];
|
||||||
options = submodules;
|
options = submodules;
|
||||||
} // typeSet
|
} // typeSet
|
||||||
) { inherit loc; declarations = []; options = []; } opts;
|
) { inherit loc; declarations = []; options = []; } opts;
|
||||||
@ -323,16 +375,9 @@ rec {
|
|||||||
else
|
else
|
||||||
mergeDefinitions loc opt.type defs';
|
mergeDefinitions loc opt.type defs';
|
||||||
|
|
||||||
|
|
||||||
# The value with a check that it is defined
|
|
||||||
valueDefined = if res.isDefined then res.mergedValue else
|
|
||||||
# (nixos-option detects this specific error message and gives it special
|
|
||||||
# handling. If changed here, please change it there too.)
|
|
||||||
throw "The option `${showOption loc}' is used but not defined.";
|
|
||||||
|
|
||||||
# Apply the 'apply' function to the merged value. This allows options to
|
# Apply the 'apply' function to the merged value. This allows options to
|
||||||
# yield a value computed from the definitions
|
# yield a value computed from the definitions
|
||||||
value = if opt ? apply then opt.apply valueDefined else valueDefined;
|
value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
|
||||||
|
|
||||||
in opt //
|
in opt //
|
||||||
{ value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
|
{ value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
|
||||||
@ -348,7 +393,7 @@ rec {
|
|||||||
let
|
let
|
||||||
# Process mkMerge and mkIf properties.
|
# Process mkMerge and mkIf properties.
|
||||||
defs' = concatMap (m:
|
defs' = concatMap (m:
|
||||||
map (value: { inherit (m) file; inherit value; }) (dischargeProperties m.value)
|
map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
|
||||||
) defs;
|
) defs;
|
||||||
|
|
||||||
# Process mkOverride properties.
|
# Process mkOverride properties.
|
||||||
@ -366,11 +411,16 @@ rec {
|
|||||||
};
|
};
|
||||||
defsFinal = defsFinal'.values;
|
defsFinal = defsFinal'.values;
|
||||||
|
|
||||||
# Type-check the remaining definitions, and merge them.
|
# Type-check the remaining definitions, and merge them. Or throw if no definitions.
|
||||||
mergedValue = foldl' (res: def:
|
mergedValue =
|
||||||
if type.check def.value then res
|
if isDefined then
|
||||||
else throw "The option value `${showOption loc}' in `${def.file}' is not of type `${type.description}'.")
|
if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
|
||||||
(type.merge loc defsFinal) defsFinal;
|
else let firstInvalid = findFirst (def: ! type.check def.value) null defsFinal;
|
||||||
|
in throw "The option value `${showOption loc}' in `${firstInvalid.file}' is not of type `${type.description}'."
|
||||||
|
else
|
||||||
|
# (nixos-option detects this specific error message and gives it special
|
||||||
|
# handling. If changed here, please change it there too.)
|
||||||
|
throw "The option `${showOption loc}' is used but not defined.";
|
||||||
|
|
||||||
isDefined = defsFinal != [];
|
isDefined = defsFinal != [];
|
||||||
|
|
||||||
@ -717,12 +767,15 @@ rec {
|
|||||||
fromOpt = getAttrFromPath from options;
|
fromOpt = getAttrFromPath from options;
|
||||||
toOf = attrByPath to
|
toOf = attrByPath to
|
||||||
(abort "Renaming error: option `${showOption to}' does not exist.");
|
(abort "Renaming error: option `${showOption to}' does not exist.");
|
||||||
|
toType = let opt = attrByPath to {} options; in opt.type or null;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = setAttrByPath from (mkOption {
|
options = setAttrByPath from (mkOption {
|
||||||
inherit visible;
|
inherit visible;
|
||||||
description = "Alias of <option>${showOption to}</option>.";
|
description = "Alias of <option>${showOption to}</option>.";
|
||||||
apply = x: use (toOf config);
|
apply = x: use (toOf config);
|
||||||
|
} // optionalAttrs (toType != null) {
|
||||||
|
type = toType;
|
||||||
});
|
});
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ rec {
|
|||||||
let ss = opt.type.getSubOptions opt.loc;
|
let ss = opt.type.getSubOptions opt.loc;
|
||||||
in if ss != {} then optionAttrSetToDocList' opt.loc ss else [];
|
in if ss != {} then optionAttrSetToDocList' opt.loc ss else [];
|
||||||
in
|
in
|
||||||
[ docOption ] ++ subOptions) (collect isOption options);
|
[ docOption ] ++ optionals docOption.visible subOptions) (collect isOption options);
|
||||||
|
|
||||||
|
|
||||||
/* This function recursively removes all derivation attributes from
|
/* This function recursively removes all derivation attributes from
|
||||||
@ -191,7 +191,14 @@ rec {
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
||||||
(showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
|
(showOption ["foo" "bar.baz" "tux"]) == "foo.bar.baz.tux"
|
||||||
|
|
||||||
|
Placeholders will not be quoted as they are not actual values:
|
||||||
|
(showOption ["foo" "*" "bar"]) == "foo.*.bar"
|
||||||
|
(showOption ["foo" "<name>" "bar"]) == "foo.<name>.bar"
|
||||||
|
|
||||||
|
Unlike attributes, options can also start with numbers:
|
||||||
|
(showOption ["windowManager" "2bwm" "enable"]) == "windowManager.2bwm.enable"
|
||||||
*/
|
*/
|
||||||
showOption = parts: let
|
showOption = parts: let
|
||||||
escapeOptionPart = part:
|
escapeOptionPart = part:
|
||||||
|
@ -9,6 +9,9 @@ rec {
|
|||||||
# Returns true if the path exists and is a directory, false otherwise
|
# Returns true if the path exists and is a directory, false otherwise
|
||||||
pathIsDirectory = p: if builtins.pathExists p then (pathType p) == "directory" else false;
|
pathIsDirectory = p: if builtins.pathExists p then (pathType p) == "directory" else false;
|
||||||
|
|
||||||
|
# Returns true if the path exists and is a regular file, false otherwise
|
||||||
|
pathIsRegularFile = p: if builtins.pathExists p then (pathType p) == "regular" else false;
|
||||||
|
|
||||||
# Bring in a path as a source, filtering out all Subversion and CVS
|
# Bring in a path as a source, filtering out all Subversion and CVS
|
||||||
# directories, as well as backup files (*~).
|
# directories, as well as backup files (*~).
|
||||||
cleanSourceFilter = name: type: let baseName = baseNameOf (toString name); in ! (
|
cleanSourceFilter = name: type: let baseName = baseNameOf (toString name); in ! (
|
||||||
@ -60,17 +63,14 @@ rec {
|
|||||||
# https://nixos.org/nix/manual/#builtin-filterSource
|
# https://nixos.org/nix/manual/#builtin-filterSource
|
||||||
#
|
#
|
||||||
# name: Optional name to use as part of the store path.
|
# name: Optional name to use as part of the store path.
|
||||||
# This defaults `src.name` or otherwise `baseNameOf src`.
|
# This defaults to `src.name` or otherwise `"source"`.
|
||||||
# We recommend setting `name` whenever `src` is syntactically `./.`.
|
|
||||||
# Otherwise, you depend on `./.`'s name in the parent directory,
|
|
||||||
# which can cause inconsistent names, defeating caching.
|
|
||||||
#
|
#
|
||||||
cleanSourceWith = { filter ? _path: _type: true, src, name ? null }:
|
cleanSourceWith = { filter ? _path: _type: true, src, name ? null }:
|
||||||
let
|
let
|
||||||
isFiltered = src ? _isLibCleanSourceWith;
|
isFiltered = src ? _isLibCleanSourceWith;
|
||||||
origSrc = if isFiltered then src.origSrc else src;
|
origSrc = if isFiltered then src.origSrc else src;
|
||||||
filter' = if isFiltered then name: type: filter name type && src.filter name type else filter;
|
filter' = if isFiltered then name: type: filter name type && src.filter name type else filter;
|
||||||
name' = if name != null then name else if isFiltered then src.name else baseNameOf src;
|
name' = if name != null then name else if isFiltered then src.name else "source";
|
||||||
in {
|
in {
|
||||||
inherit origSrc;
|
inherit origSrc;
|
||||||
filter = filter';
|
filter = filter';
|
||||||
@ -102,6 +102,7 @@ rec {
|
|||||||
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
|
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) exts;
|
||||||
in cleanSourceWith { inherit filter; src = path; };
|
in cleanSourceWith { inherit filter; src = path; };
|
||||||
|
|
||||||
|
pathIsGitRepo = path: (builtins.tryEval (commitIdFromGitRepo path)).success;
|
||||||
|
|
||||||
# Get the commit id of a git repo
|
# Get the commit id of a git repo
|
||||||
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
# Example: commitIdFromGitRepo <nixpkgs/.git>
|
||||||
@ -110,24 +111,45 @@ rec {
|
|||||||
with builtins;
|
with builtins;
|
||||||
let fileName = toString path + "/" + file;
|
let fileName = toString path + "/" + file;
|
||||||
packedRefsName = toString path + "/packed-refs";
|
packedRefsName = toString path + "/packed-refs";
|
||||||
in if lib.pathExists fileName
|
absolutePath = base: path:
|
||||||
|
if lib.hasPrefix "/" path
|
||||||
|
then path
|
||||||
|
else toString (/. + "${base}/${path}");
|
||||||
|
in if pathIsRegularFile path
|
||||||
|
# Resolve git worktrees. See gitrepository-layout(5)
|
||||||
|
then
|
||||||
|
let m = match "^gitdir: (.*)$" (lib.fileContents path);
|
||||||
|
in if m == null
|
||||||
|
then throw ("File contains no gitdir reference: " + path)
|
||||||
|
else
|
||||||
|
let gitDir = absolutePath (dirOf path) (lib.head m);
|
||||||
|
commonDir' = if pathIsRegularFile "${gitDir}/commondir"
|
||||||
|
then lib.fileContents "${gitDir}/commondir"
|
||||||
|
else gitDir;
|
||||||
|
commonDir = absolutePath gitDir commonDir';
|
||||||
|
refFile = lib.removePrefix "${commonDir}/" "${gitDir}/${file}";
|
||||||
|
in readCommitFromFile refFile commonDir
|
||||||
|
|
||||||
|
else if pathIsRegularFile fileName
|
||||||
|
# Sometimes git stores the commitId directly in the file but
|
||||||
|
# sometimes it stores something like: «ref: refs/heads/branch-name»
|
||||||
then
|
then
|
||||||
let fileContent = lib.fileContents fileName;
|
let fileContent = lib.fileContents fileName;
|
||||||
# Sometimes git stores the commitId directly in the file but
|
|
||||||
# sometimes it stores something like: «ref: refs/heads/branch-name»
|
|
||||||
matchRef = match "^ref: (.*)$" fileContent;
|
matchRef = match "^ref: (.*)$" fileContent;
|
||||||
in if matchRef == null
|
in if matchRef == null
|
||||||
then fileContent
|
then fileContent
|
||||||
else readCommitFromFile (lib.head matchRef) path
|
else readCommitFromFile (lib.head matchRef) path
|
||||||
|
|
||||||
|
else if pathIsRegularFile packedRefsName
|
||||||
# Sometimes, the file isn't there at all and has been packed away in the
|
# Sometimes, the file isn't there at all and has been packed away in the
|
||||||
# packed-refs file, so we have to grep through it:
|
# packed-refs file, so we have to grep through it:
|
||||||
else if lib.pathExists packedRefsName
|
|
||||||
then
|
then
|
||||||
let fileContent = readFile packedRefsName;
|
let fileContent = readFile packedRefsName;
|
||||||
matchRef = match (".*\n([^\n ]*) " + file + "\n.*") fileContent;
|
matchRef = match (".*\n([^\n ]*) " + file + "\n.*") fileContent;
|
||||||
in if matchRef == null
|
in if matchRef == null
|
||||||
then throw ("Could not find " + file + " in " + packedRefsName)
|
then throw ("Could not find " + file + " in " + packedRefsName)
|
||||||
else lib.head matchRef
|
else lib.head matchRef
|
||||||
|
|
||||||
else throw ("Not a .git directory: " + path);
|
else throw ("Not a .git directory: " + path);
|
||||||
in readCommitFromFile "HEAD";
|
in readCommitFromFile "HEAD";
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ rec {
|
|||||||
Also note that Nix treats strings as a list of bytes and thus doesn't
|
Also note that Nix treats strings as a list of bytes and thus doesn't
|
||||||
handle unicode.
|
handle unicode.
|
||||||
|
|
||||||
Type: stringtoCharacters :: string -> [string]
|
Type: stringToCharacters :: string -> [string]
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
stringToCharacters ""
|
stringToCharacters ""
|
||||||
@ -315,6 +315,21 @@ rec {
|
|||||||
*/
|
*/
|
||||||
escapeNixString = s: escape ["$"] (builtins.toJSON s);
|
escapeNixString = s: escape ["$"] (builtins.toJSON s);
|
||||||
|
|
||||||
|
/* Quotes a string if it can't be used as an identifier directly.
|
||||||
|
|
||||||
|
Type: string -> string
|
||||||
|
|
||||||
|
Example:
|
||||||
|
escapeNixIdentifier "hello"
|
||||||
|
=> "hello"
|
||||||
|
escapeNixIdentifier "0abc"
|
||||||
|
=> "\"0abc\""
|
||||||
|
*/
|
||||||
|
escapeNixIdentifier = s:
|
||||||
|
# Regex from https://github.com/NixOS/nix/blob/d048577909e383439c2549e849c5c2f2016c997e/src/libexpr/lexer.l#L91
|
||||||
|
if builtins.match "[a-zA-Z_][a-zA-Z0-9_'-]*" s != null
|
||||||
|
then s else escapeNixString s;
|
||||||
|
|
||||||
# Obsolete - use replaceStrings instead.
|
# Obsolete - use replaceStrings instead.
|
||||||
replaceChars = builtins.replaceStrings or (
|
replaceChars = builtins.replaceStrings or (
|
||||||
del: new: s:
|
del: new: s:
|
||||||
@ -678,4 +693,36 @@ rec {
|
|||||||
=> "1.0"
|
=> "1.0"
|
||||||
*/
|
*/
|
||||||
fileContents = file: removeSuffix "\n" (builtins.readFile file);
|
fileContents = file: removeSuffix "\n" (builtins.readFile file);
|
||||||
|
|
||||||
|
|
||||||
|
/* Creates a valid derivation name from a potentially invalid one.
|
||||||
|
|
||||||
|
Type: sanitizeDerivationName :: String -> String
|
||||||
|
|
||||||
|
Example:
|
||||||
|
sanitizeDerivationName "../hello.bar # foo"
|
||||||
|
=> "-hello.bar-foo"
|
||||||
|
sanitizeDerivationName ""
|
||||||
|
=> "unknown"
|
||||||
|
sanitizeDerivationName pkgs.hello
|
||||||
|
=> "-nix-store-2g75chlbpxlrqn15zlby2dfh8hr9qwbk-hello-2.10"
|
||||||
|
*/
|
||||||
|
sanitizeDerivationName = string: lib.pipe string [
|
||||||
|
# Get rid of string context. This is safe under the assumption that the
|
||||||
|
# resulting string is only used as a derivation name
|
||||||
|
builtins.unsafeDiscardStringContext
|
||||||
|
# Strip all leading "."
|
||||||
|
(x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0)
|
||||||
|
# Split out all invalid characters
|
||||||
|
# https://github.com/NixOS/nix/blob/2.3.2/src/libstore/store-api.cc#L85-L112
|
||||||
|
# https://github.com/NixOS/nix/blob/2242be83c61788b9c0736a92bb0b5c7bbfc40803/nix-rust/src/store/path.rs#L100-L125
|
||||||
|
(builtins.split "[^[:alnum:]+._?=-]+")
|
||||||
|
# Replace invalid character ranges with a "-"
|
||||||
|
(concatMapStrings (s: if lib.isList s then "-" else s))
|
||||||
|
# Limit to 211 characters (minus 4 chars for ".drv")
|
||||||
|
(x: substring (lib.max (stringLength x - 207) 0) (-1) x)
|
||||||
|
# If the result is empty, replace it with "unknown"
|
||||||
|
(x: if stringLength x == 0 then "unknown" else x)
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,8 @@ rec {
|
|||||||
else if final.isUClibc then "uclibc"
|
else if final.isUClibc then "uclibc"
|
||||||
else if final.isAndroid then "bionic"
|
else if final.isAndroid then "bionic"
|
||||||
else if final.isLinux /* default */ then "glibc"
|
else if final.isLinux /* default */ then "glibc"
|
||||||
else if final.isMsp430 then "newlib"
|
|
||||||
else if final.isVc4 then "newlib"
|
|
||||||
else if final.isAvr then "avrlibc"
|
else if final.isAvr then "avrlibc"
|
||||||
|
else if final.isNone then "newlib"
|
||||||
else if final.isNetBSD then "nblibc"
|
else if final.isNetBSD then "nblibc"
|
||||||
# TODO(@Ericson2314) think more about other operating systems
|
# TODO(@Ericson2314) think more about other operating systems
|
||||||
else "native/impure";
|
else "native/impure";
|
||||||
@ -66,6 +65,7 @@ rec {
|
|||||||
freebsd = "FreeBSD";
|
freebsd = "FreeBSD";
|
||||||
openbsd = "OpenBSD";
|
openbsd = "OpenBSD";
|
||||||
wasi = "Wasi";
|
wasi = "Wasi";
|
||||||
|
genode = "Genode";
|
||||||
}.${final.parsed.kernel.name} or null;
|
}.${final.parsed.kernel.name} or null;
|
||||||
|
|
||||||
# uname -p
|
# uname -p
|
||||||
@ -84,7 +84,7 @@ rec {
|
|||||||
else final.parsed.cpu.name;
|
else final.parsed.cpu.name;
|
||||||
|
|
||||||
qemuArch =
|
qemuArch =
|
||||||
if final.isArm then "arm"
|
if final.isAarch32 then "arm"
|
||||||
else if final.isx86_64 then "x86_64"
|
else if final.isx86_64 then "x86_64"
|
||||||
else if final.isx86 then "i386"
|
else if final.isx86 then "i386"
|
||||||
else {
|
else {
|
||||||
|
@ -26,7 +26,17 @@ let
|
|||||||
|
|
||||||
"riscv32-linux" "riscv64-linux"
|
"riscv32-linux" "riscv64-linux"
|
||||||
|
|
||||||
"aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" "vc4-none"
|
"arm-none" "armv6l-none" "aarch64-none"
|
||||||
|
"avr-none"
|
||||||
|
"i686-none" "x86_64-none"
|
||||||
|
"powerpc-none"
|
||||||
|
"msp430-none"
|
||||||
|
"riscv64-none" "riscv32-none"
|
||||||
|
"vc4-none"
|
||||||
|
|
||||||
|
"js-ghcjs"
|
||||||
|
|
||||||
|
"aarch64-genode" "x86_64-genode"
|
||||||
];
|
];
|
||||||
|
|
||||||
allParsed = map parse.mkSystemFromString all;
|
allParsed = map parse.mkSystemFromString all;
|
||||||
@ -46,6 +56,7 @@ in {
|
|||||||
mips = filterDoubles predicates.isMips;
|
mips = filterDoubles predicates.isMips;
|
||||||
riscv = filterDoubles predicates.isRiscV;
|
riscv = filterDoubles predicates.isRiscV;
|
||||||
vc4 = filterDoubles predicates.isVc4;
|
vc4 = filterDoubles predicates.isVc4;
|
||||||
|
js = filterDoubles predicates.isJavaScript;
|
||||||
|
|
||||||
cygwin = filterDoubles predicates.isCygwin;
|
cygwin = filterDoubles predicates.isCygwin;
|
||||||
darwin = filterDoubles predicates.isDarwin;
|
darwin = filterDoubles predicates.isDarwin;
|
||||||
@ -59,6 +70,7 @@ in {
|
|||||||
unix = filterDoubles predicates.isUnix;
|
unix = filterDoubles predicates.isUnix;
|
||||||
wasi = filterDoubles predicates.isWasi;
|
wasi = filterDoubles predicates.isWasi;
|
||||||
windows = filterDoubles predicates.isWindows;
|
windows = filterDoubles predicates.isWindows;
|
||||||
|
genode = filterDoubles predicates.isGenode;
|
||||||
|
|
||||||
embedded = filterDoubles predicates.isNone;
|
embedded = filterDoubles predicates.isNone;
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ rec {
|
|||||||
iphone64 = {
|
iphone64 = {
|
||||||
config = "aarch64-apple-ios";
|
config = "aarch64-apple-ios";
|
||||||
# config = "aarch64-apple-darwin14";
|
# config = "aarch64-apple-darwin14";
|
||||||
sdkVer = "10.2";
|
sdkVer = "12.4";
|
||||||
xcodeVer = "8.2";
|
xcodeVer = "10.3";
|
||||||
xcodePlatform = "iPhoneOS";
|
xcodePlatform = "iPhoneOS";
|
||||||
useiOSPrebuilt = true;
|
useiOSPrebuilt = true;
|
||||||
platform = {};
|
platform = {};
|
||||||
@ -180,8 +180,8 @@ rec {
|
|||||||
iphone32 = {
|
iphone32 = {
|
||||||
config = "armv7a-apple-ios";
|
config = "armv7a-apple-ios";
|
||||||
# config = "arm-apple-darwin10";
|
# config = "arm-apple-darwin10";
|
||||||
sdkVer = "10.2";
|
sdkVer = "12.4";
|
||||||
xcodeVer = "8.2";
|
xcodeVer = "10.3";
|
||||||
xcodePlatform = "iPhoneOS";
|
xcodePlatform = "iPhoneOS";
|
||||||
useiOSPrebuilt = true;
|
useiOSPrebuilt = true;
|
||||||
platform = {};
|
platform = {};
|
||||||
@ -190,8 +190,8 @@ rec {
|
|||||||
iphone64-simulator = {
|
iphone64-simulator = {
|
||||||
config = "x86_64-apple-ios";
|
config = "x86_64-apple-ios";
|
||||||
# config = "x86_64-apple-darwin14";
|
# config = "x86_64-apple-darwin14";
|
||||||
sdkVer = "10.2";
|
sdkVer = "12.4";
|
||||||
xcodeVer = "8.2";
|
xcodeVer = "10.3";
|
||||||
xcodePlatform = "iPhoneSimulator";
|
xcodePlatform = "iPhoneSimulator";
|
||||||
useiOSPrebuilt = true;
|
useiOSPrebuilt = true;
|
||||||
platform = {};
|
platform = {};
|
||||||
@ -200,8 +200,8 @@ rec {
|
|||||||
iphone32-simulator = {
|
iphone32-simulator = {
|
||||||
config = "i686-apple-ios";
|
config = "i686-apple-ios";
|
||||||
# config = "i386-apple-darwin11";
|
# config = "i386-apple-darwin11";
|
||||||
sdkVer = "10.2";
|
sdkVer = "12.4";
|
||||||
xcodeVer = "8.2";
|
xcodeVer = "10.3";
|
||||||
xcodePlatform = "iPhoneSimulator";
|
xcodePlatform = "iPhoneSimulator";
|
||||||
useiOSPrebuilt = true;
|
useiOSPrebuilt = true;
|
||||||
platform = {};
|
platform = {};
|
||||||
|
@ -47,6 +47,7 @@ rec {
|
|||||||
isMinGW = { kernel = kernels.windows; abi = abis.gnu; };
|
isMinGW = { kernel = kernels.windows; abi = abis.gnu; };
|
||||||
isWasi = { kernel = kernels.wasi; };
|
isWasi = { kernel = kernels.wasi; };
|
||||||
isGhcjs = { kernel = kernels.ghcjs; };
|
isGhcjs = { kernel = kernels.ghcjs; };
|
||||||
|
isGenode = { kernel = kernels.genode; };
|
||||||
isNone = { kernel = kernels.none; };
|
isNone = { kernel = kernels.none; };
|
||||||
|
|
||||||
isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
|
isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
|
||||||
@ -55,9 +56,6 @@ rec {
|
|||||||
|
|
||||||
isEfi = map (family: { cpu.family = family; })
|
isEfi = map (family: { cpu.family = family; })
|
||||||
[ "x86" "arm" "aarch64" ];
|
[ "x86" "arm" "aarch64" ];
|
||||||
|
|
||||||
# Deprecated after 18.03
|
|
||||||
isArm = isAarch32;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
matchAnyAttrs = patterns:
|
matchAnyAttrs = patterns:
|
||||||
|
@ -279,6 +279,7 @@ rec {
|
|||||||
wasi = { execFormat = wasm; families = { }; };
|
wasi = { execFormat = wasm; families = { }; };
|
||||||
windows = { execFormat = pe; families = { }; };
|
windows = { execFormat = pe; families = { }; };
|
||||||
ghcjs = { execFormat = unknown; families = { }; };
|
ghcjs = { execFormat = unknown; families = { }; };
|
||||||
|
genode = { execFormat = elf; families = { }; };
|
||||||
} // { # aliases
|
} // { # aliases
|
||||||
# 'darwin' is the kernel for all of them. We choose macOS by default.
|
# 'darwin' is the kernel for all of them. We choose macOS by default.
|
||||||
darwin = kernels.macos;
|
darwin = kernels.macos;
|
||||||
@ -395,6 +396,8 @@ rec {
|
|||||||
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 1; abi = elemAt l 2; }
|
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 1; abi = elemAt l 2; }
|
||||||
else if (elemAt l 2 == "ghcjs")
|
else if (elemAt l 2 == "ghcjs")
|
||||||
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 2; }
|
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 2; }
|
||||||
|
else if hasPrefix "genode" (elemAt l 2)
|
||||||
|
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
|
||||||
else throw "Target specification with 3 components is ambiguous";
|
else throw "Target specification with 3 components is ambiguous";
|
||||||
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
|
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
|
||||||
}.${toString (length l)}
|
}.${toString (length l)}
|
||||||
|
75
lib/tests/maintainers.nix
Normal file
75
lib/tests/maintainers.nix
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# to run these tests:
|
||||||
|
# nix-build nixpkgs/lib/tests/maintainers.nix
|
||||||
|
# If nothing is output, all tests passed
|
||||||
|
{ pkgs ? import ../.. {} }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
inherit (lib) types;
|
||||||
|
|
||||||
|
maintainerModule = { config, ... }: {
|
||||||
|
options = {
|
||||||
|
name = lib.mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
email = lib.mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
github = lib.mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
githubId = lib.mkOption {
|
||||||
|
type = types.nullOr types.ints.unsigned;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
keys = lib.mkOption {
|
||||||
|
type = types.listOf (types.submodule {
|
||||||
|
options.longkeyid = lib.mkOption { type = types.str; };
|
||||||
|
options.fingerprint = lib.mkOption { type = types.str; };
|
||||||
|
});
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
checkMaintainer = handle: uncheckedAttrs:
|
||||||
|
let
|
||||||
|
prefix = [ "lib" "maintainers" handle ];
|
||||||
|
checkedAttrs = (lib.modules.evalModules {
|
||||||
|
inherit prefix;
|
||||||
|
modules = [
|
||||||
|
maintainerModule
|
||||||
|
{
|
||||||
|
_file = toString ../../maintainers/maintainer-list.nix;
|
||||||
|
config = uncheckedAttrs;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}).config;
|
||||||
|
|
||||||
|
checkGithubId = lib.optional (checkedAttrs.github != null && checkedAttrs.githubId == null) ''
|
||||||
|
echo ${lib.escapeShellArg (lib.showOption prefix)}': If `github` is specified, `githubId` must be too.'
|
||||||
|
# Calling this too often would hit non-authenticated API limits, but this
|
||||||
|
# shouldn't happen since such errors will get fixed rather quickly
|
||||||
|
info=$(curl -sS https://api.github.com/users/${checkedAttrs.github})
|
||||||
|
id=$(jq -r '.id' <<< "$info")
|
||||||
|
echo "The GitHub ID for GitHub user ${checkedAttrs.github} is $id:"
|
||||||
|
echo -e " githubId = $id;\n"
|
||||||
|
'';
|
||||||
|
in lib.deepSeq checkedAttrs checkGithubId;
|
||||||
|
|
||||||
|
missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers);
|
||||||
|
|
||||||
|
success = pkgs.runCommandNoCC "checked-maintainers-success" {} ">$out";
|
||||||
|
|
||||||
|
failure = pkgs.runCommandNoCC "checked-maintainers-failure" {
|
||||||
|
nativeBuildInputs = [ pkgs.curl pkgs.jq ];
|
||||||
|
outputHash = "sha256:${lib.fakeSha256}";
|
||||||
|
outputHAlgo = "sha256";
|
||||||
|
outputHashMode = "flat";
|
||||||
|
SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||||
|
} ''
|
||||||
|
${lib.concatStringsSep "\n" missingGithubIds}
|
||||||
|
exit 1
|
||||||
|
'';
|
||||||
|
in if missingGithubIds == [] then success else failure
|
@ -3,6 +3,23 @@
|
|||||||
# if the resulting list is empty, all tests passed
|
# if the resulting list is empty, all tests passed
|
||||||
with import ../default.nix;
|
with import ../default.nix;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
testSanitizeDerivationName = { name, expected }:
|
||||||
|
let
|
||||||
|
drv = derivation {
|
||||||
|
name = strings.sanitizeDerivationName name;
|
||||||
|
builder = "x";
|
||||||
|
system = "x";
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
# Evaluate the derivation so an invalid name would be caught
|
||||||
|
expr = builtins.seq drv.drvPath drv.name;
|
||||||
|
inherit expected;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
runTests {
|
runTests {
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +165,7 @@ runTests {
|
|||||||
"${builtins.storeDir}/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11";
|
"${builtins.storeDir}/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11";
|
||||||
in {
|
in {
|
||||||
storePath = isStorePath goodPath;
|
storePath = isStorePath goodPath;
|
||||||
storePathDerivation = isStorePath (import ../.. {}).hello;
|
storePathDerivation = isStorePath (import ../.. { system = "x86_64-linux"; }).hello;
|
||||||
storePathAppendix = isStorePath
|
storePathAppendix = isStorePath
|
||||||
"${goodPath}/bin/python";
|
"${goodPath}/bin/python";
|
||||||
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
|
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
|
||||||
@ -348,6 +365,18 @@ runTests {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testToINIDuplicateKeys = {
|
||||||
|
expr = generators.toINI { listsAsDuplicateKeys = true; } { foo.bar = true; baz.qux = [ 1 false ]; };
|
||||||
|
expected = ''
|
||||||
|
[baz]
|
||||||
|
qux=1
|
||||||
|
qux=false
|
||||||
|
|
||||||
|
[foo]
|
||||||
|
bar=true
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
testToINIDefaultEscapes = {
|
testToINIDefaultEscapes = {
|
||||||
expr = generators.toINI {} {
|
expr = generators.toINI {} {
|
||||||
"no [ and ] allowed unescaped" = {
|
"no [ and ] allowed unescaped" = {
|
||||||
@ -441,4 +470,66 @@ runTests {
|
|||||||
expected = "«foo»";
|
expected = "«foo»";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
# CLI
|
||||||
|
|
||||||
|
testToGNUCommandLine = {
|
||||||
|
expr = 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
expected = [
|
||||||
|
"-X" "PUT"
|
||||||
|
"--data" "{\"id\":0}"
|
||||||
|
"--retry" "3"
|
||||||
|
"--url" "https://example.com/foo"
|
||||||
|
"--url" "https://example.com/bar"
|
||||||
|
"--verbose"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
testToGNUCommandLineShell = {
|
||||||
|
expr = 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
expected = "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
|
||||||
|
};
|
||||||
|
|
||||||
|
testSanitizeDerivationNameLeadingDots = testSanitizeDerivationName {
|
||||||
|
name = "..foo";
|
||||||
|
expected = "foo";
|
||||||
|
};
|
||||||
|
|
||||||
|
testSanitizeDerivationNameAscii = testSanitizeDerivationName {
|
||||||
|
name = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||||
|
expected = "-+--.-0123456789-=-?-ABCDEFGHIJKLMNOPQRSTUVWXYZ-_-abcdefghijklmnopqrstuvwxyz-";
|
||||||
|
};
|
||||||
|
|
||||||
|
testSanitizeDerivationNameTooLong = testSanitizeDerivationName {
|
||||||
|
name = "This string is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong";
|
||||||
|
expected = "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong";
|
||||||
|
};
|
||||||
|
|
||||||
|
testSanitizeDerivationNameTooLongWithInvalid = testSanitizeDerivationName {
|
||||||
|
name = "Hello there aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&&&&&&&";
|
||||||
|
expected = "there-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-";
|
||||||
|
};
|
||||||
|
|
||||||
|
testSanitizeDerivationNameEmpty = testSanitizeDerivationName {
|
||||||
|
name = "";
|
||||||
|
expected = "unknown";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
# This script is used to test that the module system is working as expected.
|
# This script is used to test that the module system is working as expected.
|
||||||
# By default it test the version of nixpkgs which is defined in the NIX_PATH.
|
# By default it test the version of nixpkgs which is defined in the NIX_PATH.
|
||||||
|
|
||||||
cd ./modules
|
# https://stackoverflow.com/a/246128/6605742
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
|
cd "$DIR"/modules
|
||||||
|
|
||||||
pass=0
|
pass=0
|
||||||
fail=0
|
fail=0
|
||||||
@ -12,7 +15,7 @@ evalConfig() {
|
|||||||
local attr=$1
|
local attr=$1
|
||||||
shift;
|
shift;
|
||||||
local script="import ./default.nix { modules = [ $@ ];}"
|
local script="import ./default.nix { modules = [ $@ ];}"
|
||||||
nix-instantiate --timeout 1 -E "$script" -A "$attr" --eval-only --show-trace
|
nix-instantiate --timeout 1 -E "$script" -A "$attr" --eval-only --show-trace --read-write-mode
|
||||||
}
|
}
|
||||||
|
|
||||||
reportFailure() {
|
reportFailure() {
|
||||||
@ -87,36 +90,36 @@ checkConfigOutput "false" "$@" ./define-force-enable.nix
|
|||||||
checkConfigOutput "false" "$@" ./define-enable-force.nix
|
checkConfigOutput "false" "$@" ./define-enable-force.nix
|
||||||
|
|
||||||
# Check mkForce with option and submodules.
|
# Check mkForce with option and submodules.
|
||||||
checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix
|
checkConfigError 'attribute .*foo.* .* not found' config.attrsOfSub.foo.enable ./declare-attrsOfSub-any-enable.nix
|
||||||
checkConfigOutput 'false' config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix
|
checkConfigOutput 'false' config.attrsOfSub.foo.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nix
|
||||||
set -- config.loaOfSub.foo.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo-enable.nix
|
set -- config.attrsOfSub.foo.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo-enable.nix
|
||||||
checkConfigOutput 'true' "$@"
|
checkConfigOutput 'true' "$@"
|
||||||
checkConfigOutput 'false' "$@" ./define-force-loaOfSub-foo-enable.nix
|
checkConfigOutput 'false' "$@" ./define-force-attrsOfSub-foo-enable.nix
|
||||||
checkConfigOutput 'false' "$@" ./define-loaOfSub-force-foo-enable.nix
|
checkConfigOutput 'false' "$@" ./define-attrsOfSub-force-foo-enable.nix
|
||||||
checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-force-enable.nix
|
checkConfigOutput 'false' "$@" ./define-attrsOfSub-foo-force-enable.nix
|
||||||
checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-force.nix
|
checkConfigOutput 'false' "$@" ./define-attrsOfSub-foo-enable-force.nix
|
||||||
|
|
||||||
# Check overriding effect of mkForce on submodule definitions.
|
# Check overriding effect of mkForce on submodule definitions.
|
||||||
checkConfigError 'attribute .*bar.* .* not found' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix
|
checkConfigError 'attribute .*bar.* .* not found' config.attrsOfSub.bar.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nix
|
||||||
checkConfigOutput 'false' config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix ./define-loaOfSub-bar.nix
|
checkConfigOutput 'false' config.attrsOfSub.bar.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nix ./define-attrsOfSub-bar.nix
|
||||||
set -- config.loaOfSub.bar.enable ./declare-loaOfSub-any-enable.nix ./define-loaOfSub-foo.nix ./define-loaOfSub-bar-enable.nix
|
set -- config.attrsOfSub.bar.enable ./declare-attrsOfSub-any-enable.nix ./define-attrsOfSub-foo.nix ./define-attrsOfSub-bar-enable.nix
|
||||||
checkConfigOutput 'true' "$@"
|
checkConfigOutput 'true' "$@"
|
||||||
checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-force-loaOfSub-foo-enable.nix
|
checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-force-attrsOfSub-foo-enable.nix
|
||||||
checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-loaOfSub-force-foo-enable.nix
|
checkConfigError 'attribute .*bar.* .* not found' "$@" ./define-attrsOfSub-force-foo-enable.nix
|
||||||
checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-force-enable.nix
|
checkConfigOutput 'true' "$@" ./define-attrsOfSub-foo-force-enable.nix
|
||||||
checkConfigOutput 'true' "$@" ./define-loaOfSub-foo-enable-force.nix
|
checkConfigOutput 'true' "$@" ./define-attrsOfSub-foo-enable-force.nix
|
||||||
|
|
||||||
# Check mkIf with submodules.
|
# Check mkIf with submodules.
|
||||||
checkConfigError 'attribute .*foo.* .* not found' config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix
|
checkConfigError 'attribute .*foo.* .* not found' config.attrsOfSub.foo.enable ./declare-enable.nix ./declare-attrsOfSub-any-enable.nix
|
||||||
set -- config.loaOfSub.foo.enable ./declare-enable.nix ./declare-loaOfSub-any-enable.nix
|
set -- config.attrsOfSub.foo.enable ./declare-enable.nix ./declare-attrsOfSub-any-enable.nix
|
||||||
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-if-loaOfSub-foo-enable.nix
|
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-if-attrsOfSub-foo-enable.nix
|
||||||
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-if-foo-enable.nix
|
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-attrsOfSub-if-foo-enable.nix
|
||||||
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-loaOfSub-foo-if-enable.nix
|
checkConfigError 'attribute .*foo.* .* not found' "$@" ./define-attrsOfSub-foo-if-enable.nix
|
||||||
checkConfigOutput 'false' "$@" ./define-loaOfSub-foo-enable-if.nix
|
checkConfigOutput 'false' "$@" ./define-attrsOfSub-foo-enable-if.nix
|
||||||
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-if-loaOfSub-foo-enable.nix
|
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-if-attrsOfSub-foo-enable.nix
|
||||||
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-if-foo-enable.nix
|
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-attrsOfSub-if-foo-enable.nix
|
||||||
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-if-enable.nix
|
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-attrsOfSub-foo-if-enable.nix
|
||||||
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-loaOfSub-foo-enable-if.nix
|
checkConfigOutput 'true' "$@" ./define-enable.nix ./define-attrsOfSub-foo-enable-if.nix
|
||||||
|
|
||||||
# Check disabledModules with config definitions and option declarations.
|
# Check disabledModules with config definitions and option declarations.
|
||||||
set -- config.enable ./define-enable.nix ./declare-enable.nix
|
set -- config.enable ./define-enable.nix ./declare-enable.nix
|
||||||
@ -138,7 +141,7 @@ checkConfigError 'while evaluating the module argument .*custom.* in .*import-cu
|
|||||||
checkConfigError 'infinite recursion encountered' "$@"
|
checkConfigError 'infinite recursion encountered' "$@"
|
||||||
|
|
||||||
# Check _module.check.
|
# Check _module.check.
|
||||||
set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-loaOfSub-foo.nix
|
set -- config.enable ./declare-enable.nix ./define-enable.nix ./define-attrsOfSub-foo.nix
|
||||||
checkConfigError 'The option .* defined in .* does not exist.' "$@"
|
checkConfigError 'The option .* defined in .* does not exist.' "$@"
|
||||||
checkConfigOutput "true" "$@" ./define-module-check.nix
|
checkConfigOutput "true" "$@" ./define-module-check.nix
|
||||||
|
|
||||||
@ -152,18 +155,61 @@ checkConfigOutput "12" config.value ./declare-coerced-value-unsound.nix
|
|||||||
checkConfigError 'The option value .* in .* is not.*8 bit signed integer.* or string convertible to it' config.value ./declare-coerced-value-unsound.nix ./define-value-string-bigint.nix
|
checkConfigError 'The option value .* in .* is not.*8 bit signed integer.* or string convertible to it' config.value ./declare-coerced-value-unsound.nix ./define-value-string-bigint.nix
|
||||||
checkConfigError 'unrecognised JSON value' config.value ./declare-coerced-value-unsound.nix ./define-value-string-arbitrary.nix
|
checkConfigError 'unrecognised JSON value' config.value ./declare-coerced-value-unsound.nix ./define-value-string-arbitrary.nix
|
||||||
|
|
||||||
# Check loaOf with long list.
|
|
||||||
checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-long-list.nix
|
|
||||||
|
|
||||||
# Check loaOf with many merges of lists.
|
|
||||||
checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix
|
|
||||||
|
|
||||||
# Check mkAliasOptionModule.
|
# Check mkAliasOptionModule.
|
||||||
checkConfigOutput "true" config.enable ./alias-with-priority.nix
|
checkConfigOutput "true" config.enable ./alias-with-priority.nix
|
||||||
checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix
|
checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix
|
||||||
checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
|
checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
|
||||||
checkConfigOutput "false" config.enableAlias ./alias-with-priority-can-override.nix
|
checkConfigOutput "false" config.enableAlias ./alias-with-priority-can-override.nix
|
||||||
|
|
||||||
|
# submoduleWith
|
||||||
|
|
||||||
|
## specialArgs should work
|
||||||
|
checkConfigOutput "foo" config.submodule.foo ./declare-submoduleWith-special.nix
|
||||||
|
|
||||||
|
## shorthandOnlyDefines config behaves as expected
|
||||||
|
checkConfigOutput "true" config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-shorthand.nix
|
||||||
|
checkConfigError 'is not of type `boolean' config.submodule.config ./declare-submoduleWith-shorthand.nix ./define-submoduleWith-noshorthand.nix
|
||||||
|
checkConfigError 'value is a boolean while a set was expected' config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-shorthand.nix
|
||||||
|
checkConfigOutput "true" config.submodule.config ./declare-submoduleWith-noshorthand.nix ./define-submoduleWith-noshorthand.nix
|
||||||
|
|
||||||
|
## submoduleWith should merge all modules in one swoop
|
||||||
|
checkConfigOutput "true" config.submodule.inner ./declare-submoduleWith-modules.nix
|
||||||
|
checkConfigOutput "true" config.submodule.outer ./declare-submoduleWith-modules.nix
|
||||||
|
|
||||||
|
## Paths should be allowed as values and work as expected
|
||||||
|
checkConfigOutput "true" config.submodule.enable ./declare-submoduleWith-path.nix
|
||||||
|
|
||||||
|
# Check that disabledModules works recursively and correctly
|
||||||
|
checkConfigOutput "true" config.enable ./disable-recursive/main.nix
|
||||||
|
checkConfigOutput "true" config.enable ./disable-recursive/{main.nix,disable-foo.nix}
|
||||||
|
checkConfigOutput "true" config.enable ./disable-recursive/{main.nix,disable-bar.nix}
|
||||||
|
checkConfigError 'The option .* defined in .* does not exist' config.enable ./disable-recursive/{main.nix,disable-foo.nix,disable-bar.nix}
|
||||||
|
|
||||||
|
# Check that imports can depend on derivations
|
||||||
|
checkConfigOutput "true" config.enable ./import-from-store.nix
|
||||||
|
|
||||||
|
# Check that configs can be conditional on option existence
|
||||||
|
checkConfigOutput true config.enable ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nix
|
||||||
|
checkConfigOutput 360 config.value ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nix
|
||||||
|
checkConfigOutput 7 config.value ./define-option-dependently.nix ./declare-int-positive-value.nix
|
||||||
|
checkConfigOutput true config.set.enable ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nix
|
||||||
|
checkConfigOutput 360 config.set.value ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nix
|
||||||
|
checkConfigOutput 7 config.set.value ./define-option-dependently-nested.nix ./declare-int-positive-value-nested.nix
|
||||||
|
|
||||||
|
# Check attrsOf and lazyAttrsOf. Only lazyAttrsOf should be lazy, and only
|
||||||
|
# attrsOf should work with conditional definitions
|
||||||
|
# In addition, lazyAttrsOf should honor an options emptyValue
|
||||||
|
checkConfigError "is not lazy" config.isLazy ./declare-attrsOf.nix ./attrsOf-lazy-check.nix
|
||||||
|
checkConfigOutput "true" config.isLazy ./declare-lazyAttrsOf.nix ./attrsOf-lazy-check.nix
|
||||||
|
checkConfigOutput "true" config.conditionalWorks ./declare-attrsOf.nix ./attrsOf-conditional-check.nix
|
||||||
|
checkConfigOutput "false" config.conditionalWorks ./declare-lazyAttrsOf.nix ./attrsOf-conditional-check.nix
|
||||||
|
checkConfigOutput "empty" config.value.foo ./declare-lazyAttrsOf.nix ./attrsOf-conditional-check.nix
|
||||||
|
|
||||||
|
|
||||||
|
# Even with multiple assignments, a type error should be thrown if any of them aren't valid
|
||||||
|
checkConfigError 'The option value .* in .* is not of type .*' \
|
||||||
|
config.value ./declare-int-unsigned-value.nix ./define-value-list.nix ./define-value-int-positive.nix
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
====== module tests ======
|
====== module tests ======
|
||||||
$pass Pass
|
$pass Pass
|
||||||
|
7
lib/tests/modules/attrsOf-conditional-check.nix
Normal file
7
lib/tests/modules/attrsOf-conditional-check.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{ lib, config, ... }: {
|
||||||
|
options.conditionalWorks = lib.mkOption {
|
||||||
|
default = ! config.value ? foo;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.value.foo = lib.mkIf false "should not be defined";
|
||||||
|
}
|
7
lib/tests/modules/attrsOf-lazy-check.nix
Normal file
7
lib/tests/modules/attrsOf-lazy-check.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{ lib, config, ... }: {
|
||||||
|
options.isLazy = lib.mkOption {
|
||||||
|
default = ! config.value ? foo;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.value.bar = throw "is not lazy";
|
||||||
|
}
|
6
lib/tests/modules/declare-attrsOf.nix
Normal file
6
lib/tests/modules/declare-attrsOf.nix
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{ lib, ... }: {
|
||||||
|
options.value = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.str;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
@ -17,10 +17,10 @@ in
|
|||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
loaOfSub = lib.mkOption {
|
attrsOfSub = lib.mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
example = {};
|
example = {};
|
||||||
type = lib.types.loaOf (lib.types.submodule [ submod ]);
|
type = lib.types.attrsOf (lib.types.submodule [ submod ]);
|
||||||
description = ''
|
description = ''
|
||||||
Some descriptive text
|
Some descriptive text
|
||||||
'';
|
'';
|
14
lib/tests/modules/declare-enable-nested.nix
Normal file
14
lib/tests/modules/declare-enable-nested.nix
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.set = {
|
||||||
|
enable = lib.mkOption {
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
type = lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Some descriptive text
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
9
lib/tests/modules/declare-int-positive-value-nested.nix
Normal file
9
lib/tests/modules/declare-int-positive-value-nested.nix
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.set = {
|
||||||
|
value = lib.mkOption {
|
||||||
|
type = lib.types.ints.positive;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
6
lib/tests/modules/declare-lazyAttrsOf.nix
Normal file
6
lib/tests/modules/declare-lazyAttrsOf.nix
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{ lib, ... }: {
|
||||||
|
options.value = lib.mkOption {
|
||||||
|
type = lib.types.lazyAttrsOf (lib.types.str // { emptyValue.value = "empty"; });
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
30
lib/tests/modules/declare-submoduleWith-modules.nix
Normal file
30
lib/tests/modules/declare-submoduleWith-modules.nix
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{ lib, ... }: {
|
||||||
|
options.submodule = lib.mkOption {
|
||||||
|
type = lib.types.submoduleWith {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options.inner = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
outer = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.submodule = lib.mkMerge [
|
||||||
|
({ lib, ... }: {
|
||||||
|
options.outer = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
{
|
||||||
|
inner = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
13
lib/tests/modules/declare-submoduleWith-noshorthand.nix
Normal file
13
lib/tests/modules/declare-submoduleWith-noshorthand.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ lib, ... }: let
|
||||||
|
sub.options.config = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.submodule = lib.mkOption {
|
||||||
|
type = lib.types.submoduleWith {
|
||||||
|
modules = [ sub ];
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
12
lib/tests/modules/declare-submoduleWith-path.nix
Normal file
12
lib/tests/modules/declare-submoduleWith-path.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{ lib, ... }: {
|
||||||
|
options.submodule = lib.mkOption {
|
||||||
|
type = lib.types.submoduleWith {
|
||||||
|
modules = [
|
||||||
|
./declare-enable.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.submodule = ./define-enable.nix;
|
||||||
|
}
|
14
lib/tests/modules/declare-submoduleWith-shorthand.nix
Normal file
14
lib/tests/modules/declare-submoduleWith-shorthand.nix
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{ lib, ... }: let
|
||||||
|
sub.options.config = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.submodule = lib.mkOption {
|
||||||
|
type = lib.types.submoduleWith {
|
||||||
|
modules = [ sub ];
|
||||||
|
shorthandOnlyDefinesConfig = true;
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
17
lib/tests/modules/declare-submoduleWith-special.nix
Normal file
17
lib/tests/modules/declare-submoduleWith-special.nix
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{ lib, ... }: {
|
||||||
|
options.submodule = lib.mkOption {
|
||||||
|
type = lib.types.submoduleWith {
|
||||||
|
modules = [
|
||||||
|
({ lib, ... }: {
|
||||||
|
options.foo = lib.mkOption {
|
||||||
|
default = lib.foo;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
specialArgs.lib = lib // {
|
||||||
|
foo = "foo";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
3
lib/tests/modules/define-attrsOfSub-bar-enable.nix
Normal file
3
lib/tests/modules/define-attrsOfSub-bar-enable.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
attrsOfSub.bar.enable = true;
|
||||||
|
}
|
3
lib/tests/modules/define-attrsOfSub-bar.nix
Normal file
3
lib/tests/modules/define-attrsOfSub-bar.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
attrsOfSub.bar = {};
|
||||||
|
}
|
5
lib/tests/modules/define-attrsOfSub-foo-enable-force.nix
Normal file
5
lib/tests/modules/define-attrsOfSub-foo-enable-force.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
attrsOfSub.foo.enable = lib.mkForce false;
|
||||||
|
}
|
5
lib/tests/modules/define-attrsOfSub-foo-enable-if.nix
Normal file
5
lib/tests/modules/define-attrsOfSub-foo-enable-if.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
attrsOfSub.foo.enable = lib.mkIf config.enable true;
|
||||||
|
}
|
3
lib/tests/modules/define-attrsOfSub-foo-enable.nix
Normal file
3
lib/tests/modules/define-attrsOfSub-foo-enable.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
attrsOfSub.foo.enable = true;
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
loaOfSub.foo = lib.mkForce {
|
attrsOfSub.foo = lib.mkForce {
|
||||||
enable = false;
|
enable = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
loaOfSub.foo = lib.mkIf config.enable {
|
attrsOfSub.foo = lib.mkIf config.enable {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
3
lib/tests/modules/define-attrsOfSub-foo.nix
Normal file
3
lib/tests/modules/define-attrsOfSub-foo.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
attrsOfSub.foo = {};
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
loaOfSub = lib.mkForce {
|
attrsOfSub = lib.mkForce {
|
||||||
foo.enable = false;
|
foo.enable = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
loaOfSub = lib.mkIf config.enable {
|
attrsOfSub = lib.mkIf config.enable {
|
||||||
foo.enable = true;
|
foo.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
5
lib/tests/modules/define-force-attrsOfSub-foo-enable.nix
Normal file
5
lib/tests/modules/define-force-attrsOfSub-foo-enable.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
lib.mkForce {
|
||||||
|
attrsOfSub.foo.enable = false;
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
lib.mkForce {
|
|
||||||
loaOfSub.foo.enable = false;
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
lib.mkIf config.enable {
|
lib.mkIf config.enable {
|
||||||
loaOfSub.foo.enable = true;
|
attrsOfSub.foo.enable = true;
|
||||||
}
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
loaOfSub.bar.enable = true;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
loaOfSub.bar = {};
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
loaOfSub.foo.enable = lib.mkForce false;
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
{ config, lib, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
loaOfSub.foo.enable = lib.mkIf config.enable true;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
loaOfSub.foo.enable = true;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
loaOfSub.foo = {};
|
|
||||||
}
|
|
16
lib/tests/modules/define-option-dependently-nested.nix
Normal file
16
lib/tests/modules/define-option-dependently-nested.nix
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ lib, options, ... }:
|
||||||
|
|
||||||
|
# Some modules may be distributed separately and need to adapt to other modules
|
||||||
|
# that are distributed and versioned separately.
|
||||||
|
{
|
||||||
|
|
||||||
|
# Always defined, but the value depends on the presence of an option.
|
||||||
|
config.set = {
|
||||||
|
value = if options ? set.enable then 360 else 7;
|
||||||
|
}
|
||||||
|
# Only define if possible.
|
||||||
|
// lib.optionalAttrs (options ? set.enable) {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
16
lib/tests/modules/define-option-dependently.nix
Normal file
16
lib/tests/modules/define-option-dependently.nix
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{ lib, options, ... }:
|
||||||
|
|
||||||
|
# Some modules may be distributed separately and need to adapt to other modules
|
||||||
|
# that are distributed and versioned separately.
|
||||||
|
{
|
||||||
|
|
||||||
|
# Always defined, but the value depends on the presence of an option.
|
||||||
|
config = {
|
||||||
|
value = if options ? enable then 360 else 7;
|
||||||
|
}
|
||||||
|
# Only define if possible.
|
||||||
|
// lib.optionalAttrs (options ? enable) {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
3
lib/tests/modules/define-submoduleWith-noshorthand.nix
Normal file
3
lib/tests/modules/define-submoduleWith-noshorthand.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
submodule.config.config = true;
|
||||||
|
}
|
3
lib/tests/modules/define-submoduleWith-shorthand.nix
Normal file
3
lib/tests/modules/define-submoduleWith-shorthand.nix
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
submodule.config = true;
|
||||||
|
}
|
5
lib/tests/modules/disable-recursive/bar.nix
Normal file
5
lib/tests/modules/disable-recursive/bar.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../declare-enable.nix
|
||||||
|
];
|
||||||
|
}
|
7
lib/tests/modules/disable-recursive/disable-bar.nix
Normal file
7
lib/tests/modules/disable-recursive/disable-bar.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
disabledModules = [
|
||||||
|
./bar.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
7
lib/tests/modules/disable-recursive/disable-foo.nix
Normal file
7
lib/tests/modules/disable-recursive/disable-foo.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
disabledModules = [
|
||||||
|
./foo.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
5
lib/tests/modules/disable-recursive/foo.nix
Normal file
5
lib/tests/modules/disable-recursive/foo.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../declare-enable.nix
|
||||||
|
];
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user