git.iko.soy/typeable/nixpkgs
on master help sign in
tests: Add sysctl
commit04b0f3255fc2c9e275ac93eeb29c37f6465a3992 authorTim Steinbach <tim@nequissimus.com> dateTue 5 Sep 2017, 19:03 (9 years ago) parent8706664
3 files changed+27
nixos/release-combined.nix+1 nixos/release.nix+1 nixos/tests/sysctl.nix+25
nixos/release-combined.nix+1
@@ -115,6 +115,7 @@ in rec {
115115 (all nixos.tests.sddm.default)
116116 (all nixos.tests.simple)
117117 (all nixos.tests.slim)
118+ (all nixos.tests.sysctl)
118119 (all nixos.tests.udisks2)
119120 (all nixos.tests.xfce)
120121
nixos/release.nix+1
@@ -309,6 +309,7 @@ in rec {
309309 tests.slim = callTest tests/slim.nix {};
310310 tests.smokeping = callTest tests/smokeping.nix {};
311311 tests.snapper = callTest tests/snapper.nix {};
312+ tests.sysctl = callTest tests/sysctl.nix {};
312313 tests.taskserver = callTest tests/taskserver.nix {};
313314 tests.tomcat = callTest tests/tomcat.nix {};
314315 tests.udisks2 = callTest tests/udisks2.nix {};
nixos/tests/sysctl.nixnew file+25
@@ -0,0 +1,25 @@
1+import ./make-test.nix ({ pkgs, ...} : {
2+ name = "sysctl";
3+ meta = with pkgs.stdenv.lib.maintainers; {
4+ maintainers = [ nequissimus ];
5+ };
6+
7+ machine = { config, lib, pkgs, ... }:
8+ {
9+ boot.kernelPackages = pkgs.linuxPackages;
10+ boot.kernel.sysctl = {
11+ "kernel.dmesg_restrict" = true; # Restrict dmesg access
12+ "net.core.bpf_jit_enable" = false; # Turn off bpf JIT
13+ "user.max_user_namespaces" = 0; # Disable user namespaces
14+ "vm.swappiness" = 2; # Low swap usage
15+ };
16+ };
17+
18+ testScript =
19+ ''
20+ $machine->succeed("sysctl kernel.dmesg_restrict | grep 'kernel.dmesg_restrict = 1'");
21+ $machine->succeed("sysctl net.core.bpf_jit_enable | grep 'net.core.bpf_jit_enable = 0'");
22+ $machine->succeed("sysctl user.max_user_namespaces | grep 'user.max_user_namespaces = 0'");
23+ $machine->succeed("sysctl vm.swappiness | grep 'vm.swappiness = 2'");
24+ '';
25+})