@@ -14,8 +14,8 @@ use std::process;
14
14
use std:: time:: { SystemTime , UNIX_EPOCH } ;
15
15
use tracing:: { debug, error, info, warn} ;
16
16
17
- pub struct Nix < ' a > {
18
- pub options : Options < ' a > ,
17
+ pub struct Nix {
18
+ pub options : Options ,
19
19
pool : SqlitePool ,
20
20
// TODO: all these shouldn't be here
21
21
config : config:: Config ,
@@ -29,7 +29,7 @@ pub struct Nix<'a> {
29
29
}
30
30
31
31
#[ derive( Clone ) ]
32
- pub struct Options < ' a > {
32
+ pub struct Options {
33
33
/// Run `exec` to replace the shell with the command.
34
34
pub replace_shell : bool ,
35
35
/// Error out if the command returns a non-zero status code.
@@ -41,10 +41,10 @@ pub struct Options<'a> {
41
41
/// Log the stdout of the command.
42
42
pub logging_stdout : bool ,
43
43
/// Extra flags to pass to nix commands.
44
- pub nix_flags : & ' a [ & ' a str ] ,
44
+ pub nix_flags : & ' static [ & ' static str ] ,
45
45
}
46
46
47
- impl Default for Options < ' _ > {
47
+ impl Default for Options {
48
48
fn default ( ) -> Self {
49
49
Self {
50
50
replace_shell : false ,
@@ -68,7 +68,7 @@ impl Default for Options<'_> {
68
68
}
69
69
}
70
70
71
- impl < ' a > Nix < ' a > {
71
+ impl Nix {
72
72
pub async fn new < P : AsRef < Path > > (
73
73
config : config:: Config ,
74
74
global_options : cli:: GlobalOptions ,
@@ -186,15 +186,20 @@ impl<'a> Nix<'a> {
186
186
Ok ( ( ) )
187
187
}
188
188
189
- pub async fn build ( & self , attributes : & [ & str ] ) -> Result < Vec < PathBuf > > {
189
+ pub async fn build (
190
+ & self ,
191
+ attributes : & [ & str ] ,
192
+ options : Option < Options > ,
193
+ ) -> Result < Vec < PathBuf > > {
190
194
if attributes. is_empty ( ) {
191
195
return Ok ( Vec :: new ( ) ) ;
192
196
}
193
197
194
- let options = Options {
198
+ let options = options . unwrap_or ( Options {
195
199
cache_output : true ,
196
200
..self . options
197
- } ;
201
+ } ) ;
202
+
198
203
// TODO: use eval underneath
199
204
let mut args: Vec < String > = vec ! [
200
205
"build" . to_string( ) ,
@@ -272,7 +277,18 @@ impl<'a> Nix<'a> {
272
277
pub async fn search ( & self , name : & str ) -> Result < devenv_eval_cache:: Output > {
273
278
self . run_nix_with_substituters (
274
279
"nix" ,
275
- & [ "search" , "--inputs-from" , "." , "--json" , "nixpkgs" , name] ,
280
+ & [
281
+ "search" ,
282
+ "--inputs-from" ,
283
+ "." ,
284
+ "--quiet" ,
285
+ "--option" ,
286
+ "eval-cache" ,
287
+ "true" ,
288
+ "--json" ,
289
+ "nixpkgs" ,
290
+ name,
291
+ ] ,
276
292
& self . options ,
277
293
)
278
294
. await
@@ -298,7 +314,7 @@ impl<'a> Nix<'a> {
298
314
& self ,
299
315
command : & str ,
300
316
args : & [ & str ] ,
301
- options : & Options < ' a > ,
317
+ options : & Options ,
302
318
) -> Result < devenv_eval_cache:: Output > {
303
319
let cmd = self . prepare_command ( command, args, options) ?;
304
320
self . run_nix_command ( cmd, options) . await
@@ -308,7 +324,7 @@ impl<'a> Nix<'a> {
308
324
& self ,
309
325
command : & str ,
310
326
args : & [ & str ] ,
311
- options : & Options < ' a > ,
327
+ options : & Options ,
312
328
) -> Result < devenv_eval_cache:: Output > {
313
329
let cmd = self
314
330
. prepare_command_with_substituters ( command, args, options)
@@ -319,7 +335,7 @@ impl<'a> Nix<'a> {
319
335
async fn run_nix_command (
320
336
& self ,
321
337
mut cmd : std:: process:: Command ,
322
- options : & Options < ' a > ,
338
+ options : & Options ,
323
339
) -> Result < devenv_eval_cache:: Output > {
324
340
use devenv_eval_cache:: internal_log:: Verbosity ;
325
341
use devenv_eval_cache:: { supports_eval_caching, CachedCommand } ;
@@ -444,7 +460,7 @@ impl<'a> Nix<'a> {
444
460
& self ,
445
461
command : & str ,
446
462
args : & [ & str ] ,
447
- options : & Options < ' a > ,
463
+ options : & Options ,
448
464
) -> Result < std:: process:: Command > {
449
465
let mut final_args = Vec :: new ( ) ;
450
466
let known_keys_str;
@@ -532,7 +548,7 @@ impl<'a> Nix<'a> {
532
548
& self ,
533
549
command : & str ,
534
550
args : & [ & str ] ,
535
- options : & Options < ' a > ,
551
+ options : & Options ,
536
552
) -> Result < std:: process:: Command > {
537
553
let mut flags = options. nix_flags . to_vec ( ) ;
538
554
flags. push ( "--max-jobs" ) ;
0 commit comments