Skip to content

Commit

Permalink
Add system76 NixOS module
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy committed Sep 23, 2020
1 parent 9f43146 commit 4b1850b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions nixos/modules/hardware/system-76.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{ config, lib, pkgs, ... }:

let
inherit (lib) mkOption mkEnableOption types mkIf mkMerge optional versionOlder;
cfg = config.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 {
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" ];
};
};
in {
options = {
hardware.system76 = {
enableAll = mkEnableOption "all recommended configuration for system76 systems";

firmware-daemon.enable = mkOption {
default = cfg.enableAll;
example = true;
description = "Whether to enable the system76 firmware daemon";
type = types.bool;
};

kernel-modules.enable = mkOption {
default = cfg.enableAll;
example = true;
description = "Whether to make the system76 out-of-tree kernel modules available";
type = types.bool;
};
};
};

config = mkMerge [ moduleConfig firmwareConfig ];
}
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
./hardware/printers.nix
./hardware/raid/hpsa.nix
./hardware/steam-hardware.nix
./hardware/system-76.nix
./hardware/tuxedo-keyboard.nix
./hardware/usb-wwan.nix
./hardware/onlykey.nix
Expand Down

0 comments on commit 4b1850b

Please sign in to comment.