66 lines
1.6 KiB
Nix
66 lines
1.6 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (lib) mkEnableOption mkOption mkIf types;
|
|
inherit (builtins) listToAttrs;
|
|
cfg = config.programs.murex;
|
|
in {
|
|
options.programs.murex = {
|
|
enable = mkEnableOption "murex shell";
|
|
managePlugins = mkEnableOption "plugin management";
|
|
plugins = mkOption {
|
|
type = with types; listOf package;
|
|
default = [];
|
|
};
|
|
direnv = mkEnableOption "direnv integration";
|
|
profile = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
};
|
|
preload = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
};
|
|
};
|
|
config = {
|
|
home.file =
|
|
{
|
|
".murex_preload" = {
|
|
text = cfg.preload;
|
|
enable = cfg.preload != "";
|
|
};
|
|
".murex_profile" = {
|
|
text =
|
|
cfg.profile
|
|
++ (
|
|
if cfg.direnv
|
|
then ''
|
|
direnv hook murex -> source
|
|
''
|
|
else ""
|
|
);
|
|
enable = cfg.direnv || (cfg.profile != "");
|
|
};
|
|
".murex_modules/packages.json" = {
|
|
text = builtins.toJSON (map (plugin: {
|
|
Protocol = "nix";
|
|
URI = "https://none.thanks/managed.git";
|
|
Package = plugin.pname;
|
|
})
|
|
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)));
|
|
};
|
|
}
|