shell: fix nixos-enter
[sourcephile-nix.git] / nixos / profiles / hardware / cubieboard2.nix
index 91119f980412f9cf2703a8d07cea97955e4e7754..f5bb63373569b8c19cfa9f6ae384adeb38c2e8e3 100644 (file)
-{ pkgs, lib, config, host, modulesPath, ... }:
+{ pkgs, lib, config, modulesPath, ... }:
 {
-imports = [
-  "${modulesPath}/installer/sd-card/sd-image.nix"
-];
+  imports = [
+    "${modulesPath}/installer/sd-card/sd-image.nix"
+  ];
 
-_module.args.CPUs = 2;
+  _module.args.CPUs = 2;
 
-# Too CPU hungry for this hardware, for too little Mio saved
-nix.settings.auto-optimise-store = false;
+  # Too CPU hungry for this hardware, for too little MiB saved
+  nix.settings.auto-optimise-store = false;
 
-powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
+  powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
 
-boot.supportedFilesystems = [
-  #"btrfs"
-  #"reiserfs"
-  "vfat"
-  #"f2fs"
-  #"xfs"
-  #"zfs" # ZFS tools coredump with SIGSEGV
-  #"ntfs"
-  #"cifs"
-];
+  boot.supportedFilesystems = [
+    #"btrfs"
+    #"reiserfs"
+    "vfat"
+    #"f2fs"
+    #"xfs"
+    #"zfs" # ZFS tools coredump with SIGSEGV
+    #"ntfs"
+    #"cifs"
+  ];
 
-# The serial ports listed here are:
-# - ttyS0: for Tegra (Jetson TK1)
-# - ttymxc0: for i.MX6 (Wandboard)
-# - ttyAMA0: for Allwinner (pcDuino3 Nano) and QEMU's -machine virt
-# - ttyO0: for OMAP (BeagleBone Black)
-# - ttySAC2: for Exynos (ODROID-XU3)
-boot.consoleLogLevel = lib.mkDefault 7;
-boot.kernelParams = [
-  "console=ttyS0,115200n8"
-  "console=ttymxc0,115200n8"
-  "console=ttyAMA0,115200n8"
-  "console=ttyO0,115200n8"
-  "console=ttySAC2,115200n8"
-  "console=tty0"
-];
-boot.kernelPatches = [
-  {
-    name = "0001-core_pattern-fix-too-small-CORENAME_MAX_SIZE";
-    patch = ../../../nixpkgs/patches/linux/0001-core_pattern-fix-too-small-CORENAME_MAX_SIZE.patch;
-    extraConfig = ''
-    '';
-  }
-];
+  # The serial ports listed here are:
+  # - ttyS0: for Tegra (Jetson TK1)
+  # - ttymxc0: for i.MX6 (Wandboard)
+  # - ttyAMA0: for Allwinner (pcDuino3 Nano) and QEMU's -machine virt
+  # - ttyO0: for OMAP (BeagleBone Black)
+  # - ttySAC2: for Exynos (ODROID-XU3)
+  boot.consoleLogLevel = lib.mkDefault 7;
+  boot.kernelParams = [
+    "console=ttyS0,115200n8"
+    "console=ttymxc0,115200n8"
+    "console=ttyAMA0,115200n8"
+    "console=ttyO0,115200n8"
+    "console=ttySAC2,115200n8"
+    "console=tty0"
+  ];
+  boot.kernelPatches = [
+    /*
+      {
+      name = "0001-core_pattern-fix-too-small-CORENAME_MAX_SIZE";
+      patch = ../../../nixpkgs/patches/linux/0001-core_pattern-fix-too-small-CORENAME_MAX_SIZE.patch;
+      extraConfig = ''
+      '';
+      }
+    */
+  ];
 
-#nixpkgs.config.allowUnfree = true;
-nixpkgs.crossSystem = lib.systems.examples.armv7l-hf-multiplatform;
-nixpkgs.overlays = [
-  (final: super: {
-    # https://linux-sunxi.org/Mali_Open_Source_Driver#Configuration_and_Build
-    mesa = super.mesa.override {
-      driDrivers = [];
-      eglPlatforms = ["x11"];
-      enableGalliumNine = false;
-      galliumDrivers = ["lima" "panfrost" "kmsro" "swrast"];
-      vulkanDrivers = [];
-    };
-  })
-  (final: super: {
-    linuxPackages_latest_Cubieboard2 = super.linuxPackages_latest.extend (kfinal: ksuper: {
-      kernel = ksuper.kernel.override {
+  nixpkgs.overlays = [
+    (finalPkgs: previousPkgs: {
+      # https://linux-sunxi.org/Mali_Open_Source_Driver#Configuration_and_Build
+      mesa = (previousPkgs.mesa.override {
+        eglPlatforms = [ "x11" ];
+        galliumDrivers = [
+          "lima"
+          #"panfrost"
+          "kmsro"
+          "swrast"
+        ];
+        enableGalliumNine = false;
+        vulkanDrivers = [
+          "swrast"
+          #"panfrost"
+        ];
+        #vulkanLayers = [ ];
+      }).overrideAttrs (previousAttrs: {
+        mesonFlags = previousAttrs.mesonFlags ++ [
+          # VDPAU state tracker requires at least the following gallium drivers:
+          # r600, radeonsi, nouveau or d3d12
+          "-Dgallium-vdpau=disabled"
+          "-Dgallium-va=disabled"
+          # XA state tracker requires at least one of the following gallium drivers:
+          # nouveau, freedreno, i915, svga.
+          "-Dgallium-xa=disabled"
+        ];
+      });
+    })
+  ];
+  boot.tmp.cleanOnBoot = true;
+  boot.tmp.useTmpfs = lib.mkForce false;
+  # TODO: is that needed?
+  hardware.enableRedistributableFirmware = true;
+  sdImage = {
+    postBuildCommands = ''
+      dd if=${pkgs.ubootCubieboard2}/u-boot-sunxi-with-spl.bin of=$img bs=1024 seek=8 conv=notrunc
+    '';
+    compressImage = true;
+    expandOnBoot = true;
+    firmwareSize = 1;
+    populateFirmwareCommands = "";
+    populateRootCommands = ''
+      mkdir -p ./files/boot
+      ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
+    '';
+  };
+  boot.loader.grub.enable = false;
+  boot.loader.generic-extlinux-compatible.enable = true;
+  # nix -L build .#nixosConfigurations.${hostName}.config.boot.kernelPackages.kernel.configfile
+  boot.kernelPackages = lib.mkForce (
+    # FIXME: config.boot.zfs.package.latestCompatibleLinuxPackages
+    pkgs.linuxPackages_latest.extend (finalKernel: previousKernel: {
+      kernel = previousKernel.kernel.override {
         defconfig = "sunxi_defconfig";
         structuredExtraConfig = with lib.kernel; {
           # Workaround https://github.com/NixOS/nixpkgs/pull/141942#issuecomment-954301443
@@ -77,6 +117,8 @@ nixpkgs.overlays = [
           REGULATOR = lib.mkForce no;
           MFD_CORE = no;
           PCI = yes;
+          # FIXME: Enable wdctl to work when /dev/watchdog is used by systemd
+          #WATCHDOG_SYSFS = yes;
 
           #
           # File systems
@@ -92,7 +134,6 @@ nixpkgs.overlays = [
           # misc
           DAX = module;
           DRM_DISPLAY_CONNECTOR = module;
-          FB_SIMPLE = lib.mkForce module;
           NET_SCH_CODEL = module;
           NET_SCH_FQ_CODEL = module;
           UIO = module;
@@ -707,6 +748,7 @@ nixpkgs.overlays = [
           RAID6 = no;
           STAGING = lib.mkForce no;
           ATH11K_PCI = no;
+          ATH12K = no;
 
           "6LOWPAN" = no;
           ARCNET = no;
@@ -716,10 +758,7 @@ nixpkgs.overlays = [
           CAN = no;
           COMEDI = no;
           DRM_STM = lib.mkForce no;
-          DRM_PANEL = lib.mkForce no;
 
-          DRM_BRIDGE = no;
-          DRM_PANEL_BRIDGE = no;
           DRM_CDNS_DSI = no;
           DRM_CHIPONE_ICN6211 = no;
           DRM_CHRONTEL_CH7033 = no;
@@ -779,18 +818,53 @@ nixpkgs.overlays = [
           TINYDRM_REPAPER = no;
           TINYDRM_ST7586 = no;
           TINYDRM_ST7735R = no;
-          DRM_PL111 = no;
-          DRM_TVE200 = no;
-          DRM_LIMA = no;
-          DRM_PANFROST = no;
-          DRM_MCDE = no;
-          DRM_TIDSS = no;
-          DRM_GUD = no;
+          DRM = module;
+          DRM_BRIDGE = yes;
           DRM_EXPORT_FOR_TESTS = no;
-          DRM_PANEL_ORIENTATION_QUIRKS = no;
+          DRM_FBDEV_EMULATION = yes;
+          DRM_GUD = no;
+          DRM_KMS_FB_HELPER = yes;
+          DRM_KMS_HELPER = module;
           DRM_LIB_RANDOM = no;
+          DRM_LIMA = module; # TODO: enable for the Mali 400 of the Cubieboard 2
+          DRM_LVDS_ENCODER = module;
+          DRM_NOUVEAU = no;
+          DRM_MCDE = no;
+          DRM_PANEL = yes;
+          DRM_PANEL_BRIDGE = yes;
+          DRM_PANEL_LVDS = module;
+          DRM_PANEL_ORIENTATION_QUIRKS = no;
+          DRM_PANFROST = no; # Not for the hardware of the Cubieboard 2not supported b
+          DRM_PL111 = no;
+          DRM_SCHED = module;
+          DRM_TIDSS = no;
+          DRM_TVE200 = no;
+          VIDEOMODE_HELPERS = yes;
+          FB = yes;
+          FB_CMDLINE = yes;
+          FB_NOTIFY = yes;
+          FB_CFB_FILLRECT = yes;
+          FB_CFB_COPYAREA = yes;
+          FB_CFB_IMAGEBLIT = yes;
+          FB_MODE_HELPERS = yes;
+          FB_TILEBLITTING = yes;
+          FB_SIMPLE = yes;
+
+          DUMMY_CONSOLE = yes;
+          FRAMEBUFFER_CONSOLE = yes;
+          FRAMEBUFFER_CONSOLE_DETECT_PRIMARY = yes;
+          FRAMEBUFFER_CONSOLE_ROTATION = yes;
+          FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER = yes;
+
+          BACKLIGHT_LCD_SUPPORT = yes;
+          LCD_CLASS_DEVICE = module;
+          LCD_PLATFORM = module;
+          BACKLIGHT_CLASS_DEVICE = module;
+          BACKLIGHT_GENERIC = module;
+          BACKLIGHT_PWM = module;
+          BACKLIGHT_GPIO = module;
 
-          INFINIBAND = no;
+          INFINIBAND = lib.mkForce no;
           INPUT_TOUCHSCREEN = no;
           MEDIA_ANALOG_TV_SUPPORT = lib.mkForce no;
           MEDIA_DIGITAL_TV_SUPPORT = lib.mkForce no;
@@ -811,34 +885,11 @@ nixpkgs.overlays = [
         features.debug = false;
         #ignoreConfigErrors = true;
       };
-    });
-  })
-];
-boot.cleanTmpDir = true;
-boot.tmpOnTmpfs = lib.mkForce false;
-# TODO: is that needed?
-hardware.enableRedistributableFirmware = true;
-sdImage = {
-  postBuildCommands = ''
-    dd if=${pkgs.ubootCubieboard2}/u-boot-sunxi-with-spl.bin of=$img bs=1024 seek=8 conv=notrunc
-  '';
-  compressImage = true;
-  expandOnBoot = true;
-  firmwareSize = 1;
-  populateFirmwareCommands = "";
-  populateRootCommands = ''
-    mkdir -p ./files/boot
-    ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
-  '';
-};
-boot.loader.grub.enable = false;
-boot.loader.generic-extlinux-compatible.enable = true;
-# nix -L build .#nixosConfigurations.${hostName}.config.boot.kernelPackages.kernel.configfile
-boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest_Cubieboard2;
-boot.initrd.availableKernelModules = lib.mkForce [
-  "mmc_block"
-  "usbhid"
-  "hid_generic"
-  "hid_microsoft"
-];
+    }));
+  boot.initrd.availableKernelModules = lib.mkForce [
+    "mmc_block"
+    "usbhid"
+    "hid_generic"
+    "hid_microsoft"
+  ];
 }