mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
nixos/pay-respects: add runtimeRules option
Signed-off-by: Fernando Rodrigues <alpha@sigmasquadron.net>
This commit is contained in:
parent
f23ec9f976
commit
29e9725bb7
1 changed files with 46 additions and 2 deletions
|
@ -7,16 +7,22 @@
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
getExe
|
getExe
|
||||||
|
literalExpression
|
||||||
maintainers
|
maintainers
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
mkIf
|
mkIf
|
||||||
|
mkMerge
|
||||||
mkOption
|
mkOption
|
||||||
optionalString
|
optionalString
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
inherit (types) str;
|
inherit (types) listOf str;
|
||||||
|
|
||||||
cfg = config.programs.pay-respects;
|
cfg = config.programs.pay-respects;
|
||||||
|
|
||||||
|
settingsFormat = pkgs.formats.toml { };
|
||||||
|
inherit (settingsFormat) generate type;
|
||||||
|
|
||||||
initScript =
|
initScript =
|
||||||
shell:
|
shell:
|
||||||
if (shell != "fish") then
|
if (shell != "fish") then
|
||||||
|
@ -41,11 +47,49 @@ in
|
||||||
The default value is `f`, but you can use anything else as well.
|
The default value is `f`, but you can use anything else as well.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
runtimeRules = mkOption {
|
||||||
|
type = listOf type;
|
||||||
|
default = [ ];
|
||||||
|
example = literalExpression ''
|
||||||
|
[
|
||||||
|
{
|
||||||
|
command = "xl";
|
||||||
|
match_err = [
|
||||||
|
{
|
||||||
|
pattern = [
|
||||||
|
"Permission denied"
|
||||||
|
];
|
||||||
|
suggest = [
|
||||||
|
'''
|
||||||
|
#[executable(sudo), !cmd_contains(sudo), err_contains(libxl: error:)]
|
||||||
|
sudo {{command}}
|
||||||
|
'''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
List of rules to be added to `/etc/xdg/pay-respects/rules`.
|
||||||
|
`pay-respects` will read the contents of these generated rules to recommend command corrections.
|
||||||
|
Each rule module should start with the `command` attribute that specifies the command name. See the [upstream documentation](https://codeberg.org/iff/pay-respects/src/branch/main/rules.md) for more information.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
environment.systemPackages = [ pkgs.pay-respects ];
|
environment = mkMerge (
|
||||||
|
[
|
||||||
|
{
|
||||||
|
systemPackages = [ pkgs.pay-respects ];
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ map (rule: {
|
||||||
|
etc."xdg/pay-respects/rules/${rule.command}.toml".source = generate "${rule.command}.toml" rule;
|
||||||
|
}) cfg.runtimeRules
|
||||||
|
);
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
bash.interactiveShellInit = initScript "bash";
|
bash.interactiveShellInit = initScript "bash";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue