Skip to content

Commit

Permalink
Allow plain file imports
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jul 17, 2023
1 parent b9c9d83 commit f16fca5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/reference/yaml-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ inputs:
imports:
- ./frontend
- ./backend
. ./mymodule.nix
- myproject
- myproject/relative/path
```
2 changes: 2 additions & 0 deletions examples/imports/.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
env | grep "FILE=1"
env | grep "FOLDER=1"
1 change: 1 addition & 0 deletions examples/imports/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ }
3 changes: 3 additions & 0 deletions examples/imports/devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
imports:
- ./file.nix
- ./folder/
3 changes: 3 additions & 0 deletions examples/imports/file.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
env.FILE = "1";
}
3 changes: 3 additions & 0 deletions examples/imports/folder/devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
env.FOLDER = "1";
}
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ nav:
- Common Patterns: common-patterns.md
- Writing devenv.yaml:
- Inputs: inputs.md
- Composing Using Imports: composing-using-imports.md
- Imports: composing-using-imports.md
- Overview:
- Automatic Shell Activation: automatic-shell-activation.md
- Garbage Collection: garbage-collection.md
Expand Down
4 changes: 3 additions & 1 deletion src/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
lib = pkgs.lib;
importModule = path:
if lib.hasPrefix "./" path
then ./. + (builtins.substring 1 255 path) + "/devenv.nix"
then if lib.hasSuffix ".nix" path
then ./. + (builtins.substring 1 255 path)
else ./. + (builtins.substring 1 255 path) + "/devenv.nix"
else if lib.hasPrefix "../" path
then throw "devenv: ../ is not supported for imports"
else let
Expand Down

0 comments on commit f16fca5

Please sign in to comment.