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 4141 name : numtide
4242 authToken : ' ${{ secrets.CACHIX_AUTH_TOKEN }}'
4343 - 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
4553 - name : Run nix flake archive
4654 run : nix flake archive
4755 docs :
Original file line number Diff line number Diff line change 3333in
3434rec {
3535 # Folder that contains all the extra modules
36- extraModulesDir = toString ./extra ;
36+ extraModulesPath = toString ./extra ;
37+
38+ # Alias for backward compatibility.
39+ extraModulesDir = extraModulesPath ;
3740
3841 # Get the modules documentation from an empty evaluation
3942 modules-docs =
4043 ( eval {
4144 configuration = {
4245 # Load all of the extra modules so they appear in the docs
43- imports = importTree extraModulesDir ;
46+ imports = importTree extraModulesPath ;
4447 } ;
4548 } ) . config . modules-docs ;
4649
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ lang = "en_US.UTF-8"
3131From a nix flake you would import it like
3232
3333``` nix
34- imports = ["${devshell}/extra/locale.nix"];
34+ devshell.mkShell ({ extraModulesPath, ... }: {
35+ imports = ["${extraModulesPath}/locale.nix"];
36+ })
3537```
3638
3739## Building your own modules
Original file line number Diff line number Diff line change 2121 '' ;
2222
2323 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 ; } )
2525 ) ;
2626 default = { } ;
2727 } ;
Original file line number Diff line number Diff line change @@ -6,18 +6,13 @@ nixpkgs:
66 extraSpecialArgs ? { } ,
77} :
88let
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+ ) ;
2116in
2217{
2318 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 77 dir = toString ( builtins . dirOf file ) ;
88 data = builtins . fromTOML ( builtins . readFile file ) ;
99
10- extraModulesDir = toString ../extra ;
11- extraModules = builtins . readDir extraModulesDir ;
10+ extraModulesPath = toString ../extra ;
11+ extraModules = builtins . readDir extraModulesPath ;
1212
1313 importModule =
1414 str :
1515 let
1616 repoFile = "${ dir } /${ str } " ;
17- extraFile = "${ extraModulesDir } /${ builtins . replaceStrings [ "." ] [ "/" ] str } .nix" ;
17+ extraFile = "${ extraModulesPath } /${ builtins . replaceStrings [ "." ] [ "/" ] str } .nix" ;
1818 in
1919 # First try to import from the user's repository
2020 if lib . hasPrefix "./" str || lib . hasSuffix ".nix" str || lib . hasSuffix ".toml" str then
Original file line number Diff line number Diff line change 2525 perSystem =
2626 { pkgs , ... } :
2727 {
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+ ) ;
2947 } ;
3048 } ;
3149}
You can’t perform that action at this time.
0 commit comments