diff --git a/nixos/modules/security/grsecurity.nix b/nixos/modules/security/grsecurity.nix index ea245ecc5b6a..92afb74956eb 100644 --- a/nixos/modules/security/grsecurity.nix +++ b/nixos/modules/security/grsecurity.nix @@ -57,7 +57,7 @@ in config = mkIf cfg.enable { - boot.kernelPackages = mkDefault pkgs.linuxPackages_grsec_nixos; + boot.kernelPackages = mkForce pkgs.linuxPackages_grsec_nixos; boot.kernelParams = optional cfg.disableEfiRuntimeServices "noefi"; diff --git a/nixos/modules/security/grsecurity.xml b/nixos/modules/security/grsecurity.xml index 6f9884336b1e..e41748358fbb 100644 --- a/nixos/modules/security/grsecurity.xml +++ b/nixos/modules/security/grsecurity.xml @@ -51,6 +51,13 @@ # nixos-rebuild boot # reboot + + Enabling the grsecurity module overrides + , to reduce the risk of + misconfiguration. + describes how to use a custom kernel package set. + + For most users, further configuration should be unnecessary. All users are encouraged to look over before using the system, however. If you experience problems, please refer to @@ -205,21 +212,22 @@ - To use a custom kernel with upstream's recommended settings for server - deployments: + To build a custom kernel using upstream's recommended settings for server + deployments, while still using the NixOS module: - boot.kernelPackages = - let - kernel = pkgs.linux_grsec_nixos.override { - extraConfig = '' - GRKERNSEC_CONFIG_AUTO y - GRKERNSEC_CONFIG_SERVER y - GRKERNSEC_CONFIG_SECURITY y - ''; + nixpkgs.config.packageOverrides = super: { + linux_grsec_nixos = super.linux_grsec_nixos.override { + extraConfig = '' + GRKERNSEC_CONFIG_AUTO y + GRKERNSEC_CONFIG_SERVER y + GRKERNSEC_CONFIG_SECURITY y + ''; }; - self = pkgs.linuxPackagesFor kernel self; - in self; + } + + + The wikibook provides an exhaustive listing of kernel configuration options. @@ -228,6 +236,18 @@ The NixOS module makes several assumptions about the kernel and so may be incompatible with your customised kernel. Currently, the only way to work around incompatibilities is to eschew the NixOS module. + + If not using the NixOS module, a custom grsecurity package set can + be specified inline instead, as in + + boot.kernelPackages = + let + kernel = pkgs.linux_grsec_nixos.override { + extraConfig = /* as above */; + }; + self = pkgs.linuxPackagesFor kernel self; + in self; +