# 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, lib, inputs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./../../modules/nixos/cspark-desktop-plasma/module.nix
      ./../../modules/nixos/cspark-desktop-gnome/module.nix
      ./../../modules/nixos/cspark-desktop-sway/module.nix
      ./../../modules/nixos/cspark-desktop-niri/module.nix
      ./../../modules/nixos/cspark-desktop-exwm/module.nix
      inputs.home-manager.nixosModules.default
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "cspark-nixos-laptop"; # Define your hostname.

  # Enable networking
  networking.networkmanager.enable = true;
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Setting up my desktop computer to be able to build files for my laptop
  # Make remote builder desktop a known host
  programs.ssh = {
    knownHosts = {
      cspark-desktop-nixremotebuilder = {
        extraHostNames = [ "cspark-nixos-desktop" "192.168.1.110" ];
        publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJWWfMZhdSKiUZZU1Pl7Hp6+BKHhWswLNmngLDzzMsGl";
      };
    };
    extraConfig = ''
    Host cspark-desktop-nixremotebuilder
        Hostname 192.168.1.110
        IdentitiesOnly yes
        IdentityFile /root/.ssh/cspark-desktop-nixremotebuilder
        # The weakly privileged user on the remote builder – if not set, 'root' is used – which will hopefully fail
        User nixremotebuilder
    '';
  };
  nix.buildMachines = [ {
	 hostName = "cspark-desktop-nixremotebuilder";
	 sshUser = "nixremotebuilder";
	 system = "x86_64-linux";
         protocol = "ssh-ng";
	 # if the builder supports building for multiple architectures,
	 # replace the previous line by, e.g.
	 # systems = ["x86_64-linux" "aarch64-linux"];
	 maxJobs = 1;
	 speedFactor = 2;
	 supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ];
	 mandatoryFeatures = [ ];
  }] ;
  nix.distributedBuilds = true;
  # optional, useful when the builder has a faster internet connection than yours
  nix.extraOptions = ''
    builders-use-substitutes = true
  '';

  # Custom desktop environments
  # cspark-desktop-plasma.enable = true;
  # cspark-desktop-gnome.enable = true;
  # cspark-desktop-sway.enable = true;
  cspark-desktop-niri.enable = true;
  # cspark-desktop-exwm.enable = true;

  # Home Manager Configuration
  home-manager = {
    extraSpecialArgs = { inherit inputs; };
    users = {
      "cspark" = import ./home.nix;
    };
  };

  # Steam Game Platform
  #programs.steam = {
  #  enable = true;
  #  # remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
  #  # dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
  #  gamescopeSession.enable = true;
  #};

  # Waydroid Android Emulation
  virtualisation.waydroid.enable = true;

  # Docker for development
  virtualisation.docker.enable = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    nvtopPackages.intel
  ];

}
