initrd-usb: Prepare for gadget handling task
@@ -28,30 +28,30 @@ in
};
};
- config.mobile.boot.stage-1 = lib.mkIf cfg.usb.enable {
+ config = lib.mkIf cfg.usb.enable {
+ boot.specialFileSystems = {
+ # This is required for gadgetfs configuration.
+ "/sys/kernel/config" = {
+ # FIXME: remove once added to <nixpkgs/nixos/modules/tasks/filesystems.nix> specialFSTypes
+ device = "configfs";
+ fsType = "configfs";
+ options = [ "nosuid" "noexec" "nodev" ];
+ };
+ };
+
+ mobile.boot.stage-1 = lib.mkIf cfg.usb.enable {
+ kernel.modules = [
+ "configfs"
+ ];
+
usb.features = []
++ optional cfg.networking.enable "rndis"
;
-
- # TODO: Only run, when we have the android usb driver
- init = lib.mkOrder AFTER_DEVICE_INIT ''
- # Setting up Android-specific USB.
- (
- SYS=/sys/class/android_usb/android0
- if [ -e "$SYS" ]; then
- printf "%s" "0" > "$SYS/enable"
- printf "%s" "18D1" > "$SYS/idVendor"
- printf "%s" "D001" > "$SYS/idProduct"
- printf "%s" "0" > "$SYS/bDeviceClass"
- printf "%s" "${concatStringsSep "," cfg.usb.features}" > "$SYS/functions"
- printf "%s" "mobile-nixos" > "$SYS/iManufacturer"
- printf "%s" "${device_name}" > "$SYS/iProduct"
- printf "%s" "0123456789" > "$SYS/iSerial"
-
- sleep 0.1
- printf "%s" "1" > "$SYS/enable"
- fi
- )
- '';
+ tasks = [
+ ];
+ bootConfig = {
+ boot.usb.features = cfg.usb.features;
+ };
+ };
};
}
