Add flake.nix and update tests
This commit is contained in:
parent
8a04318f93
commit
d6a521950f
5 changed files with 105 additions and 5 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
coverage
|
||||
.direnv
|
||||
|
|
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1723175592,
|
||||
"narHash": "sha256-M0xJ3FbDUc4fRZ84dPGx5VvgFsOzds77KiBMW/mMTnI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5e0ca22929f3342b19569b21b2f3462f053e497b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
36
flake.nix
Normal file
36
flake.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
description = "A flake for bash, coreutils, xxd, restic, util-linux, and openssh";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
bash
|
||||
coreutils
|
||||
kcov
|
||||
vim # provides xxd
|
||||
python3
|
||||
python312Packages.fusepy
|
||||
restic
|
||||
screen
|
||||
shellcheck
|
||||
tmux
|
||||
utillinux
|
||||
openssh
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
11
test/test.sh
11
test/test.sh
|
@ -136,8 +136,6 @@ test-file-changed-as-read-warning () {
|
|||
assert-equals-directory "$WORLD_DIR/file3.txt" "$TEST_TMP/restored/$WORLD_DIR/file3.txt"
|
||||
}
|
||||
|
||||
|
||||
|
||||
test-lock-defaults () {
|
||||
TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01")"
|
||||
./backup.sh -t "$TEST_TMP/lockfile" -i "$TEST_TMP/server/world" -o "$TEST_TMP/backups" -s "$SCREEN_TMP" -f "$TIMESTAMP"
|
||||
|
@ -241,7 +239,6 @@ test-restic-defaults () {
|
|||
check-latest-backup-restic
|
||||
}
|
||||
|
||||
|
||||
test-backup-spaces-in-directory () {
|
||||
TIMESTAMP="$(date +%F_%H-%M-%S --date="2021-01-01")"
|
||||
WORLD_SPACES="$TEST_TMP/minecraft server/the world"
|
||||
|
@ -473,6 +470,7 @@ test-restic-thinning-delete () {
|
|||
done
|
||||
EXPECTED_TIMESTAMPS=(
|
||||
# Weekly
|
||||
"2021-01-01 00:00:00"
|
||||
|
||||
# Daily (30)
|
||||
"2021-01-01 23:00:00"
|
||||
|
@ -512,11 +510,14 @@ test-restic-thinning-delete () {
|
|||
assertContains "$SNAPSHOTS" "$TIMESTAMP"
|
||||
done
|
||||
UNEXPECTED_TIMESTAMPS=(
|
||||
"2021-01-01 00:00:00"
|
||||
"2021-01-01 01:00:00"
|
||||
"2021-01-01 02:00:00"
|
||||
"2021-01-02 22:00:00"
|
||||
"2021-01-03 22:00:00"
|
||||
"2021-01-04 00:00:00"
|
||||
)
|
||||
for TIMESTAMP in "${UNEXPECTED_TIMESTAMPS[@]}"; do
|
||||
assertNotContains "$SNAPSHOTS" "$TIMESTAMP"
|
||||
assertNotContains "$SNAPSHOTS" "$TIMESTAMP"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue