krebs.backup writeDash* -> pkgs
This commit is contained in:
parent
949f466cf7
commit
02ad327081
@ -128,11 +128,11 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
push = plan: let
|
push = plan: let
|
||||||
# We use writeDashBin and return the absolute path so systemd will produce
|
# We use pkgs.writeDashBin and return the absolute path so systemd will
|
||||||
# nice names in the log, i.e. without the Nix store hash.
|
# produce nice names in the log, i.e. without the Nix store hash.
|
||||||
out = "${main}/bin/${main.name}";
|
out = "${main}/bin/${main.name}";
|
||||||
|
|
||||||
main = writeDashBin "backup.${plan.name}.push" ''
|
main = pkgs.writeDashBin "backup.${plan.name}.push" ''
|
||||||
set -efu
|
set -efu
|
||||||
dst=${shell.escape plan.dst.path}
|
dst=${shell.escape plan.dst.path}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ let
|
|||||||
exec flock -n "$dst" ${critical-section}
|
exec flock -n "$dst" ${critical-section}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
critical-section = writeDash "backup.${plan.name}.push.critical-section" ''
|
critical-section = pkgs.writeDash "backup.${plan.name}.push.critical-section" ''
|
||||||
# TODO check if there is a previous
|
# TODO check if there is a previous
|
||||||
set -efu
|
set -efu
|
||||||
identity=${shell.escape plan.src.host.ssh.privkey.path}
|
identity=${shell.escape plan.src.host.ssh.privkey.path}
|
||||||
@ -173,7 +173,7 @@ let
|
|||||||
env NOW="$NOW" /bin/sh < ${remote-snapshot}
|
env NOW="$NOW" /bin/sh < ${remote-snapshot}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
remote-snapshot = writeDash "backup.${plan.name}.push.remote-snapshot" ''
|
remote-snapshot = pkgs.writeDash "backup.${plan.name}.push.remote-snapshot" ''
|
||||||
set -efu
|
set -efu
|
||||||
dst=${shell.escape plan.dst.path}
|
dst=${shell.escape plan.dst.path}
|
||||||
|
|
||||||
@ -191,11 +191,11 @@ let
|
|||||||
|
|
||||||
# TODO admit plan.dst.user and its ssh identity
|
# TODO admit plan.dst.user and its ssh identity
|
||||||
pull = plan: let
|
pull = plan: let
|
||||||
# We use writeDashBin and return the absolute path so systemd will produce
|
# We use pkgs.writeDashBin and return the absolute path so systemd will
|
||||||
# nice names in the log, i.e. without the Nix store hash.
|
# produce nice names in the log, i.e. without the Nix store hash.
|
||||||
out = "${main}/bin/${main.name}";
|
out = "${main}/bin/${main.name}";
|
||||||
|
|
||||||
main = writeDashBin "backup.${plan.name}.pull" ''
|
main = pkgs.writeDashBin "backup.${plan.name}.pull" ''
|
||||||
set -efu
|
set -efu
|
||||||
dst=${shell.escape plan.dst.path}
|
dst=${shell.escape plan.dst.path}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ let
|
|||||||
exec flock -n "$dst" ${critical-section}
|
exec flock -n "$dst" ${critical-section}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
critical-section = writeDash "backup.${plan.name}.pull.critical-section" ''
|
critical-section = pkgs.writeDash "backup.${plan.name}.pull.critical-section" ''
|
||||||
# TODO check if there is a previous
|
# TODO check if there is a previous
|
||||||
set -efu
|
set -efu
|
||||||
identity=${shell.escape plan.dst.host.ssh.privkey.path}
|
identity=${shell.escape plan.dst.host.ssh.privkey.path}
|
||||||
@ -235,7 +235,7 @@ let
|
|||||||
'';
|
'';
|
||||||
in out;
|
in out;
|
||||||
|
|
||||||
take-snapshots = plan: writeDash "backup.${plan.name}.take-snapshots" ''
|
take-snapshots = plan: pkgs.writeDash "backup.${plan.name}.take-snapshots" ''
|
||||||
set -efu
|
set -efu
|
||||||
NOW=''${NOW-$(date +%s)}
|
NOW=''${NOW-$(date +%s)}
|
||||||
dst=${shell.escape plan.dst.path}
|
dst=${shell.escape plan.dst.path}
|
||||||
@ -280,21 +280,6 @@ let
|
|||||||
plan.snapshots)}
|
plan.snapshots)}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
writeDash = name: text: pkgs.writeScript name ''
|
|
||||||
#! ${pkgs.dash}/bin/dash
|
|
||||||
${text}
|
|
||||||
'';
|
|
||||||
|
|
||||||
writeDashBin = name: text: pkgs.writeTextFile {
|
|
||||||
executable = true;
|
|
||||||
destination = "/bin/${name}";
|
|
||||||
name = name;
|
|
||||||
text = ''
|
|
||||||
#! ${pkgs.dash}/bin/dash
|
|
||||||
${text}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# XXX Is one ping enough to determine fastest address?
|
# XXX Is one ping enough to determine fastest address?
|
||||||
# Note that we're using net.addrs4 instead of net.aliases because we define
|
# Note that we're using net.addrs4 instead of net.aliases because we define
|
||||||
# ports only for addresses. See krebs/3modules/default.nix
|
# ports only for addresses. See krebs/3modules/default.nix
|
||||||
|
@ -61,6 +61,21 @@ subdirs // rec {
|
|||||||
strip --strip-unneeded "$exe"
|
strip --strip-unneeded "$exe"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
writeDash = name: text: pkgs.writeScript name ''
|
||||||
|
#! ${pkgs.dash}/bin/dash
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
|
||||||
|
writeDashBin = name: text: pkgs.writeTextFile {
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/${name}";
|
||||||
|
name = name;
|
||||||
|
text = ''
|
||||||
|
#! ${pkgs.dash}/bin/dash
|
||||||
|
${text}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
writeNixFromCabal = name: path: pkgs.runCommand name {} ''
|
writeNixFromCabal = name: path: pkgs.runCommand name {} ''
|
||||||
${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
|
${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user