# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ../../common.nix
      ../../modules/zsh.nix
      ../../modules/neovim.nix
      ../../modules/firewall.nix

      ./proxy.nix
      ./calckey.nix
    ];

  jade = {
    neovim.enable = true;
    zsh.enable = true;
  };

  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = false;

  boot.kernelPackages = pkgs.linuxPackages_latest;

  networking.hostName = "katzencafe"; # Define your hostname.
  # Pick only one of the below networking options.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
  networking.networkmanager.enable = true;  # Easiest to use and most distros use this by default.

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.jade = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
    packages = with pkgs; [
    ];
  };

  # List packages installed in system profile. To search, run:
  environment.systemPackages = with pkgs; [
    vim gitMinimal # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
  ];

  system.stateVersion = "22.11"; # Did you read the comment?

  services.jitsi-meet = {
    enable = true;
    hostName = "meet.katzen.cafe";
  };
  services.jitsi-videobridge.openFirewall = true;

  services.murmur = {
    enable = true;
    openFirewall = true;
    registerHostname = "mumble.katzen.cafe";
    sslKey = "/var/lib/acme/mumble.katzen.cafe/key.pem";
    sslCert = "/var/lib/acme/mumble.katzen.cafe/cert.pem";
  };

  containers = {
    "phtanumb-wiki" = {
      autoStart = true;
      forwardPorts = [
        {
          containerPort = 8080;
          hostPort = 8099;
          protocol = "tcp";
        }
      ];
      bindMounts = {
        "/var/mediawiki" = {
          hostPath = "/phtanum-b/wiki";
          isReadOnly = false;
        };
      };
      config = { config, pkgs, ... }: {
        services.mediawiki = {
          enable = true;
          name = "phtanum-b";
          virtualHost.listen = [
            {
              #ip = "127.0.0.1";
              port = 8080;
              ssl = false;
            }
          ];
          virtualHost.adminAddr = "admin@katzen.cafe";
          passwordFile = "/var/mediawiki/passwordFile"; 
          extraConfig = ''
            # Disable anonymous editing
            $wgGroupPermissions['*']['edit'] = false;
          '';
        };

        system.stateVersion = "22.11";
      };
    };
  };
}

