···18171817 </listitem>
18181818 </itemizedlist>
18191819 </listitem>
18201820+ <listitem>
18211821+ <para>
18221822+ The
18231823+ <link xlink:href="options.html#opt-services.unifi.enable">services.unifi</link>
18241824+ module has been reworked, solving a number of issues. This
18251825+ leads to several user facing changes:
18261826+ </para>
18271827+ <itemizedlist spacing="compact">
18281828+ <listitem>
18291829+ <para>
18301830+ The <literal>services.unifi.dataDir</literal> option is
18311831+ removed and the data is now always located under
18321832+ <literal>/var/lib/unifi/data</literal>. This is done to
18331833+ make better use of systemd state direcotiry and thus
18341834+ making the service restart more reliable.
18351835+ </para>
18361836+ </listitem>
18371837+ <listitem>
18381838+ <para>
18391839+ The unifi logs can now be found under:
18401840+ <literal>/var/log/unifi</literal> instead of
18411841+ <literal>/var/lib/unifi/logs</literal>.
18421842+ </para>
18431843+ </listitem>
18441844+ <listitem>
18451845+ <para>
18461846+ The unifi run directory can now be found under:
18471847+ <literal>/run/unifi</literal> instead of
18481848+ <literal>/var/lib/unifi/run</literal>.
18491849+ </para>
18501850+ </listitem>
18511851+ </itemizedlist>
18521852+ </listitem>
18201853 </itemizedlist>
18211854 </section>
18221855</section>
+5
nixos/doc/manual/release-notes/rl-2111.section.md
···509509- Dokuwiki now supports caddy! However
510510 - the nginx option has been removed, in the new configuration, please use the `dokuwiki.webserver = "nginx"` instead.
511511 - The "${hostname}" option has been deprecated, please use `dokuwiki.sites = [ "${hostname}" ]` instead
512512+513513+- The [services.unifi](options.html#opt-services.unifi.enable) module has been reworked, solving a number of issues. This leads to several user facing changes:
514514+ - The `services.unifi.dataDir` option is removed and the data is now always located under `/var/lib/unifi/data`. This is done to make better use of systemd state direcotiry and thus making the service restart more reliable.
515515+ - The unifi logs can now be found under: `/var/log/unifi` instead of `/var/lib/unifi/logs`.
516516+ - The unifi run directory can now be found under: `/run/unifi` instead of `/var/lib/unifi/run`.
+26-54
nixos/modules/services/networking/unifi.nix
···99 ${optionalString (cfg.maximumJavaHeapSize != null) "-Xmx${(toString cfg.maximumJavaHeapSize)}m"} \
1010 -jar ${stateDir}/lib/ace.jar
1111 '';
1212- mountPoints = [
1313- {
1414- what = "${cfg.unifiPackage}/dl";
1515- where = "${stateDir}/dl";
1616- }
1717- {
1818- what = "${cfg.unifiPackage}/lib";
1919- where = "${stateDir}/lib";
2020- }
2121- {
2222- what = "${cfg.mongodbPackage}/bin";
2323- where = "${stateDir}/bin";
2424- }
2525- {
2626- what = "${cfg.dataDir}";
2727- where = "${stateDir}/data";
2828- }
2929- ];
3030- systemdMountPoints = map (m: "${utils.escapeSystemdPath m.where}.mount") mountPoints;
3112in
3213{
3314···6849 '';
6950 };
70517171- services.unifi.dataDir = mkOption {
7272- type = types.str;
7373- default = "${stateDir}/data";
7474- description = ''
7575- Where to store the database and other data.
7676-7777- This directory will be bind-mounted to ${stateDir}/data as part of the service startup.
7878- '';
7979- };
8080-8152 services.unifi.openPorts = mkOption {
8253 type = types.bool;
8354 default = true;
···136107 ];
137108 };
138109139139- # We must create the binary directories as bind mounts instead of symlinks
140140- # This is because the controller resolves all symlinks to absolute paths
141141- # to be used as the working directory.
142142- systemd.mounts = map ({ what, where }: {
143143- bindsTo = [ "unifi.service" ];
144144- partOf = [ "unifi.service" ];
145145- unitConfig.RequiresMountsFor = stateDir;
146146- options = "bind";
147147- what = what;
148148- where = where;
149149- }) mountPoints;
150150-151151- systemd.tmpfiles.rules = [
152152- "d '${stateDir}' 0700 unifi - - -"
153153- "d '${stateDir}/data' 0700 unifi - - -"
154154- "d '${stateDir}/webapps' 0700 unifi - - -"
155155- "L+ '${stateDir}/webapps/ROOT' - - - - ${cfg.unifiPackage}/webapps/ROOT"
156156- ];
157157-158110 systemd.services.unifi = {
159111 description = "UniFi controller daemon";
160112 wantedBy = [ "multi-user.target" ];
161161- after = [ "network.target" ] ++ systemdMountPoints;
162162- partOf = systemdMountPoints;
163163- bindsTo = systemdMountPoints;
164164- unitConfig.RequiresMountsFor = stateDir;
113113+ after = [ "network.target" ];
114114+165115 # This a HACK to fix missing dependencies of dynamic libs extracted from jars
166116 environment.LD_LIBRARY_PATH = with pkgs.stdenv; "${cc.cc.lib}/lib";
167117 # Make sure package upgrades trigger a service restart
···209159 SystemCallErrorNumber = "EPERM";
210160 SystemCallFilter = [ "@system-service" ];
211161212212- # Required for ProtectSystem=strict
213213- BindPaths = [ stateDir ];
162162+ StateDirectory = "unifi";
163163+ RuntimeDirectory = "unifi";
164164+ LogsDirectory = "unifi";
165165+ CacheDirectory= "unifi";
166166+167167+ TemporaryFileSystem = [
168168+ # required as we want to create bind mounts below
169169+ "${stateDir}/webapps:rw"
170170+ ];
171171+172172+ # We must create the binary directories as bind mounts instead of symlinks
173173+ # This is because the controller resolves all symlinks to absolute paths
174174+ # to be used as the working directory.
175175+ BindPaths = [
176176+ "/var/log/unifi:${stateDir}/logs"
177177+ "/run/unifi:${stateDir}/run"
178178+ "${cfg.unifiPackage}/dl:${stateDir}/dl"
179179+ "${cfg.unifiPackage}/lib:${stateDir}/lib"
180180+ "${cfg.mongodbPackage}/bin:${stateDir}/bin"
181181+ "${cfg.unifiPackage}/webapps/ROOT:${stateDir}/webapps/ROOT"
182182+ ];
214183215184 # Needs network access
216185 PrivateNetwork = false;
···220189 };
221190222191 };
192192+ imports = [
193193+ (mkRemovedOptionModule [ "services" "unifi" "dataDir" ] "You should move contents of dataDir to /var/lib/unifi/data" )
194194+ ];
223195224196 meta.maintainers = with lib.maintainers; [ erictapen pennae ];
225197}