Commit a511980bf904

Vincent Demeester <vincent@sbr.pm>
2022-08-19 12:05:12
systems/modules: modules.hardware.laptop takes over
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 0b2136d
Changed files (2)
systems
modules
hardware
profiles
systems/modules/hardware/laptop.nix
@@ -9,5 +9,28 @@ in
       enable = mkEnableOption "Enable laptop profile";
     };
   };
-  config = mkIf cfg.enable { };
+  config = mkIf cfg.enable {
+    # Some systctl options for all laptops
+    boot.kernel.sysctl = {
+      "vm.swappiness" = 10;
+      "vm.dirty_ratio" = 25;
+      "vm.dirty_background_ratio" = 10;
+      "vm.dirty_writeback_centisecs" = 5000;
+      "vm.dirty_expire_centisecs" = 5000;
+    };
+    # Packages that are always useful for laptops
+    environment.systemPackages = with pkgs; [
+      lm_sensors
+      powertop
+      acpi
+    ];
+    # Run nix-gc only when on AC power
+    systemd.services.nix-gc.unitConfig.ConditionACPower = true;
+    # When a laptop is docked, ignor the lid state (if the laptop is opened or closed)
+    services = {
+      logind.extraConfig = ''
+        HandleLidSwitchDocked=ignore
+      '';
+    };
+  };
 }
systems/modules/profiles/laptop.nix
@@ -11,23 +11,8 @@ in
     };
   };
   config = mkIf cfg.enable {
-    boot.kernel.sysctl = {
-      "vm.swappiness" = 10;
-      "vm.dirty_ratio" = 25;
-      "vm.dirty_background_ratio" = 10;
-      "vm.dirty_writeback_centisecs" = 5000;
-      "vm.dirty_expire_centisecs" = 5000;
-    };
-    environment.systemPackages = with pkgs; [
-      lm_sensors
-      powertop
-      acpi
-    ];
-    systemd.services.nix-gc.unitConfig.ConditionACPower = true;
-    services = {
-      logind.extraConfig = ''
-        HandleLidSwitchDocked=ignore
-      '';
-    };
+    warnings = [ "The option 'profiles.laptop' is deprecated, use modules.hardware.laptop instead" ];
+    # Use modules.hardware.enable instead
+    modules.hardware.laptop.enable = true;
   };
 }