vm.nix (1343B) - Raw
1 { 2 lib, 3 pkgs, 4 ... 5 }: { 6 e11sync = { 7 enable = true; 8 migrateOnStart = true; 9 secretKeyPath = "unsafe"; 10 vhost = ":8001"; 11 }; 12 13 services.caddy = { 14 enable = true; 15 globalConfig = '' 16 http_port 8001 17 auto_https off 18 debug 19 ''; 20 virtualHosts.":8001".extraConfig = lib.mkForce '' 21 redir /admin/* http://{host}:8003{uri} 22 ${builtins.readFile "${pkgs.e11sync-caddyfile}"} 23 ''; 24 virtualHosts."http://:8003".extraConfig = lib.mkForce '' 25 redir / /admin/ 26 ${builtins.readFile "${pkgs.e11sync-caddyfile}"} 27 ''; 28 }; 29 30 environment.systemPackages = with pkgs; [ 31 tmux 32 htop 33 ]; 34 35 nix.extraOptions = ''experimental-features = nix-command flakes''; 36 users = { 37 mutableUsers = false; 38 users.nixos = { 39 extraGroups = ["wheel"]; 40 isNormalUser = true; 41 hashedPassword = ""; 42 }; 43 }; 44 virtualisation = { 45 graphics = false; 46 forwardPorts = [ 47 { 48 from = "host"; 49 host.port = 8001; 50 guest.port = 8001; 51 } 52 { 53 from = "host"; 54 host.port = 8003; 55 guest.port = 8003; 56 } 57 ]; 58 }; 59 security.sudo.wheelNeedsPassword = false; 60 services.getty.autologinUser = "nixos"; 61 networking = { 62 hostName = "vm"; 63 firewall.allowedTCPPorts = [8001 8003]; 64 }; 65 system.stateVersion = "23.11"; 66 }