begin murex aliases

This commit is contained in:
atagen 2024-10-09 23:44:45 +11:00
parent 67702255a2
commit 0562e2235d
4 changed files with 80 additions and 27 deletions

View file

@ -11,11 +11,11 @@ in {
options.programs.murex = {
enable = mkEnableOption "murex shell";
managePlugins = mkEnableOption "plugin management";
direnv = mkEnableOption "direnv integration";
plugins = mkOption {
type = with types; listOf package;
default = [];
};
direnv = mkEnableOption "direnv integration";
profile = mkOption {
type = types.str;
default = "";
@ -26,24 +26,35 @@ in {
};
useXdgConfig = mkEnableOption "override MUREX_{PRELOAD,MODULES,PROFILE} env vars to conform to XDG_CONFIG_HOME";
};
config = {
home.file =
{
config = mkIf cfg.enable {
home.file = let
plugins = listToAttrs (map (plugin: {
name = ".murex_modules/${plugin.pname}";
value = {
recursive = true;
source = plugin;
};
})
cfg.plugins);
in
lib.mergeAttrs plugins {
".murex_preload" = {
text = cfg.preload;
executable = true;
enable = cfg.preload != "";
};
".murex_profile" = {
text =
cfg.profile
++ (
+ (
if cfg.direnv
then ''
direnv hook murex -> source
''
else ""
);
enable = cfg.direnv || (cfg.profile != "");
executable = true;
enable = cfg.direnv || cfg.profile != "";
};
".murex_modules/packages.json" = {
text = builtins.toJSON (map (plugin: {
@ -54,19 +65,13 @@ in {
cfg.plugins);
enable = cfg.managePlugins && (cfg.plugins != []);
};
}
// (mkIf cfg.managePlugins (listToAttrs (map (plugin: {
name = ".murex_modules/${plugin.pname}";
value = {
recursive = true;
source = plugin;
};
})
cfg.plugins)));
home.sessionVariables = mkIf cfg.useXdgConfig {
MUREX_PRELOAD = "$XDG_CONFIG_HOME/murex/";
MUREX_MODULES = "$XDG_CONFIG_HOME/murex/";
MUREX_PROFILE = "$XDG_CONFIG_HOME/murex/";
};
};
home.sessionVariables =
mkIf
cfg.useXdgConfig {
MUREX_PRELOAD = "$XDG_CONFIG_HOME/murex/";
MUREX_MODULES = "$XDG_CONFIG_HOME/murex/";
MUREX_PROFILE = "$XDG_CONFIG_HOME/murex/";
};
};
}