treewide: run treefmt with mdcr/nixfmt
This commit is contained in:
parent
6c47e7d5da
commit
62fe016519
@ -567,7 +567,12 @@ If you have any problems with formatting, please ping the [formatting team](http
|
|||||||
That is, write
|
That is, write
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ stdenv, fetchurl, perl }: <...>
|
{
|
||||||
|
stdenv,
|
||||||
|
fetchurl,
|
||||||
|
perl,
|
||||||
|
}:
|
||||||
|
<...>
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
@ -579,17 +584,25 @@ If you have any problems with formatting, please ping the [formatting team](http
|
|||||||
or
|
or
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ stdenv, fetchurl, perl, ... }: <...>
|
{
|
||||||
|
stdenv,
|
||||||
|
fetchurl,
|
||||||
|
perl,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
<...>
|
||||||
```
|
```
|
||||||
|
|
||||||
For functions that are truly generic in the number of arguments, but have some required arguments, you should write them using an `@`-pattern:
|
For functions that are truly generic in the number of arguments, but have some required arguments, you should write them using an `@`-pattern:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ stdenv, doCoverageAnalysis ? false, ... } @ args:
|
{
|
||||||
|
stdenv,
|
||||||
|
doCoverageAnalysis ? false,
|
||||||
|
...
|
||||||
|
}@args:
|
||||||
|
|
||||||
stdenv.mkDerivation (args // {
|
stdenv.mkDerivation (args // { foo = if doCoverageAnalysis then "bla" else ""; })
|
||||||
foo = if doCoverageAnalysis then "bla" else "";
|
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
@ -597,42 +610,37 @@ If you have any problems with formatting, please ping the [formatting team](http
|
|||||||
```nix
|
```nix
|
||||||
args:
|
args:
|
||||||
|
|
||||||
args.stdenv.mkDerivation (args // {
|
args.stdenv.mkDerivation (
|
||||||
foo = if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "";
|
args
|
||||||
})
|
// {
|
||||||
|
foo = if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "";
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
- Unnecessary string conversions should be avoided.
|
- Unnecessary string conversions should be avoided.
|
||||||
Do
|
Do
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ rev = version; }
|
||||||
rev = version;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ rev = "${version}"; }
|
||||||
rev = "${version}";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.
|
- Building lists conditionally _should_ be done with `lib.optional(s)` instead of using `if cond then [ ... ] else null` or `if cond then [ ... ] else [ ]`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ buildInputs = lib.optional stdenv.hostPlatform.isDarwin iconv; }
|
||||||
buildInputs = lib.optional stdenv.hostPlatform.isDarwin iconv;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ buildInputs = if stdenv.hostPlatform.isDarwin then [ iconv ] else null; }
|
||||||
buildInputs = if stdenv.hostPlatform.isDarwin then [ iconv ] else null;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
|
As an exception, an explicit conditional expression with null can be used when fixing a important bug without triggering a mass rebuild.
|
||||||
|
@ -60,10 +60,7 @@ lib.extendMkDerivation {
|
|||||||
}@args:
|
}@args:
|
||||||
{
|
{
|
||||||
# Arguments to pass
|
# Arguments to pass
|
||||||
inherit
|
inherit preferLocalBuild allowSubstitute;
|
||||||
preferLocalBuild
|
|
||||||
allowSubstitute
|
|
||||||
;
|
|
||||||
# Some expressions involving specialArg
|
# Some expressions involving specialArg
|
||||||
greeting = if specialArg "hi" then "hi" else "hello";
|
greeting = if specialArg "hi" then "hi" else "hello";
|
||||||
};
|
};
|
||||||
|
@ -37,9 +37,7 @@ let
|
|||||||
hash = "sha256-he1uGC1M/nFcKpMM9JKY4oeexJcnzV0ZRxhTjtJz6xw=";
|
hash = "sha256-he1uGC1M/nFcKpMM9JKY4oeexJcnzV0ZRxhTjtJz6xw=";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
appimageTools.wrapType2 {
|
appimageTools.wrapType2 { inherit pname version src; }
|
||||||
inherit pname version src;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
@ -104,9 +102,7 @@ let
|
|||||||
hash = "sha256-/hMPvYdnVB1XjKgU2v47HnVvW4+uC3rhRjbucqin4iI=";
|
hash = "sha256-/hMPvYdnVB1XjKgU2v47HnVvW4+uC3rhRjbucqin4iI=";
|
||||||
};
|
};
|
||||||
|
|
||||||
appimageContents = appimageTools.extract {
|
appimageContents = appimageTools.extract { inherit pname version src; };
|
||||||
inherit pname version src;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
appimageTools.wrapType2 {
|
appimageTools.wrapType2 {
|
||||||
inherit pname version src;
|
inherit pname version src;
|
||||||
|
@ -33,10 +33,7 @@ You may also want to consider [dockerTools](#sec-pkgs-dockerTools) for your cont
|
|||||||
The following derivation will construct a flat-file binary cache containing the closure of `hello`.
|
The following derivation will construct a flat-file binary cache containing the closure of `hello`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ mkBinaryCache, hello }:
|
{ mkBinaryCache, hello }: mkBinaryCache { rootPaths = [ hello ]; }
|
||||||
mkBinaryCache {
|
|
||||||
rootPaths = [ hello ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Build the cache on a machine.
|
Build the cache on a machine.
|
||||||
|
@ -1577,9 +1577,7 @@ This example uses [](#ex-dockerTools-streamNixShellImage-hello) as a starting po
|
|||||||
dockerTools.streamNixShellImage {
|
dockerTools.streamNixShellImage {
|
||||||
tag = "latest";
|
tag = "latest";
|
||||||
drv = hello.overrideAttrs (old: {
|
drv = hello.overrideAttrs (old: {
|
||||||
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
|
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ cowsay ];
|
||||||
cowsay
|
|
||||||
];
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -82,9 +82,7 @@ This example uses `ociTools.buildContainer` to create a simple container that ru
|
|||||||
bash,
|
bash,
|
||||||
}:
|
}:
|
||||||
ociTools.buildContainer {
|
ociTools.buildContainer {
|
||||||
args = [
|
args = [ (lib.getExe bash) ];
|
||||||
(lib.getExe bash)
|
|
||||||
];
|
|
||||||
|
|
||||||
readonly = false;
|
readonly = false;
|
||||||
}
|
}
|
||||||
|
@ -7,20 +7,18 @@ For hermeticity, Nix derivations do not allow any state to be carried over betwe
|
|||||||
However, we can tell Nix explicitly what the previous build state was, by representing that previous state as a derivation output. This allows the passed build state to be used for an incremental build.
|
However, we can tell Nix explicitly what the previous build state was, by representing that previous state as a derivation output. This allows the passed build state to be used for an incremental build.
|
||||||
|
|
||||||
To change a normal derivation to a checkpoint based build, these steps must be taken:
|
To change a normal derivation to a checkpoint based build, these steps must be taken:
|
||||||
- apply `prepareCheckpointBuild` on the desired derivation, e.g.
|
```nix
|
||||||
```nix
|
{
|
||||||
{
|
checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);
|
||||||
checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);
|
}
|
||||||
}
|
```
|
||||||
```
|
```nix
|
||||||
- change something you want in the sources of the package, e.g. use a source override:
|
{
|
||||||
```nix
|
changedVBox = pkgs.virtualbox.overrideAttrs (old: {
|
||||||
{
|
src = path/to/vbox/sources;
|
||||||
changedVBox = pkgs.virtualbox.overrideAttrs (old: {
|
});
|
||||||
src = path/to/vbox/sources;
|
}
|
||||||
});
|
```
|
||||||
}
|
|
||||||
```
|
|
||||||
- use `mkCheckpointBuild changedVBox checkpointArtifacts`
|
- use `mkCheckpointBuild changedVBox checkpointArtifacts`
|
||||||
- enjoy shorter build times
|
- enjoy shorter build times
|
||||||
|
|
||||||
@ -30,10 +28,7 @@ To change a normal derivation to a checkpoint based build, these steps must be t
|
|||||||
pkgs ? import <nixpkgs> { },
|
pkgs ? import <nixpkgs> { },
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (pkgs.checkpointBuildTools)
|
inherit (pkgs.checkpointBuildTools) prepareCheckpointBuild mkCheckpointBuild;
|
||||||
prepareCheckpointBuild
|
|
||||||
mkCheckpointBuild
|
|
||||||
;
|
|
||||||
helloCheckpoint = prepareCheckpointBuild pkgs.hello;
|
helloCheckpoint = prepareCheckpointBuild pkgs.hello;
|
||||||
changedHello = pkgs.hello.overrideAttrs (_: {
|
changedHello = pkgs.hello.overrideAttrs (_: {
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
@ -15,9 +15,7 @@ If the `moduleNames` argument is omitted, `hasPkgConfigModules` will use `meta.p
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
passthru.tests.pkg-config = testers.hasPkgConfigModules {
|
passthru.tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
|
||||||
package = finalAttrs.finalPackage;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta.pkgConfigModules = [ "libfoo" ];
|
meta.pkgConfigModules = [ "libfoo" ];
|
||||||
}
|
}
|
||||||
@ -74,9 +72,7 @@ If you have a static site that can be built with Nix, you can use `lycheeLinkChe
|
|||||||
# Check hyperlinks in the `nix` documentation
|
# Check hyperlinks in the `nix` documentation
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
testers.lycheeLinkCheck {
|
testers.lycheeLinkCheck { site = nix.doc + "/share/doc/nix/manual"; }
|
||||||
site = nix.doc + "/share/doc/nix/manual";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
@ -269,9 +265,7 @@ The default argument to the command is `--version`, and the version to be checke
|
|||||||
This example will run the command `hello --version`, and then check that the version of the `hello` package is in the output of the command.
|
This example will run the command `hello --version`, and then check that the version of the `hello` package is in the output of the command.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ passthru.tests.version = testers.testVersion { package = hello; }; }
|
||||||
passthru.tests.version = testers.testVersion { package = hello; };
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
@ -152,9 +152,7 @@ runCommandWith {
|
|||||||
|
|
||||||
Likewise, `runCommandCC name derivationArgs buildCommand` is equivalent to
|
Likewise, `runCommandCC name derivationArgs buildCommand` is equivalent to
|
||||||
```nix
|
```nix
|
||||||
runCommandWith {
|
runCommandWith { inherit name derivationArgs; } buildCommand
|
||||||
inherit name derivationArgs;
|
|
||||||
} buildCommand
|
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -713,7 +711,10 @@ concatTextFile
|
|||||||
# Writes contents of files to /nix/store/<store path>
|
# Writes contents of files to /nix/store/<store path>
|
||||||
concatText
|
concatText
|
||||||
"my-file"
|
"my-file"
|
||||||
[ file1 file2 ]
|
[
|
||||||
|
file1
|
||||||
|
file2
|
||||||
|
]
|
||||||
|
|
||||||
# Writes contents of files to /nix/store/<store path>
|
# Writes contents of files to /nix/store/<store path>
|
||||||
concatScript
|
concatScript
|
||||||
@ -790,7 +791,7 @@ The result is equivalent to the output of `nix-store -q --requisites`.
|
|||||||
For example,
|
For example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
writeClosure [ (writeScriptBin "hi" ''${hello}/bin/hello'') ]
|
writeClosure [ (writeScriptBin "hi" "${hello}/bin/hello") ]
|
||||||
```
|
```
|
||||||
|
|
||||||
produces an output path `/nix/store/<hash>-runtime-deps` containing
|
produces an output path `/nix/store/<hash>-runtime-deps` containing
|
||||||
@ -816,7 +817,7 @@ This produces the equivalent of `nix-store -q --references`.
|
|||||||
For example,
|
For example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
writeDirectReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
|
writeDirectReferencesToFile (writeScriptBin "hi" "${hello}/bin/hello")
|
||||||
```
|
```
|
||||||
|
|
||||||
produces an output path `/nix/store/<hash>-runtime-references` containing
|
produces an output path `/nix/store/<hash>-runtime-references` containing
|
||||||
|
@ -27,8 +27,8 @@ let
|
|||||||
} ":";
|
} ":";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# the INI file can now be given as plain old nix values
|
||||||
in
|
in
|
||||||
# the INI file can now be given as plain old nix values
|
|
||||||
customToINI {
|
customToINI {
|
||||||
main = {
|
main = {
|
||||||
pushinfo = true;
|
pushinfo = true;
|
||||||
|
@ -15,13 +15,24 @@
|
|||||||
src = nix-gitignore.gitignoreSource [ ] ./source;
|
src = nix-gitignore.gitignoreSource [ ] ./source;
|
||||||
# Simplest version
|
# Simplest version
|
||||||
|
|
||||||
src = nix-gitignore.gitignoreSource "supplemental-ignores\n" ./source;
|
src = nix-gitignore.gitignoreSource ''
|
||||||
|
supplemental-ignores
|
||||||
|
'' ./source;
|
||||||
# This one reads the ./source/.gitignore and concats the auxiliary ignores
|
# This one reads the ./source/.gitignore and concats the auxiliary ignores
|
||||||
|
|
||||||
src = nix-gitignore.gitignoreSourcePure "ignore-this\nignore-that\n" ./source;
|
src = nix-gitignore.gitignoreSourcePure ''
|
||||||
|
ignore-this
|
||||||
|
ignore-that
|
||||||
|
'' ./source;
|
||||||
# Use this string as gitignore, don't read ./source/.gitignore.
|
# Use this string as gitignore, don't read ./source/.gitignore.
|
||||||
|
|
||||||
src = nix-gitignore.gitignoreSourcePure [ "ignore-this\nignore-that\n" ~/.gitignore ] ./source;
|
src = nix-gitignore.gitignoreSourcePure [
|
||||||
|
''
|
||||||
|
ignore-this
|
||||||
|
ignore-that
|
||||||
|
''
|
||||||
|
~/.gitignore
|
||||||
|
] ./source;
|
||||||
# It also accepts a list (of strings and paths) that will be concatenated
|
# It also accepts a list (of strings and paths) that will be concatenated
|
||||||
# once the paths are turned to strings via readFile.
|
# once the paths are turned to strings via readFile.
|
||||||
}
|
}
|
||||||
@ -41,9 +52,7 @@ Those filter functions accept the same arguments the `builtins.filterSource` fun
|
|||||||
If you want to make your own filter from scratch, you may use
|
If you want to make your own filter from scratch, you may use
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root; }
|
||||||
gitignoreFilter = ign: root: filterPattern (gitignoreToPatterns ign) root;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## gitignore files in subdirectories {#sec-pkgs-nix-gitignore-usage-recursive}
|
## gitignore files in subdirectories {#sec-pkgs-nix-gitignore-usage-recursive}
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
This hook makes a build pause instead of stopping when a failure occurs. It prevents Nix from cleaning up the build environment immediately and allows the user to attach to the build environment. Upon a build error, it will print instructions that can be used to enter the environment for debugging. breakpointHook is only available on Linux. To use it, add `breakpointHook` to `nativeBuildInputs` in the package to be inspected.
|
This hook makes a build pause instead of stopping when a failure occurs. It prevents Nix from cleaning up the build environment immediately and allows the user to attach to the build environment. Upon a build error, it will print instructions that can be used to enter the environment for debugging. breakpointHook is only available on Linux. To use it, add `breakpointHook` to `nativeBuildInputs` in the package to be inspected.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ nativeBuildInputs = [ breakpointHook ]; }
|
||||||
nativeBuildInputs = [ breakpointHook ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
When a build failure occurs, an instruction will be printed showing how to attach to the build sandbox.
|
When a build failure occurs, an instruction will be printed showing how to attach to the build sandbox.
|
||||||
|
@ -4,17 +4,12 @@
|
|||||||
This hook starts a Memcached server during `checkPhase`. Example:
|
This hook starts a Memcached server during `checkPhase`. Example:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ stdenv, memcachedTestHook }:
|
||||||
stdenv,
|
|
||||||
memcachedTestHook,
|
|
||||||
}:
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ memcachedTestHook ];
|
||||||
memcachedTestHook
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -45,11 +40,10 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ memcachedTestHook ];
|
||||||
memcachedTestHook
|
|
||||||
];
|
|
||||||
|
|
||||||
preCheck = ''
|
preCheck = ''
|
||||||
memcachedTestPort=1234;
|
memcachedTestPort=1234;
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
@ -38,9 +38,7 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [ patchRcPathFish ];
|
||||||
patchRcPathFish
|
|
||||||
];
|
|
||||||
|
|
||||||
postFixup = ''
|
postFixup = ''
|
||||||
patchRcPathFish $out/bin/this-foo.fish ${
|
patchRcPathFish $out/bin/this-foo.fish ${
|
||||||
|
@ -13,9 +13,7 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ redisTestHook ];
|
||||||
redisTestHook
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -56,9 +54,7 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ redisTestHook ];
|
||||||
redisTestHook
|
|
||||||
];
|
|
||||||
|
|
||||||
preCheck = ''
|
preCheck = ''
|
||||||
redisTestPort=6390;
|
redisTestPort=6390;
|
||||||
|
@ -35,21 +35,17 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
|||||||
hash = "...";
|
hash = "...";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs =
|
nativeBuildInputs = [
|
||||||
[
|
# Pull in our main hook
|
||||||
# Pull in our main hook
|
cargo-tauri.hook
|
||||||
cargo-tauri.hook
|
|
||||||
|
|
||||||
# Setup npm
|
# Setup npm
|
||||||
nodejs
|
nodejs
|
||||||
npmHooks.npmConfigHook
|
npmHooks.npmConfigHook
|
||||||
|
|
||||||
# Make sure we can find our libraries
|
# Make sure we can find our libraries
|
||||||
pkg-config
|
pkg-config
|
||||||
]
|
] ++ lib.optionals stdenv.hostPlatform.isLinux [ wrapGAppsHook4 ];
|
||||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
|
||||||
wrapGAppsHook4
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||||
glib-networking # Most Tauri apps need networking
|
glib-networking # Most Tauri apps need networking
|
||||||
|
@ -16,9 +16,7 @@ The hook runs in `installCheckPhase`, requiring `doInstallCheck` is enabled for
|
|||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeInstallCheckInputs = [
|
nativeInstallCheckInputs = [ udevCheckHook ];
|
||||||
udevCheckHook
|
|
||||||
];
|
|
||||||
doInstallCheck = true;
|
doInstallCheck = true;
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
@ -15,9 +15,7 @@ You use it like this:
|
|||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
nativeInstallCheckInputs = [
|
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||||
versionCheckHook
|
|
||||||
];
|
|
||||||
doInstallCheck = true;
|
doInstallCheck = true;
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
@ -16,9 +16,7 @@ In Nixpkgs, `zig.hook` overrides the default build, check and install phases.
|
|||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
# . . .
|
# . . .
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [ zig.hook ];
|
||||||
zig.hook
|
|
||||||
];
|
|
||||||
|
|
||||||
zigBuildFlags = [ "-Dman-pages=true" ];
|
zigBuildFlags = [ "-Dman-pages=true" ];
|
||||||
|
|
||||||
|
@ -79,9 +79,7 @@ let
|
|||||||
sha256,
|
sha256,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
pkgs.fetchzip {
|
pkgs.fetchzip { inherit name url sha256; };
|
||||||
inherit name url sha256;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -144,9 +144,7 @@ agdaPackages.mkDerivation {
|
|||||||
version = "1.0";
|
version = "1.0";
|
||||||
pname = "my-agda-lib";
|
pname = "my-agda-lib";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
buildInputs = [
|
buildInputs = [ agdaPackages.standard-library ];
|
||||||
agdaPackages.standard-library
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -8,17 +8,13 @@ supporting features.
|
|||||||
Use the `android-studio-full` attribute for a very complete Android SDK, including system images:
|
Use the `android-studio-full` attribute for a very complete Android SDK, including system images:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ buildInputs = [ android-studio-full ]; }
|
||||||
buildInputs = [ android-studio-full ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This is identical to:
|
This is identical to:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ buildInputs = [ androidStudioPackages.stable.full ]; }
|
||||||
buildInputs = [ androidStudioPackages.stable.full ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, you can pass composeAndroidPackages to the `withSdk` passthru:
|
Alternatively, you can pass composeAndroidPackages to the `withSdk` passthru:
|
||||||
@ -26,11 +22,7 @@ Alternatively, you can pass composeAndroidPackages to the `withSdk` passthru:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
(android-studio.withSdk
|
(android-studio.withSdk (androidenv.composeAndroidPackages { includeNDK = true; }).androidsdk)
|
||||||
(androidenv.composeAndroidPackages {
|
|
||||||
includeNDK = true;
|
|
||||||
}).androidsdk
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -58,9 +50,7 @@ let
|
|||||||
"arm64-v8a"
|
"arm64-v8a"
|
||||||
];
|
];
|
||||||
includeNDK = true;
|
includeNDK = true;
|
||||||
includeExtras = [
|
includeExtras = [ "extras;google;auto" ];
|
||||||
"extras;google;auto"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
androidComposition.androidsdk
|
androidComposition.androidsdk
|
||||||
|
@ -65,9 +65,7 @@ let
|
|||||||
overlays = [ ];
|
overlays = [ ];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell { packages = [ pkgs.beamPackages.rebar3 ]; }
|
||||||
packages = [ pkgs.beamPackages.rebar3 ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -324,9 +322,7 @@ with pkgs;
|
|||||||
let
|
let
|
||||||
elixir = beam.packages.erlang_27.elixir_1_18;
|
elixir = beam.packages.erlang_27.elixir_1_18;
|
||||||
in
|
in
|
||||||
mkShell {
|
mkShell { buildInputs = [ elixir ]; }
|
||||||
buildInputs = [ elixir ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using an overlay {#beam-using-overlays}
|
### Using an overlay {#beam-using-overlays}
|
||||||
@ -348,11 +344,7 @@ let
|
|||||||
pkgs = import <nixpkgs> { overlays = [ elixir_1_18_1_overlay ]; };
|
pkgs = import <nixpkgs> { overlays = [ elixir_1_18_1_overlay ]; };
|
||||||
in
|
in
|
||||||
with pkgs;
|
with pkgs;
|
||||||
mkShell {
|
mkShell { buildInputs = [ elixir_1_18 ]; }
|
||||||
buildInputs = [
|
|
||||||
elixir_1_18
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Elixir - Phoenix project {#elixir---phoenix-project}
|
#### Elixir - Phoenix project {#elixir---phoenix-project}
|
||||||
|
@ -77,8 +77,8 @@ let
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
# Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use
|
||||||
|
# the local copy of `srfi-180`.
|
||||||
in
|
in
|
||||||
# Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use
|
|
||||||
# the local copy of `srfi-180`.
|
|
||||||
<...>
|
<...>
|
||||||
```
|
```
|
||||||
|
@ -145,17 +145,13 @@ There are three distinct ways of changing a Coq package by overriding one of its
|
|||||||
For example, assuming you have a special `mathcomp` dependency you want to use, here is how you could override the `mathcomp` dependency:
|
For example, assuming you have a special `mathcomp` dependency you want to use, here is how you could override the `mathcomp` dependency:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
multinomials.override {
|
multinomials.override { mathcomp = my-special-mathcomp; }
|
||||||
mathcomp = my-special-mathcomp;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In Nixpkgs, all Coq derivations take a `version` argument. This can be overridden in order to easily use a different version:
|
In Nixpkgs, all Coq derivations take a `version` argument. This can be overridden in order to easily use a different version:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
coqPackages.multinomials.override {
|
coqPackages.multinomials.override { version = "1.5.1"; }
|
||||||
version = "1.5.1";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Refer to [](#coq-packages-attribute-sets-coqpackages) for all the different formats that you can potentially pass to `version`, as well as the restrictions.
|
Refer to [](#coq-packages-attribute-sets-coqpackages) for all the different formats that you can potentially pass to `version`, as well as the restrictions.
|
||||||
|
@ -146,9 +146,7 @@ These settings ensure that the CUDA setup hooks function as intended.
|
|||||||
When using `callPackage`, you can choose to pass in a different variant, e.g. when a package requires a specific version of CUDA:
|
When using `callPackage`, you can choose to pass in a different variant, e.g. when a package requires a specific version of CUDA:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ mypkg = callPackage { cudaPackages = cudaPackages_12_2; }; }
|
||||||
mypkg = callPackage { cudaPackages = cudaPackages_12_2; };
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
::: {.caution}
|
::: {.caution}
|
||||||
@ -208,9 +206,7 @@ It is possible to run Docker or Podman containers with CUDA support. The recomme
|
|||||||
The NVIDIA Container Toolkit can be enabled in NixOS like follows:
|
The NVIDIA Container Toolkit can be enabled in NixOS like follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.nvidia-container-toolkit.enable = true; }
|
||||||
hardware.nvidia-container-toolkit.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This will automatically enable a service that generates a CDI specification (located at `/var/run/cdi/nvidia-container-toolkit.json`) based on the auto-detected hardware of your machine. You can check this service by running:
|
This will automatically enable a service that generates a CDI specification (located at `/var/run/cdi/nvidia-container-toolkit.json`) based on the auto-detected hardware of your machine. You can check this service by running:
|
||||||
|
@ -94,9 +94,7 @@ let
|
|||||||
hash = "sha256-B4Q3c6IvTLg3Q92qYa8y+i4uTaphtFdjp+Ir3QQjdN0=";
|
hash = "sha256-B4Q3c6IvTLg3Q92qYa8y+i4uTaphtFdjp+Ir3QQjdN0=";
|
||||||
};
|
};
|
||||||
|
|
||||||
dhallOverlay = self: super: {
|
dhallOverlay = self: super: { true = self.callPackage ./true.nix { }; };
|
||||||
true = self.callPackage ./true.nix { };
|
|
||||||
};
|
|
||||||
|
|
||||||
overlay = self: super: {
|
overlay = self: super: {
|
||||||
dhallPackages = super.dhallPackages.override (old: {
|
dhallPackages = super.dhallPackages.override (old: {
|
||||||
|
@ -10,9 +10,7 @@ with import <nixpkgs> { };
|
|||||||
|
|
||||||
mkShell {
|
mkShell {
|
||||||
name = "dotnet-env";
|
name = "dotnet-env";
|
||||||
packages = [
|
packages = [ dotnet-sdk ];
|
||||||
dotnet-sdk
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -161,7 +159,9 @@ buildDotnetModule rec {
|
|||||||
projectFile = "src/project.sln";
|
projectFile = "src/project.sln";
|
||||||
nugetDeps = ./deps.json; # see "Generating and updating NuGet dependencies" section for details
|
nugetDeps = ./deps.json; # see "Generating and updating NuGet dependencies" section for details
|
||||||
|
|
||||||
buildInputs = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
|
buildInputs = [
|
||||||
|
referencedProject
|
||||||
|
]; # `referencedProject` must contain `nupkg` in the folder structure.
|
||||||
|
|
||||||
dotnet-sdk = dotnetCorePackages.sdk_8_0;
|
dotnet-sdk = dotnetCorePackages.sdk_8_0;
|
||||||
dotnet-runtime = dotnetCorePackages.runtime_8_0;
|
dotnet-runtime = dotnetCorePackages.runtime_8_0;
|
||||||
|
@ -38,78 +38,75 @@ One advantage is that when `pkgs.zlib` is updated, it will automatically update
|
|||||||
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
(pkgs.zlib.override {
|
(pkgs.zlib.override { stdenv = pkgs.emscriptenStdenv; }).overrideAttrs (old: {
|
||||||
stdenv = pkgs.emscriptenStdenv;
|
buildInputs = old.buildInputs ++ [ pkg-config ];
|
||||||
}).overrideAttrs
|
# we need to reset this setting!
|
||||||
(old: {
|
env = (old.env or { }) // {
|
||||||
buildInputs = old.buildInputs ++ [ pkg-config ];
|
NIX_CFLAGS_COMPILE = "";
|
||||||
# we need to reset this setting!
|
};
|
||||||
env = (old.env or { }) // {
|
|
||||||
NIX_CFLAGS_COMPILE = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
# FIXME: Some tests require writing at $HOME
|
# FIXME: Some tests require writing at $HOME
|
||||||
HOME=$TMPDIR
|
HOME=$TMPDIR
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
|
|
||||||
#export EMCC_DEBUG=2
|
#export EMCC_DEBUG=2
|
||||||
emconfigure ./configure --prefix=$out --shared
|
emconfigure ./configure --prefix=$out --shared
|
||||||
|
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
outputs = [ "out" ];
|
outputs = [ "out" ];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
emmake make
|
emmake make
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
emmake make install
|
emmake make install
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
|
|
||||||
echo "================= testing zlib using node ================="
|
echo "================= testing zlib using node ================="
|
||||||
|
|
||||||
echo "Compiling a custom test"
|
echo "Compiling a custom test"
|
||||||
set -x
|
set -x
|
||||||
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \
|
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \
|
||||||
libz.so.${old.version} -I . -o example.js
|
libz.so.${old.version} -I . -o example.js
|
||||||
|
|
||||||
echo "Using node to execute the test"
|
echo "Using node to execute the test"
|
||||||
${pkgs.nodejs}/bin/node ./example.js
|
${pkgs.nodejs}/bin/node ./example.js
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "test failed for some reason"
|
echo "test failed for some reason"
|
||||||
exit 1;
|
exit 1;
|
||||||
else
|
else
|
||||||
echo "it seems to work! very good."
|
echo "it seems to work! very good."
|
||||||
fi
|
fi
|
||||||
echo "================= /testing zlib using node ================="
|
echo "================= /testing zlib using node ================="
|
||||||
|
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
|
postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
|
||||||
substituteInPlace configure \
|
substituteInPlace configure \
|
||||||
--replace-fail '/usr/bin/libtool' 'ar' \
|
--replace-fail '/usr/bin/libtool' 'ar' \
|
||||||
--replace-fail 'AR="libtool"' 'AR="ar"' \
|
--replace-fail 'AR="libtool"' 'AR="ar"' \
|
||||||
--replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"'
|
--replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"'
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
:::{.example #usage-2-pkgs.buildemscriptenpackage}
|
:::{.example #usage-2-pkgs.buildemscriptenpackage}
|
||||||
|
@ -81,10 +81,7 @@ The function understands several forms of source directory trees:
|
|||||||
|
|
||||||
For instance, packaging the Bresenham algorithm for line interpolation looks like this, see `pkgs/development/compilers/factor-lang/vocabs/bresenham` for the complete file:
|
For instance, packaging the Bresenham algorithm for line interpolation looks like this, see `pkgs/development/compilers/factor-lang/vocabs/bresenham` for the complete file:
|
||||||
```nix
|
```nix
|
||||||
{
|
{ factorPackages, fetchFromGitHub }:
|
||||||
factorPackages,
|
|
||||||
fetchFromGitHub,
|
|
||||||
}:
|
|
||||||
|
|
||||||
factorPackages.buildFactorVocab {
|
factorPackages.buildFactorVocab {
|
||||||
pname = "bresenham";
|
pname = "bresenham";
|
||||||
|
@ -48,9 +48,7 @@ In the rare case you need to use icons from dependencies (e.g. when an app force
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
buildInputs = [
|
buildInputs = [ pantheon.elementary-icon-theme ];
|
||||||
pantheon.elementary-icon-theme
|
|
||||||
];
|
|
||||||
preFixup = ''
|
preFixup = ''
|
||||||
gappsWrapperArgs+=(
|
gappsWrapperArgs+=(
|
||||||
# The icon theme is hardcoded.
|
# The icon theme is hardcoded.
|
||||||
|
@ -147,9 +147,7 @@ A string list of [Go build tags (also called build constraints)](https://pkg.go.
|
|||||||
Tags can also be set conditionally:
|
Tags can also be set conditionally:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ]; }
|
||||||
tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### `deleteVendor` {#var-go-deleteVendor}
|
### `deleteVendor` {#var-go-deleteVendor}
|
||||||
@ -283,9 +281,7 @@ For example, only a selection of tests could be run with:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
# -run and -skip accept regular expressions
|
# -run and -skip accept regular expressions
|
||||||
checkFlags = [
|
checkFlags = [ "-run=^Test(Simple|Fast)$" ];
|
||||||
"-run=^Test(Simple|Fast)$"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -783,9 +783,7 @@ need to build `nix-tree` with a more recent version of `brick` than the default
|
|||||||
one provided by `haskellPackages`:
|
one provided by `haskellPackages`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
haskellPackages.nix-tree.override {
|
haskellPackages.nix-tree.override { brick = haskellPackages.brick_0_67; }
|
||||||
brick = haskellPackages.brick_0_67;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- TODO(@sternenseemann): This belongs in the next section
|
<!-- TODO(@sternenseemann): This belongs in the next section
|
||||||
@ -841,8 +839,8 @@ let
|
|||||||
install -Dm644 man/${drv.pname}.1 -t "$out/share/man/man1"
|
install -Dm644 man/${drv.pname}.1 -t "$out/share/man/man1"
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
installManPage haskellPackages.pnbackup
|
installManPage haskellPackages.pnbackup
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1310,8 +1308,8 @@ let
|
|||||||
ghcName = "ghc92";
|
ghcName = "ghc92";
|
||||||
# Desired new setting
|
# Desired new setting
|
||||||
enableProfiling = true;
|
enableProfiling = true;
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
[
|
[
|
||||||
# The first overlay modifies the GHC derivation so that it does or does not
|
# The first overlay modifies the GHC derivation so that it does or does not
|
||||||
# build profiling versions of the core libraries bundled with it. It is
|
# build profiling versions of the core libraries bundled with it. It is
|
||||||
@ -1322,8 +1320,8 @@ in
|
|||||||
final: prev:
|
final: prev:
|
||||||
let
|
let
|
||||||
inherit (final) lib;
|
inherit (final) lib;
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
{
|
{
|
||||||
haskell = prev.haskell // {
|
haskell = prev.haskell // {
|
||||||
compiler = prev.haskell.compiler // {
|
compiler = prev.haskell.compiler // {
|
||||||
@ -1341,8 +1339,8 @@ in
|
|||||||
let
|
let
|
||||||
inherit (final) lib;
|
inherit (final) lib;
|
||||||
haskellLib = final.haskell.lib.compose;
|
haskellLib = final.haskell.lib.compose;
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
{
|
{
|
||||||
haskell = prev.haskell // {
|
haskell = prev.haskell // {
|
||||||
packages = prev.haskell.packages // {
|
packages = prev.haskell.packages // {
|
||||||
|
@ -31,9 +31,7 @@ Xcode.
|
|||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> { };
|
pkgs = import <nixpkgs> { };
|
||||||
|
|
||||||
xcodeenv = import ./xcodeenv {
|
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
|
||||||
inherit (pkgs) stdenv;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
xcodeenv.composeXcodeWrapper {
|
xcodeenv.composeXcodeWrapper {
|
||||||
version = "9.2";
|
version = "9.2";
|
||||||
@ -65,9 +63,7 @@ executing the `xcodeenv.buildApp {}` function:
|
|||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> { };
|
pkgs = import <nixpkgs> { };
|
||||||
|
|
||||||
xcodeenv = import ./xcodeenv {
|
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
|
||||||
inherit (pkgs) stdenv;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
xcodeenv.buildApp {
|
xcodeenv.buildApp {
|
||||||
name = "MyApp";
|
name = "MyApp";
|
||||||
@ -161,9 +157,7 @@ instances:
|
|||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> { };
|
pkgs = import <nixpkgs> { };
|
||||||
|
|
||||||
xcodeenv = import ./xcodeenv {
|
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
|
||||||
inherit (pkgs) stdenv;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
xcode.simulateApp {
|
xcode.simulateApp {
|
||||||
name = "simulate";
|
name = "simulate";
|
||||||
@ -195,9 +189,7 @@ app in the requested simulator instance:
|
|||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> { };
|
pkgs = import <nixpkgs> { };
|
||||||
|
|
||||||
xcodeenv = import ./xcodeenv {
|
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
|
||||||
inherit (pkgs) stdenv;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
xcode.simulateApp {
|
xcode.simulateApp {
|
||||||
name = "simulate";
|
name = "simulate";
|
||||||
|
@ -108,11 +108,7 @@ You can also specify what JDK your JRE should be based on, for example
|
|||||||
selecting a 'headless' build to avoid including a link to GTK+:
|
selecting a 'headless' build to avoid including a link to GTK+:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ my_jre = pkgs.jre_minimal.override { jdk = jdk11_headless; }; }
|
||||||
my_jre = pkgs.jre_minimal.override {
|
|
||||||
jdk = jdk11_headless;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note all JDKs passthru `home`, so if your application requires
|
Note all JDKs passthru `home`, so if your application requires
|
||||||
|
@ -303,9 +303,7 @@ buildNpmPackage {
|
|||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
npmDeps = importNpmLock {
|
npmDeps = importNpmLock { npmRoot = ./.; };
|
||||||
npmRoot = ./.;
|
|
||||||
};
|
|
||||||
|
|
||||||
npmConfigHook = importNpmLock.npmConfigHook;
|
npmConfigHook = importNpmLock.npmConfigHook;
|
||||||
}
|
}
|
||||||
@ -456,9 +454,7 @@ In case you are patching `package.json` or `pnpm-lock.yaml`, make sure to pass `
|
|||||||
`pnpm.configHook` supports adding additional `pnpm install` flags via `pnpmInstallFlags` which can be set to a Nix string array:
|
`pnpm.configHook` supports adding additional `pnpm install` flags via `pnpmInstallFlags` which can be set to a Nix string array:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ pnpm }:
|
||||||
pnpm,
|
|
||||||
}:
|
|
||||||
|
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "foo";
|
pname = "foo";
|
||||||
@ -470,9 +466,7 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
|
|
||||||
pnpmInstallFlags = [ "--shamefully-hoist" ];
|
pnpmInstallFlags = [ "--shamefully-hoist" ];
|
||||||
|
|
||||||
pnpmDeps = pnpm.fetchDeps {
|
pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) pnpmInstallFlags; };
|
||||||
inherit (finalAttrs) pnpmInstallFlags;
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -699,9 +693,7 @@ It's important to use the `--offline` flag. For example if you script is `"build
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [ writableTmpDirAsHomeHook ];
|
||||||
writableTmpDirAsHomeHook
|
|
||||||
];
|
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
@ -716,9 +708,7 @@ It's important to use the `--offline` flag. For example if you script is `"build
|
|||||||
The `distPhase` is packing the package's dependencies in a tarball using `yarn pack`. You can disable it using:
|
The `distPhase` is packing the package's dependencies in a tarball using `yarn pack`. You can disable it using:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ doDist = false; }
|
||||||
doDist = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The configure phase can sometimes fail because it makes many assumptions which may not always apply. One common override is:
|
The configure phase can sometimes fail because it makes many assumptions which may not always apply. One common override is:
|
||||||
@ -837,8 +827,8 @@ It's recommended to ensure you're explicitly pinning the major version used, for
|
|||||||
|
|
||||||
let
|
let
|
||||||
yarn-berry = yarn-berry_4;
|
yarn-berry = yarn-berry_4;
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "foo";
|
pname = "foo";
|
||||||
version = "0-unstable-1980-01-01";
|
version = "0-unstable-1980-01-01";
|
||||||
@ -892,8 +882,8 @@ To compensate for this, the `yarn-berry-fetcher missing-hashes` subcommand can b
|
|||||||
|
|
||||||
let
|
let
|
||||||
yarn-berry = yarn-berry_4;
|
yarn-berry = yarn-berry_4;
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "foo";
|
pname = "foo";
|
||||||
version = "0-unstable-1980-01-01";
|
version = "0-unstable-1980-01-01";
|
||||||
|
@ -49,9 +49,7 @@ Also one can create a `pkgs.mkShell` environment in `shell.nix`/`flake.nix`:
|
|||||||
let
|
let
|
||||||
sbcl' = sbcl.withPackages (ps: [ ps.alexandria ]);
|
sbcl' = sbcl.withPackages (ps: [ ps.alexandria ]);
|
||||||
in
|
in
|
||||||
mkShell {
|
mkShell { packages = [ sbcl' ]; }
|
||||||
packages = [ sbcl' ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Such a Lisp can be now used e.g. to compile your sources:
|
Such a Lisp can be now used e.g. to compile your sources:
|
||||||
@ -192,11 +190,7 @@ let
|
|||||||
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
|
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
sbcl' = sbcl.withOverrides (
|
sbcl' = sbcl.withOverrides (self: super: { inherit alexandria; });
|
||||||
self: super: {
|
|
||||||
inherit alexandria;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
sbcl'.pkgs.alexandria
|
sbcl'.pkgs.alexandria
|
||||||
```
|
```
|
||||||
|
@ -117,9 +117,7 @@ top-level while luarocks installs them in various subfolders by default.
|
|||||||
For instance:
|
For instance:
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
rtp-nvim = neovimUtils.buildNeovimPlugin {
|
rtp-nvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.rtp-nvim; };
|
||||||
luaAttr = luaPackages.rtp-nvim;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
To update these packages, you should use the lua updater rather than vim's.
|
To update these packages, you should use the lua updater rather than vim's.
|
||||||
|
@ -26,9 +26,7 @@ buildNimPackage (finalAttrs: {
|
|||||||
|
|
||||||
lockFile = ./lock.json;
|
lockFile = ./lock.json;
|
||||||
|
|
||||||
nimFlags = [
|
nimFlags = [ "-d:NimblePkgVersion=${finalAttrs.version}" ];
|
||||||
"-d:NimblePkgVersion=${finalAttrs.version}"
|
|
||||||
];
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -44,9 +44,7 @@ This will also work in a `shell.nix` file.
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [ (octave.withPackages (opkgs: with opkgs; [ symbolic ])) ];
|
||||||
(octave.withPackages (opkgs: with opkgs; [ symbolic ]))
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -267,13 +267,7 @@ php.buildComposerProject2 (finalAttrs: {
|
|||||||
|
|
||||||
# PHP version containing the `ast` extension enabled
|
# PHP version containing the `ast` extension enabled
|
||||||
php = php.buildEnv {
|
php = php.buildEnv {
|
||||||
extensions = (
|
extensions = ({ enabled, all }: enabled ++ (with all; [ ast ]));
|
||||||
{ enabled, all }:
|
|
||||||
enabled
|
|
||||||
++ (with all; [
|
|
||||||
ast
|
|
||||||
])
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# The composer vendor hash
|
# The composer vendor hash
|
||||||
|
@ -126,9 +126,7 @@ buildPythonPackage rec {
|
|||||||
pluggy
|
pluggy
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ hypothesis ];
|
||||||
hypothesis
|
|
||||||
];
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
|
changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
|
||||||
@ -271,16 +269,8 @@ be used through out all of the Python package set:
|
|||||||
python3MyBlas = pkgs.python3.override {
|
python3MyBlas = pkgs.python3.override {
|
||||||
packageOverrides = self: super: {
|
packageOverrides = self: super: {
|
||||||
# We need toPythonModule for the package set to evaluate this
|
# We need toPythonModule for the package set to evaluate this
|
||||||
blas = super.toPythonModule (
|
blas = super.toPythonModule (super.pkgs.blas.override { blasProvider = super.pkgs.mkl; });
|
||||||
super.pkgs.blas.override {
|
lapack = super.toPythonModule (super.pkgs.lapack.override { lapackProvider = super.pkgs.mkl; });
|
||||||
blasProvider = super.pkgs.mkl;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
lapack = super.toPythonModule (
|
|
||||||
super.pkgs.lapack.override {
|
|
||||||
lapackProvider = super.pkgs.mkl;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -323,9 +313,7 @@ python3Packages.buildPythonApplication rec {
|
|||||||
hash = "sha256-Pe229rT0aHwA98s+nTHQMEFKZPo/yw6sot8MivFDvAw=";
|
hash = "sha256-Pe229rT0aHwA98s+nTHQMEFKZPo/yw6sot8MivFDvAw=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = with python3Packages; [
|
build-system = with python3Packages; [ setuptools ];
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
dependencies = with python3Packages; [
|
dependencies = with python3Packages; [
|
||||||
tornado
|
tornado
|
||||||
@ -357,9 +345,7 @@ the attribute in `python-packages.nix`, and the `toPythonApplication` shall be
|
|||||||
applied to the reference:
|
applied to the reference:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ python3Packages }:
|
||||||
python3Packages,
|
|
||||||
}:
|
|
||||||
|
|
||||||
python3Packages.toPythonApplication python3Packages.youtube-dl
|
python3Packages.toPythonApplication python3Packages.youtube-dl
|
||||||
```
|
```
|
||||||
@ -395,9 +381,7 @@ mkPythonMetaPackage {
|
|||||||
pname = "psycopg2-binary";
|
pname = "psycopg2-binary";
|
||||||
inherit (psycopg2) optional-dependencies version;
|
inherit (psycopg2) optional-dependencies version;
|
||||||
dependencies = [ psycopg2 ];
|
dependencies = [ psycopg2 ];
|
||||||
meta = {
|
meta = { inherit (psycopg2.meta) description homepage; };
|
||||||
inherit (psycopg2.meta) description homepage;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -443,9 +427,7 @@ let
|
|||||||
pythonEnv = myPython.withPackages (ps: [ ps.my-editable ]);
|
pythonEnv = myPython.withPackages (ps: [ ps.my-editable ]);
|
||||||
|
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell { packages = [ pythonEnv ]; }
|
||||||
packages = [ pythonEnv ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `python.buildEnv` function {#python.buildenv-function}
|
#### `python.buildEnv` function {#python.buildenv-function}
|
||||||
@ -942,9 +924,7 @@ buildPythonPackage rec {
|
|||||||
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [ setuptools ];
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
# has no tests
|
# has no tests
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
@ -1001,9 +981,7 @@ with import <nixpkgs> { };
|
|||||||
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [ python313.pkgs.setuptools ];
|
||||||
python313.pkgs.setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
# has no tests
|
# has no tests
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
@ -1080,9 +1058,7 @@ buildPythonPackage rec {
|
|||||||
hash = "sha256-FLLvdm1MllKrgTGC6Gb0k0deZeVYvtCCLji/B7uhong=";
|
hash = "sha256-FLLvdm1MllKrgTGC6Gb0k0deZeVYvtCCLji/B7uhong=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [ setuptools ];
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
multipledispatch
|
multipledispatch
|
||||||
@ -1090,9 +1066,7 @@ buildPythonPackage rec {
|
|||||||
python-dateutil
|
python-dateutil
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ pytestCheckHook ];
|
||||||
pytestCheckHook
|
|
||||||
];
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
changelog = "https://github.com/blaze/datashape/releases/tag/${version}";
|
changelog = "https://github.com/blaze/datashape/releases/tag/${version}";
|
||||||
@ -1133,9 +1107,7 @@ buildPythonPackage rec {
|
|||||||
hash = "sha256-s9NiusRxFydHzaNRMjjxFcvWxfi45jGb9ql6eJJyQJk=";
|
hash = "sha256-s9NiusRxFydHzaNRMjjxFcvWxfi45jGb9ql6eJJyQJk=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [ setuptools ];
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
libxml2
|
libxml2
|
||||||
@ -1197,9 +1169,7 @@ buildPythonPackage rec {
|
|||||||
hash = "sha256-9ru2r6kwhUCaskiFoaPNuJCfCVoUL01J40byvRt4kHQ=";
|
hash = "sha256-9ru2r6kwhUCaskiFoaPNuJCfCVoUL01J40byvRt4kHQ=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [ setuptools ];
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
fftw
|
fftw
|
||||||
@ -1307,11 +1277,7 @@ To use `pytestCheckHook`, add it to `nativeCheckInputs`.
|
|||||||
Adding `pytest` is not required, since it is included with `pytestCheckHook`.
|
Adding `pytest` is not required, since it is included with `pytestCheckHook`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ nativeCheckInputs = [ pytestCheckHook ]; }
|
||||||
nativeCheckInputs = [
|
|
||||||
pytestCheckHook
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`pytestCheckHook` recognizes the following attributes:
|
`pytestCheckHook` recognizes the following attributes:
|
||||||
@ -1340,9 +1306,7 @@ The following example demonstrates usage of various `pytestCheckHook` attributes
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ pytestCheckHook ];
|
||||||
pytestCheckHook
|
|
||||||
];
|
|
||||||
|
|
||||||
# Allow running the following test paths and test objects.
|
# Allow running the following test paths and test objects.
|
||||||
enabledTestPaths = [
|
enabledTestPaths = [
|
||||||
@ -1402,9 +1366,7 @@ by disabling tests that match both `"Foo"` **and** `"bar"`:
|
|||||||
{
|
{
|
||||||
__structuredAttrs = true;
|
__structuredAttrs = true;
|
||||||
|
|
||||||
disabledTests = [
|
disabledTests = [ "Foo and bar" ];
|
||||||
"Foo and bar"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1492,9 +1454,7 @@ we can do:
|
|||||||
"pkg1"
|
"pkg1"
|
||||||
"pkg3"
|
"pkg3"
|
||||||
];
|
];
|
||||||
pythonRemoveDeps = [
|
pythonRemoveDeps = [ "pkg2" ];
|
||||||
"pkg2"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1509,9 +1469,7 @@ Another option is to pass `true`, that will relax/remove all dependencies, for
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ pythonRelaxDeps = true; }
|
||||||
pythonRelaxDeps = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
which would result in the following `requirements.txt` file:
|
which would result in the following `requirements.txt` file:
|
||||||
@ -1547,9 +1505,7 @@ automatically add `pythonRelaxDepsHook` if either `pythonRelaxDeps` or
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [ unittestCheckHook ];
|
||||||
unittestCheckHook
|
|
||||||
];
|
|
||||||
|
|
||||||
unittestFlags = [
|
unittestFlags = [
|
||||||
"-s"
|
"-s"
|
||||||
@ -1575,9 +1531,7 @@ render them using the default `html` style.
|
|||||||
"doc"
|
"doc"
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [ sphinxHook ];
|
||||||
sphinxHook
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1652,9 +1606,7 @@ buildPythonPackage rec {
|
|||||||
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
|
||||||
};
|
};
|
||||||
|
|
||||||
build-system = [
|
build-system = [ setuptools ];
|
||||||
setuptools
|
|
||||||
];
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
|
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
|
||||||
@ -1717,14 +1669,10 @@ with import <nixpkgs> { };
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.python310.override {
|
pkgs.python310.override { inherit packageOverrides; };
|
||||||
inherit packageOverrides;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
in
|
||||||
python.withPackages (ps: [
|
python.withPackages (ps: [ ps.pandas ])
|
||||||
ps.pandas
|
|
||||||
])
|
|
||||||
).env
|
).env
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1743,16 +1691,9 @@ with import <nixpkgs> { };
|
|||||||
|
|
||||||
(
|
(
|
||||||
let
|
let
|
||||||
packageOverrides = self: super: {
|
packageOverrides = self: super: { scipy = super.scipy_0_17; };
|
||||||
scipy = super.scipy_0_17;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
(pkgs.python310.override {
|
(pkgs.python310.override { inherit packageOverrides; }).withPackages (ps: [ ps.blaze ])
|
||||||
inherit packageOverrides;
|
|
||||||
}).withPackages
|
|
||||||
(ps: [
|
|
||||||
ps.blaze
|
|
||||||
])
|
|
||||||
).env
|
).env
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -2000,11 +1941,7 @@ this snippet:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
myPythonPackages = python3Packages.override {
|
myPythonPackages = python3Packages.override { overrides = self: super: { twisted = <...>; }; };
|
||||||
overrides = self: super: {
|
|
||||||
twisted = <...>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ Add entries to `qtWrapperArgs` are to modify the wrappers created by
|
|||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
# ...
|
# ...
|
||||||
nativeBuildInputs = [ qt6.wrapQtAppsHook ];
|
nativeBuildInputs = [ qt6.wrapQtAppsHook ];
|
||||||
qtWrapperArgs = [ ''--prefix PATH : /path/to/bin'' ];
|
qtWrapperArgs = [ "--prefix PATH : /path/to/bin" ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -172,7 +172,9 @@ let
|
|||||||
myRuby = pkgs.ruby.override {
|
myRuby = pkgs.ruby.override {
|
||||||
defaultGemConfig = pkgs.defaultGemConfig // {
|
defaultGemConfig = pkgs.defaultGemConfig // {
|
||||||
pg = attrs: {
|
pg = attrs: {
|
||||||
buildFlags = [ "--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config" ];
|
buildFlags = [
|
||||||
|
"--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -193,7 +195,9 @@ let
|
|||||||
gemdir = ./.;
|
gemdir = ./.;
|
||||||
gemConfig = pkgs.defaultGemConfig // {
|
gemConfig = pkgs.defaultGemConfig // {
|
||||||
pg = attrs: {
|
pg = attrs: {
|
||||||
buildFlags = [ "--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config" ];
|
buildFlags = [
|
||||||
|
"--with-pg-config=${pkgs."postgresql_${pg_version}".pg_config}/bin/pg_config"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -62,9 +62,7 @@ hash using `nix-hash --to-sri --type sha256 "<original sha256>"`.
|
|||||||
:::
|
:::
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8="; }
|
||||||
cargoHash = "sha256-l1vL2ZdtDRxSGvP0X/l3nMw8+6WF67KPutJEzUROjg8=";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If this method does not work, you can resort to copying the `Cargo.lock` file into nixpkgs
|
If this method does not work, you can resort to copying the `Cargo.lock` file into nixpkgs
|
||||||
@ -77,9 +75,7 @@ then be taken from the failed build. A fake hash can be used for
|
|||||||
`cargoHash` as follows:
|
`cargoHash` as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ cargoHash = lib.fakeHash; }
|
||||||
cargoHash = lib.fakeHash;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
|
Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
|
||||||
@ -478,11 +474,7 @@ and fetches every dependency as a separate fixed-output derivation.
|
|||||||
`importCargoLock` can be used as follows:
|
`importCargoLock` can be used as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }; }
|
||||||
cargoDeps = rustPlatform.importCargoLock {
|
|
||||||
lockFile = ./Cargo.lock;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If the `Cargo.lock` file includes git dependencies, then their output
|
If the `Cargo.lock` file includes git dependencies, then their output
|
||||||
@ -1000,8 +992,8 @@ let
|
|||||||
cargo = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
cargo = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
||||||
rustc = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
rustc = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
||||||
};
|
};
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
rustPlatform.buildRustPackage (finalAttrs: {
|
rustPlatform.buildRustPackage (finalAttrs: {
|
||||||
pname = "ripgrep";
|
pname = "ripgrep";
|
||||||
version = "14.1.1";
|
version = "14.1.1";
|
||||||
|
@ -25,7 +25,6 @@ primarily for Chez Scheme in a derivation, one might write:
|
|||||||
akkuPackages.chez-srfi
|
akkuPackages.chez-srfi
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The package index is located in `pkgs/tools/package-management/akku`
|
The package index is located in `pkgs/tools/package-management/akku`
|
||||||
|
@ -80,8 +80,8 @@ expression. The next step is to write that expression:
|
|||||||
let
|
let
|
||||||
# Pass the generated files to the helper.
|
# Pass the generated files to the helper.
|
||||||
generated = swiftpm2nix.helpers ./nix;
|
generated = swiftpm2nix.helpers ./nix;
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "myproject";
|
pname = "myproject";
|
||||||
version = "0.0.0";
|
version = "0.0.0";
|
||||||
@ -131,17 +131,13 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
If you'd like to build a different configuration than `release`:
|
If you'd like to build a different configuration than `release`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ swiftpmBuildConfig = "debug"; }
|
||||||
swiftpmBuildConfig = "debug";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
It is also possible to provide additional flags to `swift build`:
|
It is also possible to provide additional flags to `swift build`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ swiftpmFlags = [ "--disable-dead-strip" ]; }
|
||||||
swiftpmFlags = [ "--disable-dead-strip" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The default `buildPhase` already passes `-j` for parallel building.
|
The default `buildPhase` already passes `-j` for parallel building.
|
||||||
@ -155,9 +151,7 @@ Including `swiftpm` in your `nativeBuildInputs` also provides a default
|
|||||||
`checkPhase`, but it must be enabled with:
|
`checkPhase`, but it must be enabled with:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ doCheck = true; }
|
||||||
doCheck = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This essentially runs: `swift test -c release`
|
This essentially runs: `swift test -c release`
|
||||||
|
@ -214,24 +214,20 @@ let
|
|||||||
|
|
||||||
latex_with_foiltex = texliveSmall.withPackages (_: [ foiltex ]);
|
latex_with_foiltex = texliveSmall.withPackages (_: [ foiltex ]);
|
||||||
in
|
in
|
||||||
runCommand "test.pdf"
|
runCommand "test.pdf" { nativeBuildInputs = [ latex_with_foiltex ]; } ''
|
||||||
{
|
cat >test.tex <<EOF
|
||||||
nativeBuildInputs = [ latex_with_foiltex ];
|
\documentclass{foils}
|
||||||
}
|
|
||||||
''
|
|
||||||
cat >test.tex <<EOF
|
|
||||||
\documentclass{foils}
|
|
||||||
|
|
||||||
\title{Presentation title}
|
\title{Presentation title}
|
||||||
\date{}
|
\date{}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\maketitle
|
\maketitle
|
||||||
\end{document}
|
\end{document}
|
||||||
EOF
|
EOF
|
||||||
pdflatex test.tex
|
pdflatex test.tex
|
||||||
cp test.pdf $out
|
cp test.pdf $out
|
||||||
''
|
''
|
||||||
```
|
```
|
||||||
|
|
||||||
## LuaLaTeX font cache {#sec-language-texlive-lualatex-font-cache}
|
## LuaLaTeX font cache {#sec-language-texlive-lualatex-font-cache}
|
||||||
@ -239,15 +235,11 @@ runCommand "test.pdf"
|
|||||||
The font cache for LuaLaTeX is written to `$HOME`.
|
The font cache for LuaLaTeX is written to `$HOME`.
|
||||||
Therefore, it is necessary to set `$HOME` to a writable path, e.g. [before using LuaLaTeX in nix derivations](https://github.com/NixOS/nixpkgs/issues/180639):
|
Therefore, it is necessary to set `$HOME` to a writable path, e.g. [before using LuaLaTeX in nix derivations](https://github.com/NixOS/nixpkgs/issues/180639):
|
||||||
```nix
|
```nix
|
||||||
runCommandNoCC "lualatex-hello-world"
|
runCommandNoCC "lualatex-hello-world" { buildInputs = [ texliveFull ]; } ''
|
||||||
{
|
mkdir $out
|
||||||
buildInputs = [ texliveFull ];
|
echo '\documentclass{article} \begin{document} Hello world \end{document}' > main.tex
|
||||||
}
|
env HOME=$(mktemp -d) lualatex -interaction=nonstopmode -output-format=pdf -output-directory=$out ./main.tex
|
||||||
''
|
''
|
||||||
mkdir $out
|
|
||||||
echo '\documentclass{article} \begin{document} Hello world \end{document}' > main.tex
|
|
||||||
env HOME=$(mktemp -d) lualatex -interaction=nonstopmode -output-format=pdf -output-directory=$out ./main.tex
|
|
||||||
''
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Additionally, [the cache of a user can diverge from the nix store](https://github.com/NixOS/nixpkgs/issues/278718).
|
Additionally, [the cache of a user can diverge from the nix store](https://github.com/NixOS/nixpkgs/issues/278718).
|
||||||
|
@ -25,9 +25,7 @@ typst.withPackages.override
|
|||||||
typstPackages = old.typstPackages.extend (
|
typstPackages = old.typstPackages.extend (
|
||||||
_: previous: {
|
_: previous: {
|
||||||
polylux_0_4_0 = previous.polylux_0_4_0.overrideAttrs (oldPolylux: {
|
polylux_0_4_0 = previous.polylux_0_4_0.overrideAttrs (oldPolylux: {
|
||||||
src = oldPolylux.src.overrideAttrs {
|
src = oldPolylux.src.overrideAttrs { outputHash = YourUpToDatePolyluxHash; };
|
||||||
outputHash = YourUpToDatePolyluxHash;
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -47,10 +45,7 @@ typst.withPackages.override
|
|||||||
Here's how to define a custom Typst package:
|
Here's how to define a custom Typst package:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ buildTypstPackage, typstPackages }:
|
||||||
buildTypstPackage,
|
|
||||||
typstPackages,
|
|
||||||
}:
|
|
||||||
|
|
||||||
buildTypstPackage (finalAttrs: {
|
buildTypstPackage (finalAttrs: {
|
||||||
pname = "my-typst-package";
|
pname = "my-typst-package";
|
||||||
|
@ -29,9 +29,7 @@ The default configuration directory is `~/.cataclysm-dda`. If you prefer
|
|||||||
`$XDG_CONFIG_HOME/cataclysm-dda`, override the derivation:
|
`$XDG_CONFIG_HOME/cataclysm-dda`, override the derivation:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
cataclysm-dda.override {
|
cataclysm-dda.override { useXdgDir = true; }
|
||||||
useXdgDir = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Important note for overriding packages {#important-note-for-overriding-packages}
|
## Important note for overriding packages {#important-note-for-overriding-packages}
|
||||||
@ -62,10 +60,10 @@ let
|
|||||||
|
|
||||||
# or by using a helper function `attachPkgs`.
|
# or by using a helper function `attachPkgs`.
|
||||||
goodExample2 = attachPkgs pkgs myCDDA;
|
goodExample2 = attachPkgs pkgs myCDDA;
|
||||||
in
|
|
||||||
|
|
||||||
# badExample # parallel building disabled
|
# badExample # parallel building disabled
|
||||||
# goodExample1.withMods (_: []) # parallel building enabled
|
# goodExample1.withMods (_: []) # parallel building enabled
|
||||||
|
in
|
||||||
goodExample2.withMods (_: [ ]) # parallel building enabled
|
goodExample2.withMods (_: [ ]) # parallel building enabled
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -75,11 +73,7 @@ To install Cataclysm DDA with mods of your choice, you can use `withMods`
|
|||||||
attribute:
|
attribute:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
cataclysm-dda.withMods (
|
cataclysm-dda.withMods (mods: with mods; [ tileset.UndeadPeople ])
|
||||||
mods: with mods; [
|
|
||||||
tileset.UndeadPeople
|
|
||||||
]
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
All mods, soundpacks, and tilesets available in nixpkgs are found in
|
All mods, soundpacks, and tilesets available in nixpkgs are found in
|
||||||
|
@ -8,9 +8,7 @@ To enable them, use an override on `inkscape-with-extensions`:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
inkscape-with-extensions.override {
|
inkscape-with-extensions.override {
|
||||||
inkscapeExtensions = with inkscape-extensions; [
|
inkscapeExtensions = with inkscape-extensions; [ inkstitch ];
|
||||||
inkstitch
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -3,7 +3,5 @@
|
|||||||
Kakoune can be built to autoload plugins:
|
Kakoune can be built to autoload plugins:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
(kakoune.override {
|
(kakoune.override { plugins = with pkgs.kakounePlugins; [ parinfer-rust ]; })
|
||||||
plugins = with pkgs.kakounePlugins; [ parinfer-rust ];
|
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
@ -77,9 +77,7 @@ A plugin can be any kind of derivation, the only requirement is that it should a
|
|||||||
If the plugin is itself a Perl package that needs to be imported from other plugins or scripts, add the following passthrough:
|
If the plugin is itself a Perl package that needs to be imported from other plugins or scripts, add the following passthrough:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ passthru.perlPackages = [ "self" ]; }
|
||||||
passthru.perlPackages = [ "self" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This will make the urxvt wrapper pick up the dependency and set up the Perl path accordingly.
|
This will make the urxvt wrapper pick up the dependency and set up the Perl path accordingly.
|
||||||
|
@ -496,8 +496,8 @@
|
|||||||
```nix
|
```nix
|
||||||
let
|
let
|
||||||
pkgs = import <nixpkgs> { };
|
pkgs = import <nixpkgs> { };
|
||||||
in
|
|
||||||
|
|
||||||
|
in
|
||||||
pkgs.caddy.withPlugins {
|
pkgs.caddy.withPlugins {
|
||||||
plugins = [
|
plugins = [
|
||||||
# tagged upstream
|
# tagged upstream
|
||||||
|
@ -135,9 +135,7 @@ Some frequently encountered problems when packaging for cross-compilation should
|
|||||||
Many packages assume that an unprefixed binutils (`cc`/`ar`/`ld` etc.) is available, but Nix doesn't provide one. It only provides a prefixed one, just as it only does for all the other binutils programs. It may be necessary to patch the package to fix the build system to use a prefix. For instance, instead of `cc`, use `${stdenv.cc.targetPrefix}cc`.
|
Many packages assume that an unprefixed binutils (`cc`/`ar`/`ld` etc.) is available, but Nix doesn't provide one. It only provides a prefixed one, just as it only does for all the other binutils programs. It may be necessary to patch the package to fix the build system to use a prefix. For instance, instead of `cc`, use `${stdenv.cc.targetPrefix}cc`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; }
|
||||||
makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### How do I avoid compiling a GCC cross-compiler from source? {#cross-qa-avoid-compiling-gcc-cross-compiler}
|
#### How do I avoid compiling a GCC cross-compiler from source? {#cross-qa-avoid-compiling-gcc-cross-compiler}
|
||||||
@ -152,9 +150,7 @@ $ nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello
|
|||||||
Add the following to your `mkDerivation` invocation.
|
Add the following to your `mkDerivation` invocation.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ depsBuildBuild = [ buildPackages.stdenv.cc ]; }
|
||||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code}
|
#### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code}
|
||||||
@ -162,9 +158,7 @@ Add the following to your `mkDerivation` invocation.
|
|||||||
Add the following to your `mkDerivation` invocation.
|
Add the following to your `mkDerivation` invocation.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; }
|
||||||
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code}
|
#### Package using Meson needs to run binaries for the host platform during build. {#cross-meson-runs-host-code}
|
||||||
@ -175,13 +169,9 @@ e.g.
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
nativeBuildInputs =
|
nativeBuildInputs = [
|
||||||
[
|
meson
|
||||||
meson
|
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ mesonEmulatorHook ];
|
||||||
]
|
|
||||||
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
|
|
||||||
mesonEmulatorHook
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -108,9 +108,7 @@ The *priority* of the package, used by `nix-env` to resolve file name conflicts
|
|||||||
The list of Nix platform types on which the package is supported. Hydra builds packages according to the platform specified. If no platform is specified, the package does not have prebuilt binaries. An example is:
|
The list of Nix platform types on which the package is supported. Hydra builds packages according to the platform specified. If no platform is specified, the package does not have prebuilt binaries. An example is:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ meta.platforms = lib.platforms.linux; }
|
||||||
meta.platforms = lib.platforms.linux;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Attribute Set `lib.platforms` defines [various common lists](https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix) of platforms types.
|
Attribute Set `lib.platforms` defines [various common lists](https://github.com/NixOS/nixpkgs/blob/master/lib/systems/doubles.nix) of platforms types.
|
||||||
@ -164,9 +162,7 @@ This means that `broken` can be used to express constraints, for example:
|
|||||||
- Does not cross compile
|
- Does not cross compile
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ meta.broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform); }
|
||||||
meta.broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform);
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- Broken if all of a certain set of its dependencies are broken
|
- Broken if all of a certain set of its dependencies are broken
|
||||||
|
@ -541,11 +541,7 @@ let
|
|||||||
# An example of an attribute containing a function
|
# An example of an attribute containing a function
|
||||||
passthru.appendPackages =
|
passthru.appendPackages =
|
||||||
packages':
|
packages':
|
||||||
finalAttrs.finalPackage.overrideAttrs (
|
finalAttrs.finalPackage.overrideAttrs (newSelf: super: { packages = super.packages ++ packages'; });
|
||||||
newSelf: super: {
|
|
||||||
packages = super.packages ++ packages';
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# For illustration purposes; referenced as
|
# For illustration purposes; referenced as
|
||||||
# `(pkg.overrideAttrs(x)).finalAttrs` etc in the text below.
|
# `(pkg.overrideAttrs(x)).finalAttrs` etc in the text below.
|
||||||
@ -787,9 +783,7 @@ The file name of the Makefile.
|
|||||||
A list of strings passed as additional flags to `make`. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use `buildFlags` (see below).
|
A list of strings passed as additional flags to `make`. These flags are also used by the default install and check phase. For setting make flags specific to the build phase, use `buildFlags` (see below).
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ makeFlags = [ "PREFIX=$(out)" ]; }
|
||||||
makeFlags = [ "PREFIX=$(out)" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
::: {.note}
|
::: {.note}
|
||||||
@ -839,9 +833,7 @@ It is highly recommended, for packages' sources that are not distributed with an
|
|||||||
Controls whether the check phase is executed. By default it is skipped, but if `doCheck` is set to true, the check phase is usually executed. Thus you should set
|
Controls whether the check phase is executed. By default it is skipped, but if `doCheck` is set to true, the check phase is usually executed. Thus you should set
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ doCheck = true; }
|
||||||
doCheck = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doCheck` is set, as the newly-built program won’t run on the platform used to build it.
|
in the derivation to enable checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doCheck` is set, as the newly-built program won’t run on the platform used to build it.
|
||||||
@ -894,9 +886,7 @@ See the [build phase](#var-stdenv-makeFlags) for details.
|
|||||||
The make targets that perform the installation. Defaults to `install`. Example:
|
The make targets that perform the installation. Defaults to `install`. Example:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ installTargets = "install-bin install-doc"; }
|
||||||
installTargets = "install-bin install-doc";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `installFlags` / `installFlagsArray` {#var-stdenv-installFlags}
|
##### `installFlags` / `installFlagsArray` {#var-stdenv-installFlags}
|
||||||
@ -1085,9 +1075,7 @@ It is often better to add tests that are not part of the source distribution to
|
|||||||
Controls whether the installCheck phase is executed. By default it is skipped, but if `doInstallCheck` is set to true, the installCheck phase is usually executed. Thus you should set
|
Controls whether the installCheck phase is executed. By default it is skipped, but if `doInstallCheck` is set to true, the installCheck phase is usually executed. Thus you should set
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ doInstallCheck = true; }
|
||||||
doInstallCheck = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
in the derivation to enable install checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doInstallCheck` is set, as the newly-built program won’t run on the platform used to build it.
|
in the derivation to enable install checks. The exception is cross compilation. Cross compiled builds never run tests, no matter how `doInstallCheck` is set, as the newly-built program won’t run on the platform used to build it.
|
||||||
|
@ -21,9 +21,7 @@ In particular, all build-time dependencies are checked.
|
|||||||
A user's Nixpkgs configuration is stored in a user-specific configuration file located at `~/.config/nixpkgs/config.nix`. For example:
|
A user's Nixpkgs configuration is stored in a user-specific configuration file located at `~/.config/nixpkgs/config.nix`. For example:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ allowUnfree = true; }
|
||||||
allowUnfree = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
:::{.caution}
|
:::{.caution}
|
||||||
@ -44,9 +42,7 @@ There are two ways to try compiling a package which has been marked as broken.
|
|||||||
- For permanently allowing broken packages to be built, you may add `allowBroken = true;` to your user's configuration file, like this:
|
- For permanently allowing broken packages to be built, you may add `allowBroken = true;` to your user's configuration file, like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ allowBroken = true; }
|
||||||
allowBroken = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -63,9 +59,7 @@ There are also two ways to try compiling a package which has been marked as unsu
|
|||||||
- For permanently allowing unsupported packages to be built, you may add `allowUnsupportedSystem = true;` to your user's configuration file, like this:
|
- For permanently allowing unsupported packages to be built, you may add `allowUnsupportedSystem = true;` to your user's configuration file, like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ allowUnsupportedSystem = true; }
|
||||||
allowUnsupportedSystem = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The difference between a package being unsupported on some system and being broken is admittedly a bit fuzzy. If a program *ought* to work on a certain platform, but doesn't, the platform should be included in `meta.platforms`, but marked as broken with e.g. `meta.broken = !hostPlatform.isWindows`. Of course, this begs the question of what "ought" means exactly. That is left to the package maintainer.
|
The difference between a package being unsupported on some system and being broken is admittedly a bit fuzzy. If a program *ought* to work on a certain platform, but doesn't, the platform should be included in `meta.platforms`, but marked as broken with e.g. `meta.broken = !hostPlatform.isWindows`. Of course, this begs the question of what "ought" means exactly. That is left to the package maintainer.
|
||||||
@ -90,9 +84,7 @@ There are several ways to tweak how Nix handles a package which has been marked
|
|||||||
This option is a function which accepts a package as a parameter, and returns a boolean. The following example configuration accepts a package and always returns false:
|
This option is a function which accepts a package as a parameter, and returns a boolean. The following example configuration accepts a package and always returns false:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ allowUnfreePredicate = (pkg: false); }
|
||||||
allowUnfreePredicate = (pkg: false);
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For a more useful example, try the following. This configuration only allows unfree packages named roon-server and visual studio code:
|
For a more useful example, try the following. This configuration only allows unfree packages named roon-server and visual studio code:
|
||||||
@ -151,11 +143,7 @@ There are several ways to tweak how Nix handles a package which has been marked
|
|||||||
The following example configuration permits the installation of the hypothetically insecure package `hello`, version `1.2.3`:
|
The following example configuration permits the installation of the hypothetically insecure package `hello`, version `1.2.3`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ permittedInsecurePackages = [ "hello-1.2.3" ]; }
|
||||||
permittedInsecurePackages = [
|
|
||||||
"hello-1.2.3"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- It is also possible to create a custom policy around which insecure packages to allow and deny, by overriding the `allowInsecurePredicate` configuration option.
|
- It is also possible to create a custom policy around which insecure packages to allow and deny, by overriding the `allowInsecurePredicate` configuration option.
|
||||||
@ -165,13 +153,7 @@ There are several ways to tweak how Nix handles a package which has been marked
|
|||||||
The following configuration example allows any version of the `ovftool` package:
|
The following configuration example allows any version of the `ovftool` package:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ allowInsecurePredicate = pkg: builtins.elem (lib.getName pkg) [ "ovftool" ]; }
|
||||||
allowInsecurePredicate =
|
|
||||||
pkg:
|
|
||||||
builtins.elem (lib.getName pkg) [
|
|
||||||
"ovftool"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that `permittedInsecurePackages` is only checked if `allowInsecurePredicate` is not specified.
|
Note that `permittedInsecurePackages` is only checked if `allowInsecurePredicate` is not specified.
|
||||||
|
@ -48,12 +48,8 @@ Overlays are Nix functions which accept two arguments, conventionally called `se
|
|||||||
self: super:
|
self: super:
|
||||||
|
|
||||||
{
|
{
|
||||||
boost = super.boost.override {
|
boost = super.boost.override { python = self.python3; };
|
||||||
python = self.python3;
|
rr = super.callPackage ./pkgs/rr { stdenv = self.stdenv_32bit; };
|
||||||
};
|
|
||||||
rr = super.callPackage ./pkgs/rr {
|
|
||||||
stdenv = self.stdenv_32bit;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -99,13 +95,9 @@ Introduced in [PR #83888](https://github.com/NixOS/nixpkgs/pull/83888), we are a
|
|||||||
self: super:
|
self: super:
|
||||||
|
|
||||||
{
|
{
|
||||||
blas = super.blas.override {
|
blas = super.blas.override { blasProvider = self.mkl; };
|
||||||
blasProvider = self.mkl;
|
|
||||||
};
|
|
||||||
|
|
||||||
lapack = super.lapack.override {
|
lapack = super.lapack.override { lapackProvider = self.mkl; };
|
||||||
lapackProvider = self.mkl;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -123,13 +115,9 @@ To override `blas` and `lapack` with its reference implementations (i.e. for dev
|
|||||||
self: super:
|
self: super:
|
||||||
|
|
||||||
{
|
{
|
||||||
blas = super.blas.override {
|
blas = super.blas.override { blasProvider = self.lapack-reference; };
|
||||||
blasProvider = self.lapack-reference;
|
|
||||||
};
|
|
||||||
|
|
||||||
lapack = super.lapack.override {
|
lapack = super.lapack.override { lapackProvider = self.lapack-reference; };
|
||||||
lapackProvider = self.lapack-reference;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -31,11 +31,7 @@ pkgs.foo.override (previous: {
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
import pkgs.path {
|
import pkgs.path {
|
||||||
overlays = [
|
overlays = [ (self: super: { foo = super.foo.override { barSupport = true; }; }) ];
|
||||||
(self: super: {
|
|
||||||
foo = super.foo.override { barSupport = true; };
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -67,9 +63,7 @@ Example usages:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
helloBar = pkgs.hello.overrideAttrs (
|
helloBar = pkgs.hello.overrideAttrs (
|
||||||
finalAttrs: previousAttrs: {
|
finalAttrs: previousAttrs: { pname = previousAttrs.pname + "-bar"; }
|
||||||
pname = previousAttrs.pname + "-bar";
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -85,11 +79,7 @@ If only a one-argument function is written, the argument has the meaning of `pre
|
|||||||
Function arguments can be omitted entirely if there is no need to access `previousAttrs` or `finalAttrs`.
|
Function arguments can be omitted entirely if there is no need to access `previousAttrs` or `finalAttrs`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ helloWithDebug = pkgs.hello.overrideAttrs { separateDebugInfo = true; }; }
|
||||||
helloWithDebug = pkgs.hello.overrideAttrs {
|
|
||||||
separateDebugInfo = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In the above example, the `separateDebugInfo` attribute is overridden to be true, thus building debug info for `helloWithDebug`.
|
In the above example, the `separateDebugInfo` attribute is overridden to be true, thus building debug info for `helloWithDebug`.
|
||||||
|
@ -86,14 +86,12 @@ When adding users to [`maintainer-list.nix`](./maintainer-list.nix), the followi
|
|||||||
|
|
||||||
Given a maintainer entry like this:
|
Given a maintainer entry like this:
|
||||||
|
|
||||||
``` nix
|
```nix
|
||||||
{
|
{
|
||||||
example = {
|
example = {
|
||||||
email = "user@example.com";
|
email = "user@example.com";
|
||||||
name = "Example User";
|
name = "Example User";
|
||||||
keys = [{
|
keys = [ { fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE"; } ];
|
||||||
fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE";
|
|
||||||
}];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -28,7 +28,7 @@ can be accomplished using the following configuration on the host:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.nat.enable = true;
|
networking.nat.enable = true;
|
||||||
networking.nat.internalInterfaces = ["ve-+"];
|
networking.nat.internalInterfaces = [ "ve-+" ];
|
||||||
networking.nat.externalInterface = "eth0";
|
networking.nat.externalInterface = "eth0";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -40,9 +40,7 @@ If you are using Network Manager, you need to explicitly prevent it from
|
|||||||
managing container interfaces:
|
managing container interfaces:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ networking.networkmanager.unmanaged = [ "interface-name:ve-*" ]; }
|
||||||
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You may need to restart your system for the changes to take effect.
|
You may need to restart your system for the changes to take effect.
|
||||||
|
@ -39,9 +39,7 @@ they were in the same cgroup, then the PostgreSQL process would get
|
|||||||
`configuration.nix`:
|
`configuration.nix`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ systemd.services.httpd.serviceConfig.CPUShares = 512; }
|
||||||
systemd.services.httpd.serviceConfig.CPUShares = 512;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, every cgroup has 1024 CPU shares, so this will halve the CPU
|
By default, every cgroup has 1024 CPU shares, so this will halve the CPU
|
||||||
@ -54,9 +52,7 @@ limits can be specified in `configuration.nix`; for instance, to limit
|
|||||||
`httpd.service` to 512 MiB of RAM (excluding swap):
|
`httpd.service` to 512 MiB of RAM (excluding swap):
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ systemd.services.httpd.serviceConfig.MemoryLimit = "512M"; }
|
||||||
systemd.services.httpd.serviceConfig.MemoryLimit = "512M";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The command `systemd-cgtop` shows a continuously updated list of all
|
The command `systemd-cgtop` shows a continuously updated list of all
|
||||||
|
@ -6,13 +6,14 @@ shall be a container named `database` running PostgreSQL:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
containers.database =
|
containers.database = {
|
||||||
{ config =
|
config =
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{ services.postgresql.enable = true;
|
{
|
||||||
|
services.postgresql.enable = true;
|
||||||
services.postgresql.package = pkgs.postgresql_14;
|
services.postgresql.package = pkgs.postgresql_14;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -82,9 +82,7 @@ In order to enable a systemd *system* service with provided upstream
|
|||||||
package, use (e.g):
|
package, use (e.g):
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ systemd.packages = [ pkgs.packagekit ]; }
|
||||||
systemd.packages = [ pkgs.packagekit ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Usually NixOS modules written by the community do the above, plus take
|
Usually NixOS modules written by the community do the above, plus take
|
||||||
|
@ -4,37 +4,37 @@ If you find yourself repeating yourself over and over, it’s time to abstract.
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.httpd.virtualHosts =
|
services.httpd.virtualHosts = {
|
||||||
{ "blog.example.org" = {
|
"blog.example.org" = {
|
||||||
documentRoot = "/webroot/blog.example.org";
|
documentRoot = "/webroot/blog.example.org";
|
||||||
adminAddr = "alice@example.org";
|
adminAddr = "alice@example.org";
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
};
|
|
||||||
"wiki.example.org" = {
|
|
||||||
documentRoot = "/webroot/wiki.example.org";
|
|
||||||
adminAddr = "alice@example.org";
|
|
||||||
forceSSL = true;
|
|
||||||
enableACME = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
"wiki.example.org" = {
|
||||||
|
documentRoot = "/webroot/wiki.example.org";
|
||||||
|
adminAddr = "alice@example.org";
|
||||||
|
forceSSL = true;
|
||||||
|
enableACME = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
It defines two virtual hosts with nearly identical configuration; the only difference is the document root directories. To prevent this duplication, we can use a `let`:
|
It defines two virtual hosts with nearly identical configuration; the only difference is the document root directories. To prevent this duplication, we can use a `let`:
|
||||||
```nix
|
```nix
|
||||||
let
|
let
|
||||||
commonConfig =
|
commonConfig = {
|
||||||
{ adminAddr = "alice@example.org";
|
adminAddr = "alice@example.org";
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
services.httpd.virtualHosts =
|
services.httpd.virtualHosts = {
|
||||||
{ "blog.example.org" = (commonConfig // { documentRoot = "/webroot/blog.example.org"; });
|
"blog.example.org" = (commonConfig // { documentRoot = "/webroot/blog.example.org"; });
|
||||||
"wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.org"; });
|
"wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.org"; });
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -45,9 +45,24 @@ You can write a `let` wherever an expression is allowed. Thus, you also could ha
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.httpd.virtualHosts =
|
services.httpd.virtualHosts =
|
||||||
let commonConfig = { /* ... */ }; in
|
let
|
||||||
{ "blog.example.org" = (commonConfig // { /* ... */ });
|
commonConfig = {
|
||||||
"wiki.example.org" = (commonConfig // { /* ... */ });
|
# ...
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"blog.example.org" = (
|
||||||
|
commonConfig
|
||||||
|
// {
|
||||||
|
# ...
|
||||||
|
}
|
||||||
|
);
|
||||||
|
"wiki.example.org" = (
|
||||||
|
commonConfig
|
||||||
|
// {
|
||||||
|
# ...
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -60,18 +75,19 @@ but not `{ let commonConfig = ...; in ...; }` since attributes (as opposed to at
|
|||||||
{
|
{
|
||||||
services.httpd.virtualHosts =
|
services.httpd.virtualHosts =
|
||||||
let
|
let
|
||||||
makeVirtualHost = webroot:
|
makeVirtualHost = webroot: {
|
||||||
{ documentRoot = webroot;
|
documentRoot = webroot;
|
||||||
adminAddr = "alice@example.org";
|
adminAddr = "alice@example.org";
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
};
|
|
||||||
in
|
|
||||||
{ "example.org" = (makeVirtualHost "/webroot/example.org");
|
|
||||||
"example.com" = (makeVirtualHost "/webroot/example.com");
|
|
||||||
"example.gov" = (makeVirtualHost "/webroot/example.gov");
|
|
||||||
"example.nl" = (makeVirtualHost "/webroot/example.nl");
|
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"example.org" = (makeVirtualHost "/webroot/example.org");
|
||||||
|
"example.com" = (makeVirtualHost "/webroot/example.com");
|
||||||
|
"example.gov" = (makeVirtualHost "/webroot/example.gov");
|
||||||
|
"example.nl" = (makeVirtualHost "/webroot/example.nl");
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -7,9 +7,8 @@ modules. For instance, to statically configure an IPv6 address:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.localCommands =
|
networking.localCommands = ''
|
||||||
''
|
ip -6 addr add 2001:610:685:1::1/64 dev eth0
|
||||||
ip -6 addr add 2001:610:685:1::1/64 dev eth0
|
'';
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -23,9 +23,7 @@ Then you write and test the package as described in the Nixpkgs manual.
|
|||||||
Finally, you add it to [](#opt-environment.systemPackages), e.g.
|
Finally, you add it to [](#opt-environment.systemPackages), e.g.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ environment.systemPackages = [ pkgs.my-package ]; }
|
||||||
environment.systemPackages = [ pkgs.my-package ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
and you run `nixos-rebuild`, specifying your own Nixpkgs tree:
|
and you run `nixos-rebuild`, specifying your own Nixpkgs tree:
|
||||||
@ -43,13 +41,15 @@ tree. For instance, here is how you specify a build of the
|
|||||||
{
|
{
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
let
|
let
|
||||||
my-hello = with pkgs; stdenv.mkDerivation rec {
|
my-hello =
|
||||||
name = "hello-2.8";
|
with pkgs;
|
||||||
src = fetchurl {
|
stdenv.mkDerivation rec {
|
||||||
url = "mirror://gnu/hello/${name}.tar.gz";
|
name = "hello-2.8";
|
||||||
hash = "sha256-5rd/gffPfa761Kn1tl3myunD8TuM+66oy1O7XqVGDXM=";
|
src = fetchurl {
|
||||||
|
url = "mirror://gnu/hello/${name}.tar.gz";
|
||||||
|
hash = "sha256-5rd/gffPfa761Kn1tl3myunD8TuM+66oy1O7XqVGDXM=";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
in
|
in
|
||||||
[ my-hello ];
|
[ my-hello ];
|
||||||
}
|
}
|
||||||
@ -59,15 +59,13 @@ Of course, you can also move the definition of `my-hello` into a
|
|||||||
separate Nix expression, e.g.
|
separate Nix expression, e.g.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ environment.systemPackages = [ (import ./my-hello.nix) ]; }
|
||||||
environment.systemPackages = [ (import ./my-hello.nix) ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
where `my-hello.nix` contains:
|
where `my-hello.nix` contains:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
with import <nixpkgs> {}; # bring all of Nixpkgs into scope
|
with import <nixpkgs> { }; # bring all of Nixpkgs into scope
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "hello-2.8";
|
name = "hello-2.8";
|
||||||
|
@ -5,7 +5,8 @@ The NixOS configuration file generally looks like this:
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{ /* option definitions */
|
{
|
||||||
|
# option definitions
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -19,7 +20,8 @@ name of an option and `value` is its value. For example,
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{ services.httpd.enable = true;
|
{
|
||||||
|
services.httpd.enable = true;
|
||||||
services.httpd.adminAddr = "alice@example.org";
|
services.httpd.adminAddr = "alice@example.org";
|
||||||
services.httpd.virtualHosts.localhost.documentRoot = "/webroot";
|
services.httpd.virtualHosts.localhost.documentRoot = "/webroot";
|
||||||
}
|
}
|
||||||
@ -38,7 +40,8 @@ example above can also be written as:
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{ services = {
|
{
|
||||||
|
services = {
|
||||||
httpd = {
|
httpd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
adminAddr = "alice@example.org";
|
adminAddr = "alice@example.org";
|
||||||
|
@ -41,14 +41,14 @@ You can use them like this:
|
|||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
sl
|
sl
|
||||||
(pass.withExtensions (subpkgs: with subpkgs; [
|
(pass.withExtensions (
|
||||||
pass-audit
|
subpkgs: with subpkgs; [
|
||||||
pass-otp
|
pass-audit
|
||||||
pass-genphrase
|
pass-otp
|
||||||
]))
|
pass-genphrase
|
||||||
(python3.withPackages (subpkgs: with subpkgs; [
|
]
|
||||||
requests
|
))
|
||||||
]))
|
(python3.withPackages (subpkgs: with subpkgs; [ requests ]))
|
||||||
cowsay
|
cowsay
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -62,9 +62,7 @@ dependency on GTK 2. If you want to build it against GTK 3, you can
|
|||||||
specify that as follows:
|
specify that as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ]; }
|
||||||
environment.systemPackages = [ (pkgs.emacs.override { gtk = pkgs.gtk3; }) ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The function `override` performs the call to the Nix function that
|
The function `override` performs the call to the Nix function that
|
||||||
@ -109,9 +107,9 @@ your customised instance, you can apply a *global* override as follows:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
nixpkgs.config.packageOverrides = pkgs:
|
nixpkgs.config.packageOverrides = pkgs: {
|
||||||
{ emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
|
emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -7,9 +7,7 @@ following line to `configuration.nix` enables the Mozilla Thunderbird
|
|||||||
email application:
|
email application:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ environment.systemPackages = [ pkgs.thunderbird ]; }
|
||||||
environment.systemPackages = [ pkgs.thunderbird ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The effect of this specification is that the Thunderbird package from
|
The effect of this specification is that the Thunderbird package from
|
||||||
|
@ -7,10 +7,10 @@ point `/data`:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
fileSystems."/data" =
|
fileSystems."/data" = {
|
||||||
{ device = "/dev/disk/by-label/data";
|
device = "/dev/disk/by-label/data";
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -5,9 +5,7 @@ and other unexpected packets. The firewall applies to both IPv4 and IPv6
|
|||||||
traffic. It is enabled by default. It can be disabled as follows:
|
traffic. It is enabled by default. It can be disabled as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ networking.firewall.enable = false; }
|
||||||
networking.firewall.enable = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If the firewall is enabled, you can open specific TCP ports to the
|
If the firewall is enabled, you can open specific TCP ports to the
|
||||||
@ -15,7 +13,10 @@ outside world:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
80
|
||||||
|
443
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -28,8 +29,14 @@ To open ranges of TCP ports:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.firewall.allowedTCPPortRanges = [
|
networking.firewall.allowedTCPPortRanges = [
|
||||||
{ from = 4000; to = 4007; }
|
{
|
||||||
{ from = 8000; to = 8010; }
|
from = 4000;
|
||||||
|
to = 4007;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
from = 8000;
|
||||||
|
to = 8010;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -55,11 +55,7 @@ supported through the rocmPackages.clr.icd package. Adding this package to
|
|||||||
enables OpenCL support:
|
enables OpenCL support:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.graphics.extraPackages = [ rocmPackages.clr.icd ]; }
|
||||||
hardware.graphics.extraPackages = [
|
|
||||||
rocmPackages.clr.icd
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Intel {#sec-gpu-accel-opencl-intel}
|
### Intel {#sec-gpu-accel-opencl-intel}
|
||||||
@ -75,11 +71,7 @@ to enable OpenCL support. For example, for Gen12 and later GPUs, the following
|
|||||||
configuration can be used:
|
configuration can be used:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.graphics.extraPackages = [ intel-compute-runtime ]; }
|
||||||
hardware.graphics.extraPackages = [
|
|
||||||
intel-compute-runtime
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Vulkan {#sec-gpu-accel-vulkan}
|
## Vulkan {#sec-gpu-accel-vulkan}
|
||||||
@ -145,20 +137,15 @@ A specific driver can be forced as follows:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
hardware.graphics.extraPackages = [
|
hardware.graphics.extraPackages = [ pkgs.amdvlk ];
|
||||||
pkgs.amdvlk
|
|
||||||
];
|
|
||||||
|
|
||||||
# To enable Vulkan support for 32-bit applications, also add:
|
# To enable Vulkan support for 32-bit applications, also add:
|
||||||
hardware.graphics.extraPackages32 = [
|
hardware.graphics.extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
|
||||||
pkgs.driversi686Linux.amdvlk
|
|
||||||
];
|
|
||||||
|
|
||||||
# Force radv
|
# Force radv
|
||||||
environment.variables.AMD_VULKAN_ICD = "RADV";
|
environment.variables.AMD_VULKAN_ICD = "RADV";
|
||||||
# Or
|
# Or
|
||||||
environment.variables.VK_ICD_FILENAMES =
|
environment.variables.VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
|
||||||
"/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -183,21 +170,13 @@ $ nix-shell -p libva-utils --run vainfo
|
|||||||
Modern Intel GPUs use the iHD driver, which can be installed with:
|
Modern Intel GPUs use the iHD driver, which can be installed with:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.graphics.extraPackages = [ intel-media-driver ]; }
|
||||||
hardware.graphics.extraPackages = [
|
|
||||||
intel-media-driver
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Older Intel GPUs use the i965 driver, which can be installed with:
|
Older Intel GPUs use the i965 driver, which can be installed with:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.graphics.extraPackages = [ intel-vaapi-driver ]; }
|
||||||
hardware.graphics.extraPackages = [
|
|
||||||
intel-vaapi-driver
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Common issues {#sec-gpu-accel-common-issues}
|
## Common issues {#sec-gpu-accel-common-issues}
|
||||||
|
@ -6,10 +6,12 @@ manually as follows:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.interfaces.eth0.ipv4.addresses = [ {
|
networking.interfaces.eth0.ipv4.addresses = [
|
||||||
address = "192.168.1.2";
|
{
|
||||||
prefixLength = 24;
|
address = "192.168.1.2";
|
||||||
} ];
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -32,9 +34,7 @@ configuration is performed by `network-setup.service`.
|
|||||||
The host name is set using [](#opt-networking.hostName):
|
The host name is set using [](#opt-networking.hostName):
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ networking.hostName = "cartman"; }
|
||||||
networking.hostName = "cartman";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The default host name is `nixos`. Set it to the empty string (`""`) to
|
The default host name is `nixos`. Set it to the empty string (`""`) to
|
||||||
|
@ -9,18 +9,14 @@ may be overridden on a per-interface basis by
|
|||||||
IPv6 support globally by setting:
|
IPv6 support globally by setting:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ networking.enableIPv6 = false; }
|
||||||
networking.enableIPv6 = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can disable IPv6 on a single interface using a normal sysctl (in
|
You can disable IPv6 on a single interface using a normal sysctl (in
|
||||||
this example, we use interface `eth0`):
|
this example, we use interface `eth0`):
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true; }
|
||||||
boot.kernel.sysctl."net.ipv6.conf.eth0.disable_ipv6" = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
As with IPv4 networking interfaces are automatically configured via
|
As with IPv4 networking interfaces are automatically configured via
|
||||||
@ -28,10 +24,12 @@ DHCPv6. You can configure an interface manually:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.interfaces.eth0.ipv6.addresses = [ {
|
networking.interfaces.eth0.ipv6.addresses = [
|
||||||
address = "fe00:aa:bb:cc::2";
|
{
|
||||||
prefixLength = 64;
|
address = "fe00:aa:bb:cc::2";
|
||||||
} ];
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -24,17 +24,13 @@ the host. This enables apiserver, controllerManager, scheduler,
|
|||||||
addonManager, kube-proxy and etcd:
|
addonManager, kube-proxy and etcd:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.kubernetes.roles = [ "master" ]; }
|
||||||
services.kubernetes.roles = [ "master" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
While this will enable the kubelet and kube-proxy only:
|
While this will enable the kubelet and kube-proxy only:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.kubernetes.roles = [ "node" ]; }
|
||||||
services.kubernetes.roles = [ "node" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Assigning both the master and node roles is usable if you want a single
|
Assigning both the master and node roles is usable if you want a single
|
||||||
@ -42,7 +38,10 @@ node Kubernetes cluster for dev or testing purposes:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.kubernetes.roles = [ "master" "node" ];
|
services.kubernetes.roles = [
|
||||||
|
"master"
|
||||||
|
"node"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -5,9 +5,7 @@ option `boot.kernelPackages`. For instance, this selects the Linux 3.10
|
|||||||
kernel:
|
kernel:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10; }
|
||||||
boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that this not only replaces the kernel, but also packages that are
|
Note that this not only replaces the kernel, but also packages that are
|
||||||
@ -43,13 +41,15 @@ instance, to enable support for the kernel debugger KGDB:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs {
|
nixpkgs.config.packageOverrides =
|
||||||
linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {
|
pkgs:
|
||||||
extraConfig = ''
|
pkgs.lib.recursiveUpdate pkgs {
|
||||||
KGDB y
|
linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {
|
||||||
'';
|
extraConfig = ''
|
||||||
|
KGDB y
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -64,7 +64,11 @@ by `udev`. You can force a module to be loaded via
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];
|
boot.kernelModules = [
|
||||||
|
"fuse"
|
||||||
|
"kvm-intel"
|
||||||
|
"coretemp"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -72,9 +76,7 @@ If the module is required early during the boot (e.g. to mount the root
|
|||||||
file system), you can use [](#opt-boot.initrd.kernelModules):
|
file system), you can use [](#opt-boot.initrd.kernelModules):
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.initrd.kernelModules = [ "cifs" ]; }
|
||||||
boot.initrd.kernelModules = [ "cifs" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This causes the specified modules and their dependencies to be added to
|
This causes the specified modules and their dependencies to be added to
|
||||||
@ -84,9 +86,7 @@ Kernel runtime parameters can be set through
|
|||||||
[](#opt-boot.kernel.sysctl), e.g.
|
[](#opt-boot.kernel.sysctl), e.g.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120; }
|
||||||
boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
sets the kernel's TCP keepalive time to 120 seconds. To see the
|
sets the kernel's TCP keepalive time to 120 seconds. To see the
|
||||||
@ -99,9 +99,7 @@ Please refer to the Nixpkgs manual for the various ways of [building a custom ke
|
|||||||
To use your custom kernel package in your NixOS configuration, set
|
To use your custom kernel package in your NixOS configuration, set
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; }
|
||||||
boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rust {#sec-linux-rust}
|
## Rust {#sec-linux-rust}
|
||||||
|
@ -39,9 +39,7 @@ Should grub be used as bootloader, and `/boot` is located on an
|
|||||||
encrypted partition, it is necessary to add the following grub option:
|
encrypted partition, it is necessary to add the following grub option:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.loader.grub.enableCryptodisk = true; }
|
||||||
boot.loader.grub.enableCryptodisk = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## FIDO2 {#sec-luks-file-systems-fido2}
|
## FIDO2 {#sec-luks-file-systems-fido2}
|
||||||
@ -74,7 +72,8 @@ key, add the following to `configuration.nix`:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
boot.initrd.luks.fido2Support = true;
|
boot.initrd.luks.fido2Support = true;
|
||||||
boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";
|
boot.initrd.luks.devices."/dev/sda2".fido2.credential =
|
||||||
|
"f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -83,9 +82,7 @@ you might want to enable it only when your device is PIN protected, such
|
|||||||
as [Trezor](https://trezor.io/).
|
as [Trezor](https://trezor.io/).
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true; }
|
||||||
boot.initrd.luks.devices."/dev/sda2".fido2.passwordLess = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### systemd Stage 1 {#sec-luks-file-systems-fido2-systemd}
|
### systemd Stage 1 {#sec-luks-file-systems-fido2-systemd}
|
||||||
|
@ -71,11 +71,9 @@ Here is an example with a prebuilt plugin tarball:
|
|||||||
{
|
{
|
||||||
services.mattermost = {
|
services.mattermost = {
|
||||||
plugins = with pkgs; [
|
plugins = with pkgs; [
|
||||||
/*
|
# todo
|
||||||
* todo
|
# 0.7.1
|
||||||
* 0.7.1
|
# https://github.com/mattermost/mattermost-plugin-todo/releases/tag/v0.7.1
|
||||||
* https://github.com/mattermost/mattermost-plugin-todo/releases/tag/v0.7.1
|
|
||||||
*/
|
|
||||||
(fetchurl {
|
(fetchurl {
|
||||||
# Note: Don't unpack the tarball; the NixOS module will repack it for you.
|
# Note: Don't unpack the tarball; the NixOS module will repack it for you.
|
||||||
url = "https://github.com/mattermost-community/mattermost-plugin-todo/releases/download/v0.7.1/com.mattermost.plugin-todo-0.7.1.tar.gz";
|
url = "https://github.com/mattermost-community/mattermost-plugin-todo/releases/download/v0.7.1/com.mattermost.plugin-todo-0.7.1.tar.gz";
|
||||||
|
@ -13,7 +13,11 @@ including them from `configuration.nix`, e.g.:
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{ imports = [ ./vpn.nix ./kde.nix ];
|
{
|
||||||
|
imports = [
|
||||||
|
./vpn.nix
|
||||||
|
./kde.nix
|
||||||
|
];
|
||||||
services.httpd.enable = true;
|
services.httpd.enable = true;
|
||||||
environment.systemPackages = [ pkgs.emacs ];
|
environment.systemPackages = [ pkgs.emacs ];
|
||||||
# ...
|
# ...
|
||||||
@ -26,7 +30,8 @@ Here, we include two modules from the same directory, `vpn.nix` and
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{ services.xserver.enable = true;
|
{
|
||||||
|
services.xserver.enable = true;
|
||||||
services.displayManager.sddm.enable = true;
|
services.displayManager.sddm.enable = true;
|
||||||
services.xserver.desktopManager.plasma5.enable = true;
|
services.xserver.desktopManager.plasma5.enable = true;
|
||||||
environment.systemPackages = [ pkgs.vim ];
|
environment.systemPackages = [ pkgs.vim ];
|
||||||
@ -42,9 +47,7 @@ merged last, so for list-type options, it will appear at the end of the
|
|||||||
merged list. If you want it to appear first, you can use `mkBefore`:
|
merged list. If you want it to appear first, you can use `mkBefore`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ boot.kernelModules = mkBefore [ "kvm-intel" ]; }
|
||||||
boot.kernelModules = mkBefore [ "kvm-intel" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This causes the `kvm-intel` kernel module to be loaded before any other
|
This causes the `kvm-intel` kernel module to be loaded before any other
|
||||||
@ -62,9 +65,7 @@ When that happens, it's possible to force one definition take precedence
|
|||||||
over the others:
|
over the others:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org"; }
|
||||||
services.httpd.adminAddr = pkgs.lib.mkForce "bob@example.org";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
When using multiple modules, you may need to access configuration values
|
When using multiple modules, you may need to access configuration values
|
||||||
@ -84,9 +85,11 @@ For example, here is a module that adds some packages to
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{ environment.systemPackages =
|
{
|
||||||
|
environment.systemPackages =
|
||||||
if config.services.xserver.enable then
|
if config.services.xserver.enable then
|
||||||
[ pkgs.firefox
|
[
|
||||||
|
pkgs.firefox
|
||||||
pkgs.thunderbird
|
pkgs.thunderbird
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
@ -126,12 +129,14 @@ have the same effect as importing a file which sets those options.
|
|||||||
```nix
|
```nix
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
let netConfig = hostName: {
|
let
|
||||||
networking.hostName = hostName;
|
netConfig = hostName: {
|
||||||
networking.useDHCP = false;
|
networking.hostName = hostName;
|
||||||
};
|
networking.useDHCP = false;
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
{
|
||||||
{ imports = [ (netConfig "nixos.localdomain") ]; }
|
imports = [ (netConfig "nixos.localdomain") ];
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
@ -4,9 +4,7 @@ To facilitate network configuration, some desktop environments use
|
|||||||
NetworkManager. You can enable NetworkManager by setting:
|
NetworkManager. You can enable NetworkManager by setting:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ networking.networkmanager.enable = true; }
|
||||||
networking.networkmanager.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
some desktop managers (e.g., GNOME) enable NetworkManager automatically
|
some desktop managers (e.g., GNOME) enable NetworkManager automatically
|
||||||
@ -16,9 +14,7 @@ All users that should have permission to change network settings must
|
|||||||
belong to the `networkmanager` group:
|
belong to the `networkmanager` group:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ users.users.alice.extraGroups = [ "networkmanager" ]; }
|
||||||
users.users.alice.extraGroups = [ "networkmanager" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
NetworkManager is controlled using either `nmcli` or `nmtui`
|
NetworkManager is controlled using either `nmcli` or `nmtui`
|
||||||
@ -38,7 +34,9 @@ NetworkManager to ignore those interfaces like:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.networkmanager.unmanaged = [
|
networking.networkmanager.unmanaged = [
|
||||||
"*" "except:type:wwan" "except:type:gsm"
|
"*"
|
||||||
|
"except:type:wwan"
|
||||||
|
"except:type:gsm"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -8,11 +8,7 @@ is to say, expected usage is to add them to the imports list of your
|
|||||||
`/etc/configuration.nix` as such:
|
`/etc/configuration.nix` as such:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ imports = [ <nixpkgs/nixos/modules/profiles/profile-name.nix> ]; }
|
||||||
imports = [
|
|
||||||
<nixpkgs/nixos/modules/profiles/profile-name.nix>
|
|
||||||
];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Even if some of these profiles seem only useful in the context of
|
Even if some of these profiles seem only useful in the context of
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
Secure shell (SSH) access to your machine can be enabled by setting:
|
Secure shell (SSH) access to your machine can be enabled by setting:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.openssh.enable = true; }
|
||||||
services.openssh.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, root logins using a password are disallowed. They can be
|
By default, root logins using a password are disallowed. They can be
|
||||||
@ -17,7 +15,6 @@ as follows:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
users.users.alice.openssh.authorizedKeys.keys =
|
users.users.alice.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];
|
||||||
[ "ssh-ed25519 AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -41,37 +41,38 @@ Here's a typical setup:
|
|||||||
fileSystems."/mnt/my-dir" = {
|
fileSystems."/mnt/my-dir" = {
|
||||||
device = "my-user@example.com:/my-dir/";
|
device = "my-user@example.com:/my-dir/";
|
||||||
fsType = "sshfs";
|
fsType = "sshfs";
|
||||||
options =
|
options = [
|
||||||
[ # Filesystem options
|
# Filesystem options
|
||||||
"allow_other" # for non-root access
|
"allow_other" # for non-root access
|
||||||
"_netdev" # this is a network fs
|
"_netdev" # this is a network fs
|
||||||
"x-systemd.automount" # mount on demand
|
"x-systemd.automount" # mount on demand
|
||||||
|
|
||||||
# SSH options
|
# SSH options
|
||||||
"reconnect" # handle connection drops
|
"reconnect" # handle connection drops
|
||||||
"ServerAliveInterval=15" # keep connections alive
|
"ServerAliveInterval=15" # keep connections alive
|
||||||
"IdentityFile=/var/secrets/example-key"
|
"IdentityFile=/var/secrets/example-key"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
More options from `ssh_config(5)` can be given as well, for example you can change the default SSH port or specify a jump proxy:
|
More options from `ssh_config(5)` can be given as well, for example you can change the default SSH port or specify a jump proxy:
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
options =
|
options = [
|
||||||
[ "ProxyJump=bastion@example.com"
|
"ProxyJump=bastion@example.com"
|
||||||
"Port=22"
|
"Port=22"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
It's also possible to change the `ssh` command used by SSHFS to connect to the server.
|
It's also possible to change the `ssh` command used by SSHFS to connect to the server.
|
||||||
For example:
|
For example:
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
options =
|
options = [
|
||||||
[ (builtins.replaceStrings [" "] ["\\040"]
|
(builtins.replaceStrings [ " " ] [ "\\040" ]
|
||||||
"ssh_command=${pkgs.openssh}/bin/ssh -v -L 8080:localhost:80")
|
"ssh_command=${pkgs.openssh}/bin/ssh -v -L 8080:localhost:80"
|
||||||
];
|
)
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -24,7 +24,10 @@ appropriately:
|
|||||||
{
|
{
|
||||||
services.httpd.enable = true;
|
services.httpd.enable = true;
|
||||||
services.httpd.adminAddr = "...";
|
services.httpd.adminAddr = "...";
|
||||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
80
|
||||||
|
443
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -38,25 +41,31 @@ the password file.
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.httpd.extraModules = [
|
services.httpd.extraModules = [
|
||||||
# note that order is *super* important here
|
# note that order is *super* important here
|
||||||
{ name = "dav_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so"; }
|
{
|
||||||
{ name = "authz_svn"; path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so"; }
|
name = "dav_svn";
|
||||||
];
|
path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_dav_svn.so";
|
||||||
services.httpd.virtualHosts = {
|
}
|
||||||
"svn" = {
|
{
|
||||||
hostName = HOSTNAME;
|
name = "authz_svn";
|
||||||
documentRoot = DOCUMENTROOT;
|
path = "${pkgs.apacheHttpdPackages.subversion}/modules/mod_authz_svn.so";
|
||||||
locations."/svn".extraConfig = ''
|
}
|
||||||
DAV svn
|
];
|
||||||
SVNParentPath REPO_PARENT
|
services.httpd.virtualHosts = {
|
||||||
AuthzSVNAccessFile ACCESS_FILE
|
"svn" = {
|
||||||
AuthName "SVN Repositories"
|
hostName = HOSTNAME;
|
||||||
AuthType Basic
|
documentRoot = DOCUMENTROOT;
|
||||||
AuthUserFile PASSWORD_FILE
|
locations."/svn".extraConfig = ''
|
||||||
Require valid-user
|
DAV svn
|
||||||
'';
|
SVNParentPath REPO_PARENT
|
||||||
};
|
AuthzSVNAccessFile ACCESS_FILE
|
||||||
|
AuthName "SVN Repositories"
|
||||||
|
AuthType Basic
|
||||||
|
AuthUserFile PASSWORD_FILE
|
||||||
|
Require valid-user
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -11,7 +11,10 @@ account named `alice` shall exist:
|
|||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
home = "/home/alice";
|
home = "/home/alice";
|
||||||
description = "Alice Foobar";
|
description = "Alice Foobar";
|
||||||
extraGroups = [ "wheel" "networkmanager" ];
|
extraGroups = [
|
||||||
|
"wheel"
|
||||||
|
"networkmanager"
|
||||||
|
];
|
||||||
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
|
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -40,9 +43,7 @@ A user ID (uid) is assigned automatically. You can also specify a uid
|
|||||||
manually by adding
|
manually by adding
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ uid = 1000; }
|
||||||
uid = 1000;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
to the user specification.
|
to the user specification.
|
||||||
@ -51,9 +52,7 @@ Groups can be specified similarly. The following states that a group
|
|||||||
named `students` shall exist:
|
named `students` shall exist:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ users.groups.students.gid = 1000; }
|
||||||
users.groups.students.gid = 1000;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
As with users, the group ID (gid) is optional and will be assigned
|
As with users, the group ID (gid) is optional and will be assigned
|
||||||
@ -109,9 +108,7 @@ Instead of using a custom perl script to create users and groups, you can use
|
|||||||
systemd-sysusers:
|
systemd-sysusers:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ systemd.sysusers.enable = true; }
|
||||||
systemd.sysusers.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The primary benefit of this is to remove a dependency on perl.
|
The primary benefit of this is to remove a dependency on perl.
|
||||||
@ -137,9 +134,7 @@ the Perl script. It aims to eventually replace the Perl script by default.
|
|||||||
You can enable Userborn via:
|
You can enable Userborn via:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.userborn.enable = true; }
|
||||||
services.userborn.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can configure Userborn to store the password files
|
You can configure Userborn to store the password files
|
||||||
@ -147,9 +142,7 @@ You can configure Userborn to store the password files
|
|||||||
location to `/etc`:
|
location to `/etc`:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.userborn.passwordFilesLocation = "/persistent/etc"; }
|
||||||
services.userborn.passwordFilesLocation = "/persistent/etc";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This is useful when you store `/etc` on a `tmpfs` or if `/etc` is immutable
|
This is useful when you store `/etc` on a `tmpfs` or if `/etc` is immutable
|
||||||
|
@ -9,9 +9,7 @@ a Wayland Compositor such as sway without separately enabling a Wayland
|
|||||||
server:
|
server:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ programs.sway.enable = true; }
|
||||||
programs.sway.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This installs the sway compositor along with some essential utilities.
|
This installs the sway compositor along with some essential utilities.
|
||||||
|
@ -7,9 +7,7 @@ skip the rest of this section on wireless networks.
|
|||||||
NixOS will start wpa_supplicant for you if you enable this setting:
|
NixOS will start wpa_supplicant for you if you enable this setting:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ networking.wireless.enable = true; }
|
||||||
networking.wireless.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
NixOS lets you specify networks for wpa_supplicant declaratively:
|
NixOS lets you specify networks for wpa_supplicant declaratively:
|
||||||
@ -17,17 +15,20 @@ NixOS lets you specify networks for wpa_supplicant declaratively:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
networking.wireless.networks = {
|
networking.wireless.networks = {
|
||||||
echelon = { # SSID with no spaces or special characters
|
echelon = {
|
||||||
|
# SSID with no spaces or special characters
|
||||||
psk = "abcdefgh";
|
psk = "abcdefgh";
|
||||||
};
|
};
|
||||||
"echelon's AP" = { # SSID with spaces and/or special characters
|
"echelon's AP" = {
|
||||||
|
# SSID with spaces and/or special characters
|
||||||
psk = "ijklmnop";
|
psk = "ijklmnop";
|
||||||
};
|
};
|
||||||
echelon = { # Hidden SSID
|
echelon = {
|
||||||
|
# Hidden SSID
|
||||||
hidden = true;
|
hidden = true;
|
||||||
psk = "qrstuvwx";
|
psk = "qrstuvwx";
|
||||||
};
|
};
|
||||||
free.wifi = {}; # Public wireless network
|
free.wifi = { }; # Public wireless network
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -4,9 +4,7 @@ The X Window System (X11) provides the basis of NixOS' graphical user
|
|||||||
interface. It can be enabled as follows:
|
interface. It can be enabled as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.xserver.enable = true; }
|
||||||
services.xserver.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The X server will automatically detect and use the appropriate video
|
The X server will automatically detect and use the appropriate video
|
||||||
@ -14,9 +12,7 @@ driver from a set of X.org drivers (such as `vesa` and `intel`). You can
|
|||||||
also specify a driver manually, e.g.
|
also specify a driver manually, e.g.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.xserver.videoDrivers = [ "r128" ]; }
|
||||||
services.xserver.videoDrivers = [ "r128" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
to enable X.org's `xf86-video-r128` driver.
|
to enable X.org's `xf86-video-r128` driver.
|
||||||
@ -63,9 +59,7 @@ The X server is started automatically at boot time. If you don't want
|
|||||||
this to happen, you can set:
|
this to happen, you can set:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.xserver.autorun = false; }
|
||||||
services.xserver.autorun = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The X server can then be started manually:
|
The X server can then be started manually:
|
||||||
@ -78,9 +72,7 @@ On 64-bit systems, if you want OpenGL for 32-bit programs such as in
|
|||||||
Wine, you should also set the following:
|
Wine, you should also set the following:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.graphics.enable32Bit = true; }
|
||||||
hardware.graphics.enable32Bit = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Auto-login {#sec-x11-auto-login}
|
## Auto-login {#sec-x11-auto-login}
|
||||||
@ -98,9 +90,7 @@ desktop environment. If you wanted no desktop environment and i3 as your
|
|||||||
your window manager, you'd define:
|
your window manager, you'd define:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.displayManager.defaultSession = "none+i3"; }
|
||||||
services.displayManager.defaultSession = "none+i3";
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Every display manager in NixOS supports auto-login, here is an example
|
Every display manager in NixOS supports auto-login, here is an example
|
||||||
@ -187,9 +177,7 @@ both drivers. Use the option
|
|||||||
to set one. The recommended configuration for modern systems is:
|
to set one. The recommended configuration for modern systems is:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.xserver.videoDrivers = [ "modesetting" ]; }
|
||||||
services.xserver.videoDrivers = [ "modesetting" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
::: {.note}
|
::: {.note}
|
||||||
The `modesetting` driver doesn't currently provide a `TearFree` option (this
|
The `modesetting` driver doesn't currently provide a `TearFree` option (this
|
||||||
@ -204,7 +192,7 @@ reported to resolve the issue:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.xserver.videoDrivers = [ "intel" ];
|
services.xserver.videoDrivers = [ "intel" ];
|
||||||
services.xserver.deviceSection = ''
|
services.xserver.deviceSection = ''
|
||||||
Option "DRI" "2"
|
Option "DRI" "2"
|
||||||
Option "TearFree" "true"
|
Option "TearFree" "true"
|
||||||
'';
|
'';
|
||||||
@ -221,9 +209,7 @@ better 3D performance than the X.org drivers. It is not enabled by
|
|||||||
default because it's not free software. You can enable it as follows:
|
default because it's not free software. You can enable it as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.xserver.videoDrivers = [ "nvidia" ]; }
|
||||||
services.xserver.videoDrivers = [ "nvidia" ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have an older card, you may have to use one of the legacy drivers:
|
If you have an older card, you may have to use one of the legacy drivers:
|
||||||
@ -245,18 +231,14 @@ Support for Synaptics touchpads (found in many laptops such as the Dell
|
|||||||
Latitude series) can be enabled as follows:
|
Latitude series) can be enabled as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.libinput.enable = true; }
|
||||||
services.libinput.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The driver has many options (see [](#ch-options)).
|
The driver has many options (see [](#ch-options)).
|
||||||
For instance, the following disables tap-to-click behavior:
|
For instance, the following disables tap-to-click behavior:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.libinput.touchpad.tapping = false; }
|
||||||
services.libinput.touchpad.tapping = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: the use of `services.xserver.synaptics` is deprecated since NixOS
|
Note: the use of `services.xserver.synaptics` is deprecated since NixOS
|
||||||
@ -310,7 +292,7 @@ A minimal layout specification must include the following:
|
|||||||
{
|
{
|
||||||
services.xserver.xkb.extraLayouts.us-greek = {
|
services.xserver.xkb.extraLayouts.us-greek = {
|
||||||
description = "US layout with alt-gr greek";
|
description = "US layout with alt-gr greek";
|
||||||
languages = [ "eng" ];
|
languages = [ "eng" ];
|
||||||
symbolsFile = /yourpath/symbols/us-greek;
|
symbolsFile = /yourpath/symbols/us-greek;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -374,9 +356,9 @@ As before, to install the layout do
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.xserver.xkb.extraLayouts.media = {
|
services.xserver.xkb.extraLayouts.media = {
|
||||||
description = "Multimedia keys remapping";
|
description = "Multimedia keys remapping";
|
||||||
languages = [ "eng" ];
|
languages = [ "eng" ];
|
||||||
symbolsFile = /path/to/media-key;
|
symbolsFile = /path/to/media-key;
|
||||||
keycodesFile = /path/to/media-sym;
|
keycodesFile = /path/to/media-sym;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,15 @@ This is an example of using `warnings`.
|
|||||||
{
|
{
|
||||||
config = lib.mkIf config.services.foo.enable {
|
config = lib.mkIf config.services.foo.enable {
|
||||||
warnings =
|
warnings =
|
||||||
if config.services.foo.bar
|
if config.services.foo.bar then
|
||||||
then [ ''You have enabled the bar feature of the foo service.
|
[
|
||||||
This is known to cause some specific problems in certain situations.
|
''
|
||||||
'' ]
|
You have enabled the bar feature of the foo service.
|
||||||
else [];
|
This is known to cause some specific problems in certain situations.
|
||||||
|
''
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[ ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -30,11 +34,12 @@ This example, extracted from the [`syslogd` module](https://github.com/NixOS/nix
|
|||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
{
|
{
|
||||||
config = lib.mkIf config.services.syslogd.enable {
|
config = lib.mkIf config.services.syslogd.enable {
|
||||||
assertions =
|
assertions = [
|
||||||
[ { assertion = !config.services.rsyslogd.enable;
|
{
|
||||||
message = "rsyslogd conflicts with syslogd";
|
assertion = !config.services.rsyslogd.enable;
|
||||||
}
|
message = "rsyslogd conflicts with syslogd";
|
||||||
];
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -20,7 +20,8 @@ For this purpose, Bootspec offers a generic extension facility [`boot.bootspec.e
|
|||||||
An example for SecureBoot is to get the Nix store path to `/etc/os-release` in order to bake it into a unified kernel image:
|
An example for SecureBoot is to get the Nix store path to `/etc/os-release` in order to bake it into a unified kernel image:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ config, lib, ... }: {
|
{ config, lib, ... }:
|
||||||
|
{
|
||||||
boot.bootspec.extensions = {
|
boot.bootspec.extensions = {
|
||||||
"org.secureboot.osRelease" = config.environment.etc."os-release".source;
|
"org.secureboot.osRelease" = config.environment.etc."os-release".source;
|
||||||
};
|
};
|
||||||
|
@ -9,9 +9,7 @@ Instead of using a custom perl script to activate `/etc`, you activate it via an
|
|||||||
overlay filesystem:
|
overlay filesystem:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ system.etc.overlay.enable = true; }
|
||||||
system.etc.overlay.enable = true;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Using an overlay has two benefits:
|
Using an overlay has two benefits:
|
||||||
@ -24,9 +22,7 @@ upper layer). However, you can also mount `/etc` immutably (i.e. read-only) by
|
|||||||
setting:
|
setting:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ system.etc.overlay.mutable = false; }
|
||||||
system.etc.overlay.mutable = false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The overlay is atomically replaced during system switch. However, files that
|
The overlay is atomically replaced during system switch. However, files that
|
||||||
|
@ -23,7 +23,8 @@ type-checked and assign a default value. See
|
|||||||
for a more complete example.
|
for a more complete example.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ lib, config, ... }: {
|
{ lib, config, ... }:
|
||||||
|
{
|
||||||
|
|
||||||
options.settings = lib.mkOption {
|
options.settings = lib.mkOption {
|
||||||
type = lib.types.submodule {
|
type = lib.types.submodule {
|
||||||
|
@ -4,14 +4,19 @@ Sometimes NixOS modules need to be used in configuration but exist
|
|||||||
outside of Nixpkgs. These modules can be imported:
|
outside of Nixpkgs. These modules can be imported:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports =
|
imports = [
|
||||||
[ # Use a locally-available module definition in
|
# Use a locally-available module definition in
|
||||||
# ./example-module/default.nix
|
# ./example-module/default.nix
|
||||||
./example-module
|
./example-module
|
||||||
];
|
];
|
||||||
|
|
||||||
services.exampleModule.enable = true;
|
services.exampleModule.enable = true;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,12 @@ Each of the meta-attributes must be defined at most once per module
|
|||||||
file.
|
file.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
# ...
|
# ...
|
||||||
|
@ -8,7 +8,8 @@ If you want to build such a system, you can use the `image-based-appliance`
|
|||||||
profile:
|
profile:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ modulesPath, ... }: {
|
{ modulesPath, ... }:
|
||||||
|
{
|
||||||
imports = [ "${modulesPath}/profiles/image-based-appliance.nix" ];
|
imports = [ "${modulesPath}/profiles/image-based-appliance.nix" ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -79,13 +79,14 @@ For example:
|
|||||||
### `mkEnableOption` usage
|
### `mkEnableOption` usage
|
||||||
```nix
|
```nix
|
||||||
lib.mkEnableOption "magic"
|
lib.mkEnableOption "magic"
|
||||||
# is like
|
# is like
|
||||||
lib.mkOption {
|
lib.mkOption
|
||||||
type = lib.types.bool;
|
{
|
||||||
default = false;
|
type = lib.types.bool;
|
||||||
example = true;
|
default = false;
|
||||||
description = "Whether to enable magic.";
|
example = true;
|
||||||
}
|
description = "Whether to enable magic.";
|
||||||
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -94,7 +95,14 @@ lib.mkOption {
|
|||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkPackageOption pkgs "name" { default = [ "path" "in" "pkgs" ]; example = "literal example"; }
|
mkPackageOption pkgs "name" {
|
||||||
|
default = [
|
||||||
|
"path"
|
||||||
|
"in"
|
||||||
|
"pkgs"
|
||||||
|
];
|
||||||
|
example = "literal example";
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Creates an Option attribute set for an option that specifies the package a module should use for some purpose.
|
Creates an Option attribute set for an option that specifies the package a module should use for some purpose.
|
||||||
@ -127,47 +135,52 @@ Examples:
|
|||||||
### Simple `mkPackageOption` usage
|
### Simple `mkPackageOption` usage
|
||||||
```nix
|
```nix
|
||||||
lib.mkPackageOption pkgs "hello" { }
|
lib.mkPackageOption pkgs "hello" { }
|
||||||
# is like
|
# is like
|
||||||
lib.mkOption {
|
lib.mkOption
|
||||||
type = lib.types.package;
|
{
|
||||||
default = pkgs.hello;
|
type = lib.types.package;
|
||||||
defaultText = lib.literalExpression "pkgs.hello";
|
default = pkgs.hello;
|
||||||
description = "The hello package to use.";
|
defaultText = lib.literalExpression "pkgs.hello";
|
||||||
}
|
description = "The hello package to use.";
|
||||||
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
::: {#ex-options-declarations-util-mkPackageOption-ghc .example}
|
::: {#ex-options-declarations-util-mkPackageOption-ghc .example}
|
||||||
### `mkPackageOption` with explicit default and example
|
### `mkPackageOption` with explicit default and example
|
||||||
```nix
|
```nix
|
||||||
lib.mkPackageOption pkgs "GHC" {
|
lib.mkPackageOption pkgs "GHC"
|
||||||
default = [ "ghc" ];
|
{
|
||||||
example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
|
default = [ "ghc" ];
|
||||||
}
|
example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
|
||||||
# is like
|
}
|
||||||
lib.mkOption {
|
# is like
|
||||||
type = lib.types.package;
|
lib.mkOption
|
||||||
default = pkgs.ghc;
|
{
|
||||||
defaultText = lib.literalExpression "pkgs.ghc";
|
type = lib.types.package;
|
||||||
example = lib.literalExpression "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
|
default = pkgs.ghc;
|
||||||
description = "The GHC package to use.";
|
defaultText = lib.literalExpression "pkgs.ghc";
|
||||||
}
|
example = lib.literalExpression "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
|
||||||
|
description = "The GHC package to use.";
|
||||||
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
::: {#ex-options-declarations-util-mkPackageOption-extraDescription .example}
|
::: {#ex-options-declarations-util-mkPackageOption-extraDescription .example}
|
||||||
### `mkPackageOption` with additional description text
|
### `mkPackageOption` with additional description text
|
||||||
```nix
|
```nix
|
||||||
mkPackageOption pkgs [ "python312Packages" "torch" ] {
|
mkPackageOption pkgs [ "python312Packages" "torch" ]
|
||||||
extraDescription = "This is an example and doesn't actually do anything.";
|
{
|
||||||
}
|
extraDescription = "This is an example and doesn't actually do anything.";
|
||||||
# is like
|
}
|
||||||
lib.mkOption {
|
# is like
|
||||||
type = lib.types.package;
|
lib.mkOption
|
||||||
default = pkgs.python312Packages.torch;
|
{
|
||||||
defaultText = lib.literalExpression "pkgs.python312Packages.torch";
|
type = lib.types.package;
|
||||||
description = "The pytorch package to use. This is an example and doesn't actually do anything.";
|
default = pkgs.python312Packages.torch;
|
||||||
}
|
defaultText = lib.literalExpression "pkgs.python312Packages.torch";
|
||||||
|
description = "The pytorch package to use. This is an example and doesn't actually do anything.";
|
||||||
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@ -233,9 +246,7 @@ enforces that there can only be a single display manager enabled.
|
|||||||
### Extending `services.xserver.displayManager.enable` in the `gdm` module
|
### Extending `services.xserver.displayManager.enable` in the `gdm` module
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.xserver.displayManager.enable = mkOption {
|
services.xserver.displayManager.enable = mkOption { type = with types; nullOr (enum [ "gdm" ]); };
|
||||||
type = with types; nullOr (enum [ "gdm" ]);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
@ -244,9 +255,7 @@ enforces that there can only be a single display manager enabled.
|
|||||||
### Extending `services.xserver.displayManager.enable` in the `sddm` module
|
### Extending `services.xserver.displayManager.enable` in the `sddm` module
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
services.xserver.displayManager.enable = mkOption {
|
services.xserver.displayManager.enable = mkOption { type = with types; nullOr (enum [ "sddm" ]); };
|
||||||
type = with types; nullOr (enum [ "sddm" ]);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
@ -21,10 +21,16 @@ option, you may need to use `mkIf`. Consider, for instance:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config = if config.services.httpd.enable then {
|
config =
|
||||||
environment.systemPackages = [ /* ... */ ];
|
if config.services.httpd.enable then
|
||||||
# ...
|
{
|
||||||
} else {};
|
environment.systemPackages = [
|
||||||
|
# ...
|
||||||
|
];
|
||||||
|
# ...
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ };
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -35,11 +41,15 @@ clearly circular and contradictory:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config = if config.services.httpd.enable then {
|
config =
|
||||||
services.httpd.enable = false;
|
if config.services.httpd.enable then
|
||||||
} else {
|
{
|
||||||
services.httpd.enable = true;
|
services.httpd.enable = false;
|
||||||
};
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
services.httpd.enable = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -48,7 +58,9 @@ The solution is to write:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config = mkIf config.services.httpd.enable {
|
config = mkIf config.services.httpd.enable {
|
||||||
environment.systemPackages = [ /* ... */ ];
|
environment.systemPackages = [
|
||||||
|
# ...
|
||||||
|
];
|
||||||
# ...
|
# ...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -60,7 +72,13 @@ be "pushed down" into the individual definitions, as if you had written:
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
environment.systemPackages = if config.services.httpd.enable then [ /* ... */ ] else [];
|
environment.systemPackages =
|
||||||
|
if config.services.httpd.enable then
|
||||||
|
[
|
||||||
|
# ...
|
||||||
|
]
|
||||||
|
else
|
||||||
|
[ ];
|
||||||
# ...
|
# ...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -75,9 +93,7 @@ priority 100 and option defaults have priority 1500.
|
|||||||
You can specify an explicit priority by using `mkOverride`, e.g.
|
You can specify an explicit priority by using `mkOverride`, e.g.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ services.openssh.enable = mkOverride 10 false; }
|
||||||
services.openssh.enable = mkOverride 10 false;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This definition causes all other definitions with priorities above 10 to
|
This definition causes all other definitions with priorities above 10 to
|
||||||
@ -92,9 +108,7 @@ The functions `mkBefore` and `mkAfter` are equal to `mkOrder 500` and `mkOrder 1
|
|||||||
As an example,
|
As an example,
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{ hardware.firmware = mkBefore [ myFirmware ]; }
|
||||||
hardware.firmware = mkBefore [ myFirmware ];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This definition ensures that `myFirmware` comes before other unordered
|
This definition ensures that `myFirmware` comes before other unordered
|
||||||
@ -112,15 +126,20 @@ they were declared in separate modules. This can be done using
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config = mkMerge
|
config = mkMerge [
|
||||||
[ # Unconditional stuff.
|
# Unconditional stuff.
|
||||||
{ environment.systemPackages = [ /* ... */ ];
|
{
|
||||||
}
|
environment.systemPackages = [
|
||||||
# Conditional stuff.
|
# ...
|
||||||
(mkIf config.services.bla.enable {
|
];
|
||||||
environment.systemPackages = [ /* ... */ ];
|
}
|
||||||
})
|
# Conditional stuff.
|
||||||
];
|
(mkIf config.services.bla.enable {
|
||||||
|
environment.systemPackages = [
|
||||||
|
# ...
|
||||||
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -145,8 +164,8 @@ This is what would work
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkDefinition {
|
mkDefinition {
|
||||||
value = mkForce 42;
|
value = mkForce 42;
|
||||||
file = "somefile.nix";
|
file = "somefile.nix";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -154,8 +173,8 @@ While this would NOT work.
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkForce (mkDefinition {
|
mkForce (mkDefinition {
|
||||||
value = 42;
|
value = 42;
|
||||||
file = "somefile.nix";
|
file = "somefile.nix";
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -164,9 +183,7 @@ The following shows an example configuration that yields an error with the custo
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
_file = "file.nix";
|
_file = "file.nix";
|
||||||
options.foo = mkOption {
|
options.foo = mkOption { default = 13; };
|
||||||
default = 13;
|
|
||||||
};
|
|
||||||
config.foo = lib.mkDefinition {
|
config.foo = lib.mkDefinition {
|
||||||
file = "custom place";
|
file = "custom place";
|
||||||
# mkOptionDefault creates a conflict with the option foo's `default = 1` on purpose
|
# mkOptionDefault creates a conflict with the option foo's `default = 1` on purpose
|
||||||
|
@ -495,16 +495,14 @@ if you want to allow users to leave it undefined.
|
|||||||
{
|
{
|
||||||
options.mod = mkOption {
|
options.mod = mkOption {
|
||||||
description = "submodule example";
|
description = "submodule example";
|
||||||
type = with types; submodule {
|
type =
|
||||||
options = {
|
with types;
|
||||||
foo = mkOption {
|
submodule {
|
||||||
type = int;
|
options = {
|
||||||
};
|
foo = mkOption { type = int; };
|
||||||
bar = mkOption {
|
bar = mkOption { type = str; };
|
||||||
type = str;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -516,12 +514,8 @@ if you want to allow users to leave it undefined.
|
|||||||
let
|
let
|
||||||
modOptions = {
|
modOptions = {
|
||||||
options = {
|
options = {
|
||||||
foo = mkOption {
|
foo = mkOption { type = int; };
|
||||||
type = int;
|
bar = mkOption { type = int; };
|
||||||
};
|
|
||||||
bar = mkOption {
|
|
||||||
type = int;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@ -546,16 +540,14 @@ multiple definitions of the submodule option set
|
|||||||
{
|
{
|
||||||
options.mod = mkOption {
|
options.mod = mkOption {
|
||||||
description = "submodule example";
|
description = "submodule example";
|
||||||
type = with types; listOf (submodule {
|
type =
|
||||||
options = {
|
with types;
|
||||||
foo = mkOption {
|
listOf (submodule {
|
||||||
type = int;
|
options = {
|
||||||
|
foo = mkOption { type = int; };
|
||||||
|
bar = mkOption { type = str; };
|
||||||
};
|
};
|
||||||
bar = mkOption {
|
});
|
||||||
type = str;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -566,8 +558,14 @@ multiple definitions of the submodule option set
|
|||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config.mod = [
|
config.mod = [
|
||||||
{ foo = 1; bar = "one"; }
|
{
|
||||||
{ foo = 2; bar = "two"; }
|
foo = 1;
|
||||||
|
bar = "one";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
foo = 2;
|
||||||
|
bar = "two";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -584,16 +582,14 @@ multiple named definitions of the submodule option set
|
|||||||
{
|
{
|
||||||
options.mod = mkOption {
|
options.mod = mkOption {
|
||||||
description = "submodule example";
|
description = "submodule example";
|
||||||
type = with types; attrsOf (submodule {
|
type =
|
||||||
options = {
|
with types;
|
||||||
foo = mkOption {
|
attrsOf (submodule {
|
||||||
type = int;
|
options = {
|
||||||
|
foo = mkOption { type = int; };
|
||||||
|
bar = mkOption { type = str; };
|
||||||
};
|
};
|
||||||
bar = mkOption {
|
});
|
||||||
type = str;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -603,8 +599,14 @@ multiple named definitions of the submodule option set
|
|||||||
### Definition of attribute sets of submodules
|
### Definition of attribute sets of submodules
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
config.mod.one = { foo = 1; bar = "one"; };
|
config.mod.one = {
|
||||||
config.mod.two = { foo = 2; bar = "two"; };
|
foo = 1;
|
||||||
|
bar = "one";
|
||||||
|
};
|
||||||
|
config.mod.two = {
|
||||||
|
foo = 2;
|
||||||
|
bar = "two";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
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