diff --git a/demo/alice/currenttime/intake.json b/demo/alice/currenttime/intake.json index c93b584..40b0a0c 100644 --- a/demo/alice/currenttime/intake.json +++ b/demo/alice/currenttime/intake.json @@ -1,11 +1,8 @@ { "action": { "fetch": { - "exe": "sh", - "args": [ - "-c", - "echo {\\\"id\\\": \\\"$(date +%Y-%m-%d-%H-%M)\\\"}" - ] + "exe": "currenttime.sh", + "args": [] } } } diff --git a/demo/alice/echo/intake.json b/demo/alice/echo/intake.json new file mode 100644 index 0000000..dfe0dc7 --- /dev/null +++ b/demo/alice/echo/intake.json @@ -0,0 +1,11 @@ +{ + "action": { + "fetch": { + "exe": "echo.py", + "args": [] + } + }, + "env": { + "MESSAGE": "Hello, Alice!" + } +} diff --git a/demo/bob/echo/intake.json b/demo/bob/echo/intake.json new file mode 100644 index 0000000..8f41ac2 --- /dev/null +++ b/demo/bob/echo/intake.json @@ -0,0 +1,11 @@ +{ + "action": { + "fetch": { + "exe": "echo.py", + "args": [] + } + }, + "env": { + "MESSAGE": "Hello, Bob!" + } +} diff --git a/demo/default.nix b/demo/default.nix index d46ebe0..1f842db 100644 --- a/demo/default.nix +++ b/demo/default.nix @@ -40,19 +40,22 @@ flake: { pkgs, ... }: extraMounts = { "/mnt/alice" = ./alice; "/mnt/bob" = ./bob; + "/mnt/sources" = ./sources; }; }; # Create an activation script that copies and chowns the demo content + # chmod 777 because the users may not exist when the activation script runs system.activationScripts.demoSetup = '' ${pkgs.coreutils}/bin/mkdir -p /home/alice/.local/share/intake ${pkgs.coreutils}/bin/cp -r /mnt/alice/* /home/alice/.local/share/intake/ - ${pkgs.coreutils}/bin/chgrp -R users /home/alice - ${pkgs.coreutils}/bin/chmod -R 775 /home/alice/.local + ${pkgs.coreutils}/bin/chmod -R 777 /home/alice/.local ${pkgs.coreutils}/bin/mkdir -p /home/bob/.local/share/intake ${pkgs.coreutils}/bin/cp -r /mnt/bob/* /home/bob/.local/share/intake/ - ${pkgs.coreutils}/bin/chgrp -R users /home/bob - ${pkgs.coreutils}/bin/chmod -R 775 /home/bob/.local + ${pkgs.coreutils}/bin/chmod -R 777 /home/bob/.local ''; + + # Put the demo sources on the global PATH + environment.variables.PATH = "/mnt/sources"; } diff --git a/demo/sources/currenttime.sh b/demo/sources/currenttime.sh new file mode 100755 index 0000000..06a3366 --- /dev/null +++ b/demo/sources/currenttime.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo {\"id\": \"$(date +%Y-%m-%d-%H-%M)\"} diff --git a/demo/sources/echo.py b/demo/sources/echo.py new file mode 100755 index 0000000..a30b021 --- /dev/null +++ b/demo/sources/echo.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import hashlib, json, os, sys + +echo = os.environ.get("MESSAGE", "Hello, world!") +item = { + "id": hashlib.md5(echo.encode("utf8")).hexdigest(), + "title": echo, +} +print(json.dumps(item), file=sys.stdout)