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

with lib;
let
  cfg = config.samfelag.profiles.desktop;
in
{
  options.samfelag.profiles.desktop = {

    enable = mkEnableOption "desktop profile";

    laptop = mkOption {
      description = "Enable features for a laptop (trackpad, battery, etc...)";
      type = types.bool;
      default = false;
    };
  };

  config = mkIf cfg.enable {

    # - Packages ---------------------------------

    environment.systemPackages = with pkgs; [
      pamixer
      i3lock-blur
    ];

    # - Audio ------------------------------------

    sound.enable = true;

    hardware = {
      pulseaudio = {
        enable = true;
        support32Bit = true;
        package = pkgs.pulseaudioFull;
      };
    };

    # - Window + Display Manager -----------------

    environment.pathsToLink = [ "/libexec" ];

    services.xserver = {
      enable = true;

      libinput = mkIf cfg.laptop {
        enable = true;
        touchpad.tapping = true;
      };

      desktopManager = {
        xterm.enable = false;
      };
     
      displayManager = {
        defaultSession = "none+i3";
        lightdm = {
          enable = true;
          greeters.mini = {
            enable = true;
            user = "marc";
            extraConfig = ''
                [greeter]
                show-sys-info = true
            '';
          };
        };
      };

      windowManager.i3.enable = true;
    };

  };
}
