Skip to content

Commit f6351d5

Browse files
authored
Merge pull request #2163 from cachix/devenv-yaml-import
Implement configuration merging for devenv.yaml imports
2 parents aa99683 + b308fc4 commit f6351d5

File tree

93 files changed

+1580
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1580
-105
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ include_dir = "0.7.4"
4646
indexmap = "2.11.4"
4747
indoc = "2.0.6"
4848
lazy_static = "1.5.0"
49+
pathdiff = "0.2.3"
4950
miette = { version = "7.6.0", features = ["fancy"] }
5051
nix = { version = "0.30.1", features = ["signal", "process"] }
5152
once_cell = "1.21.3"

devenv-run-tests/src/main.rs

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -300,25 +300,6 @@ async fn run_tests_in_directory(args: &RunArgs) -> Result<Vec<TestResult>> {
300300
);
301301
eprintln!("{}", "-".repeat(50));
302302

303-
let mut config = devenv::config::Config::load_from(path)?;
304-
for input in args.override_input.chunks_exact(2) {
305-
config
306-
.override_input_url(&input[0], &input[1])
307-
.wrap_err(format!(
308-
"Failed to override input {} with {}",
309-
&input[0], &input[1]
310-
))?;
311-
}
312-
313-
// Override the input for the devenv module
314-
config
315-
.add_input(
316-
"devenv",
317-
&format!("path:{}?dir=src/modules", cwd.display()),
318-
&[],
319-
)
320-
.wrap_err("Failed to add devenv input")?;
321-
322303
// Determine whether to use a temporary directory
323304
let (devenv_root, devenv_dotfile, _tmpdir) = if test_config.use_tmp_dir {
324305
// Create temp directory in system temp dir, not the current directory
@@ -367,6 +348,36 @@ async fn run_tests_in_directory(args: &RunArgs) -> Result<Vec<TestResult>> {
367348
(devenv_root, devenv_dotfile, None)
368349
};
369350

351+
// Run .patch.sh if it exists (must run before loading config)
352+
let patch_script = PathBuf::from(".patch.sh");
353+
if patch_script.exists() {
354+
eprintln!(" Running .patch.sh");
355+
let _ = Command::new("bash")
356+
.arg(&patch_script)
357+
.status()
358+
.into_diagnostic()?;
359+
}
360+
361+
// Now load config from the current directory (which might be temp dir)
362+
let mut config = devenv::config::Config::load_from(&devenv_root)?;
363+
for input in args.override_input.chunks_exact(2) {
364+
config
365+
.override_input_url(&input[0], &input[1])
366+
.wrap_err(format!(
367+
"Failed to override input {} with {}",
368+
&input[0], &input[1]
369+
))?;
370+
}
371+
372+
// Override the input for the devenv module
373+
config
374+
.add_input(
375+
"devenv",
376+
&format!("path:{}?dir=src/modules", cwd.display()),
377+
&[],
378+
)
379+
.wrap_err("Failed to add devenv input")?;
380+
370381
let options = DevenvOptions {
371382
config,
372383
devenv_root: Some(devenv_root.clone()),
@@ -377,18 +388,6 @@ async fn run_tests_in_directory(args: &RunArgs) -> Result<Vec<TestResult>> {
377388

378389
eprintln!(" Running {dir_name}");
379390

380-
// A script to patch files in the working directory before the shell.
381-
let patch_script = ".patch.sh";
382-
383-
// Run .patch.sh if it exists
384-
if PathBuf::from(patch_script).exists() {
385-
eprintln!(" Running {patch_script}");
386-
let _ = Command::new("bash")
387-
.arg(patch_script)
388-
.status()
389-
.into_diagnostic()?;
390-
}
391-
392391
// A script to run inside the shell before the test.
393392
let setup_script = ".setup.sh";
394393

devenv.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@
6666
]
6767
},
6868
"locked": {
69-
"lastModified": 1756770412,
69+
"lastModified": 1759362264,
7070
"owner": "hercules-ci",
7171
"repo": "flake-parts",
72-
"rev": "4524271976b625a4a605beefd893f270620fd751",
72+
"rev": "758cf7296bee11f1706a574c77d072b8a7baa881",
7373
"type": "github"
7474
},
7575
"original": {
@@ -87,10 +87,10 @@
8787
]
8888
},
8989
"locked": {
90-
"lastModified": 1758108966,
90+
"lastModified": 1759523803,
9191
"owner": "cachix",
9292
"repo": "git-hooks.nix",
93-
"rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b",
93+
"rev": "cfc9f7bb163ad8542029d303e599c0f7eee09835",
9494
"type": "github"
9595
},
9696
"original": {
@@ -113,10 +113,10 @@
113113
]
114114
},
115115
"locked": {
116-
"lastModified": 1758108966,
116+
"lastModified": 1759523803,
117117
"owner": "cachix",
118118
"repo": "git-hooks.nix",
119-
"rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b",
119+
"rev": "cfc9f7bb163ad8542029d303e599c0f7eee09835",
120120
"type": "github"
121121
},
122122
"original": {
@@ -170,10 +170,10 @@
170170
},
171171
"nixpkgs": {
172172
"locked": {
173-
"lastModified": 1758690382,
173+
"lastModified": 1759381078,
174174
"owner": "NixOS",
175175
"repo": "nixpkgs",
176-
"rev": "e643668fd71b949c53f8626614b21ff71a07379d",
176+
"rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee",
177177
"type": "github"
178178
},
179179
"original": {
@@ -248,10 +248,10 @@
248248
]
249249
},
250250
"locked": {
251-
"lastModified": 1758854041,
251+
"lastModified": 1759631821,
252252
"owner": "oxalica",
253253
"repo": "rust-overlay",
254-
"rev": "02227ca8c229c968dbb5de95584cfb12b4313104",
254+
"rev": "1d7cbdaad90f8a5255a89a6eddd8af24dc89cafe",
255255
"type": "github"
256256
},
257257
"original": {

devenv/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ whoami.workspace = true
4949
xdg.workspace = true
5050
similar.workspace = true
5151
once_cell.workspace = true
52+
pathdiff.workspace = true
5253
shell-escape.workspace = true
5354
rmcp.workspace = true
5455
rmcp-macros.workspace = true

devenv/direnvrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ use_devenv() {
119119
default_watches=(".envrc" "$HOME/.direnvrc" "$HOME/.config/direnv/direnvrc")
120120

121121
if [[ -d "$devenv_dir" ]]; then
122-
default_watches+=("$devenv_dir/devenv.nix" "$devenv_dir/devenv.lock" "$devenv_dir/devenv.yaml" "$devenv_dir/devenv.local.nix")
122+
default_watches+=("$devenv_dir/devenv.nix" "$devenv_dir/devenv.lock" "$devenv_dir/devenv.yaml" "$devenv_dir/devenv.local.nix" "$devenv_dir/devenv.local.yaml")
123123

124124
if [[ -f "$devenv_dir/devenv.yaml" ]]; then
125125
if ! "${devenv_cmd[@]}" assemble; then
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
nixpkgs:
2+
cudaCapabilities: ["7.5", "7.5", "8.0"]
3+
permittedInsecurePackages: ["pkg1", "pkg2", "pkg1"]
4+
imports:
5+
- ./sub1
6+
- ./sub2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nixpkgs:
2+
cudaCapabilities: ["8.0", "8.6", "8.0"] # 8.0 is duplicate
3+
permittedInsecurePackages: ["pkg2", "pkg3"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nixpkgs:
2+
cudaCapabilities: ["7.5", "9.0"] # 7.5 already in base
3+
permittedInsecurePackages: ["pkg1", "pkg4", "pkg4"] # pkg1 already in base, pkg4 duplicate
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
allowUnfree: false
2+
allowBroken: false
3+
impure: false
4+
imports:
5+
- ./first
6+
- ./second
7+
- ./third

0 commit comments

Comments
 (0)