mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
tarsnap: add package option
This commit is contained in:
parent
d0c7a8f1c9
commit
a936b9edec
|
@ -32,6 +32,8 @@ in
|
||||||
services.tarsnap = {
|
services.tarsnap = {
|
||||||
enable = mkEnableOption (lib.mdDoc "periodic tarsnap backups");
|
enable = mkEnableOption (lib.mdDoc "periodic tarsnap backups");
|
||||||
|
|
||||||
|
package = mkPackageOption pkgs "tarsnap" { };
|
||||||
|
|
||||||
keyfile = mkOption {
|
keyfile = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "/root/tarsnap.key";
|
default = "/root/tarsnap.key";
|
||||||
|
@ -307,7 +309,7 @@ in
|
||||||
requires = [ "network-online.target" ];
|
requires = [ "network-online.target" ];
|
||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
|
|
||||||
path = with pkgs; [ iputils tarsnap util-linux ];
|
path = with pkgs; [ iputils gcfg.package util-linux ];
|
||||||
|
|
||||||
# In order for the persistent tarsnap timer to work reliably, we have to
|
# In order for the persistent tarsnap timer to work reliably, we have to
|
||||||
# make sure that the tarsnap server is reachable after systemd starts up
|
# make sure that the tarsnap server is reachable after systemd starts up
|
||||||
|
@ -318,7 +320,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
script = let
|
script = let
|
||||||
tarsnap = ''tarsnap --configfile "/etc/tarsnap/${name}.conf"'';
|
tarsnap = ''${lib.getExe gcfg.package} --configfile "/etc/tarsnap/${name}.conf"'';
|
||||||
run = ''${tarsnap} -c -f "${name}-$(date +"%Y%m%d%H%M%S")" \
|
run = ''${tarsnap} -c -f "${name}-$(date +"%Y%m%d%H%M%S")" \
|
||||||
${optionalString cfg.verbose "-v"} \
|
${optionalString cfg.verbose "-v"} \
|
||||||
${optionalString cfg.explicitSymlinks "-H"} \
|
${optionalString cfg.explicitSymlinks "-H"} \
|
||||||
|
@ -355,10 +357,10 @@ in
|
||||||
description = "Tarsnap restore '${name}'";
|
description = "Tarsnap restore '${name}'";
|
||||||
requires = [ "network-online.target" ];
|
requires = [ "network-online.target" ];
|
||||||
|
|
||||||
path = with pkgs; [ iputils tarsnap util-linux ];
|
path = with pkgs; [ iputils gcfg.package util-linux ];
|
||||||
|
|
||||||
script = let
|
script = let
|
||||||
tarsnap = ''tarsnap --configfile "/etc/tarsnap/${name}.conf"'';
|
tarsnap = ''${lib.getExe gcfg.package} --configfile "/etc/tarsnap/${name}.conf"'';
|
||||||
lastArchive = "$(${tarsnap} --list-archives | sort | tail -1)";
|
lastArchive = "$(${tarsnap} --list-archives | sort | tail -1)";
|
||||||
run = ''${tarsnap} -x -f "${lastArchive}" ${optionalString cfg.verbose "-v"}'';
|
run = ''${tarsnap} -x -f "${lastArchive}" ${optionalString cfg.verbose "-v"}'';
|
||||||
cachedir = escapeShellArg cfg.cachedir;
|
cachedir = escapeShellArg cfg.cachedir;
|
||||||
|
@ -402,6 +404,6 @@ in
|
||||||
{ text = configFile name cfg;
|
{ text = configFile name cfg;
|
||||||
}) gcfg.archives;
|
}) gcfg.archives;
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.tarsnap ];
|
environment.systemPackages = [ gcfg.package ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue