warnings.nix: port to a proper module

This commit is contained in:
Colin 2024-02-20 11:19:12 +00:00
parent 902e351085
commit d7be5da483
5 changed files with 22 additions and 14 deletions

View File

@ -16,7 +16,6 @@
./secrets.nix
./ssh.nix
./users
./warnings.nix
];
sane.nixcache.enable-trusted-keys = true;

View File

@ -51,6 +51,12 @@
};
};
# i explicitly set both `initialPassword` and `hashedPasswordFile`, so ignore the warning against this.
# see: <https://github.com/NixOS/nixpkgs/pull/287506>
sane.silencedWarnings = [
"The user 'colin' has multiple of the options\n`hashedPassword`, `password`, `hashedPasswordFile`, `initialPassword`\n& `initialHashedPassword` set to a non-null value.\nThe options silently discard others by the order of precedence\ngiven above which can lead to surprising results. To resolve this warning,\nset at most one of the options above to a non-`null` value.\n"
];
environment.etc."/security/capability.conf".text = ''
# The pam_cap.so module accepts the following arguments:
#

View File

@ -1,13 +0,0 @@
{ lib, ... }:
let
ignored = [
"The user 'colin' has multiple of the options\n`hashedPassword`, `password`, `hashedPasswordFile`, `initialPassword`\n& `initialHashedPassword` set to a non-null value.\nThe options silently discard others by the order of precedence\ngiven above which can lead to surprising results. To resolve this warning,\nset at most one of the options above to a non-`null` value.\n"
];
in
{
options = {
warnings = lib.mkOption {
apply = builtins.filter (w: !(builtins.elem w ignored));
};
};
}

View File

@ -16,6 +16,7 @@
./ssh.nix
./users.nix
./vpn.nix
./warnings.nix
./wowlan.nix
];

15
modules/warnings.nix Normal file
View File

@ -0,0 +1,15 @@
{ config, lib, ... }:
{
options = with lib; {
sane.silencedWarnings = mkOption {
type = types.listOf types.string;
default = [];
description = ''
list of `config.warnings` values you want to ignore, verbatim.
'';
};
warnings = mkOption {
apply = builtins.filter (w: !(builtins.elem w config.sane.silencedWarnings));
};
};
}