{ config, pkgs, lib, inputs, ... }:

with lib;
let
  nix-colors-lib = inputs.nix-colors.lib-contrib { inherit pkgs; };
  wallpaper = ../../data/wallpapers/simple/tarmac.png;
in
{
  imports = [
    ./hardware.nix
  ];

  # - Basic --------------------------------------

  user.name = "marc";
  user.shell = pkgs.zsh;
  networking.hostName = "reykjavik";
  networking.firewall = {
    enable = true;
    allowedUDPPortRanges = [
      # - ROS ------------------------------------
      # Open ports for ROS 2 DDS
      # See https://docs.ros.org/en/humble/Concepts/About-Domain-ID.html
      # Multicast ports for DOMAIN_ID 13
      { from = 10650; to = 10651; }
      # Unicast ports for DOMAIN_ID 13 and up to 120 particimants
      { from = 10660; to = 10890; }
    ];
  };

  # - Bootloader ---------------------------------

  boot.loader.systemd-boot.enable = true;

  # - Themeing ---------------------------------

  colorScheme = nix-colors-lib.colorSchemeFromPicture {
    path = wallpaper;
    kind = "dark";
  };

  age.identityPaths = [
    "/home/marc/.ssh/id_ed25519"
  ];

  # - Modules ------------------------------------

  samfelag.modules = {
    # - Common -----------------------------------
    # See modules/common.nix for common packages installed

    # - System -----------------------------------
    system.utils.enable = true;
    system.bluetooth.enable = true;
    system.nvidia = {
      enable = true;
      intelBusId = "PCI:0:2:0";
      nvidiaBusId = "PCI:1:0:0";
    };
    system.gpg.enable = true;
    system.pass.enable = true;
    system.sshfs.enable = true;

    # - Server ----------------------------------
    server.consul = {
      enable = true;
      agent-token = config.age.secrets."consul.d/agent-token-reykjavik.json".path;
    };

    # - Desktop ----------------------------------
    desktop = {
      inherit wallpaper;
      enable = true;
      laptop = true;
    };

    # - Editors and development ------------------
    editors.emacs.enable = true;

    dev.git.userName = "marc";
    dev.git.userEmail = "marc@sastre.cat";
    dev.devenv.enable = true;

    dev.docker.enable = true;
    dev.docker.users = ["marc"];

    # - Other apps -------------------------------
    app.spotify.enable = true;
    app.skype.enable = true;
    app.nextcloud.enable = true;

    # - Gaming -----------------------------------
    gaming.lutris.enable = true;
    gaming.steam.enable = true;
    app.discord.enable = true;
  };

  # - Extra / Temporary --------------------------
  programs.dconf.enable = true; # Inkscape crashes
  fonts.packages = [];
}
