about summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/databases/postgresql.nix2
-rw-r--r--nixos/modules/services/misc/nzbget.nix47
-rw-r--r--nixos/modules/services/networking/babeld.nix8
-rw-r--r--nixos/modules/services/networking/wpa_supplicant.nix60
-rw-r--r--nixos/modules/services/search/solr.nix2
-rw-r--r--nixos/modules/services/x11/desktop-managers/enlightenment.nix2
-rw-r--r--nixos/modules/services/x11/fractalart.nix36
7 files changed, 126 insertions, 31 deletions
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix
index a23a0ebc7366..9b5e3735239f 100644
--- a/nixos/modules/services/databases/postgresql.nix
+++ b/nixos/modules/services/databases/postgresql.nix
@@ -153,7 +153,7 @@ in
         default= if versionAtLeast config.system.stateVersion "17.09" then "postgres" else "root";
         internal = true;
         description = ''
-          NixOS traditionally used `root` as superuser, most other distros use `postgres`.
+          NixOS traditionally used 'root' as superuser, most other distros use 'postgres'.
           From 17.09 we also try to follow this standard. Internal since changing this value
           would lead to breakage while setting up databases.
         '';
diff --git a/nixos/modules/services/misc/nzbget.nix b/nixos/modules/services/misc/nzbget.nix
index b39511624c80..a186d57ceba2 100644
--- a/nixos/modules/services/misc/nzbget.nix
+++ b/nixos/modules/services/misc/nzbget.nix
@@ -4,9 +4,7 @@ with lib;
 
 let
   cfg = config.services.nzbget;
