Enabling hardened profile

I was looking around nixpkgs repo and found the file nixos/modules/profiles/hardened.nix and tried to enable in my nixos config with profiles.hardened.enable = true; but it said it doesn’t exist… I think i am missunderstanding something

You’ll notice that profiles.hardened is enabled by default in that module. That’s because the “profile” modules are intended to be explicitly imported. At the top of your configuration you add the modulesPath parameter and then you can use "${modulesPath}/profiles/hardened.nix" in imports. e.g.

{ pkgs, modulesPath, ... }:

{
  imports = [ "${modulesPath}/profiles/hardened.nix" ];
}
1 Like

I would note this discussion Proposal to deprecate the hardened profile

2 Likes