mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-27 08:04:14 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
90 lines
2.8 KiB
Nix
90 lines
2.8 KiB
Nix
{ config, lib, options, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) literalExpression mkOption mkEnableOption types mkIf mkMerge optional versionOlder;
|
|
cfg = config.hardware.system76;
|
|
opt = options.hardware.system76;
|
|
|
|
kpkgs = config.boot.kernelPackages;
|
|
modules = [ "system76" "system76-io" ] ++ (optional (versionOlder kpkgs.kernel.version "5.5") "system76-acpi");
|
|
modulePackages = map (m: kpkgs.${m}) modules;
|
|
moduleConfig = mkIf cfg.kernel-modules.enable {
|
|
boot.extraModulePackages = modulePackages;
|
|
|
|
boot.kernelModules = modules;
|
|
|
|
services.udev.packages = modulePackages;
|
|
};
|
|
|
|
firmware-pkg = pkgs.system76-firmware;
|
|
firmwareConfig = mkIf cfg.firmware-daemon.enable {
|
|
# Make system76-firmware-cli usable by root from the command line.
|
|
environment.systemPackages = [ firmware-pkg ];
|
|
|
|
services.dbus.packages = [ firmware-pkg ];
|
|
|
|
systemd.services.system76-firmware-daemon = {
|
|
description = "The System76 Firmware Daemon";
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${firmware-pkg}/bin/system76-firmware-daemon";
|
|
|
|
Restart = "on-failure";
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
};
|
|
|
|
power-pkg = config.boot.kernelPackages.system76-power;
|
|
powerConfig = mkIf cfg.power-daemon.enable {
|
|
# Make system76-power usable by root from the command line.
|
|
environment.systemPackages = [ power-pkg ];
|
|
|
|
services.dbus.packages = [ power-pkg ];
|
|
|
|
systemd.services.system76-power = {
|
|
description = "System76 Power Daemon";
|
|
serviceConfig = {
|
|
ExecStart = "${power-pkg}/bin/system76-power daemon";
|
|
Restart = "on-failure";
|
|
Type = "dbus";
|
|
BusName = "com.system76.PowerDaemon";
|
|
};
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
};
|
|
in {
|
|
options = {
|
|
hardware.system76 = {
|
|
enableAll = mkEnableOption "all recommended configuration for system76 systems";
|
|
|
|
firmware-daemon.enable = mkOption {
|
|
default = cfg.enableAll;
|
|
defaultText = literalExpression "config.${opt.enableAll}";
|
|
example = true;
|
|
description = lib.mdDoc "Whether to enable the system76 firmware daemon";
|
|
type = types.bool;
|
|
};
|
|
|
|
kernel-modules.enable = mkOption {
|
|
default = cfg.enableAll;
|
|
defaultText = literalExpression "config.${opt.enableAll}";
|
|
example = true;
|
|
description = lib.mdDoc "Whether to make the system76 out-of-tree kernel modules available";
|
|
type = types.bool;
|
|
};
|
|
|
|
power-daemon.enable = mkOption {
|
|
default = cfg.enableAll;
|
|
defaultText = literalExpression "config.${opt.enableAll}";
|
|
example = true;
|
|
description = lib.mdDoc "Whether to enable the system76 power daemon";
|
|
type = types.bool;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkMerge [ moduleConfig firmwareConfig powerConfig ];
|
|
}
|