# 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’).

{
  pkgs,
  myhostname,
  ...
}:
let
  modulesDirectory = ../../moduler;
in
{
  imports = [
    ./hardware-configuration.nix

    (modulesDirectory + /users.nix)
    (modulesDirectory + /network.nix)
    (modulesDirectory + /system.nix)

    (modulesDirectory + /services/base)
    (modulesDirectory + /services/webcam-rtsp)
  ];

  networking.networkmanager = {
    enable = true;
  };

  hardware.graphics = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver
    ];
  };

  webcam-rtsp = {
    enable = true;
    streams = {
      frontcam = {
        device = "/dev/v4l/by-id/usb-Generic_HD_WebCam_200901010001-video-index0";
        rtspUrl = "rtsp://192.168.1.143:8554/frontcam";
        framerate = 12;
        videoSize = "1280x720";
        useVaapi = true;
        vaapiDriver = "iHD";
        vaapiQp = 26;
        bitrateKbps = 900;
        maxrateKbps = 1100;
        bufsizeKbps = 1800;
      };
      webcam = {
        device = "/dev/v4l/by-id/usb-GENERAL_GENERAL_WEBCAM-video-index0";
        rtspUrl = "rtsp://192.168.1.143:8554/webcam";
        framerate = 12;
        videoSize = "1280x720";
        useVaapi = true;
        vaapiDriver = "iHD";
        vaapiQp = 26;
        bitrateKbps = 900;
        maxrateKbps = 1100;
        bufsizeKbps = 1800;
      };
    };
  };

  security.sudo.wheelNeedsPassword = false;
  users.users.root.openssh.authorizedKeys.keys = [
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII60tdNsG0z9q2jHmoTKvkeLQE6OF0bmTsDX1bpqpoG7 fw@jobb"
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFpJBGPIfPB1BwSG7aoKqwfccyZSaU7J3xpJ8behMp9N fw@core"
  ];

  boot.kernelPackages = pkgs.linuxPackages_latest;

  networking.hostName = myhostname;

  system.stateVersion = "25.05";
}
