···243243If the requested file is present in the Nix store, the resulting derivation will not be built, because its expected output is already available.
244244Otherwise, the builder will run, but fail with a message explaining to the user how to provide the file. The following code, for example:
245245246246-```
246246+```nix
247247requireFile {
248248 name = "jdk-${version}_linux-x64_bin.tar.gz";
249249 url = "https://www.oracle.com/java/technologies/javase-jdk11-downloads.html";
···270270271271`fetchtorrent` expects two arguments. `url` which can either be a Magnet URI (Magnet Link) such as `magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c` or an HTTP URL pointing to a `.torrent` file. It can also take a `config` argument which will craft a `settings.json` configuration file and give it to `transmission`, the underlying program that is performing the fetch. The available config options for `transmission` can be found [here](https://github.com/transmission/transmission/blob/main/docs/Editing-Configuration-Files.md#options)
272272273273-```
273273+```nix
274274{ fetchtorrent }:
275275276276fetchtorrent {
+2-2
doc/languages-frameworks/cuelang.section.md
···2626Nixpkgs provides a `pkgs.writeCueValidator` helper, which will write a validation script based on the provided Cuelang schema.
27272828Here is an example:
2929-```
2929+```nix
3030pkgs.writeCueValidator
3131 (pkgs.writeText "schema.cue" ''
3232 #Def1: {
···4242`document` : match your input data against this fragment of structure or definition, e.g. you may use the same schema file but different documents based on the data you are validating.
43434444Another example, given the following `validator.nix` :
4545-```
4545+```nix
4646{ pkgs ? import <nixpkgs> {} }:
4747let
4848 genericValidator = version:
+1-1
doc/languages-frameworks/dotnet.section.md
···236236$ nuget-to-nix out > deps.nix
237237```
238238Which `nuget-to-nix` will generate an output similar to below
239239-```
239239+```nix
240240{ fetchNuGet }: [
241241 (fetchNuGet { pname = "FosterFramework"; version = "0.1.15-alpha"; sha256 = "0pzsdfbsfx28xfqljcwy100xhbs6wyx0z1d5qxgmv3l60di9xkll"; })
242242 (fetchNuGet { pname = "Microsoft.AspNetCore.App.Runtime.linux-x64"; version = "8.0.1"; sha256 = "1gjz379y61ag9whi78qxx09bwkwcznkx2mzypgycibxk61g11da1"; })
+6-6
doc/languages-frameworks/lisp.section.md
···45454646Also one can create a `pkgs.mkShell` environment in `shell.nix`/`flake.nix`:
47474848-```
4848+```nix
4949let
5050 sbcl' = sbcl.withPackages (ps: [ ps.alexandria ]);
5151in mkShell {
···55555656Such a Lisp can be now used e.g. to compile your sources:
57575858-```
5858+```nix
5959buildPhase = ''
6060 ${sbcl'}/bin/sbcl --load my-build-file.lisp
6161''
···173173A package defined outside Nixpkgs using `buildASDFSystem` can be woven into the
174174Nixpkgs-provided scope like this:
175175176176-```
176176+```nix
177177let
178178 alexandria = sbcl.buildASDFSystem rec {
179179 pname = "alexandria";
···199199200200Example of overriding `alexandria`:
201201202202-```
202202+```nix
203203sbcl.pkgs.alexandria.overrideLispAttrs (oldAttrs: rec {
204204 version = "1.4";
205205 src = fetchFromGitLab {
···225225226226To package slashy systems, use `overrideLispAttrs`, like so:
227227228228-```
228228+```nix
229229ecl.pkgs.alexandria.overrideLispAttrs (oldAttrs: {
230230 systems = oldAttrs.systems ++ [ "alexandria/tests" ];
231231 lispLibs = oldAttrs.lispLibs ++ [ ecl.pkgs.rt ];
···290290291291This example wraps CLISP:
292292293293-```
293293+```nix
294294wrapLisp {
295295 pkg = clisp;
296296 faslExt = "fas";
+1-1
doc/languages-frameworks/pkg-config.section.md
···12121313A good example of all these things is zlib:
14141515-```
1515+```nix
1616{ pkg-config, testers, ... }:
17171818stdenv.mkDerivation (finalAttrs: {
+13-13
doc/languages-frameworks/python.section.md
···11971197Pytest is the most common test runner for python repositories. A trivial
11981198test run would be:
1199119912001200-```
12001200+```nix
12011201 nativeCheckInputs = [ pytest ];
12021202 checkPhase = ''
12031203 runHook preCheck
···1213121312141214To filter tests using pytest, one can do the following:
1215121512161216-```
12161216+```nix
12171217 nativeCheckInputs = [ pytest ];
12181218 # avoid tests which need additional data or touch network
12191219 checkPhase = ''
···1248124812491249Using the example above, the analogous `pytestCheckHook` usage would be:
1250125012511251-```
12511251+```nix
12521252 nativeCheckInputs = [
12531253 pytestCheckHook
12541254 ];
···12731273This is especially useful when tests need to be conditionally disabled,
12741274for example:
1275127512761276-```
12761276+```nix
12771277 disabledTests = [
12781278 # touches network
12791279 "download"
···12981298To help ensure the package still works, [`pythonImportsCheck`](#using-pythonimportscheck) can attempt to import
12991299the listed modules.
1300130013011301-```
13011301+```nix
13021302 pythonImportsCheck = [
13031303 "requests"
13041304 "urllib"
···1307130713081308roughly translates to:
1309130913101310-```
13101310+```nix
13111311 postCheck = ''
13121312 PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
13131313 python -c "import requests; import urllib"
···1342134213431343we can do:
1344134413451345-```
13451345+```nix
13461346 nativeBuildInputs = [
13471347 pythonRelaxDepsHook
13481348 ];
···13651365Another option is to pass `true`, that will relax/remove all dependencies, for
13661366example:
1367136713681368-```
13681368+```nix
13691369 nativeBuildInputs = [ pythonRelaxDepsHook ];
13701370 pythonRelaxDeps = true;
13711371```
···1392139213931393`unittestCheckHook` is a hook which will substitute the setuptools `test` command for a [`checkPhase`](#ssec-check-phase) which runs `python -m unittest discover`:
1394139413951395-```
13951395+```nix
13961396 nativeCheckInputs = [
13971397 unittestCheckHook
13981398 ];
···14091409It is setup to automatically find common documentation source paths and
14101410render them using the default `html` style.
1411141114121412-```
14121412+```nix
14131413 outputs = [
14141414 "out"
14151415 "doc"
···14241424`doc` output, if it exists. It also provides an automatic diversion
14251425for the artifacts of the `man` builder into the `man` target.
1426142614271427-```
14271427+```nix
14281428 outputs = [
14291429 "out"
14301430 "doc"
···14411441Overwrite `sphinxRoot` when the hook is unable to find your
14421442documentation source root.
1443144314441444-```
14441444+```nix
14451445 # Configure sphinxRoot for uncommon paths
14461446 sphinxRoot = "weird/docs/path";
14471447```
···19201920the builds are in that case not reproducible. To enable optimizations, override the
19211921interpreter of interest, e.g using
1922192219231923-```
19231923+```nix
19241924let
19251925 pkgs = import ./. {};
19261926 mypython = pkgs.python3.override {
+2-2
doc/languages-frameworks/rust.section.md
···458458and fetches every dependency as a separate fixed-output derivation.
459459`importCargoLock` can be used as follows:
460460461461-```
461461+```nix
462462cargoDeps = rustPlatform.importCargoLock {
463463 lockFile = ./Cargo.lock;
464464};
···468468hashes need to be specified since they are not available through the
469469lock file. For example:
470470471471-```
471471+```nix
472472cargoDeps = rustPlatform.importCargoLock {
473473 lockFile = ./Cargo.lock;
474474 outputHashes = {
+1-1
doc/languages-frameworks/swift.section.md
···147147A special function `swiftpmMakeMutable` is available to replace the symlink
148148with a writable copy:
149149150150-```
150150+```nix
151151configurePhase = generated.configure ++ ''
152152 # Replace the dependency symlink with a writable copy.
153153 swiftpmMakeMutable swift-crypto
+2-2
doc/packages/darwin-builder.section.md
···81818282## Example flake usage {#sec-darwin-builder-example-flake}
83838484-```
8484+```nix
8585{
8686 inputs = {
8787 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin";
···153153To do this, you just need to set the `virtualisation.darwin-builder.*` parameters as
154154in the example below and rebuild.
155155156156-```
156156+```nix
157157 darwin-builder = nixpkgs.lib.nixosSystem {
158158 system = linuxSystem;
159159 modules = [
···254254255255- `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:
256256257257- ```
257257+ ```nix
258258 services.github-runner.serviceOverrides.SupplementaryGroups = [
259259 "docker"
260260 ];
+1-1
nixos/doc/manual/release-notes/rl-2311.section.md
···12281228- CoreDNS may be built with external plugins now. This may be done by
12291229 overriding `externalPlugins` and `vendorHash` arguments like this:
1230123012311231- ```
12311231+ ```nix
12321232 services.coredns = {
12331233 enable = true;
12341234 package = pkgs.coredns.override {
+1-1
nixos/doc/manual/release-notes/rl-2405.section.md
···5757 without perl). Previously, the NixOS activation depended on two perl scripts
5858 which can now be replaced via an opt-in mechanism. To make your system
5959 perlless, you can use the new perlless profile:
6060- ```
6060+ ```nix
6161 { modulesPath, ... }: {
6262 imports = [ "${modulesPath}/profiles/perlless.nix" ];
6363 }
+7-7
nixos/modules/i18n/input-method/default.md
···22222323The following snippet can be used to configure IBus:
24242525-```
2525+```nix
2626i18n.inputMethod = {
2727 enabled = "ibus";
2828 ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ];
···4848 methods, it must appear in the list of engines along with
4949 `table`. For example:
50505151- ```
5151+ ```nix
5252 ibus.engines = with pkgs.ibus-engines; [ table table-others ];
5353 ```
5454···74747575The following snippet can be used to configure Fcitx:
76767777-```
7777+```nix
7878i18n.inputMethod = {
7979 enabled = "fcitx5";
8080 fcitx5.addons = with pkgs; [ fcitx5-mozc fcitx5-hangul fcitx5-m17n ];
···110110111111The following snippet can be used to configure Nabi:
112112113113-```
113113+```nix
114114i18n.inputMethod = {
115115 enabled = "nabi";
116116};
···123123124124The following snippet can be used to configure uim:
125125126126-```
126126+```nix
127127i18n.inputMethod = {
128128 enabled = "uim";
129129};
···141141142142The following snippet can be used to configure Hime:
143143144144-```
144144+```nix
145145i18n.inputMethod = {
146146 enabled = "hime";
147147};
···153153154154The following snippet can be used to configure Kime:
155155156156-```
156156+```nix
157157i18n.inputMethod = {
158158 enabled = "kime";
159159};
+4-4
nixos/modules/programs/digitalbitbox/default.md
···4455The `digitalbitbox` programs module may be installed by setting
66`programs.digitalbitbox` to `true` in a manner similar to
77-```
77+```nix
88programs.digitalbitbox.enable = true;
99```
1010and bundles the `digitalbitbox` package (see [](#sec-digitalbitbox-package)),
···21212222The binaries, `dbb-app` (a GUI tool) and `dbb-cli` (a CLI tool), are available
2323through the `digitalbitbox` package which could be installed as follows:
2424-```
2424+```nix
2525environment.systemPackages = [
2626 pkgs.digitalbitbox
2727];
···31313232The digitalbitbox hardware package enables the udev rules for Digital Bitbox
3333devices and may be installed as follows:
3434-```
3434+```nix
3535hardware.digitalbitbox.enable = true;
3636```
37373838In order to alter the udev rules, one may provide different values for the
3939`udevRule51` and `udevRule52` attributes by means of overriding as follows:
4040-```
4040+```nix
4141programs.digitalbitbox = {
4242 enable = true;
4343 package = pkgs.digitalbitbox.override {
+1-1
nixos/modules/programs/plotinus.md
···12121313To enable Plotinus, add the following to your
1414{file}`configuration.nix`:
1515-```
1515+```nix
1616programs.plotinus.enable = true;
1717```
+4-4
nixos/modules/programs/zsh/oh-my-zsh.md
···99The module uses the `oh-my-zsh` package with all available
1010features. The initial setup using Nix expressions is fairly similar to the
1111configuration format of `oh-my-zsh`.
1212-```
1212+```nix
1313{
1414 programs.zsh.ohMyZsh = {
1515 enable = true;
···3333scripts.
34343535The module can do this as well:
3636-```
3636+```nix
3737{
3838 programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts";
3939}
···48484949Rather than using a single mutable path for `ZSH_CUSTOM`,
5050it's also possible to generate this path from a list of Nix packages:
5151-```
5151+```nix
5252{ pkgs, ... }:
5353{
5454 programs.zsh.ohMyZsh.customPkgs = [
···8989 [upstream repo.](https://github.com/robbyrussell/oh-my-zsh/tree/91b771914bc7c43dd7c7a43b586c5de2c225ceb7/plugins)
90909191A derivation for `oh-my-zsh` may look like this:
9292-```
9292+```nix
9393{ stdenv, fetchFromGitHub }:
94949595stdenv.mkDerivation rec {
+3-3
nixos/modules/services/backup/borgbackup.md
···2121## Basic usage for a local backup {#opt-services-backup-borgbackup-local-directory}
22222323A very basic configuration for backing up to a locally accessible directory is:
2424-```
2424+```nix
2525{
2626 opt.services.borgbackup.jobs = {
2727 { rootBackup = {
···5959```
60606161Add the following snippet to your NixOS configuration:
6262-```
6262+```nix
6363{
6464 services.borgbackup.repos = {
6565 my_borg_repo = {
···8080{file}`/run/keys/borgbackup_passphrase`, which should be only
8181accessible by root
82828383-```
8383+```nix
8484{
8585 services.borgbackup.jobs = {
8686 backupToLocalServer = {
+3-3
nixos/modules/services/databases/foundationdb.md
···15151616To enable FoundationDB, add the following to your
1717{file}`configuration.nix`:
1818-```
1818+```nix
1919services.foundationdb.enable = true;
2020services.foundationdb.package = pkgs.foundationdb71; # FoundationDB 7.1.x
2121```
···109109FoundationDB stores all data for all server processes under
110110{file}`/var/lib/foundationdb`. You can override this using
111111{option}`services.foundationdb.dataDir`, e.g.
112112-```
112112+```nix
113113services.foundationdb.dataDir = "/data/fdb";
114114```
115115···265265For example, to create backups in {command}`/opt/fdb-backups`, first
266266set up the paths in the module options:
267267268268-```
268268+```nix
269269services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ];
270270```
271271
+6-6
nixos/modules/services/databases/postgresql.md
···1515## Configuring {#module-services-postgres-configuring}
16161717To enable PostgreSQL, add the following to your {file}`configuration.nix`:
1818-```
1818+```nix
1919services.postgresql.enable = true;
2020services.postgresql.package = pkgs.postgresql_15;
2121```
···3535-->
36363737By default, PostgreSQL stores its databases in {file}`/var/lib/postgresql/$psqlSchema`. You can override this using [](#opt-services.postgresql.dataDir), e.g.
3838-```
3838+```nix
3939services.postgresql.dataDir = "/data/postgresql";
4040```
4141···174174"13"
175175```
176176For an upgrade, a script like this can be used to simplify the process:
177177-```
177177+```nix
178178{ config, pkgs, ... }:
179179{
180180 environment.systemPackages = [
···256256```
257257258258To add plugins via NixOS configuration, set `services.postgresql.extraPlugins`:
259259-```
259259+```nix
260260services.postgresql.package = pkgs.postgresql_12;
261261services.postgresql.extraPlugins = ps: with ps; [
262262 pg_repack
···265265```
266266267267You can build custom PostgreSQL-with-plugins (to be used outside of NixOS) using function `.withPackages`. For example, creating a custom PostgreSQL package in an overlay can look like:
268268-```
268268+```nix
269269self: super: {
270270 postgresql_custom = self.postgresql_12.withPackages (ps: [
271271 ps.pg_repack
···275275```
276276277277Here's a recipe on how to override a particular plugin through an overlay:
278278-```
278278+```nix
279279self: super: {
280280 postgresql_15 = super.postgresql_15// {
281281 pkgs = super.postgresql_15.pkgs // {
+2-2
nixos/modules/services/databases/tigerbeetle.md
···77TigerBeetle is a distributed financial accounting database designed for mission critical safety and performance.
8899To enable TigerBeetle, add the following to your {file}`configuration.nix`:
1010-```
1010+```nix
1111 services.tigerbeetle.enable = true;
1212```
1313···2020To configure it to listen on a different interface (and to configure it to connect to other replicas, if you're creating more than one), you'll have to set the `addresses` option.
2121Note that the TigerBeetle module won't open any firewall ports automatically, so if you configure it to listen on an external interface, you'll need to ensure that connections can reach it:
22222323-```
2323+```nix
2424 services.tigerbeetle = {
2525 enable = true;
2626 addresses = [ "0.0.0.0:3001" ];
+2-2
nixos/modules/services/desktops/flatpak.md
···88applications on Linux.
991010To enable Flatpak, add the following to your {file}`configuration.nix`:
1111-```
1111+```nix
1212 services.flatpak.enable = true;
1313```
1414···1616be installed. If you run GNOME, this will be handled automatically for you;
1717in other cases, you will need to add something like the following to your
1818{file}`configuration.nix`:
1919-```
1919+```nix
2020 xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
2121 xdg.portal.config.common.default = "gtk";
2222```
+3-3
nixos/modules/services/development/athens.md
···1818## Basic usage for a caching proxy configuration {#opt-services-development-athens-caching-proxy}
19192020A very basic configuration for Athens that acts as a caching and forwarding HTTP proxy is:
2121-```
2121+```nix
2222{
2323 services.athens = {
2424 enable = true;
···28282929If you want to prevent Athens from writing to disk, you can instead configure it to cache modules only in memory:
30303131-```
3131+```nix
3232{
3333 services.athens = {
3434 enable = true;
···39394040To use the local proxy in Go builds, you can set the proxy as environment variable:
41414242-```
4242+```nix
4343{
4444 environment.variables = {
4545 GOPROXY = "http://localhost:3000"
+1-1
nixos/modules/services/development/blackfire.md
···77[Blackfire](https://blackfire.io) is a proprietary tool for profiling applications. There are several languages supported by the product but currently only PHP support is packaged in Nixpkgs. The back-end consists of a module that is loaded into the language runtime (called *probe*) and a service (*agent*) that the probe connects to and that sends the profiles to the server.
8899To 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:
1010-```
1010+```nix
1111let
1212 php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [
1313 blackfire
+2-2
nixos/modules/services/development/livebook.md
···99[`systemd`](https://www.freedesktop.org/wiki/Software/systemd/) unit
1010which runs the server.
11111212-```
1212+```nix
1313{ ... }:
14141515{
···5151learning Kinos require `gcc` and `gnumake`. To add these, use
5252`extraPackages`:
53535454-```
5454+```nix
5555services.livebook.extraPackages = with pkgs; [ gcc gnumake ];
5656```
+5-5
nixos/modules/services/editors/emacs.md
···178178::: {.example #module-services-emacs-configuration-nix}
179179### Custom Emacs in `configuration.nix`
180180181181-```
181181+```nix
182182{
183183 environment.systemPackages = [
184184 # [...]
···203203::: {.example #module-services-emacs-config-nix}
204204### Custom Emacs in `~/.config/nixpkgs/config.nix`
205205206206-```
206206+```nix
207207{
208208 packageOverrides = super: let self = super.pkgs; in {
209209 myemacs = import ./emacs.nix { pkgs = self; };
···228228::: {.example #ex-emacsGtk3Nix}
229229### Custom Emacs build
230230231231-```
231231+```nix
232232{ pkgs ? import <nixpkgs> {} }:
233233let
234234 myEmacs = (pkgs.emacs.override {
···262262263263To install and enable the {command}`systemd` user service for Emacs
264264daemon, add the following to your {file}`configuration.nix`:
265265-```
265265+```nix
266266services.emacs.enable = true;
267267```
268268···323323by symlinks in {file}`/etc/systemd/user`. In the case where
324324Emacs daemon is not wanted for all users, it is possible to install the
325325service but not globally enable it:
326326-```
326326+```nix
327327services.emacs.enable = false;
328328services.emacs.install = true;
329329```
+2-2
nixos/modules/services/mail/mailman.md
···99## Basic usage with Postfix {#module-services-mailman-basic-usage}
10101111For a basic configuration with Postfix as the MTA, the following settings are suggested:
1212-```
1212+```nix
1313{ config, ... }: {
1414 services.postfix = {
1515 enable = true;
···5050## Using with other MTAs {#module-services-mailman-other-mtas}
51515252Mailman also supports other MTA, though with a little bit more configuration. For example, to use Mailman with Exim, you can use the following settings:
5353-```
5353+```nix
5454{ config, ... }: {
5555 services = {
5656 mailman = {
+2-2
nixos/modules/services/matrix/mjolnir.md
···4646set in [services.mjolnir.homeserverUrl](#opt-services.mjolnir.homeserverUrl) and Mjolnir itself
4747will be configured to connect to the new Pantalaimon instance.
48484949-```
4949+```nix
5050{
5151 services.mjolnir = {
5252 enable = true;
···7878To use the Antispam Module, add `matrix-synapse-plugins.matrix-synapse-mjolnir-antispam`
7979to the Synapse plugin list and enable the `mjolnir.Module` module.
80808181-```
8181+```nix
8282{
8383 services.matrix-synapse = {
8484 plugins = with pkgs; [
+3-3
nixos/modules/services/matrix/synapse.md
···2323the host `myhostname.example.org`. For more information,
2424please refer to the
2525[installation instructions of Synapse](https://element-hq.github.io/synapse/latest/setup/installation.html) .
2626-```
2626+```nix
2727{ pkgs, lib, config, ... }:
2828let
2929 fqdn = "${config.networking.hostName}.${config.networking.domain}";
···158158 by `matrix-synapse`.
159159 - Include the file like this in your configuration:
160160161161- ```
161161+ ```nix
162162 {
163163 services.matrix-synapse.extraConfigFiles = [
164164 "/run/secrets/matrix-shared-secret"
···190190Matrix Identifier. See
191191[Try Matrix Now!](https://matrix.org/docs/projects/try-matrix-now.html)
192192for a list of existing clients and their supported featureset.
193193-```
193193+```nix
194194{
195195 services.nginx.virtualHosts."element.${fqdn}" = {
196196 enableACME = true;
+3-3
nixos/modules/services/misc/anki-sync-server.md
···1616`DynamicUser` option.
17171818This can be done by enabling the `anki-sync-server` service:
1919-```
1919+```nix
2020{ ... }:
21212222{
···2727It is necessary to set at least one username-password pair under
2828{option}`services.anki-sync-server.users`. For example
29293030-```
3030+```nix
3131{
3232 services.anki-sync-server.users = [
3333 {
···5050in most circumstances, because the sync server doesn't use HTTPS), then set the
5151following options:
52525353-```
5353+```nix
5454{
5555 services.anki-sync-server.host = "0.0.0.0";
5656 services.anki-sync-server.openFirewall = true;
+2-2
nixos/modules/services/misc/gitlab.md
···10101111For instance, the following configuration could be used to use nginx as
1212frontend proxy:
1313-```
1313+```nix
1414services.nginx = {
1515 enable = true;
1616 recommendedGzipSettings = true;
···3535all data like the repositories and uploads will be stored.
36363737A basic configuration with some custom settings could look like this:
3838-```
3838+```nix
3939services.gitlab = {
4040 enable = true;
4141 databasePasswordFile = "/var/keys/gitlab/db_password";
+1-1
nixos/modules/services/misc/sourcehut/default.md
···1212and `services.postgresql` services.
13131414A very basic configuration may look like this:
1515-```
1515+```nix
1616{ pkgs, ... }:
1717let
1818 fqdn =
+2-2
nixos/modules/services/misc/weechat.md
···1212session.
13131414This can be done by enabling the `weechat` service:
1515-```
1515+```nix
1616{ ... }:
17171818{
···3030`screenrc` needs to be tweaked by adding
3131[multiuser](https://www.gnu.org/software/screen/manual/html_node/Multiuser.html#Multiuser)
3232support:
3333-```
3333+```nix
3434{
3535 programs.screen.screenrc = ''
3636 multiuser on
···99[node exporter](https://github.com/prometheus/node_exporter),
1010it provides hardware and OS metrics from the host it's
1111running on. The exporter could be configured as follows:
1212-```
1212+```nix
1313 services.prometheus.exporters.node = {
1414 enable = true;
1515 port = 9100;
···3535the [available options](https://nixos.org/nixos/options.html#prometheus.exporters).
36363737Prometheus can now be configured to consume the metrics produced by the exporter:
3838-```
3838+```nix
3939 services.prometheus = {
4040 # ...
4141···7575 `nixos/modules/services/monitoring/prometheus/exporters/`
7676 directory, which will be called postfix.nix and contains all exporter
7777 specific options and configuration:
7878- ```
7878+ ```nix
7979 # nixpkgs/nixos/modules/services/prometheus/exporters/postfix.nix
8080 { config, lib, pkgs, options }:
8181···148148Should an exporter option change at some point, it is possible to add
149149information about the change to the exporter definition similar to
150150`nixpkgs/nixos/modules/rename.nix`:
151151-```
151151+```nix
152152{ config, lib, pkgs, options }:
153153154154with lib;
···88Litestream service is managed by a dedicated user named `litestream`
99which needs permission to the database file. Here's an example config which gives
1010required permissions to access [grafana database](#opt-services.grafana.settings.database.path):
1111-```
1111+```nix
1212{ pkgs, ... }:
1313{
1414 users.users.litestream.extraGroups = [ "grafana" ];
+3-3
nixos/modules/services/networking/pleroma.md
···1717## Initializing the database {#module-services-pleroma-initialize-db}
18181919First, the Postgresql service must be enabled in the NixOS configuration
2020-```
2020+```nix
2121services.postgresql = {
2222 enable = true;
2323 package = pkgs.postgresql_13;
···3838In this section we will enable the Pleroma service only locally, so its configurations can be improved incrementally.
39394040This is an example of configuration, where [](#opt-services.pleroma.configs) option contains the content of the file `config.exs`, generated [in the first section](#module-services-pleroma-generate-config), but with the secrets (database password, endpoint secret key, salts, etc.) removed. Removing secrets is important, because otherwise they will be stored publicly in the Nix store.
4141-```
4141+```nix
4242services.pleroma = {
4343 enable = true;
4444 secretConfigFile = "/var/lib/pleroma/secrets.exs";
···121121122122In this configuration, Pleroma is listening only on the local port 4000. Nginx can be configured as a Reverse Proxy, for forwarding requests from public ports to the Pleroma service. This is an example of configuration, using
123123[Let's Encrypt](https://letsencrypt.org/) for the TLS certificates
124124-```
124124+```nix
125125security.acme = {
126126 email = "root@example.net";
127127 acceptTerms = true;
+2-2
nixos/modules/services/networking/prosody.md
···2525[Multi User Chat (MUC)](https://xmpp.org/extensions/xep-0045.html)
2626endpoint as well as a [HTTP File Upload](https://xmpp.org/extensions/xep-0363.html)
2727endpoint will look like this:
2828-```
2828+```nix
2929services.prosody = {
3030 enable = true;
3131 admins = [ "root@example.org" ];
···57575858Provided the setup detailed in the previous section, you'll need the following acme configuration to generate
5959a TLS certificate for the three endponits:
6060-```
6060+```nix
6161security.acme = {
6262 email = "root@example.org";
6363 acceptTerms = true;
+3-3
nixos/modules/services/networking/yggdrasil.md
···1212### Simple ephemeral node {#module-services-networking-yggdrasil-configuration-simple}
13131414An annotated example of a simple configuration:
1515-```
1515+```nix
1616{
1717 services.yggdrasil = {
1818 enable = true;
···3939### Persistent node with prefix {#module-services-networking-yggdrasil-configuration-prefix}
40404141A node with a fixed address that announces a prefix:
4242-```
4242+```nix
4343let
4444 address = "210:5217:69c0:9afc:1b95:b9f:8718:c3d2";
4545 prefix = "310:5217:69c0:9afc";
···90909191A NixOS container attached to the Yggdrasil network via a node running on the
9292host:
9393-```
9393+```nix
9494let
9595 yggPrefix64 = "310:5217:69c0:9afc";
9696 # Again, taken from the output of "yggdrasilctl getself".
+2-2
nixos/modules/services/web-apps/c2fmzq-server.md
···44including but not limited to pictures and videos.
5566The service `c2fmzq-server` can be enabled by setting
77-```
77+```nix
88{
99 services.c2fmzq-server.enable = true;
1010}
···1717are command line options to manage HTTPS certificates directly, but the module
1818is designed to be served behind a reverse proxy or only accessed via localhost.
19192020-```
2020+```nix
2121{
2222 services.c2fmzq-server = {
2323 enable = true;
+5-5
nixos/modules/services/web-apps/discourse.md
···66## Basic usage {#module-services-discourse-basic-usage}
7788A minimal configuration using Let's Encrypt for TLS certificates looks like this:
99-```
99+```nix
1010services.discourse = {
1111 enable = true;
1212 hostname = "discourse.example.com";
···3434and [](#opt-services.discourse.sslCertificateKey)
3535options:
36363737-```
3737+```nix
3838services.discourse = {
3939 enable = true;
4040 hostname = "discourse.example.com";
···8080[hostname](#opt-services.discourse.hostname) as
8181email domain can be done like this:
82828383-```
8383+```nix
8484services.discourse = {
8585 enable = true;
8686 hostname = "discourse.example.com";
···162162Discourse instance and enables
163163GitHub login in the site settings,
164164and changes a few request limits in the backend settings:
165165-```
165165+```nix
166166services.discourse = {
167167 enable = true;
168168 hostname = "discourse.example.com";
···253253plugins, and disable `discourse-spoiler-alert`
254254by default:
255255256256-```
256256+```nix
257257services.discourse = {
258258 enable = true;
259259 hostname = "discourse.example.com";
+3-3
nixos/modules/services/web-apps/grocy.md
···66## Basic usage {#module-services-grocy-basic-usage}
7788A very basic configuration may look like this:
99-```
99+```nix
1010{ pkgs, ... }:
1111{
1212 services.grocy = {
···29293030The configuration for `grocy` is located at `/etc/grocy/config.php`.
3131By default, the following settings can be defined in the NixOS-configuration:
3232-```
3232+```nix
3333{ pkgs, ... }:
3434{
3535 services.grocy.settings = {
···56565757If you want to alter the configuration file on your own, you can do this manually with
5858an expression like this:
5959-```
5959+```nix
6060{ lib, ... }:
6161{
6262 environment.etc."grocy/config.php".text = lib.mkAfter ''
+2-2
nixos/modules/services/web-apps/jitsi-meet.md
···66## Basic usage {#module-services-jitsi-basic-usage}
7788A minimal configuration using Let's Encrypt for TLS certificates looks like this:
99-```
99+```nix
1010{
1111 services.jitsi-meet = {
1212 enable = true;
···2222## Configuration {#module-services-jitsi-configuration}
23232424Here is the minimal configuration with additional configurations:
2525-```
2525+```nix
2626{
2727 services.jitsi-meet = {
2828 enable = true;
+1-1
nixos/modules/services/web-apps/keycloak.md
···126126## Example configuration {#module-services-keycloak-example-config}
127127128128A basic configuration with some custom settings could look like this:
129129-```
129129+```nix
130130services.keycloak = {
131131 enable = true;
132132 settings = {
+3-3
nixos/modules/services/web-apps/nextcloud.md
···2525socket.
26262727A very basic configuration may look like this:
2828-```
2828+```nix
2929{ pkgs, ... }:
3030{
3131 services.nextcloud = {
···130130[corresponding `phpfpm` pool](#opt-services.phpfpm.pools).
131131132132An exemplary configuration may look like this:
133133-```
133133+```nix
134134{ config, lib, pkgs, ... }: {
135135 services.nginx.enable = false;
136136 services.nextcloud = {
···205205in NixOS for a safe upgrade-path before removing those. In that case we should keep those
206206packages, but mark them as insecure in an expression like this (in
207207`<nixpkgs/pkgs/servers/nextcloud/default.nix>`):
208208-```
208208+```nix
209209/* ... */
210210{
211211 nextcloud17 = generic {
+1-1
nixos/modules/services/web-apps/plausible.md
···1111```
12121313After that, `plausible` can be deployed like this:
1414-```
1414+```nix
1515{
1616 services.plausible = {
1717 enable = true;
+1-1
nixos/modules/services/web-servers/garage.md
···8080in NixOS for a safe upgrade-path before removing those. In that case we should keep those
8181packages, but mark them as insecure in an expression like this (in
8282`<nixpkgs/pkgs/tools/filesystem/garage/default.nix>`):
8383-```
8383+```nix
8484/* ... */
8585{
8686 garage_0_7_3 = generic {
···8899To enable the GNOME desktop use:
10101111-```
1111+```nix
1212services.xserver.desktopManager.gnome.enable = true;
1313services.xserver.displayManager.gdm.enable = true;
1414```
···23232424If you’d like to only use the GNOME desktop and not the apps, you can disable them with:
25252626-```
2626+```nix
2727services.gnome.core-utilities.enable = false;
2828```
2929···37373838It is also possible to disable many of the [core services](https://github.com/NixOS/nixpkgs/blob/b8ec4fd2a4edc4e30d02ba7b1a2cc1358f3db1d5/nixos/modules/services/x11/desktop-managers/gnome.nix#L329-L348). For example, if you do not need indexing files, you can disable Tracker with:
39394040-```
4040+```nix
4141services.gnome.tracker-miners.enable = false;
4242services.gnome.tracker.enable = false;
4343```
···48484949You can install all of the GNOME games with:
50505151-```
5151+```nix
5252services.gnome.games.enable = true;
5353```
5454···56565757You can install GNOME core developer tools with:
58585959-```
5959+```nix
6060services.gnome.core-developer-tools.enable = true;
6161```
6262···64646565GNOME 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:
66666767-```
6767+```nix
6868services.xserver.desktopManager.gnome.flashback.enableMetacity = true;
6969```
7070···72727373The following example uses `xmonad` window manager:
74747575-```
7575+```nix
7676services.xserver.desktopManager.gnome.flashback.customSessions = [
7777 {
7878 wmName = "xmonad";
···104104105105You can install them like any other package:
106106107107-```
107107+```nix
108108environment.systemPackages = [
109109 gnomeExtensions.dash-to-dock
110110 gnomeExtensions.gsconnect
···136136137137### Example {#sec-gnome-gsettings-overrides-example}
138138139139-```
139139+```nix
140140services.xserver.desktopManager.gnome = {
141141 extraGSettingsOverrides = ''
142142 # Change default background
···55## Enabling Pantheon {#sec-pantheon-enable}
6677All 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
88-```
88+```nix
99services.xserver.desktopManager.pantheon.enable = true;
1010```
1111This automatically enables LightDM and Pantheon's LightDM greeter. If you'd like to disable this, set
1212-```
1212+```nix
1313services.xserver.displayManager.lightdm.greeters.pantheon.enable = false;
1414services.xserver.displayManager.lightdm.enable = false;
1515```
1616but 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
1717-```
1717+```nix
1818services.pantheon.apps.enable = false;
1919```
2020You can also use [](#opt-environment.pantheon.excludePackages) to remove any other app (like `elementary-mail`).
···2929to configure the programs with plugs or indicators.
30303131The 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:
3232-```
3232+```nix
3333wingpanel-with-indicators.override {
3434 indicators = [
3535 pkgs.some-special-indicator
···4343};
4444```
4545please 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:
4646-```
4646+```nix
4747wingpanel-with-indicators.override {
4848 useDefaultIndicators = false;
4949 indicators = specialListOfIndicators;
+2-2
nixos/modules/system/boot/clevis.md
···39394040In order to activate unattended decryption of a resource at boot, enable the `clevis` module:
41414242-```
4242+```nix
4343boot.initrd.clevis.enable = true;
4444```
45454646Then, 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.
4747-```
4747+```nix
4848boot.initrd.clevis.devices."/dev/nvme0n1p1".secretFile = ./nvme0n1p1.jwe;
4949```
5050
+1-1
pkgs/README.md
···564564565565 For example in this case:
566566567567- ```
567567+ ```nix
568568 jbidwatcher = throw "jbidwatcher was discontinued in march 2021"; # added 2021-03-15
569569 ```
570570
+1-1
pkgs/servers/nextcloud/packages/README.md
···2424The apps will be available in the namespace `nextcloud25Packages.apps`.
2525Using it together with the Nextcloud module could look like this:
26262727-```
2727+```nix
2828services.nextcloud = {
2929 enable = true;
3030 package = pkgs.nextcloud25;
···2929The plugins will be available in the namespace `wordpressPackages.plugins`.
3030Using it together with the Wordpress module could look like this:
31313232-```
3232+```nix
3333services.wordpress = {
3434 sites."blog.${config.networking.domain}" = {
3535 plugins = with pkgs.wordpressPackages.plugins; [