-  nzbget = pkgs.nzbget;
-in
-{
+  nzbget = pkgs.nzbget; in {
   options = {
     services.nzbget = {
       enable = mkEnableOption "NZBGet";
@@ -42,21 +40,41 @@ in
         p7zip
       ];
       preStart = ''
-        test -d /var/lib/nzbget || {
-          echo "Creating nzbget state directoy in /var/lib/"
-          mkdir -p /var/lib/nzbget
+        datadir=/var/lib/nzbget
+        cfgtemplate=${cfg.package}/share/nzbget/nzbget.conf
+        test -d $datadir || {
+          echo "Creating nzbget data directory in $datadir"
+          mkdir -p $datadir
         }
-        test -f /var/lib/nzbget/nzbget.conf || {
-          echo "nzbget.conf not found. Copying default config to /var/lib/nzbget/nzbget.conf"
-          cp ${cfg.package}/share/nzbget/nzbget.conf /var/lib/nzbget/nzbget.conf
-          echo "Setting file mode of nzbget.conf to 0700 (needs to be written and contains plaintext credentials)"
-          chmod 0700 /var/lib/nzbget/nzbget.conf
+        test -f $configfile || {
+          echo "nzbget.conf not found. Copying default config $cfgtemplate to $configfile"
+          cp $cfgtemplate $configfile
+          echo "Setting $configfile permissions to 0700 (needs to be written and contains plaintext credentials)"
+          chmod 0700 $configfile
           echo "Setting temporary \$MAINDIR variable in default config required in order to allow nzbget to complete initial start"
           echo "Remember to change this to a proper value once NZBGet startup has been completed"
-          sed -i -e 's/MainDir=.*/MainDir=\/tmp/g' /var/lib/nzbget/nzbget.conf
+          sed -i -e 's/MainDir=.*/MainDir=\/tmp/g' $configfile
         }
-        echo "Ensuring proper ownership of /var/lib/nzbget (${cfg.user}:${cfg.group})."
-        chown -R ${cfg.user}:${cfg.group} /var/lib/nzbget
+        echo "Ensuring proper ownership of $datadir (${cfg.user}:${cfg.group})."
+        chown -R ${cfg.user}:${cfg.group} $datadir
+      '';
+
+      script = ''
+        configfile=/var/lib/nzbget/nzbget.conf
+        args="--daemon --configfile $configfile"
+        # The script in preStart (above) copies nzbget's config template to datadir on first run, containing paths that point to the nzbget derivation installed at the time. 
+        # These paths break when nzbget is upgraded & the original derivation is garbage collected. If such broken paths are found in the config file, override them to point to 
+        # the currently installed nzbget derivation.
+        cfgfallback () {
+          local hit=`grep -Po "(?<=^$1=).*+" "$configfile" | sed 's/[ \t]*$//'` # Strip trailing whitespace
+          ( test $hit && test -e $hit ) || {
+            echo "In $configfile, valid $1 not found; falling back to $1=$2"
+            args+=" -o $1=$2"
+          }
+        }
+        cfgfallback ConfigTemplate ${cfg.package}/share/nzbget/nzbget.conf
+        cfgfallback WebDir ${cfg.package}/share/nzbget/webui
+        ${cfg.package}/bin/nzbget $args
       '';
 
       serviceConfig = {
@@ -64,7 +82,6 @@ in
         User = cfg.user;
         Group = cfg.group;
         PermissionsStartOnly = "true";
-        ExecStart = "${cfg.package}/bin/nzbget --daemon --configfile /var/lib/nzbget/nzbget.conf";
         Restart = "on-failure";
       };
     };
diff --git a/nixos/modules/services/networking/babeld.nix b/nixos/modules/services/networking/babeld.nix
index dd76bac9df76..3dfd80f6ff52 100644
--- a/nixos/modules/services/networking/babeld.nix
+++ b/nixos/modules/services/networking/babeld.nix
@@ -6,8 +6,10 @@ let
 
   cfg = config.services.babeld;
 
+  conditionalBoolToString = value: if (isBool value) then (boolToString value) else (toString value);
+
   paramsString = params:
-    concatMapStringsSep "" (name: "${name} ${boolToString (getAttr name params)}")
+    concatMapStringsSep " " (name: "${name} ${conditionalBoolToString (getAttr name params)}")
                    (attrNames params);
 
   interfaceConfig = name:
@@ -49,7 +51,7 @@ in
         type = types.nullOr (types.attrsOf types.unspecified);
         example =
           {
-            wired = true;
+            type = "tunnel";
             "split-horizon" = true;
           };
       };
@@ -63,7 +65,7 @@ in
         type = types.attrsOf (types.attrsOf types.unspecified);
         example =
           { enp0s2 =
-            { wired = true;
+            { type = "wired";
               "hello-interval" = 5;
               "split-horizon" = "auto";
             };
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix
index 908c8730ad2a..4bae05b6dd30 100644
--- a/nixos/modules/services/networking/wpa_supplicant.nix
+++ b/nixos/modules/services/networking/wpa_supplicant.nix
@@ -8,17 +8,20 @@ let
     ${optionalString cfg.userControlled.enable ''
       ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=${cfg.userControlled.group}
       update_config=1''}
-    ${concatStringsSep "\n" (mapAttrsToList (ssid: networkConfig: let
-      psk = if networkConfig.psk != null
-        then ''"${networkConfig.psk}"''
-        else networkConfig.pskRaw;
-      priority = networkConfig.priority;
+    ${concatStringsSep "\n" (mapAttrsToList (ssid: config: with config; let
+      key = if psk != null
+        then ''"${psk}"''
+        else pskRaw;
+      baseAuth = if key != null
+        then ''psk=${key}''
+        else ''key_mgmt=NONE'';
     in ''
       network={
         ssid="${ssid}"
-        ${optionalString (psk != null) ''psk=${psk}''}
-        ${optionalString (psk == null) ''key_mgmt=NONE''}
         ${optionalString (priority != null) ''priority=${toString priority}''}
+        ${optionalString hidden "scan_ssid=1"}
+        ${if (auth != null) then auth else baseAuth}
+        ${extraConfig}
       }
     '') cfg.networks)}
   '' else "/etc/wpa_supplicant.conf";
@@ -70,6 +73,32 @@ in {
                 Mutually exclusive with <varname>psk</varname>.
               '';
             };
+
+            auth = mkOption {
+              type = types.nullOr types.str;
+              default = null;
+              example = ''
+                key_mgmt=WPA-EAP
+                eap=PEAP
+                identity="user@example.com"
+                password="secret"
+              '';
+              description = ''
+                Use this option to configure advanced authentication methods like EAP.
+                See wpa_supplicant.conf(5) for example configurations.
+
+                Mutually exclusive with <varname>psk</varname> and <varname>pskRaw</varname>.
+              '';
+            };
+
+            hidden = mkOption {
+              type = types.bool;
+              default = false;
+              description = ''
+                Set this to <literal>true</literal> if the SSID of the network is hidden.
+              '';
+            };
+
             priority = mkOption {
               type = types.nullOr types.int;
               default = null;
@@ -83,6 +112,19 @@ in {
                 policy, signal strength, etc.
               '';
             };
+
+            extraConfig = mkOption {
+              type = types.str;
+              default = "";
+              example = ''
+                bssid_blacklist=02:11:22:33:44:55 02:22:aa:44:55:66
+              '';
+              description = ''
+                Extra configuration lines appended to the network block.
+                See wpa_supplicant.conf(5) for available options.
+              '';
+            };
+
           };
         });
         description = ''
@@ -128,8 +170,8 @@ in {
 
   config = mkIf cfg.enable {
     assertions = flip mapAttrsToList cfg.networks (name: cfg: {
-      assertion = cfg.psk == null || cfg.pskRaw == null;
-      message = ''networking.wireless."${name}".psk and networking.wireless."${name}".pskRaw are mutually exclusive'';
+      assertion = with cfg; count (x: x != null) [ psk pskRaw auth ] <= 1;
+      message = ''options networking.wireless."${name}".{psk,pskRaw,auth} are mutually exclusive'';
     });
 
     environment.systemPackages =  [ pkgs.wpa_supplicant ];
diff --git a/nixos/modules/services/search/solr.nix b/nixos/modules/services/search/solr.nix
index 33d74e897237..90140a337ed8 100644
--- a/nixos/modules/services/search/solr.nix
+++ b/nixos/modules/services/search/solr.nix
@@ -15,8 +15,6 @@ let
       sha256 = "01mzvh53wrs1p2ym765jwd00gl6kn8f9k3nhdrnhdqr8dhimfb2p";
     };
 
-    buildPhases = [ "unpackPhase" "installPhase" ];
-
     installPhase = ''
       mkdir -p $out/lib
       cp common/lib/*.jar $out/lib/
diff --git a/nixos/modules/services/x11/desktop-managers/enlightenment.nix b/nixos/modules/services/x11/desktop-managers/enlightenment.nix
index b02eaf861a0d..8a523f0d8036 100644
--- a/nixos/modules/services/x11/desktop-managers/enlightenment.nix
+++ b/nixos/modules/services/x11/desktop-managers/enlightenment.nix
@@ -61,7 +61,7 @@ in
       '';
     }];
 
-    security.wrappers.e_freqset.source = "${e.enlightenment.out}/bin/e_freqset";
+    security.wrappers = (import (builtins.toPath "${e.enlightenment}/e-wrappers.nix")).security.wrappers;
 
     environment.etc = singleton
       { source = xcfg.xkbDir;
diff --git a/nixos/modules/services/x11/fractalart.nix b/nixos/modules/services/x11/fractalart.nix
new file mode 100644
index 000000000000..448248a58794
--- /dev/null
+++ b/nixos/modules/services/x11/fractalart.nix
@@ -0,0 +1,36 @@
+{ config, lib, pkgs, ... }:
+with lib;
+let
+  cfg = config.services.fractalart;
+in {
+  options.services.fractalart = {
+    enable = mkOption {
+      type = types.bool;
+      default = false;
+      example = true;
+      description = "Enable FractalArt for generating colorful wallpapers on login";
+    };
+
+    width = mkOption {
+      type = types.nullOr types.int;
+      default = null;
+      example = 1920;
+      description = "Screen width";
+    };
+
+    height = mkOption {
+      type = types.nullOr types.int;
+      default = null;
+      example = 1080;
+      description = "Screen height";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.systemPackages = [ pkgs.haskellPackages.FractalArt ];
+    services.xserver.displayManager.sessionCommands =
+      "${pkgs.haskellPackages.FractalArt}/bin/FractalArt --no-bg -f .background-image"
+        + optionalString (cfg.width  != null) " -w ${toString cfg.width}"
+        + optionalString (cfg.height != null) " -h ${toString cfg.height}";
+  };
+}