# AIC8800 USB Wi-Fi Driver for NixOS

This flake provides the AIC8800 USB Wi-Fi driver (used by UGREEN AX900 and similar adapters) as a NixOS module.

## Features

- ✅ Kernel 6.17+ compatibility (includes fixes for timer and cfg80211 API changes)
- ✅ Automatic firmware installation
- ✅ Configurable udev rules for USB disk ejection and power management

## Usage

### In your flake.nix

```nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    aic8800 = {
      url = "git+https://git.tvpdev.de/Tsubajashi/alc8800";
      # Or use a local path:
      # url = "path:/path/to/alc8800";
    };
  };

  outputs = { self, nixpkgs, aic8800, ... }: {
    nixosConfigurations.your-host = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = {
        aic8800-src = aic8800;  # Pass the flake source
      };
      modules = [
        aic8800.nixosModules.default
        ./configuration.nix
      ];
    };
  };
}
```

### In your configuration.nix

```nix
{
  hardware.aic8800 = {
    enable = true;
    # Optional: enable udev rules (default: true)
    enableUdevRules = true;
  };
}
```

### Alternative: Using as a flake input with specialArgs

If you're already using `aic8800-src` as a flake input:

```nix
{
  inputs = {
    aic8800-src = {
      url = "git+https://git.tvpdev.de/Tsubajashi/alc8800";
      flake = false;
    };
    aic8800 = {
      url = "git+https://git.tvpdev.de/Tsubajashi/alc8800";
    };
  };

  outputs = { self, nixpkgs, aic8800, aic8800-src, ... }: {
    nixosConfigurations.your-host = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = {
        aic8800-src = aic8800-src;  # Use the flake = false input
      };
      modules = [
        aic8800.nixosModules.default
        ./configuration.nix
      ];
    };
  };
}
```

## What it does

When enabled, the module:

1. **Builds the kernel modules** (`aic_load_fw` and `aic8800_fdrv`) for your kernel version
2. **Installs firmware** to `/lib/firmware/aic8800D80/`
3. **Loads the modules** automatically at boot
4. **Configures udev rules** to:
   - Automatically eject USB storage devices that appear when the adapter is plugged in (switches to Wi-Fi mode)
   - Keep the Wi-Fi interface awake to avoid autosuspend issues

## Kernel Compatibility

The driver includes compatibility fixes for Linux kernel 6.17+:
- Timer API changes (`del_timer` → `timer_delete`)
- cfg80211 API changes (additional parameter for spurious frame handlers)

## Troubleshooting

If you get an error about `aic8800-src` not being found, make sure you're passing it via `specialArgs` in your flake.nix.

