update to 0.16.2
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Jeffrey C. Ollie 2023-11-03 12:19:05 -05:00
parent 081a664fac
commit 25ddd648bc
Signed by: jeff
GPG key ID: 6F86035A6D97044E
2 changed files with 376 additions and 367 deletions

View file

@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1697851979,
"narHash": "sha256-lJ8k4qkkwdvi+t/Xc6Fn74kUuobpu9ynPGxNZR6OwoA=",
"lastModified": 1698846319,
"narHash": "sha256-4jyW/dqFBVpWFnhl0nvP6EN4lP7/ZqPxYRjl6var0Oc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5550a85a087c04ddcace7f892b0bdc9d8bb080c8",
"rev": "34bdaaf1f0b7fb6d9091472edc968ff10a8c2857",
"type": "github"
},
"original": {

119
flake.nix
View file

@ -9,21 +9,24 @@
url = "github:numtide/flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
(
system: let
pkgs = import nixpkgs {
inherit system;
};
in
{
in {
packages = {
restic =
let
restic = let
pname = "restic";
version = "0.16.1";
hash = "sha256-sMxOZEnZr2UdhmwLXQnggQzw+pXcoWmqqADlQ0yDhj8=";
version = "0.16.2";
hash = "sha256-Qrbg8/f1ne+7c+mnUc/8CoZBjiGLohJXnu0cnc0pT4g=";
vendorHash = "sha256-Ctg6bln5kzGs7gDLo9zUpsbSybKOtHFuHvHG3cxCfac=";
in
pkgs.buildGoModule {
@ -58,14 +61,17 @@
# rm cmd/restic/integration_fuse_test.go
'';
postInstall = ''
postInstall =
''
wrapProgram $out/bin/restic --prefix PATH : '${pkgs.rclone}/bin'
'' + pkgs.lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
''
+ pkgs.lib.optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
$out/bin/restic generate \
--bash-completion restic.bash \
--fish-completion restic.fish \
--zsh-completion restic.zsh \
--man .
installShellCompletion restic.{bash,zsh}
installShellCompletion restic.{bash,fish,zsh}
installManPage *.1
'';
@ -116,14 +122,18 @@
};
};
}
) // {
)
// {
nixosModules = {
restic = { config, lib, pkgs, ... }:
let
restic = {
config,
lib,
pkgs,
...
}: let
cfg = config.restic;
package = self.packages.${pkgs.system}.restic;
in
{
in {
options = {
restic = lib.options.mkOption {
type = lib.types.submodule {
@ -220,28 +230,27 @@
};
};
config =
let
bucket = {
config = let
bucket =
{
"b2" = cfg.b2.bucket;
"azure" = builtins.replaceStrings ["."] ["-"] "${config.networking.hostName}.${config.networking.domain}";
}.${cfg.storage};
}
.${cfg.storage};
directory = {
directory =
{
"b2" = "${config.networking.hostName}.${config.networking.domain}";
"azure" = "/";
}.${cfg.storage};
}
.${cfg.storage};
in
lib.mkIf cfg.enable {
environment.systemPackages = [
package
];
systemd.services.restic =
let
systemd.services.restic = let
curlOptions = "--fail --silent --show-error --max-time 10 --retry 5";
hcPayload =
if cfg.healthcheck.enable
@ -259,15 +268,13 @@
}
)
)
else
null;
else null;
hcSetup =
if cfg.healthcheck.enable
then ''
HC_URL=''$(${pkgs.curl}/bin/curl ${curlOptions} --request POST --header 'Content-Type: application/json' --header "X-Api-Key: ''$(<${cfg.healthcheck.apiKeyFile})" --data @${hcPayload} "${cfg.healthcheck.apiUrl}" | ${pkgs.jq}/bin/jq -r .ping_url)
''
else
"";
else "";
hcStart =
if cfg.healthcheck.enable
then ''
@ -276,8 +283,7 @@
${pkgs.curl}/bin/curl ${curlOptions} --output /dev/null "''${HC_URL}/start" || true
fi
''
else
"";
else "";
hcStop =
if cfg.healthcheck.enable
then ''
@ -286,15 +292,17 @@
${pkgs.curl}/bin/curl ${curlOptions} --output /dev/null "''${HC_URL}" || true
fi
''
else
"";
else "";
repositoryConfig = {
repositoryConfig =
{
"b2" = "b2:${bucket}:${directory}";
"azure" = "azure:${bucket}:${directory}";
}.${cfg.storage};
}
.${cfg.storage};
resticConfig = ''
resticConfig =
''
export RESTIC_CACHE_DIR=/var/cache/restic
export RESTIC_PASSWORD_FILE=${cfg.passwordFile}
export RESTIC_REPOSITORY=${repositoryConfig}
@ -308,26 +316,27 @@
export AZURE_ACCOUNT_NAME='${cfg.azure.accountName}'
export AZURE_ACCOUNT_KEY="''$(<${cfg.azure.accountKeyFile})"
'';
}.${cfg.storage};
}
.${cfg.storage};
backupCommands = lib.strings.concatStringsSep "\n"
backupCommands =
lib.strings.concatStringsSep "\n"
(
map
(
backup:
let
backup: let
oneFileSystem =
if backup.oneFileSystem
then
[ "--one-file-system" ]
else
[ ];
excludes = map
then ["--one-file-system"]
else [];
excludes =
map
(
exclude: ''--exclude="${exclude}"''
)
backup.excludes;
paths = map
paths =
map
(
path: ''"${path}"''
)
@ -335,8 +344,7 @@
arguments = lib.strings.concatStringsSep " " (
oneFileSystem ++ excludes ++ paths
);
in
''
in ''
${backup.preCommand}
${package}/bin/restic backup ${arguments}
${backup.postCommand}
@ -344,7 +352,8 @@
)
cfg.backups
);
initCheck = {
initCheck =
{
"b2" = ''
export RCLONE_CONFIG=/dev/null
export RCLONE_CONFIG_B2_TYPE=b2
@ -379,9 +388,9 @@
${package}/bin/restic init
fi
'';
}.${cfg.storage};
in
{
}
.${cfg.storage};
in {
serviceConfig = {
Type = "oneshot";
CacheDirectory = "restic";