# Common module
# -------------
# All configuration common to ANY host is located here.
# General configuration and "bare minimum" tools

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

{
  # - Nix ----------------------------------------

  system.stateVersion = "22.05";

  nix = {
    package = pkgs.nixFlakes;

    extraOptions = lib.optionalString (config.nix.package == pkgs.nixFlakes)
      "experimental-features = nix-command flakes";

    gc = {
      automatic = true;
      dates = "weekly";
      options = "--delete-older-than 14d";
    };

  };

  # - Locale -------------------------------------

  time.timeZone = "Europe/Madrid";
  i18n.defaultLocale = "ca_ES.utf8";
  console.keyMap = "es";
  services.xserver = {
    layout = "es";
    xkbVariant = "cat";
  };

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

  environment.pathsToLink = [ "/libexec" ];
  environment.systemPackages = with pkgs; [
    curl
    htop
    pciutils
    psmisc
  ];

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

  networking.networkmanager.enable = true;

  samfelag.modules = {
    shell.utils.enable = true;
    shell.zsh.enable = true;
    editors.vim.enable = true;
    dev.git.enable = true;

    # May go away from common if not all hosts use it
    system.tailscale.enable = true;
  };

}
