on master help sign in
Add GitHub loader to use fetchGit when possible
commitbc7c86f12c2b2c7148d6ac97124393ecb8f8f8dc authorElliot Cameron <eacameron@gmail.com> dateTue 15 May 2018, 12:44 (8 years ago) parent14a9380
1 file changed+23−2
lib/command/src/Obelisk/Command/Thunk.hs+23−2
lib/command/src/Obelisk/Command/Thunk.hs+23−2
@@ -345,8 +345,9 @@ updateThunkToLatest target = do
345345-- This tool will only ever produce the newest one when it writes a thunk.
346346gitHubStandaloneLoaders :: NonEmpty Text
347347gitHubStandaloneLoaders =
348− gitHubStandaloneLoaderV2 :|
349− [ gitHubStandaloneLoaderV1
348+ gitHubStandaloneLoaderV3 :|
349+ [ gitHubStandaloneLoaderV2
350+ , gitHubStandaloneLoaderV1
350351 ]
351352
352353gitHubStandaloneLoaderV1 :: Text
@@ -365,6 +366,26 @@ gitHubStandaloneLoaderV2 = T.unlines
365366 , "))"
366367 ]
367368
369+gitHubStandaloneLoaderV3 :: Text
370+gitHubStandaloneLoaderV3 = T.unlines
371+ [ "# DO NOT HAND-EDIT THIS FILE"
372+ , "let"
373+ , " fetch = { private ? false, ... }@args: if private && builtins.hasAttr \"fetchGit\" builtins"
374+ , " then fetchFromGitHubPrivate args"
375+ , " else (import <nixpkgs> {}).fetchFromGitHub (builtins.removeAttrs args [\"branch\"]);"
376+ , " fetchFromGitHubPrivate ="
377+ , " { owner, repo, rev, branch ? null, name ? null, sha256 ? null, private ? false"
378+ , " , fetchSubmodules ? false, githubBase ? \"github.com\", ..."
379+ , " }: assert !fetchSubmodules;"
380+ , " builtins.fetchGit ({"
381+ , " url = \"ssh://git@${githubBase}/${owner}/${repo}.git\";"
382+ , " inherit rev;"
383+ , " }"
384+ , " // (if branch == null then {} else { ref = branch; })"
385+ , " // (if name == null then {} else { inherit name; }));"
386+ , "in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))"
387+ ]
388+
368389plainGitStandaloneLoaders :: NonEmpty Text
369390plainGitStandaloneLoaders =
370391 plainGitStandaloneLoaderV1 :|