summary refs log tree commit diff
path: root/nixos/modules/hardware/system-76.nix
diff options
context:
space:
mode:
authorJasper Woudenberg <mail@jasperwoudenberg.com>2021-06-12 11:35:19 +0200
committerJasper Woudenberg <mail@jasperwoudenberg.com>2021-06-13 22:11:42 +0200
commit04d20258ea8945b644fc54188291b4c31269e162 (patch)
treef860ebce9647ba73d53f6cf821c80eecac3cbeba /nixos/modules/hardware/system-76.nix
parentb94e1977e0c89060d3ba63bbfa6372e0f0d231b3 (diff)
downloadnixpkgs-04d20258ea8945b644fc54188291b4c31269e162.tar
nixpkgs-04d20258ea8945b644fc54188291b4c31269e162.tar.gz
nixpkgs-04d20258ea8945b644fc54188291b4c31269e162.tar.bz2
nixpkgs-04d20258ea8945b644fc54188291b4c31269e162.tar.lz
nixpkgs-04d20258ea8945b644fc54188291b4c31269e162.tar.xz
nixpkgs-04d20258ea8945b644fc54188291b4c31269e162.tar.zst
nixpkgs-04d20258ea8945b644fc54188291b4c31269e162.zip
system76-power: init at 1.1.16
Diffstat (limited to 'nixos/modules/hardware/system-76.nix')
-rw-r--r--nixos/modules/hardware/system-76.nix28
1 files changed, 27 insertions, 1 deletions
diff --git a/nixos/modules/hardware/system-76.nix b/nixos/modules/hardware/system-76.nix
index ed661fd3303..3a50c5aa0f0 100644
--- a/nixos/modules/hardware/system-76.nix
+++ b/nixos/modules/hardware/system-76.nix
@@ -34,6 +34,25 @@ let
       wantedBy = [ "multi-user.target" ];
     };
   };
+
+  power-pkg = pkgs.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 = {
@@ -52,8 +71,15 @@ in {
         description = "Whether to make the system76 out-of-tree kernel modules available";
         type = types.bool;
       };
+
+      power-daemon.enable = mkOption {
+        default = cfg.enableAll;
+        example = true;
+        description = "Whether to enable the system76 power daemon";
+        type = types.bool;
+      };
     };
   };
 
-  config = mkMerge [ moduleConfig firmwareConfig ];
+  config = mkMerge [ moduleConfig firmwareConfig powerConfig ];
 }