Files
home-manager/modules/programs/mc.nix
Austin Horstman 01ea51d706 treewide: use inherit for attribute assignments
This change converts redundant attribute assignments of the form `a =
a;` or `a = someSet.a;` into cleaner `inherit` statements. This reduces
verbosity and follows common Nix style for bringing attributes into
scope.

Statix Codes: W03 (manual_inherit), W04 (manual_inherit_from)

Also include statix and the rule in our configuration.
2026-04-08 14:47:48 -05:00

120 lines
3.0 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.mc;
inherit ((pkgs.formats.ini { })) type;
in
{
options.programs.mc = {
enable = lib.mkEnableOption "Midnight Commander";
package = lib.mkPackageOption pkgs "mc" { nullable = true; };
settings = lib.mkOption {
inherit type;
default = { };
description = ''
Settings for `mc/ini` file.
Any missing settings will fall back to the system default.
'';
example = {
Panels = {
show_dot_files = false;
};
};
};
keymapSettings = lib.mkOption {
inherit type;
default = { };
description = ''
Settings for `mc/mc.keymap` file.
Any missing settings will fall back to the system default.
'';
example = {
panel = {
Up = "up;ctrl-k";
};
};
};
extensionSettings = lib.mkOption {
inherit type;
default = { };
description = ''
Settings for `mc/mc.ext.ini` file. This setting completely replaces the default `/etc/mc/mc.ext.ini`.
Midnight Commander does not merge this file with the system default,
so you should copy the original if you want to preserve default behavior and add your changes there.
'';
example = {
EPUB = {
Shell = ".epub";
Open = "fbreader %f &";
};
};
};
panelsSettings = lib.mkOption {
inherit type;
default = { };
description = ''
Settings for `mc/panels` file.
Any missing settings will fall back to the system default.
'';
example = {
Dirs = {
current_is_left = false;
other_dir = "/home";
};
};
};
fileHighlightSettings = lib.mkOption {
inherit type;
default = { };
description = ''
Settings for `mc/filehighlight.ini` file. This setting completely replaces the default `/etc/mc/filehighlight.ini`.
Midnight Commander does not merge this file with the system default, so you should copy the original if you want to preserve default behavior
and add your changes there.
'';
example = {
lua = {
extensions = "lua;luac";
};
};
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
xdg.configFile = {
"mc/ini" = lib.mkIf (cfg.settings != { }) {
text = lib.generators.toINI { } cfg.settings;
};
"mc/mc.keymap" = lib.mkIf (cfg.keymapSettings != { }) {
text = lib.generators.toINI { } cfg.keymapSettings;
};
"mc/mc.ext.ini" = lib.mkIf (cfg.extensionSettings != { }) {
text = lib.generators.toINI { } cfg.extensionSettings;
};
"mc/panels.ini" = lib.mkIf (cfg.panelsSettings != { }) {
text = lib.generators.toINI { } cfg.panelsSettings;
};
"mc/filehighlight.ini" = lib.mkIf (cfg.fileHighlightSettings != { }) {
text = lib.generators.toINI { } cfg.fileHighlightSettings;
};
};
};
}