tangled
alpha
login
or
join now
isabelroses.com
/
fetch-tangled
21
fork
atom
this repo has no description
21
fork
atom
overview
issues
pulls
1
pipelines
WIP
isabelroses.com
4 months ago
020a0dd7
85164383
+108
-94
1 changed file
expand all
collapse all
unified
split
fetcher.nix
+108
-94
fetcher.nix
···
10
10
{
11
11
lib,
12
12
repoRevToNameMaybe,
13
13
+
stdenvNoCC,
13
14
fetchgit,
14
15
fetchzip,
15
16
}:
16
17
17
18
lib.makeOverridable (
18
18
-
{
19
19
-
domain ? "tangled.sh",
20
20
-
owner,
21
21
-
repo,
22
22
-
rev ? null,
23
23
-
tag ? null,
24
24
-
name ? repoRevToNameMaybe repo (lib.revOrTag rev tag) "tangled",
19
19
+
lib.extendMkDerivation {
20
20
+
constructDrv = stdenvNoCC.mkDerivation;
25
21
26
26
-
# fetchgit stuff
27
27
-
fetchSubmodules ? false,
28
28
-
leaveDotGit ? false,
29
29
-
deepClone ? false,
30
30
-
forceFetchGit ? false,
31
31
-
fetchLFS ? false,
32
32
-
sparseCheckout ? [ ],
22
22
+
excludeDrvArgNames = [
23
23
+
# Additional stdenv.mkDerivation arguments from derived fetchers.
24
24
+
"derivationArgs"
33
25
34
34
-
meta ? { },
35
35
-
...
36
36
-
}@args:
26
26
+
"hash"
27
27
+
];
37
28
38
38
-
assert lib.assertMsg (lib.xor (tag != null) (
39
39
-
rev != null
40
40
-
)) "fetchFromTangled requires one of either `rev` or `tag` to be provided (not both).";
29
29
+
extendDrvArgs =
30
30
+
finalAttrs:
31
31
+
{
32
32
+
domain ? "tangled.sh",
33
33
+
owner,
34
34
+
repo,
35
35
+
rev ? null,
36
36
+
tag ? null,
37
37
+
name ? repoRevToNameMaybe repo (lib.revOrTag rev tag) "tangled",
41
38
42
42
-
let
39
39
+
# fetchgit stuff
40
40
+
fetchSubmodules ? false,
41
41
+
leaveDotGit ? false,
42
42
+
deepClone ? false,
43
43
+
forceFetchGit ? false,
44
44
+
fetchLFS ? false,
45
45
+
sparseCheckout ? [ ],
43
46
44
44
-
position = (
45
45
-
if args.meta.description or null != null then
46
46
-
builtins.unsafeGetAttrPos "description" args.meta
47
47
-
else if tag != null then
48
48
-
builtins.unsafeGetAttrPos "tag" args
49
49
-
else
50
50
-
builtins.unsafeGetAttrPos "rev" args
51
51
-
);
47
47
+
meta ? { },
48
48
+
...
49
49
+
}@args:
52
50
53
53
-
baseUrl = "https://${domain}/${owner}/${repo}";
51
51
+
assert lib.assertMsg (lib.xor (tag != null) (
52
52
+
rev != null
53
53
+
)) "fetchFromTangled requires one of either `rev` or `tag` to be provided (not both).";
54
54
55
55
-
newMeta =
56
56
-
meta
57
57
-
// {
58
58
-
homepage = meta.homepage or baseUrl;
59
59
-
}
60
60
-
// lib.optionalAttrs (position != null) {
61
61
-
# to indicate where derivation originates, similar to make-derivation.nix's mkDerivation
62
62
-
position = "${position.file}:${toString position.line}";
63
63
-
};
55
55
+
let
64
56
65
65
-
passthruAttrs = removeAttrs args [
66
66
-
"domain"
67
67
-
"owner"
68
68
-
"repo"
69
69
-
"tag"
70
70
-
"rev"
71
71
-
"fetchSubmodules"
72
72
-
"forceFetchGit"
73
73
-
];
57
57
+
position = (
58
58
+
if args.meta.description or null != null then
59
59
+
builtins.unsafeGetAttrPos "description" args.meta
60
60
+
else if tag != null then
61
61
+
builtins.unsafeGetAttrPos "tag" args
62
62
+
else
63
63
+
builtins.unsafeGetAttrPos "rev" args
64
64
+
);
74
65
75
75
-
useFetchGit =
76
76
-
fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || fetchLFS || (sparseCheckout != [ ]);
66
66
+
baseUrl = "https://${domain}/${owner}/${repo}";
77
67
78
78
-
# We prefer fetchzip in cases we don't need submodules as the hash
79
79
-
# is more stable in that case.
80
80
-
fetcher =
81
81
-
if useFetchGit then
82
82
-
fetchgit
83
83
-
# fetchzip may not be overridable when using external tools, for example nix-prefetch
84
84
-
else if fetchzip ? override then
85
85
-
fetchzip.override { withUnzip = false; }
86
86
-
else
87
87
-
fetchzip;
68
68
+
newMeta =
69
69
+
meta
70
70
+
// {
71
71
+
homepage = meta.homepage or baseUrl;
72
72
+
}
73
73
+
// lib.optionalAttrs (position != null) {
74
74
+
# to indicate where derivation originates, similar to make-derivation.nix's mkDerivation
75
75
+
position = "${position.file}:${toString position.line}";
76
76
+
};
88
77
89
89
-
revWithTag = if tag != null then "refs%2Ftags%2F${tag}" else rev;
78
78
+
passthruAttrs = removeAttrs args [
79
79
+
"domain"
80
80
+
"owner"
81
81
+
"repo"
82
82
+
"tag"
83
83
+
"rev"
84
84
+
"fetchSubmodules"
85
85
+
"forceFetchGit"
86
86
+
];
87
87
+
88
88
+
useFetchGit =
89
89
+
fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || fetchLFS || (sparseCheckout != [ ]);
90
90
+
91
91
+
# We prefer fetchzip in cases we don't need submodules as the hash
92
92
+
# is more stable in that case.
93
93
+
fetcher =
94
94
+
if useFetchGit then
95
95
+
fetchgit
96
96
+
# fetchzip may not be overridable when using external tools, for example nix-prefetch
97
97
+
else if fetchzip ? override then
98
98
+
fetchzip.override { withUnzip = false; }
99
99
+
else
100
100
+
fetchzip;
101
101
+
102
102
+
revWithTag = if tag != null then "refs%2Ftags%2F${tag}" else rev;
103
103
+
104
104
+
fetcherArgs =
105
105
+
(
106
106
+
if useFetchGit then
107
107
+
{
108
108
+
inherit
109
109
+
tag
110
110
+
rev
111
111
+
deepClone
112
112
+
fetchSubmodules
113
113
+
sparseCheckout
114
114
+
fetchLFS
115
115
+
leaveDotGit
116
116
+
;
117
117
+
url = baseUrl;
118
118
+
}
119
119
+
else
120
120
+
{
121
121
+
url = "${baseUrl}/archive/${revWithTag}";
122
122
+
extension = "tar.gz";
90
123
91
91
-
fetcherArgs =
92
92
-
(
93
93
-
if useFetchGit then
94
94
-
{
95
95
-
inherit
96
96
-
tag
97
97
-
rev
98
98
-
deepClone
99
99
-
fetchSubmodules
100
100
-
sparseCheckout
101
101
-
fetchLFS
102
102
-
leaveDotGit
103
103
-
;
104
104
-
url = baseUrl;
105
105
-
}
106
106
-
else
107
107
-
{
108
108
-
url = "${baseUrl}/archive/${revWithTag}";
109
109
-
extension = "tar.gz";
124
124
+
passthru = {
125
125
+
gitRepoUrl = baseUrl;
126
126
+
};
127
127
+
}
128
128
+
)
129
129
+
// passthruAttrs
130
130
+
// {
131
131
+
inherit name;
132
132
+
};
133
133
+
in
110
134
111
111
-
passthru = {
112
112
-
gitRepoUrl = baseUrl;
113
113
-
};
114
114
-
}
115
115
-
)
116
116
-
// passthruAttrs
135
135
+
fetcher fetcherArgs
117
136
// {
118
118
-
inherit name;
137
137
+
meta = newMeta;
138
138
+
inherit owner repo tag;
139
139
+
rev = revWithTag;
119
140
};
120
120
-
in
121
121
-
122
122
-
fetcher fetcherArgs
123
123
-
// {
124
124
-
meta = newMeta;
125
125
-
inherit owner repo tag;
126
126
-
rev = revWithTag;
127
141
}
128
142
)