@@ -15,42 +15,37 @@ let defaultInputs = import ./defaultInputs.nix; in
1515 ( import ./dep/gitignore.nix { inherit lib ; } ) . gitignoreSource ,
1616} :
1717
18- let myLib = import ./lib.nix { inherit haskell-nix pkgs ; } ; in
18+ let
19+
20+ myLib = import ./lib.nix { inherit haskell-nix pkgs ; } ; in
21+
22+ inherit ( import ./private.nix )
23+ contentsMatch
24+ isThunkWithThunkNix
25+ ;
26+
27+ in rec {
1928
20- rec {
2129 command = ( myLib . perGhc { } ) . command ;
2230
2331 # Retrieve source that is controlled by the hack-* scripts; it may be either a
2432 # stub or a checked-out git repo
2533 thunkSource = p :
2634 let
2735 contents = builtins . readDir p ;
28-
29- contentsMatch = { required , optional } :
30- ( let all = required // optional ; in all // contents == all )
31- && builtins . intersectAttrs required contents == required ;
32-
33- # Newer obelisk thunks include the feature of hackGet with a thunk.nix file in the thunk.
34- isObeliskThunkWithThunkNix =
35- let
36- packed = jsonFileName : {
37- required = { ${ jsonFileName } = "regular" ; "default.nix" = "regular" ; "thunk.nix" = "regular" ; } ;
38- optional = { ".attr-cache" = "directory" ; } ;
39- } ;
40- in builtins . any ( n : contentsMatch ( packed n ) ) [ "git.json" "github.json" ] ;
41-
36+ in if isThunkWithThunkNix contents then import ( p + "/thunk.nix" )
37+ else let # legacy cases
4238 filterArgs = x : removeAttrs x [ "branch" ] ;
4339 hasValidThunk = name : if builtins . pathExists ( p + ( "/" + name ) )
4440 then
45- contentsMatch {
41+ contentsMatch contents {
4642 required = { ${ name } = "regular" ; } ;
4743 optional = { "default.nix" = "regular" ; ".attr-cache" = "directory" ; } ;
4844 }
4945 || throw "Thunk at ${ toString p } has files in addition to ${ name } and optionally default.nix and .attr-cache. Remove either ${ name } or those other files to continue (check for leftover .git too)."
5046 else false ;
5147 in
52- if isObeliskThunkWithThunkNix then import ( p + "/thunk.nix" )
53- else if hasValidThunk "git.json" then (
48+ if hasValidThunk "git.json" then (
5449 let gitArgs = filterArgs ( builtins . fromJSON ( builtins . readFile ( p + "/git.json" ) ) ) ;
5550 in if builtins . elem "@" ( lib . stringToCharacters gitArgs . url )
5651 then pkgs . fetchgitPrivate gitArgs
0 commit comments