nixos/unifi: Properly depend on mountpoints
This commit is contained in:
parent
4e46e4cb59
commit
f83aa6c0ea
|
@ -1,9 +1,24 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, utils, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.unifi;
|
cfg = config.services.unifi;
|
||||||
stateDir = "/var/lib/unifi";
|
stateDir = "/var/lib/unifi";
|
||||||
cmd = "@${pkgs.icedtea7_jre}/bin/java java -jar ${stateDir}/lib/ace.jar";
|
cmd = "@${pkgs.icedtea7_jre}/bin/java java -jar ${stateDir}/lib/ace.jar";
|
||||||
|
mountPoints = [
|
||||||
|
{
|
||||||
|
what = "${pkgs.unifi}/dl";
|
||||||
|
where = "${stateDir}/dl";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
what = "${pkgs.unifi}/lib";
|
||||||
|
where = "${stateDir}/lib";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
what = "${pkgs.mongodb}/bin";
|
||||||
|
where = "${stateDir}/bin";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
systemdMountPoints = map (m: "${utils.escapeSystemdPath m.where}.mount") mountPoints;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -32,30 +47,18 @@ in
|
||||||
# to be used as the working directory.
|
# to be used as the working directory.
|
||||||
systemd.mounts = map ({ what, where }: {
|
systemd.mounts = map ({ what, where }: {
|
||||||
bindsTo = [ "unifi.service" ];
|
bindsTo = [ "unifi.service" ];
|
||||||
requiredBy = [ "unifi.service" ];
|
partOf = [ "unifi.service" ];
|
||||||
before = [ "unifi.service" ];
|
|
||||||
options = "bind";
|
options = "bind";
|
||||||
what = what;
|
what = what;
|
||||||
where = where;
|
where = where;
|
||||||
}) [
|
}) mountPoints;
|
||||||
{
|
|
||||||
what = "${pkgs.unifi}/dl";
|
|
||||||
where = "${stateDir}/dl";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
what = "${pkgs.unifi}/lib";
|
|
||||||
where = "${stateDir}/lib";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
what = "${pkgs.mongodb}/bin";
|
|
||||||
where = "${stateDir}/bin";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.services.unifi = {
|
systemd.services.unifi = {
|
||||||
description = "UniFi controller daemon";
|
description = "UniFi controller daemon";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ] ++ systemdMountPoints;
|
||||||
|
partOf = systemdMountPoints;
|
||||||
|
bindsTo = systemdMountPoints;
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
# Ensure privacy of state
|
# Ensure privacy of state
|
||||||
|
|
Loading…
Reference in New Issue