2023-06-05 23:58:27 +00:00
|
|
|
flake: { pkgs, ... }:
|
2023-06-05 21:52:51 +00:00
|
|
|
|
2023-06-06 01:07:31 +00:00
|
|
|
{
|
2023-06-05 21:52:51 +00:00
|
|
|
system.stateVersion = "22.11";
|
2023-05-29 17:55:03 +00:00
|
|
|
|
2023-06-08 05:47:02 +00:00
|
|
|
# Set up two users to demonstrate the user separation
|
|
|
|
users.users.alice = {
|
2023-05-29 17:55:03 +00:00
|
|
|
isNormalUser = true;
|
|
|
|
password = "alpha";
|
|
|
|
};
|
|
|
|
|
2023-06-08 05:47:02 +00:00
|
|
|
users.users.bob = {
|
2023-05-29 17:55:03 +00:00
|
|
|
isNormalUser = true;
|
|
|
|
password = "beta";
|
|
|
|
};
|
2023-06-08 05:47:02 +00:00
|
|
|
|
|
|
|
# Put intake on both users' PATH
|
|
|
|
environment.systemPackages = [ flake.packages.${pkgs.stdenv.hostPlatform.system}.default ];
|
|
|
|
|
|
|
|
# Set up intake for both users with an entry point at port 8080
|
|
|
|
services.intake = {
|
|
|
|
listen.port = 8080;
|
|
|
|
users.alice.enable = true;
|
|
|
|
users.bob.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Expose the vm's intake revproxy at host port 5234
|
|
|
|
virtualisation.forwardPorts = [{
|
|
|
|
from = "host";
|
|
|
|
host.port = 5234;
|
|
|
|
guest.port = 8080;
|
|
|
|
}];
|
|
|
|
|
|
|
|
# Mount the demo content for both users
|
|
|
|
nixos-shell.mounts = {
|
|
|
|
mountHome = false;
|
|
|
|
mountNixProfile = false;
|
|
|
|
cache = "none";
|
|
|
|
|
|
|
|
extraMounts = {
|
|
|
|
"/mnt/alice" = ./alice;
|
|
|
|
"/mnt/bob" = ./bob;
|
2023-06-09 00:07:19 +00:00
|
|
|
"/mnt/sources" = ./sources;
|
2023-06-08 05:47:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Create an activation script that copies and chowns the demo content
|
2023-06-09 00:07:19 +00:00
|
|
|
# chmod 777 because the users may not exist when the activation script runs
|
2023-06-08 05:47:02 +00:00
|
|
|
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/
|
2023-06-09 00:07:19 +00:00
|
|
|
${pkgs.coreutils}/bin/chmod -R 777 /home/alice/.local
|
2023-06-08 05:47:02 +00:00
|
|
|
|
|
|
|
${pkgs.coreutils}/bin/mkdir -p /home/bob/.local/share/intake
|
|
|
|
${pkgs.coreutils}/bin/cp -r /mnt/bob/* /home/bob/.local/share/intake/
|
2023-06-09 00:07:19 +00:00
|
|
|
${pkgs.coreutils}/bin/chmod -R 777 /home/bob/.local
|
2023-06-08 05:47:02 +00:00
|
|
|
'';
|
2023-06-09 00:07:19 +00:00
|
|
|
|
|
|
|
# Put the demo sources on the global PATH
|
|
|
|
environment.variables.PATH = "/mnt/sources";
|
2023-05-29 17:55:03 +00:00
|
|
|
}
|