···99 default = { };
1010 description = "Wrapper modules";
1111 };
1212+ /**
1313+ A function to create a wrapper module.
1414+ returns an attribute set with options and apply function.
1515+1616+ Example usage:
1717+ helloWrapper = mkWrapper (wlib: { config, ... }: {
1818+ options.greeting = lib.mkOption {
1919+ type = lib.types.str;
2020+ default = "hello";
2121+ };
2222+ config.package = config.pkgs.hello;
2323+ config.flags = {
2424+ "--greeting" = config.greeting;
2525+ };
2626+ };
2727+2828+ helloWrapper.apply {
2929+ pkgs = pkgs;
3030+ greeting = "hi";
3131+ };
3232+3333+ # This will return a derivation that wraps the hello package with the --greeting flag set to "hi".
3434+ */
1235 flake.config.wrapLib.mkWrapper =
1336 declarationArgs:
1437 let
···2043 };
2144 };
2245 file =
4646+ # we need to pass pkgs here, because writeText is in pkgs
2347 pkgs:
2448 lib.types.submodule (
2549 { name, config, ... }:
···4973 {
5074 options = {
5175 pkgs = lib.mkOption {
5252- description = "The pkgs to use.";
7676+ description = ''
7777+ The nixpkgs pkgs instance to use.
7878+ We want to have this, so wrapper modules can be system agnostic.
7979+ '';
5380 };
5481 package = lib.mkOption {
5582 type = lib.types.package;
5656- description = "The base package to use.";
8383+ description = ''
8484+ The base package to wrap.
8585+ This means we inherit all other files from this package
8686+ (like man page, /share, ...)
8787+ '';
5788 };
5889 extraPackages = lib.mkOption {
5990 type = lib.types.listOf lib.types.package;
6091 default = [ ];
9292+ description = ''
9393+ Additional packages to add to the wrapper's runtime dependencies.
9494+ This is useful if the wrapped program needs additional libraries or tools to function correctly.
9595+ These packages will be added to the wrapper's runtime dependencies, ensuring they are available when the wrapped program is executed.
9696+ '';
6197 };
6298 flags = lib.mkOption {
6399 type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling
64100 default = { };
101101+ description = ''
102102+ Flags to pass to the wrapper.
103103+ The key is the flag name, the value is the flag value.
104104+ If the value is true, the flag will be passed without a value.
105105+ If the value is false or null, the flag will not be passed.
106106+ If the value is a list, the flag will be passed multiple times with each value.
107107+ '';
65108 };
66109 env = lib.mkOption {
67110 type = lib.types.attrsOf lib.types.str;
68111 default = { };
112112+ description = ''
113113+ Environment variables to set in the wrapper.
114114+ '';
69115 };
70116 passthru = lib.mkOption {
71117 type = lib.types.attrs;
72118 default = { };
119119+ description = ''
120120+ Additional attributes to add to the resulting derivation's passthru.
121121+ This can be used to add additional metadata or functionality to the wrapped package.
122122+ This will always contain options, config and settings, so these are reserved names and cannot be used here.
123123+ '';
73124 };
74125 };
75126 }
···77128 };
78129 in
79130 {
131131+ # expose options to generate documentation of available modules
80132 options = (lib.evalModules (evalArgs { })).options;
81133 apply =
82134 settings: