intake/demo/default.nix

62 lines
1.7 KiB
Nix
Raw Normal View History

2023-06-05 23:58:27 +00:00
flake: { pkgs, ... }:
{
system.stateVersion = "22.11";
2023-06-08 05:47:02 +00:00
# Set up two users to demonstrate the user separation
users.users.alice = {
isNormalUser = true;
password = "alpha";
};
2023-06-08 05:47:02 +00:00
users.users.bob = {
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";
}