From f0835cb45cefc30b629c5ebbc99b04f305104562 Mon Sep 17 00:00:00 2001 From: mexisme Date: Tue, 10 Jan 2023 16:04:46 +1300 Subject: [PATCH] Extract "surface-control" management into new option-enabled module --- microsoft/surface/common/default.nix | 1 + .../common/surface-control/default.nix | 25 +++++++++++++++++++ microsoft/surface/default.nix | 9 +------ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 microsoft/surface/common/surface-control/default.nix diff --git a/microsoft/surface/common/default.nix b/microsoft/surface/common/default.nix index cf83775..8c1fd83 100644 --- a/microsoft/surface/common/default.nix +++ b/microsoft/surface/common/default.nix @@ -7,6 +7,7 @@ in { imports = [ ./kernel ./ipts + ./surface-control ]; microsoft-surface.kernelVersion = mkDefault "6.0.11"; diff --git a/microsoft/surface/common/surface-control/default.nix b/microsoft/surface/common/surface-control/default.nix new file mode 100644 index 0000000..4927c24 --- /dev/null +++ b/microsoft/surface/common/surface-control/default.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: + + +let + inherit (lib) mkDefault mkEnableOption mkIf mkMerge; + + cfg = config.microsoft-surface.surface-control; + +in { + options.microsoft-surface.surface-control = { + enable = mkEnableOption "Enable 'surface-control' for Microsoft Surface"; + }; + + config = mkMerge [ + { + microsoft-surface.surface-control.enable = mkDefault false; + } + + (mkIf cfg.enable { + environment.systemPackages = with pkgs; [ surface-control ]; + services.udev.packages = with pkgs; [ surface-control]; + users.groups.surface-control = { }; + }) + ]; +} diff --git a/microsoft/surface/default.nix b/microsoft/surface/default.nix index 6b84749..5b541c9 100644 --- a/microsoft/surface/default.nix +++ b/microsoft/surface/default.nix @@ -17,13 +17,6 @@ in { options iwldvm force_cam=N ''; - environment.systemPackages = [ - pkgs.surface-control - ]; - users.groups.surface-control = { }; - services.udev.packages = [ - pkgs.surface-control - ]; - + microsoft-surface.surface-control.enable = true; microsoft-surface.ipts.enable = true; }