From 0d2dea94fb37eb5f4c2247b95913030b37f70c6a 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Aleix Boné --- m/hut/configuration.nix | 1 + m/hut/nginx.nix | 3 +++ m/hut/p.nix | 24 ++++++++++++++++++++++++ 3 files changed, 28 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/nginx.nix b/m/hut/nginx.nix index 49598a2..553e06e 100644 --- a/m/hut/nginx.nix +++ b/m/hut/nginx.nix @@ -55,6 +55,9 @@ in autoindex on; absolute_redirect off; } + location /p/ { + alias /ceph/p/; + } ''; }; }; diff --git a/m/hut/p.nix b/m/hut/p.nix new file mode 100644 index 0000000..f53472d --- /dev/null +++ b/m/hut/p.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +let + p = pkgs.writeShellScriptBin "p" '' + set -e + cd /ceph + pastedir="p/$USER" + mkdir -p "$pastedir" + + ext="txt" + + if [ -n "$1" ]; then + ext="$1" + fi + + out=$(mktemp "$pastedir/XXXXXXXX.$ext") + + cat > "$out" + chmod go+r "$out" + echo "https://jungle.bsc.es/$out" + ''; +in +{ + environment.systemPackages = with pkgs; [ p ]; +}