summaryrefslogtreecommitdiff
path: root/modules/nixos/disable-screen/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos/disable-screen/default.nix')
-rw-r--r--modules/nixos/disable-screen/default.nix51
1 files changed, 24 insertions, 27 deletions
diff --git a/modules/nixos/disable-screen/default.nix b/modules/nixos/disable-screen/default.nix
index b70d80d..142507d 100644
--- a/modules/nixos/disable-screen/default.nix
+++ b/modules/nixos/disable-screen/default.nix
@@ -1,14 +1,14 @@
# This file defines some configuration options which disable the screen. This
# is only relevant because this host is an old laptop running as a server.
-
-{ lib, config, ... }:
-
-let
+{
+ lib,
+ config,
+ ...
+}: let
inherit (lib) mkEnableOption mkOption types;
cfg = config.disable-screen;
-in
-{
+in {
options.disable-screen = {
enable = mkEnableOption "disable screen";
@@ -27,38 +27,35 @@ in
config = {
# Disable sleep on lid close.
- services.logind =
- let
- lidSwitchAction = "ignore";
- in
- {
- lidSwitchExternalPower = lidSwitchAction;
- lidSwitchDocked = lidSwitchAction;
- lidSwitch = lidSwitchAction;
- };
+ services.logind = let
+ lidSwitchAction = "ignore";
+ in {
+ lidSwitchExternalPower = lidSwitchAction;
+ lidSwitchDocked = lidSwitchAction;
+ lidSwitch = lidSwitchAction;
+ };
# Don't store screen brightness between boots. We always want to turn off the
# screen.
#
# See: https://wiki.archlinux.org/title/backlight#Save_and_restore_functionality
# See: https://github.com/NixOS/nixpkgs/blob/990398921f677615c0732d704857484b84c6c888/nixos/modules/system/boot/systemd.nix#L97-L101
- systemd.suppressedSystemUnits = [ "[email protected]" ];
+ systemd.suppressedSystemUnits = ["[email protected]"];
# FIXME: Figure out how to enable screen when on-device debugging is necessary.
# Create a new service which turns off the display on boot.
#
# See: https://nixos.wiki/wiki/Backlight#.2Fsys.2Fclass.2Fbacklight.2F...
# See: https://superuser.com/questions/851846/how-to-write-a-systemd-service-that-depends-on-a-device-being-present
- systemd.services.disable-screen =
- {
- requires = [ cfg.device-unit ];
- after = [ cfg.device-unit ];
- wantedBy = [ cfg.device-unit ];
-
- serviceConfig.Type = "oneshot";
- script = ''
- tee ${cfg.device-path}/brightness <<<0
- '';
- };
+ systemd.services.disable-screen = {
+ requires = [cfg.device-unit];
+ after = [cfg.device-unit];
+ wantedBy = [cfg.device-unit];
+
+ serviceConfig.Type = "oneshot";
+ script = ''
+ tee ${cfg.device-path}/brightness <<<0
+ '';
+ };
};
}