Skip to content

Commit

Permalink
Merge pull request #830 from dsalaza4/main
Browse files Browse the repository at this point in the history
feat(back): #829 multiple directories
  • Loading branch information
dsalaza4 authored Apr 12, 2022
2 parents d97f7eb + f1d7ff4 commit 63f1bb6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Real life projects that run entirely on [Makes][MAKES]:
- [makePythonPypiEnvironmentSources](#makepythonpypienvironmentsources)
- [makeSopsEncryptedFile](#makesopsencryptedfile)
- [Framework Configuration](#framework-configuration)
- [extendingMakesDir](#extendingmakesdir)
- [extendingMakesDirs](#extendingmakesdirs)
- [inputs](#inputs)
- [Database](#database)
- [dynamoDb](#dynamodb)
Expand Down Expand Up @@ -808,23 +808,23 @@ Example usage with [direnv][DIRENV]
on remote projects:

```bash
$ cat /path/to/some/folder/.envrc
$ cat /path/to/some/dir/.envrc
source "$(m github:fluidattacks/makes@main /dev/example)/template"
# Now every time you enter /path/to/some/folder
# Now every time you enter /path/to/some/dir
# the shell will automatically load the environment
$ cd /path/to/some/folder
$ cd /path/to/some/dir
direnv: loading /path/to/some/folder/.envrc
direnv: loading /path/to/some/dir/.envrc
direnv: export ~PATH
/path/to/some/folder $ hello
/path/to/some/dir $ hello
Hello, world!
# If you exit the folder, the development environment is unloaded
/path/to/some/folder $ cd ..
# If you exit the directory, the development environment is unloaded
/path/to/some/dir $ cd ..
direnv: unloading
Expand All @@ -839,24 +839,24 @@ Example usage with [direnv][DIRENV]
on a local project:

```bash
$ cat /path/to/some/folder/.envrc
$ cat /path/to/some/dir/.envrc
cd /path/to/my/project
source "$(m . /dev/example)/template"
# Now every time you enter /path/to/some/folder
# Now every time you enter /path/to/some/dir
# the shell will automatically load the environment
$ cd /path/to/some/folder
$ cd /path/to/some/dir
direnv: loading /path/to/some/folder/.envrc
direnv: loading /path/to/some/dir/.envrc
direnv: export ~PATH
/path/to/some/folder $ hello
/path/to/some/dir $ hello
Hello, world!
# If you exit the folder, the development environment is unloaded
/path/to/some/folder $ cd ..
# If you exit the directory, the development environment is unloaded
/path/to/some/dir $ cd ..
direnv: unloading
Expand Down Expand Up @@ -1441,7 +1441,7 @@ Types:
- python (`enum [ "3.7" "3.8" "3.9" ]`):
Python interpreter version that your package/module is designed for.
- src (`str`):
Path to the file or folder that contains the tests code.
Path to the file or directory that contains the tests code.
- searchPaths (`asIn makeSearchPaths`): Optional.
Arguments here will be passed as-is to `makeSearchPaths`.
Defaults to `makeSearchPaths`'s defaults.
Expand All @@ -1455,7 +1455,7 @@ Types:
The final test structure looks like this:
```bash
/tmp/some-random-unique-folder
/tmp/some-random-unique-dir
├── __project__ # The entire source code of your project
│  ├── ...
│  └── path/to/src
Expand All @@ -1467,7 +1467,7 @@ Types:
And we will run [pytest][PYTEST] like this:
`$ pytest /tmp/some-random-unique-folder/__project__/path/to/src`
`$ pytest /tmp/some-random-unique-dir/__project__/path/to/src`
Defaults to `{ }`.
Expand Down Expand Up @@ -2481,14 +2481,14 @@ m github:fluidattacks/[email protected] /utils/makeSopsEncryptedFile \
## Framework Configuration
### extendingMakesDir
### extendingMakesDirs
Path to the magic folder where Makes extensions will be loaded from.
Paths to magic directories where Makes extensions will be loaded from.
Types:
- extendingMakesDir (`str`): Optional.
Defaults to `"/makes"`.
- extendingMakesDirs (`listOf str`): Optional.
Defaults to `["/makes"]`.
### inputs
Expand Down Expand Up @@ -3472,7 +3472,7 @@ Types:
you can omit this parameter and execute Makes,
Makes will tell you the correct SHA256 on failure.
- stripRoot (`bool`): Optional.
Most archives have a symbolic top-level folder
Most archives have a symbolic top-level directory
that is discarded during unpack phase.
If this is not the case you can set this flag to `false`.
Defaults to `true`.
Expand Down Expand Up @@ -3750,7 +3750,7 @@ $ m . /example
:warning: This function is only available on Linux at the moment.
Cook the `node_modules` folder
Cook the `node_modules` directory
for the given [NPM][NPM] project.
Types:
Expand Down
2 changes: 1 addition & 1 deletion makes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
VAR_NAME = "test";
};
};
extendingMakesDir = "/makes";
extendingMakesDirs = ["/makes"];
formatBash = {
enable = true;
targets = ["/"];
Expand Down
18 changes: 12 additions & 6 deletions src/evaluator/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
type = lib.types.str;
default = "";
};
extendingMakesDir = lib.mkOption {
default = "/makes";
type = lib.types.str;
extendingMakesDirs = lib.mkOption {
default = ["/makes"];
type = lib.types.listOf lib.types.str;
};

config = lib.mkOption {
Expand Down Expand Up @@ -104,9 +104,15 @@
(builtins.readDir path)));
in
(
attrsOptional
(builtins.pathExists (projectSrc + config.extendingMakesDir))
(attrsFromPath (projectPath config.extendingMakesDir) [])
builtins.foldl'
lib.mergeAttrs
{}
(builtins.map
(dir:
attrsOptional
(builtins.pathExists (projectSrc + dir))
(attrsFromPath (projectPath dir) []))
config.extendingMakesDirs)
)
// {
__all__ =
Expand Down

0 comments on commit 63f1bb6

Please sign in to comment.