@@ -141,6 +141,41 @@ impl FromArgMatches for Installable {
141141
142142impl Args for Installable {
143143 fn augment_args ( cmd : clap:: Command ) -> clap:: Command {
144+ let nh_flake = env:: var ( "NH_FLAKE" ) . unwrap_or_default ( ) ;
145+ let nh_os_flake = env:: var ( "NH_OS_FLAKE" ) . unwrap_or_default ( ) ;
146+ let nh_home_flake = env:: var ( "NH_HOME_FLAKE" ) . unwrap_or_default ( ) ;
147+ let nh_darwin_flake = env:: var ( "NH_DARWIN_FLAKE" ) . unwrap_or_default ( ) ;
148+ let nh_file = env:: var ( "NH_FILE" ) . unwrap_or_default ( ) ;
149+ let nh_attr = env:: var ( "NH_ATTR" ) . unwrap_or_default ( ) ;
150+
151+ let long_help = format ! (
152+ r"Which installable to use.
153+ Nix accepts various kinds of installables:
154+
155+ [FLAKEREF[#ATTRPATH]]
156+ Flake reference with an optional attribute path.
157+ [env: NH_FLAKE={nh_flake}]
158+ [env: NH_OS_FLAKE={nh_os_flake}]
159+ [env: NH_HOME_FLAKE={nh_home_flake}]
160+ [env: NH_DARWIN_FLAKE={nh_darwin_flake}]
161+
162+ {f_short}, {f_long} <FILE> [ATTRPATH]
163+ Path to file with an optional attribute path.
164+ [env: NH_FILE={nh_file}]
165+ [env: NH_ATTRP={nh_attr}]
166+
167+ {e_short}, {e_long} <EXPR> [ATTRPATH]
168+ Nix expression with an optional attribute path.
169+
170+ [PATH]
171+ Path or symlink to a /nix/store path
172+ " ,
173+ f_short = "-f" . yellow( ) ,
174+ f_long = "--file" . yellow( ) ,
175+ e_short = "-e" . yellow( ) ,
176+ e_long = "--expr" . yellow( ) ,
177+ ) ;
178+
144179 cmd
145180 . arg (
146181 Arg :: new ( "file" )
@@ -153,48 +188,16 @@ impl Args for Installable {
153188 Arg :: new ( "expr" )
154189 . short ( 'E' )
155190 . long ( "expr" )
156- . conflicts_with ( "file" )
191+ . action ( ArgAction :: Set )
157192 . hide ( true )
158- . action ( ArgAction :: Set ) ,
193+ . conflicts_with ( "file" ) ,
159194 )
160195 . arg (
161196 Arg :: new ( "installable" )
162197 . action ( ArgAction :: Set )
163198 . value_name ( "INSTALLABLE" )
164199 . help ( "Which installable to use" )
165- . long_help ( format ! (
166- r"Which installable to use.
167- Nix accepts various kinds of installables:
168-
169- [FLAKEREF[#ATTRPATH]]
170- Flake reference with an optional attribute path.
171- [env: NH_FLAKE={}]
172- [env: NH_OS_FLAKE={}]
173- [env: NH_HOME_FLAKE={}]
174- [env: NH_DARWIN_FLAKE={}]
175-
176- {}, {} <FILE> [ATTRPATH]
177- Path to file with an optional attribute path.
178- [env: NH_FILE={}]
179- [env: NH_ATTRP={}]
180-
181- {}, {} <EXPR> [ATTRPATH]
182- Nix expression with an optional attribute path.
183-
184- [PATH]
185- Path or symlink to a /nix/store path
186- " ,
187- env:: var( "NH_FLAKE" ) . unwrap_or_default( ) ,
188- env:: var( "NH_OS_FLAKE" ) . unwrap_or_default( ) ,
189- env:: var( "NH_HOME_FLAKE" ) . unwrap_or_default( ) ,
190- env:: var( "NH_DARWIN_FLAKE" ) . unwrap_or_default( ) ,
191- "-f" . yellow( ) ,
192- "--file" . yellow( ) ,
193- env:: var( "NH_FILE" ) . unwrap_or_default( ) ,
194- env:: var( "NH_ATTR" ) . unwrap_or_default( ) ,
195- "-e" . yellow( ) ,
196- "--expr" . yellow( ) ,
197- ) ) ,
200+ . long_help ( long_help) ,
198201 )
199202 }
200203
0 commit comments