{ config, lib, pkgs, inputs, system, ... }:
let cfg = config.mods;

in {
  # Hardware
  imports = [ ./hardware-configuration.nix ];

  environment.systemPackages = with inputs.nix-alien.packages.${system};
    [ nix-alien ];

  # System
  mods.user.name = "muon";
  networking.hostName = "muop";
  mods.home.file = ./home.nix;

  # Modules
  mods.desktop.enable = true;
  mods.desktop.wayland.enable = false;
  mods.desktop.gaming.enable = true;
  mods.boot.enable = false;

  mods.nix.upgrade.enable = true;
  mods.nix.clean.enable = true;

  mods.theme.enable = true;
  mods.theme.scheme = "woodland";
  mods.theme.wallpaper = ./wallpaper.png;

  mods.containers.steam.enable = false;
  mods.server.astral.enable = false;
  mods.server.astral.autoStart = false;

  mods.server.sync.enable = true;
  mods.tailscale.enable = true;
  mods.openvpn.enable = false;
  mods.wireguard.id = 4;

  services.xserver.windowManager.i3.enable = true;

  # Proprietary </3
  mods.unfree.steam.enable = true;
  mods.unfree.nvidia.enable = true;
  mods.unfree.minecraft.enable = false;

  # Hardware preferences
  boot = {
    tmp.cleanOnBoot = true;
    bootspec.enable = true;
    consoleLogLevel = 0;

    kernelParams =
      [ "cgroup_no_v1=all" "systemd.unified_cgroup_hierarchy=yes" ];
    initrd.verbose = false;

    loader = {
      systemd-boot.enable = true;
      systemd-boot.editor = false;
      efi.canTouchEfiVariables = true;
      timeout = 1;
    };
  };

  # Turn off screen-saver
  environment.extraInit = ''
    xset s off -dpms
  '';

  environment.variables = {
    WINIT_HIDPI_FACTOR = "1";
    WINIT_X11_SCALE_FACTOR = "1";
  };

  hardware = {
    graphics = {
      enable = true;
      enable32Bit = true;
      extraPackages = with pkgs; [ vaapiVdpau libvdpau-va-gl ];
    };

    nvidia = {
      open = false;
      modesetting.enable = true;
      nvidiaSettings = true;
      forceFullCompositionPipeline = true;

      powerManagement.enable = true;
      prime = {
        sync.enable = true;
        # offload = {
        #   enable = true;
        #   enableOffloadCmd = true;
        # };

        intelBusId = "PCI:0:2:0";
        nvidiaBusId = "PCI:1:0:0";
      };
    };
    pulseaudio.support32Bit = true;
  };

  ## Mouse
  services.libinput.mouse.accelProfile = "flat";

  ## Monitors
  mods.monitors = {
    primary = {
      name = "eDP-1";
      config = {
        enable = true;
        mode = "1920x1080";
        position = "0x0";
        primary = true;
        rate = "60.00";
      };
    };
  };

  # Version of first install
  system.stateVersion = "23.05";
}
