1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-26 07:31:20 +00:00

nixos/duplicati: Add dataDir to service

Other services such as minecraft-server and plex allow configuration of
the dataDir option, allowing the files stored by each service to be in a
custom location.

Co-authored-by: Aaron Andersen <aaron@fosslib.net>
This commit is contained in:
Lyndon Sanche 2021-12-24 15:04:39 -07:00
parent 9c49aab2d2
commit c7008f8fdf
No known key found for this signature in database
GPG key ID: 6F8E82F60C799B18
3 changed files with 35 additions and 9 deletions

View file

@ -253,6 +253,13 @@
configuration.
</para>
</listitem>
<listitem>
<para>
The option <literal>services.duplicati.dataDir</literal> has
been added to allow changing the location of duplicatis
files.
</para>
</listitem>
</itemizedlist>
</section>
</section>

View file

@ -101,3 +101,5 @@ In addition to numerous new and upgraded packages, this release has the followin
e.g. Wayland.
- The `services.stubby` module was converted to a [settings-style](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration.
- The option `services.duplicati.dataDir` has been added to allow changing the location of duplicati's files.

View file

@ -18,6 +18,20 @@ in
'';
};
dataDir = mkOption {
type = types.str;
default = "/var/lib/duplicati";
description = ''
The directory where Duplicati stores its data files.
<note><para>
If left as the default value this directory will automatically be created
before the Duplicati server starts, otherwise you are responsible for ensuring
the directory exists with appropriate ownership and permissions.
</para></note>
'';
};
interface = mkOption {
default = "127.0.0.1";
type = types.str;
@ -45,20 +59,23 @@ in
description = "Duplicati backup";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = cfg.user;
Group = "duplicati";
StateDirectory = "duplicati";
ExecStart = "${pkgs.duplicati}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=/var/lib/duplicati";
Restart = "on-failure";
};
serviceConfig = mkMerge [
{
User = cfg.user;
Group = "duplicati";
ExecStart = "${pkgs.duplicati}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=${cfg.dataDir}";
Restart = "on-failure";
}
(mkIf (cfg.dataDir == "/var/lib/duplicati") {
StateDirectory = "duplicati";
})
];
};
users.users = lib.optionalAttrs (cfg.user == "duplicati") {
duplicati = {
uid = config.ids.uids.duplicati;
home = "/var/lib/duplicati";
createHome = true;
home = cfg.dataDir;
group = "duplicati";
};
};