diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-04-01 19:55:49 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-04-01 20:00:27 +0200 |
commit | 224ed7e798caf80e65250385a9cb0ab09c52d2c7 (patch) | |
tree | 0017e7daad8af982560e584e072f051f7e8dbc4d | |
parent | eecb59a805b7b1a0040dfb28b249abe6283a6770 (diff) | |
download | nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.gz nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.bz2 nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.lz nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.xz nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.zst nixpkgs-224ed7e798caf80e65250385a9cb0ab09c52d2c7.zip |
nixos/hardware: Add option to enable KSM.
This is essentially what's been done for the official NixOS build slaves and I'm using it as well for a few of my machines and my own Hydra slaves. Here's the same implementation from the Delft server configurations: https://github.com/NixOS/nixos-org-configurations/blob/f47c2fc7f82cc8aa4ea8047487cbb819d6829fe2/delft/common.nix#L91-L101 Signed-off-by: aszlig <aszlig@redmoonstudios.org>
-rw-r--r-- | nixos/modules/hardware/ksm.nix | 18 | ||||
-rw-r--r-- | nixos/modules/module-list.nix | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/nixos/modules/hardware/ksm.nix b/nixos/modules/hardware/ksm.nix new file mode 100644 index 00000000000..d6ac69b5d65 --- /dev/null +++ b/nixos/modules/hardware/ksm.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +{ + options.hardware.enableKSM = lib.mkEnableOption "Kernel Same-Page Merging"; + + config = lib.mkIf config.hardware.enableKSM { + systemd.services.enable-ksm = { + description = "Enable Kernel Same-Page Merging"; + wantedBy = [ "multi-user.target" ]; + after = [ "systemd-udev-settle.service" ]; + script = '' + if [ -e /sys/kernel/mm/ksm ]; then + echo 1 > /sys/kernel/mm/ksm/run + fi + ''; + }; + }; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 738faa79e29..33830dbc810 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -29,6 +29,7 @@ ./hardware/all-firmware.nix ./hardware/cpu/amd-microcode.nix ./hardware/cpu/intel-microcode.nix + ./hardware/ksm.nix ./hardware/network/b43.nix ./hardware/network/intel-2100bg.nix ./hardware/network/intel-2200bg.nix |