blob: 3fb2c10a6e3bbfefbe8d0e186a7f3ee624519ced (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
{ 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 (lib.mdDoc "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 ];
}
|