treewide: run treefmt with mdcr/nixfmt

Changed files
+1919 -2002
doc
maintainers
nixos
doc
manual
administration
configuration
development
installation
release-notes
modules
pkgs
applications
emulators
libretro
by-name
az
azure-cli
development
tcl-modules
by-name
servers
home-assistant
custom-components
custom-lovelace-modules
+29 -21
CONTRIBUTING.md
···
That is, write
```nix
-
{ stdenv, fetchurl, perl }: <...>
+
{
+
stdenv,
+
fetchurl,
+
perl,
+
}:
+
<...>
```
instead of
···
or
```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:
```nix
-
{ stdenv, doCoverageAnalysis ? false, ... } @ args:
+
{
+
stdenv,
+
doCoverageAnalysis ? false,
+
...
+
}@args:
-
stdenv.mkDerivation (args // {
-
foo = if doCoverageAnalysis then "bla" else "";
-
})
+
stdenv.mkDerivation (args // { foo = if doCoverageAnalysis then "bla" else ""; })
```
instead of
···
```nix
args:
-
args.stdenv.mkDerivation (args // {
-
foo = if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "";
-
})
+
args.stdenv.mkDerivation (
+
args
+
// {
+
foo = if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "";
+
}
+
)
```
- Unnecessary string conversions should be avoided.
Do
```nix
-
{
-
rev = version;
-
}
+
{ rev = version; }
```
instead of
```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 [ ]`.
```nix
-
{
-
buildInputs = lib.optional stdenv.hostPlatform.isDarwin iconv;
-
}
+
{ buildInputs = lib.optional stdenv.hostPlatform.isDarwin iconv; }
```
instead of
```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.
+1 -4
doc/build-helpers/fixed-point-arguments.chapter.md
···
}@args:
{
# Arguments to pass
-
inherit
-
preferLocalBuild
-
allowSubstitute
-
;
+
inherit preferLocalBuild allowSubstitute;
# Some expressions involving specialArg
greeting = if specialArg "hi" then "hi" else "hello";
};
+2 -6
doc/build-helpers/images/appimagetools.section.md
···
hash = "sha256-he1uGC1M/nFcKpMM9JKY4oeexJcnzV0ZRxhTjtJz6xw=";
};
in
-
appimageTools.wrapType2 {
-
inherit pname version src;
-
}
+
appimageTools.wrapType2 { inherit pname version src; }
```
:::
···
hash = "sha256-/hMPvYdnVB1XjKgU2v47HnVvW4+uC3rhRjbucqin4iI=";
};
-
appimageContents = appimageTools.extract {
-
inherit pname version src;
-
};
+
appimageContents = appimageTools.extract { inherit pname version src; };
in
appimageTools.wrapType2 {
inherit pname version src;
+1 -4
doc/build-helpers/images/binarycache.section.md
···
The following derivation will construct a flat-file binary cache containing the closure of `hello`.
```nix
-
{ mkBinaryCache, hello }:
-
mkBinaryCache {
-
rootPaths = [ hello ];
-
}
+
{ mkBinaryCache, hello }: mkBinaryCache { rootPaths = [ hello ]; }
```
Build the cache on a machine.
+1 -3
doc/build-helpers/images/dockertools.section.md
···
dockerTools.streamNixShellImage {
tag = "latest";
drv = hello.overrideAttrs (old: {
-
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
-
cowsay
-
];
+
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ cowsay ];
});
```
+1 -3
doc/build-helpers/images/ocitools.section.md
···
bash,
}:
ociTools.buildContainer {
-
args = [
-
(lib.getExe bash)
-
];
+
args = [ (lib.getExe bash) ];
readonly = false;
}
+13 -18
doc/build-helpers/special/checkpoint-build.section.md
···
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:
-
- apply `prepareCheckpointBuild` on the desired derivation, e.g.
-
```nix
-
{
-
checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);
-
}
-
```
-
- 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;
-
});
-
}
-
```
+
```nix
+
{
+
checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);
+
}
+
```
+
```nix
+
{
+
changedVBox = pkgs.virtualbox.overrideAttrs (old: {
+
src = path/to/vbox/sources;
+
});
+
}
+
```
- use `mkCheckpointBuild changedVBox checkpointArtifacts`
- enjoy shorter build times
···
pkgs ? import <nixpkgs> { },
}:
let
-
inherit (pkgs.checkpointBuildTools)
-
prepareCheckpointBuild
-
mkCheckpointBuild
-
;
+
inherit (pkgs.checkpointBuildTools) prepareCheckpointBuild mkCheckpointBuild;
helloCheckpoint = prepareCheckpointBuild pkgs.hello;
changedHello = pkgs.hello.overrideAttrs (_: {
doCheck = false;
+3 -9
doc/build-helpers/testers.chapter.md
···
```nix
{
-
passthru.tests.pkg-config = testers.hasPkgConfigModules {
-
package = finalAttrs.finalPackage;
-
};
+
passthru.tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
meta.pkgConfigModules = [ "libfoo" ];
}
···
# Check hyperlinks in the `nix` documentation
```nix
-
testers.lycheeLinkCheck {
-
site = nix.doc + "/share/doc/nix/manual";
-
}
+
testers.lycheeLinkCheck { site = nix.doc + "/share/doc/nix/manual"; }
```
:::
···
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
-
{
-
passthru.tests.version = testers.testVersion { package = hello; };
-
}
+
{ passthru.tests.version = testers.testVersion { package = hello; }; }
```
:::
+7 -6
doc/build-helpers/trivial-build-helpers.chapter.md
···
Likewise, `runCommandCC name derivationArgs buildCommand` is equivalent to
```nix
-
runCommandWith {
-
inherit name derivationArgs;
-
} buildCommand
+
runCommandWith { inherit name derivationArgs; } buildCommand
```
:::
···
# Writes contents of files to /nix/store/<store path>
concatText
"my-file"
-
[ file1 file2 ]
+
[
+
file1
+
file2
+
]
# Writes contents of files to /nix/store/<store path>
concatScript
···
For example,
```nix
-
writeClosure [ (writeScriptBin "hi" ''${hello}/bin/hello'') ]
+
writeClosure [ (writeScriptBin "hi" "${hello}/bin/hello") ]
```
produces an output path `/nix/store/<hash>-runtime-deps` containing
···
For example,
```nix
-
writeDirectReferencesToFile (writeScriptBin "hi" ''${hello}/bin/hello'')
+
writeDirectReferencesToFile (writeScriptBin "hi" "${hello}/bin/hello")
```
produces an output path `/nix/store/<hash>-runtime-references` containing
+1 -1
doc/functions/generators.section.md
···
} ":";
};
+
# the INI file can now be given as plain old nix values
in
-
# the INI file can now be given as plain old nix values
customToINI {
main = {
pushinfo = true;
+15 -6
doc/functions/nix-gitignore.section.md
···
src = nix-gitignore.gitignoreSource [ ] ./source;
# 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
-
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.
-
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
# once the paths are turned to strings via readFile.
}
···
If you want to make your own filter from scratch, you may use
```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}
+1 -3
doc/hooks/breakpoint.section.md
···
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
-
{
-
nativeBuildInputs = [ breakpointHook ];
-
}
+
{ nativeBuildInputs = [ breakpointHook ]; }
```
When a build failure occurs, an instruction will be printed showing how to attach to the build sandbox.
+4 -10
doc/hooks/memcached-test-hook.section.md
···
This hook starts a Memcached server during `checkPhase`. Example:
```nix
-
{
-
stdenv,
-
memcachedTestHook,
-
}:
+
{ stdenv, memcachedTestHook }:
stdenv.mkDerivation {
# ...
-
nativeCheckInputs = [
-
memcachedTestHook
-
];
+
nativeCheckInputs = [ memcachedTestHook ];
}
```
···
# ...
-
nativeCheckInputs = [
-
memcachedTestHook
-
];
+
nativeCheckInputs = [ memcachedTestHook ];
preCheck = ''
memcachedTestPort=1234;
'';
}
+
```
+1 -3
doc/hooks/patch-rc-path-hooks.section.md
···
# ...
-
nativeBuildInputs = [
-
patchRcPathFish
-
];
+
nativeBuildInputs = [ patchRcPathFish ];
postFixup = ''
patchRcPathFish $out/bin/this-foo.fish ${
+2 -6
doc/hooks/redis-test-hook.section.md
···
# ...
-
nativeCheckInputs = [
-
redisTestHook
-
];
+
nativeCheckInputs = [ redisTestHook ];
}
```
···
# ...
-
nativeCheckInputs = [
-
redisTestHook
-
];
+
nativeCheckInputs = [ redisTestHook ];
preCheck = ''
redisTestPort=6390;
+9 -13
doc/hooks/tauri.section.md
···
hash = "...";
};
-
nativeBuildInputs =
-
[
-
# Pull in our main hook
-
cargo-tauri.hook
+
nativeBuildInputs = [
+
# Pull in our main hook
+
cargo-tauri.hook
-
# Setup npm
-
nodejs
-
npmHooks.npmConfigHook
+
# Setup npm
+
nodejs
+
npmHooks.npmConfigHook
-
# Make sure we can find our libraries
-
pkg-config
-
]
-
++ lib.optionals stdenv.hostPlatform.isLinux [
-
wrapGAppsHook4
-
];
+
# Make sure we can find our libraries
+
pkg-config
+
] ++ lib.optionals stdenv.hostPlatform.isLinux [ wrapGAppsHook4 ];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
glib-networking # Most Tauri apps need networking
+1 -3
doc/hooks/udevCheckHook.section.md
···
stdenv.mkDerivation (finalAttrs: {
# ...
-
nativeInstallCheckInputs = [
-
udevCheckHook
-
];
+
nativeInstallCheckInputs = [ udevCheckHook ];
doInstallCheck = true;
# ...
+1 -3
doc/hooks/versionCheckHook.section.md
···
stdenv.mkDerivation (finalAttrs: {
# ...
-
nativeInstallCheckInputs = [
-
versionCheckHook
-
];
+
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
# ...
+1 -3
doc/hooks/zig.section.md
···
stdenv.mkDerivation {
# . . .
-
nativeBuildInputs = [
-
zig.hook
-
];
+
nativeBuildInputs = [ zig.hook ];
zigBuildFlags = [ "-Dman-pages=true" ];
+1 -3
doc/interoperability/cyclonedx.md
···
sha256,
...
}:
-
pkgs.fetchzip {
-
inherit name url sha256;
-
};
+
pkgs.fetchzip { inherit name url sha256; };
};
in
+1 -3
doc/languages-frameworks/agda.section.md
···
version = "1.0";
pname = "my-agda-lib";
src = ./.;
-
buildInputs = [
-
agdaPackages.standard-library
-
];
+
buildInputs = [ agdaPackages.standard-library ];
}
```
+4 -14
doc/languages-frameworks/android.section.md
···
Use the `android-studio-full` attribute for a very complete Android SDK, including system images:
```nix
-
{
-
buildInputs = [ android-studio-full ];
-
}
+
{ buildInputs = [ android-studio-full ]; }
```
This is identical to:
```nix
-
{
-
buildInputs = [ androidStudioPackages.stable.full ];
-
}
+
{ buildInputs = [ androidStudioPackages.stable.full ]; }
```
Alternatively, you can pass composeAndroidPackages to the `withSdk` passthru:
···
```nix
{
buildInputs = [
-
(android-studio.withSdk
-
(androidenv.composeAndroidPackages {
-
includeNDK = true;
-
}).androidsdk
-
)
+
(android-studio.withSdk (androidenv.composeAndroidPackages { includeNDK = true; }).androidsdk)
];
}
```
···
"arm64-v8a"
];
includeNDK = true;
-
includeExtras = [
-
"extras;google;auto"
-
];
+
includeExtras = [ "extras;google;auto" ];
};
in
androidComposition.androidsdk
+3 -11
doc/languages-frameworks/beam.section.md
···
overlays = [ ];
};
in
-
pkgs.mkShell {
-
packages = [ pkgs.beamPackages.rebar3 ];
-
}
+
pkgs.mkShell { packages = [ pkgs.beamPackages.rebar3 ]; }
```
:::
···
let
elixir = beam.packages.erlang_27.elixir_1_18;
in
-
mkShell {
-
buildInputs = [ elixir ];
-
}
+
mkShell { buildInputs = [ elixir ]; }
```
### Using an overlay {#beam-using-overlays}
···
pkgs = import <nixpkgs> { overlays = [ elixir_1_18_1_overlay ]; };
in
with pkgs;
-
mkShell {
-
buildInputs = [
-
elixir_1_18
-
];
-
}
+
mkShell { buildInputs = [ elixir_1_18 ]; }
```
#### Elixir - Phoenix project {#elixir---phoenix-project}
+2 -2
doc/languages-frameworks/chicken.section.md
···
);
}
);
+
# Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use
+
# the local copy of `srfi-180`.
in
-
# Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use
-
# the local copy of `srfi-180`.
<...>
```
+2 -6
doc/languages-frameworks/coq.section.md
···
For example, assuming you have a special `mathcomp` dependency you want to use, here is how you could override the `mathcomp` dependency:
```nix
-
multinomials.override {
-
mathcomp = my-special-mathcomp;
-
}
+
multinomials.override { 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:
```nix
-
coqPackages.multinomials.override {
-
version = "1.5.1";
-
}
+
coqPackages.multinomials.override { 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.
+2 -6
doc/languages-frameworks/cuda.section.md
···
When using `callPackage`, you can choose to pass in a different variant, e.g. when a package requires a specific version of CUDA:
```nix
-
{
-
mypkg = callPackage { cudaPackages = cudaPackages_12_2; };
-
}
+
{ mypkg = callPackage { cudaPackages = cudaPackages_12_2; }; }
```
::: {.caution}
···
The NVIDIA Container Toolkit can be enabled in NixOS like follows:
```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:
+1 -3
doc/languages-frameworks/dhall.section.md
···
hash = "sha256-B4Q3c6IvTLg3Q92qYa8y+i4uTaphtFdjp+Ir3QQjdN0=";
};
-
dhallOverlay = self: super: {
-
true = self.callPackage ./true.nix { };
-
};
+
dhallOverlay = self: super: { true = self.callPackage ./true.nix { }; };
overlay = self: super: {
dhallPackages = super.dhallPackages.override (old: {
+4 -4
doc/languages-frameworks/dotnet.section.md
···
mkShell {
name = "dotnet-env";
-
packages = [
-
dotnet-sdk
-
];
+
packages = [ dotnet-sdk ];
}
```
···
projectFile = "src/project.sln";
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-runtime = dotnetCorePackages.runtime_8_0;
+52 -55
doc/languages-frameworks/emscripten.section.md
···
```nix
-
(pkgs.zlib.override {
-
stdenv = pkgs.emscriptenStdenv;
-
}).overrideAttrs
-
(old: {
-
buildInputs = old.buildInputs ++ [ pkg-config ];
-
# we need to reset this setting!
-
env = (old.env or { }) // {
-
NIX_CFLAGS_COMPILE = "";
-
};
+
(pkgs.zlib.override { stdenv = pkgs.emscriptenStdenv; }).overrideAttrs (old: {
+
buildInputs = old.buildInputs ++ [ pkg-config ];
+
# we need to reset this setting!
+
env = (old.env or { }) // {
+
NIX_CFLAGS_COMPILE = "";
+
};
-
configurePhase = ''
-
# FIXME: Some tests require writing at $HOME
-
HOME=$TMPDIR
-
runHook preConfigure
+
configurePhase = ''
+
# FIXME: Some tests require writing at $HOME
+
HOME=$TMPDIR
+
runHook preConfigure
-
#export EMCC_DEBUG=2
-
emconfigure ./configure --prefix=$out --shared
+
#export EMCC_DEBUG=2
+
emconfigure ./configure --prefix=$out --shared
-
runHook postConfigure
-
'';
+
runHook postConfigure
+
'';
-
dontStrip = true;
-
outputs = [ "out" ];
+
dontStrip = true;
+
outputs = [ "out" ];
-
buildPhase = ''
-
runHook preBuild
+
buildPhase = ''
+
runHook preBuild
-
emmake make
+
emmake make
-
runHook postBuild
-
'';
+
runHook postBuild
+
'';
-
installPhase = ''
-
runHook preInstall
+
installPhase = ''
+
runHook preInstall
-
emmake make install
+
emmake make install
-
runHook postInstall
-
'';
+
runHook postInstall
+
'';
-
checkPhase = ''
-
runHook preCheck
+
checkPhase = ''
+
runHook preCheck
-
echo "================= testing zlib using node ================="
+
echo "================= testing zlib using node ================="
-
echo "Compiling a custom test"
-
set -x
-
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \
-
libz.so.${old.version} -I . -o example.js
+
echo "Compiling a custom test"
+
set -x
+
emcc -O2 -s EMULATE_FUNCTION_POINTER_CASTS=1 test/example.c -DZ_SOLO \
+
libz.so.${old.version} -I . -o example.js
-
echo "Using node to execute the test"
-
${pkgs.nodejs}/bin/node ./example.js
+
echo "Using node to execute the test"
+
${pkgs.nodejs}/bin/node ./example.js
-
set +x
-
if [ $? -ne 0 ]; then
-
echo "test failed for some reason"
-
exit 1;
-
else
-
echo "it seems to work! very good."
-
fi
-
echo "================= /testing zlib using node ================="
+
set +x
+
if [ $? -ne 0 ]; then
+
echo "test failed for some reason"
+
exit 1;
+
else
+
echo "it seems to work! very good."
+
fi
+
echo "================= /testing zlib using node ================="
-
runHook postCheck
-
'';
+
runHook postCheck
+
'';
-
postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
-
substituteInPlace configure \
-
--replace-fail '/usr/bin/libtool' 'ar' \
-
--replace-fail 'AR="libtool"' 'AR="ar"' \
-
--replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"'
-
'';
-
})
+
postPatch = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
+
substituteInPlace configure \
+
--replace-fail '/usr/bin/libtool' 'ar' \
+
--replace-fail 'AR="libtool"' 'AR="ar"' \
+
--replace-fail 'ARFLAGS="-o"' 'ARFLAGS="-r"'
+
'';
+
})
```
:::{.example #usage-2-pkgs.buildemscriptenpackage}
+1 -4
doc/languages-frameworks/factor.section.md
···
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
-
{
-
factorPackages,
-
fetchFromGitHub,
-
}:
+
{ factorPackages, fetchFromGitHub }:
factorPackages.buildFactorVocab {
pname = "bresenham";
+1 -3
doc/languages-frameworks/gnome.section.md
···
```nix
{
-
buildInputs = [
-
pantheon.elementary-icon-theme
-
];
+
buildInputs = [ pantheon.elementary-icon-theme ];
preFixup = ''
gappsWrapperArgs+=(
# The icon theme is hardcoded.
+2 -6
doc/languages-frameworks/go.section.md
···
Tags can also be set conditionally:
```nix
-
{
-
tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ];
-
}
+
{ tags = [ "production" ] ++ lib.optionals withSqlite [ "sqlite" ]; }
```
### `deleteVendor` {#var-go-deleteVendor}
···
```nix
{
# -run and -skip accept regular expressions
-
checkFlags = [
-
"-run=^Test(Simple|Fast)$"
-
];
+
checkFlags = [ "-run=^Test(Simple|Fast)$" ];
}
```
+5 -7
doc/languages-frameworks/haskell.section.md
···
one provided by `haskellPackages`:
```nix
-
haskellPackages.nix-tree.override {
-
brick = haskellPackages.brick_0_67;
-
}
+
haskellPackages.nix-tree.override { brick = haskellPackages.brick_0_67; }
```
<!-- TODO(@sternenseemann): This belongs in the next section
···
install -Dm644 man/${drv.pname}.1 -t "$out/share/man/man1"
'';
});
-
in
+
in
installManPage haskellPackages.pnbackup
```
···
ghcName = "ghc92";
# Desired new setting
enableProfiling = true;
-
in
+
in
# 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
···
final: prev:
let
inherit (final) lib;
-
in
+
in
haskell = prev.haskell // {
compiler = prev.haskell.compiler // {
···
let
inherit (final) lib;
haskellLib = final.haskell.lib.compose;
-
in
+
in
haskell = prev.haskell // {
packages = prev.haskell.packages // {
+4 -12
doc/languages-frameworks/ios.section.md
···
let
pkgs = import <nixpkgs> { };
-
xcodeenv = import ./xcodeenv {
-
inherit (pkgs) stdenv;
-
};
+
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
in
xcodeenv.composeXcodeWrapper {
version = "9.2";
···
let
pkgs = import <nixpkgs> { };
-
xcodeenv = import ./xcodeenv {
-
inherit (pkgs) stdenv;
-
};
+
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
in
xcodeenv.buildApp {
name = "MyApp";
···
let
pkgs = import <nixpkgs> { };
-
xcodeenv = import ./xcodeenv {
-
inherit (pkgs) stdenv;
-
};
+
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
in
xcode.simulateApp {
name = "simulate";
···
let
pkgs = import <nixpkgs> { };
-
xcodeenv = import ./xcodeenv {
-
inherit (pkgs) stdenv;
-
};
+
xcodeenv = import ./xcodeenv { inherit (pkgs) stdenv; };
in
xcode.simulateApp {
name = "simulate";
+1 -5
doc/languages-frameworks/java.section.md
···
selecting a 'headless' build to avoid including a link to GTK+:
```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
+7 -17
doc/languages-frameworks/javascript.section.md
···
version = "0.1.0";
src = ./.;
-
npmDeps = importNpmLock {
-
npmRoot = ./.;
-
};
+
npmDeps = importNpmLock { npmRoot = ./.; };
npmConfigHook = importNpmLock.npmConfigHook;
}
···
`pnpm.configHook` supports adding additional `pnpm install` flags via `pnpmInstallFlags` which can be set to a Nix string array:
```nix
-
{
-
pnpm,
-
}:
+
{ pnpm }:
stdenv.mkDerivation (finalAttrs: {
pname = "foo";
···
pnpmInstallFlags = [ "--shamefully-hoist" ];
-
pnpmDeps = pnpm.fetchDeps {
-
inherit (finalAttrs) pnpmInstallFlags;
-
};
+
pnpmDeps = pnpm.fetchDeps { inherit (finalAttrs) pnpmInstallFlags; };
})
```
···
```nix
{
-
nativeBuildInputs = [
-
writableTmpDirAsHomeHook
-
];
+
nativeBuildInputs = [ writableTmpDirAsHomeHook ];
buildPhase = ''
runHook preBuild
···
The `distPhase` is packing the package's dependencies in a tarball using `yarn pack`. You can disable it using:
```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:
···
let
yarn-berry = yarn-berry_4;
-
in
+
in
stdenv.mkDerivation (finalAttrs: {
pname = "foo";
version = "0-unstable-1980-01-01";
···
let
yarn-berry = yarn-berry_4;
-
in
+
in
stdenv.mkDerivation (finalAttrs: {
pname = "foo";
version = "0-unstable-1980-01-01";
+2 -8
doc/languages-frameworks/lisp.section.md
···
let
sbcl' = sbcl.withPackages (ps: [ ps.alexandria ]);
in
-
mkShell {
-
packages = [ sbcl' ];
-
}
+
mkShell { packages = [ sbcl' ]; }
```
Such a Lisp can be now used e.g. to compile your sources:
···
hash = "sha256-1Hzxt65dZvgOFIljjjlSGgKYkj+YBLwJCACi5DZsKmQ=";
};
};
-
sbcl' = sbcl.withOverrides (
-
self: super: {
-
inherit alexandria;
-
}
-
);
+
sbcl' = sbcl.withOverrides (self: super: { inherit alexandria; });
in
sbcl'.pkgs.alexandria
```
+1 -3
doc/languages-frameworks/neovim.section.md
···
For instance:
```nix
{
-
rtp-nvim = neovimUtils.buildNeovimPlugin {
-
luaAttr = luaPackages.rtp-nvim;
-
};
+
rtp-nvim = neovimUtils.buildNeovimPlugin { luaAttr = luaPackages.rtp-nvim; };
}
```
To update these packages, you should use the lua updater rather than vim's.
+1 -3
doc/languages-frameworks/nim.section.md
···
lockFile = ./lock.json;
-
nimFlags = [
-
"-d:NimblePkgVersion=${finalAttrs.version}"
-
];
+
nimFlags = [ "-d:NimblePkgVersion=${finalAttrs.version}" ];
})
```
+1 -3
doc/languages-frameworks/octave.section.md
···
}:
pkgs.mkShell {
-
nativeBuildInputs = with pkgs; [
-
(octave.withPackages (opkgs: with opkgs; [ symbolic ]))
-
];
+
nativeBuildInputs = with pkgs; [ (octave.withPackages (opkgs: with opkgs; [ symbolic ])) ];
}
```
+1 -7
doc/languages-frameworks/php.section.md
···
# PHP version containing the `ast` extension enabled
php = php.buildEnv {
-
extensions = (
-
{ enabled, all }:
-
enabled
-
++ (with all; [
-
ast
-
])
-
);
+
extensions = ({ enabled, all }: enabled ++ (with all; [ ast ]));
};
# The composer vendor hash
+26 -89
doc/languages-frameworks/python.section.md
···
pluggy
];
-
nativeCheckInputs = [
-
hypothesis
-
];
+
nativeCheckInputs = [ hypothesis ];
meta = {
changelog = "https://github.com/pytest-dev/pytest/releases/tag/${version}";
···
python3MyBlas = pkgs.python3.override {
packageOverrides = self: super: {
# We need toPythonModule for the package set to evaluate this
-
blas = super.toPythonModule (
-
super.pkgs.blas.override {
-
blasProvider = super.pkgs.mkl;
-
}
-
);
-
lapack = super.toPythonModule (
-
super.pkgs.lapack.override {
-
lapackProvider = super.pkgs.mkl;
-
}
-
);
+
blas = super.toPythonModule (super.pkgs.blas.override { blasProvider = super.pkgs.mkl; });
+
lapack = super.toPythonModule (super.pkgs.lapack.override { lapackProvider = super.pkgs.mkl; });
};
};
}
···
hash = "sha256-Pe229rT0aHwA98s+nTHQMEFKZPo/yw6sot8MivFDvAw=";
};
-
build-system = with python3Packages; [
-
setuptools
-
];
+
build-system = with python3Packages; [ setuptools ];
dependencies = with python3Packages; [
tornado
···
applied to the reference:
```nix
-
{
-
python3Packages,
-
}:
+
{ python3Packages }:
python3Packages.toPythonApplication python3Packages.youtube-dl
```
···
pname = "psycopg2-binary";
inherit (psycopg2) optional-dependencies version;
dependencies = [ psycopg2 ];
-
meta = {
-
inherit (psycopg2.meta) description homepage;
-
};
+
meta = { inherit (psycopg2.meta) description homepage; };
}
```
···
pythonEnv = myPython.withPackages (ps: [ ps.my-editable ]);
in
-
pkgs.mkShell {
-
packages = [ pythonEnv ];
-
}
+
pkgs.mkShell { packages = [ pythonEnv ]; }
```
#### `python.buildEnv` function {#python.buildenv-function}
···
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
};
-
build-system = [
-
setuptools
-
];
+
build-system = [ setuptools ];
# has no tests
doCheck = false;
···
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
};
-
build-system = [
-
python313.pkgs.setuptools
-
];
+
build-system = [ python313.pkgs.setuptools ];
# has no tests
doCheck = false;
···
hash = "sha256-FLLvdm1MllKrgTGC6Gb0k0deZeVYvtCCLji/B7uhong=";
};
-
build-system = [
-
setuptools
-
];
+
build-system = [ setuptools ];
dependencies = [
multipledispatch
···
python-dateutil
];
-
nativeCheckInputs = [
-
pytestCheckHook
-
];
+
nativeCheckInputs = [ pytestCheckHook ];
meta = {
changelog = "https://github.com/blaze/datashape/releases/tag/${version}";
···
hash = "sha256-s9NiusRxFydHzaNRMjjxFcvWxfi45jGb9ql6eJJyQJk=";
};
-
build-system = [
-
setuptools
-
];
+
build-system = [ setuptools ];
buildInputs = [
libxml2
···
hash = "sha256-9ru2r6kwhUCaskiFoaPNuJCfCVoUL01J40byvRt4kHQ=";
};
-
build-system = [
-
setuptools
-
];
+
build-system = [ setuptools ];
buildInputs = [
fftw
···
Adding `pytest` is not required, since it is included with `pytestCheckHook`.
```nix
-
{
-
nativeCheckInputs = [
-
pytestCheckHook
-
];
-
}
+
{ nativeCheckInputs = [ pytestCheckHook ]; }
```
`pytestCheckHook` recognizes the following attributes:
···
```nix
-
nativeCheckInputs = [
-
pytestCheckHook
-
];
+
nativeCheckInputs = [ pytestCheckHook ];
# Allow running the following test paths and test objects.
enabledTestPaths = [
···
__structuredAttrs = true;
-
disabledTests = [
-
"Foo and bar"
-
];
+
disabledTests = [ "Foo and bar" ];
```
···
"pkg1"
"pkg3"
];
-
pythonRemoveDeps = [
-
"pkg2"
-
];
+
pythonRemoveDeps = [ "pkg2" ];
```
···
example:
```nix
-
{
-
pythonRelaxDeps = true;
-
}
+
{ pythonRelaxDeps = true; }
```
which would result in the following `requirements.txt` file:
···
```nix
-
nativeCheckInputs = [
-
unittestCheckHook
-
];
+
nativeCheckInputs = [ unittestCheckHook ];
unittestFlags = [
"-s"
···
"doc"
];
-
nativeBuildInputs = [
-
sphinxHook
-
];
+
nativeBuildInputs = [ sphinxHook ];
```
···
hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA=";
};
-
build-system = [
-
setuptools
-
];
+
build-system = [ setuptools ];
meta = {
changelog = "https://github.com/pytoolz/toolz/releases/tag/${version}";
···
});
};
in
-
pkgs.python310.override {
-
inherit packageOverrides;
-
};
+
pkgs.python310.override { inherit packageOverrides; };
in
-
python.withPackages (ps: [
-
ps.pandas
-
])
+
python.withPackages (ps: [ ps.pandas ])
).env
```
···
let
-
packageOverrides = self: super: {
-
scipy = super.scipy_0_17;
-
};
+
packageOverrides = self: super: { scipy = super.scipy_0_17; };
in
-
(pkgs.python310.override {
-
inherit packageOverrides;
-
}).withPackages
-
(ps: [
-
ps.blaze
-
])
+
(pkgs.python310.override { inherit packageOverrides; }).withPackages (ps: [ ps.blaze ])
).env
```
···
```nix
-
myPythonPackages = python3Packages.override {
-
overrides = self: super: {
-
twisted = <...>;
-
};
-
};
+
myPythonPackages = python3Packages.override { overrides = self: super: { twisted = <...>; }; };
```
+1 -1
doc/languages-frameworks/qt.section.md
···
stdenv.mkDerivation {
# ...
nativeBuildInputs = [ qt6.wrapQtAppsHook ];
-
qtWrapperArgs = [ ''--prefix PATH : /path/to/bin'' ];
+
qtWrapperArgs = [ "--prefix PATH : /path/to/bin" ];
}
```
+6 -2
doc/languages-frameworks/ruby.section.md
···
myRuby = pkgs.ruby.override {
defaultGemConfig = pkgs.defaultGemConfig // {
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"
+
];
};
};
};
···
gemdir = ./.;
gemConfig = pkgs.defaultGemConfig // {
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"
+
];
};
};
};
+4 -12
doc/languages-frameworks/rust.section.md
···
:::
```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
···
`cargoHash` as follows:
```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)
···
`importCargoLock` can be used as follows:
```nix
-
{
-
cargoDeps = rustPlatform.importCargoLock {
-
lockFile = ./Cargo.lock;
-
};
-
}
+
{ cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; }; }
```
If the `Cargo.lock` file includes git dependencies, then their output
···
cargo = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
rustc = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
};
-
in
+
in
rustPlatform.buildRustPackage (finalAttrs: {
pname = "ripgrep";
version = "14.1.1";
-1
doc/languages-frameworks/scheme.section.md
···
akkuPackages.chez-srfi
];
}
-
```
The package index is located in `pkgs/tools/package-management/akku`
+4 -10
doc/languages-frameworks/swift.section.md
···
let
# Pass the generated files to the helper.
generated = swiftpm2nix.helpers ./nix;
-
in
+
in
stdenv.mkDerivation (finalAttrs: {
pname = "myproject";
version = "0.0.0";
···
If you'd like to build a different configuration than `release`:
```nix
-
{
-
swiftpmBuildConfig = "debug";
-
}
+
{ swiftpmBuildConfig = "debug"; }
```
It is also possible to provide additional flags to `swift build`:
```nix
-
{
-
swiftpmFlags = [ "--disable-dead-strip" ];
-
}
+
{ swiftpmFlags = [ "--disable-dead-strip" ]; }
```
The default `buildPhase` already passes `-j` for parallel building.
···
`checkPhase`, but it must be enabled with:
```nix
-
{
-
doCheck = true;
-
}
+
{ doCheck = true; }
```
This essentially runs: `swift test -c release`
+17 -25
doc/languages-frameworks/texlive.section.md
···
latex_with_foiltex = texliveSmall.withPackages (_: [ foiltex ]);
in
-
runCommand "test.pdf"
-
{
-
nativeBuildInputs = [ latex_with_foiltex ];
-
}
-
''
-
cat >test.tex <<EOF
-
\documentclass{foils}
+
runCommand "test.pdf" { nativeBuildInputs = [ latex_with_foiltex ]; } ''
+
cat >test.tex <<EOF
+
\documentclass{foils}
-
\title{Presentation title}
-
\date{}
+
\title{Presentation title}
+
\date{}
-
\begin{document}
-
\maketitle
-
\end{document}
-
EOF
-
pdflatex test.tex
-
cp test.pdf $out
-
''
+
\begin{document}
+
\maketitle
+
\end{document}
+
EOF
+
pdflatex test.tex
+
cp test.pdf $out
+
''
```
## LuaLaTeX font cache {#sec-language-texlive-lualatex-font-cache}
···
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):
```nix
-
runCommandNoCC "lualatex-hello-world"
-
{
-
buildInputs = [ texliveFull ];
-
}
-
''
-
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
-
''
+
runCommandNoCC "lualatex-hello-world" { buildInputs = [ texliveFull ]; } ''
+
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).
+2 -7
doc/languages-frameworks/typst.section.md
···
typstPackages = old.typstPackages.extend (
_: previous: {
polylux_0_4_0 = previous.polylux_0_4_0.overrideAttrs (oldPolylux: {
-
src = oldPolylux.src.overrideAttrs {
-
outputHash = YourUpToDatePolyluxHash;
-
};
+
src = oldPolylux.src.overrideAttrs { outputHash = YourUpToDatePolyluxHash; };
});
}
);
···
Here's how to define a custom Typst package:
```nix
-
{
-
buildTypstPackage,
-
typstPackages,
-
}:
+
{ buildTypstPackage, typstPackages }:
buildTypstPackage (finalAttrs: {
pname = "my-typst-package";
+5 -11
doc/packages/cataclysm-dda.section.md
···
`$XDG_CONFIG_HOME/cataclysm-dda`, override the derivation:
```nix
-
cataclysm-dda.override {
-
useXdgDir = true;
-
}
+
cataclysm-dda.override { useXdgDir = true; }
```
## Important note for overriding packages {#important-note-for-overriding-packages}
···
# or by using a helper function `attachPkgs`.
goodExample2 = attachPkgs pkgs myCDDA;
-
in
-
# badExample # parallel building disabled
-
# goodExample1.withMods (_: []) # parallel building enabled
+
# badExample # parallel building disabled
+
# goodExample1.withMods (_: []) # parallel building enabled
+
in
goodExample2.withMods (_: [ ]) # parallel building enabled
```
···
attribute:
```nix
-
cataclysm-dda.withMods (
-
mods: with mods; [
-
tileset.UndeadPeople
-
]
-
)
+
cataclysm-dda.withMods (mods: with mods; [ tileset.UndeadPeople ])
```
All mods, soundpacks, and tilesets available in nixpkgs are found in
+1 -3
doc/packages/inkscape.section.md
···
```nix
inkscape-with-extensions.override {
-
inkscapeExtensions = with inkscape-extensions; [
-
inkstitch
-
];
+
inkscapeExtensions = with inkscape-extensions; [ inkstitch ];
}
```
+1 -3
doc/packages/kakoune.section.md
···
Kakoune can be built to autoload plugins:
```nix
-
(kakoune.override {
-
plugins = with pkgs.kakounePlugins; [ parinfer-rust ];
-
})
+
(kakoune.override { plugins = with pkgs.kakounePlugins; [ parinfer-rust ]; })
```
+1 -3
doc/packages/urxvt.section.md
···
If the plugin is itself a Perl package that needs to be imported from other plugins or scripts, add the following passthrough:
```nix
-
{
-
passthru.perlPackages = [ "self" ];
-
}
+
{ passthru.perlPackages = [ "self" ]; }
```
This will make the urxvt wrapper pick up the dependency and set up the Perl path accordingly.
+1 -1
doc/release-notes/rl-2505.section.md
···
```nix
let
pkgs = import <nixpkgs> { };
-
in
+
in
pkgs.caddy.withPlugins {
plugins = [
# tagged upstream
+6 -16
doc/stdenv/cross-compilation.chapter.md
···
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
-
{
-
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}
···
Add the following to your `mkDerivation` invocation.
```nix
-
{
-
depsBuildBuild = [ buildPackages.stdenv.cc ];
-
}
+
{ depsBuildBuild = [ buildPackages.stdenv.cc ]; }
```
#### My package’s testsuite needs to run host platform code. {#cross-testsuite-runs-host-code}
···
Add the following to your `mkDerivation` invocation.
```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}
···
```nix
{
-
nativeBuildInputs =
-
[
-
meson
-
]
-
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
-
mesonEmulatorHook
-
];
+
nativeBuildInputs = [
+
meson
+
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ mesonEmulatorHook ];
}
```
+2 -6
doc/stdenv/meta.chapter.md
···
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
-
{
-
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.
···
- Does not cross compile
```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
+5 -17
doc/stdenv/stdenv.chapter.md
···
# An example of an attribute containing a function
passthru.appendPackages =
packages':
-
finalAttrs.finalPackage.overrideAttrs (
-
newSelf: super: {
-
packages = super.packages ++ packages';
-
}
-
);
+
finalAttrs.finalPackage.overrideAttrs (newSelf: super: { packages = super.packages ++ packages'; });
# For illustration purposes; referenced as
# `(pkg.overrideAttrs(x)).finalAttrs` etc in the text 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
-
{
-
makeFlags = [ "PREFIX=$(out)" ];
-
}
+
{ makeFlags = [ "PREFIX=$(out)" ]; }
```
::: {.note}
···
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
-
{
-
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.
···
The make targets that perform the installation. Defaults to `install`. Example:
```nix
-
{
-
installTargets = "install-bin install-doc";
-
}
+
{ installTargets = "install-bin install-doc"; }
```
##### `installFlags` / `installFlagsArray` {#var-stdenv-installFlags}
···
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
-
{
-
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.
+6 -24
doc/using/configuration.chapter.md
···
A user's Nixpkgs configuration is stored in a user-specific configuration file located at `~/.config/nixpkgs/config.nix`. For example:
```nix
-
{
-
allowUnfree = true;
-
}
+
{ allowUnfree = true; }
```
:::{.caution}
···
- For permanently allowing broken packages to be built, you may add `allowBroken = true;` to your user's configuration file, like this:
```nix
-
{
-
allowBroken = true;
-
}
+
{ allowBroken = true; }
```
···
- For permanently allowing unsupported packages to be built, you may add `allowUnsupportedSystem = true;` to your user's configuration file, like this:
```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.
···
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
-
{
-
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:
···
The following example configuration permits the installation of the hypothetically insecure package `hello`, version `1.2.3`:
```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.
···
The following configuration example allows any version of the `ovftool` package:
```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.
+6 -18
doc/using/overlays.chapter.md
···
self: super:
{
-
boost = super.boost.override {
-
python = self.python3;
-
};
-
rr = super.callPackage ./pkgs/rr {
-
stdenv = self.stdenv_32bit;
-
};
+
boost = super.boost.override { python = self.python3; };
+
rr = super.callPackage ./pkgs/rr { stdenv = self.stdenv_32bit; };
}
```
···
self: super:
{
-
blas = super.blas.override {
-
blasProvider = self.mkl;
-
};
+
blas = super.blas.override { blasProvider = self.mkl; };
-
lapack = super.lapack.override {
-
lapackProvider = self.mkl;
-
};
+
lapack = super.lapack.override { lapackProvider = self.mkl; };
}
```
···
self: super:
{
-
blas = super.blas.override {
-
blasProvider = self.lapack-reference;
-
};
+
blas = super.blas.override { blasProvider = self.lapack-reference; };
-
lapack = super.lapack.override {
-
lapackProvider = self.lapack-reference;
-
};
+
lapack = super.lapack.override { lapackProvider = self.lapack-reference; };
}
```
+3 -13
doc/using/overrides.chapter.md
···
```nix
import pkgs.path {
-
overlays = [
-
(self: super: {
-
foo = super.foo.override { barSupport = true; };
-
})
-
];
+
overlays = [ (self: super: { foo = super.foo.override { barSupport = true; }; }) ];
}
```
···
```nix
{
helloBar = pkgs.hello.overrideAttrs (
-
finalAttrs: previousAttrs: {
-
pname = previousAttrs.pname + "-bar";
-
}
+
finalAttrs: previousAttrs: { pname = previousAttrs.pname + "-bar"; }
);
}
```
···
Function arguments can be omitted entirely if there is no need to access `previousAttrs` or `finalAttrs`.
```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`.
+2 -4
maintainers/README.md
···
Given a maintainer entry like this:
-
``` nix
+
```nix
{
example = {
email = "user@example.com";
name = "Example User";
-
keys = [{
-
fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE";
-
}];
+
keys = [ { fingerprint = "0000 0000 2A70 6423 0AED 3C11 F04F 7A19 AAA6 3AFE"; } ];
};
}
```
+2 -4
nixos/doc/manual/administration/container-networking.section.md
···
```nix
{
networking.nat.enable = true;
-
networking.nat.internalInterfaces = ["ve-+"];
+
networking.nat.internalInterfaces = [ "ve-+" ];
networking.nat.externalInterface = "eth0";
}
```
···
managing container interfaces:
```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.
+2 -6
nixos/doc/manual/administration/control-groups.chapter.md
···
`configuration.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
···
`httpd.service` to 512 MiB of RAM (excluding swap):
```nix
-
{
-
systemd.services.httpd.serviceConfig.MemoryLimit = "512M";
-
}
+
{ systemd.services.httpd.serviceConfig.MemoryLimit = "512M"; }
```
The command `systemd-cgtop` shows a continuously updated list of all
+7 -6
nixos/doc/manual/administration/declarative-containers.section.md
···
```nix
{
-
containers.database =
-
{ config =
-
{ config, pkgs, ... }:
-
{ services.postgresql.enable = true;
+
containers.database = {
+
config =
+
{ config, pkgs, ... }:
+
{
+
services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql_14;
-
};
-
};
+
};
+
};
}
```
+1 -3
nixos/doc/manual/administration/service-mgmt.chapter.md
···
package, use (e.g):
```nix
-
{
-
systemd.packages = [ pkgs.packagekit ];
-
}
+
{ systemd.packages = [ pkgs.packagekit ]; }
```
Usually NixOS modules written by the community do the above, plus take
+52 -36
nixos/doc/manual/configuration/abstractions.section.md
···
```nix
{
-
services.httpd.virtualHosts =
-
{ "blog.example.org" = {
-
documentRoot = "/webroot/blog.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;
-
};
+
services.httpd.virtualHosts = {
+
"blog.example.org" = {
+
documentRoot = "/webroot/blog.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`:
```nix
let
-
commonConfig =
-
{ adminAddr = "alice@example.org";
-
forceSSL = true;
-
enableACME = true;
-
};
+
commonConfig = {
+
adminAddr = "alice@example.org";
+
forceSSL = true;
+
enableACME = true;
+
};
in
{
-
services.httpd.virtualHosts =
-
{ "blog.example.org" = (commonConfig // { documentRoot = "/webroot/blog.example.org"; });
-
"wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.org"; });
-
};
+
services.httpd.virtualHosts = {
+
"blog.example.org" = (commonConfig // { documentRoot = "/webroot/blog.example.org"; });
+
"wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.org"; });
+
};
}
```
···
```nix
{
services.httpd.virtualHosts =
-
let commonConfig = { /* ... */ }; in
-
{ "blog.example.org" = (commonConfig // { /* ... */ });
-
"wiki.example.org" = (commonConfig // { /* ... */ });
+
let
+
commonConfig = {
+
# ...
+
};
+
in
+
{
+
"blog.example.org" = (
+
commonConfig
+
// {
+
# ...
+
}
+
);
+
"wiki.example.org" = (
+
commonConfig
+
// {
+
# ...
+
}
+
);
};
}
```
···
{
services.httpd.virtualHosts =
let
-
makeVirtualHost = webroot:
-
{ documentRoot = webroot;
-
adminAddr = "alice@example.org";
-
forceSSL = 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");
+
makeVirtualHost = webroot: {
+
documentRoot = webroot;
+
adminAddr = "alice@example.org";
+
forceSSL = 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");
+
};
}
```
+3 -4
nixos/doc/manual/configuration/ad-hoc-network-config.section.md
···
```nix
{
-
networking.localCommands =
-
''
-
ip -6 addr add 2001:610:685:1::1/64 dev eth0
-
'';
+
networking.localCommands = ''
+
ip -6 addr add 2001:610:685:1::1/64 dev eth0
+
'';
}
```
+11 -13
nixos/doc/manual/configuration/adding-custom-packages.section.md
···
Finally, you add it to [](#opt-environment.systemPackages), e.g.
```nix
-
{
-
environment.systemPackages = [ pkgs.my-package ];
-
}
+
{ environment.systemPackages = [ pkgs.my-package ]; }
```
and you run `nixos-rebuild`, specifying your own Nixpkgs tree:
···
{
environment.systemPackages =
let
-
my-hello = with pkgs; stdenv.mkDerivation rec {
-
name = "hello-2.8";
-
src = fetchurl {
-
url = "mirror://gnu/hello/${name}.tar.gz";
-
hash = "sha256-5rd/gffPfa761Kn1tl3myunD8TuM+66oy1O7XqVGDXM=";
+
my-hello =
+
with pkgs;
+
stdenv.mkDerivation rec {
+
name = "hello-2.8";
+
src = fetchurl {
+
url = "mirror://gnu/hello/${name}.tar.gz";
+
hash = "sha256-5rd/gffPfa761Kn1tl3myunD8TuM+66oy1O7XqVGDXM=";
+
};
};
-
};
in
[ my-hello ];
}
···
separate Nix expression, e.g.
```nix
-
{
-
environment.systemPackages = [ (import ./my-hello.nix) ];
-
}
+
{ environment.systemPackages = [ (import ./my-hello.nix) ]; }
```
where `my-hello.nix` contains:
```nix
-
with import <nixpkgs> {}; # bring all of Nixpkgs into scope
+
with import <nixpkgs> { }; # bring all of Nixpkgs into scope
stdenv.mkDerivation rec {
name = "hello-2.8";
+6 -3
nixos/doc/manual/configuration/config-file.section.md
···
```nix
{ config, pkgs, ... }:
-
{ /* option definitions */
+
{
+
# option definitions
}
```
···
```nix
{ config, pkgs, ... }:
-
{ services.httpd.enable = true;
+
{
+
services.httpd.enable = true;
services.httpd.adminAddr = "alice@example.org";
services.httpd.virtualHosts.localhost.documentRoot = "/webroot";
}
···
```nix
{ config, pkgs, ... }:
-
{ services = {
+
{
+
services = {
httpd = {
enable = true;
adminAddr = "alice@example.org";
+12 -14
nixos/doc/manual/configuration/customizing-packages.section.md
···
{
environment.systemPackages = with pkgs; [
sl
-
(pass.withExtensions (subpkgs: with subpkgs; [
-
pass-audit
-
pass-otp
-
pass-genphrase
-
]))
-
(python3.withPackages (subpkgs: with subpkgs; [
-
requests
-
]))
+
(pass.withExtensions (
+
subpkgs: with subpkgs; [
+
pass-audit
+
pass-otp
+
pass-genphrase
+
]
+
))
+
(python3.withPackages (subpkgs: with subpkgs; [ requests ]))
cowsay
];
}
···
specify that as follows:
```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
···
```nix
{
-
nixpkgs.config.packageOverrides = pkgs:
-
{ emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
-
};
+
nixpkgs.config.packageOverrides = pkgs: {
+
emacs = pkgs.emacs.override { gtk = pkgs.gtk3; };
+
};
}
```
+1 -3
nixos/doc/manual/configuration/declarative-packages.section.md
···
email application:
```nix
-
{
-
environment.systemPackages = [ pkgs.thunderbird ];
-
}
+
{ environment.systemPackages = [ pkgs.thunderbird ]; }
```
The effect of this specification is that the Thunderbird package from
+4 -4
nixos/doc/manual/configuration/file-systems.chapter.md
···
```nix
{
-
fileSystems."/data" =
-
{ device = "/dev/disk/by-label/data";
-
fsType = "ext4";
-
};
+
fileSystems."/data" = {
+
device = "/dev/disk/by-label/data";
+
fsType = "ext4";
+
};
}
```
+13 -6
nixos/doc/manual/configuration/firewall.section.md
···
traffic. It is enabled by default. It can be disabled as follows:
```nix
-
{
-
networking.firewall.enable = false;
-
}
+
{ networking.firewall.enable = false; }
```
If the firewall is enabled, you can open specific TCP ports to the
···
```nix
{
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
}
```
···
```nix
{
networking.firewall.allowedTCPPortRanges = [
-
{ from = 4000; to = 4007; }
-
{ from = 8000; to = 8010; }
+
{
+
from = 4000;
+
to = 4007;
+
}
+
{
+
from = 8000;
+
to = 8010;
+
}
];
}
```
+7 -28
nixos/doc/manual/configuration/gpu-accel.chapter.md
···
enables OpenCL support:
```nix
-
{
-
hardware.graphics.extraPackages = [
-
rocmPackages.clr.icd
-
];
-
}
+
{ hardware.graphics.extraPackages = [ rocmPackages.clr.icd ]; }
```
### Intel {#sec-gpu-accel-opencl-intel}
···
configuration can be used:
```nix
-
{
-
hardware.graphics.extraPackages = [
-
intel-compute-runtime
-
];
-
}
+
{ hardware.graphics.extraPackages = [ intel-compute-runtime ]; }
```
## Vulkan {#sec-gpu-accel-vulkan}
···
```nix
{
-
hardware.graphics.extraPackages = [
-
pkgs.amdvlk
-
];
+
hardware.graphics.extraPackages = [ pkgs.amdvlk ];
# To enable Vulkan support for 32-bit applications, also add:
-
hardware.graphics.extraPackages32 = [
-
pkgs.driversi686Linux.amdvlk
-
];
+
hardware.graphics.extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];
# Force radv
environment.variables.AMD_VULKAN_ICD = "RADV";
# Or
-
environment.variables.VK_ICD_FILENAMES =
-
"/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
+
environment.variables.VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
}
```
···
Modern Intel GPUs use the iHD driver, which can be installed with:
```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:
```nix
-
{
-
hardware.graphics.extraPackages = [
-
intel-vaapi-driver
-
];
-
}
+
{ hardware.graphics.extraPackages = [ intel-vaapi-driver ]; }
```
## Common issues {#sec-gpu-accel-common-issues}
+7 -7
nixos/doc/manual/configuration/ipv4-config.section.md
···
```nix
{
-
networking.interfaces.eth0.ipv4.addresses = [ {
-
address = "192.168.1.2";
-
prefixLength = 24;
-
} ];
+
networking.interfaces.eth0.ipv4.addresses = [
+
{
+
address = "192.168.1.2";
+
prefixLength = 24;
+
}
+
];
}
```
···
The host name is set using [](#opt-networking.hostName):
```nix
-
{
-
networking.hostName = "cartman";
-
}
+
{ networking.hostName = "cartman"; }
```
The default host name is `nixos`. Set it to the empty string (`""`) to
+8 -10
nixos/doc/manual/configuration/ipv6-config.section.md
···
IPv6 support globally by setting:
```nix
-
{
-
networking.enableIPv6 = false;
-
}
+
{ networking.enableIPv6 = false; }
```
You can disable IPv6 on a single interface using a normal sysctl (in
this example, we use interface `eth0`):
```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
···
```nix
{
-
networking.interfaces.eth0.ipv6.addresses = [ {
-
address = "fe00:aa:bb:cc::2";
-
prefixLength = 64;
-
} ];
+
networking.interfaces.eth0.ipv6.addresses = [
+
{
+
address = "fe00:aa:bb:cc::2";
+
prefixLength = 64;
+
}
+
];
}
```
+6 -7
nixos/doc/manual/configuration/kubernetes.chapter.md
···
addonManager, kube-proxy and etcd:
```nix
-
{
-
services.kubernetes.roles = [ "master" ];
-
}
+
{ services.kubernetes.roles = [ "master" ]; }
```
While this will enable the kubelet and kube-proxy only:
```nix
-
{
-
services.kubernetes.roles = [ "node" ];
-
}
+
{ services.kubernetes.roles = [ "node" ]; }
```
Assigning both the master and node roles is usable if you want a single
···
```nix
{
-
services.kubernetes.roles = [ "master" "node" ];
+
services.kubernetes.roles = [
+
"master"
+
"node"
+
];
}
```
+17 -19
nixos/doc/manual/configuration/linux-kernel.chapter.md
···
kernel:
```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
···
```nix
{
-
nixpkgs.config.packageOverrides = pkgs: pkgs.lib.recursiveUpdate pkgs {
-
linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {
-
extraConfig = ''
-
KGDB y
-
'';
+
nixpkgs.config.packageOverrides =
+
pkgs:
+
pkgs.lib.recursiveUpdate pkgs {
+
linuxKernel.kernels.linux_5_10 = pkgs.linuxKernel.kernels.linux_5_10.override {
+
extraConfig = ''
+
KGDB y
+
'';
+
};
};
-
};
}
```
···
```nix
{
-
boot.kernelModules = [ "fuse" "kvm-intel" "coretemp" ];
+
boot.kernelModules = [
+
"fuse"
+
"kvm-intel"
+
"coretemp"
+
];
}
```
···
file system), you can use [](#opt-boot.initrd.kernelModules):
```nix
-
{
-
boot.initrd.kernelModules = [ "cifs" ];
-
}
+
{ boot.initrd.kernelModules = [ "cifs" ]; }
```
This causes the specified modules and their dependencies to be added to
···
[](#opt-boot.kernel.sysctl), e.g.
```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
···
To use your custom kernel package in your NixOS configuration, set
```nix
-
{
-
boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel;
-
}
+
{ boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; }
```
## Rust {#sec-linux-rust}
+4 -7
nixos/doc/manual/configuration/luks-file-systems.section.md
···
encrypted partition, it is necessary to add the following grub option:
```nix
-
{
-
boot.loader.grub.enableCryptodisk = true;
-
}
+
{ boot.loader.grub.enableCryptodisk = true; }
```
## FIDO2 {#sec-luks-file-systems-fido2}
···
```nix
{
boot.initrd.luks.fido2Support = true;
-
boot.initrd.luks.devices."/dev/sda2".fido2.credential = "f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";
+
boot.initrd.luks.devices."/dev/sda2".fido2.credential =
+
"f1d00200108b9d6e849a8b388da457688e3dd653b4e53770012d8f28e5d3b269865038c346802f36f3da7278b13ad6a3bb6a1452e24ebeeaa24ba40eef559b1b287d2a2f80b7";
}
```
···
as [Trezor](https://trezor.io/).
```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}
+3 -5
nixos/doc/manual/configuration/mattermost.chapter.md
···
{
services.mattermost = {
plugins = with pkgs; [
-
/*
-
* todo
-
* 0.7.1
-
* https://github.com/mattermost/mattermost-plugin-todo/releases/tag/v0.7.1
-
*/
+
# todo
+
# 0.7.1
+
# https://github.com/mattermost/mattermost-plugin-todo/releases/tag/v0.7.1
(fetchurl {
# 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";
+21 -16
nixos/doc/manual/configuration/modularity.section.md
···
```nix
{ config, pkgs, ... }:
-
{ imports = [ ./vpn.nix ./kde.nix ];
+
{
+
imports = [
+
./vpn.nix
+
./kde.nix
+
];
services.httpd.enable = true;
environment.systemPackages = [ pkgs.emacs ];
# ...
···
```nix
{ config, pkgs, ... }:
-
{ services.xserver.enable = true;
+
{
+
services.xserver.enable = true;
services.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
environment.systemPackages = [ pkgs.vim ];
···
merged list. If you want it to appear first, you can use `mkBefore`:
```nix
-
{
-
boot.kernelModules = mkBefore [ "kvm-intel" ];
-
}
+
{ boot.kernelModules = mkBefore [ "kvm-intel" ]; }
```
This causes the `kvm-intel` kernel module to be loaded before any other
···
over the others:
```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
···
```nix
{ config, pkgs, ... }:
-
{ environment.systemPackages =
+
{
+
environment.systemPackages =
if config.services.xserver.enable then
-
[ pkgs.firefox
+
[
+
pkgs.firefox
pkgs.thunderbird
]
else
···
```nix
{ config, pkgs, ... }:
-
let netConfig = hostName: {
-
networking.hostName = hostName;
-
networking.useDHCP = false;
-
};
+
let
+
netConfig = hostName: {
+
networking.hostName = hostName;
+
networking.useDHCP = false;
+
};
in
-
-
{ imports = [ (netConfig "nixos.localdomain") ]; }
+
{
+
imports = [ (netConfig "nixos.localdomain") ];
+
}
```
+5 -7
nixos/doc/manual/configuration/network-manager.section.md
···
NetworkManager. You can enable NetworkManager by setting:
```nix
-
{
-
networking.networkmanager.enable = true;
-
}
+
{ networking.networkmanager.enable = true; }
```
some desktop managers (e.g., GNOME) enable NetworkManager automatically
···
belong to the `networkmanager` group:
```nix
-
{
-
users.users.alice.extraGroups = [ "networkmanager" ];
-
}
+
{ users.users.alice.extraGroups = [ "networkmanager" ]; }
```
NetworkManager is controlled using either `nmcli` or `nmtui`
···
```nix
{
networking.networkmanager.unmanaged = [
-
"*" "except:type:wwan" "except:type:gsm"
+
"*"
+
"except:type:wwan"
+
"except:type:gsm"
];
}
```
+1 -5
nixos/doc/manual/configuration/profiles.chapter.md
···
`/etc/configuration.nix` as such:
```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
+2 -5
nixos/doc/manual/configuration/ssh.section.md
···
Secure shell (SSH) access to your machine can be enabled by setting:
```nix
-
{
-
services.openssh.enable = true;
-
}
+
{ services.openssh.enable = true; }
```
By default, root logins using a password are disallowed. They can be
···
```nix
{
-
users.users.alice.openssh.authorizedKeys.keys =
-
[ "ssh-ed25519 AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];
+
users.users.alice.openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAB3NzaC1kc3MAAACBAPIkGWVEt4..." ];
}
```
+19 -18
nixos/doc/manual/configuration/sshfs-file-systems.section.md
···
fileSystems."/mnt/my-dir" = {
device = "my-user@example.com:/my-dir/";
fsType = "sshfs";
-
options =
-
[ # Filesystem options
-
"allow_other" # for non-root access
-
"_netdev" # this is a network fs
-
"x-systemd.automount" # mount on demand
+
options = [
+
# Filesystem options
+
"allow_other" # for non-root access
+
"_netdev" # this is a network fs
+
"x-systemd.automount" # mount on demand
-
# SSH options
-
"reconnect" # handle connection drops
-
"ServerAliveInterval=15" # keep connections alive
-
"IdentityFile=/var/secrets/example-key"
-
];
+
# SSH options
+
"reconnect" # handle connection drops
+
"ServerAliveInterval=15" # keep connections alive
+
"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:
```nix
{
-
options =
-
[ "ProxyJump=bastion@example.com"
-
"Port=22"
-
];
+
options = [
+
"ProxyJump=bastion@example.com"
+
"Port=22"
+
];
}
```
It's also possible to change the `ssh` command used by SSHFS to connect to the server.
For example:
```nix
{
-
options =
-
[ (builtins.replaceStrings [" "] ["\\040"]
-
"ssh_command=${pkgs.openssh}/bin/ssh -v -L 8080:localhost:80")
-
];
+
options = [
+
(builtins.replaceStrings [ " " ] [ "\\040" ]
+
"ssh_command=${pkgs.openssh}/bin/ssh -v -L 8080:localhost:80"
+
)
+
];
}
```
+28 -19
nixos/doc/manual/configuration/subversion.chapter.md
···
{
services.httpd.enable = true;
services.httpd.adminAddr = "...";
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
}
```
···
```nix
{
services.httpd.extraModules = [
-
# 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"; }
-
];
-
services.httpd.virtualHosts = {
-
"svn" = {
-
hostName = HOSTNAME;
-
documentRoot = DOCUMENTROOT;
-
locations."/svn".extraConfig = ''
-
DAV svn
-
SVNParentPath REPO_PARENT
-
AuthzSVNAccessFile ACCESS_FILE
-
AuthName "SVN Repositories"
-
AuthType Basic
-
AuthUserFile PASSWORD_FILE
-
Require valid-user
-
'';
-
};
+
# 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";
+
}
+
];
+
services.httpd.virtualHosts = {
+
"svn" = {
+
hostName = HOSTNAME;
+
documentRoot = DOCUMENTROOT;
+
locations."/svn".extraConfig = ''
+
DAV svn
+
SVNParentPath REPO_PARENT
+
AuthzSVNAccessFile ACCESS_FILE
+
AuthName "SVN Repositories"
+
AuthType Basic
+
AuthUserFile PASSWORD_FILE
+
Require valid-user
+
'';
};
+
};
}
```
+9 -16
nixos/doc/manual/configuration/user-mgmt.chapter.md
···
isNormalUser = true;
home = "/home/alice";
description = "Alice Foobar";
-
extraGroups = [ "wheel" "networkmanager" ];
+
extraGroups = [
+
"wheel"
+
"networkmanager"
+
];
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
};
}
···
manually by adding
```nix
-
{
-
uid = 1000;
-
}
+
{ uid = 1000; }
```
to the user specification.
···
named `students` shall exist:
```nix
-
{
-
users.groups.students.gid = 1000;
-
}
+
{ users.groups.students.gid = 1000; }
```
As with users, the group ID (gid) is optional and will be assigned
···
systemd-sysusers:
```nix
-
{
-
systemd.sysusers.enable = true;
-
}
+
{ systemd.sysusers.enable = true; }
```
The primary benefit of this is to remove a dependency on perl.
···
You can enable Userborn via:
```nix
-
{
-
services.userborn.enable = true;
-
}
+
{ services.userborn.enable = true; }
```
You can configure Userborn to store the password files
···
location to `/etc`:
```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
+1 -3
nixos/doc/manual/configuration/wayland.chapter.md
···
server:
```nix
-
{
-
programs.sway.enable = true;
-
}
+
{ programs.sway.enable = true; }
```
This installs the sway compositor along with some essential utilities.
+8 -7
nixos/doc/manual/configuration/wireless.section.md
···
NixOS will start wpa_supplicant for you if you enable this setting:
```nix
-
{
-
networking.wireless.enable = true;
-
}
+
{ networking.wireless.enable = true; }
```
NixOS lets you specify networks for wpa_supplicant declaratively:
···
```nix
{
networking.wireless.networks = {
-
echelon = { # SSID with no spaces or special characters
+
echelon = {
+
# SSID with no spaces or special characters
psk = "abcdefgh";
};
-
"echelon's AP" = { # SSID with spaces and/or special characters
+
"echelon's AP" = {
+
# SSID with spaces and/or special characters
psk = "ijklmnop";
};
-
echelon = { # Hidden SSID
+
echelon = {
+
# Hidden SSID
hidden = true;
psk = "qrstuvwx";
};
-
free.wifi = {}; # Public wireless network
+
free.wifi = { }; # Public wireless network
};
}
```
+14 -32
nixos/doc/manual/configuration/x-windows.chapter.md
···
interface. It can be enabled as follows:
```nix
-
{
-
services.xserver.enable = true;
-
}
+
{ services.xserver.enable = true; }
```
The X server will automatically detect and use the appropriate video
···
also specify a driver manually, e.g.
```nix
-
{
-
services.xserver.videoDrivers = [ "r128" ];
-
}
+
{ services.xserver.videoDrivers = [ "r128" ]; }
```
to enable X.org's `xf86-video-r128` driver.
···
this to happen, you can set:
```nix
-
{
-
services.xserver.autorun = false;
-
}
+
{ services.xserver.autorun = false; }
```
The X server can then be started manually:
···
Wine, you should also set the following:
```nix
-
{
-
hardware.graphics.enable32Bit = true;
-
}
+
{ hardware.graphics.enable32Bit = true; }
```
## Auto-login {#sec-x11-auto-login}
···
your window manager, you'd define:
```nix
-
{
-
services.displayManager.defaultSession = "none+i3";
-
}
+
{ services.displayManager.defaultSession = "none+i3"; }
```
Every display manager in NixOS supports auto-login, here is an example
···
to set one. The recommended configuration for modern systems is:
```nix
-
{
-
services.xserver.videoDrivers = [ "modesetting" ];
-
}
+
{ services.xserver.videoDrivers = [ "modesetting" ]; }
```
::: {.note}
The `modesetting` driver doesn't currently provide a `TearFree` option (this
···
```nix
{
services.xserver.videoDrivers = [ "intel" ];
-
services.xserver.deviceSection = ''
+
services.xserver.deviceSection = ''
Option "DRI" "2"
Option "TearFree" "true"
'';
···
default because it's not free software. You can enable it as follows:
```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:
···
Latitude series) can be enabled as follows:
```nix
-
{
-
services.libinput.enable = true;
-
}
+
{ services.libinput.enable = true; }
```
The driver has many options (see [](#ch-options)).
For instance, the following disables tap-to-click behavior:
```nix
-
{
-
services.libinput.touchpad.tapping = false;
-
}
+
{ services.libinput.touchpad.tapping = false; }
```
Note: the use of `services.xserver.synaptics` is deprecated since NixOS
···
{
services.xserver.xkb.extraLayouts.us-greek = {
description = "US layout with alt-gr greek";
-
languages = [ "eng" ];
+
languages = [ "eng" ];
symbolsFile = /yourpath/symbols/us-greek;
};
}
···
```nix
{
services.xserver.xkb.extraLayouts.media = {
-
description = "Multimedia keys remapping";
-
languages = [ "eng" ];
-
symbolsFile = /path/to/media-key;
+
description = "Multimedia keys remapping";
+
languages = [ "eng" ];
+
symbolsFile = /path/to/media-key;
keycodesFile = /path/to/media-sym;
};
}
+15 -10
nixos/doc/manual/development/assertions.section.md
···
{
config = lib.mkIf config.services.foo.enable {
warnings =
-
if config.services.foo.bar
-
then [ ''You have enabled the bar feature of the foo service.
-
This is known to cause some specific problems in certain situations.
-
'' ]
-
else [];
+
if config.services.foo.bar then
+
[
+
''
+
You have enabled the bar feature of the foo service.
+
This is known to cause some specific problems in certain situations.
+
''
+
]
+
else
+
[ ];
};
}
```
···
{ config, lib, ... }:
{
config = lib.mkIf config.services.syslogd.enable {
-
assertions =
-
[ { assertion = !config.services.rsyslogd.enable;
-
message = "rsyslogd conflicts with syslogd";
-
}
-
];
+
assertions = [
+
{
+
assertion = !config.services.rsyslogd.enable;
+
message = "rsyslogd conflicts with syslogd";
+
}
+
];
};
}
```
+2 -1
nixos/doc/manual/development/bootspec.chapter.md
···
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
-
{ config, lib, ... }: {
+
{ config, lib, ... }:
+
{
boot.bootspec.extensions = {
"org.secureboot.osRelease" = config.environment.etc."os-release".source;
};
+2 -6
nixos/doc/manual/development/etc-overlay.section.md
···
overlay filesystem:
```nix
-
{
-
system.etc.overlay.enable = true;
-
}
+
{ system.etc.overlay.enable = true; }
```
Using an overlay has two benefits:
···
setting:
```nix
-
{
-
system.etc.overlay.mutable = false;
-
}
+
{ system.etc.overlay.mutable = false; }
```
The overlay is atomically replaced during system switch. However, files that
+2 -1
nixos/doc/manual/development/freeform-modules.section.md
···
for a more complete example.
```nix
-
{ lib, config, ... }: {
+
{ lib, config, ... }:
+
{
options.settings = lib.mkOption {
type = lib.types.submodule {
+11 -6
nixos/doc/manual/development/importing-modules.section.md
···
outside of Nixpkgs. These modules can be imported:
```nix
-
{ config, lib, pkgs, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
{
-
imports =
-
[ # Use a locally-available module definition in
-
# ./example-module/default.nix
-
./example-module
-
];
+
imports = [
+
# Use a locally-available module definition in
+
# ./example-module/default.nix
+
./example-module
+
];
services.exampleModule.enable = true;
}
+6 -1
nixos/doc/manual/development/meta-attributes.section.md
···
file.
```nix
-
{ config, lib, pkgs, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
{
options = {
# ...
+2 -1
nixos/doc/manual/development/non-switchable-systems.section.md
···
profile:
```nix
-
{ modulesPath, ... }: {
+
{ modulesPath, ... }:
+
{
imports = [ "${modulesPath}/profiles/image-based-appliance.nix" ];
}
```
+52 -43
nixos/doc/manual/development/option-declarations.section.md
···
### `mkEnableOption` usage
```nix
lib.mkEnableOption "magic"
-
# is like
-
lib.mkOption {
-
type = lib.types.bool;
-
default = false;
-
example = true;
-
description = "Whether to enable magic.";
-
}
+
# is like
+
lib.mkOption
+
{
+
type = lib.types.bool;
+
default = false;
+
example = true;
+
description = "Whether to enable magic.";
+
}
```
:::
···
Usage:
```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.
···
### Simple `mkPackageOption` usage
```nix
lib.mkPackageOption pkgs "hello" { }
-
# is like
-
lib.mkOption {
-
type = lib.types.package;
-
default = pkgs.hello;
-
defaultText = lib.literalExpression "pkgs.hello";
-
description = "The hello package to use.";
-
}
+
# is like
+
lib.mkOption
+
{
+
type = lib.types.package;
+
default = pkgs.hello;
+
defaultText = lib.literalExpression "pkgs.hello";
+
description = "The hello package to use.";
+
}
```
:::
::: {#ex-options-declarations-util-mkPackageOption-ghc .example}
### `mkPackageOption` with explicit default and example
```nix
-
lib.mkPackageOption pkgs "GHC" {
-
default = [ "ghc" ];
-
example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
-
}
-
# is like
-
lib.mkOption {
-
type = lib.types.package;
-
default = pkgs.ghc;
-
defaultText = lib.literalExpression "pkgs.ghc";
-
example = lib.literalExpression "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
-
description = "The GHC package to use.";
-
}
+
lib.mkPackageOption pkgs "GHC"
+
{
+
default = [ "ghc" ];
+
example = "pkgs.haskell.packages.ghc92.ghc.withPackages (hkgs: [ hkgs.primes ])";
+
}
+
# is like
+
lib.mkOption
+
{
+
type = lib.types.package;
+
default = pkgs.ghc;
+
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}
### `mkPackageOption` with additional description text
```nix
-
mkPackageOption pkgs [ "python312Packages" "torch" ] {
-
extraDescription = "This is an example and doesn't actually do anything.";
-
}
-
# is like
-
lib.mkOption {
-
type = lib.types.package;
-
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.";
-
}
+
mkPackageOption pkgs [ "python312Packages" "torch" ]
+
{
+
extraDescription = "This is an example and doesn't actually do anything.";
+
}
+
# is like
+
lib.mkOption
+
{
+
type = lib.types.package;
+
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.";
+
}
```
:::
···
### Extending `services.xserver.displayManager.enable` in the `gdm` module
```nix
{
-
services.xserver.displayManager.enable = mkOption {
-
type = with types; nullOr (enum [ "gdm" ]);
-
};
+
services.xserver.displayManager.enable = mkOption { type = with types; nullOr (enum [ "gdm" ]); };
}
```
:::
···
### Extending `services.xserver.displayManager.enable` in the `sddm` module
```nix
{
-
services.xserver.displayManager.enable = mkOption {
-
type = with types; nullOr (enum [ "sddm" ]);
-
};
+
services.xserver.displayManager.enable = mkOption { type = with types; nullOr (enum [ "sddm" ]); };
}
```
:::
+50 -33
nixos/doc/manual/development/option-def.section.md
···
```nix
{
-
config = if config.services.httpd.enable then {
-
environment.systemPackages = [ /* ... */ ];
-
# ...
-
} else {};
+
config =
+
if config.services.httpd.enable then
+
{
+
environment.systemPackages = [
+
# ...
+
];
+
# ...
+
}
+
else
+
{ };
}
```
···
```nix
{
-
config = if config.services.httpd.enable then {
-
services.httpd.enable = false;
-
} else {
-
services.httpd.enable = true;
-
};
+
config =
+
if config.services.httpd.enable then
+
{
+
services.httpd.enable = false;
+
}
+
else
+
{
+
services.httpd.enable = true;
+
};
}
```
···
```nix
{
config = mkIf config.services.httpd.enable {
-
environment.systemPackages = [ /* ... */ ];
+
environment.systemPackages = [
+
# ...
+
];
# ...
};
}
···
```nix
{
config = {
-
environment.systemPackages = if config.services.httpd.enable then [ /* ... */ ] else [];
+
environment.systemPackages =
+
if config.services.httpd.enable then
+
[
+
# ...
+
]
+
else
+
[ ];
# ...
};
}
···
You can specify an explicit priority by using `mkOverride`, e.g.
```nix
-
{
-
services.openssh.enable = mkOverride 10 false;
-
}
+
{ services.openssh.enable = mkOverride 10 false; }
```
This definition causes all other definitions with priorities above 10 to
···
As an example,
```nix
-
{
-
hardware.firmware = mkBefore [ myFirmware ];
-
}
+
{ hardware.firmware = mkBefore [ myFirmware ]; }
```
This definition ensures that `myFirmware` comes before other unordered
···
```nix
{
-
config = mkMerge
-
[ # Unconditional stuff.
-
{ environment.systemPackages = [ /* ... */ ];
-
}
-
# Conditional stuff.
-
(mkIf config.services.bla.enable {
-
environment.systemPackages = [ /* ... */ ];
-
})
-
];
+
config = mkMerge [
+
# Unconditional stuff.
+
{
+
environment.systemPackages = [
+
# ...
+
];
+
}
+
# Conditional stuff.
+
(mkIf config.services.bla.enable {
+
environment.systemPackages = [
+
# ...
+
];
+
})
+
];
}
```
···
```nix
mkDefinition {
-
value = mkForce 42;
-
file = "somefile.nix";
+
value = mkForce 42;
+
file = "somefile.nix";
}
```
···
```nix
mkForce (mkDefinition {
-
value = 42;
-
file = "somefile.nix";
+
value = 42;
+
file = "somefile.nix";
})
```
···
```nix
{
_file = "file.nix";
-
options.foo = mkOption {
-
default = 13;
-
};
+
options.foo = mkOption { default = 13; };
config.foo = lib.mkDefinition {
file = "custom place";
# mkOptionDefault creates a conflict with the option foo's `default = 1` on purpose
+38 -36
nixos/doc/manual/development/option-types.section.md
···
{
options.mod = mkOption {
description = "submodule example";
-
type = with types; submodule {
-
options = {
-
foo = mkOption {
-
type = int;
-
};
-
bar = mkOption {
-
type = str;
+
type =
+
with types;
+
submodule {
+
options = {
+
foo = mkOption { type = int; };
+
bar = mkOption { type = str; };
};
};
-
};
};
}
```
···
let
modOptions = {
options = {
-
foo = mkOption {
-
type = int;
-
};
-
bar = mkOption {
-
type = int;
-
};
+
foo = mkOption { type = int; };
+
bar = mkOption { type = int; };
};
};
in
···
{
options.mod = mkOption {
description = "submodule example";
-
type = with types; listOf (submodule {
-
options = {
-
foo = mkOption {
-
type = int;
+
type =
+
with types;
+
listOf (submodule {
+
options = {
+
foo = mkOption { type = int; };
+
bar = mkOption { type = str; };
};
-
bar = mkOption {
-
type = str;
-
};
-
};
-
});
+
});
};
}
```
···
```nix
{
config.mod = [
-
{ foo = 1; bar = "one"; }
-
{ foo = 2; bar = "two"; }
+
{
+
foo = 1;
+
bar = "one";
+
}
+
{
+
foo = 2;
+
bar = "two";
+
}
];
}
```
···
{
options.mod = mkOption {
description = "submodule example";
-
type = with types; attrsOf (submodule {
-
options = {
-
foo = mkOption {
-
type = int;
+
type =
+
with types;
+
attrsOf (submodule {
+
options = {
+
foo = mkOption { type = int; };
+
bar = mkOption { type = str; };
};
-
bar = mkOption {
-
type = str;
-
};
-
};
-
});
+
});
};
}
```
···
### Definition of attribute sets of submodules
```nix
{
-
config.mod.one = { foo = 1; bar = "one"; };
-
config.mod.two = { foo = 2; bar = "two"; };
+
config.mod.one = {
+
foo = 1;
+
bar = "one";
+
};
+
config.mod.two = {
+
foo = 2;
+
bar = "two";
+
};
}
```
:::
+18 -8
nixos/doc/manual/development/replace-modules.section.md
···
nixos-unstable unless explicitly configured to do so.
```nix
-
{ config, lib, pkgs, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
{
disabledModules = [ "services/databases/postgresql.nix" ];
-
imports =
-
[ # Use postgresql service from nixos-unstable channel.
-
# sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
-
<nixos-unstable/nixos/modules/services/databases/postgresql.nix>
-
];
+
imports = [
+
# Use postgresql service from nixos-unstable channel.
+
# sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
+
<nixos-unstable/nixos/modules/services/databases/postgresql.nix>
+
];
services.postgresql.enable = true;
}
···
without having to know its implementation details.
```nix
-
{ config, lib, pkgs, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
let
inherit (lib) mkIf mkOption types;
cfg = config.programs.man;
-
in
+
in
{
disabledModules = [ "services/programs/man.nix" ];
+3 -1
nixos/doc/manual/development/running-nixos-tests-interactively.section.md
···
```nix
{
name = "…";
-
nodes.machines = { /* … */ };
+
nodes.machines = {
+
# …
+
};
interactive.sshBackdoor.enable = true;
}
```
+15 -6
nixos/doc/manual/development/settings-options.section.md
···
explanations.
```nix
-
{ options, config, lib, pkgs, ... }:
+
{
+
options,
+
config,
+
lib,
+
pkgs,
+
...
+
}:
let
cfg = config.services.foo;
# Define the settings format used for this program
-
settingsFormat = pkgs.formats.json {};
-
in {
+
settingsFormat = pkgs.formats.json { };
+
in
+
{
options.services.foo = {
enable = lib.mkEnableOption "foo service";
···
settings = lib.mkOption {
# Setting this type allows for correct merging behavior
type = settingsFormat.type;
-
default = {};
+
default = { };
description = ''
Configuration for foo, see
<link xlink:href="https://example.com/docs/foo"/>
···
# We know that the `user` attribute exists because we set a default value
# for it above, allowing us to use it without worries here
-
users.users.${cfg.settings.user} = { isSystemUser = true; };
+
users.users.${cfg.settings.user} = {
+
isSystemUser = true;
+
};
# ...
};
···
};
};
-
default = {};
+
default = { };
description = ''
Configuration for Foo, see
<link xlink:href="https://example.com/docs/foo"/>
+60 -37
nixos/doc/manual/development/writing-modules.chapter.md
···
```nix
{ config, pkgs, ... }:
-
{ # option definitions
+
{
+
# option definitions
}
```
···
{ config, pkgs, ... }:
{
-
imports =
-
[ # paths of other modules
-
];
+
imports = [
+
# paths of other modules
+
];
options = {
# option declarations
···
::: {#locate-example .example}
### NixOS Module for the "locate" Service
```nix
-
{ config, lib, pkgs, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
let
-
inherit (lib) concatStringsSep mkIf mkOption optionalString types;
+
inherit (lib)
+
concatStringsSep
+
mkIf
+
mkOption
+
optionalString
+
types
+
;
cfg = config.services.locate;
-
in {
+
in
+
{
options.services.locate = {
enable = mkOption {
type = types.bool;
···
};
config = {
-
systemd.services.update-locatedb =
-
{ description = "Update Locate Database";
-
path = [ pkgs.su ];
-
script =
-
''
-
mkdir -p $(dirname ${toString cfg.output})
-
chmod 0755 $(dirname ${toString cfg.output})
-
exec updatedb \
-
--localuser=${cfg.localuser} \
-
${optionalString (!cfg.includeStore) "--prunepaths='/nix/store'"} \
-
--output=${toString cfg.output} ${concatStringsSep " " cfg.extraFlags}
-
'';
-
};
+
systemd.services.update-locatedb = {
+
description = "Update Locate Database";
+
path = [ pkgs.su ];
+
script = ''
+
mkdir -p $(dirname ${toString cfg.output})
+
chmod 0755 $(dirname ${toString cfg.output})
+
exec updatedb \
+
--localuser=${cfg.localuser} \
+
${optionalString (!cfg.includeStore) "--prunepaths='/nix/store'"} \
+
--output=${toString cfg.output} ${concatStringsSep " " cfg.extraFlags}
+
'';
+
};
-
systemd.timers.update-locatedb = mkIf cfg.enable
-
{ description = "Update timer for locate database";
-
partOf = [ "update-locatedb.service" ];
-
wantedBy = [ "timers.target" ];
-
timerConfig.OnCalendar = cfg.interval;
-
};
+
systemd.timers.update-locatedb = mkIf cfg.enable {
+
description = "Update timer for locate database";
+
partOf = [ "update-locatedb.service" ];
+
wantedBy = [ "timers.target" ];
+
timerConfig.OnCalendar = cfg.interval;
+
};
};
}
```
···
::: {#exec-escaping-example .example}
### Escaping in Exec directives
```nix
-
{ config, pkgs, utils, ... }:
+
{
+
config,
+
pkgs,
+
utils,
+
...
+
}:
let
cfg = config.services.echo;
···
printf '%s\n' "$s"
done
'';
-
args = [ "a%Nything" "lang=\${LANG}" ";" "/bin/sh -c date" ];
-
in {
-
systemd.services.echo =
-
{ description = "Echo to the journal";
-
wantedBy = [ "multi-user.target" ];
-
serviceConfig.Type = "oneshot";
-
serviceConfig.ExecStart = ''
-
${echoAll} ${utils.escapeSystemdExecArgs args}
-
'';
-
};
+
args = [
+
"a%Nything"
+
"lang=\${LANG}"
+
";"
+
"/bin/sh -c date"
+
];
+
in
+
{
+
systemd.services.echo = {
+
description = "Echo to the journal";
+
wantedBy = [ "multi-user.target" ];
+
serviceConfig.Type = "oneshot";
+
serviceConfig.ExecStart = ''
+
${echoAll} ${utils.escapeSystemdExecArgs args}
+
'';
+
};
}
```
:::
+33 -29
nixos/doc/manual/development/writing-nixos-tests.section.md
···
{
# One or more machines:
-
nodes =
-
{ machine =
-
{ config, pkgs, ... }: { /* ... */ };
-
machine2 =
-
{ config, pkgs, ... }: { /* ... */ };
-
# …
-
};
+
nodes = {
+
machine =
+
{ config, pkgs, ... }:
+
{
+
# ...
+
};
+
machine2 =
+
{ config, pkgs, ... }:
+
{
+
# ...
+
};
+
# …
+
};
-
testScript =
-
''
-
Python code…
-
'';
+
testScript = ''
+
Python code…
+
'';
}
```
···
Tests that are part of NixOS are added to [`nixos/tests/all-tests.nix`](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/all-tests.nix).
```nix
-
{
-
hostname = runTest ./hostname.nix;
-
}
+
{ hostname = runTest ./hostname.nix; }
```
Overrides can be added by defining an anonymous module in `all-tests.nix`.
···
`pkgs.testers`:
```nix
-
let pkgs = import <nixpkgs> {};
+
let
+
pkgs = import <nixpkgs> { };
+
in
-
pkgs.testers.runNixOSTest {
imports = [ ./test.nix ];
defaults.services.foo.package = mypkg;
···
skipLint = true;
nodes.machine =
{ config, pkgs, ... }:
-
{ # configuration…
+
{
+
# configuration…
};
-
testScript =
-
''
-
Python code…
-
'';
+
testScript = ''
+
Python code…
+
'';
}
```
···
```nix
{
-
testScript =
-
''
-
# fmt: off
-
Python code…
-
# fmt: on
-
'';
+
testScript = ''
+
# fmt: off
+
Python code…
+
# fmt: on
+
'';
}
```
···
skipTypeCheck = true;
nodes.machine =
{ config, pkgs, ... }:
-
{ # configuration…
+
{
+
# configuration…
};
}
```
···
```nix
{
-
nodes.machine = {};
+
nodes.machine = { };
sshBackdoor.enable = true;
enableDebugHook = true;
+39 -29
nixos/doc/manual/installation/building-images-via-systemd-repart.chapter.md
···
An example of how to build an image:
```nix
-
{ config, modulesPath, ... }: {
+
{ config, modulesPath, ... }:
+
{
imports = [ "${modulesPath}/image/repart.nix" ];
···
efiArch = pkgs.stdenv.hostPlatform.efiArch;
in
(pkgs.nixos [
-
({ config, lib, pkgs, modulesPath, ... }: {
+
(
+
{
+
config,
+
lib,
+
pkgs,
+
modulesPath,
+
...
+
}:
+
{
-
imports = [ "${modulesPath}/image/repart.nix" ];
+
imports = [ "${modulesPath}/image/repart.nix" ];
-
boot.loader.grub.enable = false;
+
boot.loader.grub.enable = false;
-
fileSystems."/".device = "/dev/disk/by-label/nixos";
+
fileSystems."/".device = "/dev/disk/by-label/nixos";
-
image.repart = {
-
name = "image";
-
partitions = {
-
"esp" = {
-
contents = {
-
"/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source =
-
"${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
+
image.repart = {
+
name = "image";
+
partitions = {
+
"esp" = {
+
contents = {
+
"/EFI/BOOT/BOOT${lib.toUpper efiArch}.EFI".source =
+
"${pkgs.systemd}/lib/systemd/boot/efi/systemd-boot${efiArch}.efi";
-
"/EFI/Linux/${config.system.boot.loader.ukiFile}".source =
-
"${config.system.build.uki}/${config.system.boot.loader.ukiFile}";
-
};
-
repartConfig = {
-
Type = "esp";
-
Format = "vfat";
-
SizeMinBytes = "96M";
+
"/EFI/Linux/${config.system.boot.loader.ukiFile}".source =
+
"${config.system.build.uki}/${config.system.boot.loader.ukiFile}";
+
};
+
repartConfig = {
+
Type = "esp";
+
Format = "vfat";
+
SizeMinBytes = "96M";
+
};
};
-
};
-
"root" = {
-
storePaths = [ config.system.build.toplevel ];
-
repartConfig = {
-
Type = "root";
-
Format = "ext4";
-
Label = "nixos";
-
Minimize = "guess";
+
"root" = {
+
storePaths = [ config.system.build.toplevel ];
+
repartConfig = {
+
Type = "root";
+
Format = "ext4";
+
Label = "nixos";
+
Minimize = "guess";
+
};
};
};
};
-
};
-
})
+
}
+
)
]).image
```
+4 -1
nixos/doc/manual/installation/building-nixos.chapter.md
···
boot.initrd.kernelModules = [ "wl" ];
-
boot.kernelModules = [ "kvm-intel" "wl" ];
+
boot.kernelModules = [
+
"kvm-intel"
+
"wl"
+
];
boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ];
}
```
+1 -3
nixos/doc/manual/installation/changing-config.chapter.md
···
following to your configuration:
```nix
-
{
-
users.users.your-user.initialHashedPassword = "test";
-
}
+
{ users.users.your-user.initialHashedPassword = "test"; }
```
*Important:* delete the \$hostname.qcow2 file if you have started the
+1 -3
nixos/doc/manual/installation/installing-from-other-distro.section.md
···
`sudo passwd -l root` if you use `sudo`)
```nix
-
{
-
users.users.root.initialHashedPassword = "";
-
}
+
{ users.users.root.initialHashedPassword = ""; }
```
1. Build the NixOS closure and install it in the `system` profile:
+4 -7
nixos/doc/manual/installation/installing-kexec.section.md
···
the default installer image, you can build your own `configuration.nix`:
```nix
-
{ modulesPath, ... }: {
-
imports = [
-
(modulesPath + "/installer/netboot/netboot-minimal.nix")
-
];
+
{ modulesPath, ... }:
+
{
+
imports = [ (modulesPath + "/installer/netboot/netboot-minimal.nix") ];
services.openssh.enable = true;
-
users.users.root.openssh.authorizedKeys.keys = [
-
"my-ssh-pubkey"
-
];
+
users.users.root.openssh.authorizedKeys.keys = [ "my-ssh-pubkey" ];
}
```
+7 -8
nixos/doc/manual/installation/installing-virtualbox-guest.section.md
···
Enable booting:
```nix
-
{
-
boot.loader.grub.device = "/dev/sda";
-
}
+
{ boot.loader.grub.device = "/dev/sda"; }
```
Also remove the fsck that runs at startup. It will always fail to run,
stopping your boot until you press `*`.
```nix
-
{
-
boot.initrd.checkJournalingFS = false;
-
}
+
{ boot.initrd.checkJournalingFS = false; }
```
Shared folders can be given a name and a path in the host system in the
···
`"nofail"`, the system will not boot properly.
```nix
-
{ config, pkgs, ...} :
+
{ config, pkgs, ... }:
{
fileSystems."/virtualboxshare" = {
fsType = "vboxsf";
device = "nameofthesharedfolder";
-
options = [ "rw" "nofail" ];
+
options = [
+
"rw"
+
"nofail"
+
];
};
}
```
+1 -3
nixos/doc/manual/installation/upgrading.chapter.md
···
modules. You can also specify a channel explicitly, e.g.
```nix
-
{
-
system.autoUpgrade.channel = "https://channels.nixos.org/nixos-25.05";
-
}
+
{ system.autoUpgrade.channel = "https://channels.nixos.org/nixos-25.05"; }
```
+3 -9
nixos/doc/manual/release-notes/rl-1404.section.md
···
- Systemd units provided by packages can now be overridden from the NixOS configuration. For instance, if a package `foo` provides systemd units, you can say:
```nix
-
{
-
systemd.packages = [ pkgs.foo ];
-
}
+
{ systemd.packages = [ pkgs.foo ]; }
```
to enable those units. You can then set or override unit options in the usual way, e.g.
···
- Nixpkgs no longer exposes unfree packages by default. If your NixOS configuration requires unfree packages from Nixpkgs, you need to enable support for them explicitly by setting:
```nix
-
{
-
nixpkgs.config.allowUnfree = true;
-
}
+
{ nixpkgs.config.allowUnfree = true; }
```
Otherwise, you get an error message such as:
···
- The firewall is now enabled by default. If you don't want this, you need to disable it explicitly:
```nix
-
{
-
networking.firewall.enable = false;
-
}
+
{ networking.firewall.enable = false; }
```
- The option `boot.loader.grub.memtest86` has been renamed to `boot.loader.grub.memtest86.enable`.
+1 -3
nixos/doc/manual/release-notes/rl-1412.section.md
···
- The default version of Apache httpd is now 2.4. If you use the `extraConfig` option to pass literal Apache configuration text, you may need to update it --- see [Apache's documentation](http://httpd.apache.org/docs/2.4/upgrading.html) for details. If you wish to continue to use httpd 2.2, add the following line to your NixOS configuration:
```nix
-
{
-
services.httpd.package = pkgs.apacheHttpd_2_2;
-
}
+
{ services.httpd.package = pkgs.apacheHttpd_2_2; }
```
- PHP 5.3 has been removed because it is no longer supported by the PHP project. A [migration guide](http://php.net/migration54) is available.
+23 -14
nixos/doc/manual/release-notes/rl-1509.section.md
···
- You can now keep your NixOS system up to date automatically by setting
```nix
-
{
-
system.autoUpgrade.enable = true;
-
}
+
{ system.autoUpgrade.enable = true; }
```
This will cause the system to periodically check for updates in your current channel and run `nixos-rebuild`.
···
- `sshd` no longer supports DSA and ECDSA host keys by default. If you have existing systems with such host keys and want to continue to use them, please set
```nix
-
{
-
system.stateVersion = "14.12";
-
}
+
{ system.stateVersion = "14.12"; }
```
The new option `system.stateVersion` ensures that certain configuration changes that could break existing systems (such as the `sshd` host key setting) will maintain compatibility with the specified NixOS release. NixOps sets the state version of existing deployments automatically.
···
{
options = {
-
foo = mkOption { /* … */ };
+
foo = mkOption {
+
# …
+
};
};
-
config = mkIf config.foo { /* … */ };
+
config = mkIf config.foo {
+
# …
+
};
}
```
should be modified to look like:
```nix
-
{ config, pkgs, lib, ... }:
+
{
+
config,
+
pkgs,
+
lib,
+
...
+
}:
with lib;
{
options = {
-
foo = mkOption { /* option declaration */ };
+
foo = mkOption {
+
# option declaration
+
};
};
-
config = mkIf config.foo { /* option definition */ };
+
config = mkIf config.foo {
+
# option definition
+
};
}
```
···
src = url;
sha256 = hash;
};
-
in
+
in
{
imports = [ "${myProject}/module.nix" ];
}
···
{ config, pkgs, ... }:
let
-
myProject = (import <nixpkgs> {}).fetchurl {
+
myProject = (import <nixpkgs> { }).fetchurl {
src = url;
sha256 = hash;
};
-
in
+
in
{
imports = [ "${myProject}/module.nix" ];
}
+23 -10
nixos/doc/manual/release-notes/rl-1603.section.md
···
- Gitit is no longer automatically added to the module list in NixOS and as such there will not be any manual entries for it. You will need to add an import statement to your NixOS configuration in order to use it, e.g.
```nix
-
{
-
imports = [ <nixpkgs/nixos/modules/services/misc/gitit.nix> ];
-
}
+
{ imports = [ <nixpkgs/nixos/modules/services/misc/gitit.nix> ]; }
```
will include the Gitit service configuration options.
···
```nix
nginx.override {
-
modules = [ nginxModules.rtmp nginxModules.dav nginxModules.moreheaders ];
+
modules = [
+
nginxModules.rtmp
+
nginxModules.dav
+
nginxModules.moreheaders
+
];
}
```
···
fileSystems."/example" = {
device = "/dev/sdc";
fsType = "btrfs";
-
options = [ "noatime" "compress=lzo" "space_cache" "autodefrag" ];
+
options = [
+
"noatime"
+
"compress=lzo"
+
"space_cache"
+
"autodefrag"
+
];
};
}
```
···
```nix
{
i18n.inputMethod.enabled = "ibus";
-
i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [ anthy mozc ];
+
i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [
+
anthy
+
mozc
+
];
}
```
···
```nix
{
programs.ibus.enable = true;
-
programs.ibus.plugins = with pkgs; [ ibus-anthy mozc ];
+
programs.ibus.plugins = with pkgs; [
+
ibus-anthy
+
mozc
+
];
}
```
···
```nix
{
services.syncthing = {
-
enable = true;
-
dataDir = "/home/somebody/.syncthing";
-
user = "somebody";
+
enable = true;
+
dataDir = "/home/somebody/.syncthing";
+
user = "somebody";
};
}
```
+1 -3
nixos/doc/manual/release-notes/rl-1609.section.md
···
- Revamped grsecurity/PaX support. There is now only a single general-purpose distribution kernel and the configuration interface has been streamlined. Desktop users should be able to set
```nix
-
{
-
security.grsecurity.enable = true;
-
}
+
{ security.grsecurity.enable = true; }
```
to get a reasonably secure system without having to sacrifice too much functionality.
+14 -4
nixos/doc/manual/release-notes/rl-1703.section.md
···
```nix
let
-
pkgs = import <nixpkgs> {};
+
pkgs = import <nixpkgs> { };
in
-
pkgs.overridePackages (self: super: { /* ... */ })
+
pkgs.overridePackages (
+
self: super: {
+
# ...
+
}
+
)
```
should be replaced by:
```nix
let
-
pkgs = import <nixpkgs> {};
+
pkgs = import <nixpkgs> { };
in
-
import pkgs.path { overlays = [(self: super: { /* ... */ })]; }
+
import pkgs.path {
+
overlays = [
+
(self: super: {
+
# ...
+
})
+
];
+
}
```
- Autoloading connection tracking helpers is now disabled by default. This default was also changed in the Linux kernel and is considered insecure if not configured properly in your firewall. If you need connection tracking helpers (i.e. for active FTP) please enable `networking.firewall.autoLoadConntrackHelpers` and tune `networking.firewall.connectionTrackingModules` to suit your needs.
+2 -1
nixos/doc/manual/release-notes/rl-1709.section.md
···
- The module option `services.xserver.xrandrHeads` now causes the first head specified in this list to be set as the primary head. Apart from that, it's now possible to also set additional options by using an attribute set, for example:
```nix
-
{ services.xserver.xrandrHeads = [
+
{
+
services.xserver.xrandrHeads = [
"HDMI-0"
{
output = "DVI-0";
+4 -2
nixos/doc/manual/release-notes/rl-1803.section.md
···
```nix
{
services.xserver.displayManager.lightdm.greeters.gtk.indicators = [
-
"~host" "~spacer"
-
"~clock" "~spacer"
+
"~host"
+
"~spacer"
+
"~clock"
+
"~spacer"
"~session"
"~language"
"~a11y"
+11 -5
nixos/doc/manual/release-notes/rl-1809.section.md
···
```nix
{
-
inherit (pkgs.nixos {
-
boot.loader.grub.enable = false;
-
fileSystems."/".device = "/dev/xvda1";
-
}) toplevel kernel initialRamdisk manual;
+
inherit
+
(pkgs.nixos {
+
boot.loader.grub.enable = false;
+
fileSystems."/".device = "/dev/xvda1";
+
})
+
toplevel
+
kernel
+
initialRamdisk
+
manual
+
;
}
```
···
{ config, ... }:
{
-
security.dhparams.params.myservice = {};
+
security.dhparams.params.myservice = { };
environment.etc."myservice.conf".text = ''
dhparams = ${config.security.dhparams.params.myservice.path}
'';
+26 -27
nixos/doc/manual/release-notes/rl-1903.section.md
···
```nix
{
-
services.nscd.config =
-
''
-
server-user nscd
-
threads 1
-
paranoia no
-
debug-level 0
+
services.nscd.config = ''
+
server-user nscd
+
threads 1
+
paranoia no
+
debug-level 0
-
enable-cache passwd yes
-
positive-time-to-live passwd 600
-
negative-time-to-live passwd 20
-
suggested-size passwd 211
-
check-files passwd yes
-
persistent passwd no
-
shared passwd yes
+
enable-cache passwd yes
+
positive-time-to-live passwd 600
+
negative-time-to-live passwd 20
+
suggested-size passwd 211
+
check-files passwd yes
+
persistent passwd no
+
shared passwd yes
-
enable-cache group yes
-
positive-time-to-live group 3600
-
negative-time-to-live group 60
-
suggested-size group 211
-
check-files group yes
-
persistent group no
-
shared group yes
+
enable-cache group yes
+
positive-time-to-live group 3600
+
negative-time-to-live group 60
+
suggested-size group 211
+
check-files group yes
+
persistent group no
+
shared group yes
-
enable-cache hosts yes
-
positive-time-to-live hosts 600
-
negative-time-to-live hosts 5
-
suggested-size hosts 211
-
check-files hosts yes
-
persistent hosts no
-
shared hosts yes
+
enable-cache hosts yes
+
positive-time-to-live hosts 600
+
negative-time-to-live hosts 5
+
suggested-size hosts 211
+
check-files hosts yes
+
persistent hosts no
+
shared hosts yes
'';
}
```
+31 -24
nixos/doc/manual/release-notes/rl-2003.section.md
···
you should change it to:
```nix
-
{
-
services.xserver.displayManager.defaultSession = "xfce+icewm";
-
}
+
{ services.xserver.displayManager.defaultSession = "xfce+icewm"; }
```
- The testing driver implementation in NixOS is now in Python `make-test-python.nix`. This was done by Jacek Galowicz ([\@tfc](https://github.com/tfc)), and with the collaboration of Julian Stecklina ([\@blitz](https://github.com/blitz)) and Jana Traue ([\@jtraue](https://github.com/jtraue)). All documentation has been updated to use this testing driver, and a vast majority of the 286 tests in NixOS were ported to python driver. In 20.09 the Perl driver implementation, `make-test.nix`, is slated for removal. This should give users of the NixOS integration framework a transitory period to rewrite their tests to use the Python implementation. Users of the Perl driver will see this warning everytime they use it:
···
```nix
{
-
users.users =
-
[ { name = "me";
-
description = "My personal user.";
-
isNormalUser = true;
-
}
-
];
+
users.users = [
+
{
+
name = "me";
+
description = "My personal user.";
+
isNormalUser = true;
+
}
+
];
}
```
···
```nix
{
-
users.users.me =
-
{ description = "My personal user.";
-
isNormalUser = true;
-
};
+
users.users.me = {
+
description = "My personal user.";
+
isNormalUser = true;
+
};
}
```
···
```nix
{
security.pam.services.lightdm-autologin.text = lib.mkForce ''
-
auth requisite pam_nologin.so
-
auth required pam_succeed_if.so quiet
-
auth required pam_permit.so
+
auth requisite pam_nologin.so
+
auth required pam_succeed_if.so quiet
+
auth required pam_permit.so
-
account include lightdm
+
account include lightdm
-
password include lightdm
+
password include lightdm
-
session include lightdm
+
session include lightdm
'';
}
```
···
services.dnscrypt-proxy2.settings = {
listen_addresses = [ "127.0.0.1:43" ];
sources.public-resolvers = {
-
urls = [ "https://download.dnscrypt.info/resolvers-list/v2/public-resolvers.md" ];
+
urls = [
+
"https://download.dnscrypt.info/resolvers-list/v2/public-resolvers.md"
+
];
cache_file = "public-resolvers.md";
minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3";
refresh_delay = 72;
···
- At first, an older version of Hydra needs to be deployed which adds those (nullable) columns. When having set [stateVersion ](options.html#opt-system.stateVersion) to a value older than `20.03`, this package will be selected by default from the module when upgrading. Otherwise, the package can be deployed using the following config:
```nix
-
{ pkgs, ... }: {
+
{ pkgs, ... }:
+
{
services.hydra.package = pkgs.hydra-migration;
}
```
···
```nix
{
-
services.nginx.appendConfig = let cfg = config.services.nginx; in ''user ${cfg.user} ${cfg.group};'';
+
services.nginx.appendConfig =
+
let
+
cfg = config.services.nginx;
+
in
+
"user ${cfg.user} ${cfg.group};";
systemd.services.nginx.serviceConfig.User = lib.mkForce "root";
}
```
···
- If you use `postgresql` and configured your synapse initially on `19.09` or older, you need to enable postgresql-support explicitly:
```nix
-
{ ... }: {
+
{ ... }:
+
{
services.matrix-synapse = {
enable = true;
-
/* and all the other config you've defined here */
+
# and all the other config you've defined here
};
services.postgresql.enable = true;
}
+17 -26
nixos/doc/manual/release-notes/rl-2009.section.md
···
```nix
{
-
services.mysql.initialScript = pkgs.writeText "mariadb-init.sql" ''
-
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("verysecret");
-
'';
+
services.mysql.initialScript = pkgs.writeText "mariadb-init.sql" ''
+
ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD("verysecret");
+
'';
}
```
···
- MySQL server is now started with additional systemd sandbox/hardening options for better security. The PrivateTmp, ProtectHome, and ProtectSystem options may be problematic when MySQL is attempting to read from or write to your filesystem anywhere outside of its own state directory, for example when calling `LOAD DATA INFILE or SELECT * INTO OUTFILE`. In this scenario a variant of the following may be required: - allow MySQL to read from /home and /tmp directories when using `LOAD DATA INFILE`
```nix
-
{
-
systemd.services.mysql.serviceConfig.ProtectHome = lib.mkForce "read-only";
-
}
+
{ systemd.services.mysql.serviceConfig.ProtectHome = lib.mkForce "read-only"; }
```
\- allow MySQL to write to custom folder `/var/data` when using `SELECT * INTO OUTFILE`, assuming the mysql user has write access to `/var/data`
```nix
-
{
-
systemd.services.mysql.serviceConfig.ReadWritePaths = [ "/var/data" ];
-
}
+
{ systemd.services.mysql.serviceConfig.ReadWritePaths = [ "/var/data" ]; }
```
The MySQL service no longer runs its `systemd` service startup script as `root` anymore. A dedicated non `root` super user account is required for operation. This means users with an existing MySQL or MariaDB database server are required to run the following SQL statements as a super admin user before upgrading:
···
```nix
{
environment.systemPackages = [
-
(pkgs.php.withExtensions
-
({ all, ... }: with all; [
+
(pkgs.php.withExtensions (
+
{ all, ... }:
+
with all;
+
[
imagick
opcache
pdo
pdo_mysql
-
])
-
)
+
]
+
))
];
}
```
···
- Nginx web server now starting with additional sandbox/hardening options. By default, write access to `/var/log/nginx` and `/var/cache/nginx` is allowed. To allow writing to other folders, use `systemd.services.nginx.serviceConfig.ReadWritePaths`
```nix
-
{
-
systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ];
-
}
+
{ systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ]; }
```
Nginx is also started with the systemd option `ProtectHome = mkDefault true;` which forbids it to read anything from `/home`, `/root` and `/run/user` (see [ProtectHome docs](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectHome=) for details). If you require serving files from home directories, you may choose to set e.g.
```nix
-
{
-
systemd.services.nginx.serviceConfig.ProtectHome = "read-only";
-
}
+
{ systemd.services.nginx.serviceConfig.ProtectHome = "read-only"; }
```
- The NixOS options `nesting.clone` and `nesting.children` have been deleted, and replaced with named [specialisation](options.html#opt-specialisation) configurations.
···
- The [services.postgresql.dataDir](options.html#opt-services.postgresql.dataDir) option is now set to `"/var/lib/postgresql/${cfg.package.psqlSchema}"` regardless of your [system.stateVersion](options.html#opt-system.stateVersion). Users with an existing postgresql install that have a [system.stateVersion](options.html#opt-system.stateVersion) of `17.03` or below should double check what the value of their [services.postgresql.dataDir](options.html#opt-services.postgresql.dataDir) option is (`/var/db/postgresql`) and then explicitly set this value to maintain compatibility:
```nix
-
{
-
services.postgresql.dataDir = "/var/db/postgresql";
-
}
+
{ services.postgresql.dataDir = "/var/db/postgresql"; }
```
The postgresql module now expects there to be a database super user account called `postgres` regardless of your [system.stateVersion](options.html#opt-system.stateVersion). Users with an existing postgresql install that have a [system.stateVersion](options.html#opt-system.stateVersion) of `17.03` or below should run the following SQL statements as a database super admin user before upgrading:
···
Also, connection to the RPC (Remote Procedure Call) of `transmission-daemon` is now only available on the local network interface by default. Use:
```nix
-
{
-
services.transmission.settings.rpc-bind-address = "0.0.0.0";
-
}
+
{ services.transmission.settings.rpc-bind-address = "0.0.0.0"; }
```
to get the previous behavior of listening on all network interfaces.
···
```nix
{
services.dovecot2.mailboxes = [
-
{ name = "Junk";
+
{
+
name = "Junk";
auto = "create";
}
];
+25 -27
nixos/doc/manual/release-notes/rl-2105.section.md
···
- The `mediatomb` service is now using by default the new and maintained fork `gerbera` package instead of the unmaintained `mediatomb` package. If you want to keep the old behavior, you must declare it with:
```nix
-
{
-
services.mediatomb.package = pkgs.mediatomb;
-
}
+
{ services.mediatomb.package = pkgs.mediatomb; }
```
One new option `openFirewall` has been introduced which defaults to false. If you relied on the service declaration to add the firewall rules itself before, you should now declare it with:
```nix
-
{
-
services.mediatomb.openFirewall = true;
-
}
+
{ services.mediatomb.openFirewall = true; }
```
- xfsprogs was update from 4.19 to 5.11. It now enables reflink support by default on filesystem creation. Support for reflinks was added with an experimental status to kernel 4.9 and deemed stable in kernel 4.16. If you want to be able to mount XFS filesystems created with this release of xfsprogs on kernel releases older than those, you need to format them with `mkfs.xfs -m reflink=0`.
···
{
services.uwsgi.user = "root";
services.uwsgi.group = "root";
-
services.uwsgi.instance =
-
{
-
uid = "uwsgi";
-
gid = "uwsgi";
-
};
+
services.uwsgi.instance = {
+
uid = "uwsgi";
+
gid = "uwsgi";
+
};
}
```
···
- The attribute `mpi` is now consistently used to provide a default, system-wide MPI implementation. The default implementation is openmpi, which has been used before by all derivations affects by this change. Note that all packages that have used `mpi ? null` in the input for optional MPI builds, have been changed to the boolean input parameter `useMpi` to enable building with MPI. Building all packages with `mpich` instead of the default `openmpi` can now be achieved like this:
```nix
-
self: super:
-
{
-
mpi = super.mpich;
-
}
+
self: super: { mpi = super.mpich; }
```
- The Searx module has been updated with the ability to configure the service declaratively and uWSGI integration. The option `services.searx.configFile` has been renamed to [services.searx.settingsFile](options.html#opt-services.searx.settingsFile) for consistency with the new [services.searx.settings](options.html#opt-services.searx.settings). In addition, the `searx` uid and gid reservations have been removed since they were not necessary: the service is now running with a dynamically allocated uid.
···
```nix
{
-
environment.systemPackages = [
-
pkgs.kodi
-
];
+
environment.systemPackages = [ pkgs.kodi ];
nixpkgs.config.kodi = {
enableInputStreamAdaptive = true;
···
```nix
{
environment.systemPackages = [
-
(pkgs.kodi.withPackages (p: with p; [
-
inputstream-adaptive
-
vfs-sftp
-
]))
+
(pkgs.kodi.withPackages (
+
p: with p; [
+
inputstream-adaptive
+
vfs-sftp
+
]
+
))
];
}
```
···
```nix
{
services.mediatomb.mediaDirectories = [
-
{ path = "/var/lib/mediatomb/pictures"; recursive = false; hidden-files = false; }
-
{ path = "/var/lib/mediatomb/audio"; recursive = true; hidden-files = false; }
+
{
+
path = "/var/lib/mediatomb/pictures";
+
recursive = false;
+
hidden-files = false;
+
}
+
{
+
path = "/var/lib/mediatomb/audio";
+
recursive = true;
+
hidden-files = false;
+
}
];
}
```
···
- [Xfce4](https://www.xfce.org/) relies on GIO/GVfs for userspace virtual filesystem access in applications like [thunar](https://docs.xfce.org/xfce/thunar/) and [gigolo](https://docs.xfce.org/apps/gigolo/). For that to work, the gvfs nixos service is enabled by default, and it can be configured with the specific package that provides GVfs. Until now Xfce4 was setting it to use a lighter version of GVfs (without support for samba). To avoid conflicts with other desktop environments this setting has been dropped. Users that still want it should add the following to their system configuration:
```nix
-
{
-
services.gvfs.package = pkgs.gvfs.override { samba = null; };
-
}
+
{ services.gvfs.package = pkgs.gvfs.override { samba = null; }; }
```
- The newly enabled `systemd-pstore.service` now automatically evacuates crashdumps and panic logs from the persistent storage to `/var/lib/systemd/pstore`. This prevents NVRAM from filling up, which ensures the latest diagnostic data is always stored and alleviates problems with writing new boot configurations.
+1 -1
nixos/doc/manual/release-notes/rl-2111.section.md
···
isSystemUser = true;
group = "foo";
};
-
users.groups.foo = {};
+
users.groups.foo = { };
}
```
+42 -33
nixos/doc/manual/release-notes/rl-2205.section.md
···
tls_certificate_path = "/var/lib/acme/example.com/fullchain.pem";
tls_certificate_path = "/var/lib/acme/example.com/fullchain.pem";
-
listeners = [ {
-
port = 8448;
-
bind_address = "";
-
type = "http";
-
tls = true;
-
resources = [ {
-
names = [ "client" ];
-
compress = true;
-
} {
-
names = [ "federation" ];
-
compress = false;
-
} ];
-
} ];
+
listeners = [
+
{
+
port = 8448;
+
bind_address = "";
+
type = "http";
+
tls = true;
+
resources = [
+
{
+
names = [ "client" ];
+
compress = true;
+
}
+
{
+
names = [ "federation" ];
+
compress = false;
+
}
+
];
+
}
+
];
};
}
···
tls_certificate_path = "/var/lib/acme/example.com/fullchain.pem";
tls_certificate_path = "/var/lib/acme/example.com/fullchain.pem";
-
listeners = [ {
-
port = 8448;
-
bind_addresses = [
-
"::"
-
"0.0.0.0"
-
];
-
type = "http";
-
tls = true;
-
resources = [ {
-
names = [ "client" ];
-
compress = true;
-
} {
-
names = [ "federation" ];
-
compress = false;
-
} ];
-
} ];
+
listeners = [
+
{
+
port = 8448;
+
bind_addresses = [
+
"::"
+
"0.0.0.0"
+
];
+
type = "http";
+
tls = true;
+
resources = [
+
{
+
names = [ "client" ];
+
compress = true;
+
}
+
{
+
names = [ "federation" ];
+
compress = false;
+
}
+
];
+
}
+
];
};
-
extraConfigFiles = [
-
"/run/keys/matrix-synapse/secrets.yaml"
-
];
+
extraConfigFiles = [ "/run/keys/matrix-synapse/secrets.yaml" ];
};
}
```
···
frontendUrl = "https://keycloak.example.com/auth";
database.passwordFile = "/run/keys/db_password";
extraConfig = {
-
"subsystem=undertow"."server=default-server"."http-listener=default".proxy-address-forwarding = true;
+
"subsystem=undertow"."server=default-server"."http-listener=default".proxy-address-forwarding =
+
true;
};
};
}
+3 -11
nixos/doc/manual/release-notes/rl-2211.section.md
···
- `services.github-runner` and `services.github-runners.<name>` gained the option `serviceOverrides` which allows overriding the systemd `serviceConfig`. If you have been overriding the systemd service configuration (i.e., by defining `systemd.services.github-runner.serviceConfig`), you have to use the `serviceOverrides` option now. Example:
```nix
-
{
-
services.github-runner.serviceOverrides.SupplementaryGroups = [
-
"docker"
-
];
-
}
+
{ services.github-runner.serviceOverrides.SupplementaryGroups = [ "docker" ]; }
```
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
···
of environment variables for Grafana. If you had an expression like
```nix
-
{
-
services.grafana.extraOptions.SECURITY_ADMIN_USER = "foobar";
-
}
+
{ services.grafana.extraOptions.SECURITY_ADMIN_USER = "foobar"; }
```
your Grafana instance was running with `GF_SECURITY_ADMIN_USER=foobar` in its environment.
···
to declare
```nix
-
{
-
services.grafana.settings.security.admin_user = "foobar";
-
}
+
{ services.grafana.settings.security.admin_user = "foobar"; }
```
instead.
+13 -15
nixos/doc/manual/release-notes/rl-2305.section.md
···
- NixOS now defaults to using [nsncd](https://github.com/twosigma/nsncd), a non-caching reimplementation of nscd in Rust, as its NSS lookup dispatcher. This replaces the buggy and deprecated nscd implementation provided through glibc. When you find problems, you can switch back by disabling it:
```nix
-
{
-
services.nscd.enableNsncd = false;
-
}
+
{ services.nscd.enableNsncd = false; }
```
- The internal option `boot.bootspec.enable` is now enabled by default because [RFC 0125](https://github.com/NixOS/rfcs/pull/125) was merged. This means you will have a bootspec document called `boot.json` generated for each system and specialisation in the top-level. This is useful to enable advanced boot use cases in NixOS, such as Secure Boot.
···
```nix
{
-
swapDevices = [ {
-
device = "/dev/disk/by-partlabel/swapspace";
-
randomEncryption = {
-
enable = true;
-
cipher = "aes-xts-plain64";
-
keySize = 512;
-
sectorSize = 4096;
-
};
-
} ];
+
swapDevices = [
+
{
+
device = "/dev/disk/by-partlabel/swapspace";
+
randomEncryption = {
+
enable = true;
+
cipher = "aes-xts-plain64";
+
keySize = 512;
+
sectorSize = 4096;
+
};
+
}
+
];
}
```
···
- PostgreSQL has added opt-in support for [JIT compilation](https://www.postgresql.org/docs/current/jit-reason.html). It can be enabled like this:
```nix
-
{
-
services.postgresql.enableJIT = true;
-
}
+
{ services.postgresql.enableJIT = true; }
```
- `services.netdata` offers a [`services.netdata.deadlineBeforeStopSec`](#opt-services.netdata.deadlineBeforeStopSec) option which will control the deadline (in seconds) after which systemd will consider your netdata instance as dead if it didn't start in the elapsed time. It is helpful when your netdata instance takes longer to start because of a large amount of state or upgrades.
+7 -5
nixos/doc/manual/release-notes/rl-2311.section.md
···
```nix
{
services.nextcloud.phpOptions = lib.mkForce {
-
/* ... */
+
# ...
};
}
```
···
```nix
{
python = python3.override {
-
packageOverrides = self: super: {
-
django = super.django_3;
-
};
+
packageOverrides = self: super: { django = super.django_3; };
};
}
```
···
enable = true;
package = pkgs.coredns.override {
externalPlugins = [
-
{name = "fanout"; repo = "github.com/networkservicemesh/fanout"; version = "v1.9.1";}
+
{
+
name = "fanout";
+
repo = "github.com/networkservicemesh/fanout";
+
version = "v1.9.1";
+
}
];
vendorHash = "<SRI hash>";
};
+3 -4
nixos/doc/manual/release-notes/rl-2405.section.md
···
which can now be replaced via an opt-in mechanism. To make your system
perlless, you can use the new perlless profile:
```nix
-
{ modulesPath, ... }: {
+
{ modulesPath, ... }:
+
{
imports = [ "${modulesPath}/profiles/perlless.nix" ];
}
```
···
```nix
{
-
environment.systemPackages = [
-
(azure-cli.withExtensions [ azure-cli.extensions.aks-preview ])
-
];
+
environment.systemPackages = [ (azure-cli.withExtensions [ azure-cli.extensions.aks-preview ]) ];
}
```
To make the `azure-cli` immutable and prevent clashes in case `azure-cli` is also installed via other package managers, some configuration files were moved into the derivation.
+42 -22
nixos/doc/manual/release-notes/rl-2411.section.md
···
```nix
{
featureGates = [ "EphemeralContainers" ];
-
extraOpts = pkgs.lib.concatStringsSep " " (
-
[
-
''--feature-gates="CSIMigration=false"''
-
]
-
);
+
extraOpts = pkgs.lib.concatStringsSep " " ([ ''--feature-gates="CSIMigration=false"'' ]);
}
```
···
{
featureGates = {
EphemeralContainers = true;
-
CSIMigration=false;
+
CSIMigration = false;
};
}
```
···
If you need to upgrade to 24.11 without having completed the migration, consider the security implications of weak password hashes on your user accounts, and add the following to your configuration:
```nix
{
-
services.portunus.package = pkgs.portunus.override { libxcrypt = pkgs.libxcrypt-legacy; };
+
services.portunus.package = pkgs.portunus.override { libxcrypt = pkgs.libxcrypt-legacy; };
services.portunus.ldap.package = pkgs.openldap.override { libxcrypt = pkgs.libxcrypt-legacy; };
}
```
···
```nix
{
-
services.actkbd = let
-
volumeStep = "1%";
-
in {
-
enable = true;
-
bindings = [
-
# "Mute" media key
-
{ keys = [ 113 ]; events = [ "key" ]; command = "${alsa-utils}/bin/amixer -q set Master toggle"; }
+
services.actkbd =
+
let
+
volumeStep = "1%";
+
in
+
{
+
enable = true;
+
bindings = [
+
# "Mute" media key
+
{
+
keys = [ 113 ];
+
events = [ "key" ];
+
command = "${alsa-utils}/bin/amixer -q set Master toggle";
+
}
-
# "Lower Volume" media key
-
{ keys = [ 114 ]; events = [ "key" "rep" ]; command = "${alsa-utils}/bin/amixer -q set Master ${volumeStep}- unmute"; }
+
# "Lower Volume" media key
+
{
+
keys = [ 114 ];
+
events = [
+
"key"
+
"rep"
+
];
+
command = "${alsa-utils}/bin/amixer -q set Master ${volumeStep}- unmute";
+
}
-
# "Raise Volume" media key
-
{ keys = [ 115 ]; events = [ "key" "rep" ]; command = "${alsa-utils}/bin/amixer -q set Master ${volumeStep}+ unmute"; }
+
# "Raise Volume" media key
+
{
+
keys = [ 115 ];
+
events = [
+
"key"
+
"rep"
+
];
+
command = "${alsa-utils}/bin/amixer -q set Master ${volumeStep}+ unmute";
+
}
-
# "Mic Mute" media key
-
{ keys = [ 190 ]; events = [ "key" ]; command = "${alsa-utils}/bin/amixer -q set Capture toggle"; }
-
];
-
};
+
# "Mic Mute" media key
+
{
+
keys = [ 190 ];
+
events = [ "key" ];
+
command = "${alsa-utils}/bin/amixer -q set Capture toggle";
+
}
+
];
+
};
}
```
+5 -1
nixos/doc/manual/release-notes/rl-2505.section.md
···
enable = true;
localName = "Node 1";
localAddress = "galera_01";
-
nodeAddresses = [ "galera_01" "galera_02" "galera_03"];
+
nodeAddresses = [
+
"galera_01"
+
"galera_02"
+
"galera_03"
+
];
};
};
}
+14 -3
nixos/modules/i18n/input-method/default.md
···
i18n.inputMethod = {
enable = true;
type = "ibus";
-
ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ];
+
ibus.engines = with pkgs.ibus-engines; [
+
anthy
+
hangul
+
mozc
+
];
};
}
```
···
```nix
{
-
ibus.engines = with pkgs.ibus-engines; [ table table-others ];
+
ibus.engines = with pkgs.ibus-engines; [
+
table
+
table-others
+
];
}
```
···
i18n.inputMethod = {
enable = true;
type = "fcitx5";
-
fcitx5.addons = with pkgs; [ fcitx5-mozc fcitx5-hangul fcitx5-m17n ];
+
fcitx5.addons = with pkgs; [
+
fcitx5-mozc
+
fcitx5-hangul
+
fcitx5-m17n
+
];
};
}
```
+4 -14
nixos/modules/programs/digitalbitbox/default.md
···
The `digitalbitbox` programs module may be installed by setting
`programs.digitalbitbox` to `true` in a manner similar to
```nix
-
{
-
programs.digitalbitbox.enable = true;
-
}
+
{ programs.digitalbitbox.enable = true; }
```
and bundles the `digitalbitbox` package (see [](#sec-digitalbitbox-package)),
which contains the `dbb-app` and `dbb-cli` binaries, along with the hardware
···
The binaries, `dbb-app` (a GUI tool) and `dbb-cli` (a CLI tool), are available
through the `digitalbitbox` package which could be installed as follows:
```nix
-
{
-
environment.systemPackages = [
-
pkgs.digitalbitbox
-
];
-
}
+
{ environment.systemPackages = [ pkgs.digitalbitbox ]; }
```
## Hardware {#sec-digitalbitbox-hardware-module}
···
The digitalbitbox hardware package enables the udev rules for Digital Bitbox
devices and may be installed as follows:
```nix
-
{
-
hardware.digitalbitbox.enable = true;
-
}
+
{ hardware.digitalbitbox.enable = true; }
```
In order to alter the udev rules, one may provide different values for the
···
{
programs.digitalbitbox = {
enable = true;
-
package = pkgs.digitalbitbox.override {
-
udevRule51 = "something else";
-
};
+
package = pkgs.digitalbitbox.override { udevRule51 = "something else"; };
};
}
```
+1 -3
nixos/modules/programs/plotinus.md
···
To enable Plotinus, add the following to your
{file}`configuration.nix`:
```nix
-
{
-
programs.plotinus.enable = true;
-
}
+
{ programs.plotinus.enable = true; }
```
+6 -4
nixos/modules/programs/zsh/oh-my-zsh.md
···
{
programs.zsh.ohMyZsh = {
enable = true;
-
plugins = [ "git" "python" "man" ];
+
plugins = [
+
"git"
+
"python"
+
"man"
+
];
theme = "agnoster";
};
}
···
The module can do this as well:
```nix
-
{
-
programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts";
-
}
+
{ programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts"; }
```
## Custom environments {#module-programs-oh-my-zsh-environments}
+33 -23
nixos/modules/security/acme/default.md
···
```nix
{
systemd.services.dns-rfc2136-conf = {
-
requiredBy = ["acme-example.com.service" "bind.service"];
-
before = ["acme-example.com.service" "bind.service"];
+
requiredBy = [
+
"acme-example.com.service"
+
"bind.service"
+
];
+
before = [
+
"acme-example.com.service"
+
"bind.service"
+
];
unitConfig = {
ConditionPathExists = "!/var/lib/secrets/dnskeys.conf";
};
serviceConfig = {
Type = "oneshot";
-
UMask = 0077;
+
UMask = 77;
};
path = [ pkgs.bind ];
script = ''
···
# Now you must augment OpenSMTPD's systemd service to load
# the certificate files.
-
systemd.services.opensmtpd.requires = ["acme-finished-mail.example.com.target"];
-
systemd.services.opensmtpd.serviceConfig.LoadCredential = let
-
certDir = config.security.acme.certs."mail.example.com".directory;
-
in [
-
"cert.pem:${certDir}/cert.pem"
-
"key.pem:${certDir}/key.pem"
-
];
+
systemd.services.opensmtpd.requires = [ "acme-finished-mail.example.com.target" ];
+
systemd.services.opensmtpd.serviceConfig.LoadCredential =
+
let
+
certDir = config.security.acme.certs."mail.example.com".directory;
+
in
+
[
+
"cert.pem:${certDir}/cert.pem"
+
"key.pem:${certDir}/key.pem"
+
];
# Finally, configure OpenSMTPD to use these certs.
-
services.opensmtpd = let
-
credsDir = "/run/credentials/opensmtpd.service";
-
in {
-
enable = true;
-
setSendmail = false;
-
serverConfiguration = ''
-
pki mail.example.com cert "${credsDir}/cert.pem"
-
pki mail.example.com key "${credsDir}/key.pem"
-
listen on localhost tls pki mail.example.com
-
action act1 relay host smtp://127.0.0.1:10027
-
match for local action act1
-
'';
-
};
+
services.opensmtpd =
+
let
+
credsDir = "/run/credentials/opensmtpd.service";
+
in
+
{
+
enable = true;
+
setSendmail = false;
+
serverConfiguration = ''
+
pki mail.example.com cert "${credsDir}/cert.pem"
+
pki mail.example.com key "${credsDir}/key.pem"
+
listen on localhost tls pki mail.example.com
+
action act1 relay host smtp://127.0.0.1:10027
+
match for local action act1
+
'';
+
};
}
```
+21 -16
nixos/modules/services/backup/borgbackup.md
···
A very basic configuration for backing up to a locally accessible directory is:
```nix
{
-
services.borgbackup.jobs = {
-
rootBackup = {
-
paths = "/";
-
exclude = [ "/nix" "/path/to/local/repo" ];
-
repo = "/path/to/local/repo";
-
doInit = true;
-
encryption = {
-
mode = "repokey";
-
passphrase = "secret";
-
};
-
compression = "auto,lzma";
-
startAt = "weekly";
+
services.borgbackup.jobs = {
+
rootBackup = {
+
paths = "/";
+
exclude = [
+
"/nix"
+
"/path/to/local/repo"
+
];
+
repo = "/path/to/local/repo";
+
doInit = true;
+
encryption = {
+
mode = "repokey";
+
passphrase = "secret";
};
+
compression = "auto,lzma";
+
startAt = "weekly";
};
+
};
}
```
···
my_borg_repo = {
authorizedKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos"
-
] ;
-
path = "/var/lib/my_borg_repo" ;
+
];
+
path = "/var/lib/my_borg_repo";
};
};
}
···
backupToLocalServer = {
paths = [ "/etc/nixos" ];
doInit = true;
-
repo = "borg@nixos:." ;
+
repo = "borg@nixos:.";
encryption = {
mode = "repokey-blake2";
passCommand = "cat /run/keys/borgbackup_passphrase";
};
-
environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_my_borg_repo"; };
+
environment = {
+
BORG_RSH = "ssh -i /run/keys/id_ed25519_my_borg_repo";
+
};
compression = "auto,lzma";
startAt = "hourly";
};
+2 -6
nixos/modules/services/databases/foundationdb.md
···
{file}`/var/lib/foundationdb`. You can override this using
{option}`services.foundationdb.dataDir`, e.g.
```nix
-
{
-
services.foundationdb.dataDir = "/data/fdb";
-
}
+
{ services.foundationdb.dataDir = "/data/fdb"; }
```
Similarly, logs are stored under {file}`/var/log/foundationdb`
···
set up the paths in the module options:
```nix
-
{
-
services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ];
-
}
+
{ services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ]; }
```
Restart the FoundationDB service, and it will now be able to write to this
+52 -47
nixos/modules/services/databases/postgresql.md
···
By default, PostgreSQL stores its databases in {file}`/var/lib/postgresql/$psqlSchema`. You can override this using [](#opt-services.postgresql.dataDir), e.g.
```nix
-
{
-
services.postgresql.dataDir = "/data/postgresql";
-
}
+
{ services.postgresql.dataDir = "/data/postgresql"; }
```
## Initializing {#module-services-postgres-initializing}
···
```
For an upgrade, a script like this can be used to simplify the process:
```nix
-
{ config, lib, pkgs, ... }:
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
{
environment.systemPackages = [
-
(let
-
# XXX specify the postgresql package you'd like to upgrade to.
-
# Do not forget to list the extensions you need.
-
newPostgres = pkgs.postgresql_13.withPackages (pp: [
-
# pp.plv8
-
]);
-
cfg = config.services.postgresql;
-
in pkgs.writeScriptBin "upgrade-pg-cluster" ''
-
set -eux
-
# XXX it's perhaps advisable to stop all services that depend on postgresql
-
systemctl stop postgresql
+
(
+
let
+
# XXX specify the postgresql package you'd like to upgrade to.
+
# Do not forget to list the extensions you need.
+
newPostgres = pkgs.postgresql_13.withPackages (pp: [
+
# pp.plv8
+
]);
+
cfg = config.services.postgresql;
+
in
+
pkgs.writeScriptBin "upgrade-pg-cluster" ''
+
set -eux
+
# XXX it's perhaps advisable to stop all services that depend on postgresql
+
systemctl stop postgresql
-
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
-
export NEWBIN="${newPostgres}/bin"
+
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
+
export NEWBIN="${newPostgres}/bin"
-
export OLDDATA="${cfg.dataDir}"
-
export OLDBIN="${cfg.finalPackage}/bin"
+
export OLDDATA="${cfg.dataDir}"
+
export OLDBIN="${cfg.finalPackage}/bin"
-
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
-
cd "$NEWDATA"
-
sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA" ${lib.escapeShellArgs cfg.initdbArgs}
+
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
+
cd "$NEWDATA"
+
sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA" ${lib.escapeShellArgs cfg.initdbArgs}
-
sudo -u postgres "$NEWBIN/pg_upgrade" \
-
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
-
--old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
-
"$@"
-
'')
+
sudo -u postgres "$NEWBIN/pg_upgrade" \
+
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
+
--old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
+
"$@"
+
''
+
)
];
}
```
···
```nix
{
services.postgresql.package = pkgs.postgresql_17;
-
services.postgresql.extensions = ps: with ps; [
-
pg_repack
-
postgis
-
];
+
services.postgresql.extensions =
+
ps: with ps; [
+
pg_repack
+
postgis
+
];
}
```
···
Here's a recipe on how to override a particular plugin through an overlay:
```nix
self: super: {
-
postgresql_15 = super.postgresql_15// {
+
postgresql_15 = super.postgresql_15 // {
pkgs = super.postgresql_15.pkgs // {
pg_repack = super.postgresql_15.pkgs.pg_repack.overrideAttrs (_: {
name = "pg_repack-v20181024";
···
They are packaged as plugins and can be made available in the same way as external extensions:
```nix
{
-
services.postgresql.extensions = ps: with ps; [
-
plperl
-
plpython3
-
pltcl
-
];
+
services.postgresql.extensions =
+
ps: with ps; [
+
plperl
+
plpython3
+
pltcl
+
];
}
```
···
For example, to make `python3Packages.base58` available:
```nix
{
-
services.postgresql.extensions = pgps: with pgps; [
-
(plpython3.withPackages (pyps: with pyps; [ base58 ]))
-
];
+
services.postgresql.extensions =
+
pgps: with pgps; [ (plpython3.withPackages (pyps: with pyps; [ base58 ])) ];
}
```
···
can be optionally enabled in PostgreSQL with the following config option:
```nix
-
{
-
services.postgresql.enableJIT = true;
-
}
+
{ services.postgresql.enableJIT = true; }
```
This makes sure that the [`jit`](https://www.postgresql.org/docs/current/runtime-config-query.html#GUC-JIT)-setting
···
with import <nixpkgs> {
overlays = [
(self: super: {
-
postgresql = super.postgresql.overrideAttrs (_: { pname = "foobar"; });
+
postgresql = super.postgresql.overrideAttrs (_: {
+
pname = "foobar";
+
});
})
];
};
···
* When using [`TABLESPACE`](https://www.postgresql.org/docs/current/manage-ag-tablespaces.html)s, make sure to add the filesystem paths to `ReadWritePaths` like this:
```nix
{
-
systemd.services.postgresql.serviceConfig.ReadWritePaths = [
-
"/path/to/tablespace/location"
-
];
+
systemd.services.postgresql.serviceConfig.ReadWritePaths = [ "/path/to/tablespace/location" ];
}
```
+1 -3
nixos/modules/services/databases/tigerbeetle.md
···
To enable TigerBeetle, add the following to your {file}`configuration.nix`:
```nix
-
{
-
services.tigerbeetle.enable = true;
-
}
+
{ services.tigerbeetle.enable = true; }
```
When first started, the TigerBeetle service will create its data file at {file}`/var/lib/tigerbeetle` unless the file already exists, in which case it will just use the existing file.
+4 -12
nixos/modules/services/desktop-managers/gnome.md
···
If you’d like to only use the GNOME desktop and not the apps, you can disable them with:
```nix
-
{
-
services.gnome.core-apps.enable = false;
-
}
+
{ services.gnome.core-apps.enable = false; }
```
and none of them will be installed.
···
You can install all of the GNOME games with:
```nix
-
{
-
services.gnome.games.enable = true;
-
}
+
{ services.gnome.games.enable = true; }
```
### GNOME core developer tools {#sec-gnome-core-developer-tools}
···
You can install GNOME core developer tools with:
```nix
-
{
-
services.gnome.core-developer-tools.enable = true;
-
}
+
{ services.gnome.core-developer-tools.enable = true; }
```
## Enabling GNOME Flashback {#sec-gnome-enable-flashback}
···
GNOME Flashback provides a desktop environment based on the classic GNOME 2 architecture. You can enable the default GNOME Flashback session, which uses the Metacity window manager, with:
```nix
-
{
-
services.desktopManager.gnome.flashback.enableMetacity = true;
-
}
+
{ services.desktopManager.gnome.flashback.enableMetacity = true; }
```
It is also possible to create custom sessions that replace Metacity with a different window manager using [](#opt-services.desktopManager.gnome.flashback.customSessions).
+1 -3
nixos/modules/services/desktops/flatpak.md
···
To enable Flatpak, add the following to your {file}`configuration.nix`:
```nix
-
{
-
services.flatpak.enable = true;
-
}
+
{ services.flatpak.enable = true; }
```
For the sandboxed apps to work correctly, desktop integration portals need to
+8 -10
nixos/modules/services/development/athens.md
···
A very basic configuration for Athens that acts as a caching and forwarding HTTP proxy is:
```nix
{
-
services.athens = {
-
enable = true;
-
};
+
services.athens = {
+
enable = true;
+
};
}
```
···
```nix
{
-
services.athens = {
-
enable = true;
-
storageType = "memory";
-
};
+
services.athens = {
+
enable = true;
+
storageType = "memory";
+
};
}
```
···
This can either be done via the nix-daemon systemd unit:
```nix
-
{
-
systemd.services.nix-daemon.environment.GOPROXY = "http://localhost:3000";
-
}
+
{ systemd.services.nix-daemon.environment.GOPROXY = "http://localhost:3000"; }
```
or via the [impure-env experimental feature](https://nix.dev/manual/nix/2.24/command-ref/conf-file#conf-impure-env):
+3 -4
nixos/modules/services/development/blackfire.md
···
To use it, you will need to enable the agent and the probe on your server. The exact method will depend on the way you use PHP but here is an example of NixOS configuration for PHP-FPM:
```nix
let
-
php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [
-
blackfire
-
]));
-
in {
+
php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [ blackfire ]));
+
in
+
{
# Enable the probe extension for PHP-FPM.
services.phpfpm = {
phpPackage = php;
+4 -1
nixos/modules/services/development/livebook.md
···
```nix
{
-
services.livebook.extraPackages = with pkgs; [ gcc gnumake ];
+
services.livebook.extraPackages = with pkgs; [
+
gcc
+
gnumake
+
];
}
```
+58 -41
nixos/modules/services/editors/emacs.md
···
```nix
/*
-
This is a nix expression to build Emacs and some Emacs packages I like
-
from source on any distribution where Nix is installed. This will install
-
all the dependencies from the nixpkgs repository and build the binary files
-
without interfering with the host distribution.
+
This is a nix expression to build Emacs and some Emacs packages I like
+
from source on any distribution where Nix is installed. This will install
+
all the dependencies from the nixpkgs repository and build the binary files
+
without interfering with the host distribution.
-
To build the project, type the following from the current directory:
+
To build the project, type the following from the current directory:
-
$ nix-build emacs.nix
+
$ nix-build emacs.nix
-
To run the newly compiled executable:
+
To run the newly compiled executable:
-
$ ./result/bin/emacs
+
$ ./result/bin/emacs
*/
# The first non-comment line in this file indicates that
# the whole file represents a function.
-
{ pkgs ? import <nixpkgs> {} }:
+
{
+
pkgs ? import <nixpkgs> { },
+
}:
let
# The let expression below defines a myEmacs binding pointing to the
···
# argument: a function from a package set to a list of packages
# (the packages that will be available in Emacs).
emacsWithPackages = (pkgs.emacsPackagesFor myEmacs).emacsWithPackages;
-
in
# The rest of the file specifies the list of packages to install. In the
# example, two packages (magit and zerodark-theme) are taken from
# MELPA stable.
-
emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [
-
magit # ; Integrate git <C-x g>
+
in
+
emacsWithPackages (
+
epkgs:
+
(with epkgs.melpaStablePackages; [
+
magit # ; Integrate git <C-x g>
zerodark-theme # ; Nicolas' theme
])
# Two packages (undo-tree and zoom-frm) are taken from MELPA.
++ (with epkgs.melpaPackages; [
-
undo-tree # ; <C-x u> to show the undo tree
-
zoom-frm # ; increase/decrease font size for all buffers %lt;C-x C-+>
+
undo-tree # ; <C-x u> to show the undo tree
+
zoom-frm # ; increase/decrease font size for all buffers %lt;C-x C-+>
])
# Three packages are taken from GNU ELPA.
++ (with epkgs.elpaPackages; [
-
auctex # ; LaTeX mode
-
beacon # ; highlight my cursor when scrolling
-
nameless # ; hide current package name everywhere in elisp code
+
auctex # ; LaTeX mode
+
beacon # ; highlight my cursor when scrolling
+
nameless # ; hide current package name everywhere in elisp code
])
# notmuch is taken from a nixpkgs derivation which contains an Emacs mode.
++ [
-
pkgs.notmuch # From main packages set
-
])
+
pkgs.notmuch # From main packages set
+
]
+
)
```
:::
···
```nix
{
-
environment.systemPackages = [
-
# [...]
-
(import ./emacs.nix { inherit pkgs; })
+
environment.systemPackages = [
+
# [...]
+
(import ./emacs.nix { inherit pkgs; })
];
}
```
···
```nix
{
-
packageOverrides = super: let self = super.pkgs; in {
-
myemacs = import ./emacs.nix { pkgs = self; };
-
};
+
packageOverrides =
+
super:
+
let
+
self = super.pkgs;
+
in
+
{
+
myemacs = import ./emacs.nix { pkgs = self; };
+
};
}
```
:::
···
### Custom Emacs build
```nix
-
{ pkgs ? import <nixpkgs> {} }:
+
{
+
pkgs ? import <nixpkgs> { },
+
}:
let
-
myEmacs = (pkgs.emacs.override {
-
# Use gtk3 instead of the default gtk2
-
withGTK3 = true;
-
withGTK2 = false;
-
}).overrideAttrs (attrs: {
-
# I don't want emacs.desktop file because I only use
-
# emacsclient.
-
postInstall = (attrs.postInstall or "") + ''
-
rm $out/share/applications/emacs.desktop
-
'';
-
});
-
in [ /* ... */ ]
+
myEmacs =
+
(pkgs.emacs.override {
+
# Use gtk3 instead of the default gtk2
+
withGTK3 = true;
+
withGTK2 = false;
+
}).overrideAttrs
+
(attrs: {
+
# I don't want emacs.desktop file because I only use
+
# emacsclient.
+
postInstall =
+
(attrs.postInstall or "")
+
+ ''
+
rm $out/share/applications/emacs.desktop
+
'';
+
});
+
in
+
[
+
# ...
+
]
```
:::
···
To install and enable the {command}`systemd` user service for Emacs
daemon, add the following to your {file}`configuration.nix`:
```nix
-
{
-
services.emacs.enable = true;
-
}
+
{ services.emacs.enable = true; }
```
The {var}`services.emacs.package` option allows a custom
+46 -35
nixos/modules/services/hardware/display.md
···
# completely disable output no matter what is connected to it
hardware.display.outputs."VGA-2".mode = "d";
-
/* equals
-
boot.kernelParams = [ "video=DP-1:e" "video=VGA-2:d" ];
+
/*
+
equals
+
boot.kernelParams = [ "video=DP-1:e" "video=VGA-2:d" ];
*/
}
```
···
```nix
{
hardware.display.edid.packages = [
-
(pkgs.runCommand "edid-custom" {} ''
-
mkdir -p $out/lib/firmware/edid
-
base64 -d > "$out/lib/firmware/edid/custom1.bin" <<'EOF'
-
<insert your base64 encoded EDID file here `base64 < /sys/class/drm/card0-.../edid`>
-
EOF
-
base64 -d > "$out/lib/firmware/edid/custom2.bin" <<'EOF'
-
<insert your base64 encoded EDID file here `base64 < /sys/class/drm/card1-.../edid`>
-
EOF
+
(pkgs.runCommand "edid-custom" { } ''
+
mkdir -p $out/lib/firmware/edid
+
base64 -d > "$out/lib/firmware/edid/custom1.bin" <<'EOF'
+
<insert your base64 encoded EDID file here `base64 < /sys/class/drm/card0-.../edid`>
+
EOF
+
base64 -d > "$out/lib/firmware/edid/custom2.bin" <<'EOF'
+
<insert your base64 encoded EDID file here `base64 < /sys/class/drm/card1-.../edid`>
+
EOF
'')
];
}
···
{
hardware.display.outputs."VGA-1".edid = "custom1.bin";
hardware.display.outputs."VGA-2".edid = "custom2.bin";
-
/* equals:
-
boot.kernelParams = [ "drm.edid_firmware=VGA-1:edid/custom1.bin,VGA-2:edid/custom2.bin" ];
+
/*
+
equals:
+
boot.kernelParams = [ "drm.edid_firmware=VGA-1:edid/custom1.bin,VGA-2:edid/custom2.bin" ];
*/
}
```
···
```nix
{
-
hardware.display.edid.linuxhw."PG278Q_2014" = [ "PG278Q" "2014" ];
+
hardware.display.edid.linuxhw."PG278Q_2014" = [
+
"PG278Q"
+
"2014"
+
];
-
/* equals:
-
hardware.display.edid.packages = [
-
(pkgs.linuxhw-edid-fetcher.override {
-
displays = {
-
"PG278Q_2014" = [ "PG278Q" "2014" ];
-
};
-
})
-
];
+
/*
+
equals:
+
hardware.display.edid.packages = [
+
(pkgs.linuxhw-edid-fetcher.override {
+
displays = {
+
"PG278Q_2014" = [ "PG278Q" "2014" ];
+
};
+
})
+
];
*/
}
```
···
```nix
{
-
hardware.display.edid.modelines."PG278Q_60" = " 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync";
-
hardware.display.edid.modelines."PG278Q_120" = " 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync";
+
hardware.display.edid.modelines."PG278Q_60" =
+
" 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync";
+
hardware.display.edid.modelines."PG278Q_120" =
+
" 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync";
-
/* equals:
-
hardware.display.edid.packages = [
-
(pkgs.edid-generator.overrideAttrs {
-
clean = true;
-
modelines = ''
-
Modeline "PG278Q_60" 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync
-
Modeline "PG278Q_120" 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync
-
'';
-
})
-
];
+
/*
+
equals:
+
hardware.display.edid.packages = [
+
(pkgs.edid-generator.overrideAttrs {
+
clean = true;
+
modelines = ''
+
Modeline "PG278Q_60" 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync
+
Modeline "PG278Q_120" 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync
+
'';
+
})
+
];
*/
}
```
···
```nix
{
-
hardware.display.edid.modelines."PG278Q_60" = " 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync";
-
hardware.display.edid.modelines."PG278Q_120" = " 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync";
+
hardware.display.edid.modelines."PG278Q_60" =
+
" 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync";
+
hardware.display.edid.modelines."PG278Q_120" =
+
" 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync";
hardware.display.outputs."DP-1".edid = "PG278Q_60.bin";
hardware.display.outputs."DP-1".mode = "e";
+13 -7
nixos/modules/services/mail/mailman.md
···
For a basic configuration with Postfix as the MTA, the following settings are suggested:
```nix
-
{ config, ... }: {
+
{ config, ... }:
+
{
services.postfix = {
enable = true;
-
relayDomains = ["hash:/var/lib/mailman/data/postfix_domains"];
+
relayDomains = [ "hash:/var/lib/mailman/data/postfix_domains" ];
sslCert = config.security.acme.certs."lists.example.org".directory + "/full.pem";
sslKey = config.security.acme.certs."lists.example.org".directory + "/key.pem";
config = {
-
transport_maps = ["hash:/var/lib/mailman/data/postfix_lmtp"];
-
local_recipient_maps = ["hash:/var/lib/mailman/data/postfix_lmtp"];
+
transport_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
+
local_recipient_maps = [ "hash:/var/lib/mailman/data/postfix_lmtp" ];
};
};
services.mailman = {
enable = true;
serve.enable = true;
hyperkitty.enable = true;
-
webHosts = ["lists.example.org"];
+
webHosts = [ "lists.example.org" ];
siteOwner = "mailman@example.org";
};
services.nginx.virtualHosts."lists.example.org".enableACME = true;
-
networking.firewall.allowedTCPPorts = [ 25 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
25
+
80
+
443
+
];
}
```
···
Mailman also supports other MTA, though with a little bit more configuration. For example, to use Mailman with Exim, you can use the following settings:
```nix
-
{ config, ... }: {
+
{ config, ... }:
+
{
services = {
mailman = {
enable = true;
+1 -3
nixos/modules/services/matrix/maubot.md
···
2. If you want to use PostgreSQL instead of SQLite, do this:
```nix
-
{
-
services.maubot.settings.database = "postgresql://maubot@localhost/maubot";
-
}
+
{ services.maubot.settings.database = "postgresql://maubot@localhost/maubot"; }
```
If the PostgreSQL connection requires a password, you will have to
+5 -9
nixos/modules/services/matrix/mjolnir.md
···
enable = true;
homeserverUrl = "https://matrix.domain.tld";
pantalaimon = {
-
enable = true;
-
username = "mjolnir";
-
passwordFile = "/run/secrets/mjolnir-password";
+
enable = true;
+
username = "mjolnir";
+
passwordFile = "/run/secrets/mjolnir-password";
};
-
protectedRooms = [
-
"https://matrix.to/#/!xxx:domain.tld"
-
];
+
protectedRooms = [ "https://matrix.to/#/!xxx:domain.tld" ];
managementRoom = "!yyy:domain.tld";
};
}
···
```nix
{
services.matrix-synapse = {
-
plugins = with pkgs; [
-
matrix-synapse-plugins.matrix-synapse-mjolnir-antispam
-
];
+
plugins = with pkgs; [ matrix-synapse-plugins.matrix-synapse-mjolnir-antispam ];
extraConfig = ''
modules:
- module: mjolnir.Module
+25 -14
nixos/modules/services/matrix/synapse.md
···
please refer to the
[installation instructions of Synapse](https://element-hq.github.io/synapse/latest/setup/installation.html) .
```nix
-
{ pkgs, lib, config, ... }:
+
{
+
pkgs,
+
lib,
+
config,
+
...
+
}:
let
fqdn = "${config.networking.hostName}.${config.networking.domain}";
baseUrl = "https://${fqdn}";
···
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON data}';
'';
-
in {
+
in
+
{
networking.hostName = "myhostname";
networking.domain = "example.org";
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
services.postgresql.enable = true;
···
# in client applications.
settings.public_baseurl = baseUrl;
settings.listeners = [
-
{ port = 8008;
+
{
+
port = 8008;
bind_addresses = [ "::1" ];
type = "http";
tls = false;
x_forwarded = true;
-
resources = [ {
-
names = [ "client" "federation" ];
-
compress = true;
-
} ];
+
resources = [
+
{
+
names = [
+
"client"
+
"federation"
+
];
+
compress = true;
+
}
+
];
}
];
};
···
```nix
{
-
services.matrix-synapse.extraConfigFiles = [
-
"/run/secrets/matrix-shared-secret"
-
];
+
services.matrix-synapse.extraConfigFiles = [ "/run/secrets/matrix-shared-secret" ];
}
```
:::
···
services.nginx.virtualHosts."element.${fqdn}" = {
enableACME = true;
forceSSL = true;
-
serverAliases = [
-
"element.${config.networking.domain}"
-
];
+
serverAliases = [ "element.${config.networking.domain}" ];
root = pkgs.element-web.override {
conf = {
+1 -3
nixos/modules/services/misc/anki-sync-server.md
···
You can change the directory by using `services.anki-sync-server.baseDirectory`
```nix
-
{
-
services.anki-sync-server.baseDirectory = "/home/anki/data";
-
}
+
{ services.anki-sync-server.baseDirectory = "/home/anki/data"; }
```
By default, the server listen address {option}`services.anki-sync-server.host`
+2 -2
nixos/modules/services/misc/dump1090-fa.md
···
Exposing the integrated web interface is left to the user's configuration. Below is a minimal example demonstrating how to serve it using Nginx:
```nix
-
{ pkgs, ... }: {
+
{ pkgs, ... }:
+
{
services.dump1090-fa.enable = true;
services.nginx = {
···
};
};
}
-
```
+2 -2
nixos/modules/services/misc/forgejo.md
···
repo = "nixpkgs";
rev = "3bb45b041e7147e2fd2daf689e26a1f970a55d65";
hash = "sha256-8JL5NI9eUcGzzbR/ARkrG81WLwndoxqI650mA/4rUGI=";
-
}) {};
+
}) { };
in
{
services.forgejo.package = nixpkgs-forgejo-10.forgejo;
···
isSystemUser = true;
};
-
users.groups.gitea = {};
+
users.groups.gitea = { };
}
```
+3 -1
nixos/modules/services/misc/gitlab.md
···
email_from = "gitlab-no-reply@example.com";
email_display_name = "Example GitLab";
email_reply_to = "gitlab-no-reply@example.com";
-
default_projects_features = { builds = false; };
+
default_projects_features = {
+
builds = false;
+
};
};
};
};
+1 -3
nixos/modules/services/misc/paisa.md
···
access to the command at runtime.
```nix
-
{
-
systemd.services.paisa.path = [ pkgs.hledger ];
-
}
+
{ systemd.services.paisa.path = [ pkgs.hledger ]; }
```
::: {.note}
+2 -2
nixos/modules/services/monitoring/parsedmarc.md
···
# Not required, but recommended for full functionality
services.geoipupdate = {
settings = {
-
AccountID = 000000;
+
AccountID = 0;
LicenseKey = "/path/to/license_key_file";
};
};
···
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
-
upstreams.grafana.servers."unix:/${config.services.grafana.socket}" = {};
+
upstreams.grafana.servers."unix:/${config.services.grafana.socket}" = { };
virtualHosts.${url} = {
root = config.services.grafana.staticRootPath;
enableACME = true;
+29 -17
nixos/modules/services/monitoring/prometheus/exporters.md
···
"logind"
"systemd"
];
-
disabledCollectors = [
-
"textfile"
-
];
+
disabledCollectors = [ "textfile" ];
openFirewall = true;
firewallFilter = "-i br0 -p tcp -m tcp --dport 9100";
};
···
Prometheus can now be configured to consume the metrics produced by the exporter:
```nix
{
-
services.prometheus = {
-
# ...
+
services.prometheus = {
+
# ...
-
scrapeConfigs = [
-
{
-
job_name = "node";
-
static_configs = [{
-
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
-
}];
-
}
-
];
+
scrapeConfigs = [
+
{
+
job_name = "node";
+
static_configs = [
+
{
+
targets = [
+
"localhost:${toString config.services.prometheus.exporters.node.port}"
+
];
+
}
+
];
+
}
+
];
-
# ...
-
};
+
# ...
+
};
}
```
···
specific options and configuration:
```nix
# nixpkgs/nixos/modules/services/prometheus/exporters/postfix.nix
-
{ config, lib, pkgs, options }:
+
{
+
config,
+
lib,
+
pkgs,
+
options,
+
}:
let
# for convenience we define cfg here
cfg = config.services.prometheus.exporters.postfix;
···
information about the change to the exporter definition similar to
`nixpkgs/nixos/modules/rename.nix`:
```nix
-
{ config, lib, pkgs, options }:
+
{
+
config,
+
lib,
+
pkgs,
+
options,
+
}:
let
cfg = config.services.prometheus.exporters.nginx;
+17 -17
nixos/modules/services/network-filesystems/litestream/default.md
···
{
users.users.litestream.extraGroups = [ "grafana" ];
-
systemd.services.grafana.serviceConfig.ExecStartPost = "+" + pkgs.writeShellScript "grant-grafana-permissions" ''
-
timeout=10
+
systemd.services.grafana.serviceConfig.ExecStartPost =
+
"+"
+
+ pkgs.writeShellScript "grant-grafana-permissions" ''
+
timeout=10
-
while [ ! -f /var/lib/grafana/data/grafana.db ];
-
do
-
if [ "$timeout" == 0 ]; then
-
echo "ERROR: Timeout while waiting for /var/lib/grafana/data/grafana.db."
-
exit 1
-
fi
+
while [ ! -f /var/lib/grafana/data/grafana.db ];
+
do
+
if [ "$timeout" == 0 ]; then
+
echo "ERROR: Timeout while waiting for /var/lib/grafana/data/grafana.db."
+
exit 1
+
fi
-
sleep 1
+
sleep 1
-
((timeout--))
-
done
+
((timeout--))
+
done
-
find /var/lib/grafana -type d -exec chmod -v 775 {} \;
-
find /var/lib/grafana -type f -exec chmod -v 660 {} \;
-
'';
+
find /var/lib/grafana -type d -exec chmod -v 775 {} \;
+
find /var/lib/grafana -type f -exec chmod -v 660 {} \;
+
'';
services.litestream = {
enable = true;
···
dbs = [
{
path = "/var/lib/grafana/data/grafana.db";
-
replicas = [{
-
url = "s3://mybkt.litestream.io/grafana";
-
}];
+
replicas = [ { url = "s3://mybkt.litestream.io/grafana"; } ];
}
];
};
+1 -3
nixos/modules/services/network-filesystems/samba.md
···
A minimal configuration looks like this:
```nix
-
{
-
services.samba.enable = true;
-
}
+
{ services.samba.enable = true; }
```
This configuration automatically enables `smbd`, `nmbd` and `winbindd` services by default.
+5 -2
nixos/modules/services/networking/anubis.md
···
A minimal configuration with [nginx](#opt-services.nginx.enable) may look like the following:
```nix
-
{ config, ... }: {
+
{ config, ... }:
+
{
services.anubis.instances.default.settings.TARGET = "http://localhost:8000";
# required due to unix socket permissions
···
```nix
{
services.anubis.defaultOptions = {
-
botPolicy = { dnsbl = false; };
+
botPolicy = {
+
dnsbl = false;
+
};
settings.DIFFICULTY = 3;
};
}
+1 -1
nixos/modules/services/networking/atalkd.md
···
{
services.atalkd = {
enable = true;
-
interfaces.wlan0.config = "-router -phase 2 -net 1 -addr 1.48 -zone \"Default\"";
+
interfaces.wlan0.config = ''-router -phase 2 -net 1 -addr 1.48 -zone "Default"'';
};
}
```
+1 -3
nixos/modules/services/networking/crab-hole.md
···
To give the crab-hole service access to these files, the group which owns the certificate can be added as a supplementary group to the service.
For ACME for example:
```nix
-
{
-
services.crab-hole.supplementaryGroups = [ "acme" ];
-
}
+
{ services.crab-hole.supplementaryGroups = [ "acme" ]; }
```
+4 -1
nixos/modules/services/networking/doh-server.md
···
defaults.email = "you@example.com";
};
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
}
```
+1 -3
nixos/modules/services/networking/jotta-cli.md
···
## Quick Start {#module-services-jotta-cli-quick-start}
```nix
-
{
-
services.jotta-cli.enable = true;
-
}
+
{ services.jotta-cli.enable = true; }
```
This adds `jotta-cli` to `environment.systemPackages` and starts a user service that runs `jottad` with the default options.
+31 -25
nixos/modules/services/networking/mosquitto.md
···
{
services.mosquitto = {
enable = true;
-
listeners = [ {
-
acl = [ "pattern readwrite #" ];
-
omitPasswordAuth = true;
-
settings.allow_anonymous = true;
-
} ];
+
listeners = [
+
{
+
acl = [ "pattern readwrite #" ];
+
omitPasswordAuth = true;
+
settings.allow_anonymous = true;
+
}
+
];
};
}
```
···
{
services.mosquitto = {
enable = true;
-
listeners = [ {
-
users = {
-
monitor = {
-
acl = [ "read #" ];
-
password = "monitor";
-
};
-
service = {
-
acl = [ "write service/#" ];
-
password = "service";
+
listeners = [
+
{
+
users = {
+
monitor = {
+
acl = [ "read #" ];
+
password = "monitor";
+
};
+
service = {
+
acl = [ "write service/#" ];
+
password = "service";
+
};
};
-
};
-
} ];
+
}
+
];
};
}
```
···
{
services.mosquitto = {
enable = true;
-
listeners = [ {
-
port = 8883; # port change is not required, but helpful to avoid mistakes
-
# ...
-
settings = {
-
cafile = "/path/to/mqtt.ca.pem";
-
certfile = "/path/to/mqtt.pem";
-
keyfile = "/path/to/mqtt.key";
-
};
-
} ];
+
listeners = [
+
{
+
port = 8883; # port change is not required, but helpful to avoid mistakes
+
# ...
+
settings = {
+
cafile = "/path/to/mqtt.ca.pem";
+
certfile = "/path/to/mqtt.pem";
+
keyfile = "/path/to/mqtt.key";
+
};
+
}
+
];
};
}
```
+1 -3
nixos/modules/services/networking/netbird.md
···
The absolute minimal configuration for the Netbird client daemon looks like this:
```nix
-
{
-
services.netbird.enable = true;
-
}
+
{ services.netbird.enable = true; }
```
This will set up a netbird service listening on the port `51820` associated to the
+22 -22
nixos/modules/services/networking/pleroma.md
···
secretConfigFile = "/var/lib/pleroma/secrets.exs";
configs = [
''
-
import Config
+
import Config
-
config :pleroma, Pleroma.Web.Endpoint,
-
url: [host: "pleroma.example.net", scheme: "https", port: 443],
-
http: [ip: {127, 0, 0, 1}, port: 4000]
+
config :pleroma, Pleroma.Web.Endpoint,
+
url: [host: "pleroma.example.net", scheme: "https", port: 443],
+
http: [ip: {127, 0, 0, 1}, port: 4000]
-
config :pleroma, :instance,
-
name: "Test",
-
email: "admin@example.net",
-
notify_email: "admin@example.net",
-
limit: 5000,
-
registrations_open: true
+
config :pleroma, :instance,
+
name: "Test",
+
email: "admin@example.net",
+
notify_email: "admin@example.net",
+
limit: 5000,
+
registrations_open: true
-
config :pleroma, :media_proxy,
-
enabled: false,
-
redirect_on_failure: true
+
config :pleroma, :media_proxy,
+
enabled: false,
+
redirect_on_failure: true
-
config :pleroma, Pleroma.Repo,
-
adapter: Ecto.Adapters.Postgres,
-
username: "pleroma",
-
database: "pleroma",
-
hostname: "localhost"
+
config :pleroma, Pleroma.Repo,
+
adapter: Ecto.Adapters.Postgres,
+
username: "pleroma",
+
database: "pleroma",
+
hostname: "localhost"
-
# Configure web push notifications
-
config :web_push_encryption, :vapid_details,
-
subject: "mailto:admin@example.net"
+
# Configure web push notifications
+
config :web_push_encryption, :vapid_details,
+
subject: "mailto:admin@example.net"
-
# ... TO CONTINUE ...
+
# ... TO CONTINUE ...
''
];
};
+10 -9
nixos/modules/services/networking/prosody.md
···
ssl.cert = "/var/lib/acme/example.org/fullchain.pem";
ssl.key = "/var/lib/acme/example.org/key.pem";
virtualHosts."example.org" = {
-
enabled = true;
-
domain = "example.org";
-
ssl.cert = "/var/lib/acme/example.org/fullchain.pem";
-
ssl.key = "/var/lib/acme/example.org/key.pem";
+
enabled = true;
+
domain = "example.org";
+
ssl.cert = "/var/lib/acme/example.org/fullchain.pem";
+
ssl.key = "/var/lib/acme/example.org/key.pem";
};
-
muc = [ {
-
domain = "conference.example.org";
-
} ];
+
muc = [ { domain = "conference.example.org"; } ];
uploadHttp = {
-
domain = "upload.example.org";
+
domain = "upload.example.org";
};
};
}
···
"example.org" = {
webroot = "/var/www/example.org";
email = "root@example.org";
-
extraDomainNames = [ "conference.example.org" "upload.example.org" ];
+
extraDomainNames = [
+
"conference.example.org"
+
"upload.example.org"
+
];
};
};
};
+46 -32
nixos/modules/services/networking/yggdrasil.md
···
services.yggdrasil = {
enable = true;
persistentKeys = false;
-
# The NixOS module will generate new keys and a new IPv6 address each time
-
# it is started if persistentKeys is not enabled.
+
# The NixOS module will generate new keys and a new IPv6 address each time
+
# it is started if persistentKeys is not enabled.
settings = {
Peers = [
···
address = "210:5217:69c0:9afc:1b95:b9f:8718:c3d2";
prefix = "310:5217:69c0:9afc";
# taken from the output of "yggdrasilctl getself".
-
in {
+
in
+
{
services.yggdrasil = {
enable = true;
persistentKeys = true; # Maintain a fixed public key and IPv6 address.
settings = {
-
Peers = [ "tcp://1.2.3.4:1024" "tcp://1.2.3.5:1024" ];
+
Peers = [
+
"tcp://1.2.3.4:1024"
+
"tcp://1.2.3.5:1024"
+
];
NodeInfo = {
# This information is visible to the network.
name = config.networking.hostName;
···
};
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
-
# Forward traffic under the prefix.
+
# Forward traffic under the prefix.
-
networking.interfaces.${eth0}.ipv6.addresses = [{
-
# Set a 300::/8 address on the local physical device.
-
address = prefix + "::1";
-
prefixLength = 64;
-
}];
+
networking.interfaces.${eth0}.ipv6.addresses = [
+
{
+
# Set a 300::/8 address on the local physical device.
+
address = prefix + "::1";
+
prefixLength = 64;
+
}
+
];
services.radvd = {
# Announce the 300::/8 prefix to eth0.
···
```nix
let
yggPrefix64 = "310:5217:69c0:9afc";
-
# Again, taken from the output of "yggdrasilctl getself".
+
# Again, taken from the output of "yggdrasilctl getself".
in
{
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
···
interfaces.br0 = {
# … configured with a prefix address.
-
ipv6.addresses = [{
-
address = "${yggPrefix64}::1";
-
prefixLength = 64;
-
}];
+
ipv6.addresses = [
+
{
+
address = "${yggPrefix64}::1";
+
prefixLength = 64;
+
}
+
];
};
};
···
privateNetwork = true;
hostBridge = "br0";
# Attach the container to the bridge only.
-
config = { config, pkgs, ... }: {
-
networking.interfaces.eth0.ipv6 = {
-
addresses = [{
-
# Configure a prefix address.
-
address = "${yggPrefix64}::2";
-
prefixLength = 64;
-
}];
-
routes = [{
-
# Configure the prefix route.
-
address = "200::";
-
prefixLength = 7;
-
via = "${yggPrefix64}::1";
-
}];
+
config =
+
{ config, pkgs, ... }:
+
{
+
networking.interfaces.eth0.ipv6 = {
+
addresses = [
+
{
+
# Configure a prefix address.
+
address = "${yggPrefix64}::2";
+
prefixLength = 64;
+
}
+
];
+
routes = [
+
{
+
# Configure the prefix route.
+
address = "200::";
+
prefixLength = 7;
+
via = "${yggPrefix64}::1";
+
}
+
];
+
};
+
+
services.httpd.enable = true;
+
networking.firewall.allowedTCPPorts = [ 80 ];
};
-
-
services.httpd.enable = true;
-
networking.firewall.allowedTCPPorts = [ 80 ];
-
};
};
}
+1 -3
nixos/modules/services/search/meilisearch.md
···
the minimum to start meilisearch is
```nix
-
{
-
services.meilisearch.enable = true;
-
}
+
{ services.meilisearch.enable = true; }
```
this will start the http server included with meilisearch on port 7700.
+9 -1
nixos/modules/services/system/kerberos/kerberos-server.md
···
enable = true;
settings = {
realms."EXAMPLE.COM" = {
-
acl = [{ principal = "adminuser"; access= ["add" "cpw"]; }];
+
acl = [
+
{
+
principal = "adminuser";
+
access = [
+
"add"
+
"cpw"
+
];
+
}
+
];
};
};
};
+5 -5
nixos/modules/services/system/systemd-lock-handler.md
···
systemd.user.services.swaylock = {
description = "Screen locker for Wayland";
-
documentation = ["man:swaylock(1)"];
+
documentation = [ "man:swaylock(1)" ];
# If swaylock exits cleanly, unlock the session:
-
onSuccess = ["unlock.target"];
+
onSuccess = [ "unlock.target" ];
# When lock.target is stopped, stops this too:
-
partOf = ["lock.target"];
+
partOf = [ "lock.target" ];
# Delay lock.target until this service is ready:
-
before = ["lock.target"];
-
wantedBy = ["lock.target"];
+
before = [ "lock.target" ];
+
wantedBy = [ "lock.target" ];
serviceConfig = {
# systemd will consider this service started when swaylock forks...
+39 -39
nixos/modules/services/web-apps/akkoma.md
···
```nix
{
-
services.akkoma.config.":pleroma".":mrf".policies =
-
map (pkgs.formats.elixirConf { }).lib.mkRaw [
-
"Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy"
+
services.akkoma.config.":pleroma".":mrf".policies = map (pkgs.formats.elixirConf { }).lib.mkRaw [
+
"Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy"
];
}
```
···
```nix
{
-
services.akkoma.frontends.primary.package = pkgs.runCommand "akkoma-fe" {
-
config = builtins.toJSON {
-
expertLevel = 1;
-
collapseMessageWithSubject = false;
-
stopGifs = false;
-
replyVisibility = "following";
-
webPushHideIfCW = true;
-
hideScopeNotice = true;
-
renderMisskeyMarkdown = false;
-
hideSiteFavicon = true;
-
postContentType = "text/markdown";
-
showNavShortcuts = false;
-
};
-
nativeBuildInputs = with pkgs; [ jq xorg.lndir ];
-
passAsFile = [ "config" ];
-
} ''
-
mkdir $out
-
lndir ${pkgs.akkoma-frontends.akkoma-fe} $out
+
services.akkoma.frontends.primary.package =
+
pkgs.runCommand "akkoma-fe"
+
{
+
config = builtins.toJSON {
+
expertLevel = 1;
+
collapseMessageWithSubject = false;
+
stopGifs = false;
+
replyVisibility = "following";
+
webPushHideIfCW = true;
+
hideScopeNotice = true;
+
renderMisskeyMarkdown = false;
+
hideSiteFavicon = true;
+
postContentType = "text/markdown";
+
showNavShortcuts = false;
+
};
+
nativeBuildInputs = with pkgs; [
+
jq
+
xorg.lndir
+
];
+
passAsFile = [ "config" ];
+
}
+
''
+
mkdir $out
+
lndir ${pkgs.akkoma-frontends.akkoma-fe} $out
-
rm $out/static/config.json
-
jq -s add ${pkgs.akkoma-frontends.akkoma-fe}/static/config.json ${config} \
-
>$out/static/config.json
-
'';
+
rm $out/static/config.json
+
jq -s add ${pkgs.akkoma-frontends.akkoma-fe}/static/config.json ${config} \
+
>$out/static/config.json
+
'';
}
```
···
```nix
{
services.akkoma.config.":pleroma" = with (pkgs.formats.elixirConf { }).lib; {
-
":mrf".policies = map mkRaw [
-
"Pleroma.Web.ActivityPub.MRF.SimplePolicy"
-
];
+
":mrf".policies = map mkRaw [ "Pleroma.Web.ActivityPub.MRF.SimplePolicy" ];
":mrf_simple" = {
# Tag all media as sensitive
-
media_nsfw = mkMap {
-
"nsfw.weird.kinky" = "Untagged NSFW content";
-
};
+
media_nsfw = mkMap { "nsfw.weird.kinky" = "Untagged NSFW content"; };
# Reject all activities except deletes
reject = mkMap {
···
```nix
{
services.akkoma.config.":pleroma"."Pleroma.Upload".filters =
-
map (pkgs.formats.elixirConf { }).lib.mkRaw [
-
"Pleroma.Upload.Filter.Exiftool"
-
"Pleroma.Upload.Filter.Dedupe"
-
"Pleroma.Upload.Filter.AnonymizeFilename"
-
];
+
map (pkgs.formats.elixirConf { }).lib.mkRaw
+
[
+
"Pleroma.Upload.Filter.Exiftool"
+
"Pleroma.Upload.Filter.Dedupe"
+
"Pleroma.Upload.Filter.AnonymizeFilename"
+
];
}
```
···
The Akkoma systemd service may be confined to a chroot with
```nix
-
{
-
services.systemd.akkoma.confinement.enable = true;
-
}
+
{ services.systemd.akkoma.confinement.enable = true; }
```
Confinement of services is not generally supported in NixOS and therefore disabled by default.
+1 -3
nixos/modules/services/web-apps/c2fmzq-server.md
···
The service `c2fmzq-server` can be enabled by setting
```nix
-
{
-
services.c2fmzq-server.enable = true;
-
}
+
{ services.c2fmzq-server.enable = true; }
```
This will spin up an instance of the server which is API-compatible with
[Stingle Photos](https://stingle.org) and an experimental Progressive Web App
+4 -1
nixos/modules/services/web-apps/castopod.md
···
```nix
{
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
services.castopod = {
enable = true;
database.createLocally = true;
+5 -2
nixos/modules/services/web-apps/filesender.md
···
```nix
let
-
format = pkgs.formats.php {};
+
format = pkgs.formats.php { };
in
{
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
services.filesender = {
enable = true;
localDomain = "filesender.example.com";
+4 -1
nixos/modules/services/web-apps/gotosocial.md
···
```nix
{
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
services.nginx = {
enable = true;
clientMaxBodySize = "40M";
+8 -2
nixos/modules/services/web-apps/jitsi-meet.md
···
hostName = "jitsi.example.com";
};
services.jitsi-videobridge.openFirewall = true;
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
security.acme.email = "me@example.com";
security.acme.acceptTerms = true;
}
···
};
};
services.jitsi-videobridge.openFirewall = true;
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
security.acme.email = "me@example.com";
security.acme.acceptTerms = true;
}
+1 -1
nixos/modules/services/web-apps/keycloak.md
···
hostname = "keycloak.example.com";
hostname-strict-backchannel = true;
};
-
initialAdminPassword = "e6Wcm0RrtegMEHl"; # change on first login
+
initialAdminPassword = "e6Wcm0RrtegMEHl"; # change on first login
sslCertificate = "/run/keys/ssl_cert";
sslCertificateKey = "/run/keys/ssl_key";
database.passwordFile = "/run/keys/db_password";
+20 -10
nixos/modules/services/web-apps/nextcloud.md
···
};
};
-
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
networking.firewall.allowedTCPPorts = [
+
80
+
443
+
];
}
```
···
or the systemd configuration from `nextcloud-setup.service` (recommended):
```nix
-
{ config, ... }: {
+
{ config, ... }:
+
{
systemd.services.my-custom-service = {
script = ''
nextcloud-occ …
···
inherit (config.systemd.services.nextcloud-cron.serviceConfig)
User
LoadCredential
-
KillMode;
+
KillMode
+
;
};
};
}
···
the cache size to zero:
```nix
-
{
-
services.nextcloud.phpOptions."realpath_cache_size" = "0";
-
}
+
{ services.nextcloud.phpOptions."realpath_cache_size" = "0"; }
```
- **Empty Files on chunked uploads**
···
An exemplary configuration may look like this:
```nix
-
{ config, lib, pkgs, ... }: {
+
{
+
config,
+
lib,
+
pkgs,
+
...
+
}:
+
{
services.nginx.enable = false;
services.nextcloud = {
enable = true;
hostName = "localhost";
-
/* further, required options */
+
# further, required options
};
services.phpfpm.pools.nextcloud.settings = {
"listen.owner" = config.services.httpd.user;
···
that are managed by Nix:
```nix
-
{ config, pkgs, ... }: {
+
{ config, pkgs, ... }:
+
{
services.nextcloud.extraApps = with config.services.nextcloud.package.packages.apps; {
inherit user_oidc calendar contacts;
};
···
packages, but mark them as insecure in an expression like this (in
`<nixpkgs/pkgs/servers/nextcloud/default.nix>`):
```nix
-
/* ... */
+
# ...
{
nextcloud17 = generic {
version = "17.0.x";
+1 -3
nixos/modules/services/web-apps/pict-rs.md
···
the minimum to start pict-rs is
```nix
-
{
-
services.pict-rs.enable = true;
-
}
+
{ services.pict-rs.enable = true; }
```
this will start the http server on port 8080 by default.
+1 -1
nixos/modules/services/web-servers/garage.md
···
packages, but mark them as insecure in an expression like this (in
`<nixpkgs/pkgs/tools/filesystem/garage/default.nix>`):
```nix
-
/* ... */
+
# ...
{
garage_1_2_0 = generic {
version = "1.2.0";
+4 -15
nixos/modules/services/x11/desktop-managers/pantheon.md
···
All of Pantheon is working in NixOS and the applications should be available, aside from a few [exceptions](https://github.com/NixOS/nixpkgs/issues/58161). To enable Pantheon, set
```nix
-
{
-
services.xserver.desktopManager.pantheon.enable = true;
-
}
+
{ services.xserver.desktopManager.pantheon.enable = true; }
```
This automatically enables LightDM and Pantheon's LightDM greeter. If you'd like to disable this, set
```nix
···
```
but please be aware using Pantheon without LightDM as a display manager will break screenlocking from the UI. The NixOS module for Pantheon installs all of Pantheon's default applications. If you'd like to not install Pantheon's apps, set
```nix
-
{
-
services.pantheon.apps.enable = false;
-
}
+
{ services.pantheon.apps.enable = false; }
```
You can also use [](#opt-environment.pantheon.excludePackages) to remove any other app (like `elementary-mail`).
···
The difference in NixOS is both these programs are patched to load plugins from a directory that is the value of an environment variable. All of which is controlled in Nix. If you need to configure the particular packages manually you can override the packages like:
```nix
wingpanel-with-indicators.override {
-
indicators = [
-
pkgs.some-special-indicator
-
];
+
indicators = [ pkgs.some-special-indicator ];
}
-
```
```nix
-
switchboard-with-plugs.override {
-
plugs = [
-
pkgs.some-special-plug
-
];
-
}
+
switchboard-with-plugs.override { plugs = [ pkgs.some-special-plug ]; }
```
please note that, like how the NixOS options describe these as extra plugins, this would only add to the default plugins included with the programs. If for some reason you'd like to configure which plugins to use exactly, both packages have an argument for this:
```nix
+2 -6
nixos/modules/system/boot/clevis.md
···
In order to activate unattended decryption of a resource at boot, enable the `clevis` module:
```nix
-
{
-
boot.initrd.clevis.enable = true;
-
}
+
{ boot.initrd.clevis.enable = true; }
```
Then, specify the device you want to decrypt using a given clevis secret. Clevis will automatically try to decrypt the device at boot and will fallback to interactive unlocking if the decryption policy is not fulfilled.
```nix
-
{
-
boot.initrd.clevis.devices."/dev/nvme0n1p1".secretFile = ./nvme0n1p1.jwe;
-
}
+
{ boot.initrd.clevis.devices."/dev/nvme0n1p1".secretFile = ./nvme0n1p1.jwe; }
```
Only `bcachefs`, `zfs` and `luks` encrypted devices are supported at this time.
+2 -1
nixos/modules/system/boot/loader/external/external.md
···
You can enable FooBoot like this:
```nix
-
{ pkgs, ... }: {
+
{ pkgs, ... }:
+
{
boot.loader.external = {
enable = true;
installHook = "${pkgs.fooboot}/bin/fooboot-install";
+64 -36
pkgs/README.md
···
The latter avoids link rot when the upstream abandons, squashes or rebases their change, in which case the commit may get garbage-collected.
```nix
-
{
-
patches = [ ./0001-add-missing-include.patch ];
-
}
+
{ patches = [ ./0001-add-missing-include.patch ]; }
```
If you do need to do create this sort of patch file, one way to do so is with git:
···
For very simple tests, they can be written inline:
```nix
-
{ /* ... , */ yq-go }:
+
# ... ,
+
{ yq-go }:
buildGoModule rec {
# …
passthru.tests = {
-
simple = runCommand "${pname}-test" {} ''
+
simple = runCommand "${pname}-test" { } ''
echo "test: 1" | ${yq-go}/bin/yq eval -j > $out
[ "$(cat $out | tr -d $'\n ')" = '{"test":1}' ]
'';
···
```nix
# my-package/example.nix
-
{ runCommand, lib, my-package, ... }:
-
runCommand "my-package-test" {
-
nativeBuildInputs = [ my-package ];
-
src = lib.sources.sourcesByRegex ./. [ ".*.in" ".*.expected" ];
-
} ''
-
my-package --help
-
my-package <example.in >example.actual
-
diff -U3 --color=auto example.expected example.actual
-
mkdir $out
-
''
+
{
+
runCommand,
+
lib,
+
my-package,
+
...
+
}:
+
runCommand "my-package-test"
+
{
+
nativeBuildInputs = [ my-package ];
+
src = lib.sources.sourcesByRegex ./. [
+
".*.in"
+
".*.expected"
+
];
+
}
+
''
+
my-package --help
+
my-package <example.in >example.actual
+
diff -U3 --color=auto example.expected example.actual
+
mkdir $out
+
''
```
### Writing larger package tests
···
Add the tests in `passthru.tests` to the package definition like this:
```nix
-
{ stdenv, lib, fetchurl, callPackage }:
+
{
+
stdenv,
+
lib,
+
fetchurl,
+
callPackage,
+
}:
stdenv.mkDerivation {
# …
···
simple-execution = callPackage ./tests.nix { };
};
-
meta = { /* … */ };
+
meta = {
+
# …
+
};
}
```
···
let
inherit (phoronix-test-suite) pname version;
+
in
-
-
runCommand "${pname}-tests" { meta.timeout = 60; }
-
''
-
# automatic initial setup to prevent interactive questions
-
${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null
-
# get version of installed program and compare with package version
-
if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then
-
echo "Error: program version does not match package version"
-
exit 1
-
fi
-
# run dummy command
-
${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null
-
# needed for Nix to register the command as successful
-
touch $out
-
''
+
runCommand "${pname}-tests" { meta.timeout = 60; } ''
+
# automatic initial setup to prevent interactive questions
+
${phoronix-test-suite}/bin/phoronix-test-suite enterprise-setup >/dev/null
+
# get version of installed program and compare with package version
+
if [[ `${phoronix-test-suite}/bin/phoronix-test-suite version` != *"${version}"* ]]; then
+
echo "Error: program version does not match package version"
+
exit 1
+
fi
+
# run dummy command
+
${phoronix-test-suite}/bin/phoronix-test-suite dummy_module.dummy-command >/dev/null
+
# needed for Nix to register the command as successful
+
touch $out
+
''
```
### Running package tests
···
For example, assuming we're packaging `nginx`, we can link its module test via `passthru.tests`:
```nix
-
{ stdenv, lib, nixosTests }:
+
{
+
stdenv,
+
lib,
+
nixosTests,
+
}:
stdenv.mkDerivation {
# ...
···
{ stdenv }:
stdenv.mkDerivation {
# ...
-
passthru.updateScript = [ ../../update.sh pname "--requested-release=unstable" ];
+
passthru.updateScript = [
+
../../update.sh
+
pname
+
"--requested-release=unstable"
+
];
}
```
···
pname = "my-package";
# ...
passthru.updateScript = {
-
command = [ ../../update.sh pname ];
+
command = [
+
../../update.sh
+
pname
+
];
attrPath = pname;
-
supportedFeatures = [ /* ... */ ];
+
supportedFeatures = [
+
# ...
+
];
};
}
```
+10 -8
pkgs/applications/emulators/libretro/README.md
···
{ pkgs, ... }:
let
-
retroarchWithCores = (pkgs.retroarch.withCores (cores: with cores; [
-
bsnes
-
mgba
-
quicknes
-
]));
+
retroarchWithCores = (
+
pkgs.retroarch.withCores (
+
cores: with cores; [
+
bsnes
+
mgba
+
quicknes
+
]
+
)
+
);
in
{
-
environment.systemPackages = [
-
retroarchWithCores
-
];
+
environment.systemPackages = [ retroarchWithCores ];
}
```
+14 -27
pkgs/by-name/README.md
···
# The return value must be a derivation
stdenv.mkDerivation {
# ...
-
buildInputs =
-
lib.optional enableBar libbar;
+
buildInputs = lib.optional enableBar libbar;
}
```
···
```nix
{
-
libfoo = callPackage ../by-name/so/some-package/package.nix {
-
libbar = libbar_2;
-
};
+
libfoo = callPackage ../by-name/so/some-package/package.nix { libbar = libbar_2; };
}
```
···
```nix
# all-packages.nix
{
-
fooWithBaz = foo.override {
-
bar = baz;
-
};
+
fooWithBaz = foo.override { bar = baz; };
}
```
```nix
# turned into pkgs/by-name/fo/fooWithBaz/package.nix with:
-
{
-
foo,
-
baz,
-
}:
+
{ foo, baz }:
-
foo.override {
-
bar = baz;
-
}
+
foo.override { bar = baz; }
```
## Limitations
···
This is not required, but the above solution also allows refactoring the definitions into a separate file:
```nix
-
{
-
inherit (import ../tools/foo pkgs)
-
foo_1 foo_2;
-
}
+
{ inherit (import ../tools/foo pkgs) foo_1 foo_2; }
```
```nix
···
if `callPackage` isn't used underneath and you want the same `.override` arguments for all attributes:
```nix
-
{
-
inherit (callPackages ../tools/foo { })
-
foo_1 foo_2;
-
}
+
{ inherit (callPackages ../tools/foo { }) foo_1 foo_2; }
```
```nix
# pkgs/tools/foo/default.nix
+
{ stdenv }:
{
-
stdenv
-
}: {
-
foo_1 = stdenv.mkDerivation { /* ... */ };
-
foo_2 = stdenv.mkDerivation { /* ... */ };
+
foo_1 = stdenv.mkDerivation {
+
# ...
+
};
+
foo_2 = stdenv.mkDerivation {
+
# ...
+
};
}
```
+1 -3
pkgs/by-name/az/azure-cli/README.md
···
url = "https://github.com/Azure/azure-devops-cli-extension/releases/download/20240206.1/azure_devops-${version}-py2.py3-none-any.whl";
sha256 = "658a2854d8c80f874f9382d421fa45abf6a38d00334737dda006f8dec64cf70a";
description = "Tools for managing Azure DevOps";
-
propagatedBuildInputs = with python3Packages; [
-
distro
-
];
+
propagatedBuildInputs = with python3Packages; [ distro ];
meta.maintainers = with lib.maintainers; [ katexochen ];
};
}
+5 -4
pkgs/development/tcl-modules/by-name/README.md
···
The only difference is the scope:
```nix
-
{ lib
-
# You can get tclPackages attributes directly
-
, mkTclDerivation
-
, tcllib
+
{
+
lib,
+
# You can get tclPackages attributes directly
+
mkTclDerivation,
+
tcllib,
}:
mkTclDerivation {
+6 -9
pkgs/servers/home-assistant/custom-components/README.md
···
**Example Boilerplate:**
```nix
-
{ lib
-
, buildHomeAssistantComponent
-
, fetchFromGitHub
+
{
+
lib,
+
buildHomeAssistantComponent,
+
fetchFromGitHub,
}:
buildHomeAssistantComponent {
···
```nix
{
-
dependencies = [
-
pyemvue
-
];
+
dependencies = [ pyemvue ];
# don't check the version constraint of pyemvue
-
ignoreVersionRequirement = [
-
"pyemvue"
-
];
+
ignoreVersionRequirement = [ "pyemvue" ];
}
```
+1 -3
pkgs/servers/home-assistant/custom-lovelace-modules/README.md
···
The entrypoint used can be overridden in `passthru` like this:
```nix
-
{
-
passthru.entrypoint = "demo-card-bundle.js";
-
}
+
{ passthru.entrypoint = "demo-card-bundle.js"; }
```