From 93b196f86886ec0516f4e4146313cafcd8e817bf Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 17 Oct 2026 17:15:45 +0200 Subject: refactor: make workstation packages buildable via packages.* --- nixos/profiles/workstation/pkgs/scripts/package.nix | 11 +++++++++++ nixos/profiles/workstation/pkgs/scripts/src/ed | 12 ++++++++++++ nixos/profiles/workstation/pkgs/scripts/src/rsqlite | 15 +++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 nixos/profiles/workstation/pkgs/scripts/package.nix create mode 100755 nixos/profiles/workstation/pkgs/scripts/src/ed create mode 100755 nixos/profiles/workstation/pkgs/scripts/src/rsqlite (limited to 'nixos/profiles/workstation/pkgs/scripts') diff --git a/nixos/profiles/workstation/pkgs/scripts/package.nix b/nixos/profiles/workstation/pkgs/scripts/package.nix new file mode 100644 index 0000000..53d408a --- /dev/null +++ b/nixos/profiles/workstation/pkgs/scripts/package.nix @@ -0,0 +1,11 @@ +{ stdenvNoCC }: + +stdenvNoCC.mkDerivation { + name = "workstation-scripts"; + src = ./src; + + installPhase = '' + mkdir -p $out/bin + cp $src/* $out/bin/ + ''; +} diff --git a/nixos/profiles/workstation/pkgs/scripts/src/ed b/nixos/profiles/workstation/pkgs/scripts/src/ed new file mode 100755 index 0000000..e6c23d3 --- /dev/null +++ b/nixos/profiles/workstation/pkgs/scripts/src/ed @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +list_files() { + if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + git -c core.quotePath=false ls-files --cached --others --exclude-standard + else + find . -type f -not -path "*/.*" + fi +} + +files=$(list_files | sk --no-info "$@") || exit +$VISUAL "$files" diff --git a/nixos/profiles/workstation/pkgs/scripts/src/rsqlite b/nixos/profiles/workstation/pkgs/scripts/src/rsqlite new file mode 100755 index 0000000..d9dc2ae --- /dev/null +++ b/nixos/profiles/workstation/pkgs/scripts/src/rsqlite @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +if [[ "$#" != 2 && "$#" != "3" ]]; then + echo "usage: $0 [sql]" + exit 1 +fi + +printf -v path %q "$2" + +if [[ "$#" == "3" ]]; then + printf -v sql %q "$3" +else + sql="" +fi + +ssh "$1" -t "sudo su -c 'sqlite3 /var/lib/$path $sql'" -- cgit v1.3.1