From 37b77e488024a184c9cd331f02f72f73d549abdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sun, 4 May 2025 11:25:32 +0200 Subject: [PATCH] Add noita-helper script --- home/scripts/default.nix | 5 ++++- home/scripts/noita-helper.nix | 14 ++++++++++++++ home/scripts/noita-helper.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 home/scripts/noita-helper.nix create mode 100644 home/scripts/noita-helper.sh diff --git a/home/scripts/default.nix b/home/scripts/default.nix index 0a97f32..d4f1e75 100644 --- a/home/scripts/default.nix +++ b/home/scripts/default.nix @@ -1,6 +1,9 @@ { pkgs, config, ... }: { - imports = [ ./lockhelper.nix ]; + imports = [ + ./lockhelper.nix + ./noita-helper.nix + ]; home.file.".local/bin/hl-no-opacity" = { source = ./hl-no-opacity.sh; executable = true; diff --git a/home/scripts/noita-helper.nix b/home/scripts/noita-helper.nix new file mode 100644 index 0000000..bbbb6a6 --- /dev/null +++ b/home/scripts/noita-helper.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +let + noita-helper = pkgs.writeShellApplication { + name = "noita-helper"; + runtimeInputs = with pkgs; [ + grim + jq + ]; + text = (builtins.readFile ./noita-helper.sh); + }; +in +{ + home.packages = [ noita-helper ]; +} diff --git a/home/scripts/noita-helper.sh b/home/scripts/noita-helper.sh new file mode 100644 index 0000000..b4491d8 --- /dev/null +++ b/home/scripts/noita-helper.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +SAVE_DIR="/home/torjus/.local/share/Steam/steamapps/compatdata/881100/pfx/drive_c/users/steamuser/AppData/LocalLow/Nolla_Games_Noita" + +RESTIC_REPOSITORY="/home/$(whoami)/tmp/noita-backup" +export RESTIC_REPOSITORY +export RESTIC_PASSWORD="noita" + +echo "Doing initial backup" +restic backup -q "$SAVE_DIR" +echo "Backup done" + +echo "Mounting tmpfs for save folder..." +sudo mount -o size=2G -t tmpfs none "$SAVE_DIR" + +echo "Restoring initial backup..." +restic restore "latest:$SAVE_DIR" --target "$SAVE_DIR" + +echo "Ready to play Noita!" +echo "Remember to unmount the tmpfs after playing:" +echo "sudo umount $SAVE_DIR" +echo "restic restore latest:$SAVE_DIR --target $SAVE_DIR" + +while true +do + restic backup -q "$SAVE_DIR" + echo "Periodic backup done..." + sleep 30m +done