diff --git a/doc/build-aux/pandoc-filters/myst-reader/roles.lua b/doc/build-aux/pandoc-filters/myst-reader/roles.lua index c33a688eeba7..f4ef6d390b40 100644 --- a/doc/build-aux/pandoc-filters/myst-reader/roles.lua +++ b/doc/build-aux/pandoc-filters/myst-reader/roles.lua @@ -17,9 +17,16 @@ function Inlines(inlines) if correct_tags then -- docutils supports alphanumeric strings separated by [-._:] -- We are slightly more liberal for simplicity. - local role = first.text:match('^{([-._+:%w]+)}$') - if role ~= nil then - inlines:remove(i) + -- Allow preceding punctuation (eg '('), otherwise '({file}`...`)' + -- does not match. Also allow anything followed by a non-breaking space + -- since pandoc emits those after certain abbreviations (e.g. e.g.). + local prefix, role = first.text:match('^(.*){([-._+:%w]+)}$') + if role ~= nil and (prefix == '' or prefix:match("^.*[%p ]$") ~= nil) then + if prefix == '' then + inlines:remove(i) + else + first.text = prefix + end second.attributes['role'] = role second.classes:insert('interpreted-text') end diff --git a/nixos/doc/manual/development/meta-attributes.section.md b/nixos/doc/manual/development/meta-attributes.section.md index 946c08efd0a3..7129cf8723e6 100644 --- a/nixos/doc/manual/development/meta-attributes.section.md +++ b/nixos/doc/manual/development/meta-attributes.section.md @@ -40,6 +40,26 @@ file. $ nix-build nixos/release.nix -A manual.x86_64-linux ``` + This file should *not* usually be written by hand. Instead it is preferred + to write documentation using CommonMark and converting it to CommonMark + using pandoc. The simplest documentation can be converted using just + + ```ShellSession + $ pandoc doc.md -t docbook --top-level-division=chapter -f markdown+smart > doc.xml + ``` + + More elaborate documentation may wish to add one or more of the pandoc + filters used to build the remainder of the manual, for example the GNOME + desktop uses + + ```ShellSession + $ pandoc gnome.md -t docbook --top-level-division=chapter \ + --extract-media=media -f markdown+smart \ + --lua-filter ../../../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua \ + --lua-filter ../../../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua \ + > gnome.xml + ``` + - `buildDocsInSandbox` indicates whether the option documentation for the module can be built in a derivation sandbox. This option is currently only honored for modules shipped by nixpkgs. User modules and modules taken from diff --git a/nixos/doc/manual/from_md/development/meta-attributes.section.xml b/nixos/doc/manual/from_md/development/meta-attributes.section.xml index 9cc58afa1fdd..450a5f670f3a 100644 --- a/nixos/doc/manual/from_md/development/meta-attributes.section.xml +++ b/nixos/doc/manual/from_md/development/meta-attributes.section.xml @@ -50,6 +50,27 @@ $ nix-build nixos/release.nix -A manual.x86_64-linux + + + This file should not usually be written by + hand. Instead it is preferred to write documentation using + CommonMark and converting it to CommonMark using pandoc. The + simplest documentation can be converted using just + + +$ pandoc doc.md -t docbook --top-level-division=chapter -f markdown+smart > doc.xml + + + More elaborate documentation may wish to add one or more of the + pandoc filters used to build the remainder of the manual, for + example the GNOME desktop uses + + +$ pandoc gnome.md -t docbook --top-level-division=chapter \ + --extract-media=media -f markdown+smart \ + --lua-filter ../../../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua \ + --lua-filter ../../../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua \ + > gnome.xml diff --git a/nixos/doc/manual/md-to-db.sh b/nixos/doc/manual/md-to-db.sh index 4698e94f508b..a7421bed532e 100755 --- a/nixos/doc/manual/md-to-db.sh +++ b/nixos/doc/manual/md-to-db.sh @@ -50,3 +50,21 @@ for mf in ${MD_FILES[*]}; do done popd + +# now handle module chapters. we'll need extra checks to ensure that we don't process +# markdown files we're not interested in, so we'll require an x.nix file for ever x.md +# that we'll convert to xml. +pushd "$DIR/../../modules" + +mapfile -t MD_FILES < <(find . -type f -regex '.*\.md$') + +for mf in ${MD_FILES[*]}; do + [ -f "${mf%.md}.nix" ] || continue + + pandoc --top-level-division=chapter "$mf" "${pandoc_flags[@]}" -o "${mf%.md}.xml" + sed -i -e '1 i ' \ + "${mf%.md}.xml" +done + +popd diff --git a/nixos/modules/i18n/input-method/default.md b/nixos/modules/i18n/input-method/default.md new file mode 100644 index 000000000000..05ae12065c34 --- /dev/null +++ b/nixos/modules/i18n/input-method/default.md @@ -0,0 +1,158 @@ +# Input Methods {#module-services-input-methods} + +Input methods are an operating system component that allows any data, such as +keyboard strokes or mouse movements, to be received as input. In this way +users can enter characters and symbols not found on their input devices. +Using an input method is obligatory for any language that has more graphemes +than there are keys on the keyboard. + +The following input methods are available in NixOS: + + - IBus: The intelligent input bus. + - Fcitx: A customizable lightweight input method. + - Nabi: A Korean input method based on XIM. + - Uim: The universal input method, is a library with a XIM bridge. + - Hime: An extremely easy-to-use input method framework. + - Kime: Korean IME + +## IBus {#module-services-input-methods-ibus} + +IBus is an Intelligent Input Bus. It provides full featured and user +friendly input method user interface. + +The following snippet can be used to configure IBus: + +``` +i18n.inputMethod = { + enabled = "ibus"; + ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ]; +}; +``` + +`i18n.inputMethod.ibus.engines` is optional and can be used +to add extra IBus engines. + +Available extra IBus engines are: + + - Anthy (`ibus-engines.anthy`): Anthy is a system for + Japanese input method. It converts Hiragana text to Kana Kanji mixed text. + - Hangul (`ibus-engines.hangul`): Korean input method. + - m17n (`ibus-engines.m17n`): m17n is an input method that + uses input methods and corresponding icons in the m17n database. + - mozc (`ibus-engines.mozc`): A Japanese input method from + Google. + - Table (`ibus-engines.table`): An input method that load + tables of input methods. + - table-others (`ibus-engines.table-others`): Various + table-based input methods. To use this, and any other table-based input + methods, it must appear in the list of engines along with + `table`. For example: + + ``` + ibus.engines = with pkgs.ibus-engines; [ table table-others ]; + ``` + +To use any input method, the package must be added in the configuration, as +shown above, and also (after running `nixos-rebuild`) the +input method must be added from IBus' preference dialog. + +### Troubleshooting {#module-services-input-methods-troubleshooting} + +If IBus works in some applications but not others, a likely cause of this +is that IBus is depending on a different version of `glib` +to what the applications are depending on. This can be checked by running +`nix-store -q --requisites | grep glib`, +where `` is the path of either IBus or an +application in the Nix store. The `glib` packages must +match exactly. If they do not, uninstalling and reinstalling the +application is a likely fix. + +## Fcitx {#module-services-input-methods-fcitx} + +Fcitx is an input method framework with extension support. It has three +built-in Input Method Engine, Pinyin, QuWei and Table-based input methods. + +The following snippet can be used to configure Fcitx: + +``` +i18n.inputMethod = { + enabled = "fcitx"; + fcitx.engines = with pkgs.fcitx-engines; [ mozc hangul m17n ]; +}; +``` + +`i18n.inputMethod.fcitx.engines` is optional and can be +used to add extra Fcitx engines. + +Available extra Fcitx engines are: + + - Anthy (`fcitx-engines.anthy`): Anthy is a system for + Japanese input method. It converts Hiragana text to Kana Kanji mixed text. + - Chewing (`fcitx-engines.chewing`): Chewing is an + intelligent Zhuyin input method. It is one of the most popular input + methods among Traditional Chinese Unix users. + - Hangul (`fcitx-engines.hangul`): Korean input method. + - Unikey (`fcitx-engines.unikey`): Vietnamese input method. + - m17n (`fcitx-engines.m17n`): m17n is an input method that + uses input methods and corresponding icons in the m17n database. + - mozc (`fcitx-engines.mozc`): A Japanese input method from + Google. + - table-others (`fcitx-engines.table-others`): Various + table-based input methods. + +## Nabi {#module-services-input-methods-nabi} + +Nabi is an easy to use Korean X input method. It allows you to enter +phonetic Korean characters (hangul) and pictographic Korean characters +(hanja). + +The following snippet can be used to configure Nabi: + +``` +i18n.inputMethod = { + enabled = "nabi"; +}; +``` + +## Uim {#module-services-input-methods-uim} + +Uim (short for "universal input method") is a multilingual input method +framework. Applications can use it through so-called bridges. + +The following snippet can be used to configure uim: + +``` +i18n.inputMethod = { + enabled = "uim"; +}; +``` + +Note: The [](#opt-i18n.inputMethod.uim.toolbar) option can be +used to choose uim toolbar. + +## Hime {#module-services-input-methods-hime} + +Hime is an extremely easy-to-use input method framework. It is lightweight, +stable, powerful and supports many commonly used input methods, including +Cangjie, Zhuyin, Dayi, Rank, Shrimp, Greek, Korean Pinyin, Latin Alphabet, +etc... + +The following snippet can be used to configure Hime: + +``` +i18n.inputMethod = { + enabled = "hime"; +}; +``` + +## Kime {#module-services-input-methods-kime} + +Kime is Korean IME. it's built with Rust language and let you get simple, safe, fast Korean typing + +The following snippet can be used to configure Kime: + +``` +i18n.inputMethod = { + enabled = "kime"; +}; +``` diff --git a/nixos/modules/i18n/input-method/default.xml b/nixos/modules/i18n/input-method/default.xml index dd66316c7308..7b7907cd32a6 100644 --- a/nixos/modules/i18n/input-method/default.xml +++ b/nixos/modules/i18n/input-method/default.xml @@ -1,291 +1,275 @@ - - Input Methods - - Input methods are an operating system component that allows any data, such as - keyboard strokes or mouse movements, to be received as input. In this way - users can enter characters and symbols not found on their input devices. - Using an input method is obligatory for any language that has more graphemes - than there are keys on the keyboard. - - - The following input methods are available in NixOS: - - - - - IBus: The intelligent input bus. - - - - - Fcitx: A customizable lightweight input method. - - - - - Nabi: A Korean input method based on XIM. - - - - - Uim: The universal input method, is a library with a XIM bridge. - - - - - Hime: An extremely easy-to-use input method framework. - - - + + + Input Methods + + Input methods are an operating system component that allows any + data, such as keyboard strokes or mouse movements, to be received as + input. In this way users can enter characters and symbols not found + on their input devices. Using an input method is obligatory for any + language that has more graphemes than there are keys on the + keyboard. + + + The following input methods are available in NixOS: + + + + + IBus: The intelligent input bus. + + + + + Fcitx: A customizable lightweight input method. + + + + + Nabi: A Korean input method based on XIM. + + + + + Uim: The universal input method, is a library with a XIM bridge. + + + + + Hime: An extremely easy-to-use input method framework. + + + + + Kime: Korean IME + + + +
+ IBus - Kime: Korean IME + IBus is an Intelligent Input Bus. It provides full featured and + user friendly input method user interface. - - -
- IBus - - - IBus is an Intelligent Input Bus. It provides full featured and user - friendly input method user interface. - - - - The following snippet can be used to configure IBus: - - - + + The following snippet can be used to configure IBus: + + i18n.inputMethod = { - enabled = "ibus"; - ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ]; + enabled = "ibus"; + ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ]; }; - - - i18n.inputMethod.ibus.engines is optional and can be used - to add extra IBus engines. - - - - Available extra IBus engines are: - - - - - Anthy (ibus-engines.anthy): Anthy is a system for - Japanese input method. It converts Hiragana text to Kana Kanji mixed text. + i18n.inputMethod.ibus.engines is optional and + can be used to add extra IBus engines. - - - Hangul (ibus-engines.hangul): Korean input method. + Available extra IBus engines are: - - - - m17n (ibus-engines.m17n): m17n is an input method that - uses input methods and corresponding icons in the m17n database. - - - - - mozc (ibus-engines.mozc): A Japanese input method from - Google. - - - - - Table (ibus-engines.table): An input method that load - tables of input methods. - - - - - table-others (ibus-engines.table-others): Various - table-based input methods. To use this, and any other table-based input - methods, it must appear in the list of engines along with - table. For example: - + + + + Anthy (ibus-engines.anthy): Anthy is a + system for Japanese input method. It converts Hiragana text to + Kana Kanji mixed text. + + + + + Hangul (ibus-engines.hangul): Korean input + method. + + + + + m17n (ibus-engines.m17n): m17n is an input + method that uses input methods and corresponding icons in the + m17n database. + + + + + mozc (ibus-engines.mozc): A Japanese input + method from Google. + + + + + Table (ibus-engines.table): An input method + that load tables of input methods. + + + + + table-others (ibus-engines.table-others): + Various table-based input methods. To use this, and any other + table-based input methods, it must appear in the list of + engines along with table. For example: + + ibus.engines = with pkgs.ibus-engines; [ table table-others ]; + + + + To use any input method, the package must be added in the + configuration, as shown above, and also (after running + nixos-rebuild) the input method must be added + from IBus’ preference dialog. - - - - - To use any input method, the package must be added in the configuration, as - shown above, and also (after running nixos-rebuild) the - input method must be added from IBus' preference dialog. - - - - Troubleshooting - - If IBus works in some applications but not others, a likely cause of this - is that IBus is depending on a different version of glib - to what the applications are depending on. This can be checked by running - nix-store -q --requisites <path> | grep glib, - where <path> is the path of either IBus or an - application in the Nix store. The glib packages must - match exactly. If they do not, uninstalling and reinstalling the - application is a likely fix. - - -
-
- Fcitx - - - Fcitx is an input method framework with extension support. It has three - built-in Input Method Engine, Pinyin, QuWei and Table-based input methods. - - - - The following snippet can be used to configure Fcitx: - - - +
+ Troubleshooting + + If IBus works in some applications but not others, a likely + cause of this is that IBus is depending on a different version + of glib to what the applications are + depending on. This can be checked by running + nix-store -q --requisites <path> | grep glib, + where <path> is the path of either IBus + or an application in the Nix store. The glib + packages must match exactly. If they do not, uninstalling and + reinstalling the application is a likely fix. + +
+
+
+ Fcitx + + Fcitx is an input method framework with extension support. It has + three built-in Input Method Engine, Pinyin, QuWei and Table-based + input methods. + + + The following snippet can be used to configure Fcitx: + + i18n.inputMethod = { - enabled = "fcitx"; - fcitx.engines = with pkgs.fcitx-engines; [ mozc hangul m17n ]; + enabled = "fcitx"; + fcitx.engines = with pkgs.fcitx-engines; [ mozc hangul m17n ]; }; - - - i18n.inputMethod.fcitx.engines is optional and can be - used to add extra Fcitx engines. - - - - Available extra Fcitx engines are: - - - - - Anthy (fcitx-engines.anthy): Anthy is a system for - Japanese input method. It converts Hiragana text to Kana Kanji mixed text. + i18n.inputMethod.fcitx.engines is optional and + can be used to add extra Fcitx engines. - - - Chewing (fcitx-engines.chewing): Chewing is an - intelligent Zhuyin input method. It is one of the most popular input - methods among Traditional Chinese Unix users. + Available extra Fcitx engines are: - - + + + + Anthy (fcitx-engines.anthy): Anthy is a + system for Japanese input method. It converts Hiragana text to + Kana Kanji mixed text. + + + + + Chewing (fcitx-engines.chewing): Chewing is + an intelligent Zhuyin input method. It is one of the most + popular input methods among Traditional Chinese Unix users. + + + + + Hangul (fcitx-engines.hangul): Korean input + method. + + + + + Unikey (fcitx-engines.unikey): Vietnamese + input method. + + + + + m17n (fcitx-engines.m17n): m17n is an input + method that uses input methods and corresponding icons in the + m17n database. + + + + + mozc (fcitx-engines.mozc): A Japanese input + method from Google. + + + + + table-others (fcitx-engines.table-others): + Various table-based input methods. + + + +
+
+ Nabi - Hangul (fcitx-engines.hangul): Korean input method. + Nabi is an easy to use Korean X input method. It allows you to + enter phonetic Korean characters (hangul) and pictographic Korean + characters (hanja). - - - Unikey (fcitx-engines.unikey): Vietnamese input method. + The following snippet can be used to configure Nabi: - - - - m17n (fcitx-engines.m17n): m17n is an input method that - uses input methods and corresponding icons in the m17n database. - - - - - mozc (fcitx-engines.mozc): A Japanese input method from - Google. - - - - - table-others (fcitx-engines.table-others): Various - table-based input methods. - - - -
-
- Nabi - - - Nabi is an easy to use Korean X input method. It allows you to enter - phonetic Korean characters (hangul) and pictographic Korean characters - (hanja). - - - - The following snippet can be used to configure Nabi: - - - + i18n.inputMethod = { - enabled = "nabi"; + enabled = "nabi"; }; -
-
- Uim - - - Uim (short for "universal input method") is a multilingual input method - framework. Applications can use it through so-called bridges. - - - - The following snippet can be used to configure uim: - - - +
+
+ Uim + + Uim (short for universal input method) is a + multilingual input method framework. Applications can use it + through so-called bridges. + + + The following snippet can be used to configure uim: + + i18n.inputMethod = { - enabled = "uim"; + enabled = "uim"; }; - - - Note: The option can be - used to choose uim toolbar. - -
-
- Hime - - - Hime is an extremely easy-to-use input method framework. It is lightweight, - stable, powerful and supports many commonly used input methods, including - Cangjie, Zhuyin, Dayi, Rank, Shrimp, Greek, Korean Pinyin, Latin Alphabet, - etc... - - - - The following snippet can be used to configure Hime: - - - + + Note: The + option can be used to choose uim toolbar. + +
+
+ Hime + + Hime is an extremely easy-to-use input method framework. It is + lightweight, stable, powerful and supports many commonly used + input methods, including Cangjie, Zhuyin, Dayi, Rank, Shrimp, + Greek, Korean Pinyin, Latin Alphabet, etc… + + + The following snippet can be used to configure Hime: + + i18n.inputMethod = { - enabled = "hime"; + enabled = "hime"; }; -
-
- Kime - - - Kime is Korean IME. it's built with Rust language and let you get simple, safe, fast Korean typing - - - - The following snippet can be used to configure Kime: - - - +
+
+ Kime + + Kime is Korean IME. it’s built with Rust language and let you get + simple, safe, fast Korean typing + + + The following snippet can be used to configure Kime: + + i18n.inputMethod = { - enabled = "kime"; + enabled = "kime"; }; -
+
diff --git a/nixos/modules/programs/digitalbitbox/default.md b/nixos/modules/programs/digitalbitbox/default.md new file mode 100644 index 000000000000..9bca14e97ffe --- /dev/null +++ b/nixos/modules/programs/digitalbitbox/default.md @@ -0,0 +1,47 @@ +# Digital Bitbox {#module-programs-digitalbitbox} + +Digital Bitbox is a hardware wallet and second-factor authenticator. + +The `digitalbitbox` programs module may be installed by setting +`programs.digitalbitbox` to `true` in a manner similar to +``` +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 +module (see [](#sec-digitalbitbox-hardware-module)) which sets up the necessary +udev rules to access the device. + +Enabling the digitalbitbox module is pretty much the easiest way to get a +Digital Bitbox device working on your system. + +For more information, see . + +## Package {#sec-digitalbitbox-package} + +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: +``` +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: +``` +hardware.digitalbitbox.enable = true; +``` + +In order to alter the udev rules, one may provide different values for the +`udevRule51` and `udevRule52` attributes by means of overriding as follows: +``` +programs.digitalbitbox = { + enable = true; + package = pkgs.digitalbitbox.override { + udevRule51 = "something else"; + }; +}; +``` diff --git a/nixos/modules/programs/digitalbitbox/default.nix b/nixos/modules/programs/digitalbitbox/default.nix index 101ee8ddbafc..054110fe5df2 100644 --- a/nixos/modules/programs/digitalbitbox/default.nix +++ b/nixos/modules/programs/digitalbitbox/default.nix @@ -33,7 +33,7 @@ in }; meta = { - doc = ./doc.xml; + doc = ./default.xml; maintainers = with lib.maintainers; [ vidbina ]; }; } diff --git a/nixos/modules/programs/digitalbitbox/default.xml b/nixos/modules/programs/digitalbitbox/default.xml new file mode 100644 index 000000000000..ee892523223c --- /dev/null +++ b/nixos/modules/programs/digitalbitbox/default.xml @@ -0,0 +1,70 @@ + + + Digital Bitbox + + Digital Bitbox is a hardware wallet and second-factor authenticator. + + + The digitalbitbox programs module may be + installed by setting programs.digitalbitbox to + true in a manner similar to + + +programs.digitalbitbox.enable = true; + + + and bundles the digitalbitbox package (see + ), which contains the + dbb-app and dbb-cli binaries, + along with the hardware module (see + ) which sets up + the necessary udev rules to access the device. + + + Enabling the digitalbitbox module is pretty much the easiest way to + get a Digital Bitbox device working on your system. + + + For more information, see + https://digitalbitbox.com/start_linux. + +
+ Package + + 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: + + +environment.systemPackages = [ + pkgs.digitalbitbox +]; + +
+
+ Hardware + + The digitalbitbox hardware package enables the udev rules for + Digital Bitbox devices and may be installed as follows: + + +hardware.digitalbitbox.enable = true; + + + In order to alter the udev rules, one may provide different values + for the udevRule51 and + udevRule52 attributes by means of overriding as + follows: + + +programs.digitalbitbox = { + enable = true; + package = pkgs.digitalbitbox.override { + udevRule51 = "something else"; + }; +}; + +
+
diff --git a/nixos/modules/programs/digitalbitbox/doc.xml b/nixos/modules/programs/digitalbitbox/doc.xml deleted file mode 100644 index c63201628dbd..000000000000 --- a/nixos/modules/programs/digitalbitbox/doc.xml +++ /dev/null @@ -1,74 +0,0 @@ - - Digital Bitbox - - Digital Bitbox is a hardware wallet and second-factor authenticator. - - - The digitalbitbox programs module may be installed by - setting programs.digitalbitbox to true - in a manner similar to - - = true; - - and bundles the digitalbitbox package (see - ), which contains the - dbb-app and dbb-cli binaries, along - with the hardware module (see - ) which sets up the - necessary udev rules to access the device. - - - Enabling the digitalbitbox module is pretty much the easiest way to get a - Digital Bitbox device working on your system. - - - For more information, see - . - -
- Package - - - 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: - - = [ - pkgs.digitalbitbox -]; - - -
-
- Hardware - - - The digitalbitbox hardware package enables the udev rules for Digital Bitbox - devices and may be installed as follows: - - = true; - - - - - In order to alter the udev rules, one may provide different values for the - udevRule51 and udevRule52 attributes - by means of overriding as follows: - -programs.digitalbitbox = { - enable = true; - package = pkgs.digitalbitbox.override { - udevRule51 = "something else"; - }; -}; - - -
-
diff --git a/nixos/modules/programs/plotinus.md b/nixos/modules/programs/plotinus.md new file mode 100644 index 000000000000..fac3bbad1e08 --- /dev/null +++ b/nixos/modules/programs/plotinus.md @@ -0,0 +1,17 @@ +# Plotinus {#module-program-plotinus} + +*Source:* {file}`modules/programs/plotinus.nix` + +*Upstream documentation:* + +Plotinus is a searchable command palette in every modern GTK application. + +When in a GTK 3 application and Plotinus is enabled, you can press +`Ctrl+Shift+P` to open the command palette. The command +palette provides a searchable list of of all menu items in the application. + +To enable Plotinus, add the following to your +{file}`configuration.nix`: +``` +programs.plotinus.enable = true; +``` diff --git a/nixos/modules/programs/plotinus.xml b/nixos/modules/programs/plotinus.xml index 8fc8c22c6d76..2d4db0285148 100644 --- a/nixos/modules/programs/plotinus.xml +++ b/nixos/modules/programs/plotinus.xml @@ -1,30 +1,30 @@ - - Plotinus - - Source: - modules/programs/plotinus.nix - - - Upstream documentation: - - - - Plotinus is a searchable command palette in every modern GTK application. - - - When in a GTK 3 application and Plotinus is enabled, you can press - Ctrl+Shift+P to open the command palette. The command - palette provides a searchable list of of all menu items in the application. - - - To enable Plotinus, add the following to your - configuration.nix: - - = true; + + + Plotinus + + Source: + modules/programs/plotinus.nix + + + Upstream documentation: + https://github.com/p-e-w/plotinus + + + Plotinus is a searchable command palette in every modern GTK + application. + + + When in a GTK 3 application and Plotinus is enabled, you can press + Ctrl+Shift+P to open the command palette. The + command palette provides a searchable list of of all menu items in + the application. + + + To enable Plotinus, add the following to your + configuration.nix: + + +programs.plotinus.enable = true; - diff --git a/nixos/modules/programs/zsh/oh-my-zsh.md b/nixos/modules/programs/zsh/oh-my-zsh.md new file mode 100644 index 000000000000..73d425244ce7 --- /dev/null +++ b/nixos/modules/programs/zsh/oh-my-zsh.md @@ -0,0 +1,109 @@ +# Oh my ZSH {#module-programs-zsh-ohmyzsh} + +[`oh-my-zsh`](https://ohmyz.sh/) is a framework to manage your [ZSH](https://www.zsh.org/) +configuration including completion scripts for several CLI tools or custom +prompt themes. + +## Basic usage {#module-programs-oh-my-zsh-usage} + +The module uses the `oh-my-zsh` package with all available +features. The initial setup using Nix expressions is fairly similar to the +configuration format of `oh-my-zsh`. +``` +{ + programs.zsh.ohMyZsh = { + enable = true; + plugins = [ "git" "python" "man" ]; + theme = "agnoster"; + }; +} +``` +For a detailed explanation of these arguments please refer to the +[`oh-my-zsh` docs](https://github.com/robbyrussell/oh-my-zsh/wiki). + +The expression generates the needed configuration and writes it into your +`/etc/zshrc`. + +## Custom additions {#module-programs-oh-my-zsh-additions} + +Sometimes third-party or custom scripts such as a modified theme may be +needed. `oh-my-zsh` provides the +[`ZSH_CUSTOM`](https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals) +environment variable for this which points to a directory with additional +scripts. + +The module can do this as well: +``` +{ + programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts"; +} +``` + +## Custom environments {#module-programs-oh-my-zsh-environments} + +There are several extensions for `oh-my-zsh` packaged in +`nixpkgs`. One of them is +[nix-zsh-completions](https://github.com/spwhitt/nix-zsh-completions) +which bundles completion scripts and a plugin for `oh-my-zsh`. + +Rather than using a single mutable path for `ZSH_CUSTOM`, +it's also possible to generate this path from a list of Nix packages: +``` +{ pkgs, ... }: +{ + programs.zsh.ohMyZsh.customPkgs = [ + pkgs.nix-zsh-completions + # and even more... + ]; +} +``` +Internally a single store path will be created using +`buildEnv`. Please refer to the docs of +[`buildEnv`](https://nixos.org/nixpkgs/manual/#sec-building-environment) +for further reference. + +*Please keep in mind that this is not compatible with +`programs.zsh.ohMyZsh.custom` as it requires an immutable +store path while `custom` shall remain mutable! An +evaluation failure will be thrown if both `custom` and +`customPkgs` are set.* + +## Package your own customizations {#module-programs-oh-my-zsh-packaging-customizations} + +If third-party customizations (e.g. new themes) are supposed to be added to +`oh-my-zsh` there are several pitfalls to keep in mind: + + - To comply with the default structure of `ZSH` the entire + output needs to be written to `$out/share/zsh.` + + - Completion scripts are supposed to be stored at + `$out/share/zsh/site-functions`. This directory is part of the + [`fpath`](http://zsh.sourceforge.net/Doc/Release/Functions.html) + and the package should be compatible with pure `ZSH` + setups. The module will automatically link the contents of + `site-functions` to completions directory in the proper + store path. + + - The `plugins` directory needs the structure + `pluginname/pluginname.plugin.zsh` as structured in the + [upstream repo.](https://github.com/robbyrussell/oh-my-zsh/tree/91b771914bc7c43dd7c7a43b586c5de2c225ceb7/plugins) + +A derivation for `oh-my-zsh` may look like this: +``` +{ stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + name = "exemplary-zsh-customization-${version}"; + version = "1.0.0"; + src = fetchFromGitHub { + # path to the upstream repository + }; + + dontBuild = true; + installPhase = '' + mkdir -p $out/share/zsh/site-functions + cp {themes,plugins} $out/share/zsh + cp completions $out/share/zsh/site-functions + ''; +} +``` diff --git a/nixos/modules/programs/zsh/oh-my-zsh.xml b/nixos/modules/programs/zsh/oh-my-zsh.xml index 14a7228ad9b0..2a2bba96b859 100644 --- a/nixos/modules/programs/zsh/oh-my-zsh.xml +++ b/nixos/modules/programs/zsh/oh-my-zsh.xml @@ -1,76 +1,74 @@ - - Oh my ZSH - - oh-my-zsh is a - framework to manage your ZSH - configuration including completion scripts for several CLI tools or custom - prompt themes. - -
- Basic usage - + + + Oh my ZSH - The module uses the oh-my-zsh package with all available - features. The initial setup using Nix expressions is fairly similar to the - configuration format of oh-my-zsh. - + oh-my-zsh + is a framework to manage your + ZSH configuration + including completion scripts for several CLI tools or custom prompt + themes. + +
+ Basic usage + + The module uses the oh-my-zsh package with all + available features. The initial setup using Nix expressions is + fairly similar to the configuration format of + oh-my-zsh. + + { programs.zsh.ohMyZsh = { enable = true; - plugins = [ "git" "python" "man" ]; - theme = "agnoster"; + plugins = [ "git" "python" "man" ]; + theme = "agnoster"; }; } - For a detailed explanation of these arguments please refer to the - oh-my-zsh - docs. - - - - The expression generates the needed configuration and writes it into your - /etc/zshrc. - -
-
- Custom additions - - - Sometimes third-party or custom scripts such as a modified theme may be - needed. oh-my-zsh provides the - ZSH_CUSTOM - environment variable for this which points to a directory with additional - scripts. - - - - The module can do this as well: - + + For a detailed explanation of these arguments please refer to the + oh-my-zsh + docs. + + + The expression generates the needed configuration and writes it + into your /etc/zshrc. + +
+
+ Custom additions + + Sometimes third-party or custom scripts such as a modified theme + may be needed. oh-my-zsh provides the + ZSH_CUSTOM + environment variable for this which points to a directory with + additional scripts. + + + The module can do this as well: + + { - programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts"; + programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts"; } - -
-
- Custom environments - - - There are several extensions for oh-my-zsh packaged in - nixpkgs. One of them is - nix-zsh-completions - which bundles completion scripts and a plugin for - oh-my-zsh. - - - - Rather than using a single mutable path for ZSH_CUSTOM, - it's also possible to generate this path from a list of Nix packages: - +
+
+ Custom environments + + There are several extensions for oh-my-zsh + packaged in nixpkgs. One of them is + nix-zsh-completions + which bundles completion scripts and a plugin for + oh-my-zsh. + + + Rather than using a single mutable path for + ZSH_CUSTOM, it’s also possible to generate this + path from a list of Nix packages: + + { pkgs, ... }: { programs.zsh.ohMyZsh.customPkgs = [ @@ -79,65 +77,67 @@ ]; } - Internally a single store path will be created using - buildEnv. Please refer to the docs of - buildEnv - for further reference. - - - - Please keep in mind that this is not compatible with - programs.zsh.ohMyZsh.custom as it requires an immutable - store path while custom shall remain mutable! An - evaluation failure will be thrown if both custom and - customPkgs are set. - -
-
- Package your own customizations - - - If third-party customizations (e.g. new themes) are supposed to be added to - oh-my-zsh there are several pitfalls to keep in mind: - - - - - To comply with the default structure of ZSH the entire - output needs to be written to $out/share/zsh. + Internally a single store path will be created using + buildEnv. Please refer to the docs of + buildEnv + for further reference. - - - Completion scripts are supposed to be stored at - $out/share/zsh/site-functions. This directory is part - of the - fpath - and the package should be compatible with pure ZSH - setups. The module will automatically link the contents of - site-functions to completions directory in the proper - store path. + Please keep in mind that this is not compatible with + programs.zsh.ohMyZsh.custom as it requires an + immutable store path while custom shall remain + mutable! An evaluation failure will be thrown if both + custom and customPkgs are + set. - - +
+
+ Package your own customizations - The plugins directory needs the structure - pluginname/pluginname.plugin.zsh as structured in the - upstream - repo. + If third-party customizations (e.g. new themes) are supposed to be + added to oh-my-zsh there are several pitfalls + to keep in mind: - - - - - A derivation for oh-my-zsh may look like this: - + + + + To comply with the default structure of ZSH + the entire output needs to be written to + $out/share/zsh. + + + + + Completion scripts are supposed to be stored at + $out/share/zsh/site-functions. This + directory is part of the + fpath + and the package should be compatible with pure + ZSH setups. The module will automatically + link the contents of site-functions to + completions directory in the proper store path. + + + + + The plugins directory needs the structure + pluginname/pluginname.plugin.zsh as + structured in the + upstream + repo. + + + + + A derivation for oh-my-zsh may look like this: + + { stdenv, fetchFromGitHub }: stdenv.mkDerivation rec { - name = "exemplary-zsh-customization-${version}"; - version = "1.0.0"; + name = "exemplary-zsh-customization-${version}"; + version = "1.0.0"; src = fetchFromGitHub { # path to the upstream repository }; @@ -150,6 +150,5 @@ stdenv.mkDerivation rec { ''; } - -
+
diff --git a/nixos/modules/security/acme/default.md b/nixos/modules/security/acme/default.md new file mode 100644 index 000000000000..8ff97b55f685 --- /dev/null +++ b/nixos/modules/security/acme/default.md @@ -0,0 +1,354 @@ +# SSL/TLS Certificates with ACME {#module-security-acme} + +NixOS supports automatic domain validation & certificate retrieval and +renewal using the ACME protocol. Any provider can be used, but by default +NixOS uses Let's Encrypt. The alternative ACME client +[lego](https://go-acme.github.io/lego/) is used under +the hood. + +Automatic cert validation and configuration for Apache and Nginx virtual +hosts is included in NixOS, however if you would like to generate a wildcard +cert or you are not using a web server you will have to configure DNS +based validation. + +## Prerequisites {#module-security-acme-prerequisites} + +To use the ACME module, you must accept the provider's terms of service +by setting [](#opt-security.acme.acceptTerms) +to `true`. The Let's Encrypt ToS can be found +[here](https://letsencrypt.org/repository/). + +You must also set an email address to be used when creating accounts with +Let's Encrypt. You can set this for all certs with +[](#opt-security.acme.defaults.email) +and/or on a per-cert basis with +[](#opt-security.acme.certs._name_.email). +This address is only used for registration and renewal reminders, +and cannot be used to administer the certificates in any way. + +Alternatively, you can use a different ACME server by changing the +[](#opt-security.acme.defaults.server) option +to a provider of your choosing, or just change the server for one cert with +[](#opt-security.acme.certs._name_.server). + +You will need an HTTP server or DNS server for verification. For HTTP, +the server must have a webroot defined that can serve +{file}`.well-known/acme-challenge`. This directory must be +writeable by the user that will run the ACME client. For DNS, you must +set up credentials with your provider/server for use with lego. + +## Using ACME certificates in Nginx {#module-security-acme-nginx} + +NixOS supports fetching ACME certificates for you by setting +`enableACME = true;` in a virtualHost config. We first create self-signed +placeholder certificates in place of the real ACME certs. The placeholder +certs are overwritten when the ACME certs arrive. For +`foo.example.com` the config would look like this: + +``` +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; +services.nginx = { + enable = true; + virtualHosts = { + "foo.example.com" = { + forceSSL = true; + enableACME = true; + # All serverAliases will be added as extra domain names on the certificate. + serverAliases = [ "bar.example.com" ]; + locations."/" = { + root = "/var/www"; + }; + }; + + # We can also add a different vhost and reuse the same certificate + # but we have to append extraDomainNames manually beforehand: + # security.acme.certs."foo.example.com".extraDomainNames = [ "baz.example.com" ]; + "baz.example.com" = { + forceSSL = true; + useACMEHost = "foo.example.com"; + locations."/" = { + root = "/var/www"; + }; + }; + }; +} +``` + +## Using ACME certificates in Apache/httpd {#module-security-acme-httpd} + +Using ACME certificates with Apache virtual hosts is identical +to using them with Nginx. The attribute names are all the same, just replace +"nginx" with "httpd" where appropriate. + +## Manual configuration of HTTP-01 validation {#module-security-acme-configuring} + +First off you will need to set up a virtual host to serve the challenges. +This example uses a vhost called `certs.example.com`, with +the intent that you will generate certs for all your vhosts and redirect +everyone to HTTPS. + +``` +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; + +# /var/lib/acme/.challenges must be writable by the ACME user +# and readable by the Nginx user. The easiest way to achieve +# this is to add the Nginx user to the ACME group. +users.users.nginx.extraGroups = [ "acme" ]; + +services.nginx = { + enable = true; + virtualHosts = { + "acmechallenge.example.com" = { + # Catchall vhost, will redirect users to HTTPS for all vhosts + serverAliases = [ "*.example.com" ]; + locations."/.well-known/acme-challenge" = { + root = "/var/lib/acme/.challenges"; + }; + locations."/" = { + return = "301 https://$host$request_uri"; + }; + }; + }; +} +# Alternative config for Apache +users.users.wwwrun.extraGroups = [ "acme" ]; +services.httpd = { + enable = true; + virtualHosts = { + "acmechallenge.example.com" = { + # Catchall vhost, will redirect users to HTTPS for all vhosts + serverAliases = [ "*.example.com" ]; + # /var/lib/acme/.challenges must be writable by the ACME user and readable by the Apache user. + # By default, this is the case. + documentRoot = "/var/lib/acme/.challenges"; + extraConfig = '' + RewriteEngine On + RewriteCond %{HTTPS} off + RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge [NC] + RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301] + ''; + }; + }; +} +``` + +Now you need to configure ACME to generate a certificate. + +``` +security.acme.certs."foo.example.com" = { + webroot = "/var/lib/acme/.challenges"; + email = "foo@example.com"; + # Ensure that the web server you use can read the generated certs + # Take a look at the group option for the web server you choose. + group = "nginx"; + # Since we have a wildcard vhost to handle port 80, + # we can generate certs for anything! + # Just make sure your DNS resolves them. + extraDomainNames = [ "mail.example.com" ]; +}; +``` + +The private key {file}`key.pem` and certificate +{file}`fullchain.pem` will be put into +{file}`/var/lib/acme/foo.example.com`. + +Refer to [](#ch-options) for all available configuration +options for the [security.acme](#opt-security.acme.certs) +module. + +## Configuring ACME for DNS validation {#module-security-acme-config-dns} + +This is useful if you want to generate a wildcard certificate, since +ACME servers will only hand out wildcard certs over DNS validation. +There are a number of supported DNS providers and servers you can utilise, +see the [lego docs](https://go-acme.github.io/lego/dns/) +for provider/server specific configuration values. For the sake of these +docs, we will provide a fully self-hosted example using bind. + +``` +services.bind = { + enable = true; + extraConfig = '' + include "/var/lib/secrets/dnskeys.conf"; + ''; + zones = [ + rec { + name = "example.com"; + file = "/var/db/bind/${name}"; + master = true; + extraConfig = "allow-update { key rfc2136key.example.com.; };"; + } + ]; +} + +# Now we can configure ACME +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; +security.acme.certs."example.com" = { + domain = "*.example.com"; + dnsProvider = "rfc2136"; + credentialsFile = "/var/lib/secrets/certs.secret"; + # We don't need to wait for propagation since this is a local DNS server + dnsPropagationCheck = false; +}; +``` + +The {file}`dnskeys.conf` and {file}`certs.secret` +must be kept secure and thus you should not keep their contents in your +Nix config. Instead, generate them one time with a systemd service: + +``` +systemd.services.dns-rfc2136-conf = { + 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; + }; + path = [ pkgs.bind ]; + script = '' + mkdir -p /var/lib/secrets + chmod 755 /var/lib/secrets + tsig-keygen rfc2136key.example.com > /var/lib/secrets/dnskeys.conf + chown named:root /var/lib/secrets/dnskeys.conf + chmod 400 /var/lib/secrets/dnskeys.conf + + # extract secret value from the dnskeys.conf + while read x y; do if [ "$x" = "secret" ]; then secret="''${y:1:''${#y}-3}"; fi; done < /var/lib/secrets/dnskeys.conf + + cat > /var/lib/secrets/certs.secret << EOF + RFC2136_NAMESERVER='127.0.0.1:53' + RFC2136_TSIG_ALGORITHM='hmac-sha256.' + RFC2136_TSIG_KEY='rfc2136key.example.com' + RFC2136_TSIG_SECRET='$secret' + EOF + chmod 400 /var/lib/secrets/certs.secret + ''; +}; +``` + +Now you're all set to generate certs! You should monitor the first invocation +by running `systemctl start acme-example.com.service & +journalctl -fu acme-example.com.service` and watching its log output. + +## Using DNS validation with web server virtual hosts {#module-security-acme-config-dns-with-vhosts} + +It is possible to use DNS-01 validation with all certificates, +including those automatically configured via the Nginx/Apache +[`enableACME`](#opt-services.nginx.virtualHosts._name_.enableACME) +option. This configuration pattern is fully +supported and part of the module's test suite for Nginx + Apache. + +You must follow the guide above on configuring DNS-01 validation +first, however instead of setting the options for one certificate +(e.g. [](#opt-security.acme.certs._name_.dnsProvider)) +you will set them as defaults +(e.g. [](#opt-security.acme.defaults.dnsProvider)). + +``` +# Configure ACME appropriately +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; +security.acme.defaults = { + dnsProvider = "rfc2136"; + credentialsFile = "/var/lib/secrets/certs.secret"; + # We don't need to wait for propagation since this is a local DNS server + dnsPropagationCheck = false; +}; + +# For each virtual host you would like to use DNS-01 validation with, +# set acmeRoot = null +services.nginx = { + enable = true; + virtualHosts = { + "foo.example.com" = { + enableACME = true; + acmeRoot = null; + }; + }; +} +``` + +And that's it! Next time your configuration is rebuilt, or when +you add a new virtualHost, it will be DNS-01 validated. + +## Using ACME with services demanding root owned certificates {#module-security-acme-root-owned} + +Some services refuse to start if the configured certificate files +are not owned by root. PostgreSQL and OpenSMTPD are examples of these. +There is no way to change the user the ACME module uses (it will always be +`acme`), however you can use systemd's +`LoadCredential` feature to resolve this elegantly. +Below is an example configuration for OpenSMTPD, but this pattern +can be applied to any service. + +``` +# Configure ACME however you like (DNS or HTTP validation), adding +# the following configuration for the relevant certificate. +# Note: You cannot use `systemctl reload` here as that would mean +# the LoadCredential configuration below would be skipped and +# the service would continue to use old certificates. +security.acme.certs."mail.example.com".postRun = '' + systemctl restart opensmtpd +''; + +# 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" +]; + +# 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 + ''; +}; +``` + +## Regenerating certificates {#module-security-acme-regenerate} + +Should you need to regenerate a particular certificate in a hurry, such +as when a vulnerability is found in Let's Encrypt, there is now a convenient +mechanism for doing so. Running +`systemctl clean --what=state acme-example.com.service` +will remove all certificate files and the account data for the given domain, +allowing you to then `systemctl start acme-example.com.service` +to generate fresh ones. + +## Fixing JWS Verification error {#module-security-acme-fix-jws} + +It is possible that your account credentials file may become corrupt and need +to be regenerated. In this scenario lego will produce the error `JWS verification error`. +The solution is to simply delete the associated accounts file and +re-run the affected service(s). + +``` +# Find the accounts folder for the certificate +systemctl cat acme-example.com.service | grep -Po 'accounts/[^:]*' +export accountdir="$(!!)" +# Move this folder to some place else +mv /var/lib/acme/.lego/$accountdir{,.bak} +# Recreate the folder using systemd-tmpfiles +systemd-tmpfiles --create +# Get a new account and reissue certificates +# Note: Do this for all certs that share the same account email address +systemctl start acme-example.com.service +``` diff --git a/nixos/modules/security/acme/default.nix b/nixos/modules/security/acme/default.nix index a380bb5484af..06db420632e5 100644 --- a/nixos/modules/security/acme/default.nix +++ b/nixos/modules/security/acme/default.nix @@ -916,6 +916,6 @@ in { meta = { maintainers = lib.teams.acme.members; - doc = ./doc.xml; + doc = ./default.xml; }; } diff --git a/nixos/modules/security/acme/default.xml b/nixos/modules/security/acme/default.xml new file mode 100644 index 000000000000..e80ce3b6a494 --- /dev/null +++ b/nixos/modules/security/acme/default.xml @@ -0,0 +1,395 @@ + + + SSL/TLS Certificates with ACME + + NixOS supports automatic domain validation & certificate + retrieval and renewal using the ACME protocol. Any provider can be + used, but by default NixOS uses Let’s Encrypt. The alternative ACME + client + lego is + used under the hood. + + + Automatic cert validation and configuration for Apache and Nginx + virtual hosts is included in NixOS, however if you would like to + generate a wildcard cert or you are not using a web server you will + have to configure DNS based validation. + +
+ Prerequisites + + To use the ACME module, you must accept the provider’s terms of + service by setting + to + true. The Let’s Encrypt ToS can be found + here. + + + You must also set an email address to be used when creating + accounts with Let’s Encrypt. You can set this for all certs with + and/or on a + per-cert basis with + . This + address is only used for registration and renewal reminders, and + cannot be used to administer the certificates in any way. + + + Alternatively, you can use a different ACME server by changing the + option to a + provider of your choosing, or just change the server for one cert + with . + + + You will need an HTTP server or DNS server for verification. For + HTTP, the server must have a webroot defined that can serve + .well-known/acme-challenge. This directory + must be writeable by the user that will run the ACME client. For + DNS, you must set up credentials with your provider/server for use + with lego. + +
+
+ Using ACME certificates in Nginx + + NixOS supports fetching ACME certificates for you by setting + enableACME = true; in a virtualHost config. We + first create self-signed placeholder certificates in place of the + real ACME certs. The placeholder certs are overwritten when the + ACME certs arrive. For foo.example.com the + config would look like this: + + +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; +services.nginx = { + enable = true; + virtualHosts = { + "foo.example.com" = { + forceSSL = true; + enableACME = true; + # All serverAliases will be added as extra domain names on the certificate. + serverAliases = [ "bar.example.com" ]; + locations."/" = { + root = "/var/www"; + }; + }; + + # We can also add a different vhost and reuse the same certificate + # but we have to append extraDomainNames manually beforehand: + # security.acme.certs."foo.example.com".extraDomainNames = [ "baz.example.com" ]; + "baz.example.com" = { + forceSSL = true; + useACMEHost = "foo.example.com"; + locations."/" = { + root = "/var/www"; + }; + }; + }; +} + +
+
+ Using ACME certificates in Apache/httpd + + Using ACME certificates with Apache virtual hosts is identical to + using them with Nginx. The attribute names are all the same, just + replace nginx with httpd where + appropriate. + +
+
+ Manual configuration of HTTP-01 validation + + First off you will need to set up a virtual host to serve the + challenges. This example uses a vhost called + certs.example.com, with the intent that you + will generate certs for all your vhosts and redirect everyone to + HTTPS. + + +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; + +# /var/lib/acme/.challenges must be writable by the ACME user +# and readable by the Nginx user. The easiest way to achieve +# this is to add the Nginx user to the ACME group. +users.users.nginx.extraGroups = [ "acme" ]; + +services.nginx = { + enable = true; + virtualHosts = { + "acmechallenge.example.com" = { + # Catchall vhost, will redirect users to HTTPS for all vhosts + serverAliases = [ "*.example.com" ]; + locations."/.well-known/acme-challenge" = { + root = "/var/lib/acme/.challenges"; + }; + locations."/" = { + return = "301 https://$host$request_uri"; + }; + }; + }; +} +# Alternative config for Apache +users.users.wwwrun.extraGroups = [ "acme" ]; +services.httpd = { + enable = true; + virtualHosts = { + "acmechallenge.example.com" = { + # Catchall vhost, will redirect users to HTTPS for all vhosts + serverAliases = [ "*.example.com" ]; + # /var/lib/acme/.challenges must be writable by the ACME user and readable by the Apache user. + # By default, this is the case. + documentRoot = "/var/lib/acme/.challenges"; + extraConfig = '' + RewriteEngine On + RewriteCond %{HTTPS} off + RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge [NC] + RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301] + ''; + }; + }; +} + + + Now you need to configure ACME to generate a certificate. + + +security.acme.certs."foo.example.com" = { + webroot = "/var/lib/acme/.challenges"; + email = "foo@example.com"; + # Ensure that the web server you use can read the generated certs + # Take a look at the group option for the web server you choose. + group = "nginx"; + # Since we have a wildcard vhost to handle port 80, + # we can generate certs for anything! + # Just make sure your DNS resolves them. + extraDomainNames = [ "mail.example.com" ]; +}; + + + The private key key.pem and certificate + fullchain.pem will be put into + /var/lib/acme/foo.example.com. + + + Refer to for all available + configuration options for the + security.acme + module. + +
+
+ Configuring ACME for DNS validation + + This is useful if you want to generate a wildcard certificate, + since ACME servers will only hand out wildcard certs over DNS + validation. There are a number of supported DNS providers and + servers you can utilise, see the + lego + docs for provider/server specific configuration values. For + the sake of these docs, we will provide a fully self-hosted + example using bind. + + +services.bind = { + enable = true; + extraConfig = '' + include "/var/lib/secrets/dnskeys.conf"; + ''; + zones = [ + rec { + name = "example.com"; + file = "/var/db/bind/${name}"; + master = true; + extraConfig = "allow-update { key rfc2136key.example.com.; };"; + } + ]; +} + +# Now we can configure ACME +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; +security.acme.certs."example.com" = { + domain = "*.example.com"; + dnsProvider = "rfc2136"; + credentialsFile = "/var/lib/secrets/certs.secret"; + # We don't need to wait for propagation since this is a local DNS server + dnsPropagationCheck = false; +}; + + + The dnskeys.conf and + certs.secret must be kept secure and thus you + should not keep their contents in your Nix config. Instead, + generate them one time with a systemd service: + + +systemd.services.dns-rfc2136-conf = { + 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; + }; + path = [ pkgs.bind ]; + script = '' + mkdir -p /var/lib/secrets + chmod 755 /var/lib/secrets + tsig-keygen rfc2136key.example.com > /var/lib/secrets/dnskeys.conf + chown named:root /var/lib/secrets/dnskeys.conf + chmod 400 /var/lib/secrets/dnskeys.conf + + # extract secret value from the dnskeys.conf + while read x y; do if [ "$x" = "secret" ]; then secret="''${y:1:''${#y}-3}"; fi; done < /var/lib/secrets/dnskeys.conf + + cat > /var/lib/secrets/certs.secret << EOF + RFC2136_NAMESERVER='127.0.0.1:53' + RFC2136_TSIG_ALGORITHM='hmac-sha256.' + RFC2136_TSIG_KEY='rfc2136key.example.com' + RFC2136_TSIG_SECRET='$secret' + EOF + chmod 400 /var/lib/secrets/certs.secret + ''; +}; + + + Now you’re all set to generate certs! You should monitor the first + invocation by running + systemctl start acme-example.com.service & journalctl -fu acme-example.com.service + and watching its log output. + +
+
+ Using DNS validation with web server virtual hosts + + It is possible to use DNS-01 validation with all certificates, + including those automatically configured via the Nginx/Apache + enableACME + option. This configuration pattern is fully supported and part of + the module’s test suite for Nginx + Apache. + + + You must follow the guide above on configuring DNS-01 validation + first, however instead of setting the options for one certificate + (e.g. + ) you + will set them as defaults (e.g. + ). + + +# Configure ACME appropriately +security.acme.acceptTerms = true; +security.acme.defaults.email = "admin+acme@example.com"; +security.acme.defaults = { + dnsProvider = "rfc2136"; + credentialsFile = "/var/lib/secrets/certs.secret"; + # We don't need to wait for propagation since this is a local DNS server + dnsPropagationCheck = false; +}; + +# For each virtual host you would like to use DNS-01 validation with, +# set acmeRoot = null +services.nginx = { + enable = true; + virtualHosts = { + "foo.example.com" = { + enableACME = true; + acmeRoot = null; + }; + }; +} + + + And that’s it! Next time your configuration is rebuilt, or when + you add a new virtualHost, it will be DNS-01 validated. + +
+
+ Using ACME with services demanding root owned + certificates + + Some services refuse to start if the configured certificate files + are not owned by root. PostgreSQL and OpenSMTPD are examples of + these. There is no way to change the user the ACME module uses (it + will always be acme), however you can use + systemd’s LoadCredential feature to resolve + this elegantly. Below is an example configuration for OpenSMTPD, + but this pattern can be applied to any service. + + +# Configure ACME however you like (DNS or HTTP validation), adding +# the following configuration for the relevant certificate. +# Note: You cannot use `systemctl reload` here as that would mean +# the LoadCredential configuration below would be skipped and +# the service would continue to use old certificates. +security.acme.certs."mail.example.com".postRun = '' + systemctl restart opensmtpd +''; + +# 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" +]; + +# 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 + ''; +}; + +
+
+ Regenerating certificates + + Should you need to regenerate a particular certificate in a hurry, + such as when a vulnerability is found in Let’s Encrypt, there is + now a convenient mechanism for doing so. Running + systemctl clean --what=state acme-example.com.service + will remove all certificate files and the account data for the + given domain, allowing you to then + systemctl start acme-example.com.service to + generate fresh ones. + +
+
+ Fixing JWS Verification error + + It is possible that your account credentials file may become + corrupt and need to be regenerated. In this scenario lego will + produce the error JWS verification error. The + solution is to simply delete the associated accounts file and + re-run the affected service(s). + + +# Find the accounts folder for the certificate +systemctl cat acme-example.com.service | grep -Po 'accounts/[^:]*' +export accountdir="$(!!)" +# Move this folder to some place else +mv /var/lib/acme/.lego/$accountdir{,.bak} +# Recreate the folder using systemd-tmpfiles +systemd-tmpfiles --create +# Get a new account and reissue certificates +# Note: Do this for all certs that share the same account email address +systemctl start acme-example.com.service + +
+
diff --git a/nixos/modules/security/acme/doc.xml b/nixos/modules/security/acme/doc.xml deleted file mode 100644 index 1439594a5aca..000000000000 --- a/nixos/modules/security/acme/doc.xml +++ /dev/null @@ -1,414 +0,0 @@ - - SSL/TLS Certificates with ACME - - NixOS supports automatic domain validation & certificate retrieval and - renewal using the ACME protocol. Any provider can be used, but by default - NixOS uses Let's Encrypt. The alternative ACME client - lego is used under - the hood. - - - Automatic cert validation and configuration for Apache and Nginx virtual - hosts is included in NixOS, however if you would like to generate a wildcard - cert or you are not using a web server you will have to configure DNS - based validation. - -
- Prerequisites - - - To use the ACME module, you must accept the provider's terms of service - by setting - to true. The Let's Encrypt ToS can be found - here. - - - - You must also set an email address to be used when creating accounts with - Let's Encrypt. You can set this for all certs with - - and/or on a per-cert basis with - . - This address is only used for registration and renewal reminders, - and cannot be used to administer the certificates in any way. - - - - Alternatively, you can use a different ACME server by changing the - option - to a provider of your choosing, or just change the server for one cert with - . - - - - You will need an HTTP server or DNS server for verification. For HTTP, - the server must have a webroot defined that can serve - .well-known/acme-challenge. This directory must be - writeable by the user that will run the ACME client. For DNS, you must - set up credentials with your provider/server for use with lego. - -
-
- Using ACME certificates in Nginx - - - NixOS supports fetching ACME certificates for you by setting - enableACME - = true; in a virtualHost config. We first create self-signed - placeholder certificates in place of the real ACME certs. The placeholder - certs are overwritten when the ACME certs arrive. For - foo.example.com the config would look like this: - - - - = true; - = "admin+acme@example.com"; -services.nginx = { - enable = true; - virtualHosts = { - "foo.example.com" = { - forceSSL = true; - enableACME = true; - # All serverAliases will be added as extra domain names on the certificate. - serverAliases = [ "bar.example.com" ]; - locations."/" = { - root = "/var/www"; - }; - }; - - # We can also add a different vhost and reuse the same certificate - # but we have to append extraDomainNames manually beforehand: - # security.acme.certs."foo.example.com".extraDomainNames = [ "baz.example.com" ]; - "baz.example.com" = { - forceSSL = true; - useACMEHost = "foo.example.com"; - locations."/" = { - root = "/var/www"; - }; - }; - }; -} - -
-
- Using ACME certificates in Apache/httpd - - - Using ACME certificates with Apache virtual hosts is identical - to using them with Nginx. The attribute names are all the same, just replace - "nginx" with "httpd" where appropriate. - -
-
- Manual configuration of HTTP-01 validation - - - First off you will need to set up a virtual host to serve the challenges. - This example uses a vhost called certs.example.com, with - the intent that you will generate certs for all your vhosts and redirect - everyone to HTTPS. - - - - = true; - = "admin+acme@example.com"; - -# /var/lib/acme/.challenges must be writable by the ACME user -# and readable by the Nginx user. The easiest way to achieve -# this is to add the Nginx user to the ACME group. -users.users.nginx.extraGroups = [ "acme" ]; - -services.nginx = { - enable = true; - virtualHosts = { - "acmechallenge.example.com" = { - # Catchall vhost, will redirect users to HTTPS for all vhosts - serverAliases = [ "*.example.com" ]; - locations."/.well-known/acme-challenge" = { - root = "/var/lib/acme/.challenges"; - }; - locations."/" = { - return = "301 https://$host$request_uri"; - }; - }; - }; -} -# Alternative config for Apache -users.users.wwwrun.extraGroups = [ "acme" ]; -services.httpd = { - enable = true; - virtualHosts = { - "acmechallenge.example.com" = { - # Catchall vhost, will redirect users to HTTPS for all vhosts - serverAliases = [ "*.example.com" ]; - # /var/lib/acme/.challenges must be writable by the ACME user and readable by the Apache user. - # By default, this is the case. - documentRoot = "/var/lib/acme/.challenges"; - extraConfig = '' - RewriteEngine On - RewriteCond %{HTTPS} off - RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge [NC] - RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301] - ''; - }; - }; -} - - - - Now you need to configure ACME to generate a certificate. - - - -."foo.example.com" = { - webroot = "/var/lib/acme/.challenges"; - email = "foo@example.com"; - # Ensure that the web server you use can read the generated certs - # Take a look at the group option for the web server you choose. - group = "nginx"; - # Since we have a wildcard vhost to handle port 80, - # we can generate certs for anything! - # Just make sure your DNS resolves them. - extraDomainNames = [ "mail.example.com" ]; -}; - - - - The private key key.pem and certificate - fullchain.pem will be put into - /var/lib/acme/foo.example.com. - - - - Refer to for all available configuration - options for the security.acme - module. - -
-
- Configuring ACME for DNS validation - - - This is useful if you want to generate a wildcard certificate, since - ACME servers will only hand out wildcard certs over DNS validation. - There are a number of supported DNS providers and servers you can utilise, - see the lego docs - for provider/server specific configuration values. For the sake of these - docs, we will provide a fully self-hosted example using bind. - - - -services.bind = { - enable = true; - extraConfig = '' - include "/var/lib/secrets/dnskeys.conf"; - ''; - zones = [ - rec { - name = "example.com"; - file = "/var/db/bind/${name}"; - master = true; - extraConfig = "allow-update { key rfc2136key.example.com.; };"; - } - ]; -} - -# Now we can configure ACME - = true; - = "admin+acme@example.com"; -."example.com" = { - domain = "*.example.com"; - dnsProvider = "rfc2136"; - credentialsFile = "/var/lib/secrets/certs.secret"; - # We don't need to wait for propagation since this is a local DNS server - dnsPropagationCheck = false; -}; - - - - The dnskeys.conf and certs.secret - must be kept secure and thus you should not keep their contents in your - Nix config. Instead, generate them one time with a systemd service: - - - -systemd.services.dns-rfc2136-conf = { - 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; - }; - path = [ pkgs.bind ]; - script = '' - mkdir -p /var/lib/secrets - chmod 755 /var/lib/secrets - tsig-keygen rfc2136key.example.com > /var/lib/secrets/dnskeys.conf - chown named:root /var/lib/secrets/dnskeys.conf - chmod 400 /var/lib/secrets/dnskeys.conf - - # extract secret value from the dnskeys.conf - while read x y; do if [ "$x" = "secret" ]; then secret="''${y:1:''${#y}-3}"; fi; done < /var/lib/secrets/dnskeys.conf - - cat > /var/lib/secrets/certs.secret << EOF - RFC2136_NAMESERVER='127.0.0.1:53' - RFC2136_TSIG_ALGORITHM='hmac-sha256.' - RFC2136_TSIG_KEY='rfc2136key.example.com' - RFC2136_TSIG_SECRET='$secret' - EOF - chmod 400 /var/lib/secrets/certs.secret - ''; -}; - - - - Now you're all set to generate certs! You should monitor the first invocation - by running systemctl start acme-example.com.service & - journalctl -fu acme-example.com.service and watching its log output. - -
- -
- Using DNS validation with web server virtual hosts - - - It is possible to use DNS-01 validation with all certificates, - including those automatically configured via the Nginx/Apache - enableACME - option. This configuration pattern is fully - supported and part of the module's test suite for Nginx + Apache. - - - - You must follow the guide above on configuring DNS-01 validation - first, however instead of setting the options for one certificate - (e.g. ) - you will set them as defaults - (e.g. ). - - - -# Configure ACME appropriately - = true; - = "admin+acme@example.com"; - = { - dnsProvider = "rfc2136"; - credentialsFile = "/var/lib/secrets/certs.secret"; - # We don't need to wait for propagation since this is a local DNS server - dnsPropagationCheck = false; -}; - -# For each virtual host you would like to use DNS-01 validation with, -# set acmeRoot = null -services.nginx = { - enable = true; - virtualHosts = { - "foo.example.com" = { - enableACME = true; - acmeRoot = null; - }; - }; -} - - - - And that's it! Next time your configuration is rebuilt, or when - you add a new virtualHost, it will be DNS-01 validated. - -
- -
- Using ACME with services demanding root owned certificates - - - Some services refuse to start if the configured certificate files - are not owned by root. PostgreSQL and OpenSMTPD are examples of these. - There is no way to change the user the ACME module uses (it will always be - acme), however you can use systemd's - LoadCredential feature to resolve this elegantly. - Below is an example configuration for OpenSMTPD, but this pattern - can be applied to any service. - - - -# Configure ACME however you like (DNS or HTTP validation), adding -# the following configuration for the relevant certificate. -# Note: You cannot use `systemctl reload` here as that would mean -# the LoadCredential configuration below would be skipped and -# the service would continue to use old certificates. -security.acme.certs."mail.example.com".postRun = '' - systemctl restart opensmtpd -''; - -# 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" -]; - -# 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 - ''; -}; - -
- -
- Regenerating certificates - - - Should you need to regenerate a particular certificate in a hurry, such - as when a vulnerability is found in Let's Encrypt, there is now a convenient - mechanism for doing so. Running - systemctl clean --what=state acme-example.com.service - will remove all certificate files and the account data for the given domain, - allowing you to then systemctl start acme-example.com.service - to generate fresh ones. - -
-
- Fixing JWS Verification error - - - It is possible that your account credentials file may become corrupt and need - to be regenerated. In this scenario lego will produce the error JWS verification error. - The solution is to simply delete the associated accounts file and - re-run the affected service(s). - - - -# Find the accounts folder for the certificate -systemctl cat acme-example.com.service | grep -Po 'accounts/[^:]*' -export accountdir="$(!!)" -# Move this folder to some place else -mv /var/lib/acme/.lego/$accountdir{,.bak} -# Recreate the folder using systemd-tmpfiles -systemd-tmpfiles --create -# Get a new account and reissue certificates -# Note: Do this for all certs that share the same account email address -systemctl start acme-example.com.service - - -
-
diff --git a/nixos/modules/services/backup/borgbackup.md b/nixos/modules/services/backup/borgbackup.md new file mode 100644 index 000000000000..e86ae593bbd6 --- /dev/null +++ b/nixos/modules/services/backup/borgbackup.md @@ -0,0 +1,163 @@ +# BorgBackup {#module-borgbase} + +*Source:* {file}`modules/services/backup/borgbackup.nix` + +*Upstream documentation:* + +[BorgBackup](https://www.borgbackup.org/) (short: Borg) +is a deduplicating backup program. Optionally, it supports compression and +authenticated encryption. + +The main goal of Borg is to provide an efficient and secure way to backup +data. The data deduplication technique used makes Borg suitable for daily +backups since only changes are stored. The authenticated encryption technique +makes it suitable for backups to not fully trusted targets. + +## Configuring {#module-services-backup-borgbackup-configuring} + +A complete list of options for the Borgbase module may be found +[here](#opt-services.borgbackup.jobs). + +## Basic usage for a local backup {#opt-services-backup-borgbackup-local-directory} + +A very basic configuration for backing up to a locally accessible directory is: +``` +{ + opt.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"; + }; + } + }; +} +``` + +::: {.warning} +If you do not want the passphrase to be stored in the world-readable +Nix store, use passCommand. You find an example below. +::: + +## Create a borg backup server {#opt-services-backup-create-server} + +You should use a different SSH key for each repository you write to, +because the specified keys are restricted to running borg serve and can only +access this single repository. You need the output of the generate pub file. + +```ShellSession +# sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo +# cat /run/keys/id_ed25519_my_borg_repo +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos +``` + +Add the following snippet to your NixOS configuration: +``` +{ + services.borgbackup.repos = { + my_borg_repo = { + authorizedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos" + ] ; + path = "/var/lib/my_borg_repo" ; + }; + }; +} +``` + +## Backup to the borg repository server {#opt-services-backup-borgbackup-remote-server} + +The following NixOS snippet creates an hourly backup to the service +(on the host nixos) as created in the section above. We assume +that you have stored a secret passphrasse in the file +{file}`/run/keys/borgbackup_passphrase`, which should be only +accessible by root + +``` +{ + services.borgbackup.jobs = { + backupToLocalServer = { + paths = [ "/etc/nixos" ]; + doInit = true; + 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"; }; + compression = "auto,lzma"; + startAt = "hourly"; + }; + }; +}; +``` + +The following few commands (run as root) let you test your backup. +``` +> nixos-rebuild switch +...restarting the following units: polkit.service +> systemctl restart borgbackup-job-backupToLocalServer +> sleep 10 +> systemctl restart borgbackup-job-backupToLocalServer +> export BORG_PASSPHRASE=topSecrect +> borg list --rsh='ssh -i /run/keys/id_ed25519_my_borg_repo' borg@nixos:. +nixos-backupToLocalServer-2020-03-30T21:46:17 Mon, 2020-03-30 21:46:19 [84feb97710954931ca384182f5f3cb90665f35cef214760abd7350fb064786ac] +nixos-backupToLocalServer-2020-03-30T21:46:30 Mon, 2020-03-30 21:46:32 [e77321694ecd160ca2228611747c6ad1be177d6e0d894538898de7a2621b6e68] +``` + +## Backup to a hosting service {#opt-services-backup-borgbackup-borgbase} + +Several companies offer [(paid) hosting services](https://www.borgbackup.org/support/commercial.html) +for Borg repositories. + +To backup your home directory to borgbase you have to: + + - Generate a SSH key without a password, to access the remote server. E.g. + + sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_borgbase + + - Create the repository on the server by following the instructions for your + hosting server. + - Initialize the repository on the server. Eg. + + sudo borg init --encryption=repokey-blake2 \ + -rsh "ssh -i /run/keys/id_ed25519_borgbase" \ + zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo + + - Add it to your NixOS configuration, e.g. + + { + services.borgbackup.jobs = { + my_Remote_Backup = { + paths = [ "/" ]; + exclude = [ "/nix" "'**/.cache'" ]; + repo = "zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo"; + encryption = { + mode = "repokey-blake2"; + passCommand = "cat /run/keys/borgbackup_passphrase"; + }; + environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; + compression = "auto,lzma"; + startAt = "daily"; + }; + }; + }} + +## Vorta backup client for the desktop {#opt-services-backup-borgbackup-vorta} + +Vorta is a backup client for macOS and Linux desktops. It integrates the +mighty BorgBackup with your desktop environment to protect your data from +disk failure, ransomware and theft. + +It can be installed in NixOS e.g. by adding `pkgs.vorta` +to [](#opt-environment.systemPackages). + +Details about using Vorta can be found under +[https://vorta.borgbase.com](https://vorta.borgbase.com/usage) . diff --git a/nixos/modules/services/backup/borgbackup.xml b/nixos/modules/services/backup/borgbackup.xml index f38064f86775..2b9e0baa6d09 100644 --- a/nixos/modules/services/backup/borgbackup.xml +++ b/nixos/modules/services/backup/borgbackup.xml @@ -1,209 +1,215 @@ - - BorgBackup + + + BorgBackup - Source: - modules/services/backup/borgbackup.nix - - - Upstream documentation: - - - - BorgBackup (short: Borg) - is a deduplicating backup program. Optionally, it supports compression and - authenticated encryption. + Source: + modules/services/backup/borgbackup.nix - The main goal of Borg is to provide an efficient and secure way to backup - data. The data deduplication technique used makes Borg suitable for daily - backups since only changes are stored. The authenticated encryption technique - makes it suitable for backups to not fully trusted targets. - + Upstream documentation: + https://borgbackup.readthedocs.io/ + + + BorgBackup + (short: Borg) is a deduplicating backup program. Optionally, it + supports compression and authenticated encryption. + + + The main goal of Borg is to provide an efficient and secure way to + backup data. The data deduplication technique used makes Borg + suitable for daily backups since only changes are stored. The + authenticated encryption technique makes it suitable for backups to + not fully trusted targets. +
- Configuring - - A complete list of options for the Borgbase module may be found - here. - -
-
- Basic usage for a local backup - - - A very basic configuration for backing up to a locally accessible directory - is: - + Configuring + + A complete list of options for the Borgbase module may be found + here. + +
+
+ Basic usage for a local backup + + A very basic configuration for backing up to a locally accessible + directory is: + + { opt.services.borgbackup.jobs = { { rootBackup = { - paths = "/"; - exclude = [ "/nix" "/path/to/local/repo" ]; - repo = "/path/to/local/repo"; + paths = "/"; + exclude = [ "/nix" "/path/to/local/repo" ]; + repo = "/path/to/local/repo"; doInit = true; encryption = { - mode = "repokey"; - passphrase = "secret"; + mode = "repokey"; + passphrase = "secret"; }; - compression = "auto,lzma"; - startAt = "weekly"; + compression = "auto,lzma"; + startAt = "weekly"; }; } }; -} - - +} + + + + If you do not want the passphrase to be stored in the + world-readable Nix store, use passCommand. You find an example + below. + + +
+
+ Create a borg backup server - If you do not want the passphrase to be stored in the world-readable - Nix store, use passCommand. You find an example below. - - -
-
- Create a borg backup server - You should use a different SSH key for each repository you write to, - because the specified keys are restricted to running borg serve and can only - access this single repository. You need the output of the generate pub file. - - - -# sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo -# cat /run/keys/id_ed25519_my_borg_repo -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos + You should use a different SSH key for each repository you write + to, because the specified keys are restricted to running borg + serve and can only access this single repository. You need the + output of the generate pub file. + +# sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo +# cat /run/keys/id_ed25519_my_borg_repo +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos + Add the following snippet to your NixOS configuration: - + + { services.borgbackup.repos = { my_borg_repo = { authorizedKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos" ] ; - path = "/var/lib/my_borg_repo" ; + path = "/var/lib/my_borg_repo" ; }; }; -} +} + +
+
+ Backup to the borg repository server + + The following NixOS snippet creates an hourly backup to the + service (on the host nixos) as created in the section above. We + assume that you have stored a secret passphrasse in the file + /run/keys/borgbackup_passphrase, which should + be only accessible by root -
- -
- Backup to the borg repository server - The following NixOS snippet creates an hourly backup to the service - (on the host nixos) as created in the section above. We assume - that you have stored a secret passphrasse in the file - /run/keys/borgbackup_passphrase, which should be only - accessible by root - - - + { services.borgbackup.jobs = { backupToLocalServer = { - paths = [ "/etc/nixos" ]; + paths = [ "/etc/nixos" ]; doInit = true; - repo = "borg@nixos:." ; + repo = "borg@nixos:." ; encryption = { - mode = "repokey-blake2"; - passCommand = "cat /run/keys/borgbackup_passphrase"; + mode = "repokey-blake2"; + passCommand = "cat /run/keys/borgbackup_passphrase"; }; - environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_my_borg_repo"; }; - compression = "auto,lzma"; - startAt = "hourly"; + environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_my_borg_repo"; }; + compression = "auto,lzma"; + startAt = "hourly"; }; }; -}; - - The following few commands (run as root) let you test your backup. - -> nixos-rebuild switch +}; + + + The following few commands (run as root) let you test your backup. + + +> nixos-rebuild switch ...restarting the following units: polkit.service -> systemctl restart borgbackup-job-backupToLocalServer -> sleep 10 -> systemctl restart borgbackup-job-backupToLocalServer -> export BORG_PASSPHRASE=topSecrect -> borg list --rsh='ssh -i /run/keys/id_ed25519_my_borg_repo' borg@nixos:. +> systemctl restart borgbackup-job-backupToLocalServer +> sleep 10 +> systemctl restart borgbackup-job-backupToLocalServer +> export BORG_PASSPHRASE=topSecrect +> borg list --rsh='ssh -i /run/keys/id_ed25519_my_borg_repo' borg@nixos:. nixos-backupToLocalServer-2020-03-30T21:46:17 Mon, 2020-03-30 21:46:19 [84feb97710954931ca384182f5f3cb90665f35cef214760abd7350fb064786ac] -nixos-backupToLocalServer-2020-03-30T21:46:30 Mon, 2020-03-30 21:46:32 [e77321694ecd160ca2228611747c6ad1be177d6e0d894538898de7a2621b6e68] - -
- -
- Backup to a hosting service - - - Several companies offer (paid) +nixos-backupToLocalServer-2020-03-30T21:46:30 Mon, 2020-03-30 21:46:32 [e77321694ecd160ca2228611747c6ad1be177d6e0d894538898de7a2621b6e68] + +
+
+ Backup to a hosting service + + Several companies offer + (paid) hosting services for Borg repositories. - - - To backup your home directory to borgbase you have to: - - - - - Generate a SSH key without a password, to access the remote server. E.g. - sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_borgbase + To backup your home directory to borgbase you have to: - - - - Create the repository on the server by following the instructions for your - hosting server. - - - - - Initialize the repository on the server. Eg. - + + + + Generate a SSH key without a password, to access the remote + server. E.g. + + +sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_borgbase + + + + + Create the repository on the server by following the + instructions for your hosting server. + + + + + Initialize the repository on the server. Eg. + + sudo borg init --encryption=repokey-blake2 \ - -rsh "ssh -i /run/keys/id_ed25519_borgbase" \ - zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo - - - -Add it to your NixOS configuration, e.g. - + -rsh "ssh -i /run/keys/id_ed25519_borgbase" \ + zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo + + + + + Add it to your NixOS configuration, e.g. + + { services.borgbackup.jobs = { my_Remote_Backup = { - paths = [ "/" ]; - exclude = [ "/nix" "'**/.cache'" ]; - repo = "zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo"; + paths = [ "/" ]; + exclude = [ "/nix" "'**/.cache'" ]; + repo = "zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo"; encryption = { - mode = "repokey-blake2"; - passCommand = "cat /run/keys/borgbackup_passphrase"; + mode = "repokey-blake2"; + passCommand = "cat /run/keys/borgbackup_passphrase"; }; - environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; - compression = "auto,lzma"; - startAt = "daily"; + environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; }; + compression = "auto,lzma"; + startAt = "daily"; }; }; -}} - - - -
+}} + +
+
+
- Vorta backup client for the desktop - - Vorta is a backup client for macOS and Linux desktops. It integrates the - mighty BorgBackup with your desktop environment to protect your data from - disk failure, ransomware and theft. - - - It can be installed in NixOS e.g. by adding pkgs.vorta - to . - - - Details about using Vorta can be found under https://vorta.borgbase.com - . - -
+ Vorta backup client for the desktop + + Vorta is a backup client for macOS and Linux desktops. It + integrates the mighty BorgBackup with your desktop environment to + protect your data from disk failure, ransomware and theft. + + + It can be installed in NixOS e.g. by adding + pkgs.vorta to + . + + + Details about using Vorta can be found under + https://vorta.borgbase.com + . + +
diff --git a/nixos/modules/services/databases/foundationdb.md b/nixos/modules/services/databases/foundationdb.md new file mode 100644 index 000000000000..f852c6888d84 --- /dev/null +++ b/nixos/modules/services/databases/foundationdb.md @@ -0,0 +1,309 @@ +# FoundationDB {#module-services-foundationdb} + +*Source:* {file}`modules/services/databases/foundationdb.nix` + +*Upstream documentation:* + +*Maintainer:* Austin Seipp + +*Available version(s):* 5.1.x, 5.2.x, 6.0.x + +FoundationDB (or "FDB") is an open source, distributed, transactional +key-value store. + +## Configuring and basic setup {#module-services-foundationdb-configuring} + +To enable FoundationDB, add the following to your +{file}`configuration.nix`: +``` +services.foundationdb.enable = true; +services.foundationdb.package = pkgs.foundationdb52; # FoundationDB 5.2.x +``` + +The {option}`services.foundationdb.package` option is required, and +must always be specified. Due to the fact FoundationDB network protocols and +on-disk storage formats may change between (major) versions, and upgrades +must be explicitly handled by the user, you must always manually specify +this yourself so that the NixOS module will use the proper version. Note +that minor, bugfix releases are always compatible. + +After running {command}`nixos-rebuild`, you can verify whether +FoundationDB is running by executing {command}`fdbcli` (which is +added to {option}`environment.systemPackages`): +```ShellSession +$ sudo -u foundationdb fdbcli +Using cluster file `/etc/foundationdb/fdb.cluster'. + +The database is available. + +Welcome to the fdbcli. For help, type `help'. +fdb> status + +Using cluster file `/etc/foundationdb/fdb.cluster'. + +Configuration: + Redundancy mode - single + Storage engine - memory + Coordinators - 1 + +Cluster: + FoundationDB processes - 1 + Machines - 1 + Memory availability - 5.4 GB per process on machine with least available + Fault Tolerance - 0 machines + Server time - 04/20/18 15:21:14 + +... + +fdb> +``` + +You can also write programs using the available client libraries. For +example, the following Python program can be run in order to grab the +cluster status, as a quick example. (This example uses +{command}`nix-shell` shebang support to automatically supply the +necessary Python modules). +```ShellSession +a@link> cat fdb-status.py +#! /usr/bin/env nix-shell +#! nix-shell -i python -p python pythonPackages.foundationdb52 + +import fdb +import json + +def main(): + fdb.api_version(520) + db = fdb.open() + + @fdb.transactional + def get_status(tr): + return str(tr['\xff\xff/status/json']) + + obj = json.loads(get_status(db)) + print('FoundationDB available: %s' % obj['client']['database_status']['available']) + +if __name__ == "__main__": + main() +a@link> chmod +x fdb-status.py +a@link> ./fdb-status.py +FoundationDB available: True +a@link> +``` + +FoundationDB is run under the {command}`foundationdb` user and group +by default, but this may be changed in the NixOS configuration. The systemd +unit {command}`foundationdb.service` controls the +{command}`fdbmonitor` process. + +By default, the NixOS module for FoundationDB creates a single SSD-storage +based database for development and basic usage. This storage engine is +designed for SSDs and will perform poorly on HDDs; however it can handle far +more data than the alternative "memory" engine and is a better default +choice for most deployments. (Note that you can change the storage backend +on-the-fly for a given FoundationDB cluster using +{command}`fdbcli`.) + +Furthermore, only 1 server process and 1 backup agent are started in the +default configuration. See below for more on scaling to increase this. + +FoundationDB stores all data for all server processes under +{file}`/var/lib/foundationdb`. You can override this using +{option}`services.foundationdb.dataDir`, e.g. +``` +services.foundationdb.dataDir = "/data/fdb"; +``` + +Similarly, logs are stored under {file}`/var/log/foundationdb` +by default, and there is a corresponding +{option}`services.foundationdb.logDir` as well. + +## Scaling processes and backup agents {#module-services-foundationdb-scaling} + +Scaling the number of server processes is quite easy; simply specify +{option}`services.foundationdb.serverProcesses` to be the number of +FoundationDB worker processes that should be started on the machine. + +FoundationDB worker processes typically require 4GB of RAM per-process at +minimum for good performance, so this option is set to 1 by default since +the maximum amount of RAM is unknown. You're advised to abide by this +restriction, so pick a number of processes so that each has 4GB or more. + +A similar option exists in order to scale backup agent processes, +{option}`services.foundationdb.backupProcesses`. Backup agents are +not as performance/RAM sensitive, so feel free to experiment with the number +of available backup processes. + +## Clustering {#module-services-foundationdb-clustering} + +FoundationDB on NixOS works similarly to other Linux systems, so this +section will be brief. Please refer to the full FoundationDB documentation +for more on clustering. + +FoundationDB organizes clusters using a set of +*coordinators*, which are just specially-designated +worker processes. By default, every installation of FoundationDB on NixOS +will start as its own individual cluster, with a single coordinator: the +first worker process on {command}`localhost`. + +Coordinators are specified globally using the +{command}`/etc/foundationdb/fdb.cluster` file, which all servers and +client applications will use to find and join coordinators. Note that this +file *can not* be managed by NixOS so easily: +FoundationDB is designed so that it will rewrite the file at runtime for all +clients and nodes when cluster coordinators change, with clients +transparently handling this without intervention. It is fundamentally a +mutable file, and you should not try to manage it in any way in NixOS. + +When dealing with a cluster, there are two main things you want to do: + + - Add a node to the cluster for storage/compute. + - Promote an ordinary worker to a coordinator. + +A node must already be a member of the cluster in order to properly be +promoted to a coordinator, so you must always add it first if you wish to +promote it. + +To add a machine to a FoundationDB cluster: + + - Choose one of the servers to start as the initial coordinator. + - Copy the {command}`/etc/foundationdb/fdb.cluster` file from this + server to all the other servers. Restart FoundationDB on all of these + other servers, so they join the cluster. + - All of these servers are now connected and working together in the + cluster, under the chosen coordinator. + +At this point, you can add as many nodes as you want by just repeating the +above steps. By default there will still be a single coordinator: you can +use {command}`fdbcli` to change this and add new coordinators. + +As a convenience, FoundationDB can automatically assign coordinators based +on the redundancy mode you wish to achieve for the cluster. Once all the +nodes have been joined, simply set the replication policy, and then issue +the {command}`coordinators auto` command + +For example, assuming we have 3 nodes available, we can enable double +redundancy mode, then auto-select coordinators. For double redundancy, 3 +coordinators is ideal: therefore FoundationDB will make +*every* node a coordinator automatically: + +```ShellSession +fdbcli> configure double ssd +fdbcli> coordinators auto +``` + +This will transparently update all the servers within seconds, and +appropriately rewrite the {command}`fdb.cluster` file, as well as +informing all client processes to do the same. + +## Client connectivity {#module-services-foundationdb-connectivity} + +By default, all clients must use the current {command}`fdb.cluster` +file to access a given FoundationDB cluster. This file is located by default +in {command}`/etc/foundationdb/fdb.cluster` on all machines with the +FoundationDB service enabled, so you may copy the active one from your +cluster to a new node in order to connect, if it is not part of the cluster. + +## Client authorization and TLS {#module-services-foundationdb-authorization} + +By default, any user who can connect to a FoundationDB process with the +correct cluster configuration can access anything. FoundationDB uses a +pluggable design to transport security, and out of the box it supports a +LibreSSL-based plugin for TLS support. This plugin not only does in-flight +encryption, but also performs client authorization based on the given +endpoint's certificate chain. For example, a FoundationDB server may be +configured to only accept client connections over TLS, where the client TLS +certificate is from organization *Acme Co* in the +*Research and Development* unit. + +Configuring TLS with FoundationDB is done using the +{option}`services.foundationdb.tls` options in order to control the +peer verification string, as well as the certificate and its private key. + +Note that the certificate and its private key must be accessible to the +FoundationDB user account that the server runs under. These files are also +NOT managed by NixOS, as putting them into the store may reveal private +information. + +After you have a key and certificate file in place, it is not enough to +simply set the NixOS module options -- you must also configure the +{command}`fdb.cluster` file to specify that a given set of +coordinators use TLS. This is as simple as adding the suffix +{command}`:tls` to your cluster coordinator configuration, after the +port number. For example, assuming you have a coordinator on localhost with +the default configuration, simply specifying: + +``` +XXXXXX:XXXXXX@127.0.0.1:4500:tls +``` + +will configure all clients and server processes to use TLS from now on. + +## Backups and Disaster Recovery {#module-services-foundationdb-disaster-recovery} + +The usual rules for doing FoundationDB backups apply on NixOS as written in +the FoundationDB manual. However, one important difference is the security +profile for NixOS: by default, the {command}`foundationdb` systemd +unit uses *Linux namespaces* to restrict write access to +the system, except for the log directory, data directory, and the +{command}`/etc/foundationdb/` directory. This is enforced by default +and cannot be disabled. + +However, a side effect of this is that the {command}`fdbbackup` +command doesn't work properly for local filesystem backups: FoundationDB +uses a server process alongside the database processes to perform backups +and copy the backups to the filesystem. As a result, this process is put +under the restricted namespaces above: the backup process can only write to +a limited number of paths. + +In order to allow flexible backup locations on local disks, the FoundationDB +NixOS module supports a +{option}`services.foundationdb.extraReadWritePaths` option. This +option takes a list of paths, and adds them to the systemd unit, allowing +the processes inside the service to write (and read) the specified +directories. + +For example, to create backups in {command}`/opt/fdb-backups`, first +set up the paths in the module options: + +``` +services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ]; +``` + +Restart the FoundationDB service, and it will now be able to write to this +directory (even if it does not yet exist.) Note: this path +*must* exist before restarting the unit. Otherwise, +systemd will not include it in the private FoundationDB namespace (and it +will not add it dynamically at runtime). + +You can now perform a backup: + +```ShellSession +$ sudo -u foundationdb fdbbackup start -t default -d file:///opt/fdb-backups +$ sudo -u foundationdb fdbbackup status -t default +``` + +## Known limitations {#module-services-foundationdb-limitations} + +The FoundationDB setup for NixOS should currently be considered beta. +FoundationDB is not new software, but the NixOS compilation and integration +has only undergone fairly basic testing of all the available functionality. + + - There is no way to specify individual parameters for individual + {command}`fdbserver` processes. Currently, all server processes + inherit all the global {command}`fdbmonitor` settings. + - Ruby bindings are not currently installed. + - Go bindings are not currently installed. + +## Options {#module-services-foundationdb-options} + +NixOS's FoundationDB module allows you to configure all of the most relevant +configuration options for {command}`fdbmonitor`, matching it quite +closely. A complete list of options for the FoundationDB module may be found +[here](#opt-services.foundationdb.enable). You should +also read the FoundationDB documentation as well. + +## Full documentation {#module-services-foundationdb-full-docs} + +FoundationDB is a complex piece of software, and requires careful +administration to properly use. Full documentation for administration can be +found here: . diff --git a/nixos/modules/services/databases/foundationdb.xml b/nixos/modules/services/databases/foundationdb.xml index b0b1ebeab45f..611535a9eb8a 100644 --- a/nixos/modules/services/databases/foundationdb.xml +++ b/nixos/modules/services/databases/foundationdb.xml @@ -1,60 +1,58 @@ - - FoundationDB - - Source: - modules/services/databases/foundationdb.nix - - - Upstream documentation: - - - - Maintainer: Austin Seipp - - - Available version(s): 5.1.x, 5.2.x, 6.0.x - - - FoundationDB (or "FDB") is an open source, distributed, transactional - key-value store. - -
- Configuring and basic setup - + + + FoundationDB - To enable FoundationDB, add the following to your - configuration.nix: - + Source: + modules/services/databases/foundationdb.nix + + + Upstream documentation: + https://apple.github.io/foundationdb/ + + + Maintainer: Austin Seipp + + + Available version(s): 5.1.x, 5.2.x, 6.0.x + + + FoundationDB (or FDB) is an open source, distributed, + transactional key-value store. + +
+ Configuring and basic setup + + To enable FoundationDB, add the following to your + configuration.nix: + + services.foundationdb.enable = true; services.foundationdb.package = pkgs.foundationdb52; # FoundationDB 5.2.x - - - - The option is required, and - must always be specified. Due to the fact FoundationDB network protocols and - on-disk storage formats may change between (major) versions, and upgrades - must be explicitly handled by the user, you must always manually specify - this yourself so that the NixOS module will use the proper version. Note - that minor, bugfix releases are always compatible. - - - - After running nixos-rebuild, you can verify whether - FoundationDB is running by executing fdbcli (which is - added to ): - -$ sudo -u foundationdb fdbcli + + The option is + required, and must always be specified. Due to the fact + FoundationDB network protocols and on-disk storage formats may + change between (major) versions, and upgrades must be explicitly + handled by the user, you must always manually specify this + yourself so that the NixOS module will use the proper version. + Note that minor, bugfix releases are always compatible. + + + After running nixos-rebuild, you can verify + whether FoundationDB is running by executing + fdbcli (which is added to + ): + + +$ sudo -u foundationdb fdbcli Using cluster file `/etc/foundationdb/fdb.cluster'. The database is available. Welcome to the fdbcli. For help, type `help'. -fdb> status +fdb> status Using cluster file `/etc/foundationdb/fdb.cluster'. @@ -72,18 +70,17 @@ Cluster: ... -fdb> - - - - - You can also write programs using the available client libraries. For - example, the following Python program can be run in order to grab the - cluster status, as a quick example. (This example uses - nix-shell shebang support to automatically supply the - necessary Python modules). - -a@link> cat fdb-status.py +fdb> + + + You can also write programs using the available client libraries. + For example, the following Python program can be run in order to + grab the cluster status, as a quick example. (This example uses + nix-shell shebang support to automatically + supply the necessary Python modules). + + +a@link> cat fdb-status.py #! /usr/bin/env nix-shell #! nix-shell -i python -p python pythonPackages.foundationdb52 @@ -101,343 +98,328 @@ def main(): obj = json.loads(get_status(db)) print('FoundationDB available: %s' % obj['client']['database_status']['available']) -if __name__ == "__main__": +if __name__ == "__main__": main() -a@link> chmod +x fdb-status.py -a@link> ./fdb-status.py +a@link> chmod +x fdb-status.py +a@link> ./fdb-status.py FoundationDB available: True -a@link> - - - - - FoundationDB is run under the foundationdb user and group - by default, but this may be changed in the NixOS configuration. The systemd - unit foundationdb.service controls the - fdbmonitor process. - - - - By default, the NixOS module for FoundationDB creates a single SSD-storage - based database for development and basic usage. This storage engine is - designed for SSDs and will perform poorly on HDDs; however it can handle far - more data than the alternative "memory" engine and is a better default - choice for most deployments. (Note that you can change the storage backend - on-the-fly for a given FoundationDB cluster using - fdbcli.) - - - - Furthermore, only 1 server process and 1 backup agent are started in the - default configuration. See below for more on scaling to increase this. - - - - FoundationDB stores all data for all server processes under - /var/lib/foundationdb. You can override this using - , e.g. - -services.foundationdb.dataDir = "/data/fdb"; +a@link> - - - - Similarly, logs are stored under /var/log/foundationdb - by default, and there is a corresponding - as well. - -
-
- Scaling processes and backup agents - - - Scaling the number of server processes is quite easy; simply specify - to be the number of - FoundationDB worker processes that should be started on the machine. - - - - FoundationDB worker processes typically require 4GB of RAM per-process at - minimum for good performance, so this option is set to 1 by default since - the maximum amount of RAM is unknown. You're advised to abide by this - restriction, so pick a number of processes so that each has 4GB or more. - - - - A similar option exists in order to scale backup agent processes, - . Backup agents are - not as performance/RAM sensitive, so feel free to experiment with the number - of available backup processes. - -
-
- Clustering - - - FoundationDB on NixOS works similarly to other Linux systems, so this - section will be brief. Please refer to the full FoundationDB documentation - for more on clustering. - - - - FoundationDB organizes clusters using a set of - coordinators, which are just specially-designated - worker processes. By default, every installation of FoundationDB on NixOS - will start as its own individual cluster, with a single coordinator: the - first worker process on localhost. - - - - Coordinators are specified globally using the - /etc/foundationdb/fdb.cluster file, which all servers and - client applications will use to find and join coordinators. Note that this - file can not be managed by NixOS so easily: - FoundationDB is designed so that it will rewrite the file at runtime for all - clients and nodes when cluster coordinators change, with clients - transparently handling this without intervention. It is fundamentally a - mutable file, and you should not try to manage it in any way in NixOS. - - - - When dealing with a cluster, there are two main things you want to do: - - - - - Add a node to the cluster for storage/compute. + FoundationDB is run under the foundationdb user + and group by default, but this may be changed in the NixOS + configuration. The systemd unit + foundationdb.service controls the + fdbmonitor process. - - - Promote an ordinary worker to a coordinator. + By default, the NixOS module for FoundationDB creates a single + SSD-storage based database for development and basic usage. This + storage engine is designed for SSDs and will perform poorly on + HDDs; however it can handle far more data than the alternative + memory engine and is a better default choice for + most deployments. (Note that you can change the storage backend + on-the-fly for a given FoundationDB cluster using + fdbcli.) - - - - - A node must already be a member of the cluster in order to properly be - promoted to a coordinator, so you must always add it first if you wish to - promote it. - - - - To add a machine to a FoundationDB cluster: - - - - - Choose one of the servers to start as the initial coordinator. + Furthermore, only 1 server process and 1 backup agent are started + in the default configuration. See below for more on scaling to + increase this. - - - Copy the /etc/foundationdb/fdb.cluster file from this - server to all the other servers. Restart FoundationDB on all of these - other servers, so they join the cluster. + FoundationDB stores all data for all server processes under + /var/lib/foundationdb. You can override this + using , e.g. - - + +services.foundationdb.dataDir = "/data/fdb"; + - All of these servers are now connected and working together in the - cluster, under the chosen coordinator. + Similarly, logs are stored under + /var/log/foundationdb by default, and there + is a corresponding + as well. - - - - - At this point, you can add as many nodes as you want by just repeating the - above steps. By default there will still be a single coordinator: you can - use fdbcli to change this and add new coordinators. - - - - As a convenience, FoundationDB can automatically assign coordinators based - on the redundancy mode you wish to achieve for the cluster. Once all the - nodes have been joined, simply set the replication policy, and then issue - the coordinators auto command - - - - For example, assuming we have 3 nodes available, we can enable double - redundancy mode, then auto-select coordinators. For double redundancy, 3 - coordinators is ideal: therefore FoundationDB will make - every node a coordinator automatically: - - - -fdbcli> configure double ssd -fdbcli> coordinators auto - - - - This will transparently update all the servers within seconds, and - appropriately rewrite the fdb.cluster file, as well as - informing all client processes to do the same. - -
-
- Client connectivity - - - By default, all clients must use the current fdb.cluster - file to access a given FoundationDB cluster. This file is located by default - in /etc/foundationdb/fdb.cluster on all machines with the - FoundationDB service enabled, so you may copy the active one from your - cluster to a new node in order to connect, if it is not part of the cluster. - -
-
- Client authorization and TLS - - - By default, any user who can connect to a FoundationDB process with the - correct cluster configuration can access anything. FoundationDB uses a - pluggable design to transport security, and out of the box it supports a - LibreSSL-based plugin for TLS support. This plugin not only does in-flight - encryption, but also performs client authorization based on the given - endpoint's certificate chain. For example, a FoundationDB server may be - configured to only accept client connections over TLS, where the client TLS - certificate is from organization Acme Co in the - Research and Development unit. - - - - Configuring TLS with FoundationDB is done using the - options in order to control the - peer verification string, as well as the certificate and its private key. - - - - Note that the certificate and its private key must be accessible to the - FoundationDB user account that the server runs under. These files are also - NOT managed by NixOS, as putting them into the store may reveal private - information. - - - - After you have a key and certificate file in place, it is not enough to - simply set the NixOS module options -- you must also configure the - fdb.cluster file to specify that a given set of - coordinators use TLS. This is as simple as adding the suffix - :tls to your cluster coordinator configuration, after the - port number. For example, assuming you have a coordinator on localhost with - the default configuration, simply specifying: - - - +
+
+ Scaling processes and backup agents + + Scaling the number of server processes is quite easy; simply + specify to + be the number of FoundationDB worker processes that should be + started on the machine. + + + FoundationDB worker processes typically require 4GB of RAM + per-process at minimum for good performance, so this option is set + to 1 by default since the maximum amount of RAM is unknown. You’re + advised to abide by this restriction, so pick a number of + processes so that each has 4GB or more. + + + A similar option exists in order to scale backup agent processes, + . Backup + agents are not as performance/RAM sensitive, so feel free to + experiment with the number of available backup processes. + +
+
+ Clustering + + FoundationDB on NixOS works similarly to other Linux systems, so + this section will be brief. Please refer to the full FoundationDB + documentation for more on clustering. + + + FoundationDB organizes clusters using a set of + coordinators, which are just + specially-designated worker processes. By default, every + installation of FoundationDB on NixOS will start as its own + individual cluster, with a single coordinator: the first worker + process on localhost. + + + Coordinators are specified globally using the + /etc/foundationdb/fdb.cluster file, which all + servers and client applications will use to find and join + coordinators. Note that this file can not be + managed by NixOS so easily: FoundationDB is designed so that it + will rewrite the file at runtime for all clients and nodes when + cluster coordinators change, with clients transparently handling + this without intervention. It is fundamentally a mutable file, and + you should not try to manage it in any way in NixOS. + + + When dealing with a cluster, there are two main things you want to + do: + + + + + Add a node to the cluster for storage/compute. + + + + + Promote an ordinary worker to a coordinator. + + + + + A node must already be a member of the cluster in order to + properly be promoted to a coordinator, so you must always add it + first if you wish to promote it. + + + To add a machine to a FoundationDB cluster: + + + + + Choose one of the servers to start as the initial coordinator. + + + + + Copy the /etc/foundationdb/fdb.cluster file + from this server to all the other servers. Restart + FoundationDB on all of these other servers, so they join the + cluster. + + + + + All of these servers are now connected and working together in + the cluster, under the chosen coordinator. + + + + + At this point, you can add as many nodes as you want by just + repeating the above steps. By default there will still be a single + coordinator: you can use fdbcli to change this + and add new coordinators. + + + As a convenience, FoundationDB can automatically assign + coordinators based on the redundancy mode you wish to achieve for + the cluster. Once all the nodes have been joined, simply set the + replication policy, and then issue the + coordinators auto command + + + For example, assuming we have 3 nodes available, we can enable + double redundancy mode, then auto-select coordinators. For double + redundancy, 3 coordinators is ideal: therefore FoundationDB will + make every node a coordinator automatically: + + +fdbcli> configure double ssd +fdbcli> coordinators auto + + + This will transparently update all the servers within seconds, and + appropriately rewrite the fdb.cluster file, as + well as informing all client processes to do the same. + +
+
+ Client connectivity + + By default, all clients must use the current + fdb.cluster file to access a given FoundationDB + cluster. This file is located by default in + /etc/foundationdb/fdb.cluster on all machines + with the FoundationDB service enabled, so you may copy the active + one from your cluster to a new node in order to connect, if it is + not part of the cluster. + +
+
+ Client authorization and TLS + + By default, any user who can connect to a FoundationDB process + with the correct cluster configuration can access anything. + FoundationDB uses a pluggable design to transport security, and + out of the box it supports a LibreSSL-based plugin for TLS + support. This plugin not only does in-flight encryption, but also + performs client authorization based on the given endpoint’s + certificate chain. For example, a FoundationDB server may be + configured to only accept client connections over TLS, where the + client TLS certificate is from organization Acme + Co in the Research and Development + unit. + + + Configuring TLS with FoundationDB is done using the + options in order to + control the peer verification string, as well as the certificate + and its private key. + + + Note that the certificate and its private key must be accessible + to the FoundationDB user account that the server runs under. These + files are also NOT managed by NixOS, as putting them into the + store may reveal private information. + + + After you have a key and certificate file in place, it is not + enough to simply set the NixOS module options – you must also + configure the fdb.cluster file to specify that + a given set of coordinators use TLS. This is as simple as adding + the suffix :tls to your cluster coordinator + configuration, after the port number. For example, assuming you + have a coordinator on localhost with the default configuration, + simply specifying: + + XXXXXX:XXXXXX@127.0.0.1:4500:tls - - - will configure all clients and server processes to use TLS from now on. - -
-
- Backups and Disaster Recovery - - - The usual rules for doing FoundationDB backups apply on NixOS as written in - the FoundationDB manual. However, one important difference is the security - profile for NixOS: by default, the foundationdb systemd - unit uses Linux namespaces to restrict write access to - the system, except for the log directory, data directory, and the - /etc/foundationdb/ directory. This is enforced by default - and cannot be disabled. - - - - However, a side effect of this is that the fdbbackup - command doesn't work properly for local filesystem backups: FoundationDB - uses a server process alongside the database processes to perform backups - and copy the backups to the filesystem. As a result, this process is put - under the restricted namespaces above: the backup process can only write to - a limited number of paths. - - - - In order to allow flexible backup locations on local disks, the FoundationDB - NixOS module supports a - option. This - option takes a list of paths, and adds them to the systemd unit, allowing - the processes inside the service to write (and read) the specified - directories. - - - - For example, to create backups in /opt/fdb-backups, first - set up the paths in the module options: - - - -services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ]; + + will configure all clients and server processes to use TLS from + now on. + +
+
+ Backups and Disaster Recovery + + The usual rules for doing FoundationDB backups apply on NixOS as + written in the FoundationDB manual. However, one important + difference is the security profile for NixOS: by default, the + foundationdb systemd unit uses Linux + namespaces to restrict write access to the system, + except for the log directory, data directory, and the + /etc/foundationdb/ directory. This is enforced + by default and cannot be disabled. + + + However, a side effect of this is that the + fdbbackup command doesn’t work properly for + local filesystem backups: FoundationDB uses a server process + alongside the database processes to perform backups and copy the + backups to the filesystem. As a result, this process is put under + the restricted namespaces above: the backup process can only write + to a limited number of paths. + + + In order to allow flexible backup locations on local disks, the + FoundationDB NixOS module supports a + option. + This option takes a list of paths, and adds them to the systemd + unit, allowing the processes inside the service to write (and + read) the specified directories. + + + For example, to create backups in + /opt/fdb-backups, first set up the paths in the + module options: + + +services.foundationdb.extraReadWritePaths = [ "/opt/fdb-backups" ]; - - - Restart the FoundationDB service, and it will now be able to write to this - directory (even if it does not yet exist.) Note: this path - must exist before restarting the unit. Otherwise, - systemd will not include it in the private FoundationDB namespace (and it - will not add it dynamically at runtime). - - - - You can now perform a backup: - - - -$ sudo -u foundationdb fdbbackup start -t default -d file:///opt/fdb-backups -$ sudo -u foundationdb fdbbackup status -t default - -
-
- Known limitations - - - The FoundationDB setup for NixOS should currently be considered beta. - FoundationDB is not new software, but the NixOS compilation and integration - has only undergone fairly basic testing of all the available functionality. - - - - - There is no way to specify individual parameters for individual - fdbserver processes. Currently, all server processes - inherit all the global fdbmonitor settings. + Restart the FoundationDB service, and it will now be able to write + to this directory (even if it does not yet exist.) Note: this path + must exist before restarting the unit. + Otherwise, systemd will not include it in the private FoundationDB + namespace (and it will not add it dynamically at runtime). - - - Ruby bindings are not currently installed. + You can now perform a backup: - - + +$ sudo -u foundationdb fdbbackup start -t default -d file:///opt/fdb-backups +$ sudo -u foundationdb fdbbackup status -t default + +
+
+ Known limitations - Go bindings are not currently installed. + The FoundationDB setup for NixOS should currently be considered + beta. FoundationDB is not new software, but the NixOS compilation + and integration has only undergone fairly basic testing of all the + available functionality. - - -
-
- Options - - - NixOS's FoundationDB module allows you to configure all of the most relevant - configuration options for fdbmonitor, matching it quite - closely. A complete list of options for the FoundationDB module may be found - here. You should - also read the FoundationDB documentation as well. - -
-
- Full documentation - - - FoundationDB is a complex piece of software, and requires careful - administration to properly use. Full documentation for administration can be - found here: . - -
+ + + + There is no way to specify individual parameters for + individual fdbserver processes. Currently, + all server processes inherit all the global + fdbmonitor settings. + + + + + Ruby bindings are not currently installed. + + + + + Go bindings are not currently installed. + + + +
+
+ Options + + NixOS’s FoundationDB module allows you to configure all of the + most relevant configuration options for + fdbmonitor, matching it quite closely. A + complete list of options for the FoundationDB module may be found + here. You + should also read the FoundationDB documentation as well. + +
+
+ Full documentation + + FoundationDB is a complex piece of software, and requires careful + administration to properly use. Full documentation for + administration can be found here: + https://apple.github.io/foundationdb/. + +
diff --git a/nixos/modules/services/databases/postgresql.md b/nixos/modules/services/databases/postgresql.md new file mode 100644 index 000000000000..1805bafe3be3 --- /dev/null +++ b/nixos/modules/services/databases/postgresql.md @@ -0,0 +1,173 @@ +# PostgreSQL {#module-postgresql} + + + + +*Source:* {file}`modules/services/databases/postgresql.nix` + +*Upstream documentation:* + + + +PostgreSQL is an advanced, free relational database. + + +## Configuring {#module-services-postgres-configuring} + +To enable PostgreSQL, add the following to your {file}`configuration.nix`: +``` +services.postgresql.enable = true; +services.postgresql.package = pkgs.postgresql_11; +``` +Note that you are required to specify the desired version of PostgreSQL (e.g. `pkgs.postgresql_11`). Since upgrading your PostgreSQL version requires a database dump and reload (see below), NixOS cannot provide a default value for [](#opt-services.postgresql.package) such as the most recent release of PostgreSQL. + + + +By default, PostgreSQL stores its databases in {file}`/var/lib/postgresql/$psqlSchema`. You can override this using [](#opt-services.postgresql.dataDir), e.g. +``` +services.postgresql.dataDir = "/data/postgresql"; +``` + +## Upgrading {#module-services-postgres-upgrading} + +::: {.note} +The steps below demonstrate how to upgrade from an older version to `pkgs.postgresql_13`. +These instructions are also applicable to other versions. +::: + +Major PostgreSQL upgrades require a downtime and a few imperative steps to be called. This is the case because +each major version has some internal changes in the databases' state during major releases. Because of that, +NixOS places the state into {file}`/var/lib/postgresql/<version>` where each `version` +can be obtained like this: +``` +$ nix-instantiate --eval -A postgresql_13.psqlSchema +"13" +``` +For an upgrade, a script like this can be used to simplify the process: +``` +{ config, 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 + ]); + 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 OLDDATA="${config.services.postgresql.dataDir}" + export OLDBIN="${config.services.postgresql.package}/bin" + + install -d -m 0700 -o postgres -g postgres "$NEWDATA" + cd "$NEWDATA" + sudo -u postgres $NEWBIN/initdb -D "$NEWDATA" + + sudo -u postgres $NEWBIN/pg_upgrade \ + --old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \ + --old-bindir $OLDBIN --new-bindir $NEWBIN \ + "$@" + '') + ]; +} +``` + +The upgrade process is: + + 1. Rebuild nixos configuration with the configuration above added to your {file}`configuration.nix`. Alternatively, add that into separate file and reference it in `imports` list. + 2. Login as root (`sudo su -`) + 3. Run `upgrade-pg-cluster`. It will stop old postgresql, initialize a new one and migrate the old one to the new one. You may supply arguments like `--jobs 4` and `--link` to speedup migration process. See for details. + 4. Change postgresql package in NixOS configuration to the one you were upgrading to via [](#opt-services.postgresql.package). Rebuild NixOS. This should start new postgres using upgraded data directory and all services you stopped during the upgrade. + 5. After the upgrade it's advisable to analyze the new cluster. + + - For PostgreSQL ≥ 14, use the `vacuumdb` command printed by the upgrades script. + - For PostgreSQL < 14, run (as `su -l postgres` in the [](#opt-services.postgresql.dataDir), in this example {file}`/var/lib/postgresql/13`): + + ``` + $ ./analyze_new_cluster.sh + ``` + + ::: {.warning} + The next step removes the old state-directory! + ::: + + ``` + $ ./delete_old_cluster.sh + ``` + +## Options {#module-services-postgres-options} + +A complete list of options for the PostgreSQL module may be found [here](#opt-services.postgresql.enable). + +## Plugins {#module-services-postgres-plugins} + +Plugins collection for each PostgreSQL version can be accessed with `.pkgs`. For example, for `pkgs.postgresql_11` package, its plugin collection is accessed by `pkgs.postgresql_11.pkgs`: +```ShellSession +$ nix repl '' + +Loading ''... +Added 10574 variables. + +nix-repl> postgresql_11.pkgs. +postgresql_11.pkgs.cstore_fdw postgresql_11.pkgs.pg_repack +postgresql_11.pkgs.pg_auto_failover postgresql_11.pkgs.pg_safeupdate +postgresql_11.pkgs.pg_bigm postgresql_11.pkgs.pg_similarity +postgresql_11.pkgs.pg_cron postgresql_11.pkgs.pg_topn +postgresql_11.pkgs.pg_hll postgresql_11.pkgs.pgjwt +postgresql_11.pkgs.pg_partman postgresql_11.pkgs.pgroonga +... +``` + +To add plugins via NixOS configuration, set `services.postgresql.extraPlugins`: +``` +services.postgresql.package = pkgs.postgresql_11; +services.postgresql.extraPlugins = with pkgs.postgresql_11.pkgs; [ + pg_repack + postgis +]; +``` + +You 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: +``` +self: super: { + postgresql_custom = self.postgresql_11.withPackages (ps: [ + ps.pg_repack + ps.postgis + ]); +} +``` + +Here's a recipe on how to override a particular plugin through an overlay: +``` +self: super: { + postgresql_11 = super.postgresql_11.override { this = self.postgresql_11; } // { + pkgs = super.postgresql_11.pkgs // { + pg_repack = super.postgresql_11.pkgs.pg_repack.overrideAttrs (_: { + name = "pg_repack-v20181024"; + src = self.fetchzip { + url = "https://github.com/reorg/pg_repack/archive/923fa2f3c709a506e111cc963034bf2fd127aa00.tar.gz"; + sha256 = "17k6hq9xaax87yz79j773qyigm4fwk8z4zh5cyp6z0sxnwfqxxw5"; + }; + }); + }; + }; +} +``` diff --git a/nixos/modules/services/databases/postgresql.xml b/nixos/modules/services/databases/postgresql.xml index e48c578e6ce6..2f62d5d80b19 100644 --- a/nixos/modules/services/databases/postgresql.xml +++ b/nixos/modules/services/databases/postgresql.xml @@ -1,181 +1,199 @@ - - PostgreSQL - - - - Source: modules/services/databases/postgresql.nix - - - Upstream documentation: - - - - PostgreSQL is an advanced, free relational database. - - -
- Configuring - + + + PostgreSQL - To enable PostgreSQL, add the following to your configuration.nix: - - = true; - = pkgs.postgresql_11; - - Note that you are required to specify the desired version of PostgreSQL (e.g. pkgs.postgresql_11). Since upgrading your PostgreSQL version requires a database dump and reload (see below), NixOS cannot provide a default value for such as the most recent release of PostgreSQL. + Source: + modules/services/databases/postgresql.nix - - - - By default, PostgreSQL stores its databases in /var/lib/postgresql/$psqlSchema. You can override this using , e.g. - - = "/data/postgresql"; - + Upstream documentation: + http://www.postgresql.org/docs/ -
-
- Upgrading - - - - The steps below demonstrate how to upgrade from an older version to pkgs.postgresql_13. - These instructions are also applicable to other versions. - - - Major PostgreSQL upgrades require a downtime and a few imperative steps to be called. This is the case because - each major version has some internal changes in the databases' state during major releases. Because of that, - NixOS places the state into /var/lib/postgresql/<version> where each version - can be obtained like this: - -$ nix-instantiate --eval -A postgresql_13.psqlSchema -"13" + PostgreSQL is an advanced, free relational database. + +
+ Configuring + + To enable PostgreSQL, add the following to your + configuration.nix: + + +services.postgresql.enable = true; +services.postgresql.package = pkgs.postgresql_11; - For an upgrade, a script like this can be used to simplify the process: - + + Note that you are required to specify the desired version of + PostgreSQL (e.g. pkgs.postgresql_11). Since + upgrading your PostgreSQL version requires a database dump and + reload (see below), NixOS cannot provide a default value for + such as the + most recent release of PostgreSQL. + + + By default, PostgreSQL stores its databases in + /var/lib/postgresql/$psqlSchema. You can + override this using + , e.g. + + +services.postgresql.dataDir = "/data/postgresql"; + +
+
+ Upgrading + + + The steps below demonstrate how to upgrade from an older version + to pkgs.postgresql_13. These instructions are + also applicable to other versions. + + + + Major PostgreSQL upgrades require a downtime and a few imperative + steps to be called. This is the case because each major version + has some internal changes in the databases’ state during major + releases. Because of that, NixOS places the state into + /var/lib/postgresql/<version> where + each version can be obtained like this: + + +$ nix-instantiate --eval -A postgresql_13.psqlSchema +"13" + + + For an upgrade, a script like this can be used to simplify the + process: + + { config, 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 ]); - in pkgs.writeScriptBin "upgrade-pg-cluster" '' + 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 NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}" - export NEWBIN="${newPostgres}/bin" + export NEWBIN="${newPostgres}/bin" - export OLDDATA="${config.}" - export OLDBIN="${config.}/bin" + export OLDDATA="${config.services.postgresql.dataDir}" + export OLDBIN="${config.services.postgresql.package}/bin" - install -d -m 0700 -o postgres -g postgres "$NEWDATA" - cd "$NEWDATA" - sudo -u postgres $NEWBIN/initdb -D "$NEWDATA" + install -d -m 0700 -o postgres -g postgres "$NEWDATA" + cd "$NEWDATA" + sudo -u postgres $NEWBIN/initdb -D "$NEWDATA" sudo -u postgres $NEWBIN/pg_upgrade \ - --old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \ + --old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \ --old-bindir $OLDBIN --new-bindir $NEWBIN \ - "$@" + "$@" '') ]; } - - - - The upgrade process is: - - - - - Rebuild nixos configuration with the configuration above added to your configuration.nix. Alternatively, add that into separate file and reference it in imports list. + The upgrade process is: - - - - Login as root (sudo su -) - - - - - Run upgrade-pg-cluster. It will stop old postgresql, initialize a new one and migrate the old one to the new one. You may supply arguments like --jobs 4 and --link to speedup migration process. See for details. - - - - - Change postgresql package in NixOS configuration to the one you were upgrading to via . Rebuild NixOS. This should start new postgres using upgraded data directory and all services you stopped during the upgrade. - - - - - After the upgrade it's advisable to analyze the new cluster. - - - - - For PostgreSQL ≥ 14, use the vacuumdb command printed by the upgrades script. - - - - - For PostgreSQL < 14, run (as su -l postgres in the , in this example /var/lib/postgresql/13): - -$ ./analyze_new_cluster.sh + + + + Rebuild nixos configuration with the configuration above added + to your configuration.nix. Alternatively, + add that into separate file and reference it in + imports list. + + + + + Login as root (sudo su -) + + + + + Run upgrade-pg-cluster. It will stop old + postgresql, initialize a new one and migrate the old one to + the new one. You may supply arguments like + --jobs 4 and --link to + speedup migration process. See + https://www.postgresql.org/docs/current/pgupgrade.html + for details. + + + + + Change postgresql package in NixOS configuration to the one + you were upgrading to via + . Rebuild + NixOS. This should start new postgres using upgraded data + directory and all services you stopped during the upgrade. + + + + + After the upgrade it’s advisable to analyze the new cluster. + + + + + For PostgreSQL ≥ 14, use the vacuumdb + command printed by the upgrades script. + + + + + For PostgreSQL < 14, run (as + su -l postgres in the + , in + this example /var/lib/postgresql/13): + + +$ ./analyze_new_cluster.sh - - - - - The next step removes the old state-directory! - -$ ./delete_old_cluster.sh + + + + + The next step removes the old state-directory! + + + +$ ./delete_old_cluster.sh + + +
+
+ Options + + A complete list of options for the PostgreSQL module may be found + here. - - -
-
- Options - - - A complete list of options for the PostgreSQL module may be found here. - -
-
- Plugins - - - Plugins collection for each PostgreSQL version can be accessed with .pkgs. For example, for pkgs.postgresql_11 package, its plugin collection is accessed by pkgs.postgresql_11.pkgs: - -$ nix repl '<nixpkgs>' +
+
+ Plugins + + Plugins collection for each PostgreSQL version can be accessed + with .pkgs. For example, for + pkgs.postgresql_11 package, its plugin + collection is accessed by + pkgs.postgresql_11.pkgs: + + +$ nix repl '<nixpkgs>' Loading '<nixpkgs>'... Added 10574 variables. -nix-repl> postgresql_11.pkgs.<TAB><TAB> +nix-repl> postgresql_11.pkgs.<TAB><TAB> postgresql_11.pkgs.cstore_fdw postgresql_11.pkgs.pg_repack postgresql_11.pkgs.pg_auto_failover postgresql_11.pkgs.pg_safeupdate postgresql_11.pkgs.pg_bigm postgresql_11.pkgs.pg_similarity @@ -183,23 +201,25 @@ postgresql_11.pkgs.pg_cron postgresql_11.pkgs.pg_topn postgresql_11.pkgs.pg_hll postgresql_11.pkgs.pgjwt postgresql_11.pkgs.pg_partman postgresql_11.pkgs.pgroonga ... - - - - - To add plugins via NixOS configuration, set services.postgresql.extraPlugins: - - = pkgs.postgresql_11; - = with pkgs.postgresql_11.pkgs; [ + + + To add plugins via NixOS configuration, set + services.postgresql.extraPlugins: + + +services.postgresql.package = pkgs.postgresql_11; +services.postgresql.extraPlugins = with pkgs.postgresql_11.pkgs; [ pg_repack postgis ]; - - - - You 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: - + + You 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: + + self: super: { postgresql_custom = self.postgresql_11.withPackages (ps: [ ps.pg_repack @@ -207,25 +227,24 @@ self: super: { ]); } - - - - Here's a recipe on how to override a particular plugin through an overlay: - + + Here’s a recipe on how to override a particular plugin through an + overlay: + + self: super: { postgresql_11 = super.postgresql_11.override { this = self.postgresql_11; } // { pkgs = super.postgresql_11.pkgs // { pg_repack = super.postgresql_11.pkgs.pg_repack.overrideAttrs (_: { - name = "pg_repack-v20181024"; + name = "pg_repack-v20181024"; src = self.fetchzip { - url = "https://github.com/reorg/pg_repack/archive/923fa2f3c709a506e111cc963034bf2fd127aa00.tar.gz"; - sha256 = "17k6hq9xaax87yz79j773qyigm4fwk8z4zh5cyp6z0sxnwfqxxw5"; + url = "https://github.com/reorg/pg_repack/archive/923fa2f3c709a506e111cc963034bf2fd127aa00.tar.gz"; + sha256 = "17k6hq9xaax87yz79j773qyigm4fwk8z4zh5cyp6z0sxnwfqxxw5"; }; }); }; }; } - -
+
diff --git a/nixos/modules/services/desktops/flatpak.md b/nixos/modules/services/desktops/flatpak.md new file mode 100644 index 000000000000..65b1554d79b4 --- /dev/null +++ b/nixos/modules/services/desktops/flatpak.md @@ -0,0 +1,39 @@ +# Flatpak {#module-services-flatpak} + +*Source:* {file}`modules/services/desktop/flatpak.nix` + +*Upstream documentation:* + +Flatpak is a system for building, distributing, and running sandboxed desktop +applications on Linux. + +To enable Flatpak, add the following to your {file}`configuration.nix`: +``` + services.flatpak.enable = true; +``` + +For the sandboxed apps to work correctly, desktop integration portals need to +be installed. If you run GNOME, this will be handled automatically for you; +in other cases, you will need to add something like the following to your +{file}`configuration.nix`: +``` + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; +``` + +Then, you will need to add a repository, for example, +[Flathub](https://github.com/flatpak/flatpak/wiki), +either using the following commands: +```ShellSession +$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +$ flatpak update +``` +or by opening the +[repository file](https://flathub.org/repo/flathub.flatpakrepo) in GNOME Software. + +Finally, you can search and install programs: +```ShellSession +$ flatpak search bustle +$ flatpak install flathub org.freedesktop.Bustle +$ flatpak run org.freedesktop.Bustle +``` +Again, GNOME Software offers graphical interface for these tasks. diff --git a/nixos/modules/services/desktops/flatpak.xml b/nixos/modules/services/desktops/flatpak.xml index 8f080b250228..cdc3278fa996 100644 --- a/nixos/modules/services/desktops/flatpak.xml +++ b/nixos/modules/services/desktops/flatpak.xml @@ -1,56 +1,59 @@ - - Flatpak - - Source: - modules/services/desktop/flatpak.nix - - - Upstream documentation: - - - - Flatpak is a system for building, distributing, and running sandboxed desktop - applications on Linux. - - - To enable Flatpak, add the following to your - configuration.nix: - - = true; + + + Flatpak + + Source: + modules/services/desktop/flatpak.nix + + + Upstream documentation: + https://github.com/flatpak/flatpak/wiki + + + Flatpak is a system for building, distributing, and running + sandboxed desktop applications on Linux. + + + To enable Flatpak, add the following to your + configuration.nix: + + + services.flatpak.enable = true; - - - For the sandboxed apps to work correctly, desktop integration portals need to - be installed. If you run GNOME, this will be handled automatically for you; - in other cases, you will need to add something like the following to your - configuration.nix: - - = [ pkgs.xdg-desktop-portal-gtk ]; + + For the sandboxed apps to work correctly, desktop integration + portals need to be installed. If you run GNOME, this will be handled + automatically for you; in other cases, you will need to add + something like the following to your + configuration.nix: + + + xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; - - - Then, you will need to add a repository, for example, - Flathub, - either using the following commands: - -$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo -$ flatpak update - - or by opening the - repository - file in GNOME Software. - - - Finally, you can search and install programs: - -$ flatpak search bustle -$ flatpak install flathub org.freedesktop.Bustle -$ flatpak run org.freedesktop.Bustle - - Again, GNOME Software offers graphical interface for these tasks. - + + Then, you will need to add a repository, for example, + Flathub, + either using the following commands: + + +$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +$ flatpak update + + + or by opening the + repository + file in GNOME Software. + + + Finally, you can search and install programs: + + +$ flatpak search bustle +$ flatpak install flathub org.freedesktop.Bustle +$ flatpak run org.freedesktop.Bustle + + + Again, GNOME Software offers graphical interface for these tasks. + diff --git a/nixos/modules/services/development/blackfire.md b/nixos/modules/services/development/blackfire.md new file mode 100644 index 000000000000..e2e7e4780c79 --- /dev/null +++ b/nixos/modules/services/development/blackfire.md @@ -0,0 +1,39 @@ +# Blackfire profiler {#module-services-blackfire} + +*Source:* {file}`modules/services/development/blackfire.nix` + +*Upstream documentation:* + +[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. + +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: +``` +let + php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [ + blackfire + ])); +in { + # Enable the probe extension for PHP-FPM. + services.phpfpm = { + phpPackage = php; + }; + + # Enable and configure the agent. + services.blackfire-agent = { + enable = true; + settings = { + # You will need to get credentials at https://blackfire.io/my/settings/credentials + # You can also use other options described in https://blackfire.io/docs/up-and-running/configuration/agent + server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; + server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; + }; + }; + + # Make the agent run on start-up. + # (WantedBy= from the upstream unit not respected: https://github.com/NixOS/nixpkgs/issues/81138) + # Alternately, you can start it manually with `systemctl start blackfire-agent`. + systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ]; +} +``` + +On your developer machine, you will also want to install [the client](https://blackfire.io/docs/up-and-running/installation#install-a-profiling-client) (see `blackfire` package) or the browser extension to actually trigger the profiling. diff --git a/nixos/modules/services/development/blackfire.xml b/nixos/modules/services/development/blackfire.xml index cecd249dda48..842e5bec97d5 100644 --- a/nixos/modules/services/development/blackfire.xml +++ b/nixos/modules/services/development/blackfire.xml @@ -1,19 +1,31 @@ - - Blackfire profiler - - Source: - modules/services/development/blackfire.nix - - - Upstream documentation: - - - - Blackfire 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. - - - 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: -let + + + Blackfire profiler + + Source: + modules/services/development/blackfire.nix + + + Upstream documentation: + https://blackfire.io/docs/introduction + + + Blackfire 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. + + + 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: + + +let php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [ blackfire ])); @@ -29,18 +41,21 @@ in { settings = { # You will need to get credentials at https://blackfire.io/my/settings/credentials # You can also use other options described in https://blackfire.io/docs/up-and-running/configuration/agent - server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; - server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; + server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; + server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; }; }; # Make the agent run on start-up. # (WantedBy= from the upstream unit not respected: https://github.com/NixOS/nixpkgs/issues/81138) # Alternately, you can start it manually with `systemctl start blackfire-agent`. - systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ]; -} - - - On your developer machine, you will also want to install the client (see blackfire package) or the browser extension to actually trigger the profiling. - + systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ]; +} + + + On your developer machine, you will also want to install + the + client (see blackfire package) or the + browser extension to actually trigger the profiling. + diff --git a/nixos/modules/services/editors/emacs.md b/nixos/modules/services/editors/emacs.md new file mode 100644 index 000000000000..c072b3664ad1 --- /dev/null +++ b/nixos/modules/services/editors/emacs.md @@ -0,0 +1,399 @@ +# Emacs {#module-services-emacs} + + + +[Emacs](https://www.gnu.org/software/emacs/) is an +extensible, customizable, self-documenting real-time display editor — and +more. At its core is an interpreter for Emacs Lisp, a dialect of the Lisp +programming language with extensions to support text editing. + +Emacs runs within a graphical desktop environment using the X Window System, +but works equally well on a text terminal. Under +macOS, a "Mac port" edition is available, which +uses Apple's native GUI frameworks. + +Nixpkgs provides a superior environment for +running Emacs. It's simple to create custom builds +by overriding the default packages. Chaotic collections of Emacs Lisp code +and extensions can be brought under control using declarative package +management. NixOS even provides a +{command}`systemd` user service for automatically starting the Emacs +daemon. + +## Installing Emacs {#module-services-emacs-installing} + +Emacs can be installed in the normal way for Nix (see +[](#sec-package-management)). In addition, a NixOS +*service* can be enabled. + +### The Different Releases of Emacs {#module-services-emacs-releases} + +Nixpkgs defines several basic Emacs packages. +The following are attributes belonging to the {var}`pkgs` set: + + {var}`emacs` + : The latest stable version of Emacs using the [GTK 2](http://www.gtk.org) + widget toolkit. + + {var}`emacs-nox` + : Emacs built without any dependency on X11 libraries. + + {var}`emacsMacport` + : Emacs with the "Mac port" patches, providing a more native look and + feel under macOS. + +If those aren't suitable, then the following imitation Emacs editors are +also available in Nixpkgs: +[Zile](https://www.gnu.org/software/zile/), +[mg](http://homepage.boetes.org/software/mg/), +[Yi](http://yi-editor.github.io/), +[jmacs](https://joe-editor.sourceforge.io/). + +### Adding Packages to Emacs {#module-services-emacs-adding-packages} + +Emacs includes an entire ecosystem of functionality beyond text editing, +including a project planner, mail and news reader, debugger interface, +calendar, and more. + +Most extensions are gotten with the Emacs packaging system +({file}`package.el`) from +[Emacs Lisp Package Archive (ELPA)](https://elpa.gnu.org/), +[MELPA](https://melpa.org/), +[MELPA Stable](https://stable.melpa.org/), and +[Org ELPA](http://orgmode.org/elpa.html). Nixpkgs is +regularly updated to mirror all these archives. + +Under NixOS, you can continue to use +`package-list-packages` and +`package-install` to install packages. You can also +declare the set of Emacs packages you need using the derivations from +Nixpkgs. The rest of this section discusses declarative installation of +Emacs packages through nixpkgs. + +The first step to declare the list of packages you want in your Emacs +installation is to create a dedicated derivation. This can be done in a +dedicated {file}`emacs.nix` file such as: + +[]{#ex-emacsNix} + +```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. + +To build the project, type the following from the current directory: + +$ nix-build emacs.nix + +To run the newly compiled executable: + +$ ./result/bin/emacs +*/ + +# The first non-comment line in this file indicates that +# the whole file represents a function. +{ pkgs ? import {} }: + +let + # The let expression below defines a myEmacs binding pointing to the + # current stable version of Emacs. This binding is here to separate + # the choice of the Emacs binary from the specification of the + # required packages. + myEmacs = pkgs.emacs; + # This generates an emacsWithPackages function. It takes a single + # 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 + zerodark-theme # ; Nicolas' theme + ]) + # Two packages (undo-tree and zoom-frm) are taken from MELPA. + ++ (with epkgs.melpaPackages; [ + undo-tree # ; 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 + ]) + # notmuch is taken from a nixpkgs derivation which contains an Emacs mode. + ++ [ + pkgs.notmuch # From main packages set + ]) +``` + +The result of this configuration will be an {command}`emacs` +command which launches Emacs with all of your chosen packages in the +{var}`load-path`. + +You can check that it works by executing this in a terminal: +```ShellSession +$ nix-build emacs.nix +$ ./result/bin/emacs -q +``` +and then typing `M-x package-initialize`. Check that you +can use all the packages you want in this Emacs instance. For example, try +switching to the zerodark theme through `M-x load-theme zerodark y`. + +::: {.tip} +A few popular extensions worth checking out are: auctex, company, +edit-server, flycheck, helm, iedit, magit, multiple-cursors, projectile, +and yasnippet. +::: + +The list of available packages in the various ELPA repositories can be seen +with the following commands: +[]{#module-services-emacs-querying-packages} +``` +nix-env -f "" -qaP -A emacs.pkgs.elpaPackages +nix-env -f "" -qaP -A emacs.pkgs.melpaPackages +nix-env -f "" -qaP -A emacs.pkgs.melpaStablePackages +nix-env -f "" -qaP -A emacs.pkgs.orgPackages +``` + +If you are on NixOS, you can install this particular Emacs for all users by +adding it to the list of system packages (see +[](#sec-declarative-package-mgmt)). Simply modify your file +{file}`configuration.nix` to make it contain: +[]{#module-services-emacs-configuration-nix} +``` +{ + environment.systemPackages = [ + # [...] + (import /path/to/emacs.nix { inherit pkgs; }) + ]; +} +``` + +In this case, the next {command}`nixos-rebuild switch` will take +care of adding your {command}`emacs` to the {var}`PATH` +environment variable (see [](#sec-changing-config)). + + + +If you are not on NixOS or want to install this particular Emacs only for +yourself, you can do so by adding it to your +{file}`~/.config/nixpkgs/config.nix` (see +[Nixpkgs manual](https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides)): +[]{#module-services-emacs-config-nix} +``` +{ + packageOverrides = super: let self = super.pkgs; in { + myemacs = import /path/to/emacs.nix { pkgs = self; }; + }; +} +``` + +In this case, the next `nix-env -f '' -iA +myemacs` will take care of adding your emacs to the +{var}`PATH` environment variable. + +### Advanced Emacs Configuration {#module-services-emacs-advanced} + +If you want, you can tweak the Emacs package itself from your +{file}`emacs.nix`. For example, if you want to have a +GTK 3-based Emacs instead of the default GTK 2-based binary and remove the +automatically generated {file}`emacs.desktop` (useful if you +only use {command}`emacsclient`), you can change your file +{file}`emacs.nix` in this way: + +[]{#ex-emacsGtk3Nix} +``` +{ pkgs ? import {} }: +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 [...] +``` + +After building this file as shown in [the example above](#ex-emacsNix), you +will get an GTK 3-based Emacs binary pre-loaded with your favorite packages. + +## Running Emacs as a Service {#module-services-emacs-running} + +NixOS provides an optional +{command}`systemd` service which launches +[Emacs daemon](https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html) +with the user's login session. + +*Source:* {file}`modules/services/editors/emacs.nix` + +### Enabling the Service {#module-services-emacs-enabling} + +To install and enable the {command}`systemd` user service for Emacs +daemon, add the following to your {file}`configuration.nix`: +``` +services.emacs.enable = true; +services.emacs.package = import /home/cassou/.emacs.d { pkgs = pkgs; }; +``` + +The {var}`services.emacs.package` option allows a custom +derivation to be used, for example, one created by +`emacsWithPackages`. + +Ensure that the Emacs server is enabled for your user's Emacs +configuration, either by customizing the {var}`server-mode` +variable, or by adding `(server-start)` to +{file}`~/.emacs.d/init.el`. + +To start the daemon, execute the following: +```ShellSession +$ nixos-rebuild switch # to activate the new configuration.nix +$ systemctl --user daemon-reload # to force systemd reload +$ systemctl --user start emacs.service # to start the Emacs daemon +``` +The server should now be ready to serve Emacs clients. + +### Starting the client {#module-services-emacs-starting-client} + +Ensure that the emacs server is enabled, either by customizing the +{var}`server-mode` variable, or by adding +`(server-start)` to {file}`~/.emacs`. + +To connect to the emacs daemon, run one of the following: +``` +emacsclient FILENAME +emacsclient --create-frame # opens a new frame (window) +emacsclient --create-frame --tty # opens a new frame on the current terminal +``` + +### Configuring the {var}`EDITOR` variable {#module-services-emacs-editor-variable} + + + +If [](#opt-services.emacs.defaultEditor) is +`true`, the {var}`EDITOR` variable will be set +to a wrapper script which launches {command}`emacsclient`. + +Any setting of {var}`EDITOR` in the shell config files will +override {var}`services.emacs.defaultEditor`. To make sure +{var}`EDITOR` refers to the Emacs wrapper script, remove any +existing {var}`EDITOR` assignment from +{file}`.profile`, {file}`.bashrc`, +{file}`.zshenv` or any other shell config file. + +If you have formed certain bad habits when editing files, these can be +corrected with a shell alias to the wrapper script: +``` +alias vi=$EDITOR +``` + +### Per-User Enabling of the Service {#module-services-emacs-per-user} + +In general, {command}`systemd` user services are globally enabled +by symlinks in {file}`/etc/systemd/user`. In the case where +Emacs daemon is not wanted for all users, it is possible to install the +service but not globally enable it: +``` +services.emacs.enable = false; +services.emacs.install = true; +``` + +To enable the {command}`systemd` user service for just the +currently logged in user, run: +``` +systemctl --user enable emacs +``` +This will add the symlink +{file}`~/.config/systemd/user/emacs.service`. + +## Configuring Emacs {#module-services-emacs-configuring} + +The Emacs init file should be changed to load the extension packages at +startup: +[]{#module-services-emacs-package-initialisation} +``` +(require 'package) + +;; optional. makes unpure packages archives unavailable +(setq package-archives nil) + +(setq package-enable-at-startup nil) +(package-initialize) +``` + +After the declarative emacs package configuration has been tested, +previously downloaded packages can be cleaned up by removing +{file}`~/.emacs.d/elpa` (do make a backup first, in case you +forgot a package). + + + +### A Major Mode for Nix Expressions {#module-services-emacs-major-mode} + +Of interest may be {var}`melpaPackages.nix-mode`, which +provides syntax highlighting for the Nix language. This is particularly +convenient if you regularly edit Nix files. + +### Accessing man pages {#module-services-emacs-man-pages} + +You can use `woman` to get completion of all available +man pages. For example, type `M-x woman nixos-rebuild .` + +### Editing DocBook 5 XML Documents {#sec-emacs-docbook-xml} + +Emacs includes +[nXML](https://www.gnu.org/software/emacs/manual/html_node/nxml-mode/Introduction.html), +a major-mode for validating and editing XML documents. When editing DocBook +5.0 documents, such as [this one](#book-nixos-manual), +nXML needs to be configured with the relevant schema, which is not +included. + +To install the DocBook 5.0 schemas, either add +{var}`pkgs.docbook5` to [](#opt-environment.systemPackages) +([NixOS](#sec-declarative-package-mgmt)), or run +`nix-env -f '' -iA docbook5` +([Nix](#sec-ad-hoc-packages)). + +Then customize the variable {var}`rng-schema-locating-files` to +include {file}`~/.emacs.d/schemas.xml` and put the following +text into that file: +[]{#ex-emacs-docbook-xml} +```xml + + + + + + + +``` diff --git a/nixos/modules/services/editors/emacs.xml b/nixos/modules/services/editors/emacs.xml index fd99ee9442c9..37d7a93a12b3 100644 --- a/nixos/modules/services/editors/emacs.xml +++ b/nixos/modules/services/editors/emacs.xml @@ -1,143 +1,121 @@ - - Emacs - - - Emacs is an - extensible, customizable, self-documenting real-time display editor — and - more. At its core is an interpreter for Emacs Lisp, a dialect of the Lisp - programming language with extensions to support text editing. - - - Emacs runs within a graphical desktop environment using the X Window System, - but works equally well on a text terminal. Under - macOS, a "Mac port" edition is available, which - uses Apple's native GUI frameworks. - - - Nixpkgs provides a superior environment for - running Emacs. It's simple to create custom builds - by overriding the default packages. Chaotic collections of Emacs Lisp code - and extensions can be brought under control using declarative package - management. NixOS even provides a - systemd user service for automatically starting the Emacs - daemon. - -
- Installing <application>Emacs</application> - + + + Emacs - Emacs can be installed in the normal way for Nix (see - ). In addition, a NixOS - service can be enabled. + Emacs + is an extensible, customizable, self-documenting real-time display + editor — and more. At its core is an interpreter for Emacs Lisp, a + dialect of the Lisp programming language with extensions to support + text editing. - -
- The Different Releases of Emacs - - - Nixpkgs defines several basic Emacs packages. - The following are attributes belonging to the pkgs set: - - - - emacs - - - emacs - - - - The latest stable version of Emacs using the - GTK 2 - widget toolkit. - - - - - - emacs-nox - - - - Emacs built without any dependency on X11 libraries. - - - - - - emacsMacport - - - emacsMacport - - - - Emacs with the "Mac port" patches, providing a more native look and - feel under macOS. - - - - - - - - If those aren't suitable, then the following imitation Emacs editors are - also available in Nixpkgs: - Zile, - mg, - Yi, - jmacs. - -
- -
- Adding Packages to Emacs - - - Emacs includes an entire ecosystem of functionality beyond text editing, - including a project planner, mail and news reader, debugger interface, - calendar, and more. - - - - Most extensions are gotten with the Emacs packaging system - (package.el) from - Emacs Lisp Package Archive - (ELPA), - MELPA, - MELPA Stable, and - Org ELPA. Nixpkgs is - regularly updated to mirror all these archives. - - - - Under NixOS, you can continue to use - package-list-packages and - package-install to install packages. You can also - declare the set of Emacs packages you need using the derivations from - Nixpkgs. The rest of this section discusses declarative installation of - Emacs packages through nixpkgs. - - - - The first step to declare the list of packages you want in your Emacs - installation is to create a dedicated derivation. This can be done in a - dedicated emacs.nix file such as: - - Nix expression to build Emacs with packages (<filename>emacs.nix</filename>) - + + Emacs runs within a graphical desktop environment using the X Window + System, but works equally well on a text terminal. Under macOS, a + Mac port edition is available, which uses Apple’s + native GUI frameworks. + + + Nixpkgs provides a superior environment for running Emacs. It’s + simple to create custom builds by overriding the default packages. + Chaotic collections of Emacs Lisp code and extensions can be brought + under control using declarative package management. NixOS even + provides a systemd user service for automatically + starting the Emacs daemon. + +
+ Installing Emacs + + Emacs can be installed in the normal way for Nix (see + ). In addition, a NixOS + service can be enabled. + +
+ The Different Releases of Emacs + + Nixpkgs defines several basic Emacs packages. The following are + attributes belonging to the pkgs set: + + + + + emacs + + + + The latest stable version of Emacs using the + GTK 2 widget + toolkit. + + + + + + emacs-nox + + + + Emacs built without any dependency on X11 libraries. + + + + + + emacsMacport + + + + Emacs with the Mac port patches, providing + a more native look and feel under macOS. + + + + + + If those aren’t suitable, then the following imitation Emacs + editors are also available in Nixpkgs: + Zile, + mg, + Yi, + jmacs. + +
+
+ Adding Packages to Emacs + + Emacs includes an entire ecosystem of functionality beyond text + editing, including a project planner, mail and news reader, + debugger interface, calendar, and more. + + + Most extensions are gotten with the Emacs packaging system + (package.el) from + Emacs Lisp Package + Archive (ELPA), + MELPA, + MELPA + Stable, and + Org ELPA. + Nixpkgs is regularly updated to mirror all these archives. + + + Under NixOS, you can continue to use + package-list-packages and + package-install to install packages. You can + also declare the set of Emacs packages you need using the + derivations from Nixpkgs. The rest of this section discusses + declarative installation of Emacs packages through nixpkgs. + + + The first step to declare the list of packages you want in your + Emacs installation is to create a dedicated derivation. This can + be done in a dedicated emacs.nix file such + as: + + + + + /* 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 @@ -152,185 +130,142 @@ To run the newly compiled executable: $ ./result/bin/emacs */ -{ pkgs ? import <nixpkgs> {} }: + +# The first non-comment line in this file indicates that +# the whole file represents a function. +{ pkgs ? import <nixpkgs> {} }: let - myEmacs = pkgs.emacs; - emacsWithPackages = (pkgs.emacsPackagesFor myEmacs).emacsWithPackages; + # The let expression below defines a myEmacs binding pointing to the + # current stable version of Emacs. This binding is here to separate + # the choice of the Emacs binary from the specification of the + # required packages. + myEmacs = pkgs.emacs; + # This generates an emacsWithPackages function. It takes a single + # 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 - emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [ + # 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> zerodark-theme # ; Nicolas' theme - ]) ++ (with epkgs.melpaPackages; [ + ]) + # 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-+> - ]) ++ (with epkgs.elpaPackages; [ + ]) + # 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 - ]) ++ [ - pkgs.notmuch # From main packages set + ]) + # notmuch is taken from a nixpkgs derivation which contains an Emacs mode. + ++ [ + pkgs.notmuch # From main packages set ]) - - - - The first non-comment line in this file ({ pkgs ? ... - }) indicates that the whole file represents a function. + The result of this configuration will be an + emacs command which launches Emacs with all + of your chosen packages in the load-path. - - - The let expression below defines a - myEmacs binding pointing to the current stable - version of Emacs. This binding is here to separate the choice of the - Emacs binary from the specification of the required packages. + You can check that it works by executing this in a terminal: - - + +$ nix-build emacs.nix +$ ./result/bin/emacs -q + - This generates an emacsWithPackages function. It - takes a single argument: a function from a package set to a list of - packages (the packages that will be available in Emacs). + and then typing M-x package-initialize. Check + that you can use all the packages you want in this Emacs + instance. For example, try switching to the zerodark theme + through + M-x load-theme <RET> zerodark <RET> y. - - + + + A few popular extensions worth checking out are: auctex, + company, edit-server, flycheck, helm, iedit, magit, + multiple-cursors, projectile, and yasnippet. + + - 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. + The list of available packages in the various ELPA repositories + can be seen with the following commands: + - - + +nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.elpaPackages +nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.melpaPackages +nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.melpaStablePackages +nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.orgPackages + - Two packages (undo-tree and - zoom-frm) are taken from MELPA. + If you are on NixOS, you can install this particular Emacs for + all users by adding it to the list of system packages (see + ). Simply modify + your file configuration.nix to make it + contain: + - - - - Three packages are taken from GNU ELPA. - - - - - notmuch is taken from a nixpkgs derivation which - contains an Emacs mode. - - - - - - - The result of this configuration will be an emacs - command which launches Emacs with all of your chosen packages in the - load-path. - - - - You can check that it works by executing this in a terminal: - -$ nix-build emacs.nix -$ ./result/bin/emacs -q - - and then typing M-x package-initialize. Check that you - can use all the packages you want in this Emacs instance. For example, try - switching to the zerodark theme through M-x load-theme <RET> - zerodark <RET> y. - - - - - A few popular extensions worth checking out are: auctex, company, - edit-server, flycheck, helm, iedit, magit, multiple-cursors, projectile, - and yasnippet. - - - - - The list of available packages in the various ELPA repositories can be seen - with the following commands: - - Querying Emacs packages -" -qaP -A emacs.pkgs.elpaPackages -nix-env -f "" -qaP -A emacs.pkgs.melpaPackages -nix-env -f "" -qaP -A emacs.pkgs.melpaStablePackages -nix-env -f "" -qaP -A emacs.pkgs.orgPackages -]]> - - - - - If you are on NixOS, you can install this particular Emacs for all users by - adding it to the list of system packages (see - ). Simply modify your file - configuration.nix to make it contain: - - Custom Emacs in <filename>configuration.nix</filename> - { environment.systemPackages = [ # [...] (import /path/to/emacs.nix { inherit pkgs; }) ]; } -]]> - - - - - In this case, the next nixos-rebuild switch will take - care of adding your emacs to the PATH - environment variable (see ). - - - - - - If you are not on NixOS or want to install this particular Emacs only for - yourself, you can do so by adding it to your - ~/.config/nixpkgs/config.nix (see - Nixpkgs - manual): - - Custom Emacs in <filename>~/.config/nixpkgs/config.nix</filename> - + + In this case, the next nixos-rebuild switch + will take care of adding your emacs to the + PATH environment variable (see + ). + + + If you are not on NixOS or want to install this particular Emacs + only for yourself, you can do so by adding it to your + ~/.config/nixpkgs/config.nix (see + Nixpkgs + manual): + + + { packageOverrides = super: let self = super.pkgs; in { myemacs = import /path/to/emacs.nix { pkgs = self; }; }; } -]]> - - - - - In this case, the next nix-env -f '<nixpkgs>' -iA - myemacs will take care of adding your emacs to the - PATH environment variable. - -
- -
- Advanced Emacs Configuration - - - If you want, you can tweak the Emacs package itself from your - emacs.nix. For example, if you want to have a - GTK 3-based Emacs instead of the default GTK 2-based binary and remove the - automatically generated emacs.desktop (useful if you - only use emacsclient), you can change your file - emacs.nix in this way: - - - - Custom Emacs build - {} }: + + + In this case, the next + nix-env -f '<nixpkgs>' -iA myemacs will + take care of adding your emacs to the PATH + environment variable. + +
+
+ Advanced Emacs Configuration + + If you want, you can tweak the Emacs package itself from your + emacs.nix. For example, if you want to have + a GTK 3-based Emacs instead of the default GTK 2-based binary + and remove the automatically generated + emacs.desktop (useful if you only use + emacsclient), you can change your file + emacs.nix in this way: + + + + + +{ pkgs ? import <nixpkgs> {} }: let myEmacs = (pkgs.emacs.override { # Use gtk3 instead of the default gtk2 @@ -339,149 +274,143 @@ let }).overrideAttrs (attrs: { # I don't want emacs.desktop file because I only use # emacsclient. - postInstall = (attrs.postInstall or "") + '' + postInstall = (attrs.postInstall or "") + '' rm $out/share/applications/emacs.desktop ''; }); in [...] -]]> - - - - After building this file as shown in , you - will get an GTK 3-based Emacs binary pre-loaded with your favorite packages. - -
-
-
- Running Emacs as a Service - - - NixOS provides an optional - systemd service which launches - - Emacs daemon with the user's login session. - - - - Source: - modules/services/editors/emacs.nix - - -
- Enabling the Service - - - To install and enable the systemd user service for Emacs - daemon, add the following to your configuration.nix: - - = true; - = import /home/cassou/.emacs.d { pkgs = pkgs; }; - - - - The services.emacs.package option allows a custom - derivation to be used, for example, one created by - emacsWithPackages. - - - - Ensure that the Emacs server is enabled for your user's Emacs - configuration, either by customizing the server-mode - variable, or by adding (server-start) to - ~/.emacs.d/init.el. - - - - To start the daemon, execute the following: - -$ nixos-rebuild switch # to activate the new configuration.nix -$ systemctl --user daemon-reload # to force systemd reload -$ systemctl --user start emacs.service # to start the Emacs daemon - - The server should now be ready to serve Emacs clients. - + + After building this file as shown in + the example above, you will + get an GTK 3-based Emacs binary pre-loaded with your favorite + packages. + +
- -
- Starting the client - - - Ensure that the emacs server is enabled, either by customizing the - server-mode variable, or by adding - (server-start) to ~/.emacs. - - - - To connect to the emacs daemon, run one of the following: - + Running Emacs as a Service + + NixOS provides an optional systemd service + which launches + Emacs + daemon with the user’s login session. + + + Source: + modules/services/editors/emacs.nix + +
+ Enabling the Service + + To install and enable the systemd user + service for Emacs daemon, add the following to your + configuration.nix: + + +services.emacs.enable = true; +services.emacs.package = import /home/cassou/.emacs.d { pkgs = pkgs; }; + + + The services.emacs.package option allows a + custom derivation to be used, for example, one created by + emacsWithPackages. + + + Ensure that the Emacs server is enabled for your user’s Emacs + configuration, either by customizing the + server-mode variable, or by adding + (server-start) to + ~/.emacs.d/init.el. + + + To start the daemon, execute the following: + + +$ nixos-rebuild switch # to activate the new configuration.nix +$ systemctl --user daemon-reload # to force systemd reload +$ systemctl --user start emacs.service # to start the Emacs daemon + + + The server should now be ready to serve Emacs clients. + +
+
+ Starting the client + + Ensure that the emacs server is enabled, either by customizing + the server-mode variable, or by adding + (server-start) to + ~/.emacs. + + + To connect to the emacs daemon, run one of the following: + + emacsclient FILENAME emacsclient --create-frame # opens a new frame (window) emacsclient --create-frame --tty # opens a new frame on the current terminal -]]> - -
- -
- Configuring the <varname>EDITOR</varname> variable - - - - - If is - true, the EDITOR variable will be set - to a wrapper script which launches emacsclient. - - - - Any setting of EDITOR in the shell config files will - override services.emacs.defaultEditor. To make sure - EDITOR refers to the Emacs wrapper script, remove any - existing EDITOR assignment from - .profile, .bashrc, - .zshenv or any other shell config file. - - - - If you have formed certain bad habits when editing files, these can be - corrected with a shell alias to the wrapper script: -alias vi=$EDITOR - -
- -
- Per-User Enabling of the Service - - - In general, systemd user services are globally enabled - by symlinks in /etc/systemd/user. In the case where - Emacs daemon is not wanted for all users, it is possible to install the - service but not globally enable it: - - = false; - = true; - - - - To enable the systemd user service for just the - currently logged in user, run: -systemctl --user enable emacs - This will add the symlink - ~/.config/systemd/user/emacs.service. - +
+
+ Configuring the <varname>EDITOR</varname> variable + + If is + true, the EDITOR variable + will be set to a wrapper script which launches + emacsclient. + + + Any setting of EDITOR in the shell config + files will override + services.emacs.defaultEditor. To make sure + EDITOR refers to the Emacs wrapper script, + remove any existing EDITOR assignment from + .profile, .bashrc, + .zshenv or any other shell config file. + + + If you have formed certain bad habits when editing files, these + can be corrected with a shell alias to the wrapper script: + + +alias vi=$EDITOR + +
+
+ Per-User Enabling of the Service + + In general, systemd user services are + globally enabled by symlinks in + /etc/systemd/user. In the case where Emacs + daemon is not wanted for all users, it is possible to install + the service but not globally enable it: + + +services.emacs.enable = false; +services.emacs.install = true; + + + To enable the systemd user service for just + the currently logged in user, run: + + +systemctl --user enable emacs + + + This will add the symlink + ~/.config/systemd/user/emacs.service. + +
-
-
- Configuring Emacs - - - The Emacs init file should be changed to load the extension packages at - startup: - - Package initialization in <filename>.emacs</filename> - + Configuring Emacs + + The Emacs init file should be changed to load the extension + packages at startup: + + + (require 'package) ;; optional. makes unpure packages archives unavailable @@ -489,92 +418,73 @@ emacsclient --create-frame --tty # opens a new frame on the current terminal (setq package-enable-at-startup nil) (package-initialize) -]]> - - - - - After the declarative emacs package configuration has been tested, - previously downloaded packages can be cleaned up by removing - ~/.emacs.d/elpa (do make a backup first, in case you - forgot a package). - - - - -
- A Major Mode for Nix Expressions - - - Of interest may be melpaPackages.nix-mode, which - provides syntax highlighting for the Nix language. This is particularly - convenient if you regularly edit Nix files. - -
- -
- Accessing man pages - - - You can use woman to get completion of all available - man pages. For example, type M-x woman <RET> nixos-rebuild - <RET>. - -
- -
- Editing DocBook 5 XML Documents - - - Emacs includes - nXML, - a major-mode for validating and editing XML documents. When editing DocBook - 5.0 documents, such as this one, - nXML needs to be configured with the relevant schema, which is not - included. - - - - To install the DocBook 5.0 schemas, either add - pkgs.docbook5 to - - (NixOS), or run - nix-env -f '<nixpkgs>' -iA docbook5 - (Nix). - - - - Then customize the variable rng-schema-locating-files to - include ~/.emacs.d/schemas.xml and put the following - text into that file: - - nXML Schema Configuration (<filename>~/.emacs.d/schemas.xml</filename>) - - - - - - - -]]> - - + --> + <namespace ns="http://docbook.org/ns/docbook" + uri="/run/current-system/sw/share/xml/docbook-5.0/rng/docbookxi.rnc"/> + <!-- + Use this variation if installing schema with "nix-env -iA pkgs.docbook5". + <namespace ns="http://docbook.org/ns/docbook" + uri="../.nix-profile/share/xml/docbook-5.0/rng/docbookxi.rnc"/> + --> +</locatingRules> + +
-
diff --git a/nixos/modules/services/hardware/trezord.md b/nixos/modules/services/hardware/trezord.md new file mode 100644 index 000000000000..58c244a44bc1 --- /dev/null +++ b/nixos/modules/services/hardware/trezord.md @@ -0,0 +1,17 @@ +# Trezor {#trezor} + +Trezor is an open-source cryptocurrency hardware wallet and security token +allowing secure storage of private keys. + +It offers advanced features such U2F two-factor authorization, SSH login +through +[Trezor SSH agent](https://wiki.trezor.io/Apps:SSH_agent), +[GPG](https://wiki.trezor.io/GPG) and a +[password manager](https://wiki.trezor.io/Trezor_Password_Manager). +For more information, guides and documentation, see . + +To enable Trezor support, add the following to your {file}`configuration.nix`: + + services.trezord.enable = true; + +This will add all necessary udev rules and start Trezor Bridge. diff --git a/nixos/modules/services/hardware/trezord.xml b/nixos/modules/services/hardware/trezord.xml index 972d409d9d0e..1ba9dc1f1887 100644 --- a/nixos/modules/services/hardware/trezord.xml +++ b/nixos/modules/services/hardware/trezord.xml @@ -1,26 +1,29 @@ - - Trezor - - Trezor is an open-source cryptocurrency hardware wallet and security token - allowing secure storage of private keys. - - - It offers advanced features such U2F two-factor authorization, SSH login - through - Trezor SSH agent, - GPG and a - password manager. - For more information, guides and documentation, see . - - - To enable Trezor support, add the following to your configuration.nix: - - = true; + + + Trezor + + Trezor is an open-source cryptocurrency hardware wallet and security + token allowing secure storage of private keys. + + + It offers advanced features such U2F two-factor authorization, SSH + login through + Trezor SSH + agent, + GPG and a + password + manager. For more information, guides and documentation, see + https://wiki.trezor.io. + + + To enable Trezor support, add the following to your + configuration.nix: + + +services.trezord.enable = true; - This will add all necessary udev rules and start Trezor Bridge. - + + This will add all necessary udev rules and start Trezor Bridge. + diff --git a/nixos/modules/services/mail/mailman.md b/nixos/modules/services/mail/mailman.md new file mode 100644 index 000000000000..55b61f8a2582 --- /dev/null +++ b/nixos/modules/services/mail/mailman.md @@ -0,0 +1,82 @@ +# Mailman {#module-services-mailman} + +[Mailman](https://www.list.org) is free +software for managing electronic mail discussion and e-newsletter +lists. Mailman and its web interface can be configured using the +corresponding NixOS module. Note that this service is best used with +an existing, securely configured Postfix setup, as it does not automatically configure this. + +## Basic usage with Postfix {#module-services-mailman-basic-usage} + +For a basic configuration with Postfix as the MTA, the following settings are suggested: +``` +{ config, ... }: { + services.postfix = { + enable = true; + 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"]; + }; + }; + services.mailman = { + enable = true; + serve.enable = true; + hyperkitty.enable = true; + webHosts = ["lists.example.org"]; + siteOwner = "mailman@example.org"; + }; + services.nginx.virtualHosts."lists.example.org".enableACME = true; + networking.firewall.allowedTCPPorts = [ 25 80 443 ]; +} +``` + +DNS records will also be required: + + - `AAAA` and `A` records pointing to the host in question, in order for browsers to be able to discover the address of the web server; + - An `MX` record pointing to a domain name at which the host is reachable, in order for other mail servers to be able to deliver emails to the mailing lists it hosts. + +After this has been done and appropriate DNS records have been +set up, the Postorius mailing list manager and the Hyperkitty +archive browser will be available at +https://lists.example.org/. Note that this setup is not +sufficient to deliver emails to most email providers nor to +avoid spam -- a number of additional measures for authenticating +incoming and outgoing mails, such as SPF, DMARC and DKIM are +necessary, but outside the scope of the Mailman module. + +## Using with other MTAs {#module-services-mailman-other-mtas} + +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: +``` +{ config, ... }: { + services = { + mailman = { + enable = true; + siteOwner = "mailman@example.org"; + enablePostfix = false; + settings.mta = { + incoming = "mailman.mta.exim4.LMTP"; + outgoing = "mailman.mta.deliver.deliver"; + lmtp_host = "localhost"; + lmtp_port = "8024"; + smtp_host = "localhost"; + smtp_port = "25"; + configuration = "python:mailman.config.exim4"; + }; + }; + exim = { + enable = true; + # You can configure Exim in a separate file to reduce configuration.nix clutter + config = builtins.readFile ./exim.conf; + }; + }; +} +``` + +The exim config needs some special additions to work with Mailman. Currently +NixOS can't manage Exim config with such granularity. Please refer to +[Mailman documentation](https://mailman.readthedocs.io/en/latest/src/mailman/docs/mta.html) +for more info on configuring Mailman for working with Exim. diff --git a/nixos/modules/services/mail/mailman.xml b/nixos/modules/services/mail/mailman.xml index 27247fb064f2..23b0d0b7da4c 100644 --- a/nixos/modules/services/mail/mailman.xml +++ b/nixos/modules/services/mail/mailman.xml @@ -1,79 +1,95 @@ - + + Mailman Mailman is free software for managing electronic mail discussion and e-newsletter lists. Mailman and its web interface can be configured using the corresponding NixOS module. Note that this service is best used with - an existing, securely configured Postfix setup, as it does not automatically configure this. + an existing, securely configured Postfix setup, as it does not + automatically configure this. -
Basic usage with Postfix - For a basic configuration with Postfix as the MTA, the following settings are suggested: - { config, ... }: { + For a basic configuration with Postfix as the MTA, the following + settings are suggested: + + +{ config, ... }: { services.postfix = { enable = true; - 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"; + 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"]; - siteOwner = "mailman@example.org"; + enable = true; + serve.enable = true; + hyperkitty.enable = true; + webHosts = ["lists.example.org"]; + siteOwner = "mailman@example.org"; }; - services.nginx.virtualHosts."lists.example.org".enableACME = true; - networking.firewall.allowedTCPPorts = [ 25 80 443 ]; -} - + services.nginx.virtualHosts."lists.example.org".enableACME = true; + networking.firewall.allowedTCPPorts = [ 25 80 443 ]; +} + DNS records will also be required: - - AAAA and A records pointing to the host in question, in order for browsers to be able to discover the address of the web server; - An MX record pointing to a domain name at which the host is reachable, in order for other mail servers to be able to deliver emails to the mailing lists it hosts. - + + + + AAAA and A records + pointing to the host in question, in order for browsers to be + able to discover the address of the web server; + + + + + An MX record pointing to a domain name at + which the host is reachable, in order for other mail servers + to be able to deliver emails to the mailing lists it hosts. + + + - After this has been done and appropriate DNS records have been - set up, the Postorius mailing list manager and the Hyperkitty - archive browser will be available at - https://lists.example.org/. Note that this setup is not - sufficient to deliver emails to most email providers nor to - avoid spam -- a number of additional measures for authenticating - incoming and outgoing mails, such as SPF, DMARC and DKIM are - necessary, but outside the scope of the Mailman module. + After this has been done and appropriate DNS records have been set + up, the Postorius mailing list manager and the Hyperkitty archive + browser will be available at https://lists.example.org/. Note that + this setup is not sufficient to deliver emails to most email + providers nor to avoid spam – a number of additional measures for + authenticating incoming and outgoing mails, such as SPF, DMARC and + DKIM are necessary, but outside the scope of the Mailman module.
Using with other MTAs - 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: - { config, ... }: { + 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: + + +{ config, ... }: { services = { mailman = { enable = true; - siteOwner = "mailman@example.org"; - enablePostfix = false; + siteOwner = "mailman@example.org"; + enablePostfix = false; settings.mta = { - incoming = "mailman.mta.exim4.LMTP"; - outgoing = "mailman.mta.deliver.deliver"; - lmtp_host = "localhost"; - lmtp_port = "8024"; - smtp_host = "localhost"; - smtp_port = "25"; - configuration = "python:mailman.config.exim4"; + incoming = "mailman.mta.exim4.LMTP"; + outgoing = "mailman.mta.deliver.deliver"; + lmtp_host = "localhost"; + lmtp_port = "8024"; + smtp_host = "localhost"; + smtp_port = "25"; + configuration = "python:mailman.config.exim4"; }; }; exim = { @@ -82,13 +98,15 @@ config = builtins.readFile ./exim.conf; }; }; -} - +} + - The exim config needs some special additions to work with Mailman. Currently - NixOS can't manage Exim config with such granularity. Please refer to - Mailman documentation - for more info on configuring Mailman for working with Exim. + The exim config needs some special additions to work with Mailman. + Currently NixOS can’t manage Exim config with such granularity. + Please refer to + Mailman + documentation for more info on configuring Mailman for + working with Exim.
diff --git a/nixos/modules/services/matrix/mjolnir.md b/nixos/modules/services/matrix/mjolnir.md new file mode 100644 index 000000000000..f6994eeb8fa5 --- /dev/null +++ b/nixos/modules/services/matrix/mjolnir.md @@ -0,0 +1,110 @@ +# Mjolnir (Matrix Moderation Tool) {#module-services-mjolnir} + +This chapter will show you how to set up your own, self-hosted +[Mjolnir](https://github.com/matrix-org/mjolnir) instance. + +As an all-in-one moderation tool, it can protect your server from +malicious invites, spam messages, and whatever else you don't want. +In addition to server-level protection, Mjolnir is great for communities +wanting to protect their rooms without having to use their personal +accounts for moderation. + +The bot by default includes support for bans, redactions, anti-spam, +server ACLs, room directory changes, room alias transfers, account +deactivation, room shutdown, and more. + +See the [README](https://github.com/matrix-org/mjolnir#readme) +page and the [Moderator's guide](https://github.com/matrix-org/mjolnir/blob/main/docs/moderators.md) +for additional instructions on how to setup and use Mjolnir. + +For [additional settings](#opt-services.mjolnir.settings) +see [the default configuration](https://github.com/matrix-org/mjolnir/blob/main/config/default.yaml). + +## Mjolnir Setup {#module-services-mjolnir-setup} + +First create a new Room which will be used as a management room for Mjolnir. In +this room, Mjolnir will log possible errors and debugging information. You'll +need to set this Room-ID in [services.mjolnir.managementRoom](#opt-services.mjolnir.managementRoom). + +Next, create a new user for Mjolnir on your homeserver, if not present already. + +The Mjolnir Matrix user expects to be free of any rate limiting. +See [Synapse #6286](https://github.com/matrix-org/synapse/issues/6286) +for an example on how to achieve this. + +If you want Mjolnir to be able to deactivate users, move room aliases, shutdown rooms, etc. +you'll need to make the Mjolnir user a Matrix server admin. + +Now invite the Mjolnir user to the management room. + +It is recommended to use [Pantalaimon](https://github.com/matrix-org/pantalaimon), +so your management room can be encrypted. This also applies if you are looking to moderate an encrypted room. + +To enable the Pantalaimon E2E Proxy for mjolnir, enable +[services.mjolnir.pantalaimon](#opt-services.mjolnir.pantalaimon.enable). This will +autoconfigure a new Pantalaimon instance, which will connect to the homeserver +set in [services.mjolnir.homeserverUrl](#opt-services.mjolnir.homeserverUrl) and Mjolnir itself +will be configured to connect to the new Pantalaimon instance. + +``` +{ + services.mjolnir = { + enable = true; + homeserverUrl = "https://matrix.domain.tld"; + pantalaimon = { + enable = true; + username = "mjolnir"; + passwordFile = "/run/secrets/mjolnir-password"; + }; + protectedRooms = [ + "https://matrix.to/#/!xxx:domain.tld" + ]; + managementRoom = "!yyy:domain.tld"; + }; +} +``` + +### Element Matrix Services (EMS) {#module-services-mjolnir-setup-ems} + +If you are using a managed ["Element Matrix Services (EMS)"](https://ems.element.io/) +server, you will need to consent to the terms and conditions. Upon startup, an error +log entry with a URL to the consent page will be generated. + +## Synapse Antispam Module {#module-services-mjolnir-matrix-synapse-antispam} + +A Synapse module is also available to apply the same rulesets the bot +uses across an entire homeserver. + +To use the Antispam Module, add `matrix-synapse-plugins.matrix-synapse-mjolnir-antispam` +to the Synapse plugin list and enable the `mjolnir.Module` module. + +``` +{ + services.matrix-synapse = { + plugins = with pkgs; [ + matrix-synapse-plugins.matrix-synapse-mjolnir-antispam + ]; + extraConfig = '' + modules: + - module: mjolnir.Module + config: + # Prevent servers/users in the ban lists from inviting users on this + # server to rooms. Default true. + block_invites: true + # Flag messages sent by servers/users in the ban lists as spam. Currently + # this means that spammy messages will appear as empty to users. Default + # false. + block_messages: false + # Remove users from the user directory search by filtering matrix IDs and + # display names by the entries in the user ban list. Default false. + block_usernames: false + # The room IDs of the ban lists to honour. Unlike other parts of Mjolnir, + # this list cannot be room aliases or permalinks. This server is expected + # to already be joined to the room - Mjolnir will not automatically join + # these rooms. + ban_lists: + - "!roomid:example.org" + ''; + }; +} +``` diff --git a/nixos/modules/services/matrix/mjolnir.xml b/nixos/modules/services/matrix/mjolnir.xml index b07abe339791..5bd2919e437c 100644 --- a/nixos/modules/services/matrix/mjolnir.xml +++ b/nixos/modules/services/matrix/mjolnir.xml @@ -1,106 +1,120 @@ - - Mjolnir (Matrix Moderation Tool) - - This chapter will show you how to set up your own, self-hosted - Mjolnir - instance. - - - As an all-in-one moderation tool, it can protect your server from - malicious invites, spam messages, and whatever else you don't want. - In addition to server-level protection, Mjolnir is great for communities - wanting to protect their rooms without having to use their personal - accounts for moderation. - - - The bot by default includes support for bans, redactions, anti-spam, - server ACLs, room directory changes, room alias transfers, account - deactivation, room shutdown, and more. - - - See the README - page and the Moderator's guide - for additional instructions on how to setup and use Mjolnir. - - - For additional settings - see the default configuration. - -
- Mjolnir Setup + + + Mjolnir (Matrix Moderation Tool) - First create a new Room which will be used as a management room for Mjolnir. In - this room, Mjolnir will log possible errors and debugging information. You'll - need to set this Room-ID in services.mjolnir.managementRoom. + This chapter will show you how to set up your own, self-hosted + Mjolnir + instance. - Next, create a new user for Mjolnir on your homeserver, if not present already. + As an all-in-one moderation tool, it can protect your server from + malicious invites, spam messages, and whatever else you don’t want. + In addition to server-level protection, Mjolnir is great for + communities wanting to protect their rooms without having to use + their personal accounts for moderation. - The Mjolnir Matrix user expects to be free of any rate limiting. - See Synapse #6286 - for an example on how to achieve this. + The bot by default includes support for bans, redactions, anti-spam, + server ACLs, room directory changes, room alias transfers, account + deactivation, room shutdown, and more. - If you want Mjolnir to be able to deactivate users, move room aliases, shutdown rooms, etc. - you'll need to make the Mjolnir user a Matrix server admin. + See the + README + page and the + Moderator’s + guide for additional instructions on how to setup and use + Mjolnir. - Now invite the Mjolnir user to the management room. + For additional + settings see + the + default configuration. - - It is recommended to use Pantalaimon, - so your management room can be encrypted. This also applies if you are looking to moderate an encrypted room. - - - To enable the Pantalaimon E2E Proxy for mjolnir, enable - services.mjolnir.pantalaimon. This will - autoconfigure a new Pantalaimon instance, which will connect to the homeserver - set in services.mjolnir.homeserverUrl and Mjolnir itself - will be configured to connect to the new Pantalaimon instance. - - +
+ Mjolnir Setup + + First create a new Room which will be used as a management room + for Mjolnir. In this room, Mjolnir will log possible errors and + debugging information. You’ll need to set this Room-ID in + services.mjolnir.managementRoom. + + + Next, create a new user for Mjolnir on your homeserver, if not + present already. + + + The Mjolnir Matrix user expects to be free of any rate limiting. + See + Synapse + #6286 for an example on how to achieve this. + + + If you want Mjolnir to be able to deactivate users, move room + aliases, shutdown rooms, etc. you’ll need to make the Mjolnir user + a Matrix server admin. + + + Now invite the Mjolnir user to the management room. + + + It is recommended to use + Pantalaimon, + so your management room can be encrypted. This also applies if you + are looking to moderate an encrypted room. + + + To enable the Pantalaimon E2E Proxy for mjolnir, enable + services.mjolnir.pantalaimon. + This will autoconfigure a new Pantalaimon instance, which will + connect to the homeserver set in + services.mjolnir.homeserverUrl + and Mjolnir itself will be configured to connect to the new + Pantalaimon instance. + + { services.mjolnir = { enable = true; - homeserverUrl = "https://matrix.domain.tld"; - pantalaimon = { - enable = true; - username = "mjolnir"; - passwordFile = "/run/secrets/mjolnir-password"; + homeserverUrl = "https://matrix.domain.tld"; + pantalaimon = { + 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"; + managementRoom = "!yyy:domain.tld"; }; } -
- Element Matrix Services (EMS) - - If you are using a managed "Element Matrix Services (EMS)" - server, you will need to consent to the terms and conditions. Upon startup, an error - log entry with a URL to the consent page will be generated. - -
-
- -
- Synapse Antispam Module - - A Synapse module is also available to apply the same rulesets the bot - uses across an entire homeserver. - - - To use the Antispam Module, add matrix-synapse-plugins.matrix-synapse-mjolnir-antispam - to the Synapse plugin list and enable the mjolnir.Module module. - - +
+ Element Matrix Services (EMS) + + If you are using a managed + Element Matrix + Services (EMS) server, you will need to consent + to the terms and conditions. Upon startup, an error log entry + with a URL to the consent page will be generated. + +
+
+
+ Synapse Antispam Module + + A Synapse module is also available to apply the same rulesets the + bot uses across an entire homeserver. + + + To use the Antispam Module, add + matrix-synapse-plugins.matrix-synapse-mjolnir-antispam + to the Synapse plugin list and enable the + mjolnir.Module module. + + { services.matrix-synapse = { plugins = with pkgs; [ @@ -125,10 +139,10 @@ # to already be joined to the room - Mjolnir will not automatically join # these rooms. ban_lists: - - "!roomid:example.org" + - "!roomid:example.org" ''; }; } -
+
diff --git a/nixos/modules/services/matrix/synapse.md b/nixos/modules/services/matrix/synapse.md new file mode 100644 index 000000000000..22f3bce64a40 --- /dev/null +++ b/nixos/modules/services/matrix/synapse.md @@ -0,0 +1,216 @@ +# Matrix {#module-services-matrix} + +[Matrix](https://matrix.org/) is an open standard for +interoperable, decentralised, real-time communication over IP. It can be used +to power Instant Messaging, VoIP/WebRTC signalling, Internet of Things +communication - or anywhere you need a standard HTTP API for publishing and +subscribing to data whilst tracking the conversation history. + +This chapter will show you how to set up your own, self-hosted Matrix +homeserver using the Synapse reference homeserver, and how to serve your own +copy of the Element web client. See the +[Try Matrix Now!](https://matrix.org/docs/projects/try-matrix-now.html) +overview page for links to Element Apps for Android and iOS, +desktop clients, as well as bridges to other networks and other projects +around Matrix. + +## Synapse Homeserver {#module-services-matrix-synapse} + +[Synapse](https://github.com/matrix-org/synapse) is +the reference homeserver implementation of Matrix from the core development +team at matrix.org. The following configuration example will set up a +synapse server for the `example.org` domain, served from +the host `myhostname.example.org`. For more information, +please refer to the +[installation instructions of Synapse](https://matrix-org.github.io/synapse/latest/setup/installation.html) . +``` +{ pkgs, lib, config, ... }: +let + fqdn = "${config.networking.hostName}.${config.networking.domain}"; + clientConfig = { + "m.homeserver".base_url = "https://${fqdn}"; + "m.identity_server" = {}; + }; + serverConfig."m.server" = "${config.services.matrix-synapse.settings.server_name}:443"; + mkWellKnown = data: '' + add_header Content-Type application/json; + add_header Access-Control-Allow-Origin *; + return 200 '${builtins.toJSON data}'; + ''; +in { + networking.hostName = "myhostname"; + networking.domain = "example.org"; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + + services.postgresql.enable = true; + services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" '' + CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse'; + CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" + TEMPLATE template0 + LC_COLLATE = "C" + LC_CTYPE = "C"; + ''; + + services.nginx = { + enable = true; + recommendedTlsSettings = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + recommendedProxySettings = true; + virtualHosts = { + # If the A and AAAA DNS records on example.org do not point on the same host as the + # records for myhostname.example.org, you can easily move the /.well-known + # virtualHost section of the code to the host that is serving example.org, while + # the rest stays on myhostname.example.org with no other changes required. + # This pattern also allows to seamlessly move the homeserver from + # myhostname.example.org to myotherhost.example.org by only changing the + # /.well-known redirection target. + "${config.networking.domain}" = { + enableACME = true; + forceSSL = true; + # This section is not needed if the server_name of matrix-synapse is equal to + # the domain (i.e. example.org from @foo:example.org) and the federation port + # is 8448. + # Further reference can be found in the docs about delegation under + # https://matrix-org.github.io/synapse/latest/delegate.html + locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig; + # This is usually needed for homeserver discovery (from e.g. other Matrix clients). + # Further reference can be found in the upstream docs at + # https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixclient + locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig; + }; + "${fqdn}" = { + enableACME = true; + forceSSL = true; + # It's also possible to do a redirect here or something else, this vhost is not + # needed for Matrix. It's recommended though to *not put* element + # here, see also the section about Element. + locations."/".extraConfig = '' + return 404; + ''; + # Forward all Matrix API calls to the synapse Matrix homeserver. A trailing slash + # *must not* be used here. + locations."/_matrix".proxyPass = "http://[::1]:8008"; + # Forward requests for e.g. SSO and password-resets. + locations."/_synapse/client".proxyPass = "http://[::1]:8008"; + }; + }; + }; + + services.matrix-synapse = { + enable = true; + settings.server_name = config.networking.domain; + settings.listeners = [ + { port = 8008; + bind_addresses = [ "::1" ]; + type = "http"; + tls = false; + x_forwarded = true; + resources = [ { + names = [ "client" "federation" ]; + compress = true; + } ]; + } + ]; + }; +} +``` + +## Registering Matrix users {#module-services-matrix-register-users} + +If you want to run a server with public registration by anybody, you can +then enable `services.matrix-synapse.settings.enable_registration = true;`. +Otherwise, or you can generate a registration secret with +{command}`pwgen -s 64 1` and set it with +[](#opt-services.matrix-synapse.settings.registration_shared_secret). +To create a new user or admin, run the following after you have set the secret +and have rebuilt NixOS: +```ShellSession +$ nix-shell -p matrix-synapse +$ register_new_matrix_user -k your-registration-shared-secret http://localhost:8008 +New user localpart: your-username +Password: +Confirm password: +Make admin [no]: +Success! +``` +In the example, this would create a user with the Matrix Identifier +`@your-username:example.org`. + +::: {.warning} +When using [](#opt-services.matrix-synapse.settings.registration_shared_secret), the secret +will end up in the world-readable store. Instead it's recommended to deploy the secret +in an additional file like this: + + - Create a file with the following contents: + + ``` + registration_shared_secret: your-very-secret-secret + ``` + - Deploy the file with a secret-manager such as + [{option}`deployment.keys`](https://nixops.readthedocs.io/en/latest/overview.html#managing-keys) + from {manpage}`nixops(1)` or [sops-nix](https://github.com/Mic92/sops-nix/) to + e.g. {file}`/run/secrets/matrix-shared-secret` and ensure that it's readable + by `matrix-synapse`. + - Include the file like this in your configuration: + + ``` + { + services.matrix-synapse.extraConfigFiles = [ + "/run/secrets/matrix-shared-secret" + ]; + } + ``` +::: + +::: {.note} +It's also possible to user alternative authentication mechanism such as +[LDAP (via `matrix-synapse-ldap3`)](https://github.com/matrix-org/matrix-synapse-ldap3) +or [OpenID](https://matrix-org.github.io/synapse/latest/openid.html). +::: + +## Element (formerly known as Riot) Web Client {#module-services-matrix-element-web} + +[Element Web](https://github.com/vector-im/riot-web/) is +the reference web client for Matrix and developed by the core team at +matrix.org. Element was formerly known as Riot.im, see the +[Element introductory blog post](https://element.io/blog/welcome-to-element/) +for more information. The following snippet can be optionally added to the code before +to complete the synapse installation with a web client served at +`https://element.myhostname.example.org` and +`https://element.example.org`. Alternatively, you can use the hosted +copy at , +or use other web clients or native client applications. Due to the +`/.well-known` urls set up done above, many clients should +fill in the required connection details automatically when you enter your +Matrix Identifier. See +[Try Matrix Now!](https://matrix.org/docs/projects/try-matrix-now.html) +for a list of existing clients and their supported featureset. +``` +{ + services.nginx.virtualHosts."element.${fqdn}" = { + enableACME = true; + forceSSL = true; + serverAliases = [ + "element.${config.networking.domain}" + ]; + + root = pkgs.element-web.override { + conf = { + default_server_config = clientConfig; # see `clientConfig` from the snippet above. + }; + }; + }; +} +``` + +::: {.note} +The Element developers do not recommend running Element and your Matrix +homeserver on the same fully-qualified domain name for security reasons. In +the example, this means that you should not reuse the +`myhostname.example.org` virtualHost to also serve Element, +but instead serve it on a different subdomain, like +`element.example.org` in the example. See the +[Element Important Security Notes](https://github.com/vector-im/element-web/tree/v1.10.0#important-security-notes) +for more information on this subject. +::: diff --git a/nixos/modules/services/matrix/synapse.xml b/nixos/modules/services/matrix/synapse.xml index 40ad72173a53..686aec93ab67 100644 --- a/nixos/modules/services/matrix/synapse.xml +++ b/nixos/modules/services/matrix/synapse.xml @@ -1,256 +1,243 @@ - - Matrix - - Matrix is an open standard for - interoperable, decentralised, real-time communication over IP. It can be used - to power Instant Messaging, VoIP/WebRTC signalling, Internet of Things - communication - or anywhere you need a standard HTTP API for publishing and - subscribing to data whilst tracking the conversation history. - - - This chapter will show you how to set up your own, self-hosted Matrix - homeserver using the Synapse reference homeserver, and how to serve your own - copy of the Element web client. See the - Try - Matrix Now! overview page for links to Element Apps for Android and iOS, - desktop clients, as well as bridges to other networks and other projects - around Matrix. - -
- Synapse Homeserver - + + + Matrix - Synapse is - the reference homeserver implementation of Matrix from the core development - team at matrix.org. The following configuration example will set up a - synapse server for the example.org domain, served from - the host myhostname.example.org. For more information, - please refer to the - - installation instructions of Synapse . - + Matrix is an open + standard for interoperable, decentralised, real-time communication + over IP. It can be used to power Instant Messaging, VoIP/WebRTC + signalling, Internet of Things communication - or anywhere you need + a standard HTTP API for publishing and subscribing to data whilst + tracking the conversation history. + + + This chapter will show you how to set up your own, self-hosted + Matrix homeserver using the Synapse reference homeserver, and how to + serve your own copy of the Element web client. See the + Try + Matrix Now! overview page for links to Element Apps for + Android and iOS, desktop clients, as well as bridges to other + networks and other projects around Matrix. + +
+ Synapse Homeserver + + Synapse + is the reference homeserver implementation of Matrix from the core + development team at matrix.org. The following configuration + example will set up a synapse server for the + example.org domain, served from the host + myhostname.example.org. For more information, + please refer to the + installation + instructions of Synapse . + + { pkgs, lib, config, ... }: let - fqdn = "${config.networking.hostName}.${config.networking.domain}"; + fqdn = "${config.networking.hostName}.${config.networking.domain}"; clientConfig = { - "m.homeserver".base_url = "https://${fqdn}"; - "m.identity_server" = {}; + "m.homeserver".base_url = "https://${fqdn}"; + "m.identity_server" = {}; }; - serverConfig."m.server" = "${config.services.matrix-synapse.settings.server_name}:443"; + serverConfig."m.server" = "${config.services.matrix-synapse.settings.server_name}:443"; mkWellKnown = data: '' add_header Content-Type application/json; add_header Access-Control-Allow-Origin *; return 200 '${builtins.toJSON data}'; ''; in { - = "myhostname"; - = "example.org"; - = [ 80 443 ]; + networking.hostName = "myhostname"; + networking.domain = "example.org"; + networking.firewall.allowedTCPPorts = [ 80 443 ]; - = true; - = pkgs.writeText "synapse-init.sql" '' - CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse'; - CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" + services.postgresql.enable = true; + services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" '' + CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse'; + CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" TEMPLATE template0 - LC_COLLATE = "C" - LC_CTYPE = "C"; + LC_COLLATE = "C" + LC_CTYPE = "C"; ''; services.nginx = { - enable = true; - recommendedTlsSettings = true; - recommendedOptimisation = true; - recommendedGzipSettings = true; - recommendedProxySettings = true; - virtualHosts = { - "${config.networking.domain}" = { - enableACME = true; - forceSSL = true; - locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig; - locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig; + enable = true; + recommendedTlsSettings = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + recommendedProxySettings = true; + virtualHosts = { + # If the A and AAAA DNS records on example.org do not point on the same host as the + # records for myhostname.example.org, you can easily move the /.well-known + # virtualHost section of the code to the host that is serving example.org, while + # the rest stays on myhostname.example.org with no other changes required. + # This pattern also allows to seamlessly move the homeserver from + # myhostname.example.org to myotherhost.example.org by only changing the + # /.well-known redirection target. + "${config.networking.domain}" = { + enableACME = true; + forceSSL = true; + # This section is not needed if the server_name of matrix-synapse is equal to + # the domain (i.e. example.org from @foo:example.org) and the federation port + # is 8448. + # Further reference can be found in the docs about delegation under + # https://matrix-org.github.io/synapse/latest/delegate.html + locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig; + # This is usually needed for homeserver discovery (from e.g. other Matrix clients). + # Further reference can be found in the upstream docs at + # https://spec.matrix.org/latest/client-server-api/#getwell-knownmatrixclient + locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig; }; - "${fqdn}" = { - enableACME = true; - forceSSL = true; - locations."/".extraConfig = '' + "${fqdn}" = { + enableACME = true; + forceSSL = true; + # It's also possible to do a redirect here or something else, this vhost is not + # needed for Matrix. It's recommended though to *not put* element + # here, see also the section about Element. + locations."/".extraConfig = '' return 404; ''; - locations."/_matrix".proxyPass = "http://[::1]:8008"; - locations."/_synapse/client".proxyPass = "http://[::1]:8008"; + # Forward all Matrix API calls to the synapse Matrix homeserver. A trailing slash + # *must not* be used here. + locations."/_matrix".proxyPass = "http://[::1]:8008"; + # Forward requests for e.g. SSO and password-resets. + locations."/_synapse/client".proxyPass = "http://[::1]:8008"; }; }; }; services.matrix-synapse = { - enable = true; - settings.server_name = config.networking.domain; - settings.listeners = [ - { port = 8008; - bind_addresses = [ "::1" ]; - type = "http"; - tls = false; - x_forwarded = true; - resources = [ { - names = [ "client" "federation" ]; - compress = true; + enable = true; + settings.server_name = config.networking.domain; + settings.listeners = [ + { port = 8008; + bind_addresses = [ "::1" ]; + type = "http"; + tls = false; + x_forwarded = true; + resources = [ { + names = [ "client" "federation" ]; + compress = true; } ]; } ]; }; } - - - +
+
+ Registering Matrix users - If the A and AAAA DNS records on - example.org do not point on the same host as the records - for myhostname.example.org, you can easily move the - /.well-known virtualHost section of the code to the host that - is serving example.org, while the rest stays on - myhostname.example.org with no other changes required. - This pattern also allows to seamlessly move the homeserver from - myhostname.example.org to - myotherhost.example.org by only changing the - /.well-known redirection target. + If you want to run a server with public registration by anybody, + you can then enable + services.matrix-synapse.settings.enable_registration = true;. + Otherwise, or you can generate a registration secret with + pwgen -s 64 1 and set it with + . + To create a new user or admin, run the following after you have + set the secret and have rebuilt NixOS: - - - - This section is not needed if the server_name - of matrix-synapse is equal to the domain (i.e. - example.org from @foo:example.org) - and the federation port is 8448. - Further reference can be found in the docs - about delegation. - - - - - This is usually needed for homeserver discovery (from e.g. other Matrix clients). - Further reference can be found in the upstream docs - - - - - It's also possible to do a redirect here or something else, this vhost is not - needed for Matrix. It's recommended though to not put element - here, see also the section about Element. - - - - - Forward all Matrix API calls to the synapse Matrix homeserver. A trailing slash - must not be used here. - - - - - Forward requests for e.g. SSO and password-resets. - - - -
-
- Registering Matrix users - - If you want to run a server with public registration by anybody, you can - then enable services.matrix-synapse.settings.enable_registration = - true;. Otherwise, or you can generate a registration secret with - pwgen -s 64 1 and set it with - . - To create a new user or admin, run the following after you have set the secret - and have rebuilt NixOS: - -$ nix-shell -p matrix-synapse -$ register_new_matrix_user -k your-registration-shared-secret http://localhost:8008 -New user localpart: your-username -Password: -Confirm password: -Make admin [no]: + +$ nix-shell -p matrix-synapse +$ register_new_matrix_user -k your-registration-shared-secret http://localhost:8008 +New user localpart: your-username +Password: +Confirm password: +Make admin [no]: Success! - - In the example, this would create a user with the Matrix Identifier - @your-username:example.org. - + - When using , the secret - will end up in the world-readable store. Instead it's recommended to deploy the secret - in an additional file like this: - - - - Create a file with the following contents: -registration_shared_secret: your-very-secret-secret - - - - - Deploy the file with a secret-manager such as - from nixops1 - or sops-nix to - e.g. /run/secrets/matrix-shared-secret and ensure that it's readable - by matrix-synapse. - - - - - Include the file like this in your configuration: - + In the example, this would create a user with the Matrix + Identifier @your-username:example.org. + + + + When using + , + the secret will end up in the world-readable store. Instead it’s + recommended to deploy the secret in an additional file like + this: + + + + + Create a file with the following contents: + + +registration_shared_secret: your-very-secret-secret + + + + + Deploy the file with a secret-manager such as + + from + nixops1 + or + sops-nix + to e.g. + /run/secrets/matrix-shared-secret and + ensure that it’s readable by + matrix-synapse. + + + + + Include the file like this in your configuration: + + { - = [ - "/run/secrets/matrix-shared-secret" + services.matrix-synapse.extraConfigFiles = [ + "/run/secrets/matrix-shared-secret" ]; } - - - + + + + + + It’s also possible to user alternative authentication mechanism + such as + LDAP + (via matrix-synapse-ldap3) or + OpenID. + + +
+
+ Element (formerly known as Riot) Web Client + + Element + Web is the reference web client for Matrix and developed by + the core team at matrix.org. Element was formerly known as + Riot.im, see the + Element + introductory blog post for more information. The following + snippet can be optionally added to the code before to complete the + synapse installation with a web client served at + https://element.myhostname.example.org and + https://element.example.org. Alternatively, you + can use the hosted copy at + https://app.element.io/, + or use other web clients or native client applications. Due to the + /.well-known urls set up done above, many + clients should fill in the required connection details + automatically when you enter your Matrix Identifier. See + Try + Matrix Now! for a list of existing clients and their + supported featureset. - - - - - It's also possible to user alternative authentication mechanism such as - LDAP (via matrix-synapse-ldap3) - or OpenID. - - -
-
- Element (formerly known as Riot) Web Client - - - Element Web is - the reference web client for Matrix and developed by the core team at - matrix.org. Element was formerly known as Riot.im, see the - Element introductory blog post - for more information. The following snippet can be optionally added to the code before - to complete the synapse installation with a web client served at - https://element.myhostname.example.org and - https://element.example.org. Alternatively, you can use the hosted - copy at https://app.element.io/, - or use other web clients or native client applications. Due to the - /.well-known urls set up done above, many clients should - fill in the required connection details automatically when you enter your - Matrix Identifier. See - Try - Matrix Now! for a list of existing clients and their supported - featureset. - + { - services.nginx.virtualHosts."element.${fqdn}" = { - enableACME = true; - forceSSL = true; - serverAliases = [ - "element.${config.networking.domain}" + services.nginx.virtualHosts."element.${fqdn}" = { + enableACME = true; + forceSSL = true; + serverAliases = [ + "element.${config.networking.domain}" ]; - root = pkgs.element-web.override { + root = pkgs.element-web.override { conf = { default_server_config = clientConfig; # see `clientConfig` from the snippet above. }; @@ -258,19 +245,19 @@ Success! }; } - - - - - The Element developers do not recommend running Element and your Matrix - homeserver on the same fully-qualified domain name for security reasons. In - the example, this means that you should not reuse the - myhostname.example.org virtualHost to also serve Element, - but instead serve it on a different subdomain, like - element.example.org in the example. See the - Element - Important Security Notes for more information on this subject. - - -
+ + + The Element developers do not recommend running Element and your + Matrix homeserver on the same fully-qualified domain name for + security reasons. In the example, this means that you should not + reuse the myhostname.example.org virtualHost + to also serve Element, but instead serve it on a different + subdomain, like element.example.org in the + example. See the + Element + Important Security Notes for more information on this + subject. + + +
diff --git a/nixos/modules/services/misc/gitlab.md b/nixos/modules/services/misc/gitlab.md new file mode 100644 index 000000000000..916b23584ed0 --- /dev/null +++ b/nixos/modules/services/misc/gitlab.md @@ -0,0 +1,112 @@ +# GitLab {#module-services-gitlab} + +GitLab is a feature-rich git hosting service. + +## Prerequisites {#module-services-gitlab-prerequisites} + +The `gitlab` service exposes only an Unix socket at +`/run/gitlab/gitlab-workhorse.socket`. You need to +configure a webserver to proxy HTTP requests to the socket. + +For instance, the following configuration could be used to use nginx as +frontend proxy: +``` +services.nginx = { + enable = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + virtualHosts."git.example.com" = { + enableACME = true; + forceSSL = true; + locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket"; + }; +}; +``` + +## Configuring {#module-services-gitlab-configuring} + +GitLab depends on both PostgreSQL and Redis and will automatically enable +both services. In the case of PostgreSQL, a database and a role will be +created. + +The default state dir is `/var/gitlab/state`. This is where +all data like the repositories and uploads will be stored. + +A basic configuration with some custom settings could look like this: +``` +services.gitlab = { + enable = true; + databasePasswordFile = "/var/keys/gitlab/db_password"; + initialRootPasswordFile = "/var/keys/gitlab/root_password"; + https = true; + host = "git.example.com"; + port = 443; + user = "git"; + group = "git"; + smtp = { + enable = true; + address = "localhost"; + port = 25; + }; + secrets = { + dbFile = "/var/keys/gitlab/db"; + secretFile = "/var/keys/gitlab/secret"; + otpFile = "/var/keys/gitlab/otp"; + jwsFile = "/var/keys/gitlab/jws"; + }; + extraConfig = { + gitlab = { + 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; }; + }; + }; +}; +``` + +If you're setting up a new GitLab instance, generate new +secrets. You for instance use +`tr -dc A-Za-z0-9 < /dev/urandom | head -c 128 > /var/keys/gitlab/db` to +generate a new db secret. Make sure the files can be read by, and +only by, the user specified by +[services.gitlab.user](#opt-services.gitlab.user). GitLab +encrypts sensitive data stored in the database. If you're restoring +an existing GitLab instance, you must specify the secrets secret +from `config/secrets.yml` located in your GitLab +state folder. + +When `incoming_mail.enabled` is set to `true` +in [extraConfig](#opt-services.gitlab.extraConfig) an additional +service called `gitlab-mailroom` is enabled for fetching incoming mail. + +Refer to [](#ch-options) for all available configuration +options for the [services.gitlab](#opt-services.gitlab.enable) module. + +## Maintenance {#module-services-gitlab-maintenance} + +### Backups {#module-services-gitlab-maintenance-backups} + +Backups can be configured with the options in +[services.gitlab.backup](#opt-services.gitlab.backup.keepTime). Use +the [services.gitlab.backup.startAt](#opt-services.gitlab.backup.startAt) +option to configure regular backups. + +To run a manual backup, start the `gitlab-backup` service: +```ShellSession +$ systemctl start gitlab-backup.service +``` + +### Rake tasks {#module-services-gitlab-maintenance-rake} + +You can run GitLab's rake tasks with `gitlab-rake` +which will be available on the system when GitLab is enabled. You +will have to run the command as the user that you configured to run +GitLab with. + +A list of all available rake tasks can be obtained by running: +```ShellSession +$ sudo -u git -H gitlab-rake -T +``` diff --git a/nixos/modules/services/misc/gitlab.xml b/nixos/modules/services/misc/gitlab.xml index 9816fdac7dd7..a193657b0b76 100644 --- a/nixos/modules/services/misc/gitlab.xml +++ b/nixos/modules/services/misc/gitlab.xml @@ -1,151 +1,143 @@ - - GitLab - - GitLab is a feature-rich git hosting service. - -
- Prerequisites - + + + GitLab - The gitlab service exposes only an Unix socket at - /run/gitlab/gitlab-workhorse.socket. You need to - configure a webserver to proxy HTTP requests to the socket. + GitLab is a feature-rich git hosting service. - - - For instance, the following configuration could be used to use nginx as - frontend proxy: - -services.nginx = { - enable = true; - recommendedGzipSettings = true; - recommendedOptimisation = true; - recommendedProxySettings = true; - recommendedTlsSettings = true; - virtualHosts."git.example.com" = { - enableACME = true; - forceSSL = true; - locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket"; +
+ Prerequisites + + The gitlab service exposes only an Unix socket + at /run/gitlab/gitlab-workhorse.socket. You + need to configure a webserver to proxy HTTP requests to the + socket. + + + For instance, the following configuration could be used to use + nginx as frontend proxy: + + +services.nginx = { + enable = true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + recommendedProxySettings = true; + recommendedTlsSettings = true; + virtualHosts."git.example.com" = { + enableACME = true; + forceSSL = true; + locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket"; }; }; - -
-
- Configuring - - - GitLab depends on both PostgreSQL and Redis and will automatically enable - both services. In the case of PostgreSQL, a database and a role will be - created. - - - - The default state dir is /var/gitlab/state. This is where - all data like the repositories and uploads will be stored. - - - - A basic configuration with some custom settings could look like this: - +
+
+ Configuring + + GitLab depends on both PostgreSQL and Redis and will automatically + enable both services. In the case of PostgreSQL, a database and a + role will be created. + + + The default state dir is /var/gitlab/state. + This is where all data like the repositories and uploads will be + stored. + + + A basic configuration with some custom settings could look like + this: + + services.gitlab = { - enable = true; - databasePasswordFile = "/var/keys/gitlab/db_password"; - initialRootPasswordFile = "/var/keys/gitlab/root_password"; - https = true; - host = "git.example.com"; - port = 443; - user = "git"; - group = "git"; + enable = true; + databasePasswordFile = "/var/keys/gitlab/db_password"; + initialRootPasswordFile = "/var/keys/gitlab/root_password"; + https = true; + host = "git.example.com"; + port = 443; + user = "git"; + group = "git"; smtp = { - enable = true; - address = "localhost"; - port = 25; + enable = true; + address = "localhost"; + port = 25; }; secrets = { - dbFile = "/var/keys/gitlab/db"; - secretFile = "/var/keys/gitlab/secret"; - otpFile = "/var/keys/gitlab/otp"; - jwsFile = "/var/keys/gitlab/jws"; + dbFile = "/var/keys/gitlab/db"; + secretFile = "/var/keys/gitlab/secret"; + otpFile = "/var/keys/gitlab/otp"; + jwsFile = "/var/keys/gitlab/jws"; }; - extraConfig = { + extraConfig = { gitlab = { - email_from = "gitlab-no-reply@example.com"; - email_display_name = "Example GitLab"; - email_reply_to = "gitlab-no-reply@example.com"; + 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; }; }; }; }; - - - - If you're setting up a new GitLab instance, generate new - secrets. You for instance use tr -dc A-Za-z0-9 < - /dev/urandom | head -c 128 > /var/keys/gitlab/db to - generate a new db secret. Make sure the files can be read by, and - only by, the user specified by services.gitlab.user. GitLab - encrypts sensitive data stored in the database. If you're restoring - an existing GitLab instance, you must specify the secrets secret - from config/secrets.yml located in your GitLab - state folder. - - - - When incoming_mail.enabled is set to true - in extraConfig an additional - service called gitlab-mailroom is enabled for fetching incoming mail. - - - - Refer to for all available configuration - options for the - services.gitlab module. - -
-
- Maintenance - -
- Backups - - Backups can be configured with the options in services.gitlab.backup. Use - the services.gitlab.backup.startAt - option to configure regular backups. - - - - To run a manual backup, start the gitlab-backup service: - -$ systemctl start gitlab-backup.service - - + + If you’re setting up a new GitLab instance, generate new secrets. + You for instance use + tr -dc A-Za-z0-9 < /dev/urandom | head -c 128 > /var/keys/gitlab/db + to generate a new db secret. Make sure the files can be read by, + and only by, the user specified by + services.gitlab.user. + GitLab encrypts sensitive data stored in the database. If you’re + restoring an existing GitLab instance, you must specify the + secrets secret from config/secrets.yml located + in your GitLab state folder. + + + When incoming_mail.enabled is set to + true in + extraConfig + an additional service called gitlab-mailroom is + enabled for fetching incoming mail. + + + Refer to for all available + configuration options for the + services.gitlab + module. +
- -
- Rake tasks - - - You can run GitLab's rake tasks with gitlab-rake - which will be available on the system when GitLab is enabled. You - will have to run the command as the user that you configured to run - GitLab with. - - - - A list of all available rake tasks can be obtained by running: - -$ sudo -u git -H gitlab-rake -T - - +
+ Maintenance +
+ Backups + + Backups can be configured with the options in + services.gitlab.backup. + Use the + services.gitlab.backup.startAt + option to configure regular backups. + + + To run a manual backup, start the + gitlab-backup service: + + +$ systemctl start gitlab-backup.service + +
+
+ Rake tasks + + You can run GitLab’s rake tasks with + gitlab-rake which will be available on the + system when GitLab is enabled. You will have to run the command + as the user that you configured to run GitLab with. + + + A list of all available rake tasks can be obtained by running: + + +$ sudo -u git -H gitlab-rake -T + +
-
diff --git a/nixos/modules/services/misc/sourcehut/default.md b/nixos/modules/services/misc/sourcehut/default.md new file mode 100644 index 000000000000..44d58aa0bef3 --- /dev/null +++ b/nixos/modules/services/misc/sourcehut/default.md @@ -0,0 +1,93 @@ +# Sourcehut {#module-services-sourcehut} + +[Sourcehut](https://sr.ht.com/) is an open-source, +self-hostable software development platform. The server setup can be automated using +[services.sourcehut](#opt-services.sourcehut.enable). + +## Basic usage {#module-services-sourcehut-basic-usage} + +Sourcehut is a Python and Go based set of applications. +This NixOS module also provides basic configuration integrating Sourcehut into locally running +`services.nginx`, `services.redis.servers.sourcehut`, `services.postfix` +and `services.postgresql` services. + +A very basic configuration may look like this: +``` +{ pkgs, ... }: +let + fqdn = + let + join = hostName: domain: hostName + optionalString (domain != null) ".${domain}"; + in join config.networking.hostName config.networking.domain; +in { + + networking = { + hostName = "srht"; + domain = "tld"; + firewall.allowedTCPPorts = [ 22 80 443 ]; + }; + + services.sourcehut = { + enable = true; + git.enable = true; + man.enable = true; + meta.enable = true; + nginx.enable = true; + postfix.enable = true; + postgresql.enable = true; + redis.enable = true; + settings = { + "sr.ht" = { + environment = "production"; + global-domain = fqdn; + origin = "https://${fqdn}"; + # Produce keys with srht-keygen from sourcehut.coresrht. + network-key = "/run/keys/path/to/network-key"; + service-key = "/run/keys/path/to/service-key"; + }; + webhooks.private-key= "/run/keys/path/to/webhook-key"; + }; + }; + + security.acme.certs."${fqdn}".extraDomainNames = [ + "meta.${fqdn}" + "man.${fqdn}" + "git.${fqdn}" + ]; + + services.nginx = { + enable = true; + # only recommendedProxySettings are strictly required, but the rest make sense as well. + recommendedTlsSettings = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + recommendedProxySettings = true; + + # Settings to setup what certificates are used for which endpoint. + virtualHosts = { + "${fqdn}".enableACME = true; + "meta.${fqdn}".useACMEHost = fqdn: + "man.${fqdn}".useACMEHost = fqdn: + "git.${fqdn}".useACMEHost = fqdn: + }; + }; +} +``` + + The `hostName` option is used internally to configure the nginx +reverse-proxy. The `settings` attribute set is +used by the configuration generator and the result is placed in `/etc/sr.ht/config.ini`. + +## Configuration {#module-services-sourcehut-configuration} + +All configuration parameters are also stored in +`/etc/sr.ht/config.ini` which is generated by +the module and linked from the store to ensure that all values from `config.ini` +can be modified by the module. + +## Using an alternative webserver as reverse-proxy (e.g. `httpd`) {#module-services-sourcehut-httpd} + +By default, `nginx` is used as reverse-proxy for `sourcehut`. +However, it's possible to use e.g. `httpd` by explicitly disabling +`nginx` using [](#opt-services.nginx.enable) and fixing the +`settings`. diff --git a/nixos/modules/services/misc/sourcehut/default.nix b/nixos/modules/services/misc/sourcehut/default.nix index 7dd254e34920..b03cf0739e9d 100644 --- a/nixos/modules/services/misc/sourcehut/default.nix +++ b/nixos/modules/services/misc/sourcehut/default.nix @@ -1390,6 +1390,6 @@ in '') ]; - meta.doc = ./sourcehut.xml; + meta.doc = ./default.xml; meta.maintainers = with maintainers; [ tomberek ]; } diff --git a/nixos/modules/services/misc/sourcehut/default.xml b/nixos/modules/services/misc/sourcehut/default.xml new file mode 100644 index 000000000000..1d8330931ddf --- /dev/null +++ b/nixos/modules/services/misc/sourcehut/default.xml @@ -0,0 +1,113 @@ + + + Sourcehut + + Sourcehut is an + open-source, self-hostable software development platform. The server + setup can be automated using + services.sourcehut. + +
+ Basic usage + + Sourcehut is a Python and Go based set of applications. This NixOS + module also provides basic configuration integrating Sourcehut + into locally running services.nginx, + services.redis.servers.sourcehut, + services.postfix and + services.postgresql services. + + + A very basic configuration may look like this: + + +{ pkgs, ... }: +let + fqdn = + let + join = hostName: domain: hostName + optionalString (domain != null) ".${domain}"; + in join config.networking.hostName config.networking.domain; +in { + + networking = { + hostName = "srht"; + domain = "tld"; + firewall.allowedTCPPorts = [ 22 80 443 ]; + }; + + services.sourcehut = { + enable = true; + git.enable = true; + man.enable = true; + meta.enable = true; + nginx.enable = true; + postfix.enable = true; + postgresql.enable = true; + redis.enable = true; + settings = { + "sr.ht" = { + environment = "production"; + global-domain = fqdn; + origin = "https://${fqdn}"; + # Produce keys with srht-keygen from sourcehut.coresrht. + network-key = "/run/keys/path/to/network-key"; + service-key = "/run/keys/path/to/service-key"; + }; + webhooks.private-key= "/run/keys/path/to/webhook-key"; + }; + }; + + security.acme.certs."${fqdn}".extraDomainNames = [ + "meta.${fqdn}" + "man.${fqdn}" + "git.${fqdn}" + ]; + + services.nginx = { + enable = true; + # only recommendedProxySettings are strictly required, but the rest make sense as well. + recommendedTlsSettings = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + recommendedProxySettings = true; + + # Settings to setup what certificates are used for which endpoint. + virtualHosts = { + "${fqdn}".enableACME = true; + "meta.${fqdn}".useACMEHost = fqdn: + "man.${fqdn}".useACMEHost = fqdn: + "git.${fqdn}".useACMEHost = fqdn: + }; + }; +} + + + The hostName option is used internally to + configure the nginx reverse-proxy. The settings + attribute set is used by the configuration generator and the + result is placed in /etc/sr.ht/config.ini. + +
+
+ Configuration + + All configuration parameters are also stored in + /etc/sr.ht/config.ini which is generated by the + module and linked from the store to ensure that all values from + config.ini can be modified by the module. + +
+
+ Using an alternative webserver as reverse-proxy (e.g. + <literal>httpd</literal>) + + By default, nginx is used as reverse-proxy for + sourcehut. However, it’s possible to use e.g. + httpd by explicitly disabling + nginx using + and fixing the + settings. + +
+
diff --git a/nixos/modules/services/misc/sourcehut/sourcehut.xml b/nixos/modules/services/misc/sourcehut/sourcehut.xml deleted file mode 100644 index 41094f65a94d..000000000000 --- a/nixos/modules/services/misc/sourcehut/sourcehut.xml +++ /dev/null @@ -1,119 +0,0 @@ - - Sourcehut - - Sourcehut is an open-source, - self-hostable software development platform. The server setup can be automated using - services.sourcehut. - - -
- Basic usage - - Sourcehut is a Python and Go based set of applications. - This NixOS module also provides basic configuration integrating Sourcehut into locally running - services.nginx, - services.redis.servers.sourcehut, - services.postfix - and - services.postgresql services. - - - - A very basic configuration may look like this: - -{ pkgs, ... }: -let - fqdn = - let - join = hostName: domain: hostName + optionalString (domain != null) ".${domain}"; - in join config.networking.hostName config.networking.domain; -in { - - networking = { - hostName = "srht"; - domain = "tld"; - firewall.allowedTCPPorts = [ 22 80 443 ]; - }; - - services.sourcehut = { - enable = true; - git.enable = true; - man.enable = true; - meta.enable = true; - nginx.enable = true; - postfix.enable = true; - postgresql.enable = true; - redis.enable = true; - settings = { - "sr.ht" = { - environment = "production"; - global-domain = fqdn; - origin = "https://${fqdn}"; - # Produce keys with srht-keygen from sourcehut.coresrht. - network-key = "/run/keys/path/to/network-key"; - service-key = "/run/keys/path/to/service-key"; - }; - webhooks.private-key= "/run/keys/path/to/webhook-key"; - }; - }; - - security.acme.certs."${fqdn}".extraDomainNames = [ - "meta.${fqdn}" - "man.${fqdn}" - "git.${fqdn}" - ]; - - services.nginx = { - enable = true; - # only recommendedProxySettings are strictly required, but the rest make sense as well. - recommendedTlsSettings = true; - recommendedOptimisation = true; - recommendedGzipSettings = true; - recommendedProxySettings = true; - - # Settings to setup what certificates are used for which endpoint. - virtualHosts = { - "${fqdn}".enableACME = true; - "meta.${fqdn}".useACMEHost = fqdn: - "man.${fqdn}".useACMEHost = fqdn: - "git.${fqdn}".useACMEHost = fqdn: - }; - }; -} - - - - - The hostName option is used internally to configure the nginx - reverse-proxy. The settings attribute set is - used by the configuration generator and the result is placed in /etc/sr.ht/config.ini. - -
- -
- Configuration - - - All configuration parameters are also stored in - /etc/sr.ht/config.ini which is generated by - the module and linked from the store to ensure that all values from config.ini - can be modified by the module. - - -
- -
- Using an alternative webserver as reverse-proxy (e.g. <literal>httpd</literal>) - - By default, nginx is used as reverse-proxy for sourcehut. - However, it's possible to use e.g. httpd by explicitly disabling - nginx using and fixing the - settings. - -
- -
diff --git a/nixos/modules/services/misc/taskserver/default.md b/nixos/modules/services/misc/taskserver/default.md new file mode 100644 index 000000000000..ee3b3908e2ae --- /dev/null +++ b/nixos/modules/services/misc/taskserver/default.md @@ -0,0 +1,93 @@ +# Taskserver {#module-services-taskserver} + +Taskserver is the server component of +[Taskwarrior](https://taskwarrior.org/), a free and +open source todo list application. + +*Upstream documentation:* + +## Configuration {#module-services-taskserver-configuration} + +Taskserver does all of its authentication via TLS using client certificates, +so you either need to roll your own CA or purchase a certificate from a +known CA, which allows creation of client certificates. These certificates +are usually advertised as "server certificates". + +So in order to make it easier to handle your own CA, there is a helper tool +called {command}`nixos-taskserver` which manages the custom CA along +with Taskserver organisations, users and groups. + +While the client certificates in Taskserver only authenticate whether a user +is allowed to connect, every user has its own UUID which identifies it as an +entity. + +With {command}`nixos-taskserver` the client certificate is created +along with the UUID of the user, so it handles all of the credentials needed +in order to setup the Taskwarrior client to work with a Taskserver. + +## The nixos-taskserver tool {#module-services-taskserver-nixos-taskserver-tool} + +Because Taskserver by default only provides scripts to setup users +imperatively, the {command}`nixos-taskserver` tool is used for +addition and deletion of organisations along with users and groups defined +by [](#opt-services.taskserver.organisations) and as well for +imperative set up. + +The tool is designed to not interfere if the command is used to manually set +up some organisations, users or groups. + +For example if you add a new organisation using {command}`nixos-taskserver +org add foo`, the organisation is not modified and deleted no +matter what you define in +{option}`services.taskserver.organisations`, even if you're adding +the same organisation in that option. + +The tool is modelled to imitate the official {command}`taskd` +command, documentation for each subcommand can be shown by using the +{option}`--help` switch. + +## Declarative/automatic CA management {#module-services-taskserver-declarative-ca-management} + +Everything is done according to what you specify in the module options, +however in order to set up a Taskwarrior client for synchronisation with a +Taskserver instance, you have to transfer the keys and certificates to the +client machine. + +This is done using {command}`nixos-taskserver user export $orgname +$username` which is printing a shell script fragment to stdout +which can either be used verbatim or adjusted to import the user on the +client machine. + +For example, let's say you have the following configuration: +```ShellSession +{ + services.taskserver.enable = true; + services.taskserver.fqdn = "server"; + services.taskserver.listenHost = "::"; + services.taskserver.organisations.my-company.users = [ "alice" ]; +} +``` +This creates an organisation called `my-company` with the +user `alice`. + +Now in order to import the `alice` user to another machine +`alicebox`, all we need to do is something like this: +```ShellSession +$ ssh server nixos-taskserver user export my-company alice | sh +``` +Of course, if no SSH daemon is available on the server you can also copy +& paste it directly into a shell. + +After this step the user should be set up and you can start synchronising +your tasks for the first time with {command}`task sync init` on +`alicebox`. + +Subsequent synchronisation requests merely require the command {command}`task +sync` after that stage. + +## Manual CA management {#module-services-taskserver-manual-ca-management} + +If you set any options within +[service.taskserver.pki.manual](#opt-services.taskserver.pki.manual.ca.cert).*, +{command}`nixos-taskserver` won't issue certificates, but you can +still use it for adding or removing user accounts. diff --git a/nixos/modules/services/misc/taskserver/default.nix b/nixos/modules/services/misc/taskserver/default.nix index ee4bf42183f9..7331c323adba 100644 --- a/nixos/modules/services/misc/taskserver/default.nix +++ b/nixos/modules/services/misc/taskserver/default.nix @@ -566,5 +566,5 @@ in { }) ]; - meta.doc = ./doc.xml; + meta.doc = ./default.xml; } diff --git a/nixos/modules/services/misc/taskserver/default.xml b/nixos/modules/services/misc/taskserver/default.xml new file mode 100644 index 000000000000..bbb38211b7ca --- /dev/null +++ b/nixos/modules/services/misc/taskserver/default.xml @@ -0,0 +1,130 @@ + + + Taskserver + + Taskserver is the server component of + Taskwarrior, a + free and open source todo list application. + + + Upstream documentation: + https://taskwarrior.org/docs/#taskd + +
+ Configuration + + Taskserver does all of its authentication via TLS using client + certificates, so you either need to roll your own CA or purchase a + certificate from a known CA, which allows creation of client + certificates. These certificates are usually advertised as + server certificates. + + + So in order to make it easier to handle your own CA, there is a + helper tool called nixos-taskserver which + manages the custom CA along with Taskserver organisations, users + and groups. + + + While the client certificates in Taskserver only authenticate + whether a user is allowed to connect, every user has its own UUID + which identifies it as an entity. + + + With nixos-taskserver the client certificate is + created along with the UUID of the user, so it handles all of the + credentials needed in order to setup the Taskwarrior client to + work with a Taskserver. + +
+
+ The nixos-taskserver tool + + Because Taskserver by default only provides scripts to setup users + imperatively, the nixos-taskserver tool is used + for addition and deletion of organisations along with users and + groups defined by + and as + well for imperative set up. + + + The tool is designed to not interfere if the command is used to + manually set up some organisations, users or groups. + + + For example if you add a new organisation using + nixos-taskserver org add foo, the organisation + is not modified and deleted no matter what you define in + , even if you’re + adding the same organisation in that option. + + + The tool is modelled to imitate the official + taskd command, documentation for each + subcommand can be shown by using the + switch. + +
+
+ Declarative/automatic CA management + + Everything is done according to what you specify in the module + options, however in order to set up a Taskwarrior client for + synchronisation with a Taskserver instance, you have to transfer + the keys and certificates to the client machine. + + + This is done using + nixos-taskserver user export $orgname $username + which is printing a shell script fragment to stdout which can + either be used verbatim or adjusted to import the user on the + client machine. + + + For example, let’s say you have the following configuration: + + +{ + services.taskserver.enable = true; + services.taskserver.fqdn = "server"; + services.taskserver.listenHost = "::"; + services.taskserver.organisations.my-company.users = [ "alice" ]; +} + + + This creates an organisation called my-company + with the user alice. + + + Now in order to import the alice user to + another machine alicebox, all we need to do is + something like this: + + +$ ssh server nixos-taskserver user export my-company alice | sh + + + Of course, if no SSH daemon is available on the server you can + also copy & paste it directly into a shell. + + + After this step the user should be set up and you can start + synchronising your tasks for the first time with + task sync init on alicebox. + + + Subsequent synchronisation requests merely require the command + task sync after that stage. + +
+
+ Manual CA management + + If you set any options within + service.taskserver.pki.manual.*, + nixos-taskserver won’t issue certificates, but + you can still use it for adding or removing user accounts. + +
+
diff --git a/nixos/modules/services/misc/taskserver/doc.xml b/nixos/modules/services/misc/taskserver/doc.xml deleted file mode 100644 index f6ead7c37857..000000000000 --- a/nixos/modules/services/misc/taskserver/doc.xml +++ /dev/null @@ -1,135 +0,0 @@ - - Taskserver - - Taskserver is the server component of - Taskwarrior, a free and - open source todo list application. - - - Upstream documentation: - - -
- Configuration - - - Taskserver does all of its authentication via TLS using client certificates, - so you either need to roll your own CA or purchase a certificate from a - known CA, which allows creation of client certificates. These certificates - are usually advertised as server certificates. - - - - So in order to make it easier to handle your own CA, there is a helper tool - called nixos-taskserver which manages the custom CA along - with Taskserver organisations, users and groups. - - - - While the client certificates in Taskserver only authenticate whether a user - is allowed to connect, every user has its own UUID which identifies it as an - entity. - - - - With nixos-taskserver the client certificate is created - along with the UUID of the user, so it handles all of the credentials needed - in order to setup the Taskwarrior client to work with a Taskserver. - -
-
- The nixos-taskserver tool - - - Because Taskserver by default only provides scripts to setup users - imperatively, the nixos-taskserver tool is used for - addition and deletion of organisations along with users and groups defined - by and as well for - imperative set up. - - - - The tool is designed to not interfere if the command is used to manually set - up some organisations, users or groups. - - - - For example if you add a new organisation using nixos-taskserver - org add foo, the organisation is not modified and deleted no - matter what you define in - , even if you're adding - the same organisation in that option. - - - - The tool is modelled to imitate the official taskd - command, documentation for each subcommand can be shown by using the - switch. - -
-
- Declarative/automatic CA management - - - Everything is done according to what you specify in the module options, - however in order to set up a Taskwarrior client for synchronisation with a - Taskserver instance, you have to transfer the keys and certificates to the - client machine. - - - - This is done using nixos-taskserver user export $orgname - $username which is printing a shell script fragment to stdout - which can either be used verbatim or adjusted to import the user on the - client machine. - - - - For example, let's say you have the following configuration: - -{ - = true; - = "server"; - = "::"; - services.taskserver.organisations.my-company.users = [ "alice" ]; -} - - This creates an organisation called my-company with the - user alice. - - - - Now in order to import the alice user to another machine - alicebox, all we need to do is something like this: - -$ ssh server nixos-taskserver user export my-company alice | sh - - Of course, if no SSH daemon is available on the server you can also copy - & paste it directly into a shell. - - - - After this step the user should be set up and you can start synchronising - your tasks for the first time with task sync init on - alicebox. - - - - Subsequent synchronisation requests merely require the command task - sync after that stage. - -
-
- Manual CA management - - - If you set any options within - service.taskserver.pki.manual.*, - nixos-taskserver won't issue certificates, but you can - still use it for adding or removing user accounts. - -
-
diff --git a/nixos/modules/services/misc/weechat.md b/nixos/modules/services/misc/weechat.md new file mode 100644 index 000000000000..21f41be5b4a0 --- /dev/null +++ b/nixos/modules/services/misc/weechat.md @@ -0,0 +1,46 @@ +# WeeChat {#module-services-weechat} + +[WeeChat](https://weechat.org/) is a fast and +extensible IRC client. + +## Basic Usage {#module-services-weechat-basic-usage} + +By default, the module creates a +[`systemd`](https://www.freedesktop.org/wiki/Software/systemd/) +unit which runs the chat client in a detached +[`screen`](https://www.gnu.org/software/screen/) +session. + +This can be done by enabling the `weechat` service: +``` +{ ... }: + +{ + services.weechat.enable = true; +} +``` + +The service is managed by a dedicated user named `weechat` +in the state directory `/var/lib/weechat`. + +## Re-attaching to WeeChat {#module-services-weechat-reattach} + +WeeChat runs in a screen session owned by a dedicated user. To explicitly +allow your another user to attach to this session, the +`screenrc` needs to be tweaked by adding +[multiuser](https://www.gnu.org/software/screen/manual/html_node/Multiuser.html#Multiuser) +support: +``` +{ + programs.screen.screenrc = '' + multiuser on + acladd normal_user + ''; +} +``` +Now, the session can be re-attached like this: +``` +screen -x weechat/weechat-screen +``` + +*The session name can be changed using [services.weechat.sessionName.](options.html#opt-services.weechat.sessionName)* diff --git a/nixos/modules/services/misc/weechat.xml b/nixos/modules/services/misc/weechat.xml index 7255edfb9da3..83ae171217d2 100644 --- a/nixos/modules/services/misc/weechat.xml +++ b/nixos/modules/services/misc/weechat.xml @@ -1,66 +1,63 @@ - - WeeChat - - WeeChat is a fast and - extensible IRC client. - -
- Basic Usage - + + + WeeChat - By default, the module creates a - systemd - unit which runs the chat client in a detached - screen - session. + WeeChat is a fast and + extensible IRC client. - - - This can be done by enabling the weechat service: - +
+ Basic Usage + + By default, the module creates a + systemd + unit which runs the chat client in a detached + screen + session. + + + This can be done by enabling the weechat + service: + + { ... }: { - services.weechat.enable = true; + services.weechat.enable = true; } - - - - The service is managed by a dedicated user named weechat - in the state directory /var/lib/weechat. - -
-
- Re-attaching to WeeChat - - - WeeChat runs in a screen session owned by a dedicated user. To explicitly - allow your another user to attach to this session, the - screenrc needs to be tweaked by adding - multiuser - support: - + + The service is managed by a dedicated user named + weechat in the state directory + /var/lib/weechat. + +
+
+ Re-attaching to WeeChat + + WeeChat runs in a screen session owned by a dedicated user. To + explicitly allow your another user to attach to this session, the + screenrc needs to be tweaked by adding + multiuser + support: + + { - programs.screen.screenrc = '' + programs.screen.screenrc = '' multiuser on acladd normal_user ''; } - Now, the session can be re-attached like this: - + + Now, the session can be re-attached like this: + + screen -x weechat/weechat-screen - - - - The session name can be changed using - services.weechat.sessionName. - -
+ + The session name can be changed using + services.weechat.sessionName. + +
diff --git a/nixos/modules/services/monitoring/parsedmarc.md b/nixos/modules/services/monitoring/parsedmarc.md index 5a17f79da5d4..eac07e0cc9fe 100644 --- a/nixos/modules/services/monitoring/parsedmarc.md +++ b/nixos/modules/services/monitoring/parsedmarc.md @@ -25,7 +25,7 @@ services.parsedmarc = { Note that GeoIP provisioning is disabled in the example for simplicity, but should be turned on for fully functional reports. -## Local mail +## Local mail {#module-services-parsedmarc-local-mail} Instead of watching an external inbox, a local inbox can be automatically provisioned. The recipient's name is by default set to `dmarc`, but can be configured in @@ -49,7 +49,7 @@ services.parsedmarc = { }; ``` -## Grafana and GeoIP +## Grafana and GeoIP {#module-services-parsedmarc-grafana-geoip} The reports can be visualized and summarized with parsedmarc's official Grafana dashboard. For all views to work, and for the data to be complete, GeoIP databases are also required. The following example diff --git a/nixos/modules/services/monitoring/parsedmarc.nix b/nixos/modules/services/monitoring/parsedmarc.nix index 40c76b804559..2e7c4fd00b42 100644 --- a/nixos/modules/services/monitoring/parsedmarc.nix +++ b/nixos/modules/services/monitoring/parsedmarc.nix @@ -539,8 +539,6 @@ in }; }; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc parsedmarc.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > parsedmarc.xml` meta.doc = ./parsedmarc.xml; meta.maintainers = [ lib.maintainers.talyz ]; } diff --git a/nixos/modules/services/monitoring/parsedmarc.xml b/nixos/modules/services/monitoring/parsedmarc.xml index b6a4bcf8ff5a..4d9b12c9a429 100644 --- a/nixos/modules/services/monitoring/parsedmarc.xml +++ b/nixos/modules/services/monitoring/parsedmarc.xml @@ -1,3 +1,5 @@ + parsedmarc @@ -15,7 +17,7 @@ email address and saves them to a local Elasticsearch instance looks like this: - + services.parsedmarc = { enable = true; settings.imap = { @@ -31,7 +33,7 @@ services.parsedmarc = { simplicity, but should be turned on for fully functional reports.
-
+
Local mail Instead of watching an external inbox, a local inbox can be @@ -44,7 +46,7 @@ services.parsedmarc = { email address that should be configured in the domain’s dmarc policy is dmarc@monitoring.example.com. - + services.parsedmarc = { enable = true; provision = { @@ -57,7 +59,7 @@ services.parsedmarc = { };
-
+
Grafana and GeoIP The reports can be visualized and summarized with parsedmarc’s @@ -67,7 +69,7 @@ services.parsedmarc = { Elasticsearch instance is automatically added as a Grafana datasource, and the dashboard is added to Grafana as well. - + services.parsedmarc = { enable = true; provision = { diff --git a/nixos/modules/services/monitoring/prometheus/exporters.md b/nixos/modules/services/monitoring/prometheus/exporters.md new file mode 100644 index 000000000000..c085e46d20d7 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters.md @@ -0,0 +1,180 @@ +# Prometheus exporters {#module-services-prometheus-exporters} + +Prometheus exporters provide metrics for the +[prometheus monitoring system](https://prometheus.io). + +## Configuration {#module-services-prometheus-exporters-configuration} + +One of the most common exporters is the +[node exporter](https://github.com/prometheus/node_exporter), +it provides hardware and OS metrics from the host it's +running on. The exporter could be configured as follows: +``` + services.prometheus.exporters.node = { + enable = true; + port = 9100; + enabledCollectors = [ + "logind" + "systemd" + ]; + disabledCollectors = [ + "textfile" + ]; + openFirewall = true; + firewallFilter = "-i br0 -p tcp -m tcp --dport 9100"; + }; +``` +It should now serve all metrics from the collectors that are explicitly +enabled and the ones that are +[enabled by default](https://github.com/prometheus/node_exporter#enabled-by-default), +via http under `/metrics`. In this +example the firewall should just allow incoming connections to the +exporter's port on the bridge interface `br0` (this would +have to be configured separately of course). For more information about +configuration see `man configuration.nix` or search through +the [available options](https://nixos.org/nixos/options.html#prometheus.exporters). + +Prometheus can now be configured to consume the metrics produced by the exporter: +``` + services.prometheus = { + # ... + + scrapeConfigs = [ + { + job_name = "node"; + static_configs = [{ + targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; + }]; + } + ]; + + # ... + } +``` + +## Adding a new exporter {#module-services-prometheus-exporters-new-exporter} + +To add a new exporter, it has to be packaged first (see +`nixpkgs/pkgs/servers/monitoring/prometheus/` for +examples), then a module can be added. The postfix exporter is used in this +example: + + - Some default options for all exporters are provided by + `nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix`: + + - `enable` + - `port` + - `listenAddress` + - `extraFlags` + - `openFirewall` + - `firewallFilter` + - `user` + - `group` + - As there is already a package available, the module can now be added. This + is accomplished by adding a new file to the + `nixos/modules/services/monitoring/prometheus/exporters/` + directory, which will be called postfix.nix and contains all exporter + specific options and configuration: + ``` + # nixpgs/nixos/modules/services/prometheus/exporters/postfix.nix + { config, lib, pkgs, options }: + + with lib; + + let + # for convenience we define cfg here + cfg = config.services.prometheus.exporters.postfix; + in + { + port = 9154; # The postfix exporter listens on this port by default + + # `extraOpts` is an attribute set which contains additional options + # (and optional overrides for default options). + # Note that this attribute is optional. + extraOpts = { + telemetryPath = mkOption { + type = types.str; + default = "/metrics"; + description = '' + Path under which to expose metrics. + ''; + }; + logfilePath = mkOption { + type = types.path; + default = /var/log/postfix_exporter_input.log; + example = /var/log/mail.log; + description = '' + Path where Postfix writes log entries. + This file will be truncated by this exporter! + ''; + }; + showqPath = mkOption { + type = types.path; + default = /var/spool/postfix/public/showq; + example = /var/lib/postfix/queue/public/showq; + description = '' + Path at which Postfix places its showq socket. + ''; + }; + }; + + # `serviceOpts` is an attribute set which contains configuration + # for the exporter's systemd service. One of + # `serviceOpts.script` and `serviceOpts.serviceConfig.ExecStart` + # has to be specified here. This will be merged with the default + # service configuration. + # Note that by default 'DynamicUser' is 'true'. + serviceOpts = { + serviceConfig = { + DynamicUser = false; + ExecStart = '' + ${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \ + --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ + --web.telemetry-path ${cfg.telemetryPath} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + }; + }; + } + ``` + - This should already be enough for the postfix exporter. Additionally one + could now add assertions and conditional default values. This can be done + in the 'meta-module' that combines all exporter definitions and generates + the submodules: + `nixpkgs/nixos/modules/services/prometheus/exporters.nix` + +## Updating an exporter module {#module-services-prometheus-exporters-update-exporter-module} + +Should an exporter option change at some point, it is possible to add +information about the change to the exporter definition similar to +`nixpkgs/nixos/modules/rename.nix`: +``` +{ config, lib, pkgs, options }: + +with lib; + +let + cfg = config.services.prometheus.exporters.nginx; +in +{ + port = 9113; + extraOpts = { + # additional module options + # ... + }; + serviceOpts = { + # service configuration + # ... + }; + imports = [ + # 'services.prometheus.exporters.nginx.telemetryEndpoint' -> 'services.prometheus.exporters.nginx.telemetryPath' + (mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ]) + + # removed option 'services.prometheus.exporters.nginx.insecure' + (mkRemovedOptionModule [ "insecure" ] '' + This option was replaced by 'prometheus.exporters.nginx.sslVerify' which defaults to true. + '') + ({ options.warnings = options.warnings; }) + ]; +} +``` diff --git a/nixos/modules/services/monitoring/prometheus/exporters.xml b/nixos/modules/services/monitoring/prometheus/exporters.xml index e922e1ace8d0..0ea95e513ff3 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.xml +++ b/nixos/modules/services/monitoring/prometheus/exporters.xml @@ -1,138 +1,135 @@ - - Prometheus exporters - - Prometheus exporters provide metrics for the - prometheus monitoring system. - -
- Configuration - + + + Prometheus exporters - One of the most common exporters is the - node - exporter, it provides hardware and OS metrics from the host it's - running on. The exporter could be configured as follows: - + Prometheus exporters provide metrics for the + prometheus monitoring + system. + +
+ Configuration + + One of the most common exporters is the + node + exporter, it provides hardware and OS metrics from the host + it’s running on. The exporter could be configured as follows: + + services.prometheus.exporters.node = { enable = true; port = 9100; enabledCollectors = [ - "logind" - "systemd" + "logind" + "systemd" ]; disabledCollectors = [ - "textfile" + "textfile" ]; openFirewall = true; - firewallFilter = "-i br0 -p tcp -m tcp --dport 9100"; + firewallFilter = "-i br0 -p tcp -m tcp --dport 9100"; }; - It should now serve all metrics from the collectors that are explicitly - enabled and the ones that are - enabled - by default, via http under /metrics. In this - example the firewall should just allow incoming connections to the - exporter's port on the bridge interface br0 (this would - have to be configured separately of course). For more information about - configuration see man configuration.nix or search through - the - available - options. - - - - Prometheus can now be configured to consume the metrics produced by the exporter: + + It should now serve all metrics from the collectors that are + explicitly enabled and the ones that are + enabled + by default, via http under /metrics. In + this example the firewall should just allow incoming connections + to the exporter’s port on the bridge interface + br0 (this would have to be configured + separately of course). For more information about configuration + see man configuration.nix or search through the + available + options. + + + Prometheus can now be configured to consume the metrics produced + by the exporter: + services.prometheus = { # ... scrapeConfigs = [ { - job_name = "node"; + job_name = "node"; static_configs = [{ - targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; + targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; }]; } ]; # ... } - - -
-
- Adding a new exporter - - - To add a new exporter, it has to be packaged first (see - nixpkgs/pkgs/servers/monitoring/prometheus/ for - examples), then a module can be added. The postfix exporter is used in this - example: - - - - + +
+
+ Adding a new exporter - Some default options for all exporters are provided by - nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix: + To add a new exporter, it has to be packaged first (see + nixpkgs/pkgs/servers/monitoring/prometheus/ for + examples), then a module can be added. The postfix exporter is + used in this example: - - - - - enable - - - - - port - - - - - listenAddress - - - - - extraFlags - - - - - openFirewall - - - - - firewallFilter - - - - - user - - - - - group - - - - - - - As there is already a package available, the module can now be added. This - is accomplished by adding a new file to the - nixos/modules/services/monitoring/prometheus/exporters/ - directory, which will be called postfix.nix and contains all exporter - specific options and configuration: - + + + Some default options for all exporters are provided by + nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix: + + + + + enable + + + + + port + + + + + listenAddress + + + + + extraFlags + + + + + openFirewall + + + + + firewallFilter + + + + + user + + + + + group + + + + + + + As there is already a package available, the module can now be + added. This is accomplished by adding a new file to the + nixos/modules/services/monitoring/prometheus/exporters/ + directory, which will be called postfix.nix and contains all + exporter specific options and configuration: + + # nixpgs/nixos/modules/services/prometheus/exporters/postfix.nix { config, lib, pkgs, options }: @@ -151,7 +148,7 @@ in extraOpts = { telemetryPath = mkOption { type = types.str; - default = "/metrics"; + default = "/metrics"; description = '' Path under which to expose metrics. ''; @@ -188,32 +185,33 @@ in ${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ --web.telemetry-path ${cfg.telemetryPath} \ - ${concatStringsSep " \\\n " cfg.extraFlags} + ${concatStringsSep " \\\n " cfg.extraFlags} ''; }; }; } - - - + + + + This should already be enough for the postfix exporter. + Additionally one could now add assertions and conditional + default values. This can be done in the + meta-module that combines all exporter + definitions and generates the submodules: + nixpkgs/nixos/modules/services/prometheus/exporters.nix + + + +
+
+ Updating an exporter module - This should already be enough for the postfix exporter. Additionally one - could now add assertions and conditional default values. This can be done - in the 'meta-module' that combines all exporter definitions and generates - the submodules: - nixpkgs/nixos/modules/services/prometheus/exporters.nix + Should an exporter option change at some point, it is possible to + add information about the change to the exporter definition + similar to nixpkgs/nixos/modules/rename.nix: - - -
-
- Updating an exporter module - - Should an exporter option change at some point, it is possible to add - information about the change to the exporter definition similar to - nixpkgs/nixos/modules/rename.nix: - + { config, lib, pkgs, options }: with lib; @@ -232,17 +230,16 @@ in # ... }; imports = [ - # 'services.prometheus.exporters.nginx.telemetryEndpoint' -> 'services.prometheus.exporters.nginx.telemetryPath' - (mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ]) + # 'services.prometheus.exporters.nginx.telemetryEndpoint' -> 'services.prometheus.exporters.nginx.telemetryPath' + (mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ]) # removed option 'services.prometheus.exporters.nginx.insecure' - (mkRemovedOptionModule [ "insecure" ] '' + (mkRemovedOptionModule [ "insecure" ] '' This option was replaced by 'prometheus.exporters.nginx.sslVerify' which defaults to true. '') ({ options.warnings = options.warnings; }) ]; } -
diff --git a/nixos/modules/services/network-filesystems/litestream/litestream.xml b/nixos/modules/services/network-filesystems/litestream/default.md similarity index 51% rename from nixos/modules/services/network-filesystems/litestream/litestream.xml rename to nixos/modules/services/network-filesystems/litestream/default.md index 8f5597bb6891..8d8486507b77 100644 --- a/nixos/modules/services/network-filesystems/litestream/litestream.xml +++ b/nixos/modules/services/network-filesystems/litestream/default.md @@ -1,23 +1,14 @@ - - Litestream - - Litestream is a standalone streaming - replication tool for SQLite. - +# Litestream {#module-services-litestream} -
- Configuration +[Litestream](https://litestream.io/) is a standalone streaming +replication tool for SQLite. - - Litestream service is managed by a dedicated user named litestream - which needs permission to the database file. Here's an example config which gives - required permissions to access - grafana database: - +## Configuration {#module-services-litestream-configuration} + +Litestream service is managed by a dedicated user named `litestream` +which needs permission to the database file. Here's an example config which gives +required permissions to access [grafana database](#opt-services.grafana.settings.database.path): +``` { pkgs, ... }: { users.users.litestream.extraGroups = [ "grafana" ]; @@ -58,8 +49,4 @@ }; }; } - - -
- -
+``` diff --git a/nixos/modules/services/network-filesystems/litestream/default.nix b/nixos/modules/services/network-filesystems/litestream/default.nix index 884ffa50e7c6..0d987f12a324 100644 --- a/nixos/modules/services/network-filesystems/litestream/default.nix +++ b/nixos/modules/services/network-filesystems/litestream/default.nix @@ -94,5 +94,6 @@ in }; users.groups.litestream = {}; }; - meta.doc = ./litestream.xml; + + meta.doc = ./default.xml; } diff --git a/nixos/modules/services/network-filesystems/litestream/default.xml b/nixos/modules/services/network-filesystems/litestream/default.xml new file mode 100644 index 000000000000..756899fdb88d --- /dev/null +++ b/nixos/modules/services/network-filesystems/litestream/default.xml @@ -0,0 +1,62 @@ + + + Litestream + + Litestream is a + standalone streaming replication tool for SQLite. + +
+ Configuration + + Litestream service is managed by a dedicated user named + litestream which needs permission to the + database file. Here’s an example config which gives required + permissions to access + grafana + database: + + +{ pkgs, ... }: +{ + users.users.litestream.extraGroups = [ "grafana" ]; + + 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 + + sleep 1 + + ((timeout--)) + done + + find /var/lib/grafana -type d -exec chmod -v 775 {} \; + find /var/lib/grafana -type f -exec chmod -v 660 {} \; + ''; + + services.litestream = { + enable = true; + + environmentFile = "/run/secrets/litestream"; + + settings = { + dbs = [ + { + path = "/var/lib/grafana/data/grafana.db"; + replicas = [{ + url = "s3://mybkt.litestream.io/grafana"; + }]; + } + ]; + }; + }; +} + +
+
diff --git a/nixos/modules/services/networking/firefox-syncserver.nix b/nixos/modules/services/networking/firefox-syncserver.nix index 9733fb16d903..c26a6ae265ff 100644 --- a/nixos/modules/services/networking/firefox-syncserver.nix +++ b/nixos/modules/services/networking/firefox-syncserver.nix @@ -311,8 +311,6 @@ in meta = { maintainers = with lib.maintainers; [ pennae ]; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc firefox-syncserver.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > firefox-syncserver.xml` doc = ./firefox-syncserver.xml; }; } diff --git a/nixos/modules/services/networking/firefox-syncserver.xml b/nixos/modules/services/networking/firefox-syncserver.xml index 66c812266951..440922cbba00 100644 --- a/nixos/modules/services/networking/firefox-syncserver.xml +++ b/nixos/modules/services/networking/firefox-syncserver.xml @@ -1,3 +1,5 @@ + Firefox Sync server diff --git a/nixos/modules/services/networking/mosquitto.nix b/nixos/modules/services/networking/mosquitto.nix index 270450cb0c62..563412025561 100644 --- a/nixos/modules/services/networking/mosquitto.nix +++ b/nixos/modules/services/networking/mosquitto.nix @@ -671,8 +671,6 @@ in meta = { maintainers = with lib.maintainers; [ pennae ]; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc mosquitto.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > mosquitto.xml` doc = ./mosquitto.xml; }; } diff --git a/nixos/modules/services/networking/mosquitto.xml b/nixos/modules/services/networking/mosquitto.xml index d16ab28c0269..91934617c56d 100644 --- a/nixos/modules/services/networking/mosquitto.xml +++ b/nixos/modules/services/networking/mosquitto.xml @@ -1,3 +1,5 @@ + Mosquitto @@ -9,7 +11,7 @@ A minimal configuration for Mosquitto is - + services.mosquitto = { enable = true; listeners = [ { @@ -31,7 +33,7 @@ services.mosquitto = { restricted write access to a user service could look like - + services.mosquitto = { enable = true; listeners = [ { @@ -52,7 +54,7 @@ services.mosquitto = { TLS authentication is configured by setting TLS-related options of the listener: - + services.mosquitto = { enable = true; listeners = [ { diff --git a/nixos/modules/services/networking/pleroma.md b/nixos/modules/services/networking/pleroma.md new file mode 100644 index 000000000000..7c499e1c616c --- /dev/null +++ b/nixos/modules/services/networking/pleroma.md @@ -0,0 +1,180 @@ +# Pleroma {#module-services-pleroma} + +[Pleroma](https://pleroma.social/) is a lightweight activity pub server. + +## Generating the Pleroma config {#module-services-pleroma-generate-config} + +The `pleroma_ctl` CLI utility will prompt you some questions and it will generate an initial config file. This is an example of usage +```ShellSession +$ mkdir tmp-pleroma +$ cd tmp-pleroma +$ nix-shell -p pleroma-otp +$ pleroma_ctl instance gen --output config.exs --output-psql setup.psql +``` + +The `config.exs` file can be further customized following the instructions on the [upstream documentation](https://docs-develop.pleroma.social/backend/configuration/cheatsheet/). Many refinements can be applied also after the service is running. + +## Initializing the database {#module-services-pleroma-initialize-db} + +First, the Postgresql service must be enabled in the NixOS configuration +``` +services.postgresql = { + enable = true; + package = pkgs.postgresql_13; +}; +``` +and activated with the usual +```ShellSession +$ nixos-rebuild switch +``` + +Then you can create and seed the database, using the `setup.psql` file that you generated in the previous section, by running +```ShellSession +$ sudo -u postgres psql -f setup.psql +``` + +## Enabling the Pleroma service locally {#module-services-pleroma-enable} + +In this section we will enable the Pleroma service only locally, so its configurations can be improved incrementally. + +This 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. +``` +services.pleroma = { + enable = true; + secretConfigFile = "/var/lib/pleroma/secrets.exs"; + configs = [ + '' + 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, :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, 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" + + # ... TO CONTINUE ... + '' + ]; +}; +``` + +Secrets must be moved into a file pointed by [](#opt-services.pleroma.secretConfigFile), in our case `/var/lib/pleroma/secrets.exs`. This file can be created copying the previously generated `config.exs` file and then removing all the settings, except the secrets. This is an example +``` +# Pleroma instance passwords + +import Config + +config :pleroma, Pleroma.Web.Endpoint, + secret_key_base: "", + signing_salt: "" + +config :pleroma, Pleroma.Repo, + password: "" + +# Configure web push notifications +config :web_push_encryption, :vapid_details, + public_key: "", + private_key: "" + +# ... TO CONTINUE ... +``` +Note that the lines of the same configuration group are comma separated (i.e. all the lines end with a comma, except the last one), so when the lines with passwords are added or removed, commas must be adjusted accordingly. + +The service can be enabled with the usual +```ShellSession +$ nixos-rebuild switch +``` + +The service is accessible only from the local `127.0.0.1:4000` port. It can be tested using a port forwarding like this +```ShellSession +$ ssh -L 4000:localhost:4000 myuser@example.net +``` +and then accessing from a web browser. + +## Creating the admin user {#module-services-pleroma-admin-user} + +After Pleroma service is running, all [Pleroma administration utilities](https://docs-develop.pleroma.social/) can be used. In particular an admin user can be created with +```ShellSession +$ pleroma_ctl user new --admin --moderator --password +``` + +## Configuring Nginx {#module-services-pleroma-nginx} + +In 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 +[Let's Encrypt](https://letsencrypt.org/) for the TLS certificates +``` +security.acme = { + email = "root@example.net"; + acceptTerms = true; +}; + +services.nginx = { + enable = true; + addSSL = true; + + recommendedTlsSettings = true; + recommendedOptimisation = true; + recommendedGzipSettings = true; + + recommendedProxySettings = false; + # NOTE: if enabled, the NixOS proxy optimizations will override the Pleroma + # specific settings, and they will enter in conflict. + + virtualHosts = { + "pleroma.example.net" = { + http2 = true; + enableACME = true; + forceSSL = true; + + locations."/" = { + proxyPass = "http://127.0.0.1:4000"; + + extraConfig = '' + etag on; + gzip on; + + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Methods' 'POST, PUT, DELETE, GET, PATCH, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Idempotency-Key' always; + add_header 'Access-Control-Expose-Headers' 'Link, X-RateLimit-Reset, X-RateLimit-Limit, X-RateLimit-Remaining, X-Request-Id' always; + if ($request_method = OPTIONS) { + return 204; + } + add_header X-XSS-Protection "1; mode=block"; + add_header X-Permitted-Cross-Domain-Policies none; + add_header X-Frame-Options DENY; + add_header X-Content-Type-Options nosniff; + add_header Referrer-Policy same-origin; + add_header X-Download-Options noopen; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + + client_max_body_size 16m; + # NOTE: increase if users need to upload very big files + ''; + }; + }; + }; +}; +``` diff --git a/nixos/modules/services/networking/pleroma.xml b/nixos/modules/services/networking/pleroma.xml index ad0a481af28b..97954f4b9514 100644 --- a/nixos/modules/services/networking/pleroma.xml +++ b/nixos/modules/services/networking/pleroma.xml @@ -1,63 +1,91 @@ - - Pleroma - - Pleroma is a lightweight activity pub server. -
- Generating the Pleroma config - The pleroma_ctl CLI utility will prompt you some questions and it will generate an initial config file. This is an example of usage - -$ mkdir tmp-pleroma -$ cd tmp-pleroma -$ nix-shell -p pleroma-otp -$ pleroma_ctl instance gen --output config.exs --output-psql setup.psql - + + + Pleroma + + Pleroma is a + lightweight activity pub server. - The config.exs file can be further customized following the instructions on the upstream documentation. Many refinements can be applied also after the service is running. -
-
- Initializing the database - First, the Postgresql service must be enabled in the NixOS configuration - +
+ Generating the Pleroma config + + The pleroma_ctl CLI utility will prompt you + some questions and it will generate an initial config file. This + is an example of usage + + +$ mkdir tmp-pleroma +$ cd tmp-pleroma +$ nix-shell -p pleroma-otp +$ pleroma_ctl instance gen --output config.exs --output-psql setup.psql + + + The config.exs file can be further customized + following the instructions on the + upstream + documentation. Many refinements can be applied also after + the service is running. + +
+
+ Initializing the database + + First, the Postgresql service must be enabled in the NixOS + configuration + + services.postgresql = { enable = true; package = pkgs.postgresql_13; }; -and activated with the usual - -$ nixos-rebuild switch + + and activated with the usual + + +$ nixos-rebuild switch - - Then you can create and seed the database, using the setup.psql file that you generated in the previous section, by running - -$ sudo -u postgres psql -f setup.psql + + Then you can create and seed the database, using the + setup.psql file that you generated in the + previous section, by running + + +$ sudo -u postgres psql -f setup.psql - -
-
- Enabling the Pleroma service locally - In this section we will enable the Pleroma service only locally, so its configurations can be improved incrementally. - This is an example of configuration, where services.pleroma.configs option contains the content of the file config.exs, generated in the first section, 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. - +
+
+ Enabling the Pleroma service locally + + In this section we will enable the Pleroma service only locally, + so its configurations can be improved incrementally. + + + This is an example of configuration, where + option contains + the content of the file config.exs, generated + in the + first section, 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. + + services.pleroma = { enable = true; - secretConfigFile = "/var/lib/pleroma/secrets.exs"; + secretConfigFile = "/var/lib/pleroma/secrets.exs"; configs = [ '' import Config config :pleroma, Pleroma.Web.Endpoint, - url: [host: "pleroma.example.net", scheme: "https", port: 443], + 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", + name: "Test", + email: "admin@example.net", + notify_email: "admin@example.net", limit: 5000, registrations_open: true @@ -67,68 +95,97 @@ services.pleroma = { config :pleroma, Pleroma.Repo, adapter: Ecto.Adapters.Postgres, - username: "pleroma", - database: "pleroma", - hostname: "localhost" + username: "pleroma", + database: "pleroma", + hostname: "localhost" # Configure web push notifications config :web_push_encryption, :vapid_details, - subject: "mailto:admin@example.net" + subject: "mailto:admin@example.net" # ... TO CONTINUE ... '' ]; }; - - Secrets must be moved into a file pointed by services.pleroma.secretConfigFile, in our case /var/lib/pleroma/secrets.exs. This file can be created copying the previously generated config.exs file and then removing all the settings, except the secrets. This is an example - + + Secrets must be moved into a file pointed by + , in our + case /var/lib/pleroma/secrets.exs. This file + can be created copying the previously generated + config.exs file and then removing all the + settings, except the secrets. This is an example + + # Pleroma instance passwords import Config config :pleroma, Pleroma.Web.Endpoint, - secret_key_base: "<the secret generated by pleroma_ctl>", - signing_salt: "<the secret generated by pleroma_ctl>" + secret_key_base: "<the secret generated by pleroma_ctl>", + signing_salt: "<the secret generated by pleroma_ctl>" config :pleroma, Pleroma.Repo, - password: "<the secret generated by pleroma_ctl>" + password: "<the secret generated by pleroma_ctl>" # Configure web push notifications config :web_push_encryption, :vapid_details, - public_key: "<the secret generated by pleroma_ctl>", - private_key: "<the secret generated by pleroma_ctl>" + public_key: "<the secret generated by pleroma_ctl>", + private_key: "<the secret generated by pleroma_ctl>" # ... TO CONTINUE ... - Note that the lines of the same configuration group are comma separated (i.e. all the lines end with a comma, except the last one), so when the lines with passwords are added or removed, commas must be adjusted accordingly. - - The service can be enabled with the usual - -$ nixos-rebuild switch + + Note that the lines of the same configuration group are comma + separated (i.e. all the lines end with a comma, except the last + one), so when the lines with passwords are added or removed, + commas must be adjusted accordingly. + + + The service can be enabled with the usual + + +$ nixos-rebuild switch - - The service is accessible only from the local 127.0.0.1:4000 port. It can be tested using a port forwarding like this - -$ ssh -L 4000:localhost:4000 myuser@example.net + + The service is accessible only from the local + 127.0.0.1:4000 port. It can be tested using a + port forwarding like this + + +$ ssh -L 4000:localhost:4000 myuser@example.net -and then accessing http://localhost:4000 from a web browser. -
-
- Creating the admin user - After Pleroma service is running, all Pleroma administration utilities can be used. In particular an admin user can be created with - -$ pleroma_ctl user new <nickname> <email> --admin --moderator --password <password> + + and then accessing + http://localhost:4000 + from a web browser. + +
+
+ Creating the admin user + + After Pleroma service is running, all + Pleroma + administration utilities can be used. In particular an + admin user can be created with + + +$ pleroma_ctl user new <nickname> <email> --admin --moderator --password <password> - -
-
- Configuring Nginx - In 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 -Let's Encrypt for the TLS certificates - +
+
+ Configuring Nginx + + In 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 + Let’s Encrypt + for the TLS certificates + + security.acme = { - email = "root@example.net"; + email = "root@example.net"; acceptTerms = true; }; @@ -145,13 +202,13 @@ services.nginx = { # specific settings, and they will enter in conflict. virtualHosts = { - "pleroma.example.net" = { + "pleroma.example.net" = { http2 = true; enableACME = true; forceSSL = true; - locations."/" = { - proxyPass = "http://127.0.0.1:4000"; + locations."/" = { + proxyPass = "http://127.0.0.1:4000"; extraConfig = '' etag on; @@ -164,7 +221,7 @@ services.nginx = { if ($request_method = OPTIONS) { return 204; } - add_header X-XSS-Protection "1; mode=block"; + add_header X-XSS-Protection "1; mode=block"; add_header X-Permitted-Cross-Domain-Policies none; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; @@ -172,7 +229,7 @@ services.nginx = { add_header X-Download-Options noopen; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + proxy_set_header Connection "upgrade"; proxy_set_header Host $host; client_max_body_size 16m; @@ -183,6 +240,5 @@ services.nginx = { }; }; - -
+
diff --git a/nixos/modules/services/networking/prosody.md b/nixos/modules/services/networking/prosody.md new file mode 100644 index 000000000000..2da2c242a98b --- /dev/null +++ b/nixos/modules/services/networking/prosody.md @@ -0,0 +1,72 @@ +# Prosody {#module-services-prosody} + +[Prosody](https://prosody.im/) is an open-source, modern XMPP server. + +## Basic usage {#module-services-prosody-basic-usage} + +A common struggle for most XMPP newcomers is to find the right set +of XMPP Extensions (XEPs) to setup. Forget to activate a few of +those and your XMPP experience might turn into a nightmare! + +The XMPP community tackles this problem by creating a meta-XEP +listing a decent set of XEPs you should implement. This meta-XEP +is issued every year, the 2020 edition being +[XEP-0423](https://xmpp.org/extensions/xep-0423.html). + +The NixOS Prosody module will implement most of these recommendend XEPs out of +the box. That being said, two components still require some +manual configuration: the +[Multi User Chat (MUC)](https://xmpp.org/extensions/xep-0045.html) +and the [HTTP File Upload](https://xmpp.org/extensions/xep-0363.html) ones. +You'll need to create a DNS subdomain for each of those. The current convention is to name your +MUC endpoint `conference.example.org` and your HTTP upload domain `upload.example.org`. + +A good configuration to start with, including a +[Multi User Chat (MUC)](https://xmpp.org/extensions/xep-0045.html) +endpoint as well as a [HTTP File Upload](https://xmpp.org/extensions/xep-0363.html) +endpoint will look like this: +``` +services.prosody = { + enable = true; + admins = [ "root@example.org" ]; + 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"; + }; + muc = [ { + domain = "conference.example.org"; + } ]; + uploadHttp = { + domain = "upload.example.org"; + }; +}; +``` + +## Let's Encrypt Configuration {#module-services-prosody-letsencrypt} + +As you can see in the code snippet from the +[previous section](#module-services-prosody-basic-usage), +you'll need a single TLS certificate covering your main endpoint, +the MUC one as well as the HTTP Upload one. We can generate such a +certificate by leveraging the ACME +[extraDomainNames](#opt-security.acme.certs._name_.extraDomainNames) module option. + +Provided the setup detailed in the previous section, you'll need the following acme configuration to generate +a TLS certificate for the three endponits: +``` +security.acme = { + email = "root@example.org"; + acceptTerms = true; + certs = { + "example.org" = { + webroot = "/var/www/example.org"; + email = "root@example.org"; + extraDomainNames = [ "conference.example.org" "upload.example.org" ]; + }; + }; +}; +``` diff --git a/nixos/modules/services/networking/prosody.nix b/nixos/modules/services/networking/prosody.nix index 342638f93bae..0746bbf184fc 100644 --- a/nixos/modules/services/networking/prosody.nix +++ b/nixos/modules/services/networking/prosody.nix @@ -904,5 +904,6 @@ in }; }; + meta.doc = ./prosody.xml; } diff --git a/nixos/modules/services/networking/prosody.xml b/nixos/modules/services/networking/prosody.xml index 6358d744ff78..5df046f81459 100644 --- a/nixos/modules/services/networking/prosody.xml +++ b/nixos/modules/services/networking/prosody.xml @@ -1,87 +1,92 @@ - - Prosody - - Prosody is an open-source, modern XMPP server. - -
- Basic usage - + + + Prosody - A common struggle for most XMPP newcomers is to find the right set - of XMPP Extensions (XEPs) to setup. Forget to activate a few of - those and your XMPP experience might turn into a nightmare! + Prosody is an + open-source, modern XMPP server. - - - The XMPP community tackles this problem by creating a meta-XEP - listing a decent set of XEPs you should implement. This meta-XEP - is issued every year, the 2020 edition being - XEP-0423. - - - The NixOS Prosody module will implement most of these recommendend XEPs out of - the box. That being said, two components still require some - manual configuration: the - Multi User Chat (MUC) - and the HTTP File Upload ones. - You'll need to create a DNS subdomain for each of those. The current convention is to name your - MUC endpoint conference.example.org and your HTTP upload domain upload.example.org. - - - A good configuration to start with, including a - Multi User Chat (MUC) - endpoint as well as a HTTP File Upload - endpoint will look like this: +
+ Basic usage + + A common struggle for most XMPP newcomers is to find the right set + of XMPP Extensions (XEPs) to setup. Forget to activate a few of + those and your XMPP experience might turn into a nightmare! + + + The XMPP community tackles this problem by creating a meta-XEP + listing a decent set of XEPs you should implement. This meta-XEP + is issued every year, the 2020 edition being + XEP-0423. + + + The NixOS Prosody module will implement most of these recommendend + XEPs out of the box. That being said, two components still require + some manual configuration: the + Multi + User Chat (MUC) and the + HTTP + File Upload ones. You’ll need to create a DNS subdomain for + each of those. The current convention is to name your MUC endpoint + conference.example.org and your HTTP upload + domain upload.example.org. + + + A good configuration to start with, including a + Multi + User Chat (MUC) endpoint as well as a + HTTP + File Upload endpoint will look like this: + services.prosody = { - enable = true; - admins = [ "root@example.org" ]; - 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"; + enable = true; + admins = [ "root@example.org" ]; + 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"; }; - muc = [ { - domain = "conference.example.org"; + muc = [ { + domain = "conference.example.org"; } ]; - uploadHttp = { - domain = "upload.example.org"; + uploadHttp = { + domain = "upload.example.org"; }; -}; - -
-
- Let's Encrypt Configuration - - As you can see in the code snippet from the - previous section, - you'll need a single TLS certificate covering your main endpoint, - the MUC one as well as the HTTP Upload one. We can generate such a - certificate by leveraging the ACME - extraDomainNames module option. - - - Provided the setup detailed in the previous section, you'll need the following acme configuration to generate - a TLS certificate for the three endponits: +}; + +
+
+ Let’s Encrypt Configuration + + As you can see in the code snippet from the + previous + section, you’ll need a single TLS certificate covering your + main endpoint, the MUC one as well as the HTTP Upload one. We can + generate such a certificate by leveraging the ACME + extraDomainNames + module option. + + + Provided the setup detailed in the previous section, you’ll need + the following acme configuration to generate a TLS certificate for + the three endponits: + security.acme = { - email = "root@example.org"; - acceptTerms = true; - certs = { - "example.org" = { - webroot = "/var/www/example.org"; - email = "root@example.org"; - extraDomainNames = [ "conference.example.org" "upload.example.org" ]; + email = "root@example.org"; + acceptTerms = true; + certs = { + "example.org" = { + webroot = "/var/www/example.org"; + email = "root@example.org"; + extraDomainNames = [ "conference.example.org" "upload.example.org" ]; }; }; -}; - -
+}; + +
diff --git a/nixos/modules/services/networking/yggdrasil.md b/nixos/modules/services/networking/yggdrasil.md new file mode 100644 index 000000000000..bbaea5bc74aa --- /dev/null +++ b/nixos/modules/services/networking/yggdrasil.md @@ -0,0 +1,141 @@ +# Yggdrasil {#module-services-networking-yggdrasil} + +*Source:* {file}`modules/services/networking/yggdrasil/default.nix` + +*Upstream documentation:* + +Yggdrasil is an early-stage implementation of a fully end-to-end encrypted, +self-arranging IPv6 network. + +## Configuration {#module-services-networking-yggdrasil-configuration} + +### Simple ephemeral node {#module-services-networking-yggdrasil-configuration-simple} + +An annotated example of a simple configuration: +``` +{ + 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. + + settings = { + Peers = [ + # Yggdrasil will automatically connect and "peer" with other nodes it + # discovers via link-local multicast announcements. Unless this is the + # case (it probably isn't) a node needs peers within the existing + # network that it can tunnel to. + "tcp://1.2.3.4:1024" + "tcp://1.2.3.5:1024" + # Public peers can be found at + # https://github.com/yggdrasil-network/public-peers + ]; + }; + }; +} +``` + +### Persistent node with prefix {#module-services-networking-yggdrasil-configuration-prefix} + +A node with a fixed address that announces a prefix: +``` +let + address = "210:5217:69c0:9afc:1b95:b9f:8718:c3d2"; + prefix = "310:5217:69c0:9afc"; + # taken from the output of "yggdrasilctl getself". +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" ]; + NodeInfo = { + # This information is visible to the network. + name = config.networking.hostName; + location = "The North Pole"; + }; + }; + }; + + boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; + # 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; + }]; + + services.radvd = { + # Announce the 300::/8 prefix to eth0. + enable = true; + config = '' + interface eth0 + { + AdvSendAdvert on; + prefix ${prefix}::/64 { + AdvOnLink on; + AdvAutonomous on; + }; + route 200::/8 {}; + }; + ''; + }; +} +``` + +### Yggdrasil attached Container {#module-services-networking-yggdrasil-configuration-container} + +A NixOS container attached to the Yggdrasil network via a node running on the +host: +``` +let + yggPrefix64 = "310:5217:69c0:9afc"; + # Again, taken from the output of "yggdrasilctl getself". +in +{ + boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; + # Enable IPv6 forwarding. + + networking = { + bridges.br0.interfaces = [ ]; + # A bridge only to containers… + + interfaces.br0 = { + # … configured with a prefix address. + ipv6.addresses = [{ + address = "${yggPrefix64}::1"; + prefixLength = 64; + }]; + }; + }; + + containers.foo = { + autoStart = true; + 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"; + }]; + }; + + services.httpd.enable = true; + networking.firewall.allowedTCPPorts = [ 80 ]; + }; + }; + +} +``` diff --git a/nixos/modules/services/networking/yggdrasil.xml b/nixos/modules/services/networking/yggdrasil.xml index a7b8c469529a..39faacbf30ef 100644 --- a/nixos/modules/services/networking/yggdrasil.xml +++ b/nixos/modules/services/networking/yggdrasil.xml @@ -1,5 +1,6 @@ - - + + Yggdrasil Source: @@ -7,19 +8,20 @@ Upstream documentation: - + https://yggdrasil-network.github.io/ -Yggdrasil is an early-stage implementation of a fully end-to-end encrypted, -self-arranging IPv6 network. - + Yggdrasil is an early-stage implementation of a fully end-to-end + encrypted, self-arranging IPv6 network. +
Configuration
Simple ephemeral node -An annotated example of a simple configuration: - + An annotated example of a simple configuration: + + { services.yggdrasil = { enable = true; @@ -29,12 +31,12 @@ An annotated example of a simple configuration: settings = { Peers = [ - # Yggdrasil will automatically connect and "peer" with other nodes it + # Yggdrasil will automatically connect and "peer" with other nodes it # discovers via link-local multicast announcements. Unless this is the # case (it probably isn't) a node needs peers within the existing # network that it can tunnel to. - "tcp://1.2.3.4:1024" - "tcp://1.2.3.5:1024" + "tcp://1.2.3.4:1024" + "tcp://1.2.3.5:1024" # Public peers can be found at # https://github.com/yggdrasil-network/public-peers ]; @@ -42,38 +44,38 @@ An annotated example of a simple configuration: }; } -
Persistent node with prefix -A node with a fixed address that announces a prefix: - + A node with a fixed address that announces a prefix: + + let - address = "210:5217:69c0:9afc:1b95:b9f:8718:c3d2"; - prefix = "310:5217:69c0:9afc"; - # taken from the output of "yggdrasilctl getself". + address = "210:5217:69c0:9afc:1b95:b9f:8718:c3d2"; + prefix = "310:5217:69c0:9afc"; + # taken from the output of "yggdrasilctl getself". 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; - location = "The North Pole"; + location = "The North Pole"; }; }; }; - boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; + boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; # Forward traffic under the prefix. networking.interfaces.${eth0}.ipv6.addresses = [{ # Set a 300::/8 address on the local physical device. - address = prefix + "::1"; + address = prefix + "::1"; prefixLength = 64; }]; @@ -94,30 +96,30 @@ in { }; } -
Yggdrasil attached Container -A NixOS container attached to the Yggdrasil network via a node running on the -host: - + A NixOS container attached to the Yggdrasil network via a node + running on the host: + + let - yggPrefix64 = "310:5217:69c0:9afc"; - # Again, taken from the output of "yggdrasilctl getself". + yggPrefix64 = "310:5217:69c0:9afc"; + # Again, taken from the output of "yggdrasilctl getself". in { - boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; + boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1; # Enable IPv6 forwarding. networking = { bridges.br0.interfaces = [ ]; - # A bridge only to containers… + # A bridge only to containers… interfaces.br0 = { - # … configured with a prefix address. + # … configured with a prefix address. ipv6.addresses = [{ - address = "${yggPrefix64}::1"; + address = "${yggPrefix64}::1"; prefixLength = 64; }]; }; @@ -126,20 +128,20 @@ in containers.foo = { autoStart = true; privateNetwork = true; - hostBridge = "br0"; + hostBridge = "br0"; # Attach the container to the bridge only. config = { config, pkgs, ... }: { networking.interfaces.eth0.ipv6 = { addresses = [{ # Configure a prefix address. - address = "${yggPrefix64}::2"; + address = "${yggPrefix64}::2"; prefixLength = 64; }]; routes = [{ # Configure the prefix route. - address = "200::"; + address = "200::"; prefixLength = 7; - via = "${yggPrefix64}::1"; + via = "${yggPrefix64}::1"; }]; }; @@ -150,7 +152,6 @@ in } -
diff --git a/nixos/modules/services/search/meilisearch.md b/nixos/modules/services/search/meilisearch.md index 98e7c542cb9a..98af396117c8 100644 --- a/nixos/modules/services/search/meilisearch.md +++ b/nixos/modules/services/search/meilisearch.md @@ -2,7 +2,7 @@ Meilisearch is a lightweight, fast and powerful search engine. Think elastic search with a much smaller footprint. -## Quickstart +## Quickstart {#module-services-meilisearch-quickstart} the minimum to start meilisearch is @@ -14,19 +14,19 @@ this will start the http server included with meilisearch on port 7700. test with `curl -X GET 'http://localhost:7700/health'` -## Usage +## Usage {#module-services-meilisearch-usage} you first need to add documents to an index before you can search for documents. -### Add a documents to the `movies` index +### Add a documents to the `movies` index {#module-services-meilisearch-quickstart-add} `curl -X POST 'http://127.0.0.1:7700/indexes/movies/documents' --data '[{"id": "123", "title": "Superman"}, {"id": 234, "title": "Batman"}]'` -### Search documents in the `movies` index +### Search documents in the `movies` index {#module-services-meilisearch-quickstart-search} `curl 'http://127.0.0.1:7700/indexes/movies/search' --data '{ "q": "botman" }'` (note the typo is intentional and there to demonstrate the typo tolerant capabilities) -## Defaults +## Defaults {#module-services-meilisearch-defaults} - The default nixos package doesn't come with the [dashboard](https://docs.meilisearch.com/learn/getting_started/quick_start.html#search), since the dashboard features makes some assets downloads at compile time. @@ -34,6 +34,6 @@ you first need to add documents to an index before you can search for documents. - Default deployment is development mode. It doesn't require a secret master key. All routes are not protected and accessible. -## Missing +## Missing {#module-services-meilisearch-missing} - the snapshot feature is not yet configurable from the module, it's just a matter of adding the relevant environment variables. diff --git a/nixos/modules/services/search/meilisearch.nix b/nixos/modules/services/search/meilisearch.nix index 3983b1b2c92c..9b727b76b1c6 100644 --- a/nixos/modules/services/search/meilisearch.nix +++ b/nixos/modules/services/search/meilisearch.nix @@ -9,8 +9,6 @@ in { meta.maintainers = with maintainers; [ Br1ght0ne happysalada ]; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc meilisearch.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > meilisearch.xml` meta.doc = ./meilisearch.xml; ###### interface diff --git a/nixos/modules/services/search/meilisearch.xml b/nixos/modules/services/search/meilisearch.xml index c1a73f358c28..8bfd64920b03 100644 --- a/nixos/modules/services/search/meilisearch.xml +++ b/nixos/modules/services/search/meilisearch.xml @@ -1,15 +1,17 @@ + Meilisearch Meilisearch is a lightweight, fast and powerful search engine. Think elastic search with a much smaller footprint. -
+
Quickstart the minimum to start meilisearch is - + services.meilisearch.enable = true; @@ -21,20 +23,20 @@ services.meilisearch.enable = true; curl -X GET 'http://localhost:7700/health'
-
+
Usage you first need to add documents to an index before you can search for documents. -
+
Add a documents to the <literal>movies</literal> index curl -X POST 'http://127.0.0.1:7700/indexes/movies/documents' --data '[{"id": "123", "title": "Superman"}, {"id": 234, "title": "Batman"}]'
-
+
Search documents in the <literal>movies</literal> index @@ -44,7 +46,7 @@ services.meilisearch.enable = true;
-
+
Defaults @@ -70,7 +72,7 @@ services.meilisearch.enable = true;
-
+
Missing diff --git a/nixos/modules/services/web-apps/akkoma.xml b/nixos/modules/services/web-apps/akkoma.xml index 76e6b806f30f..49cbcc911e1d 100644 --- a/nixos/modules/services/web-apps/akkoma.xml +++ b/nixos/modules/services/web-apps/akkoma.xml @@ -1,3 +1,5 @@ + Akkoma @@ -371,7 +373,7 @@ services.systemd.akkoma.confinement.enable = true; and permit access to outside paths through bind mounts. Refer to - systemd.exec5 + systemd.exec5 for details.
diff --git a/nixos/modules/services/web-apps/discourse.md b/nixos/modules/services/web-apps/discourse.md new file mode 100644 index 000000000000..35180bea87d9 --- /dev/null +++ b/nixos/modules/services/web-apps/discourse.md @@ -0,0 +1,286 @@ +# Discourse {#module-services-discourse} + +[Discourse](https://www.discourse.org/) is a +modern and open source discussion platform. + +## Basic usage {#module-services-discourse-basic-usage} + +A minimal configuration using Let's Encrypt for TLS certificates looks like this: +``` +services.discourse = { + enable = true; + hostname = "discourse.example.com"; + admin = { + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; + }; + secretKeyBaseFile = "/path/to/secret_key_base_file"; +}; +security.acme.email = "me@example.com"; +security.acme.acceptTerms = true; +``` + +Provided a proper DNS setup, you'll be able to connect to the +instance at `discourse.example.com` and log in +using the credentials provided in +`services.discourse.admin`. + +## Using a regular TLS certificate {#module-services-discourse-tls} + +To set up TLS using a regular certificate and key on file, use +the [](#opt-services.discourse.sslCertificate) +and [](#opt-services.discourse.sslCertificateKey) +options: + +``` +services.discourse = { + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; + admin = { + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; + }; + secretKeyBaseFile = "/path/to/secret_key_base_file"; +}; +``` + +## Database access {#module-services-discourse-database} + +Discourse uses PostgreSQL to store most of its +data. A database will automatically be enabled and a database +and role created unless [](#opt-services.discourse.database.host) is changed from +its default of `null` or [](#opt-services.discourse.database.createLocally) is set +to `false`. + +External database access can also be configured by setting +[](#opt-services.discourse.database.host), +[](#opt-services.discourse.database.username) and +[](#opt-services.discourse.database.passwordFile) as +appropriate. Note that you need to manually create a database +called `discourse` (or the name you chose in +[](#opt-services.discourse.database.name)) and +allow the configured database user full access to it. + +## Email {#module-services-discourse-mail} + +In addition to the basic setup, you'll want to configure an SMTP +server Discourse can use to send user +registration and password reset emails, among others. You can +also optionally let Discourse receive +email, which enables people to reply to threads and conversations +via email. + +A basic setup which assumes you want to use your configured +[hostname](#opt-services.discourse.hostname) as +email domain can be done like this: + +``` +services.discourse = { + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; + admin = { + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; + }; + mail.outgoing = { + serverAddress = "smtp.emailprovider.com"; + port = 587; + username = "user@emailprovider.com"; + passwordFile = "/path/to/smtp_password_file"; + }; + mail.incoming.enable = true; + secretKeyBaseFile = "/path/to/secret_key_base_file"; +}; +``` + +This assumes you have set up an MX record for the address you've +set in [hostname](#opt-services.discourse.hostname) and +requires proper SPF, DKIM and DMARC configuration to be done for +the domain you're sending from, in order for email to be reliably delivered. + +If you want to use a different domain for your outgoing email +(for example `example.com` instead of +`discourse.example.com`) you should set +[](#opt-services.discourse.mail.notificationEmailAddress) and +[](#opt-services.discourse.mail.contactEmailAddress) manually. + +::: {.note} +Setup of TLS for incoming email is currently only configured +automatically when a regular TLS certificate is used, i.e. when +[](#opt-services.discourse.sslCertificate) and +[](#opt-services.discourse.sslCertificateKey) are +set. +::: + +## Additional settings {#module-services-discourse-settings} + +Additional site settings and backend settings, for which no +explicit NixOS options are provided, +can be set in [](#opt-services.discourse.siteSettings) and +[](#opt-services.discourse.backendSettings) respectively. + +### Site settings {#module-services-discourse-site-settings} + +"Site settings" are the settings that can be +changed through the Discourse +UI. Their *default* values can be set using +[](#opt-services.discourse.siteSettings). + +Settings are expressed as a Nix attribute set which matches the +structure of the configuration in +[config/site_settings.yml](https://github.com/discourse/discourse/blob/master/config/site_settings.yml). +To find a setting's path, you only need to care about the first +two levels; i.e. its category (e.g. `login`) +and name (e.g. `invite_only`). + +Settings containing secret data should be set to an attribute +set containing the attribute `_secret` - a +string pointing to a file containing the value the option +should be set to. See the example. + +### Backend settings {#module-services-discourse-backend-settings} + +Settings are expressed as a Nix attribute set which matches the +structure of the configuration in +[config/discourse.conf](https://github.com/discourse/discourse/blob/stable/config/discourse_defaults.conf). +Empty parameters can be defined by setting them to +`null`. + +### Example {#module-services-discourse-settings-example} + +The following example sets the title and description of the +Discourse instance and enables +GitHub login in the site settings, +and changes a few request limits in the backend settings: +``` +services.discourse = { + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; + admin = { + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; + }; + mail.outgoing = { + serverAddress = "smtp.emailprovider.com"; + port = 587; + username = "user@emailprovider.com"; + passwordFile = "/path/to/smtp_password_file"; + }; + mail.incoming.enable = true; + siteSettings = { + required = { + title = "My Cats"; + site_description = "Discuss My Cats (and be nice plz)"; + }; + login = { + enable_github_logins = true; + github_client_id = "a2f6dfe838cb3206ce20"; + github_client_secret._secret = /run/keys/discourse_github_client_secret; + }; + }; + backendSettings = { + max_reqs_per_ip_per_minute = 300; + max_reqs_per_ip_per_10_seconds = 60; + max_asset_reqs_per_ip_per_10_seconds = 250; + max_reqs_per_ip_mode = "warn+block"; + }; + secretKeyBaseFile = "/path/to/secret_key_base_file"; +}; +``` + +In the resulting site settings file, the +`login.github_client_secret` key will be set +to the contents of the +{file}`/run/keys/discourse_github_client_secret` +file. + +## Plugins {#module-services-discourse-plugins} + +You can install Discourse plugins +using the [](#opt-services.discourse.plugins) +option. Pre-packaged plugins are provided in +`.plugins`. If +you want the full suite of plugins provided through +`nixpkgs`, you can also set the [](#opt-services.discourse.package) option to +`pkgs.discourseAllPlugins`. + +Plugins can be built with the +`.mkDiscoursePlugin` +function. Normally, it should suffice to provide a +`name` and `src` attribute. If +the plugin has Ruby dependencies, however, they need to be +packaged in accordance with the [Developing with Ruby](https://nixos.org/manual/nixpkgs/stable/#developing-with-ruby) +section of the Nixpkgs manual and the +appropriate gem options set in `bundlerEnvArgs` +(normally `gemdir` is sufficient). A plugin's +Ruby dependencies are listed in its +{file}`plugin.rb` file as function calls to +`gem`. To construct the corresponding +{file}`Gemfile` manually, run {command}`bundle init`, then add the `gem` lines to it +verbatim. + +Much of the packaging can be done automatically by the +{file}`nixpkgs/pkgs/servers/web-apps/discourse/update.py` +script - just add the plugin to the `plugins` +list in the `update_plugins` function and run +the script: +```bash +./update.py update-plugins +``` + +Some plugins provide [site settings](#module-services-discourse-site-settings). +Their defaults can be configured using [](#opt-services.discourse.siteSettings), just like +regular site settings. To find the names of these settings, look +in the `config/settings.yml` file of the plugin +repo. + +For example, to add the [discourse-spoiler-alert](https://github.com/discourse/discourse-spoiler-alert) +and [discourse-solved](https://github.com/discourse/discourse-solved) +plugins, and disable `discourse-spoiler-alert` +by default: + +``` +services.discourse = { + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; + admin = { + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; + }; + mail.outgoing = { + serverAddress = "smtp.emailprovider.com"; + port = 587; + username = "user@emailprovider.com"; + passwordFile = "/path/to/smtp_password_file"; + }; + mail.incoming.enable = true; + plugins = with config.services.discourse.package.plugins; [ + discourse-spoiler-alert + discourse-solved + ]; + siteSettings = { + plugins = { + spoiler_enabled = false; + }; + }; + secretKeyBaseFile = "/path/to/secret_key_base_file"; +}; +``` diff --git a/nixos/modules/services/web-apps/discourse.xml b/nixos/modules/services/web-apps/discourse.xml index ad9b65abf51e..a5e8b3656b7d 100644 --- a/nixos/modules/services/web-apps/discourse.xml +++ b/nixos/modules/services/web-apps/discourse.xml @@ -1,355 +1,331 @@ - - Discourse - - Discourse is a - modern and open source discussion platform. - - -
- Basic usage - - A minimal configuration using Let's Encrypt for TLS certificates looks like this: - + + + Discourse + + Discourse is a + modern and open source discussion platform. + +
+ Basic usage + + A minimal configuration using Let’s Encrypt for TLS certificates + looks like this: + + services.discourse = { - enable = true; - hostname = "discourse.example.com"; + enable = true; + hostname = "discourse.example.com"; admin = { - email = "admin@example.com"; - username = "admin"; - fullName = "Administrator"; - passwordFile = "/path/to/password_file"; + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; }; - secretKeyBaseFile = "/path/to/secret_key_base_file"; + secretKeyBaseFile = "/path/to/secret_key_base_file"; }; -security.acme.email = "me@example.com"; -security.acme.acceptTerms = true; +security.acme.email = "me@example.com"; +security.acme.acceptTerms = true; - - - - Provided a proper DNS setup, you'll be able to connect to the - instance at discourse.example.com and log in - using the credentials provided in - services.discourse.admin. - -
- -
- Using a regular TLS certificate - - To set up TLS using a regular certificate and key on file, use - the - and - options: - - + + Provided a proper DNS setup, you’ll be able to connect to the + instance at discourse.example.com and log in + using the credentials provided in + services.discourse.admin. + +
+
+ Using a regular TLS certificate + + To set up TLS using a regular certificate and key on file, use the + and + + options: + + services.discourse = { - enable = true; - hostname = "discourse.example.com"; - sslCertificate = "/path/to/ssl_certificate"; - sslCertificateKey = "/path/to/ssl_certificate_key"; + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; admin = { - email = "admin@example.com"; - username = "admin"; - fullName = "Administrator"; - passwordFile = "/path/to/password_file"; + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; }; - secretKeyBaseFile = "/path/to/secret_key_base_file"; + secretKeyBaseFile = "/path/to/secret_key_base_file"; }; - - -
- -
- Database access - - Discourse uses - PostgreSQL to store most of its - data. A database will automatically be enabled and a database - and role created unless is changed from - its default of null or is set - to false. - - - - External database access can also be configured by setting - , and as - appropriate. Note that you need to manually create a database - called discourse (or the name you chose in - ) and - allow the configured database user full access to it. - -
- -
- Email - - In addition to the basic setup, you'll want to configure an SMTP - server Discourse can use to send user - registration and password reset emails, among others. You can - also optionally let Discourse receive - email, which enables people to reply to threads and conversations - via email. - - - - A basic setup which assumes you want to use your configured hostname as - email domain can be done like this: - - +
+
+ Database access + + Discourse uses PostgreSQL to store most of its data. A database + will automatically be enabled and a database and role created + unless is + changed from its default of null or + + is set to false. + + + External database access can also be configured by setting + , + and + as + appropriate. Note that you need to manually create a database + called discourse (or the name you chose in + ) and allow + the configured database user full access to it. + +
+
+ Email + + In addition to the basic setup, you’ll want to configure an SMTP + server Discourse can use to send user registration and password + reset emails, among others. You can also optionally let Discourse + receive email, which enables people to reply to threads and + conversations via email. + + + A basic setup which assumes you want to use your configured + hostname as + email domain can be done like this: + + services.discourse = { - enable = true; - hostname = "discourse.example.com"; - sslCertificate = "/path/to/ssl_certificate"; - sslCertificateKey = "/path/to/ssl_certificate_key"; + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; admin = { - email = "admin@example.com"; - username = "admin"; - fullName = "Administrator"; - passwordFile = "/path/to/password_file"; + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; }; mail.outgoing = { - serverAddress = "smtp.emailprovider.com"; - port = 587; - username = "user@emailprovider.com"; - passwordFile = "/path/to/smtp_password_file"; + serverAddress = "smtp.emailprovider.com"; + port = 587; + username = "user@emailprovider.com"; + passwordFile = "/path/to/smtp_password_file"; }; - mail.incoming.enable = true; - secretKeyBaseFile = "/path/to/secret_key_base_file"; + mail.incoming.enable = true; + secretKeyBaseFile = "/path/to/secret_key_base_file"; }; - - This assumes you have set up an MX record for the address you've - set in hostname and - requires proper SPF, DKIM and DMARC configuration to be done for - the domain you're sending from, in order for email to be reliably delivered. - - - - If you want to use a different domain for your outgoing email - (for example example.com instead of - discourse.example.com) you should set - and - manually. - - - - - Setup of TLS for incoming email is currently only configured - automatically when a regular TLS certificate is used, i.e. when - and - are - set. - - - -
- -
- Additional settings - - Additional site settings and backend settings, for which no - explicit NixOS options are provided, - can be set in and - respectively. - - -
- Site settings - - Site settings are the settings that can be - changed through the Discourse - UI. Their default values can be set using - . - - - - Settings are expressed as a Nix attribute set which matches the - structure of the configuration in - config/site_settings.yml. - To find a setting's path, you only need to care about the first - two levels; i.e. its category (e.g. login) - and name (e.g. invite_only). - - - - Settings containing secret data should be set to an attribute - set containing the attribute _secret - a - string pointing to a file containing the value the option - should be set to. See the example. - -
- -
- Backend settings - - Settings are expressed as a Nix attribute set which matches the - structure of the configuration in - config/discourse.conf. - Empty parameters can be defined by setting them to - null. - -
- -
- Example - - The following example sets the title and description of the - Discourse instance and enables - GitHub login in the site settings, - and changes a few request limits in the backend settings: - + + This assumes you have set up an MX record for the address you’ve + set in + hostname + and requires proper SPF, DKIM and DMARC configuration to be done + for the domain you’re sending from, in order for email to be + reliably delivered. + + + If you want to use a different domain for your outgoing email (for + example example.com instead of + discourse.example.com) you should set + + and + + manually. + + + + Setup of TLS for incoming email is currently only configured + automatically when a regular TLS certificate is used, i.e. when + and + are + set. + + +
+
+ Additional settings + + Additional site settings and backend settings, for which no + explicit NixOS options are provided, can be set in + and + + respectively. + +
+ Site settings + + Site settings are the settings that can be + changed through the Discourse UI. Their + default values can be set using + . + + + Settings are expressed as a Nix attribute set which matches the + structure of the configuration in + config/site_settings.yml. + To find a setting’s path, you only need to care about the first + two levels; i.e. its category (e.g. login) + and name (e.g. invite_only). + + + Settings containing secret data should be set to an attribute + set containing the attribute _secret - a + string pointing to a file containing the value the option should + be set to. See the example. + +
+
+ Backend settings + + Settings are expressed as a Nix attribute set which matches the + structure of the configuration in + config/discourse.conf. + Empty parameters can be defined by setting them to + null. + +
+
+ Example + + The following example sets the title and description of the + Discourse instance and enables GitHub login in the site + settings, and changes a few request limits in the backend + settings: + + services.discourse = { - enable = true; - hostname = "discourse.example.com"; - sslCertificate = "/path/to/ssl_certificate"; - sslCertificateKey = "/path/to/ssl_certificate_key"; + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; admin = { - email = "admin@example.com"; - username = "admin"; - fullName = "Administrator"; - passwordFile = "/path/to/password_file"; + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; }; mail.outgoing = { - serverAddress = "smtp.emailprovider.com"; - port = 587; - username = "user@emailprovider.com"; - passwordFile = "/path/to/smtp_password_file"; + serverAddress = "smtp.emailprovider.com"; + port = 587; + username = "user@emailprovider.com"; + passwordFile = "/path/to/smtp_password_file"; }; - mail.incoming.enable = true; - siteSettings = { + mail.incoming.enable = true; + siteSettings = { required = { - title = "My Cats"; - site_description = "Discuss My Cats (and be nice plz)"; + title = "My Cats"; + site_description = "Discuss My Cats (and be nice plz)"; }; login = { enable_github_logins = true; - github_client_id = "a2f6dfe838cb3206ce20"; + github_client_id = "a2f6dfe838cb3206ce20"; github_client_secret._secret = /run/keys/discourse_github_client_secret; }; }; - backendSettings = { + backendSettings = { max_reqs_per_ip_per_minute = 300; max_reqs_per_ip_per_10_seconds = 60; max_asset_reqs_per_ip_per_10_seconds = 250; - max_reqs_per_ip_mode = "warn+block"; + max_reqs_per_ip_mode = "warn+block"; }; - secretKeyBaseFile = "/path/to/secret_key_base_file"; + secretKeyBaseFile = "/path/to/secret_key_base_file"; }; - - - In the resulting site settings file, the - login.github_client_secret key will be set - to the contents of the - /run/keys/discourse_github_client_secret - file. - -
-
+ + In the resulting site settings file, the + login.github_client_secret key will be set to + the contents of the + /run/keys/discourse_github_client_secret + file. + +
+
Plugins - You can install Discourse plugins - using the - option. Pre-packaged plugins are provided in + You can install Discourse plugins using the + option. + Pre-packaged plugins are provided in <your_discourse_package_here>.plugins. If you want the full suite of plugins provided through - nixpkgs, you can also set the option to + nixpkgs, you can also set the + option to pkgs.discourseAllPlugins. - Plugins can be built with the <your_discourse_package_here>.mkDiscoursePlugin function. Normally, it should suffice to provide a name and src attribute. If the plugin has Ruby dependencies, however, they need to be - packaged in accordance with the Developing - with Ruby section of the Nixpkgs manual and the - appropriate gem options set in bundlerEnvArgs - (normally gemdir is sufficient). A plugin's - Ruby dependencies are listed in its - plugin.rb file as function calls to - gem. To construct the corresponding - Gemfile manually, run bundle - init, then add the gem lines to it - verbatim. + packaged in accordance with the + Developing + with Ruby section of the Nixpkgs manual and the appropriate + gem options set in bundlerEnvArgs (normally + gemdir is sufficient). A plugin’s Ruby + dependencies are listed in its plugin.rb file + as function calls to gem. To construct the + corresponding Gemfile manually, run + bundle init, then add the + gem lines to it verbatim. - Much of the packaging can be done automatically by the nixpkgs/pkgs/servers/web-apps/discourse/update.py script - just add the plugin to the plugins - list in the update_plugins function and run - the script: - + list in the update_plugins function and run the + script: + + ./update.py update-plugins - - - Some plugins provide site - settings. Their defaults can be configured using , just like + Some plugins provide + site + settings. Their defaults can be configured using + , just like regular site settings. To find the names of these settings, look in the config/settings.yml file of the plugin repo. - - For example, to add the discourse-spoiler-alert - and discourse-solved - plugins, and disable discourse-spoiler-alert - by default: - - + For example, to add the + discourse-spoiler-alert + and + discourse-solved + plugins, and disable discourse-spoiler-alert by + default: + + services.discourse = { - enable = true; - hostname = "discourse.example.com"; - sslCertificate = "/path/to/ssl_certificate"; - sslCertificateKey = "/path/to/ssl_certificate_key"; + enable = true; + hostname = "discourse.example.com"; + sslCertificate = "/path/to/ssl_certificate"; + sslCertificateKey = "/path/to/ssl_certificate_key"; admin = { - email = "admin@example.com"; - username = "admin"; - fullName = "Administrator"; - passwordFile = "/path/to/password_file"; + email = "admin@example.com"; + username = "admin"; + fullName = "Administrator"; + passwordFile = "/path/to/password_file"; }; mail.outgoing = { - serverAddress = "smtp.emailprovider.com"; - port = 587; - username = "user@emailprovider.com"; - passwordFile = "/path/to/smtp_password_file"; + serverAddress = "smtp.emailprovider.com"; + port = 587; + username = "user@emailprovider.com"; + passwordFile = "/path/to/smtp_password_file"; }; - mail.incoming.enable = true; - plugins = with config.services.discourse.package.plugins; [ + mail.incoming.enable = true; + plugins = with config.services.discourse.package.plugins; [ discourse-spoiler-alert discourse-solved ]; - siteSettings = { + siteSettings = { plugins = { spoiler_enabled = false; }; }; - secretKeyBaseFile = "/path/to/secret_key_base_file"; + secretKeyBaseFile = "/path/to/secret_key_base_file"; }; - -
diff --git a/nixos/modules/services/web-apps/grocy.md b/nixos/modules/services/web-apps/grocy.md new file mode 100644 index 000000000000..62aad4b103df --- /dev/null +++ b/nixos/modules/services/web-apps/grocy.md @@ -0,0 +1,66 @@ +# Grocy {#module-services-grocy} + +[Grocy](https://grocy.info/) is a web-based self-hosted groceries +& household management solution for your home. + +## Basic usage {#module-services-grocy-basic-usage} + +A very basic configuration may look like this: +``` +{ pkgs, ... }: +{ + services.grocy = { + enable = true; + hostName = "grocy.tld"; + }; +} +``` +This configures a simple vhost using [nginx](#opt-services.nginx.enable) +which listens to `grocy.tld` with fully configured ACME/LE (this can be +disabled by setting [services.grocy.nginx.enableSSL](#opt-services.grocy.nginx.enableSSL) +to `false`). After the initial setup the credentials `admin:admin` +can be used to login. + +The application's state is persisted at `/var/lib/grocy/grocy.db` in a +`sqlite3` database. The migration is applied when requesting the `/`-route +of the application. + +## Settings {#module-services-grocy-settings} + +The configuration for `grocy` is located at `/etc/grocy/config.php`. +By default, the following settings can be defined in the NixOS-configuration: +``` +{ pkgs, ... }: +{ + services.grocy.settings = { + # The default currency in the system for invoices etc. + # Please note that exchange rates aren't taken into account, this + # is just the setting for what's shown in the frontend. + currency = "EUR"; + + # The display language (and locale configuration) for grocy. + culture = "de"; + + calendar = { + # Whether or not to show the week-numbers + # in the calendar. + showWeekNumber = true; + + # Index of the first day to be shown in the calendar (0=Sunday, 1=Monday, + # 2=Tuesday and so on). + firstDayOfWeek = 2; + }; + }; +} +``` + +If you want to alter the configuration file on your own, you can do this manually with +an expression like this: +``` +{ lib, ... }: +{ + environment.etc."grocy/config.php".text = lib.mkAfter '' + // Arbitrary PHP code in grocy's configuration file + ''; +} +``` diff --git a/nixos/modules/services/web-apps/grocy.xml b/nixos/modules/services/web-apps/grocy.xml index fdf6d00f4b12..08de25b4ce2b 100644 --- a/nixos/modules/services/web-apps/grocy.xml +++ b/nixos/modules/services/web-apps/grocy.xml @@ -1,77 +1,84 @@ - - + + Grocy - Grocy is a web-based self-hosted groceries - & household management solution for your home. + Grocy is a web-based + self-hosted groceries & household management solution for your + home. -
- Basic usage - - A very basic configuration may look like this: -{ pkgs, ... }: + Basic usage + + A very basic configuration may look like this: + + +{ pkgs, ... }: { services.grocy = { - enable = true; - hostName = "grocy.tld"; + enable = true; + hostName = "grocy.tld"; }; -} - This configures a simple vhost using nginx - which listens to grocy.tld with fully configured ACME/LE (this can be - disabled by setting services.grocy.nginx.enableSSL - to false). After the initial setup the credentials admin:admin - can be used to login. - - - The application's state is persisted at /var/lib/grocy/grocy.db in a - sqlite3 database. The migration is applied when requesting the /-route - of the application. - +} + + + This configures a simple vhost using + nginx which + listens to grocy.tld with fully configured + ACME/LE (this can be disabled by setting + services.grocy.nginx.enableSSL + to false). After the initial setup the + credentials admin:admin can be used to login. + + + The application’s state is persisted at + /var/lib/grocy/grocy.db in a + sqlite3 database. The migration is applied when + requesting the /-route of the application. +
-
- Settings - - The configuration for grocy is located at /etc/grocy/config.php. - By default, the following settings can be defined in the NixOS-configuration: -{ pkgs, ... }: + Settings + + The configuration for grocy is located at + /etc/grocy/config.php. By default, the + following settings can be defined in the NixOS-configuration: + + +{ pkgs, ... }: { services.grocy.settings = { # The default currency in the system for invoices etc. # Please note that exchange rates aren't taken into account, this # is just the setting for what's shown in the frontend. - currency = "EUR"; + currency = "EUR"; # The display language (and locale configuration) for grocy. - culture = "de"; + culture = "de"; calendar = { # Whether or not to show the week-numbers # in the calendar. - showWeekNumber = true; + showWeekNumber = true; # Index of the first day to be shown in the calendar (0=Sunday, 1=Monday, # 2=Tuesday and so on). - firstDayOfWeek = 2; + firstDayOfWeek = 2; }; }; -} - - - If you want to alter the configuration file on your own, you can do this manually with - an expression like this: -{ lib, ... }: +} + + + If you want to alter the configuration file on your own, you can + do this manually with an expression like this: + + +{ lib, ... }: { - environment.etc."grocy/config.php".text = lib.mkAfter '' + environment.etc."grocy/config.php".text = lib.mkAfter '' // Arbitrary PHP code in grocy's configuration file ''; -} - +} +
-
diff --git a/nixos/modules/services/web-apps/jitsi-meet.md b/nixos/modules/services/web-apps/jitsi-meet.md new file mode 100644 index 000000000000..060ef9752650 --- /dev/null +++ b/nixos/modules/services/web-apps/jitsi-meet.md @@ -0,0 +1,45 @@ +# Jitsi Meet {#module-services-jitsi-meet} + +With Jitsi Meet on NixOS you can quickly configure a complete, +private, self-hosted video conferencing solution. + +## Basic usage {#module-services-jitsi-basic-usage} + +A minimal configuration using Let's Encrypt for TLS certificates looks like this: +``` +{ + services.jitsi-meet = { + enable = true; + hostName = "jitsi.example.com"; + }; + services.jitsi-videobridge.openFirewall = true; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + security.acme.email = "me@example.com"; + security.acme.acceptTerms = true; +} +``` + +## Configuration {#module-services-jitsi-configuration} + +Here is the minimal configuration with additional configurations: +``` +{ + services.jitsi-meet = { + enable = true; + hostName = "jitsi.example.com"; + config = { + enableWelcomePage = false; + prejoinPageEnabled = true; + defaultLang = "fi"; + }; + interfaceConfig = { + SHOW_JITSI_WATERMARK = false; + SHOW_WATERMARK_FOR_GUESTS = false; + }; + }; + services.jitsi-videobridge.openFirewall = true; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + security.acme.email = "me@example.com"; + security.acme.acceptTerms = true; +} +``` diff --git a/nixos/modules/services/web-apps/jitsi-meet.xml b/nixos/modules/services/web-apps/jitsi-meet.xml index ff44c724adf4..4d2d8aa55e19 100644 --- a/nixos/modules/services/web-apps/jitsi-meet.xml +++ b/nixos/modules/services/web-apps/jitsi-meet.xml @@ -1,55 +1,55 @@ - - Jitsi Meet - - With Jitsi Meet on NixOS you can quickly configure a complete, - private, self-hosted video conferencing solution. - - -
- Basic usage - - A minimal configuration using Let's Encrypt for TLS certificates looks like this: -{ + + + Jitsi Meet + + With Jitsi Meet on NixOS you can quickly configure a complete, + private, self-hosted video conferencing solution. + +
+ Basic usage + + A minimal configuration using Let’s Encrypt for TLS certificates + looks like this: + + +{ services.jitsi-meet = { - enable = true; - hostName = "jitsi.example.com"; + enable = true; + hostName = "jitsi.example.com"; }; - services.jitsi-videobridge.openFirewall = true; - networking.firewall.allowedTCPPorts = [ 80 443 ]; - security.acme.email = "me@example.com"; - security.acme.acceptTerms = true; -} - -
- -
- Configuration - - Here is the minimal configuration with additional configurations: -{ + services.jitsi-videobridge.openFirewall = true; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + security.acme.email = "me@example.com"; + security.acme.acceptTerms = true; +} + +
+
+ Configuration + + Here is the minimal configuration with additional configurations: + + +{ services.jitsi-meet = { - enable = true; - hostName = "jitsi.example.com"; - config = { + enable = true; + hostName = "jitsi.example.com"; + config = { enableWelcomePage = false; prejoinPageEnabled = true; - defaultLang = "fi"; + defaultLang = "fi"; }; - interfaceConfig = { + interfaceConfig = { SHOW_JITSI_WATERMARK = false; SHOW_WATERMARK_FOR_GUESTS = false; }; }; - services.jitsi-videobridge.openFirewall = true; - 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 ]; + security.acme.email = "me@example.com"; + security.acme.acceptTerms = true; +} +
+
diff --git a/nixos/modules/services/web-apps/keycloak.md b/nixos/modules/services/web-apps/keycloak.md new file mode 100644 index 000000000000..aa8de40d642b --- /dev/null +++ b/nixos/modules/services/web-apps/keycloak.md @@ -0,0 +1,141 @@ +# Keycloak {#module-services-keycloak} + +[Keycloak](https://www.keycloak.org/) is an +open source identity and access management server with support for +[OpenID Connect](https://openid.net/connect/), +[OAUTH 2.0](https://oauth.net/2/) and +[SAML 2.0](https://en.wikipedia.org/wiki/SAML_2.0). + +## Administration {#module-services-keycloak-admin} + +An administrative user with the username +`admin` is automatically created in the +`master` realm. Its initial password can be +configured by setting [](#opt-services.keycloak.initialAdminPassword) +and defaults to `changeme`. The password is +not stored safely and should be changed immediately in the +admin panel. + +Refer to the [Keycloak Server Administration Guide]( + https://www.keycloak.org/docs/latest/server_admin/index.html +) for information on +how to administer your Keycloak +instance. + +## Database access {#module-services-keycloak-database} + +Keycloak can be used with either PostgreSQL, MariaDB or +MySQL. Which one is used can be +configured in [](#opt-services.keycloak.database.type). The selected +database will automatically be enabled and a database and role +created unless [](#opt-services.keycloak.database.host) is changed +from its default of `localhost` or +[](#opt-services.keycloak.database.createLocally) is set to `false`. + +External database access can also be configured by setting +[](#opt-services.keycloak.database.host), +[](#opt-services.keycloak.database.name), +[](#opt-services.keycloak.database.username), +[](#opt-services.keycloak.database.useSSL) and +[](#opt-services.keycloak.database.caCert) as +appropriate. Note that you need to manually create the database +and allow the configured database user full access to it. + +[](#opt-services.keycloak.database.passwordFile) +must be set to the path to a file containing the password used +to log in to the database. If [](#opt-services.keycloak.database.host) +and [](#opt-services.keycloak.database.createLocally) +are kept at their defaults, the database role +`keycloak` with that password is provisioned +on the local database instance. + +::: {.warning} +The path should be provided as a string, not a Nix path, since Nix +paths are copied into the world readable Nix store. +::: + +## Hostname {#module-services-keycloak-hostname} + +The hostname is used to build the public URL used as base for +all frontend requests and must be configured through +[](#opt-services.keycloak.settings.hostname). + +::: {.note} +If you're migrating an old Wildfly based Keycloak instance +and want to keep compatibility with your current clients, +you'll likely want to set [](#opt-services.keycloak.settings.http-relative-path) +to `/auth`. See the option description +for more details. +::: + +[](#opt-services.keycloak.settings.hostname-strict-backchannel) +determines whether Keycloak should force all requests to go +through the frontend URL. By default, +Keycloak allows backend requests to +instead use its local hostname or IP address and may also +advertise it to clients through its OpenID Connect Discovery +endpoint. + +For more information on hostname configuration, see the [Hostname +section of the Keycloak Server Installation and Configuration +Guide](https://www.keycloak.org/server/hostname). + +## Setting up TLS/SSL {#module-services-keycloak-tls} + +By default, Keycloak won't accept +unsecured HTTP connections originating from outside its local +network. + +HTTPS support requires a TLS/SSL certificate and a private key, +both [PEM formatted](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail). +Their paths should be set through +[](#opt-services.keycloak.sslCertificate) and +[](#opt-services.keycloak.sslCertificateKey). + +::: {.warning} + The paths should be provided as a strings, not a Nix paths, +since Nix paths are copied into the world readable Nix store. +::: + +## Themes {#module-services-keycloak-themes} + +You can package custom themes and make them visible to +Keycloak through [](#opt-services.keycloak.themes). See the +[Themes section of the Keycloak Server Development Guide]( + https://www.keycloak.org/docs/latest/server_development/#_themes +) and the description of the aforementioned NixOS option for +more information. + +## Configuration file settings {#module-services-keycloak-settings} + +Keycloak server configuration parameters can be set in +[](#opt-services.keycloak.settings). These correspond +directly to options in +{file}`conf/keycloak.conf`. Some of the most +important parameters are documented as suboptions, the rest can +be found in the [All +configuration section of the Keycloak Server Installation and +Configuration Guide](https://www.keycloak.org/server/all-config). + +Options containing secret data should be set to an attribute +set containing the attribute `_secret` - a +string pointing to a file containing the value the option +should be set to. See the description of +[](#opt-services.keycloak.settings) for an example. + +## Example configuration {#module-services-keycloak-example-config} + +A basic configuration with some custom settings could look like this: +``` +services.keycloak = { + enable = true; + settings = { + hostname = "keycloak.example.com"; + hostname-strict-backchannel = true; + }; + initialAdminPassword = "e6Wcm0RrtegMEHl"; # change on first login + sslCertificate = "/run/keys/ssl_cert"; + sslCertificateKey = "/run/keys/ssl_key"; + database.passwordFile = "/run/keys/db_password"; +}; +``` diff --git a/nixos/modules/services/web-apps/keycloak.xml b/nixos/modules/services/web-apps/keycloak.xml index 861756e33ac0..148782d30f39 100644 --- a/nixos/modules/services/web-apps/keycloak.xml +++ b/nixos/modules/services/web-apps/keycloak.xml @@ -1,202 +1,177 @@ - - Keycloak - - Keycloak is an - open source identity and access management server with support for - OpenID - Connect, OAUTH - 2.0 and SAML - 2.0. - -
- Administration - - An administrative user with the username - admin is automatically created in the - master realm. Its initial password can be - configured by setting - and defaults to changeme. The password is - not stored safely and should be changed immediately in the - admin panel. - - - - Refer to the - Keycloak Server Administration Guide for information on - how to administer your Keycloak - instance. - -
- -
- Database access - - Keycloak can be used with either - PostgreSQL, - MariaDB or - MySQL. Which one is used can be - configured in . The selected - database will automatically be enabled and a database and role - created unless is changed - from its default of localhost or is - set to false. - - - - External database access can also be configured by setting - , , , and as - appropriate. Note that you need to manually create the database - and allow the configured database user full access to it. - - - - - must be set to the path to a file containing the password used - to log in to the database. If - and - are kept at their defaults, the database role - keycloak with that password is provisioned - on the local database instance. - - - - - The path should be provided as a string, not a Nix path, since Nix - paths are copied into the world readable Nix store. - - -
- -
- Hostname - - The hostname is used to build the public URL used as base for - all frontend requests and must be configured through . - - - - - If you're migrating an old Wildfly based Keycloak instance - and want to keep compatibility with your current clients, - you'll likely want to set to /auth. See the option description - for more details. - - - - - - determines whether Keycloak should force all requests to go - through the frontend URL. By default, - Keycloak allows backend requests to - instead use its local hostname or IP address and may also - advertise it to clients through its OpenID Connect Discovery - endpoint. - - - - For more information on hostname configuration, see the Hostname - section of the Keycloak Server Installation and Configuration - Guide. - -
- -
- Setting up TLS/SSL - - By default, Keycloak won't accept - unsecured HTTP connections originating from outside its local - network. - - - - HTTPS support requires a TLS/SSL certificate and a private key, - both PEM - formatted. Their paths should be set through and . - - - - - The paths should be provided as a strings, not a Nix paths, - since Nix paths are copied into the world readable Nix store. - - -
- -
- Themes - - You can package custom themes and make them visible to - Keycloak through . See the - Themes section of the Keycloak Server Development Guide - and the description of the aforementioned NixOS option for - more information. - -
- -
- Configuration file settings - - Keycloak server configuration parameters can be set in . These correspond - directly to options in - conf/keycloak.conf. Some of the most - important parameters are documented as suboptions, the rest can - be found in the All - configuration section of the Keycloak Server Installation and - Configuration Guide. - - - - Options containing secret data should be set to an attribute - set containing the attribute _secret - a - string pointing to a file containing the value the option - should be set to. See the description of for an example. - -
- - -
- Example configuration - - A basic configuration with some custom settings could look like this: - + + + Keycloak + + Keycloak is an + open source identity and access management server with support for + OpenID + Connect, OAUTH + 2.0 and + SAML + 2.0. + +
+ Administration + + An administrative user with the username admin + is automatically created in the master realm. + Its initial password can be configured by setting + and + defaults to changeme. The password is not + stored safely and should be changed immediately in the admin + panel. + + + Refer to the + Keycloak + Server Administration Guide for information on how to + administer your Keycloak instance. + +
+
+ Database access + + Keycloak can be used with either PostgreSQL, MariaDB or MySQL. + Which one is used can be configured in + . The + selected database will automatically be enabled and a database and + role created unless + is changed + from its default of localhost or + is + set to false. + + + External database access can also be configured by setting + , + , + , + and + as + appropriate. Note that you need to manually create the database + and allow the configured database user full access to it. + + + + must be set to the path to a file containing the password used to + log in to the database. If + and + + are kept at their defaults, the database role + keycloak with that password is provisioned on + the local database instance. + + + + The path should be provided as a string, not a Nix path, since + Nix paths are copied into the world readable Nix store. + + +
+
+ Hostname + + The hostname is used to build the public URL used as base for all + frontend requests and must be configured through + . + + + + If you’re migrating an old Wildfly based Keycloak instance and + want to keep compatibility with your current clients, you’ll + likely want to set + + to /auth. See the option description for more + details. + + + + + determines whether Keycloak should force all requests to go + through the frontend URL. By default, Keycloak allows backend + requests to instead use its local hostname or IP address and may + also advertise it to clients through its OpenID Connect Discovery + endpoint. + + + For more information on hostname configuration, see the + Hostname + section of the Keycloak Server Installation and Configuration + Guide. + +
+
+ Setting up TLS/SSL + + By default, Keycloak won’t accept unsecured HTTP connections + originating from outside its local network. + + + HTTPS support requires a TLS/SSL certificate and a private key, + both + PEM + formatted. Their paths should be set through + and + . + + + + The paths should be provided as a strings, not a Nix paths, + since Nix paths are copied into the world readable Nix store. + + +
+
+ Themes + + You can package custom themes and make them visible to Keycloak + through . See the + Themes + section of the Keycloak Server Development Guide and the + description of the aforementioned NixOS option for more + information. + +
+
+ Configuration file settings + + Keycloak server configuration parameters can be set in + . These + correspond directly to options in + conf/keycloak.conf. Some of the most + important parameters are documented as suboptions, the rest can be + found in the + All + configuration section of the Keycloak Server Installation and + Configuration Guide. + + + Options containing secret data should be set to an attribute set + containing the attribute _secret - a string + pointing to a file containing the value the option should be set + to. See the description of + for an example. + +
+
+ Example configuration + + A basic configuration with some custom settings could look like + this: + + services.keycloak = { - enable = true; + enable = true; settings = { - hostname = "keycloak.example.com"; - hostname-strict-backchannel = true; + hostname = "keycloak.example.com"; + hostname-strict-backchannel = true; }; - initialAdminPassword = "e6Wcm0RrtegMEHl"; # change on first login - sslCertificate = "/run/keys/ssl_cert"; - sslCertificateKey = "/run/keys/ssl_key"; - database.passwordFile = "/run/keys/db_password"; + initialAdminPassword = "e6Wcm0RrtegMEHl"; # change on first login + sslCertificate = "/run/keys/ssl_cert"; + sslCertificateKey = "/run/keys/ssl_key"; + database.passwordFile = "/run/keys/db_password"; }; - - -
-
+
+
diff --git a/nixos/modules/services/web-apps/lemmy.nix b/nixos/modules/services/web-apps/lemmy.nix index 267584dd0ca7..f2eb6e726b90 100644 --- a/nixos/modules/services/web-apps/lemmy.nix +++ b/nixos/modules/services/web-apps/lemmy.nix @@ -6,8 +6,6 @@ let in { meta.maintainers = with maintainers; [ happysalada ]; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc lemmy.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > lemmy.xml` meta.doc = ./lemmy.xml; imports = [ diff --git a/nixos/modules/services/web-apps/lemmy.xml b/nixos/modules/services/web-apps/lemmy.xml index f04316b3c515..114e11f3488a 100644 --- a/nixos/modules/services/web-apps/lemmy.xml +++ b/nixos/modules/services/web-apps/lemmy.xml @@ -1,3 +1,5 @@ + Lemmy diff --git a/nixos/modules/services/web-apps/matomo-doc.xml b/nixos/modules/services/web-apps/matomo-doc.xml deleted file mode 100644 index 69d1170e4523..000000000000 --- a/nixos/modules/services/web-apps/matomo-doc.xml +++ /dev/null @@ -1,107 +0,0 @@ - - Matomo - - Matomo is a real-time web analytics application. This module configures - php-fpm as backend for Matomo, optionally configuring an nginx vhost as well. - - - An automatic setup is not suported by Matomo, so you need to configure Matomo - itself in the browser-based Matomo setup. - -
- Database Setup - - - You also need to configure a MariaDB or MySQL database and -user for Matomo - yourself, and enter those credentials in your browser. You can use - passwordless database authentication via the UNIX_SOCKET authentication - plugin with the following SQL commands: - -# For MariaDB -INSTALL PLUGIN unix_socket SONAME 'auth_socket'; -CREATE DATABASE matomo; -CREATE USER 'matomo'@'localhost' IDENTIFIED WITH unix_socket; -GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; - -# For MySQL -INSTALL PLUGIN auth_socket SONAME 'auth_socket.so'; -CREATE DATABASE matomo; -CREATE USER 'matomo'@'localhost' IDENTIFIED WITH auth_socket; -GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; - - Then fill in matomo as database user and database name, - and leave the password field blank. This authentication works by allowing - only the matomo unix user to authenticate as the - matomo database user (without needing a password), but no - other users. For more information on passwordless login, see - . - - - - Of course, you can use password based authentication as well, e.g. when the - database is not on the same host. - -
-
- Archive Processing - - - This module comes with the systemd service - matomo-archive-processing.service and a timer that - automatically triggers archive processing every hour. This means that you - can safely - - disable browser triggers for Matomo archiving at - Administration > System > General Settings. - - - - With automatic archive processing, you can now also enable to - - delete old visitor logs at Administration > System > - Privacy, but make sure that you run systemctl start - matomo-archive-processing.service at least once without errors if - you have already collected data before, so that the reports get archived - before the source data gets deleted. - -
-
- Backup - - - You only need to take backups of your MySQL database and the - /var/lib/matomo/config/config.ini.php file. Use a user - in the matomo group or root to access the file. For more - information, see - . - -
-
- Issues - - - - - Matomo will warn you that the JavaScript tracker is not writable. This is - because it's located in the read-only nix store. You can safely ignore - this, unless you need a plugin that needs JavaScript tracker access. - - - -
-
- Using other Web Servers than nginx - - - You can use other web servers by forwarding calls for - index.php and piwik.php to the - services.phpfpm.pools.<name>.socket fastcgi unix socket. You can use - the nginx configuration in the module code as a reference to what else - should be configured. - -
-
diff --git a/nixos/modules/services/web-apps/matomo.md b/nixos/modules/services/web-apps/matomo.md new file mode 100644 index 000000000000..f5536a35f7a8 --- /dev/null +++ b/nixos/modules/services/web-apps/matomo.md @@ -0,0 +1,77 @@ +# Matomo {#module-services-matomo} + +Matomo is a real-time web analytics application. This module configures +php-fpm as backend for Matomo, optionally configuring an nginx vhost as well. + +An automatic setup is not suported by Matomo, so you need to configure Matomo +itself in the browser-based Matomo setup. + +## Database Setup {#module-services-matomo-database-setup} + +You also need to configure a MariaDB or MySQL database and -user for Matomo +yourself, and enter those credentials in your browser. You can use +passwordless database authentication via the UNIX_SOCKET authentication +plugin with the following SQL commands: +``` +# For MariaDB +INSTALL PLUGIN unix_socket SONAME 'auth_socket'; +CREATE DATABASE matomo; +CREATE USER 'matomo'@'localhost' IDENTIFIED WITH unix_socket; +GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; + +# For MySQL +INSTALL PLUGIN auth_socket SONAME 'auth_socket.so'; +CREATE DATABASE matomo; +CREATE USER 'matomo'@'localhost' IDENTIFIED WITH auth_socket; +GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; +``` +Then fill in `matomo` as database user and database name, +and leave the password field blank. This authentication works by allowing +only the `matomo` unix user to authenticate as the +`matomo` database user (without needing a password), but no +other users. For more information on passwordless login, see +. + +Of course, you can use password based authentication as well, e.g. when the +database is not on the same host. + +## Archive Processing {#module-services-matomo-archive-processing} + +This module comes with the systemd service +`matomo-archive-processing.service` and a timer that +automatically triggers archive processing every hour. This means that you +can safely +[disable browser triggers for Matomo archiving]( +https://matomo.org/docs/setup-auto-archiving/#disable-browser-triggers-for-matomo-archiving-and-limit-matomo-reports-to-updating-every-hour +) at +`Administration > System > General Settings`. + +With automatic archive processing, you can now also enable to +[delete old visitor logs](https://matomo.org/docs/privacy/#step-2-delete-old-visitors-logs) +at `Administration > System > Privacy`, but make sure that you run `systemctl start +matomo-archive-processing.service` at least once without errors if +you have already collected data before, so that the reports get archived +before the source data gets deleted. + +## Backup {#module-services-matomo-backups} + +You only need to take backups of your MySQL database and the +{file}`/var/lib/matomo/config/config.ini.php` file. Use a user +in the `matomo` group or root to access the file. For more +information, see +. + +## Issues {#module-services-matomo-issues} + + - Matomo will warn you that the JavaScript tracker is not writable. This is + because it's located in the read-only nix store. You can safely ignore + this, unless you need a plugin that needs JavaScript tracker access. + +## Using other Web Servers than nginx {#module-services-matomo-other-web-servers} + +You can use other web servers by forwarding calls for +{file}`index.php` and {file}`piwik.php` to the +[`services.phpfpm.pools..socket`](#opt-services.phpfpm.pools._name_.socket) +fastcgi unix socket. You can use +the nginx configuration in the module code as a reference to what else +should be configured. diff --git a/nixos/modules/services/web-apps/matomo.nix b/nixos/modules/services/web-apps/matomo.nix index 0435d21ce8a2..984510659952 100644 --- a/nixos/modules/services/web-apps/matomo.nix +++ b/nixos/modules/services/web-apps/matomo.nix @@ -325,7 +325,7 @@ in { }; meta = { - doc = ./matomo-doc.xml; + doc = ./matomo.xml; maintainers = with lib.maintainers; [ florianjacob ]; }; } diff --git a/nixos/modules/services/web-apps/matomo.xml b/nixos/modules/services/web-apps/matomo.xml new file mode 100644 index 000000000000..30994cc9f1da --- /dev/null +++ b/nixos/modules/services/web-apps/matomo.xml @@ -0,0 +1,107 @@ + + + Matomo + + Matomo is a real-time web analytics application. This module + configures php-fpm as backend for Matomo, optionally configuring an + nginx vhost as well. + + + An automatic setup is not suported by Matomo, so you need to + configure Matomo itself in the browser-based Matomo setup. + +
+ Database Setup + + You also need to configure a MariaDB or MySQL database and -user + for Matomo yourself, and enter those credentials in your browser. + You can use passwordless database authentication via the + UNIX_SOCKET authentication plugin with the following SQL commands: + + +# For MariaDB +INSTALL PLUGIN unix_socket SONAME 'auth_socket'; +CREATE DATABASE matomo; +CREATE USER 'matomo'@'localhost' IDENTIFIED WITH unix_socket; +GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; + +# For MySQL +INSTALL PLUGIN auth_socket SONAME 'auth_socket.so'; +CREATE DATABASE matomo; +CREATE USER 'matomo'@'localhost' IDENTIFIED WITH auth_socket; +GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost'; + + + Then fill in matomo as database user and + database name, and leave the password field blank. This + authentication works by allowing only the + matomo unix user to authenticate as the + matomo database user (without needing a + password), but no other users. For more information on + passwordless login, see + https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin/. + + + Of course, you can use password based authentication as well, e.g. + when the database is not on the same host. + +
+
+ Archive Processing + + This module comes with the systemd service + matomo-archive-processing.service and a timer + that automatically triggers archive processing every hour. This + means that you can safely + disable + browser triggers for Matomo archiving at + Administration > System > General Settings. + + + With automatic archive processing, you can now also enable to + delete + old visitor logs at + Administration > System > Privacy, but + make sure that you run + systemctl start matomo-archive-processing.service + at least once without errors if you have already collected data + before, so that the reports get archived before the source data + gets deleted. + +
+
+ Backup + + You only need to take backups of your MySQL database and the + /var/lib/matomo/config/config.ini.php file. + Use a user in the matomo group or root to + access the file. For more information, see + https://matomo.org/faq/how-to-install/faq_138/. + +
+
+ Issues + + + + Matomo will warn you that the JavaScript tracker is not + writable. This is because it’s located in the read-only nix + store. You can safely ignore this, unless you need a plugin + that needs JavaScript tracker access. + + + +
+
+ Using other Web Servers than nginx + + You can use other web servers by forwarding calls for + index.php and piwik.php + to the + services.phpfpm.pools.<name>.socket + fastcgi unix socket. You can use the nginx configuration in the + module code as a reference to what else should be configured. + +
+
diff --git a/nixos/modules/services/web-apps/nextcloud.md b/nixos/modules/services/web-apps/nextcloud.md new file mode 100644 index 000000000000..014807f3da23 --- /dev/null +++ b/nixos/modules/services/web-apps/nextcloud.md @@ -0,0 +1,237 @@ +# Nextcloud {#module-services-nextcloud} + +[Nextcloud](https://nextcloud.com/) is an open-source, +self-hostable cloud platform. The server setup can be automated using +[services.nextcloud](#opt-services.nextcloud.enable). A +desktop client is packaged at `pkgs.nextcloud-client`. + +The current default by NixOS is `nextcloud25` which is also the latest +major version available. + +## Basic usage {#module-services-nextcloud-basic-usage} + +Nextcloud is a PHP-based application which requires an HTTP server +([`services.nextcloud`](#opt-services.nextcloud.enable) +optionally supports +[`services.nginx`](#opt-services.nginx.enable)) +and a database (it's recommended to use +[`services.postgresql`](#opt-services.postgresql.enable)). + +A very basic configuration may look like this: +``` +{ pkgs, ... }: +{ + services.nextcloud = { + enable = true; + hostName = "nextcloud.tld"; + config = { + dbtype = "pgsql"; + dbuser = "nextcloud"; + dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself + dbname = "nextcloud"; + adminpassFile = "/path/to/admin-pass-file"; + adminuser = "root"; + }; + }; + + services.postgresql = { + enable = true; + ensureDatabases = [ "nextcloud" ]; + ensureUsers = [ + { name = "nextcloud"; + ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; + } + ]; + }; + + # ensure that postgres is running *before* running the setup + systemd.services."nextcloud-setup" = { + requires = ["postgresql.service"]; + after = ["postgresql.service"]; + }; + + networking.firewall.allowedTCPPorts = [ 80 443 ]; +} +``` + +The `hostName` option is used internally to configure an HTTP +server using [`PHP-FPM`](https://php-fpm.org/) +and `nginx`. The `config` attribute set is +used by the imperative installer and all values are written to an additional file +to ensure that changes can be applied by changing the module's options. + +In case the application serves multiple domains (those are checked with +[`$_SERVER['HTTP_HOST']`](http://php.net/manual/en/reserved.variables.server.php)) +it's needed to add them to +[`services.nextcloud.config.extraTrustedDomains`](#opt-services.nextcloud.config.extraTrustedDomains). + +Auto updates for Nextcloud apps can be enabled using +[`services.nextcloud.autoUpdateApps`](#opt-services.nextcloud.autoUpdateApps.enable). + +## Common problems {#module-services-nextcloud-pitfalls-during-upgrade} + + - **General notes.** + Unfortunately Nextcloud appears to be very stateful when it comes to + managing its own configuration. The config file lives in the home directory + of the `nextcloud` user (by default + `/var/lib/nextcloud/config/config.php`) and is also used to + track several states of the application (e.g., whether installed or not). + + All configuration parameters are also stored in + {file}`/var/lib/nextcloud/config/override.config.php` which is generated by + the module and linked from the store to ensure that all values from + {file}`config.php` can be modified by the module. + However {file}`config.php` manages the application's state and shouldn't be + touched manually because of that. + + ::: {.warning} + Don't delete {file}`config.php`! This file + tracks the application's state and a deletion can cause unwanted + side-effects! + ::: + + ::: {.warning} + Don't rerun `nextcloud-occ maintenance:install`! + This command tries to install the application + and can cause unwanted side-effects! + ::: + - **Multiple version upgrades.** + Nextcloud doesn't allow to move more than one major-version forward. E.g., if you're on + `v16`, you cannot upgrade to `v18`, you need to upgrade to + `v17` first. This is ensured automatically as long as the + [stateVersion](#opt-system.stateVersion) is declared properly. In that case + the oldest version available (one major behind the one from the previous NixOS + release) will be selected by default and the module will generate a warning that reminds + the user to upgrade to latest Nextcloud *after* that deploy. + - **`Error: Command "upgrade" is not defined.`** + This error usually occurs if the initial installation + ({command}`nextcloud-occ maintenance:install`) has failed. After that, the application + is not installed, but the upgrade is attempted to be executed. Further context can + be found in [NixOS/nixpkgs#111175](https://github.com/NixOS/nixpkgs/issues/111175). + + First of all, it makes sense to find out what went wrong by looking at the logs + of the installation via {command}`journalctl -u nextcloud-setup` and try to fix + the underlying issue. + + - If this occurs on an *existing* setup, this is most likely because + the maintenance mode is active. It can be deactivated by running + {command}`nextcloud-occ maintenance:mode --off`. It's advisable though to + check the logs first on why the maintenance mode was activated. + - ::: {.warning} + Only perform the following measures on + *freshly installed instances!* + ::: + + A re-run of the installer can be forced by *deleting* + {file}`/var/lib/nextcloud/config/config.php`. This is the only time + advisable because the fresh install doesn't have any state that can be lost. + In case that doesn't help, an entire re-creation can be forced via + {command}`rm -rf ~nextcloud/`. + + - **Server-side encryption.** + Nextcloud supports [server-side encryption (SSE)](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/encryption_configuration.html). + This is not an end-to-end encryption, but can be used to encrypt files that will be persisted + to external storage such as S3. Please note that this won't work anymore when using OpenSSL 3 + for PHP's openssl extension because this is implemented using the legacy cipher RC4. + If [](#opt-system.stateVersion) is *above* `22.05`, + this is disabled by default. To turn it on again and for further information please refer to + [](#opt-services.nextcloud.enableBrokenCiphersForSSE). + +## Using an alternative webserver as reverse-proxy (e.g. `httpd`) {#module-services-nextcloud-httpd} + +By default, `nginx` is used as reverse-proxy for `nextcloud`. +However, it's possible to use e.g. `httpd` by explicitly disabling +`nginx` using [](#opt-services.nginx.enable) and fixing the +settings `listen.owner` & `listen.group` in the +[corresponding `phpfpm` pool](#opt-services.phpfpm.pools). + +An exemplary configuration may look like this: +``` +{ config, lib, pkgs, ... }: { + services.nginx.enable = false; + services.nextcloud = { + enable = true; + hostName = "localhost"; + + /* further, required options */ + }; + services.phpfpm.pools.nextcloud.settings = { + "listen.owner" = config.services.httpd.user; + "listen.group" = config.services.httpd.group; + }; + services.httpd = { + enable = true; + adminAddr = "webmaster@localhost"; + extraModules = [ "proxy_fcgi" ]; + virtualHosts."localhost" = { + documentRoot = config.services.nextcloud.package; + extraConfig = '' + + + + SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/" + + + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.php$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.php [L] + + DirectoryIndex index.php + Require all granted + Options +FollowSymLinks + + ''; + }; + }; +} +``` + +## Installing Apps and PHP extensions {#installing-apps-php-extensions-nextcloud} + +Nextcloud apps are installed statefully through the web interface. +Some apps may require extra PHP extensions to be installed. +This can be configured with the [](#opt-services.nextcloud.phpExtraExtensions) setting. + +Alternatively, extra apps can also be declared with the [](#opt-services.nextcloud.extraApps) setting. +When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps +that are managed by Nix. If you want automatic updates it is recommended that you use web interface to install apps. + +## Maintainer information {#module-services-nextcloud-maintainer-info} + +As stated in the previous paragraph, we must provide a clean upgrade-path for Nextcloud +since it cannot move more than one major version forward on a single upgrade. This chapter +adds some notes how Nextcloud updates should be rolled out in the future. + +While minor and patch-level updates are no problem and can be done directly in the +package-expression (and should be backported to supported stable branches after that), +major-releases should be added in a new attribute (e.g. Nextcloud `v19.0.0` +should be available in `nixpkgs` as `pkgs.nextcloud19`). +To provide simple upgrade paths it's generally useful to backport those as well to stable +branches. As long as the package-default isn't altered, this won't break existing setups. +After that, the versioning-warning in the `nextcloud`-module should be +updated to make sure that the +[package](#opt-services.nextcloud.package)-option selects the latest version +on fresh setups. + +If major-releases will be abandoned by upstream, we should check first if those are needed +in NixOS for a safe upgrade-path before removing those. In that case we should keep those +packages, but mark them as insecure in an expression like this (in +``): +``` +/* ... */ +{ + nextcloud17 = generic { + version = "17.0.x"; + sha256 = "0000000000000000000000000000000000000000000000000000"; + eol = true; + }; +} +``` + +Ideally we should make sure that it's possible to jump two NixOS versions forward: +i.e. the warnings and the logic in the module should guard a user to upgrade from a +Nextcloud on e.g. 19.09 to a Nextcloud on 20.09. diff --git a/nixos/modules/services/web-apps/nextcloud.xml b/nixos/modules/services/web-apps/nextcloud.xml index 4207c4008d5b..a5ac05723ef4 100644 --- a/nixos/modules/services/web-apps/nextcloud.xml +++ b/nixos/modules/services/web-apps/nextcloud.xml @@ -1,226 +1,249 @@ - - Nextcloud - - Nextcloud is an open-source, - self-hostable cloud platform. The server setup can be automated using - services.nextcloud. A - desktop client is packaged at pkgs.nextcloud-client. - - - The current default by NixOS is nextcloud25 which is also the latest - major version available. - -
- Basic usage - + + + Nextcloud - Nextcloud is a PHP-based application which requires an HTTP server - (services.nextcloud - optionally supports - services.nginx) - and a database (it's recommended to use - services.postgresql). + Nextcloud is an + open-source, self-hostable cloud platform. The server setup can be + automated using + services.nextcloud. + A desktop client is packaged at + pkgs.nextcloud-client. - - A very basic configuration may look like this: -{ pkgs, ... }: + The current default by NixOS is nextcloud25 which + is also the latest major version available. + +
+ Basic usage + + Nextcloud is a PHP-based application which requires an HTTP server + (services.nextcloud + optionally supports + services.nginx) + and a database (it’s recommended to use + services.postgresql). + + + A very basic configuration may look like this: + + +{ pkgs, ... }: { services.nextcloud = { - enable = true; - hostName = "nextcloud.tld"; + enable = true; + hostName = "nextcloud.tld"; config = { - dbtype = "pgsql"; - dbuser = "nextcloud"; - dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself - dbname = "nextcloud"; - adminpassFile = "/path/to/admin-pass-file"; - adminuser = "root"; + dbtype = "pgsql"; + dbuser = "nextcloud"; + dbhost = "/run/postgresql"; # nextcloud will add /.s.PGSQL.5432 by itself + dbname = "nextcloud"; + adminpassFile = "/path/to/admin-pass-file"; + adminuser = "root"; }; }; services.postgresql = { - enable = true; - ensureDatabases = [ "nextcloud" ]; - ensureUsers = [ - { name = "nextcloud"; - ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; + enable = true; + ensureDatabases = [ "nextcloud" ]; + ensureUsers = [ + { name = "nextcloud"; + ensurePermissions."DATABASE nextcloud" = "ALL PRIVILEGES"; } ]; }; # ensure that postgres is running *before* running the setup - systemd.services."nextcloud-setup" = { - requires = ["postgresql.service"]; - after = ["postgresql.service"]; + systemd.services."nextcloud-setup" = { + requires = ["postgresql.service"]; + after = ["postgresql.service"]; }; - networking.firewall.allowedTCPPorts = [ 80 443 ]; -} - - - - The hostName option is used internally to configure an HTTP - server using PHP-FPM - and nginx. The config attribute set is - used by the imperative installer and all values are written to an additional file - to ensure that changes can be applied by changing the module's options. - - - - In case the application serves multiple domains (those are checked with - $_SERVER['HTTP_HOST']) - it's needed to add them to - services.nextcloud.config.extraTrustedDomains. - - - - Auto updates for Nextcloud apps can be enabled using - services.nextcloud.autoUpdateApps. - - -
- -
- Common problems - - - - General notes - - Unfortunately Nextcloud appears to be very stateful when it comes to - managing its own configuration. The config file lives in the home directory - of the nextcloud user (by default - /var/lib/nextcloud/config/config.php) and is also used to - track several states of the application (e.g., whether installed or not). - - + networking.firewall.allowedTCPPorts = [ 80 443 ]; +} + - All configuration parameters are also stored in - /var/lib/nextcloud/config/override.config.php which is generated by - the module and linked from the store to ensure that all values from - config.php can be modified by the module. - However config.php manages the application's state and shouldn't be - touched manually because of that. + The hostName option is used internally to + configure an HTTP server using + PHP-FPM + and nginx. The config + attribute set is used by the imperative installer and all values + are written to an additional file to ensure that changes can be + applied by changing the module’s options. - - Don't delete config.php! This file - tracks the application's state and a deletion can cause unwanted - side-effects! - - - - Don't rerun nextcloud-occ - maintenance:install! This command tries to install the application - and can cause unwanted side-effects! - - - - - Multiple version upgrades - - Nextcloud doesn't allow to move more than one major-version forward. E.g., if you're on - v16, you cannot upgrade to v18, you need to upgrade to - v17 first. This is ensured automatically as long as the - stateVersion is declared properly. In that case - the oldest version available (one major behind the one from the previous NixOS - release) will be selected by default and the module will generate a warning that reminds - the user to upgrade to latest Nextcloud after that deploy. - - - - - - <literal>Error: Command "upgrade" is not defined.</literal> - - This error usually occurs if the initial installation - (nextcloud-occ maintenance:install) has failed. After that, the application - is not installed, but the upgrade is attempted to be executed. Further context can - be found in NixOS/nixpkgs#111175. - - - First of all, it makes sense to find out what went wrong by looking at the logs - of the installation via journalctl -u nextcloud-setup and try to fix - the underlying issue. + In case the application serves multiple domains (those are checked + with + $_SERVER['HTTP_HOST']) + it’s needed to add them to + services.nextcloud.config.extraTrustedDomains. + + Auto updates for Nextcloud apps can be enabled using + services.nextcloud.autoUpdateApps. + +
+
+ Common problems - - - If this occurs on an existing setup, this is most likely because - the maintenance mode is active. It can be deactivated by running - nextcloud-occ maintenance:mode --off. It's advisable though to - check the logs first on why the maintenance mode was activated. - - - - Only perform the following measures on - freshly installed instances! - - A re-run of the installer can be forced by deleting - /var/lib/nextcloud/config/config.php. This is the only time - advisable because the fresh install doesn't have any state that can be lost. - In case that doesn't help, an entire re-creation can be forced via - rm -rf ~nextcloud/. - - + + + General notes. + Unfortunately Nextcloud appears to be very stateful when it + comes to managing its own configuration. The config file lives + in the home directory of the nextcloud user + (by default + /var/lib/nextcloud/config/config.php) and + is also used to track several states of the application (e.g., + whether installed or not). + + + All configuration parameters are also stored in + /var/lib/nextcloud/config/override.config.php + which is generated by the module and linked from the store to + ensure that all values from config.php + can be modified by the module. However + config.php manages the application’s + state and shouldn’t be touched manually because of that. + + + + Don’t delete config.php! This file + tracks the application’s state and a deletion can cause + unwanted side-effects! + + + + + Don’t rerun + nextcloud-occ maintenance:install! This + command tries to install the application and can cause + unwanted side-effects! + + + + + + Multiple version upgrades. + Nextcloud doesn’t allow to move more than one major-version + forward. E.g., if you’re on v16, you cannot + upgrade to v18, you need to upgrade to + v17 first. This is ensured automatically as + long as the + stateVersion is + declared properly. In that case the oldest version available + (one major behind the one from the previous NixOS release) + will be selected by default and the module will generate a + warning that reminds the user to upgrade to latest Nextcloud + after that deploy. + + + + + Error: Command "upgrade" is not defined. + This error usually occurs if the initial installation + (nextcloud-occ maintenance:install) has + failed. After that, the application is not installed, but the + upgrade is attempted to be executed. Further context can be + found in + NixOS/nixpkgs#111175. + + + First of all, it makes sense to find out what went wrong by + looking at the logs of the installation via + journalctl -u nextcloud-setup and try to + fix the underlying issue. + + + + + If this occurs on an existing setup, + this is most likely because the maintenance mode is + active. It can be deactivated by running + nextcloud-occ maintenance:mode --off. + It’s advisable though to check the logs first on why the + maintenance mode was activated. + + + + + + Only perform the following measures on freshly + installed instances! + + + + A re-run of the installer can be forced by + deleting + /var/lib/nextcloud/config/config.php. + This is the only time advisable because the fresh install + doesn’t have any state that can be lost. In case that + doesn’t help, an entire re-creation can be forced via + rm -rf ~nextcloud/. + + + + + + + Server-side encryption. + Nextcloud supports + server-side + encryption (SSE). This is not an end-to-end encryption, + but can be used to encrypt files that will be persisted to + external storage such as S3. Please note that this won’t work + anymore when using OpenSSL 3 for PHP’s openssl extension + because this is implemented using the legacy cipher RC4. If + is + above 22.05, this is + disabled by default. To turn it on again and for further + information please refer to + . + + - - - - Server-side encryption - - Nextcloud supports server-side encryption (SSE). - This is not an end-to-end encryption, but can be used to encrypt files that will be persisted - to external storage such as S3. Please note that this won't work anymore when using OpenSSL 3 - for PHP's openssl extension because this is implemented using the legacy cipher RC4. - If is above 22.05, - this is disabled by default. To turn it on again and for further information please refer to - . - - - - -
- -
- Using an alternative webserver as reverse-proxy (e.g. <literal>httpd</literal>) - - By default, nginx is used as reverse-proxy for nextcloud. - However, it's possible to use e.g. httpd by explicitly disabling - nginx using and fixing the - settings listen.owner & listen.group in the - corresponding phpfpm pool. - - - An exemplary configuration may look like this: -{ config, lib, pkgs, ... }: { - services.nginx.enable = false; +
+
+ Using an alternative webserver as reverse-proxy (e.g. + <literal>httpd</literal>) + + By default, nginx is used as reverse-proxy for + nextcloud. However, it’s possible to use e.g. + httpd by explicitly disabling + nginx using + and fixing the + settings listen.owner & + listen.group in the + corresponding + phpfpm pool. + + + An exemplary configuration may look like this: + + +{ config, lib, pkgs, ... }: { + services.nginx.enable = false; services.nextcloud = { - enable = true; - hostName = "localhost"; + enable = true; + hostName = "localhost"; /* further, required options */ }; - services.phpfpm.pools.nextcloud.settings = { - "listen.owner" = config.services.httpd.user; - "listen.group" = config.services.httpd.group; + services.phpfpm.pools.nextcloud.settings = { + "listen.owner" = config.services.httpd.user; + "listen.group" = config.services.httpd.group; }; services.httpd = { - enable = true; - adminAddr = "webmaster@localhost"; - extraModules = [ "proxy_fcgi" ]; - virtualHosts."localhost" = { - documentRoot = config.services.nextcloud.package; - extraConfig = '' - <Directory "${config.services.nextcloud.package}"> - <FilesMatch "\.php$"> - <If "-f %{REQUEST_FILENAME}"> - SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/" + enable = true; + adminAddr = "webmaster@localhost"; + extraModules = [ "proxy_fcgi" ]; + virtualHosts."localhost" = { + documentRoot = config.services.nextcloud.package; + extraConfig = '' + <Directory "${config.services.nextcloud.package}"> + <FilesMatch "\.php$"> + <If "-f %{REQUEST_FILENAME}"> + SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/" </If> </FilesMatch> <IfModule mod_rewrite.c> @@ -238,68 +261,73 @@ ''; }; }; -} - -
- -
- Installing Apps and PHP extensions - - - Nextcloud apps are installed statefully through the web interface. - - Some apps may require extra PHP extensions to be installed. - This can be configured with the setting. - - - - Alternatively, extra apps can also be declared with the setting. - When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps - that are managed by Nix. If you want automatic updates it is recommended that you use web interface to install apps. - -
- -
- Maintainer information - - - As stated in the previous paragraph, we must provide a clean upgrade-path for Nextcloud - since it cannot move more than one major version forward on a single upgrade. This chapter - adds some notes how Nextcloud updates should be rolled out in the future. - - - - While minor and patch-level updates are no problem and can be done directly in the - package-expression (and should be backported to supported stable branches after that), - major-releases should be added in a new attribute (e.g. Nextcloud v19.0.0 - should be available in nixpkgs as pkgs.nextcloud19). - To provide simple upgrade paths it's generally useful to backport those as well to stable - branches. As long as the package-default isn't altered, this won't break existing setups. - After that, the versioning-warning in the nextcloud-module should be - updated to make sure that the - package-option selects the latest version - on fresh setups. - - - - If major-releases will be abandoned by upstream, we should check first if those are needed - in NixOS for a safe upgrade-path before removing those. In that case we should keep those - packages, but mark them as insecure in an expression like this (in - <nixpkgs/pkgs/servers/nextcloud/default.nix>): -/* ... */ +} + +
+
+ Installing Apps and PHP extensions + + Nextcloud apps are installed statefully through the web interface. + Some apps may require extra PHP extensions to be installed. This + can be configured with the + + setting. + + + Alternatively, extra apps can also be declared with the + setting. When + using this setting, apps can no longer be managed statefully + because this can lead to Nextcloud updating apps that are managed + by Nix. If you want automatic updates it is recommended that you + use web interface to install apps. + +
+
+ Maintainer information + + As stated in the previous paragraph, we must provide a clean + upgrade-path for Nextcloud since it cannot move more than one + major version forward on a single upgrade. This chapter adds some + notes how Nextcloud updates should be rolled out in the future. + + + While minor and patch-level updates are no problem and can be done + directly in the package-expression (and should be backported to + supported stable branches after that), major-releases should be + added in a new attribute (e.g. Nextcloud + v19.0.0 should be available in + nixpkgs as + pkgs.nextcloud19). To provide simple upgrade + paths it’s generally useful to backport those as well to stable + branches. As long as the package-default isn’t altered, this won’t + break existing setups. After that, the versioning-warning in the + nextcloud-module should be updated to make sure + that the + package-option + selects the latest version on fresh setups. + + + If major-releases will be abandoned by upstream, we should check + first if those are needed in NixOS for a safe upgrade-path before + removing those. In that case we should keep those packages, but + mark them as insecure in an expression like this (in + <nixpkgs/pkgs/servers/nextcloud/default.nix>): + + +/* ... */ { nextcloud17 = generic { - version = "17.0.x"; - sha256 = "0000000000000000000000000000000000000000000000000000"; + version = "17.0.x"; + sha256 = "0000000000000000000000000000000000000000000000000000"; eol = true; }; -} - - - - Ideally we should make sure that it's possible to jump two NixOS versions forward: - i.e. the warnings and the logic in the module should guard a user to upgrade from a - Nextcloud on e.g. 19.09 to a Nextcloud on 20.09. - -
+} + + + Ideally we should make sure that it’s possible to jump two NixOS + versions forward: i.e. the warnings and the logic in the module + should guard a user to upgrade from a Nextcloud on e.g. 19.09 to a + Nextcloud on 20.09. + +
diff --git a/nixos/modules/services/web-apps/pict-rs.md b/nixos/modules/services/web-apps/pict-rs.md index 4b622049909d..2fa6bb3aebce 100644 --- a/nixos/modules/services/web-apps/pict-rs.md +++ b/nixos/modules/services/web-apps/pict-rs.md @@ -15,6 +15,7 @@ this will start the http server on port 8080 by default. ## Usage {#module-services-pict-rs-usage} pict-rs offers the following endpoints: + - `POST /image` for uploading an image. Uploaded content must be valid multipart/form-data with an image array located within the `images[]` key diff --git a/nixos/modules/services/web-apps/pict-rs.nix b/nixos/modules/services/web-apps/pict-rs.nix index ee9ff9b484f6..ad07507ca37d 100644 --- a/nixos/modules/services/web-apps/pict-rs.nix +++ b/nixos/modules/services/web-apps/pict-rs.nix @@ -5,8 +5,6 @@ let in { meta.maintainers = with maintainers; [ happysalada ]; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc pict-rs.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > pict-rs.xml` meta.doc = ./pict-rs.xml; options.services.pict-rs = { diff --git a/nixos/modules/services/web-apps/pict-rs.xml b/nixos/modules/services/web-apps/pict-rs.xml index bf129f5cc2ac..3f5900c55f15 100644 --- a/nixos/modules/services/web-apps/pict-rs.xml +++ b/nixos/modules/services/web-apps/pict-rs.xml @@ -1,3 +1,5 @@ + Pict-rs @@ -8,7 +10,7 @@ the minimum to start pict-rs is - + services.pict-rs.enable = true; @@ -18,14 +20,20 @@ services.pict-rs.enable = true;
Usage - pict-rs offers the following endpoints: - - POST /image for uploading an image. Uploaded - content must be valid multipart/form-data with an image array - located within the images[] key + pict-rs offers the following endpoints: - -This endpoint returns the following JSON structure on success with a 201 Created status -```json + + + + POST /image for uploading an image. + Uploaded content must be valid multipart/form-data with an + image array located within the images[] key + + + This endpoint returns the following JSON structure on success + with a 201 Created status + + { "files": [ { @@ -43,9 +51,8 @@ This endpoint returns the following JSON structure on success with a 201 Created ], "msg": "ok" } -``` - + GET /image/download?url=... Download an @@ -66,8 +73,20 @@ This endpoint returns the following JSON structure on success with a 201 Created GET /image/details/original/{file} for getting the details of a full-resolution image. The returned JSON is structured like so: - json { "width": 800, "height": 537, "content_type": "image/webp", "created_at": [ 2020, 345, 67376, 394363487 ] } + +{ + "width": 800, + "height": 537, + "content_type": "image/webp", + "created_at": [ + 2020, + 345, + 67376, + 394363487 + ] +} + @@ -124,7 +143,11 @@ This endpoint returns the following JSON structure on success with a 201 Created An example of usage could be - GET /image/process.jpg?src=asdf.png&thumbnail=256&blur=3.0 + + +GET /image/process.jpg?src=asdf.png&thumbnail=256&blur=3.0 + + which would create a 256x256px JPEG thumbnail and blur it diff --git a/nixos/modules/services/web-apps/plausible.md b/nixos/modules/services/web-apps/plausible.md new file mode 100644 index 000000000000..1328ce69441a --- /dev/null +++ b/nixos/modules/services/web-apps/plausible.md @@ -0,0 +1,35 @@ +# Plausible {#module-services-plausible} + +[Plausible](https://plausible.io/) is a privacy-friendly alternative to +Google analytics. + +## Basic Usage {#module-services-plausible-basic-usage} + +At first, a secret key is needed to be generated. This can be done with e.g. +```ShellSession +$ openssl rand -base64 64 +``` + +After that, `plausible` can be deployed like this: +``` +{ + services.plausible = { + enable = true; + adminUser = { + # activate is used to skip the email verification of the admin-user that's + # automatically created by plausible. This is only supported if + # postgresql is configured by the module. This is done by default, but + # can be turned off with services.plausible.database.postgres.setup. + activate = true; + email = "admin@localhost"; + passwordFile = "/run/secrets/plausible-admin-pwd"; + }; + server = { + baseUrl = "http://analytics.example.org"; + # secretKeybaseFile is a path to the file which contains the secret generated + # with openssl as described above. + secretKeybaseFile = "/run/secrets/plausible-secret-key-base"; + }; + }; +} +``` diff --git a/nixos/modules/services/web-apps/plausible.xml b/nixos/modules/services/web-apps/plausible.xml index 92a571b9fbdb..39ff004ffd95 100644 --- a/nixos/modules/services/web-apps/plausible.xml +++ b/nixos/modules/services/web-apps/plausible.xml @@ -1,51 +1,45 @@ - - Plausible - - Plausible is a privacy-friendly alternative to - Google analytics. - -
- Basic Usage + + + Plausible - At first, a secret key is needed to be generated. This can be done with e.g. - $ openssl rand -base64 64 + Plausible is a + privacy-friendly alternative to Google analytics. - - After that, plausible can be deployed like this: -{ +
+ Basic Usage + + At first, a secret key is needed to be generated. This can be done + with e.g. + + +$ openssl rand -base64 64 + + + After that, plausible can be deployed like + this: + + +{ services.plausible = { - enable = true; + enable = true; adminUser = { - activate = true; - email = "admin@localhost"; - passwordFile = "/run/secrets/plausible-admin-pwd"; + # activate is used to skip the email verification of the admin-user that's + # automatically created by plausible. This is only supported if + # postgresql is configured by the module. This is done by default, but + # can be turned off with services.plausible.database.postgres.setup. + activate = true; + email = "admin@localhost"; + passwordFile = "/run/secrets/plausible-admin-pwd"; }; server = { - baseUrl = "http://analytics.example.org"; - secretKeybaseFile = "/run/secrets/plausible-secret-key-base"; + baseUrl = "http://analytics.example.org"; + # secretKeybaseFile is a path to the file which contains the secret generated + # with openssl as described above. + secretKeybaseFile = "/run/secrets/plausible-secret-key-base"; }; }; -} - - - - activate is used to skip the email verification of the admin-user that's - automatically created by plausible. This is only supported if - postgresql is configured by the module. This is done by default, but - can be turned off with . - - - - - secretKeybaseFile is a path to the file which contains the secret generated - with openssl as described above. - - - - -
+} +
+
diff --git a/nixos/modules/services/web-servers/garage-doc.xml b/nixos/modules/services/web-servers/garage-doc.xml deleted file mode 100644 index 16f6fde94b5a..000000000000 --- a/nixos/modules/services/web-servers/garage-doc.xml +++ /dev/null @@ -1,139 +0,0 @@ - - Garage - - Garage - is an open-source, self-hostable S3 store, simpler than MinIO, for geodistributed stores. - The server setup can be automated using - services.garage. A - client configured to your local Garage instance is available in - the global environment as garage-manage. - - - The current default by NixOS is garage_0_8 which is also the latest - major version available. - -
- General considerations on upgrades - - - Garage provides a cookbook documentation on how to upgrade: - https://garagehq.deuxfleurs.fr/documentation/cookbook/upgrading/ - - - - Garage has two types of upgrades: patch-level upgrades and minor/major version upgrades. - - In all cases, you should read the changelog and ideally test the upgrade on a staging cluster. - - Checking the health of your cluster can be achieved using garage-manage repair. - - - - - Until 1.0 is released, patch-level upgrades are considered as minor version upgrades. - Minor version upgrades are considered as major version upgrades. - i.e. 0.6 to 0.7 is a major version upgrade. - - - - - - Straightforward upgrades (patch-level upgrades) - - Upgrades must be performed one by one, i.e. for each node, stop it, upgrade it : change stateVersion or services.garage.package, restart it if it was not already by switching. - - - - - - - Multiple version upgrades - - Garage do not provide any guarantee on moving more than one major-version forward. - E.g., if you're on 0.7, you cannot upgrade to 0.9. - You need to upgrade to 0.8 first. - - As long as stateVersion is declared properly, - this is enforced automatically. The module will issue a warning to remind the user to upgrade to latest - Garage after that deploy. - - - - -
- -
- Advanced upgrades (minor/major version upgrades) - Here are some baseline instructions to handle advanced upgrades in Garage, when in doubt, please refer to upstream instructions. - - - Disable API and web access to Garage. - Perform garage-manage repair --all-nodes --yes tables and garage-manage repair --all-nodes --yes blocks. - Verify the resulting logs and check that data is synced properly between all nodes. - If you have time, do additional checks (scrub, block_refs, etc.). - Check if queues are empty by garage-manage stats or through monitoring tools. - Run systemctl stop garage to stop the actual Garage version. - Backup the metadata folder of ALL your nodes, e.g. for a metadata directory (the default one) in /var/lib/garage/meta, - you can run pushd /var/lib/garage; tar -acf meta-v0.7.tar.zst meta/; popd. - Run the offline migration: nix-shell -p garage_0_8 --run "garage offline-repair --yes", this can take some time depending on how many objects are stored in your cluster. - Bump Garage version in your NixOS configuration, either by changing stateVersion or bumping services.garage.package, this should restart Garage automatically. - Perform garage-manage repair --all-nodes --yes tables and garage-manage repair --all-nodes --yes blocks. - Wait for a full table sync to run. - - - - Your upgraded cluster should be in a working state, re-enable API and web access. - -
- -
- Maintainer information - - - As stated in the previous paragraph, we must provide a clean upgrade-path for Garage - since it cannot move more than one major version forward on a single upgrade. This chapter - adds some notes how Garage updates should be rolled out in the future. - - This is inspired from how Nextcloud does it. - - - - While patch-level updates are no problem and can be done directly in the - package-expression (and should be backported to supported stable branches after that), - major-releases should be added in a new attribute (e.g. Garage v0.8.0 - should be available in nixpkgs as pkgs.garage_0_8_0). - To provide simple upgrade paths it's generally useful to backport those as well to stable - branches. As long as the package-default isn't altered, this won't break existing setups. - After that, the versioning-warning in the garage-module should be - updated to make sure that the - package-option selects the latest version - on fresh setups. - - - - If major-releases will be abandoned by upstream, we should check first if those are needed - in NixOS for a safe upgrade-path before removing those. In that case we shold keep those - packages, but mark them as insecure in an expression like this (in - <nixpkgs/pkgs/tools/filesystem/garage/default.nix>): -/* ... */ -{ - garage_0_7_3 = generic { - version = "0.7.3"; - sha256 = "0000000000000000000000000000000000000000000000000000"; - eol = true; - }; -} - - - - Ideally we should make sure that it's possible to jump two NixOS versions forward: - i.e. the warnings and the logic in the module should guard a user to upgrade from a - Garage on e.g. 22.11 to a Garage on 23.11. - -
- -
diff --git a/nixos/modules/services/web-servers/garage.md b/nixos/modules/services/web-servers/garage.md new file mode 100644 index 000000000000..b1003e5dae1e --- /dev/null +++ b/nixos/modules/services/web-servers/garage.md @@ -0,0 +1,96 @@ +# Garage {#module-services-garage} + +[Garage](https://garagehq.deuxfleurs.fr/) +is an open-source, self-hostable S3 store, simpler than MinIO, for geodistributed stores. +The server setup can be automated using +[services.garage](#opt-services.garage.enable). A + client configured to your local Garage instance is available in + the global environment as `garage-manage`. + +The current default by NixOS is `garage_0_8` which is also the latest +major version available. + +## General considerations on upgrades {#module-services-garage-upgrade-scenarios} + +Garage provides a cookbook documentation on how to upgrade: + + +::: {.warning} +Garage has two types of upgrades: patch-level upgrades and minor/major version upgrades. + +In all cases, you should read the changelog and ideally test the upgrade on a staging cluster. + +Checking the health of your cluster can be achieved using `garage-manage repair`. +::: + +::: {.warning} +Until 1.0 is released, patch-level upgrades are considered as minor version upgrades. +Minor version upgrades are considered as major version upgrades. +i.e. 0.6 to 0.7 is a major version upgrade. +::: + + - **Straightforward upgrades (patch-level upgrades).** + Upgrades must be performed one by one, i.e. for each node, stop it, upgrade it : change [stateVersion](#opt-system.stateVersion) or [services.garage.package](#opt-services.garage.package), restart it if it was not already by switching. + - **Multiple version upgrades.** + Garage do not provide any guarantee on moving more than one major-version forward. + E.g., if you're on `0.7`, you cannot upgrade to `0.9`. + You need to upgrade to `0.8` first. + As long as [stateVersion](#opt-system.stateVersion) is declared properly, + this is enforced automatically. The module will issue a warning to remind the user to upgrade to latest + Garage *after* that deploy. + +## Advanced upgrades (minor/major version upgrades) {#module-services-garage-advanced-upgrades} + +Here are some baseline instructions to handle advanced upgrades in Garage, when in doubt, please refer to upstream instructions. + + - Disable API and web access to Garage. + - Perform `garage-manage repair --all-nodes --yes tables` and `garage-manage repair --all-nodes --yes blocks`. + - Verify the resulting logs and check that data is synced properly between all nodes. + If you have time, do additional checks (`scrub`, `block_refs`, etc.). + - Check if queues are empty by `garage-manage stats` or through monitoring tools. + - Run `systemctl stop garage` to stop the actual Garage version. + - Backup the metadata folder of ALL your nodes, e.g. for a metadata directory (the default one) in `/var/lib/garage/meta`, + you can run `pushd /var/lib/garage; tar -acf meta-v0.7.tar.zst meta/; popd`. + - Run the offline migration: `nix-shell -p garage_0_8 --run "garage offline-repair --yes"`, this can take some time depending on how many objects are stored in your cluster. + - Bump Garage version in your NixOS configuration, either by changing [stateVersion](#opt-system.stateVersion) or bumping [services.garage.package](#opt-services.garage.package), this should restart Garage automatically. + - Perform `garage-manage repair --all-nodes --yes tables` and `garage-manage repair --all-nodes --yes blocks`. + - Wait for a full table sync to run. + +Your upgraded cluster should be in a working state, re-enable API and web access. + +## Maintainer information {#module-services-garage-maintainer-info} + +As stated in the previous paragraph, we must provide a clean upgrade-path for Garage +since it cannot move more than one major version forward on a single upgrade. This chapter +adds some notes how Garage updates should be rolled out in the future. +This is inspired from how Nextcloud does it. + +While patch-level updates are no problem and can be done directly in the +package-expression (and should be backported to supported stable branches after that), +major-releases should be added in a new attribute (e.g. Garage `v0.8.0` +should be available in `nixpkgs` as `pkgs.garage_0_8_0`). +To provide simple upgrade paths it's generally useful to backport those as well to stable +branches. As long as the package-default isn't altered, this won't break existing setups. +After that, the versioning-warning in the `garage`-module should be +updated to make sure that the +[package](#opt-services.garage.package)-option selects the latest version +on fresh setups. + +If major-releases will be abandoned by upstream, we should check first if those are needed +in NixOS for a safe upgrade-path before removing those. In that case we shold keep those +packages, but mark them as insecure in an expression like this (in +``): +``` +/* ... */ +{ + garage_0_7_3 = generic { + version = "0.7.3"; + sha256 = "0000000000000000000000000000000000000000000000000000"; + eol = true; + }; +} +``` + +Ideally we should make sure that it's possible to jump two NixOS versions forward: +i.e. the warnings and the logic in the module should guard a user to upgrade from a +Garage on e.g. 22.11 to a Garage on 23.11. diff --git a/nixos/modules/services/web-servers/garage.nix b/nixos/modules/services/web-servers/garage.nix index d66bcd731508..1c25d865f980 100644 --- a/nixos/modules/services/web-servers/garage.nix +++ b/nixos/modules/services/web-servers/garage.nix @@ -9,7 +9,7 @@ let in { meta = { - doc = ./garage-doc.xml; + doc = ./garage.xml; maintainers = with pkgs.lib.maintainers; [ raitobezarius ]; }; diff --git a/nixos/modules/services/web-servers/garage.xml b/nixos/modules/services/web-servers/garage.xml new file mode 100644 index 000000000000..6a16b1693daf --- /dev/null +++ b/nixos/modules/services/web-servers/garage.xml @@ -0,0 +1,206 @@ + + + Garage + + Garage is + an open-source, self-hostable S3 store, simpler than MinIO, for + geodistributed stores. The server setup can be automated using + services.garage. A + client configured to your local Garage instance is available in the + global environment as garage-manage. + + + The current default by NixOS is garage_0_8 which + is also the latest major version available. + +
+ General considerations on upgrades + + Garage provides a cookbook documentation on how to upgrade: + https://garagehq.deuxfleurs.fr/documentation/cookbook/upgrading/ + + + + Garage has two types of upgrades: patch-level upgrades and + minor/major version upgrades. + + + In all cases, you should read the changelog and ideally test the + upgrade on a staging cluster. + + + Checking the health of your cluster can be achieved using + garage-manage repair. + + + + + Until 1.0 is released, patch-level upgrades are considered as + minor version upgrades. Minor version upgrades are considered as + major version upgrades. i.e. 0.6 to 0.7 is a major version + upgrade. + + + + + + Straightforward upgrades (patch-level + upgrades). Upgrades must be performed one by one, + i.e. for each node, stop it, upgrade it : change + stateVersion or + services.garage.package, + restart it if it was not already by switching. + + + + + Multiple version upgrades. + Garage do not provide any guarantee on moving more than one + major-version forward. E.g., if you’re on + 0.7, you cannot upgrade to + 0.9. You need to upgrade to + 0.8 first. As long as + stateVersion is + declared properly, this is enforced automatically. The module + will issue a warning to remind the user to upgrade to latest + Garage after that deploy. + + + +
+
+ Advanced upgrades (minor/major version upgrades) + + Here are some baseline instructions to handle advanced upgrades in + Garage, when in doubt, please refer to upstream instructions. + + + + + Disable API and web access to Garage. + + + + + Perform + garage-manage repair --all-nodes --yes tables + and + garage-manage repair --all-nodes --yes blocks. + + + + + Verify the resulting logs and check that data is synced + properly between all nodes. If you have time, do additional + checks (scrub, + block_refs, etc.). + + + + + Check if queues are empty by + garage-manage stats or through monitoring + tools. + + + + + Run systemctl stop garage to stop the + actual Garage version. + + + + + Backup the metadata folder of ALL your nodes, e.g. for a + metadata directory (the default one) in + /var/lib/garage/meta, you can run + pushd /var/lib/garage; tar -acf meta-v0.7.tar.zst meta/; popd. + + + + + Run the offline migration: + nix-shell -p garage_0_8 --run "garage offline-repair --yes", + this can take some time depending on how many objects are + stored in your cluster. + + + + + Bump Garage version in your NixOS configuration, either by + changing + stateVersion or + bumping + services.garage.package, + this should restart Garage automatically. + + + + + Perform + garage-manage repair --all-nodes --yes tables + and + garage-manage repair --all-nodes --yes blocks. + + + + + Wait for a full table sync to run. + + + + + Your upgraded cluster should be in a working state, re-enable API + and web access. + +
+
+ Maintainer information + + As stated in the previous paragraph, we must provide a clean + upgrade-path for Garage since it cannot move more than one major + version forward on a single upgrade. This chapter adds some notes + how Garage updates should be rolled out in the future. This is + inspired from how Nextcloud does it. + + + While patch-level updates are no problem and can be done directly + in the package-expression (and should be backported to supported + stable branches after that), major-releases should be added in a + new attribute (e.g. Garage v0.8.0 should be + available in nixpkgs as + pkgs.garage_0_8_0). To provide simple upgrade + paths it’s generally useful to backport those as well to stable + branches. As long as the package-default isn’t altered, this won’t + break existing setups. After that, the versioning-warning in the + garage-module should be updated to make sure + that the + package-option + selects the latest version on fresh setups. + + + If major-releases will be abandoned by upstream, we should check + first if those are needed in NixOS for a safe upgrade-path before + removing those. In that case we shold keep those packages, but + mark them as insecure in an expression like this (in + <nixpkgs/pkgs/tools/filesystem/garage/default.nix>): + + +/* ... */ +{ + garage_0_7_3 = generic { + version = "0.7.3"; + sha256 = "0000000000000000000000000000000000000000000000000000"; + eol = true; + }; +} + + + Ideally we should make sure that it’s possible to jump two NixOS + versions forward: i.e. the warnings and the logic in the module + should guard a user to upgrade from a Garage on e.g. 22.11 to a + Garage on 23.11. + +
+
diff --git a/nixos/modules/services/x11/desktop-managers/gnome.md b/nixos/modules/services/x11/desktop-managers/gnome.md new file mode 100644 index 000000000000..d9e75bfe6bdd --- /dev/null +++ b/nixos/modules/services/x11/desktop-managers/gnome.md @@ -0,0 +1,167 @@ +# GNOME Desktop {#chap-gnome} + +GNOME provides a simple, yet full-featured desktop environment with a focus on productivity. Its Mutter compositor supports both Wayland and X server, and the GNOME Shell user interface is fully customizable by extensions. + +## Enabling GNOME {#sec-gnome-enable} + +All of the core apps, optional apps, games, and core developer tools from GNOME are available. + +To enable the GNOME desktop use: + +``` +services.xserver.desktopManager.gnome.enable = true; +services.xserver.displayManager.gdm.enable = true; +``` + +::: {.note} +While it is not strictly necessary to use GDM as the display manager with GNOME, it is recommended, as some features such as screen lock [might not work](#sec-gnome-faq-can-i-use-lightdm-with-gnome) without it. +::: + +The default applications used in NixOS are very minimal, inspired by the defaults used in [gnome-build-meta](https://gitlab.gnome.org/GNOME/gnome-build-meta/blob/40.0/elements/core/meta-gnome-core-utilities.bst). + +### GNOME without the apps {#sec-gnome-without-the-apps} + +If you’d like to only use the GNOME desktop and not the apps, you can disable them with: + +``` +services.gnome.core-utilities.enable = false; +``` + +and none of them will be installed. + +If you’d only like to omit a subset of the core utilities, you can use +[](#opt-environment.gnome.excludePackages). +Note that this mechanism can only exclude core utilities, games and core developer tools. + +### Disabling GNOME services {#sec-gnome-disabling-services} + +It 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: + +``` +services.gnome.tracker-miners.enable = false; +services.gnome.tracker.enable = false; +``` + +Note, however, that doing so is not supported and might break some applications. Notably, GNOME Music cannot work without Tracker. + +### GNOME games {#sec-gnome-games} + +You can install all of the GNOME games with: + +``` +services.gnome.games.enable = true; +``` + +### GNOME core developer tools {#sec-gnome-core-developer-tools} + +You can install GNOME core developer tools with: + +``` +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: + +``` +services.xserver.desktopManager.gnome.flashback.enableMetacity = true; +``` + +It is also possible to create custom sessions that replace Metacity with a different window manager using [](#opt-services.xserver.desktopManager.gnome.flashback.customSessions). + +The following example uses `xmonad` window manager: + +``` +services.xserver.desktopManager.gnome.flashback.customSessions = [ + { + wmName = "xmonad"; + wmLabel = "XMonad"; + wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad"; + enableGnomePanel = false; + } +]; +``` + +## Icons and GTK Themes {#sec-gnome-icons-and-gtk-themes} + +Icon themes and GTK themes don’t require any special option to install in NixOS. + +You can add them to [](#opt-environment.systemPackages) and switch to them with GNOME Tweaks. +If you’d like to do this manually in dconf, change the values of the following keys: + +``` +/org/gnome/desktop/interface/gtk-theme +/org/gnome/desktop/interface/icon-theme +``` + +in `dconf-editor` + +## Shell Extensions {#sec-gnome-shell-extensions} + +Most Shell extensions are packaged under the `gnomeExtensions` attribute. +Some packages that include Shell extensions, like `gnome.gpaste`, don’t have their extension decoupled under this attribute. + +You can install them like any other package: + +``` +environment.systemPackages = [ + gnomeExtensions.dash-to-dock + gnomeExtensions.gsconnect + gnomeExtensions.mpris-indicator-button +]; +``` + +Unfortunately, we lack a way for these to be managed in a completely declarative way. +So you have to enable them manually with an Extensions application. +It is possible to use a [GSettings override](#sec-gnome-gsettings-overrides) for this on `org.gnome.shell.enabled-extensions`, but that will only influence the default value. + +## GSettings Overrides {#sec-gnome-gsettings-overrides} + +Majority of software building on the GNOME platform use GLib’s [GSettings](https://developer.gnome.org/gio/unstable/GSettings.html) system to manage runtime configuration. For our purposes, the system consists of XML schemas describing the individual configuration options, stored in the package, and a settings backend, where the values of the settings are stored. On NixOS, like on most Linux distributions, dconf database is used as the backend. + +[GSettings vendor overrides](https://developer.gnome.org/gio/unstable/GSettings.html#id-1.4.19.2.9.25) can be used to adjust the default values for settings of the GNOME desktop and apps by replacing the default values specified in the XML schemas. Using overrides will allow you to pre-seed user settings before you even start the session. + +::: {.warning} +Overrides really only change the default values for GSettings keys so if you or an application changes the setting value, the value set by the override will be ignored. Until [NixOS’s dconf module implements changing values](https://github.com/NixOS/nixpkgs/issues/54150), you will either need to keep that in mind and clear the setting from the backend using `dconf reset` command when that happens, or use the [module from home-manager](https://nix-community.github.io/home-manager/options.html#opt-dconf.settings). +::: + +You can override the default GSettings values using the +[](#opt-services.xserver.desktopManager.gnome.extraGSettingsOverrides) option. + +Take note that whatever packages you want to override GSettings for, you need to add them to +[](#opt-services.xserver.desktopManager.gnome.extraGSettingsOverridePackages). + +You can use `dconf-editor` tool to explore which GSettings you can set. + +### Example {#sec-gnome-gsettings-overrides-example} + +``` +services.xserver.desktopManager.gnome = { + extraGSettingsOverrides = '' + # Change default background + [org.gnome.desktop.background] + picture-uri='file://${pkgs.nixos-artwork.wallpapers.mosaic-blue.gnomeFilePath}' + + # Favorite apps in gnome-shell + [org.gnome.shell] + favorite-apps=['org.gnome.Photos.desktop', 'org.gnome.Nautilus.desktop'] + ''; + + extraGSettingsOverridePackages = [ + pkgs.gsettings-desktop-schemas # for org.gnome.desktop + pkgs.gnome.gnome-shell # for org.gnome.shell + ]; +}; +``` + +## Frequently Asked Questions {#sec-gnome-faq} + +### Can I use LightDM with GNOME? {#sec-gnome-faq-can-i-use-lightdm-with-gnome} + +Yes you can, and any other display-manager in NixOS. + +However, it doesn’t work correctly for the Wayland session of GNOME Shell yet, and +won’t be able to lock your screen. + +See [this issue.](https://github.com/NixOS/nixpkgs/issues/56342) diff --git a/nixos/modules/services/x11/desktop-managers/gnome.xml b/nixos/modules/services/x11/desktop-managers/gnome.xml index 807c9d64e204..6613f49eec7a 100644 --- a/nixos/modules/services/x11/desktop-managers/gnome.xml +++ b/nixos/modules/services/x11/desktop-managers/gnome.xml @@ -1,217 +1,228 @@ - - GNOME Desktop - - GNOME provides a simple, yet full-featured desktop environment with a focus on productivity. Its Mutter compositor supports both Wayland and X server, and the GNOME Shell user interface is fully customizable by extensions. - - -
- Enabling GNOME - + + + GNOME Desktop - All of the core apps, optional apps, games, and core developer tools from GNOME are available. + GNOME provides a simple, yet full-featured desktop environment with + a focus on productivity. Its Mutter compositor supports both Wayland + and X server, and the GNOME Shell user interface is fully + customizable by extensions. - - - To enable the GNOME desktop use: - - - - = true; - = true; +
+ Enabling GNOME + + All of the core apps, optional apps, games, and core developer + tools from GNOME are available. + + + To enable the GNOME desktop use: + + +services.xserver.desktopManager.gnome.enable = true; +services.xserver.displayManager.gdm.enable = true; - - - - While it is not strictly necessary to use GDM as the display manager with GNOME, it is recommended, as some features such as screen lock might not work without it. - - - - - The default applications used in NixOS are very minimal, inspired by the defaults used in gnome-build-meta. - - -
- GNOME without the apps - - - If you’d like to only use the GNOME desktop and not the apps, you can disable them with: - - - - = false; + + + While it is not strictly necessary to use GDM as the display + manager with GNOME, it is recommended, as some features such as + screen lock + might + not work without it. + + + + The default applications used in NixOS are very minimal, inspired + by the defaults used in + gnome-build-meta. + +
+ GNOME without the apps + + If you’d like to only use the GNOME desktop and not the apps, + you can disable them with: + + +services.gnome.core-utilities.enable = false; - - - and none of them will be installed. - - - - If you’d only like to omit a subset of the core utilities, you can use . - Note that this mechanism can only exclude core utilities, games and core developer tools. - + + and none of them will be installed. + + + If you’d only like to omit a subset of the core utilities, you + can use + . Note + that this mechanism can only exclude core utilities, games and + core developer tools. + +
+
+ Disabling GNOME services + + It is also possible to disable many of the + core + services. For example, if you do not need indexing files, + you can disable Tracker with: + + +services.gnome.tracker-miners.enable = false; +services.gnome.tracker.enable = false; + + + Note, however, that doing so is not supported and might break + some applications. Notably, GNOME Music cannot work without + Tracker. + +
+
+ GNOME games + + You can install all of the GNOME games with: + + +services.gnome.games.enable = true; + +
+
+ GNOME core developer tools + + You can install GNOME core developer tools with: + + +services.gnome.core-developer-tools.enable = true; + +
- -
- Disabling GNOME services - - - It is also possible to disable many of the core services. For example, if you do not need indexing files, you can disable Tracker with: - - - - = false; - = false; +
+ Enabling GNOME 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: + + +services.xserver.desktopManager.gnome.flashback.enableMetacity = true; - - - Note, however, that doing so is not supported and might break some applications. Notably, GNOME Music cannot work without Tracker. - -
- -
- GNOME games - - - You can install all of the GNOME games with: - - - - = true; - -
- -
- GNOME core developer tools - - - You can install GNOME core developer tools with: - - - - = true; - -
-
- -
- Enabling GNOME 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: - - - - = true; - - - - It is also possible to create custom sessions that replace Metacity with a different window manager using . - - - - The following example uses xmonad window manager: - - - - = [ + + It is also possible to create custom sessions that replace + Metacity with a different window manager using + . + + + The following example uses xmonad window + manager: + + +services.xserver.desktopManager.gnome.flashback.customSessions = [ { - wmName = "xmonad"; - wmLabel = "XMonad"; - wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad"; + wmName = "xmonad"; + wmLabel = "XMonad"; + wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad"; enableGnomePanel = false; } ]; - -
- -
- Icons and GTK Themes - - - Icon themes and GTK themes don’t require any special option to install in NixOS. - - - - You can add them to and switch to them with GNOME Tweaks. - If you’d like to do this manually in dconf, change the values of the following keys: - - - +
+
+ Icons and GTK Themes + + Icon themes and GTK themes don’t require any special option to + install in NixOS. + + + You can add them to + and switch to + them with GNOME Tweaks. If you’d like to do this manually in + dconf, change the values of the following keys: + + /org/gnome/desktop/interface/gtk-theme /org/gnome/desktop/interface/icon-theme - - - in dconf-editor - -
- -
- Shell Extensions - - - Most Shell extensions are packaged under the gnomeExtensions attribute. - Some packages that include Shell extensions, like gnome.gpaste, don’t have their extension decoupled under this attribute. - - - - You can install them like any other package: - - - - = [ + + in dconf-editor + +
+
+ Shell Extensions + + Most Shell extensions are packaged under the + gnomeExtensions attribute. Some packages that + include Shell extensions, like gnome.gpaste, + don’t have their extension decoupled under this attribute. + + + You can install them like any other package: + + +environment.systemPackages = [ gnomeExtensions.dash-to-dock gnomeExtensions.gsconnect gnomeExtensions.mpris-indicator-button ]; - - - Unfortunately, we lack a way for these to be managed in a completely declarative way. - So you have to enable them manually with an Extensions application. - It is possible to use a GSettings override for this on org.gnome.shell.enabled-extensions, but that will only influence the default value. - -
- -
- GSettings Overrides - - - Majority of software building on the GNOME platform use GLib’s GSettings system to manage runtime configuration. For our purposes, the system consists of XML schemas describing the individual configuration options, stored in the package, and a settings backend, where the values of the settings are stored. On NixOS, like on most Linux distributions, dconf database is used as the backend. - - - - GSettings vendor overrides can be used to adjust the default values for settings of the GNOME desktop and apps by replacing the default values specified in the XML schemas. Using overrides will allow you to pre-seed user settings before you even start the session. - - - - - Overrides really only change the default values for GSettings keys so if you or an application changes the setting value, the value set by the override will be ignored. Until NixOS’s dconf module implements changing values, you will either need to keep that in mind and clear the setting from the backend using dconf reset command when that happens, or use the module from home-manager. - - - - - You can override the default GSettings values using the option. - - - - Take note that whatever packages you want to override GSettings for, you need to add them to - . - - - - You can use dconf-editor tool to explore which GSettings you can set. - - -
- Example - - + + Unfortunately, we lack a way for these to be managed in a + completely declarative way. So you have to enable them manually + with an Extensions application. It is possible to use a + GSettings + override for this on + org.gnome.shell.enabled-extensions, but that + will only influence the default value. + +
+
+ GSettings Overrides + + Majority of software building on the GNOME platform use GLib’s + GSettings + system to manage runtime configuration. For our purposes, the + system consists of XML schemas describing the individual + configuration options, stored in the package, and a settings + backend, where the values of the settings are stored. On NixOS, + like on most Linux distributions, dconf database is used as the + backend. + + + GSettings + vendor overrides can be used to adjust the default values + for settings of the GNOME desktop and apps by replacing the + default values specified in the XML schemas. Using overrides will + allow you to pre-seed user settings before you even start the + session. + + + + Overrides really only change the default values for GSettings + keys so if you or an application changes the setting value, the + value set by the override will be ignored. Until + NixOS’s + dconf module implements changing values, you will either + need to keep that in mind and clear the setting from the backend + using dconf reset command when that happens, + or use the + module + from home-manager. + + + + You can override the default GSettings values using the + + option. + + + Take note that whatever packages you want to override GSettings + for, you need to add them to + . + + + You can use dconf-editor tool to explore which + GSettings you can set. + +
+ Example + services.xserver.desktopManager.gnome = { - extraGSettingsOverrides = '' + extraGSettingsOverrides = '' # Change default background [org.gnome.desktop.background] picture-uri='file://${pkgs.nixos-artwork.wallpapers.mosaic-blue.gnomeFilePath}' @@ -221,33 +232,30 @@ services.xserver.desktopManager.gnome = { favorite-apps=['org.gnome.Photos.desktop', 'org.gnome.Nautilus.desktop'] ''; - extraGSettingsOverridePackages = [ + extraGSettingsOverridePackages = [ pkgs.gsettings-desktop-schemas # for org.gnome.desktop pkgs.gnome.gnome-shell # for org.gnome.shell ]; }; +
-
- -
- Frequently Asked Questions - -
- Can I use LightDM with GNOME? - - - Yes you can, and any other display-manager in NixOS. - - - - However, it doesn’t work correctly for the Wayland session of GNOME Shell yet, and - won’t be able to lock your screen. - - - - See this issue. - +
+ Frequently Asked Questions +
+ Can I use LightDM with GNOME? + + Yes you can, and any other display-manager in NixOS. + + + However, it doesn’t work correctly for the Wayland session of + GNOME Shell yet, and won’t be able to lock your screen. + + + See + this + issue. + +
-
diff --git a/nixos/modules/services/x11/desktop-managers/pantheon.md b/nixos/modules/services/x11/desktop-managers/pantheon.md new file mode 100644 index 000000000000..1c14ede84749 --- /dev/null +++ b/nixos/modules/services/x11/desktop-managers/pantheon.md @@ -0,0 +1,74 @@ +# Pantheon Desktop {#chap-pantheon} + +Pantheon is the desktop environment created for the elementary OS distribution. It is written from scratch in Vala, utilizing GNOME technologies with GTK and Granite. + +## Enabling Pantheon {#sec-pantheon-enable} + +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 +``` +services.xserver.desktopManager.pantheon.enable = true; +``` +This automatically enables LightDM and Pantheon's LightDM greeter. If you'd like to disable this, set +``` +services.xserver.displayManager.lightdm.greeters.pantheon.enable = false; +services.xserver.displayManager.lightdm.enable = false; +``` +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 +``` +services.pantheon.apps.enable = false; +``` +You can also use [](#opt-environment.pantheon.excludePackages) to remove any other app (like `elementary-mail`). + +## Wingpanel and Switchboard plugins {#sec-pantheon-wingpanel-switchboard} + +Wingpanel and Switchboard work differently than they do in other distributions, as far as using plugins. You cannot install a plugin globally (like with {option}`environment.systemPackages`) to start using it. You should instead be using the following options: + + - [](#opt-services.xserver.desktopManager.pantheon.extraWingpanelIndicators) + - [](#opt-services.xserver.desktopManager.pantheon.extraSwitchboardPlugs) + +to configure the programs with plugs or indicators. + +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: +``` +wingpanel-with-indicators.override { + indicators = [ + pkgs.some-special-indicator + ]; +}; + +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: +``` +wingpanel-with-indicators.override { + useDefaultIndicators = false; + indicators = specialListOfIndicators; +}; + +switchboard-with-plugs.override { + useDefaultPlugs = false; + plugs = specialListOfPlugs; +}; +``` +this could be most useful for testing a particular plug-in in isolation. + +## FAQ {#sec-pantheon-faq} + +[I have switched from a different desktop and Pantheon’s theming looks messed up.]{#sec-pantheon-faq-messed-up-theme} + : Open Switchboard and go to: Administration → About → Restore Default Settings → Restore Settings. This will reset any dconf settings to their Pantheon defaults. Note this could reset certain GNOME specific preferences if that desktop was used prior. + +[I cannot enable both GNOME and Pantheon.]{#sec-pantheon-faq-gnome-and-pantheon} + : This is a known [issue](https://github.com/NixOS/nixpkgs/issues/64611) and there is no known workaround. + +[Does AppCenter work, or is it available?]{#sec-pantheon-faq-appcenter} + : AppCenter has been available since 20.03. Starting from 21.11, the Flatpak backend should work so you can install some Flatpak applications using it. However, due to missing appstream metadata, the Packagekit backend does not function currently. See this [issue](https://github.com/NixOS/nixpkgs/issues/15932). + + If you are using Pantheon, AppCenter should be installed by default if you have [Flatpak support](#module-services-flatpak) enabled. If you also wish to add the `appcenter` Flatpak remote: + + ```ShellSession + $ flatpak remote-add --if-not-exists appcenter https://flatpak.elementary.io/repo.flatpakrepo + ``` diff --git a/nixos/modules/services/x11/desktop-managers/pantheon.xml b/nixos/modules/services/x11/desktop-managers/pantheon.xml index 6226f8f6a272..0e98b08fb658 100644 --- a/nixos/modules/services/x11/desktop-managers/pantheon.xml +++ b/nixos/modules/services/x11/desktop-managers/pantheon.xml @@ -1,53 +1,78 @@ - - Pantheon Desktop - - Pantheon is the desktop environment created for the elementary OS distribution. It is written from scratch in Vala, utilizing GNOME technologies with GTK and Granite. - -
- Enabling Pantheon - + + + Pantheon Desktop - All of Pantheon is working in NixOS and the applications should be available, aside from a few exceptions. To enable Pantheon, set - - = true; - - This automatically enables LightDM and Pantheon's LightDM greeter. If you'd like to disable this, set - - = false; - = false; - - 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 - - = false; - - You can also use to remove any other app (like elementary-mail). + Pantheon is the desktop environment created for the elementary OS + distribution. It is written from scratch in Vala, utilizing GNOME + technologies with GTK and Granite. -
-
- Wingpanel and Switchboard plugins - - - Wingpanel and Switchboard work differently than they do in other distributions, as far as using plugins. You cannot install a plugin globally (like with ) to start using it. You should instead be using the following options: - - - - - - - - - - - - - to configure the programs with plugs or indicators. - - - - 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: - +
+ Enabling Pantheon + + All of Pantheon is working in NixOS and the applications should be + available, aside from a few + exceptions. + To enable Pantheon, set + + +services.xserver.desktopManager.pantheon.enable = true; + + + This automatically enables LightDM and Pantheon’s LightDM greeter. + If you’d like to disable this, set + + +services.xserver.displayManager.lightdm.greeters.pantheon.enable = false; +services.xserver.displayManager.lightdm.enable = false; + + + 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 + + +services.pantheon.apps.enable = false; + + + You can also use + to + remove any other app (like elementary-mail). + +
+
+ Wingpanel and Switchboard plugins + + Wingpanel and Switchboard work differently than they do in other + distributions, as far as using plugins. You cannot install a + plugin globally (like with + ) to start using it. + You should instead be using the following options: + + + + + + + + + + + + + + + to configure the programs with plugs or indicators. + + + 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: + + wingpanel-with-indicators.override { indicators = [ pkgs.some-special-indicator @@ -60,8 +85,14 @@ switchboard-with-plugs.override { ]; }; - 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: - + + 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: + + wingpanel-with-indicators.override { useDefaultIndicators = false; indicators = specialListOfIndicators; @@ -72,49 +103,69 @@ switchboard-with-plugs.override { plugs = specialListOfPlugs; }; - this could be most useful for testing a particular plug-in in isolation. - -
-
- FAQ - - - - - I have switched from a different desktop and Pantheon’s theming looks messed up. - - - - Open Switchboard and go to: AdministrationAboutRestore Default SettingsRestore Settings. This will reset any dconf settings to their Pantheon defaults. Note this could reset certain GNOME specific preferences if that desktop was used prior. - - - - - - I cannot enable both GNOME and Pantheon. - - - - This is a known issue and there is no known workaround. - - - - - - Does AppCenter work, or is it available? - - - - AppCenter has been available since 20.03. Starting from 21.11, the Flatpak backend should work so you can install some Flatpak applications using it. However, due to missing appstream metadata, the Packagekit backend does not function currently. See this issue. - - - If you are using Pantheon, AppCenter should be installed by default if you have Flatpak support enabled. If you also wish to add the appcenter Flatpak remote: - - -$ flatpak remote-add --if-not-exists appcenter https://flatpak.elementary.io/repo.flatpakrepo - - - - -
+ + this could be most useful for testing a particular plug-in in + isolation. + +
+
+ FAQ + + + + I have + switched from a different desktop and Pantheon’s theming looks + messed up. + + + + Open Switchboard and go to: Administration → About → Restore + Default Settings → Restore Settings. This will reset any + dconf settings to their Pantheon defaults. Note this could + reset certain GNOME specific preferences if that desktop was + used prior. + + + + + + I + cannot enable both GNOME and Pantheon. + + + + This is a known + issue + and there is no known workaround. + + + + + + Does AppCenter + work, or is it available? + + + + AppCenter has been available since 20.03. Starting from + 21.11, the Flatpak backend should work so you can install + some Flatpak applications using it. However, due to missing + appstream metadata, the Packagekit backend does not function + currently. See this + issue. + + + If you are using Pantheon, AppCenter should be installed by + default if you have + Flatpak + support enabled. If you also wish to add the + appcenter Flatpak remote: + + +$ flatpak remote-add --if-not-exists appcenter https://flatpak.elementary.io/repo.flatpakrepo + + + + +
diff --git a/nixos/modules/system/boot/loader/external/external.md b/nixos/modules/system/boot/loader/external/external.md index ba1dfd4d9b9a..4f5b559dfc40 100644 --- a/nixos/modules/system/boot/loader/external/external.md +++ b/nixos/modules/system/boot/loader/external/external.md @@ -20,7 +20,7 @@ You can enable FooBoot like this: } ``` -## Developing Custom Bootloader Backends +## Developing Custom Bootloader Backends {#sec-bootloader-external-developing} Bootloaders should use [RFC-0125](https://github.com/NixOS/rfcs/pull/125)'s Bootspec format and synthesis tools to identify the key properties for bootable system generations. diff --git a/nixos/modules/system/boot/loader/external/external.nix b/nixos/modules/system/boot/loader/external/external.nix index 5cf478e6c83c..7c5455bb47aa 100644 --- a/nixos/modules/system/boot/loader/external/external.nix +++ b/nixos/modules/system/boot/loader/external/external.nix @@ -8,8 +8,6 @@ in { meta = { maintainers = with maintainers; [ cole-h grahamc raitobezarius ]; - # Don't edit the docbook xml directly, edit the md and generate it: - # `pandoc external.md -t docbook --top-level-division=chapter --extract-media=media -f markdown+smart > external.xml` doc = ./external.xml; }; diff --git a/nixos/modules/system/boot/loader/external/external.xml b/nixos/modules/system/boot/loader/external/external.xml index 39ab2156bc8c..9a392c27441d 100644 --- a/nixos/modules/system/boot/loader/external/external.xml +++ b/nixos/modules/system/boot/loader/external/external.xml @@ -1,3 +1,5 @@ + External Bootloader Backends @@ -29,7 +31,7 @@ }; } -
+
Developing Custom Bootloader Backends Bootloaders should use