-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate devenv.yaml schema and move overlays to inputs
- Loading branch information
1 parent
4430eb1
commit b0f22d7
Showing
5 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
allowUnfree: true | ||
inputs: | ||
nixpkgs: | ||
url: github:NixOS/nixpkgs/nixpkgs-unstable | ||
rust-overlay: | ||
url: github:oxalica/rust-overlay | ||
allowUnfree: true | ||
overlays: | ||
rust-overlay: | ||
- default | ||
overlays: | ||
- default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ pkgs }: | ||
|
||
pkgs.writers.writePython3Bin "devenv-yaml" { libraries = with pkgs.python3Packages; [ strictyaml path ]; } '' | ||
from strictyaml import Map, MapPattern, Str, Seq | ||
from strictyaml import load, Bool, Any, Optional, YAMLError | ||
import json | ||
import sys | ||
import os | ||
from path import Path | ||
inputsSchema = MapPattern(Str(), Map({ | ||
"url": Str(), | ||
Optional("flake", default=None): Bool(), | ||
Optional("inputs", default=None): Any(), | ||
Optional("overlays", default=None): Seq(Str()) | ||
})) | ||
schema = Map({ | ||
Optional("inputs", default=None): inputsSchema, | ||
Optional("allowUnfree", default=False): Bool(), | ||
Optional("imports", default=None): Seq(Str()) | ||
}) | ||
filename = Path("devenv.yaml").bytes().decode('utf8') | ||
try: | ||
devenv = load(filename, schema, label="devenv.yaml").data | ||
except YAMLError as error: | ||
print("Error in `devenv.yaml`", error) | ||
sys.exit(1) | ||
inputs = {} | ||
for input, attrs in devenv['inputs'].items(): | ||
inputs[input] = {k: attrs[k] for k in ('url', 'inputs', 'flake') | ||
if k in attrs} | ||
devenv_state = sys.argv[1] | ||
with open(os.path.join(devenv_state, "flake.json"), 'w') as f: | ||
f.write(json.dumps(inputs)) | ||
with open(os.path.join(devenv_state, "devenv.json"), 'w') as f: | ||
f.write(json.dumps(devenv)) | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters