fork/home-manager
git clone https://git.julia.blue/fork/home-manager
b84767a1
master
1{ config , lib , pkgs , ...} : 2let 3inherit ( lib ) 4concatStringsSep types mkIf mkOption mkEnableOption mkPackageOption 5literalExpression ; 6 7cfg = config . programs . xplr ; 8 9initialConfig = '' 10version = ' ${ cfg . package . version } ' 11'' ; 12 13# We provide a default version line within the configuration file, which is 14# obtained from the package's attributes. Merge the initial configFile, a 15# mapped list of plugins and then the user defined configuration to obtain the 16# final configuration. 17pluginPath = if cfg . plugins != [ ] then 18( '' 19package.path= 20'' + ( concatStringsSep " ..\n" 21( map ( p :''" ${ p } /init.lua; ${ p } /?.lua;"'' ) cfg . plugins )) + '' 22.. 23package.path 24'' ) 25else 26"\n" ; 27 28configFile = initialConfig + pluginPath + cfg . extraConfig ; 29in { 30meta . maintainers = [ lib . maintainers . NotAShelf ]; 31 32options . programs . xplr = { 33enable = mkEnableOption "xplr, terminal UI based file explorer" ; 34 35package = mkPackageOption pkgs "xplr" { }; 36 37plugins = mkOption { 38type = with types ; nullOr ( listOf ( either package str )); 39default = [ ]; 40defaultText = literalExpression "[]" ; 41description = '' 42Plugins to be added to your configuration file. 43 44Must be a package, an absolute plugin path, or string to be recognized 45by xplr. Paths will be relative to 46{file}`$XDG_CONFIG_HOME/xplr/init.lua` unless they are absolute. 47'' ; 48}; 49 50extraConfig = mkOption { 51type = types . lines ; 52default = "" ; 53example = literalExpression '' 54require("wl-clipboard").setup { 55copy_command = "wl-copy -t text/uri-list", 56paste_command = "wl-paste", 57keep_selection = true, 58} 59'' ; 60description = '' 61Extra xplr configuration. 62'' ; 63}; 64}; 65 66config = mkIf cfg . enable { 67home . packages = [ cfg . package ]; 68 69xdg . configFile . "xplr/init.lua" . source = 70pkgs . writeText "init.lua" configFile ; 71}; 72}