File tree Expand file tree Collapse file tree 9 files changed +358
-249
lines changed Expand file tree Collapse file tree 9 files changed +358
-249
lines changed Original file line number Diff line number Diff line change 99 lib . evalModules {
1010 modules = [
1111 ./modules/many-wrappers.nix
12- ] ++ modules ;
12+ ]
13+ ++ modules ;
1314 specialArgs = {
14- inherit pkgs ;
15- } // specialArgs ;
15+ pkgs = extendPkgs pkgs ;
16+ }
17+ // specialArgs ;
1618 } ;
19+
20+ getPkgs =
21+ pkgs :
22+ pkgs . lib . packagesFromDirectoryRecursive {
23+ inherit ( pkgs ) callPackage newScope ;
24+ directory = ./pkgs ;
25+ } ;
26+ extendPkgs = pkgs : pkgs . extend ( _ : prev : getPkgs prev ) ;
1727in
1828{
1929 lib = {
2737 module
2838 ] ;
2939 specialArgs = {
30- inherit pkgs ;
40+ pkgs = extendPkgs pkgs ;
3141 } ;
3242 } ) . config . wrapped ;
3343 } ;
44+ inherit getPkgs ;
3445}
Original file line number Diff line number Diff line change 2828 "--config"
2929 ./config.nu
3030 ];
31- env .STARSHIP_CONFIG.value = ../starship.toml;
31+ envVars .STARSHIP_CONFIG.value = ../starship.toml;
3232 pathAdd = [
3333 pkgs.starship
3434 pkgs.carapace
119119 # Wrap a singular package
120120 myGit = wrapper-manager.lib.wrapWith pkgs {
121121 basePackage = pkgs.git;
122- env .GIT_CONFIG.value = ./gitconfig;
122+ envVars .GIT_CONFIG.value = ./gitconfig;
123123 };
124124 #=> «derivation /nix/store/...»
125125in
@@ -172,6 +172,12 @@ https://github.com/viperML/wrapper-manager/issues
172172
173173## Changelog
174174
175+ - 2025-08-13
176+ - Separate wrapper build helper from module system
177+ - Add ` helpers ` output, currently has ` mkWrapper `
178+ - ` wrapFlags ` now read-only for access to final flags
179+ - ` env ` has been renamed to ` envVars `
180+
175181- 2025-06-19
176182 - Full rewrite
177183 - ` flags ` has been removed in favor of ` prependFlags `
Original file line number Diff line number Diff line change 55 ...
66} :
77let
8- inherit ( lib ) mkOption types flatten ;
8+ inherit ( lib )
9+ mkRenamedOptionModule
10+ mkOption
11+ types
12+ flatten
13+ ;
914 inherit ( builtins ) attrValues ;
1015 flagsType = with types ; listOf ( coercedTo anything ( x : "${ x } " ) str ) ;
1116in
1217{
18+ imports = [ ( mkRenamedOptionModule [ "env" ] [ "envVars" ] ) ] ;
19+
1320 options = {
1421 wrapFlags = mkOption {
15- type = flagsType ;
16- default = [ ] ;
17- description = "Structured flags passed to makeWrapper." ;
18- example = [
19- "--argv0"
20- "myprog"
21- ] ;
22+ type = with types ; separatedString " " ;
23+ readOnly = true ;
24+ description = "(Read-only) Final flags to wrap with" ;
2225 } ;
2326 appendFlags = mkOption {
2427 type = flagsType ;
5154 ["--config-file" ./config.toml]
5255 '' ;
5356 } ;
54- env = mkOption {
57+ envVars = mkOption {
5558 type = with types ; attrsOf ( submodule ./env-type.nix ) ;
5659 default = { } ;
5760 description = "Structured configuration for environment variables." ;
9093
9194 config = {
9295 wrapFlags =
93- ( flatten (
94- map ( f : [
95- "--add-flag"
96- f
97- ] ) config . prependFlags
98- ) )
99- # Force the eval of config.flags to trigger throw
100- ++ ( flatten (
101- map ( f : [
102- "--add-flag"
103- f
104- ] ) config . flags
105- ) )
106- ++ ( flatten (
107- map ( f : [
108- "--append-flag"
109- f
110- ] ) config . appendFlags
96+ ( lib . escapeShellArgs (
97+ ( flatten (
98+ map ( f : [
99+ "--add-flag"
100+ f
101+ ] ) config . prependFlags
102+ ) )
103+ # Force the eval of config.flags to trigger throw
104+ ++ ( flatten (
105+ map ( f : [
106+ "--add-flag"
107+ f
108+ ] ) config . flags
109+ ) )
110+ ++ ( flatten (
111+ map ( f : [
112+ "--append-flag"
113+ f
114+ ] ) config . appendFlags
115+ ) )
116+ ++ ( lib . optionals ( config . pathAdd != [ ] ) [
117+ "--prefix"
118+ "PATH"
119+ ":"
120+ ( lib . makeBinPath config . pathAdd )
121+ ] )
122+ ++ ( flatten ( map ( e : e . asFlags ) ( attrValues config . envVars ) ) )
111123 ) )
112- ++ ( lib . optionals ( config . pathAdd != [ ] ) [
113- "--prefix"
114- "PATH"
115- ":"
116- ( lib . makeBinPath config . pathAdd )
117- ] )
118- ++ ( flatten ( map ( e : e . asFlags ) ( attrValues config . env ) ) ) ;
124+ + config . extraWrapperFlags ;
119125 } ;
120126}
Original file line number Diff line number Diff line change 7070 ( lib . warn ''
7171 ${
7272 lib . showOption [
73- "env "
73+ "envVars "
7474 config . name
7575 "value"
7676 ]
7777 } is null (indicating unsetting the variable), but ${
7878 lib . showOption [
79- "env "
79+ "envVars "
8080 config . name
8181 "force"
8282 ]
Original file line number Diff line number Diff line change 1+ {
2+ pkgs ,
3+ lib ,
4+ config ,
5+ ...
6+ } :
7+ let
8+ inherit ( lib ) mkOption types ;
9+
10+ in
11+ {
12+ imports = [
13+ ./common-wrapper-args.nix
14+ ] ;
15+
16+ options = {
17+ basePackage = mkOption {
18+ type = with types ; package ;
19+ description = "Program to be wrapped" ;
20+ } ;
21+
22+ extraPackages = mkOption {
23+ type = with types ; listOf package ;
24+ default = [ ] ;
25+ description = "Optional extra packages to also wrap" ;
26+ } ;
27+
28+ programs = mkOption {
29+ default = { } ;
30+ description = "Wrap specific binaries with specific options. You may use it to skip wrapping some program." ;
31+ example = lib . literalExpression ''
32+ {
33+ supervim = {
34+ target = "neovim";
35+ };
36+
37+ git = {
38+ envVars.GIT_CONFIG.value = ./gitconfig;
39+ };
40+
41+ # Don't wrap scalar
42+ scalar = {};
43+ }
44+ '' ;
45+ type = types . attrsOf (
46+ types . submoduleWith {
47+ modules = [
48+ ./common-wrapper-args.nix
49+ (
50+ { name , ... } :
51+ {
52+ options = {
53+ name = mkOption {
54+ type = types . str ;
55+ default = name ;
56+ description = "Name of the program" ;
57+ } ;
58+
59+ target = mkOption {
60+ type = with types ; nullOr str ;
61+ default = null ;
62+ description = "Target of the program" ;
63+ } ;
64+ } ;
65+
66+ config = {
67+ wrapperType = lib . mkDefault config . wrapperType ;
68+ } ;
69+ }
70+ )
71+ ] ;
72+ }
73+ ) ;
74+ } ;
75+ } ;
76+ }
You can’t perform that action at this time.
0 commit comments