This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

mkWrapper: add some documentation

+54 -2
+54 -2
wrapperModules/flake-module.nix
··· 9 9 default = { }; 10 10 description = "Wrapper modules"; 11 11 }; 12 + /** 13 + A function to create a wrapper module. 14 + returns an attribute set with options and apply function. 15 + 16 + Example usage: 17 + helloWrapper = mkWrapper (wlib: { config, ... }: { 18 + options.greeting = lib.mkOption { 19 + type = lib.types.str; 20 + default = "hello"; 21 + }; 22 + config.package = config.pkgs.hello; 23 + config.flags = { 24 + "--greeting" = config.greeting; 25 + }; 26 + }; 27 + 28 + helloWrapper.apply { 29 + pkgs = pkgs; 30 + greeting = "hi"; 31 + }; 32 + 33 + # This will return a derivation that wraps the hello package with the --greeting flag set to "hi". 34 + */ 12 35 flake.config.wrapLib.mkWrapper = 13 36 declarationArgs: 14 37 let ··· 20 43 }; 21 44 }; 22 45 file = 46 + # we need to pass pkgs here, because writeText is in pkgs 23 47 pkgs: 24 48 lib.types.submodule ( 25 49 { name, config, ... }: ··· 49 73 { 50 74 options = { 51 75 pkgs = lib.mkOption { 52 - description = "The pkgs to use."; 76 + description = '' 77 + The nixpkgs pkgs instance to use. 78 + We want to have this, so wrapper modules can be system agnostic. 79 + ''; 53 80 }; 54 81 package = lib.mkOption { 55 82 type = lib.types.package; 56 - description = "The base package to use."; 83 + description = '' 84 + The base package to wrap. 85 + This means we inherit all other files from this package 86 + (like man page, /share, ...) 87 + ''; 57 88 }; 58 89 extraPackages = lib.mkOption { 59 90 type = lib.types.listOf lib.types.package; 60 91 default = [ ]; 92 + description = '' 93 + Additional packages to add to the wrapper's runtime dependencies. 94 + This is useful if the wrapped program needs additional libraries or tools to function correctly. 95 + These packages will be added to the wrapper's runtime dependencies, ensuring they are available when the wrapped program is executed. 96 + ''; 61 97 }; 62 98 flags = lib.mkOption { 63 99 type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 64 100 default = { }; 101 + description = '' 102 + Flags to pass to the wrapper. 103 + The key is the flag name, the value is the flag value. 104 + If the value is true, the flag will be passed without a value. 105 + If the value is false or null, the flag will not be passed. 106 + If the value is a list, the flag will be passed multiple times with each value. 107 + ''; 65 108 }; 66 109 env = lib.mkOption { 67 110 type = lib.types.attrsOf lib.types.str; 68 111 default = { }; 112 + description = '' 113 + Environment variables to set in the wrapper. 114 + ''; 69 115 }; 70 116 passthru = lib.mkOption { 71 117 type = lib.types.attrs; 72 118 default = { }; 119 + description = '' 120 + Additional attributes to add to the resulting derivation's passthru. 121 + This can be used to add additional metadata or functionality to the wrapped package. 122 + This will always contain options, config and settings, so these are reserved names and cannot be used here. 123 + ''; 73 124 }; 74 125 }; 75 126 } ··· 77 128 }; 78 129 in 79 130 { 131 + # expose options to generate documentation of available modules 80 132 options = (lib.evalModules (evalArgs { })).options; 81 133 apply = 82 134 settings: