mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/services.upower: remove with lib;
This commit is contained in:
parent
c1573bb3ef
commit
ab7b22c311
1 changed files with 27 additions and 31 deletions
|
@ -1,9 +1,5 @@
|
||||||
# Upower daemon.
|
# Upower daemon.
|
||||||
|
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.upower;
|
cfg = config.services.upower;
|
||||||
|
@ -18,8 +14,8 @@ in
|
||||||
|
|
||||||
services.upower = {
|
services.upower = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Whether to enable Upower, a DBus service that provides power
|
Whether to enable Upower, a DBus service that provides power
|
||||||
|
@ -27,10 +23,10 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkPackageOption pkgs "upower" { };
|
package = lib.mkPackageOption pkgs "upower" { };
|
||||||
|
|
||||||
enableWattsUpPro = mkOption {
|
enableWattsUpPro = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Enable the Watts Up Pro device.
|
Enable the Watts Up Pro device.
|
||||||
|
@ -47,8 +43,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
noPollBatteries = mkOption {
|
noPollBatteries = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Don't poll the kernel for battery level changes.
|
Don't poll the kernel for battery level changes.
|
||||||
|
@ -59,8 +55,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
ignoreLid = mkOption {
|
ignoreLid = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Do we ignore the lid state
|
Do we ignore the lid state
|
||||||
|
@ -73,8 +69,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
usePercentageForPolicy = mkOption {
|
usePercentageForPolicy = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = ''
|
description = ''
|
||||||
Policy for warnings and action based on battery levels
|
Policy for warnings and action based on battery levels
|
||||||
|
@ -87,8 +83,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
percentageLow = mkOption {
|
percentageLow = lib.mkOption {
|
||||||
type = types.ints.unsigned;
|
type = lib.types.ints.unsigned;
|
||||||
default = 10;
|
default = 10;
|
||||||
description = ''
|
description = ''
|
||||||
When `usePercentageForPolicy` is
|
When `usePercentageForPolicy` is
|
||||||
|
@ -105,8 +101,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
percentageCritical = mkOption {
|
percentageCritical = lib.mkOption {
|
||||||
type = types.ints.unsigned;
|
type = lib.types.ints.unsigned;
|
||||||
default = 3;
|
default = 3;
|
||||||
description = ''
|
description = ''
|
||||||
When `usePercentageForPolicy` is
|
When `usePercentageForPolicy` is
|
||||||
|
@ -123,8 +119,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
percentageAction = mkOption {
|
percentageAction = lib.mkOption {
|
||||||
type = types.ints.unsigned;
|
type = lib.types.ints.unsigned;
|
||||||
default = 2;
|
default = 2;
|
||||||
description = ''
|
description = ''
|
||||||
When `usePercentageForPolicy` is
|
When `usePercentageForPolicy` is
|
||||||
|
@ -141,8 +137,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
timeLow = mkOption {
|
timeLow = lib.mkOption {
|
||||||
type = types.ints.unsigned;
|
type = lib.types.ints.unsigned;
|
||||||
default = 1200;
|
default = 1200;
|
||||||
description = ''
|
description = ''
|
||||||
When `usePercentageForPolicy` is
|
When `usePercentageForPolicy` is
|
||||||
|
@ -155,8 +151,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
timeCritical = mkOption {
|
timeCritical = lib.mkOption {
|
||||||
type = types.ints.unsigned;
|
type = lib.types.ints.unsigned;
|
||||||
default = 300;
|
default = 300;
|
||||||
description = ''
|
description = ''
|
||||||
When `usePercentageForPolicy` is
|
When `usePercentageForPolicy` is
|
||||||
|
@ -169,8 +165,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
timeAction = mkOption {
|
timeAction = lib.mkOption {
|
||||||
type = types.ints.unsigned;
|
type = lib.types.ints.unsigned;
|
||||||
default = 120;
|
default = 120;
|
||||||
description = ''
|
description = ''
|
||||||
When `usePercentageForPolicy` is
|
When `usePercentageForPolicy` is
|
||||||
|
@ -183,8 +179,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
criticalPowerAction = mkOption {
|
criticalPowerAction = lib.mkOption {
|
||||||
type = types.enum [ "PowerOff" "Hibernate" "HybridSleep" ];
|
type = lib.types.enum [ "PowerOff" "Hibernate" "HybridSleep" ];
|
||||||
default = "HybridSleep";
|
default = "HybridSleep";
|
||||||
description = ''
|
description = ''
|
||||||
The action to take when `timeAction` or
|
The action to take when `timeAction` or
|
||||||
|
@ -200,7 +196,7 @@ in
|
||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
environment.systemPackages = [ cfg.package ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
|
@ -210,7 +206,7 @@ in
|
||||||
|
|
||||||
systemd.packages = [ cfg.package ];
|
systemd.packages = [ cfg.package ];
|
||||||
|
|
||||||
environment.etc."UPower/UPower.conf".text = generators.toINI {} {
|
environment.etc."UPower/UPower.conf".text = lib.generators.toINI {} {
|
||||||
UPower = {
|
UPower = {
|
||||||
EnableWattsUpPro = cfg.enableWattsUpPro;
|
EnableWattsUpPro = cfg.enableWattsUpPro;
|
||||||
NoPollBatteries = cfg.noPollBatteries;
|
NoPollBatteries = cfg.noPollBatteries;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue