fork/home-manager
git clone https://git.julia.blue/fork/home-manager
0945875a
master
1{ config , lib , pkgs , ...} : 2with lib ; 3let 4cfg = config . programs . boxxy ; 5 6configPath = " ${ config . xdg . configHome } /boxxy/boxxy.yaml" ; 7settingsFormat = pkgs . formats . yaml { }; 8 9boxxyRulesOpts = types . submodule { 10freeformType = settingsFormat . type ; 11 12options = { 13name = mkOption { 14type = types . str ; 15description = '' 16Unique identifier of the boxxy rule. This can be any single-line string. 17'' ; 18}; 19 20target = mkOption { 21type = types . str ; 22default = "" ; 23example = "~/.ssh" ; 24description = '' 25What directory/file to redirect. 26'' ; 27}; 28 29rewrite = mkOption { 30type = types . str ; 31default = "" ; 32example = literalExpression ''"''${config.xdg.configHome}/ssh"'' ; 33description = '' 34Where that file/directory should be rewritten to. 35'' ; 36}; 37 38mode = mkOption { 39type = types . enum [ "file" "directory" ]; 40default = "directory" ; 41description = '' 42Does the current path redirect a file or a directory? 43'' ; 44}; 45 46only = mkOption { 47type = types . listOf types . str ; 48default = [ ]; 49example = literalExpression '' 50[ 51"bash" 52"/usr/bin/sh" 53] 54'' ; 55description = '' 56Apply redirection ONLY to specified executable names. 57'' ; 58}; 59 60context = mkOption { 61type = types . listOf types . str ; 62default = [ ]; 63example = [ "/home/example/Projects/my-project" ]; 64description = '' 65Apply redirection ONLY when in a certain directory. 66'' ; 67}; 68 69env = mkOption { 70type = types . attrsOf types . str ; 71default = { }; 72example = literalExpression '' 73{ 74MY_ENV_VAR = "my_env_var_value"; 75} 76'' ; 77description = '' 78Give certain environment variables for said match. 79'' ; 80}; 81}; 82}; 83in { 84options . programs . boxxy = { 85enable = mkEnableOption "boxxy: Boxes in badly behaving applications" ; 86 87package = mkPackageOption pkgs "boxxy" { }; 88 89rules = mkOption { 90type = types . listOf boxxyRulesOpts ; 91default = [ ]; 92description = "List of boxxy rules" ; 93}; 94}; 95 96config = mkIf cfg . enable { 97assertions = 98[ ( hm . assertions . assertPlatform "programs.boxxy" pkgs platforms . linux ) ]; 99 100home . file = mkIf ( cfg . rules != [ ]) { 101" ${ configPath } " . source = 102settingsFormat . generate "boxxy-config.yaml" { rules = cfg . rules ; }; 103}; 104 105home . packages = [ cfg . package ]; 106}; 107 108meta . maintainers = with lib . hm . maintainers ; [ nikp123 ]; 109} 110