forked from mirrors/nixpkgs
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
91 lines
2.8 KiB
Nix
91 lines
2.8 KiB
Nix
{ lib, pkgs, config, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.zfs.autoReplication;
|
|
recursive = optionalString cfg.recursive " --recursive";
|
|
followDelete = optionalString cfg.followDelete " --follow-delete";
|
|
in {
|
|
options = {
|
|
services.zfs.autoReplication = {
|
|
enable = mkEnableOption "ZFS snapshot replication.";
|
|
|
|
followDelete = mkOption {
|
|
description = lib.mdDoc "Remove remote snapshots that don't have a local correspondant.";
|
|
default = true;
|
|
type = types.bool;
|
|
};
|
|
|
|
host = mkOption {
|
|
description = lib.mdDoc "Remote host where snapshots should be sent. `lz4` is expected to be installed on this host.";
|
|
example = "example.com";
|
|
type = types.str;
|
|
};
|
|
|
|
identityFilePath = mkOption {
|
|
description = lib.mdDoc "Path to SSH key used to login to host.";
|
|
example = "/home/username/.ssh/id_rsa";
|
|
type = types.path;
|
|
};
|
|
|
|
localFilesystem = mkOption {
|
|
description = lib.mdDoc "Local ZFS fileystem from which snapshots should be sent. Defaults to the attribute name.";
|
|
example = "pool/file/path";
|
|
type = types.str;
|
|
};
|
|
|
|
remoteFilesystem = mkOption {
|
|
description = lib.mdDoc "Remote ZFS filesystem where snapshots should be sent.";
|
|
example = "pool/file/path";
|
|
type = types.str;
|
|
};
|
|
|
|
recursive = mkOption {
|
|
description = lib.mdDoc "Recursively discover snapshots to send.";
|
|
default = true;
|
|
type = types.bool;
|
|
};
|
|
|
|
username = mkOption {
|
|
description = lib.mdDoc "Username used by SSH to login to remote host.";
|
|
example = "username";
|
|
type = types.str;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.systemPackages = [
|
|
pkgs.lz4
|
|
];
|
|
|
|
systemd.services.zfs-replication = {
|
|
after = [
|
|
"zfs-snapshot-daily.service"
|
|
"zfs-snapshot-frequent.service"
|
|
"zfs-snapshot-hourly.service"
|
|
"zfs-snapshot-monthly.service"
|
|
"zfs-snapshot-weekly.service"
|
|
];
|
|
description = "ZFS Snapshot Replication";
|
|
documentation = [
|
|
"https://github.com/alunduil/zfs-replicate"
|
|
];
|
|
restartIfChanged = false;
|
|
serviceConfig.ExecStart = "${pkgs.zfs-replicate}/bin/zfs-replicate${recursive} -l ${escapeShellArg cfg.username} -i ${escapeShellArg cfg.identityFilePath}${followDelete} ${escapeShellArg cfg.host} ${escapeShellArg cfg.remoteFilesystem} ${escapeShellArg cfg.localFilesystem}";
|
|
wantedBy = [
|
|
"zfs-snapshot-daily.service"
|
|
"zfs-snapshot-frequent.service"
|
|
"zfs-snapshot-hourly.service"
|
|
"zfs-snapshot-monthly.service"
|
|
"zfs-snapshot-weekly.service"
|
|
];
|
|
};
|
|
};
|
|
|
|
meta = {
|
|
maintainers = with lib.maintainers; [ alunduil ];
|
|
};
|
|
}
|