diff options
author | Domen Kožar <domen@dev.si> | 2019-06-25 14:28:03 +0200 |
---|---|---|
committer | Domen Kožar <domen@dev.si> | 2019-06-25 14:28:03 +0200 |
commit | e8916cc6af7daf2de5008f3063441c8b3f00e9ac (patch) | |
tree | 41de14cf04d60718a9ee8b610d6740c4092cca91 /nixos | |
parent | 53ac12b25be037ef59e0fba34ac671bac01d7421 (diff) | |
download | nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.tar nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.tar.gz nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.tar.bz2 nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.tar.lz nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.tar.xz nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.tar.zst nixlib-e8916cc6af7daf2de5008f3063441c8b3f00e9ac.zip |
duplicati: allow changing the user
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/backup/duplicati.nix | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/nixos/modules/services/backup/duplicati.nix b/nixos/modules/services/backup/duplicati.nix index a3af3d9b5c9f..d2fe4698e885 100644 --- a/nixos/modules/services/backup/duplicati.nix +++ b/nixos/modules/services/backup/duplicati.nix @@ -26,6 +26,15 @@ in Set it to "any" to listen on all available interfaces ''; }; + + user = mkOption { + default = "duplicati"; + type = types.str; + description = '' + Duplicati runs as it's own user. It will only be able to backup world-readable files. + Run as root with special care. + ''; + }; }; }; @@ -37,14 +46,19 @@ in after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { - User = "duplicati"; + User = cfg.user; + PermissionsStartOnly = true; Group = "duplicati"; ExecStart = "${pkgs.duplicati}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=/var/lib/duplicati"; Restart = "on-failure"; }; + preStart = '' + mkdir -p /var/lib/duplicati + chown -R ${cfg.user}:duplicati /var/lib/duplicati + ''; }; - users.users.duplicati = { + users.users.duplicati = lib.optionalAttrs (cfg.user == "duplicati") { uid = config.ids.uids.duplicati; home = "/var/lib/duplicati"; createHome = true; |