nixos: add option hardware.enableAllHardware

This allows users to simply enable support for all hardware by enabling the option `hardware.enableAllHardware`, instead of having to import `modules/profiles/all-hardware.nix`.

This is better, as the enableAllHardware option will be discoverable via search.nixos.org, while the `all-hardware.nix` is hidden inside nixpkgs and hard to discover.

Backward compatibility is provided by replacing the old `profiles/all-hardware.nix` with a file that sets the `enableAllHardware` option to true.
This commit is contained in:
DavHau 2024-12-12 11:12:41 +07:00
parent 45628b1432
commit 08783a39b0
6 changed files with 98 additions and 82 deletions

View file

@ -3,12 +3,18 @@
# enabled in the initrd. Its primary use is in the NixOS installation
# CDs.
{ pkgs, lib,... }:
{ config, lib, pkgs, ... }:
let
platform = pkgs.stdenv.hostPlatform;
in
{
options = {
hardware.enableAllHardware = lib.mkEnableOption "Enable support for most hardware";
};
config = lib.mkIf config.hardware.enableAllHardware {
# The initrd has to contain any module that might be necessary for
# supporting the most important parts of HW like drives.
boot.initrd.availableKernelModules =
@ -110,4 +116,5 @@ in
# Include lots of firmware.
hardware.enableRedistributableFirmware = true;
};
}

View file

@ -6,11 +6,12 @@
[ ./iso-image.nix
# Profiles of this basic installation CD.
../../profiles/all-hardware.nix
../../profiles/base.nix
../../profiles/installation-device.nix
];
hardware.enableAllHardware = true;
# Adds terminus_font for people with HiDPI displays
console.packages = options.console.packages.default ++ [ pkgs.terminus_font ];

View file

@ -10,8 +10,9 @@ with lib;
./netboot.nix
# Profiles of this basic netboot media
../../profiles/all-hardware.nix
../../profiles/base.nix
../../profiles/installation-device.nix
];
hardware.enableAllHardware = true;
}

View file

@ -29,7 +29,6 @@ in
imports = [
(mkRemovedOptionModule [ "sdImage" "bootPartitionID" ] "The FAT partition for SD image now only holds the Raspberry Pi firmware files. Use firmwarePartitionID to configure that partition's ID.")
(mkRemovedOptionModule [ "sdImage" "bootSize" ] "The boot files for SD image have been moved to the main ext4 partition. The FAT partition now only holds the Raspberry Pi firmware files. Changing its size may not be required.")
../../profiles/all-hardware.nix
];
options.sdImage = {
@ -162,6 +161,8 @@ in
};
config = {
hardware.enableAllHardware = true;
fileSystems = {
"/boot/firmware" = {
device = "/dev/disk/by-label/${config.sdImage.firmwarePartitionName}";

View file

@ -48,6 +48,7 @@
./config/zram.nix
./hardware/acpilight.nix
./hardware/all-firmware.nix
./hardware/all-hardware.nix
./hardware/apple-touchbar.nix
./hardware/bladeRF.nix
./hardware/brillo.nix

View file

@ -0,0 +1,5 @@
# Set `hardware.enableAllHardware = true` instead of importing this file.
# This file provides backwards compatibility for older configurations.
{
hardware.enableAllHardware = true;
}