on master help sign in
Add new loader for GitHub
c9283daMatthew Bauer
lib/command/src/Obelisk/Command/Thunk.hs+28−2
@@ -415,8 +415,9 @@ setThunk target gs branch = do
415-- This tool will only ever produce the newest one when it writes a thunk.
415-- This tool will only ever produce the newest one when it writes a thunk.
416gitHubStandaloneLoaders :: NonEmpty Text
416gitHubStandaloneLoaders :: NonEmpty Text
417gitHubStandaloneLoaders =
417gitHubStandaloneLoaders =
418− gitHubStandaloneLoaderV2 :|
418+ gitHubStandaloneLoaderV4 :|
419+ [ gitHubStandaloneLoaderV2
419− [ gitHubStandaloneLoaderV3
420+ , gitHubStandaloneLoaderV3
420 , gitHubStandaloneLoaderV1
421 , gitHubStandaloneLoaderV1
421 ]
422 ]
422
423
@@ -456,6 +457,31 @@ gitHubStandaloneLoaderV3 = T.unlines
456 , "in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))"
457 , "in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))"
457 ]
458 ]
458
459
460+gitHubStandaloneLoaderV4 :: Text
461+gitHubStandaloneLoaderV4 = T.unlines
462+ [ "# DO NOT HAND-EDIT THIS FILE"
463+ , "let"
464+ , " fetch = { private ? false, ... }@args:"
465+ , " if private && builtins.hasAttr \"fetchGit\" builtins"
466+ , " then fetchFromGitHubPrivate args"
467+ , " else fetchFromGitHub (builtins.removeAttrs args [\"branch\"]);"
468+ , " fetchFromGitHub = if builtins.hasAttr \"fetchTarball\" builtins then"
469+ , " ({ owner, repo, rev, sha256, ... }: builtins.fetchTarball {"
470+ , " url = \"https://github.com/${owner}/${repo}/archive/${rev}.tar.gz\";"
471+ , " inherit sha256; })"
472+ , " else (import <nixpkgs> {}).fetchFromGitHub;"
473+ , " fetchFromGitHubPrivate ="
474+ , " { owner, repo, rev, branch ? null, name ? null, sha256 ? null"
475+ , " , private ? false, fetchSubmodules ? false"
476+ , " , githubBase ? \"github.com\", ...}: assert !fetchSubmodules;"
477+ , " builtins.fetchGit ({"
478+ , " url = \"ssh://git@${githubBase}/${owner}/${repo}.git\";"
479+ , " inherit rev;"
480+ , " } // (if branch == null then {} else { ref = branch; })"
481+ , " // (if name == null then {} else { inherit name; }));"
482+ , "in import (fetch (builtins.fromJSON (builtins.readFile ./github.json)))"
483+ ]
484+
459plainGitStandaloneLoaders :: NonEmpty Text
485plainGitStandaloneLoaders :: NonEmpty Text
460plainGitStandaloneLoaders =
486plainGitStandaloneLoaders =
461 plainGitStandaloneLoaderV1 :|
487 plainGitStandaloneLoaderV1 :|