Add support for tarsnap options -H and -L

A new option `explicitSymlinks` will set `-H` when creating an archive.
This option makes tarsnap follow any symlinks specified explicitly on
the commandline, but not any found inside the file tree.

A new option `followSymlinks` will set `-L` when creating an archive.
This option makes tarsnap follow any symlinks found anywhere in the file
tree instead of storing them as-is.
This commit is contained in:
Michishige Kaito 2018-03-26 12:39:00 +01:00
parent adaa9d9348
commit d462595600

View file

@ -238,6 +238,20 @@ in
Whether to produce verbose logging output. Whether to produce verbose logging output.
''; '';
}; };
explicitSymlinks = mkOption {
type = types.bool;
default = false;
description = ''
Whether to follow symlinks specified as archives.
'';
};
followSymlinks = mkOption {
type = types.bool;
default = false;
description = ''
Whether to follow all symlinks in archive trees.
'';
};
}; };
} }
)); ));
@ -304,6 +318,8 @@ in
let run = ''tarsnap --configfile "/etc/tarsnap/${name}.conf" \ let run = ''tarsnap --configfile "/etc/tarsnap/${name}.conf" \
-c -f "${name}-$(date +"%Y%m%d%H%M%S")" \ -c -f "${name}-$(date +"%Y%m%d%H%M%S")" \
${optionalString cfg.verbose "-v"} \ ${optionalString cfg.verbose "-v"} \
${optionalString cfg.explicitSymlinks "-H"} \
${optionalString cfg.followSymlinks "-L"} \
${concatStringsSep " " cfg.directories}''; ${concatStringsSep " " cfg.directories}'';
in if (cfg.cachedir != null) then '' in if (cfg.cachedir != null) then ''
mkdir -p ${cfg.cachedir} mkdir -p ${cfg.cachedir}