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 /nixos/modules/hardware/ksm.nix | |
parent | eecb59a805b7b1a0040dfb28b249abe6283a6770 (diff) | |
download | nixlib-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar nixlib-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.gz nixlib-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.bz2 nixlib-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.lz nixlib-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.xz nixlib-224ed7e798caf80e65250385a9cb0ab09c52d2c7.tar.zst nixlib-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>
Diffstat (limited to 'nixos/modules/hardware/ksm.nix')
-rw-r--r-- | nixos/modules/hardware/ksm.nix | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nixos/modules/hardware/ksm.nix b/nixos/modules/hardware/ksm.nix new file mode 100644 index 000000000000..d6ac69b5d65e --- /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 + ''; + }; + }; +} |