mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 04:02:55 +03:00
rsnapshot module: Avoid package rebuild, pass config file explicitly.
This commit is contained in:
parent
7abe192b05
commit
c90d5eb298
@ -2,7 +2,19 @@
|
||||
|
||||
with lib;
|
||||
|
||||
let cfg = config.services.rsnapshot;
|
||||
let
|
||||
cfg = config.services.rsnapshot;
|
||||
cfgfile = pkgs.writeText "rsnapshot.conf" ''
|
||||
config_version 1.2
|
||||
cmd_cp ${pkgs.coreutils}/bin/cp
|
||||
cmd_rsync ${pkgs.rsync}/bin/rsync
|
||||
cmd_ssh ${pkgs.openssh}/bin/ssh
|
||||
cmd_logger ${pkgs.inetutils}/bin/logger
|
||||
cmd_du ${pkgs.coreutils}/bin/du
|
||||
lockfile /run/rsnapshot.pid
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@ -39,37 +51,11 @@ in
|
||||
as retain options.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.rsnapshot;
|
||||
defaultText = "pkgs.rsnapshot";
|
||||
example = literalExample "pkgs.rsnapshotGit";
|
||||
description = ''
|
||||
RSnapshot package to use.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (let
|
||||
myRsnapshot = cfg.package.override { configFile = rsnapshotCfg; };
|
||||
rsnapshotCfg = with pkgs; writeText "gen-rsnapshot.conf" (''
|
||||
config_version 1.2
|
||||
cmd_cp ${coreutils}/bin/cp
|
||||
cmd_rsync ${rsync}/bin/rsync
|
||||
cmd_ssh ${openssh}/bin/ssh
|
||||
cmd_logger ${inetutils}/bin/logger
|
||||
cmd_du ${coreutils}/bin/du
|
||||
lockfile /run/rsnapshot.pid
|
||||
|
||||
${cfg.extraConfig}
|
||||
'');
|
||||
in {
|
||||
environment.systemPackages = [ myRsnapshot ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.cron.systemCronJobs =
|
||||
mapAttrsToList (interval: time: "${time} root ${myRsnapshot}/bin/rsnapshot ${interval}") cfg.cronIntervals;
|
||||
}
|
||||
);
|
||||
mapAttrsToList (interval: time: "${time} root ${pkgs.rsnapshot}/bin/rsnapshot -c ${cfgfile} ${interval}") cfg.cronIntervals;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user