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

{
  # Home Manager activation for the nixos live user is provided by the
  # home-manager.nixosModules.home-manager module wired up in flake.nix.

  environment.systemPackages = with pkgs; [
    git
    gum
    alacritty
    parted
    btrfs-progs
    cryptsetup
    inputs.disko.packages.${pkgs.stdenv.hostPlatform.system}.disko
    (pkgs.makeDesktopItem {
      name = "install-nomarchy";
      desktopName = "Install Nomarchy";
      exec = "alacritty -e sudo /etc/install.sh";
      terminal = false;
      categories = [ "System" ];
    })
  ];

  # Ensure the live environment user has the necessary groups for graphical acceleration and audio
  users.users.nixos.extraGroups = [ "wheel" "video" "render" "audio" "networkmanager" ];

  # Graphics support for live environment.
  # `virtio` is a no-op on real hardware (no virtio-gpu PCI device) but lets
  # the ISO render correctly when booted in QEMU via nomarchy-test-live-iso.
  boot.initrd.kernelModules = [ "amdgpu" "radeon" "nouveau" "i915" "virtio_gpu" ];
  services.xserver.videoDrivers = [ "amdgpu" "radeon" "nouveau" "modesetting" "fbdev" "virtio" ];

  environment.etc."install.sh" = {
    source = ../installer/install.sh;
    mode = "0755";
  };

  environment.etc."disko-golden.nix" = {
    source = ../installer/disko-golden.nix;
  };

  environment.etc."nomarchy".source = inputs.self;
}
