feat(mc): make the F2 menu overridable via local.mc.menu
Expose the user menu as a `types.lines` option instead of a baked source file. The shipped menu is a `mkBefore` definition (not a `default`, which a consumer definition would drop), so `local.mc.menu = "…"` appends entries after the baseline and `lib.mkForce "…"` replaces it wholesale. `ini` stays a baked source file: it is section/key=value, so append-to-extend risks duplicate keys — not a safe override path.
This commit is contained in:
+22
-2
@@ -10,23 +10,43 @@
|
|||||||
# mutable runtime state (history, cursor positions) in $XDG_DATA_HOME/mc — no
|
# mutable runtime state (history, cursor positions) in $XDG_DATA_HOME/mc — no
|
||||||
# env vars needed. `ini` sets auto_save_setup=false so mc never rewrites these
|
# env vars needed. `ini` sets auto_save_setup=false so mc never rewrites these
|
||||||
# read-only store symlinks on exit.
|
# read-only store symlinks on exit.
|
||||||
|
#
|
||||||
|
# The F2 menu is a `types.lines` option, not a baked source file, so consumers
|
||||||
|
# can extend or replace it. The shipped menu is a `mkBefore` definition (stays
|
||||||
|
# first, ahead of appended entries), NOT a `default` — a `default` is dropped
|
||||||
|
# the moment a consumer adds a definition, which would lose the base. As a real
|
||||||
|
# definition it merges: `local.mc.menu = "…";` appends after the base entries;
|
||||||
|
# `lib.mkForce "…"` replaces it wholesale.
|
||||||
|
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
options.local.mc.otherDir = lib.mkOption {
|
options.local.mc = {
|
||||||
|
otherDir = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = config.home.homeDirectory;
|
default = config.home.homeDirectory;
|
||||||
defaultText = lib.literalExpression "config.home.homeDirectory";
|
defaultText = lib.literalExpression "config.home.homeDirectory";
|
||||||
description = "Startup directory for mc's other (right) panel.";
|
description = "Startup directory for mc's other (right) panel.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
menu = lib.mkOption {
|
||||||
|
type = lib.types.lines;
|
||||||
|
description = ''
|
||||||
|
Contents of mc's F2 user menu. The shipped baseline is a mkBefore
|
||||||
|
definition, so a plain assignment appends entries after it; use
|
||||||
|
lib.mkForce to replace it entirely.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
home.packages = [ pkgs.mc pkgs.ouch ];
|
home.packages = [ pkgs.mc pkgs.ouch ];
|
||||||
|
|
||||||
|
local.mc.menu = lib.mkBefore (builtins.readFile ./assets/mc/menu);
|
||||||
|
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
"mc/ini".source = ./assets/mc/ini;
|
"mc/ini".source = ./assets/mc/ini;
|
||||||
"mc/menu".source = ./assets/mc/menu;
|
"mc/menu".text = config.local.mc.menu;
|
||||||
|
|
||||||
# Generated (not a static asset) so other_dir tracks the option instead of
|
# Generated (not a static asset) so other_dir tracks the option instead of
|
||||||
# baking in a personal path.
|
# baking in a personal path.
|
||||||
|
|||||||
Reference in New Issue
Block a user