mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
116 lines
2.7 KiB
Nix
116 lines
2.7 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) literalExpression mkOption types;
|
|
|
|
cfg = config.programs.boxxy;
|
|
|
|
configPath = "${config.xdg.configHome}/boxxy/boxxy.yaml";
|
|
settingsFormat = pkgs.formats.yaml { };
|
|
|
|
boxxyRulesOpts = types.submodule {
|
|
freeformType = settingsFormat.type;
|
|
|
|
options = {
|
|
name = mkOption {
|
|
type = types.str;
|
|
description = ''
|
|
Unique identifier of the boxxy rule. This can be any single-line string.
|
|
'';
|
|
};
|
|
|
|
target = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
example = "~/.ssh";
|
|
description = ''
|
|
What directory/file to redirect.
|
|
'';
|
|
};
|
|
|
|
rewrite = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
example = literalExpression ''"''${config.xdg.configHome}/ssh"'';
|
|
description = ''
|
|
Where that file/directory should be rewritten to.
|
|
'';
|
|
};
|
|
|
|
mode = mkOption {
|
|
type = types.enum [
|
|
"file"
|
|
"directory"
|
|
];
|
|
default = "directory";
|
|
description = ''
|
|
Does the current path redirect a file or a directory?
|
|
'';
|
|
};
|
|
|
|
only = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [
|
|
"bash"
|
|
"/usr/bin/sh"
|
|
];
|
|
description = ''
|
|
Apply redirection ONLY to specified executable names.
|
|
'';
|
|
};
|
|
|
|
context = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "/home/example/Projects/my-project" ];
|
|
description = ''
|
|
Apply redirection ONLY when in a certain directory.
|
|
'';
|
|
};
|
|
|
|
env = mkOption {
|
|
type = types.attrsOf types.str;
|
|
default = { };
|
|
example = {
|
|
MY_ENV_VAR = "my_env_var_value";
|
|
};
|
|
description = ''
|
|
Give certain environment variables for said match.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
meta.maintainers = with lib.hm.maintainers; [ nikp123 ];
|
|
|
|
options.programs.boxxy = {
|
|
enable = lib.mkEnableOption "boxxy: Boxes in badly behaving applications";
|
|
|
|
package = lib.mkPackageOption pkgs "boxxy" { nullable = true; };
|
|
|
|
rules = mkOption {
|
|
type = types.listOf boxxyRulesOpts;
|
|
default = [ ];
|
|
description = "List of boxxy rules";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "programs.boxxy" pkgs lib.platforms.linux)
|
|
];
|
|
|
|
home.file = lib.mkIf (cfg.rules != [ ]) {
|
|
"${configPath}".source = settingsFormat.generate "boxxy-config.yaml" { inherit (cfg) rules; };
|
|
};
|
|
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
};
|
|
}
|