From 0141ca45f0c6d7da7fb160a28ff28707d062360c Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 17 Sep 2025 21:59:33 +0100 Subject: [PATCH] Add `weight` and `add-weight` scripts Signed-off-by: Oliver Davies --- modules/scripts/add-weight.nix | 34 ++++++++++++++++++++++++++++++++++ modules/scripts/weight.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 modules/scripts/add-weight.nix create mode 100644 modules/scripts/weight.nix diff --git a/modules/scripts/add-weight.nix b/modules/scripts/add-weight.nix new file mode 100644 index 00000000..cb884e97 --- /dev/null +++ b/modules/scripts/add-weight.nix @@ -0,0 +1,34 @@ +{ withSystem, ... }: + +let + name = "add-weight"; +in +{ + perSystem = + psArgs@{ pkgs, ... }: + { + packages.${name} = pkgs.writeShellApplication { + inherit name; + + runtimeInputs = with pkgs; [ + coreutils + psArgs.config.packages.today2 + psArgs.config.packages.weight + ]; + + text = '' + echo "$(today2),$1" >> "$XDG_DOCUMENTS_DIR/wiki/2-areas/health-fitness/weight.csv" + + weight + ''; + }; + }; + + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = [ + (withSystem pkgs.system (psArgs: psArgs.config.packages.${name})) + ]; + }; +} diff --git a/modules/scripts/weight.nix b/modules/scripts/weight.nix new file mode 100644 index 00000000..4c63f47c --- /dev/null +++ b/modules/scripts/weight.nix @@ -0,0 +1,28 @@ +{ withSystem, ... }: + +let + name = "weight"; +in +{ + perSystem = + { pkgs, ... }: + { + packages.${name} = pkgs.writeShellApplication { + inherit name; + + runtimeInputs = with pkgs; [ + coreutils + ]; + + text = ''tail "$XDG_DOCUMENTS_DIR/wiki/2-areas/health-fitness/weight.csv"''; + }; + }; + + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = [ + (withSystem pkgs.system (psArgs: psArgs.config.packages.${name})) + ]; + }; +}