traque/nix/vm.nix

62 lines
1.6 KiB
Nix

{ pkgs, lib, ... }:
{
nix = {
nixPath = [
"nixpkgs=${builtins.storePath pkgs.path}"
"nixos=${builtins.storePath pkgs.path}"
];
package = pkgs.lix;
};
environment.systemPackages = with pkgs; [ wget tmux ];
services.nginx = {
enable = true;
virtualHosts."localhost" = {
default = true;
locations = {
"/" = {
root = "/traque/static";
tryFiles = "$uri @backend";
};
"@backend" = {
recommendedProxySettings = true;
proxyPass = "http://localhost:8000";
extraConfig = ''
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
'';
};
};
#extraConfig = ''
# error_page 502 =503;
#'';
};
};
services.getty = {
autologinUser = "root";
helpLine = lib.mkForce ''
On serial console: type Ctrl-a c to switch to the qemu console and `quit` to stop the VM.
traque source is on /traque (rw), `cd /traque && ./target/debug/traque` to run the test.
Compile from the host for performance (the VM is highly limited).'';
};
nixos-shell.mounts = {
mountHome = false;
mountNixProfile = false;
cache = "none";
extraMounts = {
"/traque" = {
target = toString ../.;
cache = "none";
};
};
};
virtualisation = {
forwardPorts = [
{ from = "host"; host.port = 8000; guest.port = 80; }
];
};
system.stateVersion = "24.11";
}