Merge pull request #32 from nicolaschan/flake

Add flake.nix and update tests
This commit is contained in:
Nicolas Chan 2024-08-11 01:01:10 -07:00 committed by GitHub
commit dfb1a1c27d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 105 additions and 5 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View file

@ -1 +1,2 @@
coverage
.direnv

61
flake.lock generated Normal file
View 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
View 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
];
};
}
);
}

View file

@ -50,7 +50,7 @@ assert-equals-directory () {
fi
if [ -d "$1" ]; then
for FILE in "$1"/*; do
assert-equals-directory "$FILE" "$2/${FILE##$1}"
assert-equals-directory "$FILE" "$2/${FILE##"$1"}"
done
else
assertEquals "$(cat "$1")" "$(cat "$2")"
@ -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"
@ -513,7 +510,11 @@ test-restic-thinning-delete () {
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"