Skip to content

Commit b7c8e22

Browse files
gabevenbergbachp
authored andcommitted
nixos/restic-rest-server: add htpasswd-file setting
in the restic rest-server, you can set the file to use in place of $datadir/.htpasswd with the --htpasswd-file option. However, this was unusable from the module with extraConfig, due to systemd hardening. Adding a dedicated option fixes this.
1 parent dc585df commit b7c8e22

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

nixos/modules/services/backup/restic-rest-server.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ in
3636
'';
3737
};
3838

39+
htpasswd-file = lib.mkOption {
40+
default = null;
41+
type = lib.types.nullOr lib.types.path;
42+
description = "The path to the servers .htpasswd file. Defaults to {dataDir}/htpasswd.";
43+
};
44+
3945
privateRepos = lib.mkOption {
4046
default = false;
4147
type = lib.types.bool;
@@ -84,6 +90,7 @@ in
8490
ExecStart = ''
8591
${cfg.package}/bin/rest-server \
8692
--path ${cfg.dataDir} \
93+
--htpasswd-file ${cfg.htpasswd-file} \
8794
${lib.optionalString cfg.appendOnly "--append-only"} \
8895
${lib.optionalString cfg.privateRepos "--private-repos"} \
8996
${lib.optionalString cfg.prometheus "--prometheus"} \
@@ -112,6 +119,7 @@ in
112119
ProtectControlGroups = true;
113120
PrivateDevices = true;
114121
ReadWritePaths = [ cfg.dataDir ];
122+
ReadOnlyPaths = [ cfg.htpasswd-file ];
115123
RemoveIPC = true;
116124
RestrictAddressFamilies = "none";
117125
RestrictNamespaces = true;

0 commit comments

Comments
 (0)