intake/demo/default.nix

59 lines
1.6 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;
};
};
# Create an activation script that copies and chowns the demo content
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/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
'';
}