laptop.nix (1354B)
1 { config, lib, pkgs, ... }: 2 let 3 inherit (lib) mkEnableOption mkIf mkMerge mkOption types; 4 cfg = config.modules.hardware.laptop; 5 in 6 { 7 options = { 8 modules.hardware.laptop = { 9 enable = mkEnableOption "Enable laptop profile"; 10 }; 11 }; 12 config = mkIf cfg.enable (mkMerge [ 13 { 14 # Some systctl options for all laptops 15 boot.kernel.sysctl = { 16 "vm.swappiness" = 10; 17 "vm.dirty_ratio" = 25; 18 "vm.dirty_background_ratio" = 10; 19 "vm.dirty_writeback_centisecs" = 5000; 20 "vm.dirty_expire_centisecs" = 5000; 21 }; 22 # Packages that are always useful for laptops 23 environment.systemPackages = with pkgs; [ 24 lm_sensors 25 powertop 26 acpi 27 ]; 28 # Run nix-gc only when on AC power 29 systemd.services.nix-gc.unitConfig.ConditionACPower = true; 30 # When a laptop is docked or on external power, ignore the lid state (if the laptop is opened or closed) 31 services = { 32 logind.extraConfig = '' 33 HandleLidSwitchExternalPower=ignore 34 HandleLidSwitchDocked=ignore 35 ''; 36 }; 37 } 38 (mkIf config.modules.desktop.enable { 39 # FIXME to enable 40 # Graphical interface, we can add additionnal packages 41 # Enable setting power-profiles trough DBus 42 services.power-profiles-daemon.enable = true; 43 }) 44 ]); 45 }