Add real source programs to PATH

This commit is contained in:
Tim Van Baak 2023-06-08 17:07:19 -07:00
parent e03b82dbea
commit 0c86a78d51
6 changed files with 43 additions and 9 deletions

View File

@ -1,11 +1,8 @@
{ {
"action": { "action": {
"fetch": { "fetch": {
"exe": "sh", "exe": "currenttime.sh",
"args": [ "args": []
"-c",
"echo {\\\"id\\\": \\\"$(date +%Y-%m-%d-%H-%M)\\\"}"
]
} }
} }
} }

View File

@ -0,0 +1,11 @@
{
"action": {
"fetch": {
"exe": "echo.py",
"args": []
}
},
"env": {
"MESSAGE": "Hello, Alice!"
}
}

11
demo/bob/echo/intake.json Normal file
View File

@ -0,0 +1,11 @@
{
"action": {
"fetch": {
"exe": "echo.py",
"args": []
}
},
"env": {
"MESSAGE": "Hello, Bob!"
}
}

View File

@ -40,19 +40,22 @@ flake: { pkgs, ... }:
extraMounts = { extraMounts = {
"/mnt/alice" = ./alice; "/mnt/alice" = ./alice;
"/mnt/bob" = ./bob; "/mnt/bob" = ./bob;
"/mnt/sources" = ./sources;
}; };
}; };
# Create an activation script that copies and chowns the demo content # 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 = '' system.activationScripts.demoSetup = ''
${pkgs.coreutils}/bin/mkdir -p /home/alice/.local/share/intake ${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/cp -r /mnt/alice/* /home/alice/.local/share/intake/
${pkgs.coreutils}/bin/chgrp -R users /home/alice ${pkgs.coreutils}/bin/chmod -R 777 /home/alice/.local
${pkgs.coreutils}/bin/chmod -R 775 /home/alice/.local
${pkgs.coreutils}/bin/mkdir -p /home/bob/.local/share/intake ${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/cp -r /mnt/bob/* /home/bob/.local/share/intake/
${pkgs.coreutils}/bin/chgrp -R users /home/bob ${pkgs.coreutils}/bin/chmod -R 777 /home/bob/.local
${pkgs.coreutils}/bin/chmod -R 775 /home/bob/.local
''; '';
# Put the demo sources on the global PATH
environment.variables.PATH = "/mnt/sources";
} }

2
demo/sources/currenttime.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
echo {\"id\": \"$(date +%Y-%m-%d-%H-%M)\"}

10
demo/sources/echo.py Executable file
View File

@ -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)