diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 4ebc8ae..dc894ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ coverage +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6e99d27 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2433017 --- /dev/null +++ b/flake.nix @@ -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 + ]; + }; + } + ); +} diff --git a/test/test.sh b/test/test.sh index 5935aab..3690347 100755 --- a/test/test.sh +++ b/test/test.sh @@ -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,10 +510,14 @@ 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" + assertNotContains "$SNAPSHOTS" "$TIMESTAMP" done }