Skip to content

Commit

Permalink
Add devShell option (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
srid authored Mar 30, 2023
1 parent dc7ba61 commit 6000244
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ A `flake-parts` module for finding your way to the project root directory
};
```

Now you have access to the program that returns the absolute path to the project root via `${lib.getExe config.flake-root.package}`.
Now you have access to the program that returns the absolute path to the project root via `${lib.getExe config.flake-root.package}`. There is also `config.flake-root.devShell` which exposes a `shellHook` providing the `$FLAKE_ROOT` environment variable.

## Examples

Expand Down
18 changes: 16 additions & 2 deletions flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,23 @@ in
description = lib.mdDoc "The name of the unique file that exists only at project root";
default = "flake.nix";
};
# Functions
devShell = mkOption {
type = types.package;
readOnly = true;
description = lib.mdDoc ''
Devshell providing a shellHook setting $FLAKE_ROOT
'';
default = pkgs.mkShell {
name = "flake-root-devshell";
shellHook = ''
FLAKE_ROOT="''$(${lib.getExe config.flake-root.package})"
export FLAKE_ROOT
'';
};
};
package = mkOption {
type = types.package;
readOnly = true;
description = lib.mdDoc ''
The Nix package providing the command to find the project root.
'';
Expand Down Expand Up @@ -57,7 +71,7 @@ in
description = lib.mdDoc ''
flake-root module options
'';
default = {};
default = { };
};
});
};
Expand Down

0 comments on commit 6000244

Please sign in to comment.