mc: add midnight commander module (#7225)

This commit is contained in:
Egor Konovalov 2025-06-09 16:25:11 +02:00 committed by GitHub
parent eee140958a
commit 35e1f5a7c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 200 additions and 0 deletions

View file

@ -188,6 +188,7 @@ let
./programs/mangohud.nix
./programs/matplotlib.nix
./programs/mbsync.nix
./programs/mc.nix
./programs/mcfly.nix
./programs/meli.nix
./programs/mercurial.nix

119
modules/programs/mc.nix Normal file
View file

@ -0,0 +1,119 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.mc;
type = (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;
};
};
};
}

View file

@ -245,6 +245,7 @@ import nmtSrc {
./modules/programs/lsd
./modules/programs/man
./modules/programs/mbsync
./modules/programs/mc
./modules/programs/meli
./modules/programs/mergiraf
./modules/programs/micro

View file

@ -0,0 +1,2 @@
[Panels]
show_dot_files=false

View file

@ -0,0 +1,66 @@
{ config, lib, ... }:
{
programs.mc = {
enable = true;
settings = {
Panels = {
show_dot_files = false;
};
};
keymapSettings = {
panel = {
Up = "up;ctrl-k";
};
};
extensionSettings = {
EPUB = {
Shell = ".epub";
Open = "fbreader %f &";
};
};
panelsSettings = {
Dirs = {
current_is_left = false;
other_dir = "/home";
};
};
fileHighlightSettings = {
lua = {
extensions = "lua;luac";
};
};
};
nmt.script = ''
mcFolder="home-files/.config/mc"
assertFileExists "$mcFolder/ini"
assertFileExists "$mcFolder/mc.keymap"
assertFileExists "$mcFolder/mc.ext.ini"
assertFileExists "$mcFolder/panels.ini"
assertFileExists "$mcFolder/filehighlight.ini"
assertFileContent \
"$mcFolder/ini" \
${./basic-configuration}
assertFileContent \
"$mcFolder/mc.keymap" \
${./mc.keymap}
assertFileContent \
"$mcFolder/mc.ext.ini" \
${./mc.ext.ini}
assertFileContent \
"$mcFolder/panels.ini" \
${./panels.ini}
assertFileContent \
"$mcFolder/filehighlight.ini" \
${./filehighlight.ini}
'';
}

View file

@ -0,0 +1 @@
{ mc-basic-configuration = ./basic-configuration.nix; }

View file

@ -0,0 +1,2 @@
[lua]
extensions=lua;luac

View file

@ -0,0 +1,3 @@
[EPUB]
Open=fbreader %f &
Shell=.epub

View file

@ -0,0 +1,2 @@
[panel]
Up=up;ctrl-k

View file

@ -0,0 +1,3 @@
[Dirs]
current_is_left=false
other_dir=/home