Getting the same obscure error as many other people here
Biggest issue is that I use the exact same config on another system without issues. Just that there I use flakes, here I just use regular nix channels.
I will share my heavily reduced configs
my configuration.nix:
{ config, lib, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
...
configs/security.nix
...
];
boot.x
networking.x
time.x
i18n.x
console.x
nixpkgs.config.x
nix.settings.x
boot.x
users.users.x
system.stateVersion = x
}
then my configs/security.nix:
{ config, lib, pkgs, ... }:
{
security.apparmor.enable = true;
services.dbus.apparmor = "enabled";
services.dbus.implementation = "broker";
security.apparmor.killUnconfinedConfinables = true;
config.systemd.enableStrictShellChecks = true;
services.logrotate = {
enable = true;
};
### Kernel Arguments
config = {
boot.kernelParams = [
"mitigations=auto"
"pti=on"
"spectre_v2=on"
"l1tf=full,force"
];
boot.initrd.luks.mitigateDMAAttacks = true;
boot.blacklistedKernelModules = [
"appletalk"
"hfs"
"hfsplus"
];
boot.extraModprobeConfig = ''
options vhost max_mem_regions=509
'';
boot.kernel.sysctl = {
"net.core.bpf_jit_enable" = false;
};
};
security = {
lockKernelModules = true;
protectKernelImage = true;
allowSimultaneousMultithreading = true;
unprivilegedUsernsClone = config.virtualisation.containers.enable;
virtualisation.flushL1DataCache = "always";
};
security.sudo.enable = false;
security.sudo-rs.enable = true;
security.wrappers = {
su.enable = false;
pkexec.enable = false;
chsh = {
source = "${pkgs.shadow}/bin/chsh";
setuid = lib.mkForce false;
owner = "root";
group = "root";
};
};
services.clamav = {
updater = {
enable = true;
interval = "6h";
};
scanner = {
enable = true;
interval = "*-*-* 17:00:00";
scanDirectories = [
"/home/user/Downloads"
];
};
};
}
I am getting multiple of these errors and did not understand the reason and solution
error: Module `/etc/nixos/configs/security.nix' has an unsupported attribute `security'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: security services) into the explicit `config' attribute.
error: Module `/etc/nixos/configs/security.nix' has an unsupported attribute `boot'. This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: boot security services) into the explicit `config' attribute.