# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).

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

{
  imports =
    [ # Include the results of the hardware scan...
      ./hardware-configuration.nix
      
      # ...and additional configurations...
      ./var_reg.nix 
      ./vars.nix

      # System
      ./users.nix
      ./program-homemanager.nix
      ./ssh.nix

      # Hardware
      ./nfs-mount.nix
      ./hwaccel.nix

      # Services
      ./keepalived.nix
      ./wireguard.nix
      ./docker.nix
      ./docker-device-mapper.nix         
    ];

  # Use the systemd-boot EFI boot loader and enable that sweet zfs stuff.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  # boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
  boot.supportedFilesystems = [ "nfs" ]; # "zfs"
  boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; };
  boot.kernel.sysctl = { "net.ipv6.conf.all.forwarding" = 1; };
  boot.kernelModules = [ "rbd" "nbd" ];
  # boot.zfs.forceImportRoot = false;
  # boot.zfs.extraPools = [ "SERVICE" ];
  # services.zfs.autoScrub.enable = true;
  
  networking.hostName = config.vars.hostname; # Define your hostname.
  networking.hostId = config.vars.hostid; # Define your hostID - Needs to be unique!.
  networking = {
    interfaces.enp1s0 = {
      ipv4.addresses = [{
        address = config.vars.local_ip;
        prefixLength = 24;
      }];
    };
    defaultGateway = {
      address = "192.168.178.1";
      interface = "enp1s0";
    };
  };

  # Set your time zone.
  time.timeZone = "Europe/Berlin";

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable the X11 windowing system.
  services.xserver.enable = false; 

  # Enable CUPS to print documents.
  services.printing.enable = false;

  # Enable sound.
  hardware.pulseaudio.enable = false;

  # Enable touchpad support (enabled default in most desktopManager).
  services.libinput.enable = false;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  security.sudo.wheelNeedsPassword = false;
  users.defaultUserShell = pkgs.zsh;

  # Allow unfree software and packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  #   vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    htop
    ncdu
    git
    tmux
    zsh
    zoxide
    fzf
    # zrepl
    wireguard-tools
    unison
  ];

  programs.tmux = {
    enable = true;
    clock24 = true;
  };

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  networking.firewall.enable = false;

  # Copy the NixOS configuration file and link it from the resulting system
  # (/run/current-system/configuration.nix). This is useful in case you
  # accidentally delete configuration.nix.
  system.copySystemConfiguration = true;

  # DO NOT TOUCH!!!!!!!!!!!!!!!!!!!!!!!!!!
  # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
  system.stateVersion = "23.11"; # Did you read the comment?
 # DO NOT TOUCH!!!!!!!!!!!!!!!!!!!!!!!!!!

}