From 2f6321f6caa5af83ca9597c3dd03b50a62df3356 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 19 Jun 2023 12:33:39 -0700 Subject: [PATCH] Add some inline instructions to the demo --- demo/alice/credentials.json | 4 ---- demo/bob/credentials.json | 4 ---- demo/default.nix | 43 +++++++++++++++++++++++++++++-------- demo/sources/currenttime.sh | 2 +- demo/sources/echo.py | 2 +- 5 files changed, 36 insertions(+), 19 deletions(-) delete mode 100644 demo/alice/credentials.json delete mode 100644 demo/bob/credentials.json diff --git a/demo/alice/credentials.json b/demo/alice/credentials.json deleted file mode 100644 index fb3a62c..0000000 --- a/demo/alice/credentials.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "username": "alice", - "secret": "alpha" -} diff --git a/demo/bob/credentials.json b/demo/bob/credentials.json deleted file mode 100644 index 04fd3e7..0000000 --- a/demo/bob/credentials.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "username": "bob", - "secret": "beta" -} diff --git a/demo/default.nix b/demo/default.nix index 1f842db..70cb86a 100644 --- a/demo/default.nix +++ b/demo/default.nix @@ -7,11 +7,13 @@ flake: { pkgs, ... }: users.users.alice = { isNormalUser = true; password = "alpha"; + uid = 1000; }; users.users.bob = { isNormalUser = true; password = "beta"; + uid = 1001; }; # Put intake on both users' PATH @@ -46,16 +48,39 @@ flake: { pkgs, ... }: # 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/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/chmod -R 777 /home/bob/.local - ''; + system.activationScripts = + let + userSetup = name: uid: '' + ${pkgs.coreutils}/bin/mkdir -p /home/${name}/.local/share/intake + ${pkgs.coreutils}/bin/cp -r /mnt/${name}/* /home/${name}/.local/share/intake/ + ${pkgs.coreutils}/bin/chown -R ${uid} /home/${name} + ${pkgs.findutils}/bin/find /home/${name} -type d -exec ${pkgs.coreutils}/bin/chmod 755 {} \; + ${pkgs.findutils}/bin/find /home/${name} -type f -exec ${pkgs.coreutils}/bin/chmod 644 {} \; + ''; + in + { + aliceSetup = userSetup "alice" "1000"; + bobSetup = userSetup "bob" "1001"; + }; # Put the demo sources on the global PATH environment.variables.PATH = "/mnt/sources"; + + # Include some demo instructions + environment.etc.issue.text = '' + # Welcome to the intake demo! Log in as `alice` with password `alpha` to begin. + + # Exit the VM with ctrl+a x, or switch to the qemu console with ctrl+a c and `quit`. + + ''; + users.motd = '' + + # To set a password for the web interface, run `intake passwd` and set a password. + + # Within this demo VM, the main intake entry point can be found at localhost:8080. This is also exposed on the host machine at localhost:5234. After you set a password, navigate to localhost:5234 on your host machine and log in to see the web interface. + + # Try updating the currenttime source by running `intake update -s currenttime`. You should see a new item after refreshing the source's feed. + + # The `echo` source demonstrates the use of `env` source configuration. Try changing the message in the web interface or via `intake edit -s echo`, then updating the source. + ''; } diff --git a/demo/sources/currenttime.sh b/demo/sources/currenttime.sh index 06a3366..4110517 100755 --- a/demo/sources/currenttime.sh +++ b/demo/sources/currenttime.sh @@ -1,2 +1,2 @@ -#!/bin/bash +#!/bin/sh echo {\"id\": \"$(date +%Y-%m-%d-%H-%M)\"} diff --git a/demo/sources/echo.py b/demo/sources/echo.py index a30b021..296359e 100755 --- a/demo/sources/echo.py +++ b/demo/sources/echo.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import hashlib, json, os, sys