File tree Expand file tree Collapse file tree 8 files changed +64
-21
lines changed Expand file tree Collapse file tree 8 files changed +64
-21
lines changed Original file line number Diff line number Diff line change 41
41
name : numtide
42
42
authToken : ' ${{ secrets.CACHIX_AUTH_TOKEN }}'
43
43
- run : nix flake check
44
- - run : nix develop -c echo OK
44
+ - name : Run devshell entry sanity checks
45
+ run : |
46
+ nix develop -c echo OK
47
+ for tmpl in ./templates/*; do
48
+ if ! [ -d "$tmpl" ]; then
49
+ continue
50
+ fi
51
+ nix develop --override-input devshell . "$tmpl" -c echo OK
52
+ done
45
53
- name : Run nix flake archive
46
54
run : nix flake archive
47
55
docs :
Original file line number Diff line number Diff line change 33
33
in
34
34
rec {
35
35
# Folder that contains all the extra modules
36
- extraModulesDir = toString ./extra ;
36
+ extraModulesPath = toString ./extra ;
37
+
38
+ # Alias for backward compatibility.
39
+ extraModulesDir = extraModulesPath ;
37
40
38
41
# Get the modules documentation from an empty evaluation
39
42
modules-docs =
40
43
( eval {
41
44
configuration = {
42
45
# Load all of the extra modules so they appear in the docs
43
- imports = importTree extraModulesDir ;
46
+ imports = importTree extraModulesPath ;
44
47
} ;
45
48
} ) . config . modules-docs ;
46
49
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ lang = "en_US.UTF-8"
31
31
From a nix flake you would import it like
32
32
33
33
``` nix
34
- imports = ["${devshell}/extra/locale.nix"];
34
+ devshell.mkShell ({ extraModulesPath, ... }: {
35
+ imports = ["${extraModulesPath}/locale.nix"];
36
+ })
35
37
```
36
38
37
39
## Building your own modules
Original file line number Diff line number Diff line change 21
21
'' ;
22
22
23
23
type = types . lazyAttrsOf (
24
- types . submoduleWith { modules = import ./modules/modules .nix { inherit pkgs lib ; } ; }
24
+ types . submoduleWith ( import ./modules/eval-args .nix { inherit pkgs lib ; } )
25
25
) ;
26
26
default = { } ;
27
27
} ;
Original file line number Diff line number Diff line change @@ -6,18 +6,13 @@ nixpkgs:
6
6
extraSpecialArgs ? { } ,
7
7
} :
8
8
let
9
- devenvModules = import ./modules.nix {
10
- pkgs = nixpkgs ;
11
- inherit lib ;
12
- } ;
13
-
14
- module = lib . evalModules {
15
- modules = [ configuration ] ++ devenvModules ;
16
- specialArgs = {
17
- modulesPath = builtins . toString ./. ;
18
- extraModulesPath = builtins . toString ../extra ;
19
- } // extraSpecialArgs ;
20
- } ;
9
+ module = lib . evalModules (
10
+ import ./eval-args.nix {
11
+ inherit lib extraSpecialArgs ;
12
+ pkgs = nixpkgs ;
13
+ modules = [ configuration ] ;
14
+ }
15
+ ) ;
21
16
in
22
17
{
23
18
inherit ( module ) config options ;
Original file line number Diff line number Diff line change
1
+ # Arguments for `lib.evalModules` or `types.submoduleWith`.
2
+ {
3
+ pkgs ,
4
+ lib ,
5
+ modules ? [ ] ,
6
+ extraSpecialArgs ? { } ,
7
+ } :
8
+ let
9
+ devenvModules = import ./modules.nix { inherit lib pkgs ; } ;
10
+ in
11
+ {
12
+ modules = ( lib . toList modules ) ++ devenvModules ;
13
+ specialArgs = {
14
+ modulesPath = builtins . toString ./. ;
15
+ extraModulesPath = builtins . toString ../extra ;
16
+ } // extraSpecialArgs ;
17
+ }
Original file line number Diff line number Diff line change 7
7
dir = toString ( builtins . dirOf file ) ;
8
8
data = builtins . fromTOML ( builtins . readFile file ) ;
9
9
10
- extraModulesDir = toString ../extra ;
11
- extraModules = builtins . readDir extraModulesDir ;
10
+ extraModulesPath = toString ../extra ;
11
+ extraModules = builtins . readDir extraModulesPath ;
12
12
13
13
importModule =
14
14
str :
15
15
let
16
16
repoFile = "${ dir } /${ str } " ;
17
- extraFile = "${ extraModulesDir } /${ builtins . replaceStrings [ "." ] [ "/" ] str } .nix" ;
17
+ extraFile = "${ extraModulesPath } /${ builtins . replaceStrings [ "." ] [ "/" ] str } .nix" ;
18
18
in
19
19
# First try to import from the user's repository
20
20
if lib . hasPrefix "./" str || lib . hasSuffix ".nix" str || lib . hasSuffix ".toml" str then
Original file line number Diff line number Diff line change 25
25
perSystem =
26
26
{ pkgs , ... } :
27
27
{
28
- devshells . default = { } ;
28
+ devshells . default = (
29
+ { extraModulesPath , ... } @args :
30
+ {
31
+ # `extraModulesPath` provides access to additional modules that are
32
+ # not included in the standard devshell modules list.
33
+ #
34
+ # Please see https://numtide.github.io/devshell/extending.html for
35
+ # documentation on consuming extra modules, and see
36
+ # https://github.com/numtide/devshell/tree/main/extra for the
37
+ # extra modules that are currently available.
38
+ imports = [ "${ extraModulesPath } /git/hooks.nix" ] ;
39
+
40
+ git . hooks . enable = false ;
41
+ git . hooks . pre-commit . text = ''
42
+ echo 1>&2 'time to implement a pre-commit hook!'
43
+ exit 1
44
+ '' ;
45
+ }
46
+ ) ;
29
47
} ;
30
48
} ;
31
49
}
You can’t perform that action at this time.
0 commit comments