{
  withSystem,
  inputs,
  self,
  ...
}: {
  flake.nixosConfigurations.legion = withSystem "x86_64-linux" ({
    system,
    self',
    pkgs,
    ...
  }: let
    inherit (pkgs) lib;
    inherit (inputs) fenix nur nixpkgs home-manager;
    user = self'.lib.const.user;
  in
    self'.lib.mkSystem {
      system = {
        imports = [
          ./configuration.nix
          ../../nixos/ssh.nix
          self.nixosModules.sunshine
          nur.nixosModules.nur
        ];
        services.sunshine.enable = true;

        services.tailscale.enable = true;

        services.jellyfin.enable = true;
        services.radarr.enable = true;
        services.prowlarr.enable = true;
        services.deluge = {
          enable = true;
          web.enable = true;
          config.download_location = "/media/deluge";
        };
        services.smartd.enable = true;

        users.users = {
          jellyfin.extraGroups = ["radarr"];
          radarr.extraGroups = ["deluge"];
          niko.extraGroups = ["deluge"];
        };
      };

      user = {pkgs, ...}: {
        imports = [
          ../../home-manager/desktop/xorg/i3.nix
          ../../home-manager/desktop/wayland/sway.nix
          ../../home-manager/desktop/qute.nix
          ../../home-manager/node.nix
          ../../home-manager/pijul.nix
          ../../home-manager/desktop/chromium.nix
        ];
        home.packages = with pkgs; [virt-manager steam-run slack logseq ghidra-bin pwndbg];
        niko = {
          desktop.alacritty.enable = true;
          dev.rust.enable = true;
        };
      };
    });
}