From 9b1391a9f69fd84b9cd83587188397e9efb3d8f4 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 16 Sep 2024 16:33:42 +0200 Subject: [PATCH] Add p command to paste files --- m/hut/configuration.nix | 1 + m/hut/p.nix | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 m/hut/p.nix diff --git a/m/hut/configuration.nix b/m/hut/configuration.nix index 3a14eb6..f232df2 100644 --- a/m/hut/configuration.nix +++ b/m/hut/configuration.nix @@ -18,6 +18,7 @@ ./msmtp.nix ./postgresql.nix ./nginx.nix + ./p.nix #./pxe.nix ]; diff --git a/m/hut/p.nix b/m/hut/p.nix new file mode 100644 index 0000000..ae595c2 --- /dev/null +++ b/m/hut/p.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: +let + p = pkgs.writeShellScriptBin "p" '' + set -e + cd /ceph + pastedir="p/$USER" + mkdir -p "$pastedir" + + if [ -n "$1" ]; then + out="$pastedir/$1" + else + out=$(mktemp "$pastedir/XXXXXXXX.txt") + fi + + cat > "$out" + chmod go+r "$out" + echo "https://jungle.bsc.es/$out" + ''; +in +{ + environment.systemPackages = with pkgs; [ p ]; +}