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
fp
isabelroses.com
3 months ago
c38353c3
20770ef7
+55
-119
2 changed files
expand all
collapse all
unified
split
fetcher.nix
flake.nix
+54
-118
fetcher.nix
···
4
4
5
5
{
6
6
lib,
7
7
-
repoRevToNameMaybe,
8
8
-
fetchgit,
9
9
-
fetchzip,
7
7
+
fetchFromGitProvider,
10
8
}:
11
9
12
10
lib.makeOverridable (
13
13
-
{
14
14
-
domain ? "tangled.org",
15
15
-
owner,
16
16
-
repo,
17
17
-
rev ? null,
18
18
-
tag ? null,
11
11
+
lib.extendMkDerivation {
12
12
+
constructDrv = fetchFromGitProvider;
19
13
20
20
-
# TODO: add back when doing FP
21
21
-
# name ? repoRevToNameMaybe repo (lib.revOrTag rev tag) "tangled",
14
14
+
excludeDrvArgNames = [
15
15
+
"domain"
16
16
+
"owner"
22
17
23
23
-
# fetchgit stuff
24
24
-
fetchSubmodules ? false,
25
25
-
leaveDotGit ? false,
26
26
-
deepClone ? false,
27
27
-
forceFetchGit ? false,
28
28
-
fetchLFS ? false,
29
29
-
sparseCheckout ? [ ],
18
18
+
"useFetchGit"
19
19
+
];
30
20
31
31
-
passthru ? { },
32
32
-
meta ? { },
33
33
-
...
34
34
-
}@args:
21
21
+
extendDrvArgs =
22
22
+
finalAttrs:
23
23
+
{
24
24
+
domain ? "tangled.org",
25
25
+
owner,
26
26
+
repo,
27
27
+
rev ? null,
28
28
+
tag ? null,
29
29
+
passthru ? { },
30
30
+
meta ? { },
31
31
+
...
32
32
+
}@args:
35
33
36
36
-
assert lib.assertMsg (lib.xor (tag != null) (
37
37
-
rev != null
38
38
-
)) "fetchFromTangled requires one of either `rev` or `tag` to be provided (not both).";
34
34
+
let
39
35
40
40
-
let
36
36
+
position = (
37
37
+
if args.meta.description or null != null then
38
38
+
builtins.unsafeGetAttrPos "description" args.meta
39
39
+
else if tag != null then
40
40
+
builtins.unsafeGetAttrPos "tag" args
41
41
+
else
42
42
+
builtins.unsafeGetAttrPos "rev" args
43
43
+
);
41
44
42
42
-
position = (
43
43
-
if args.meta.description or null != null then
44
44
-
builtins.unsafeGetAttrPos "description" args.meta
45
45
-
else if tag != null then
46
46
-
builtins.unsafeGetAttrPos "tag" args
47
47
-
else
48
48
-
builtins.unsafeGetAttrPos "rev" args
49
49
-
);
45
45
+
baseUrl = "https://${domain}/${owner}/${repo}";
50
46
51
51
-
baseUrl = "https://${domain}/${owner}/${repo}";
47
47
+
newMeta =
48
48
+
meta
49
49
+
// {
50
50
+
homepage = meta.homepage or baseUrl;
51
51
+
}
52
52
+
// lib.optionalAttrs (position != null) {
53
53
+
# to indicate where derivation originates, similar to make-derivation.nix's mkDerivation
54
54
+
position = "${position.file}:${toString position.line}";
55
55
+
};
52
56
53
53
-
newMeta =
54
54
-
meta
55
55
-
// {
56
56
-
homepage = meta.homepage or baseUrl;
57
57
-
}
58
58
-
// lib.optionalAttrs (position != null) {
59
59
-
# to indicate where derivation originates, similar to make-derivation.nix's mkDerivation
60
60
-
position = "${position.file}:${toString position.line}";
61
61
-
};
57
57
+
in
62
58
63
63
-
passthruAttrs = removeAttrs args [
64
64
-
"domain"
65
65
-
"owner"
66
66
-
"repo"
67
67
-
"tag"
68
68
-
"rev"
69
69
-
"fetchSubmodules"
70
70
-
"forceFetchGit"
71
71
-
];
59
59
+
{
60
60
+
providerName = "tangled";
72
61
73
73
-
useFetchGit =
74
74
-
fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || fetchLFS || (sparseCheckout != [ ]);
62
62
+
derivationArgs = {
63
63
+
inherit
64
64
+
domain
65
65
+
owner
66
66
+
;
67
67
+
};
75
68
76
76
-
# We prefer fetchzip in cases we don't need submodules as the hash
77
77
-
# is more stable in that case.
78
78
-
fetcher =
79
79
-
if useFetchGit then
80
80
-
fetchgit
81
81
-
# fetchzip may not be overridable when using external tools, for example nix-prefetch
82
82
-
else if fetchzip ? override then
83
83
-
fetchzip.override { withUnzip = false; }
84
84
-
else
85
85
-
fetchzip;
69
69
+
inherit repo;
86
70
87
87
-
fetcherArgs =
88
88
-
finalAttrs:
89
89
-
passthruAttrs
90
90
-
// (
91
91
-
if useFetchGit then
92
92
-
{
93
93
-
inherit
94
94
-
tag
95
95
-
rev
96
96
-
deepClone
97
97
-
fetchSubmodules
98
98
-
sparseCheckout
99
99
-
fetchLFS
100
100
-
leaveDotGit
101
101
-
;
102
102
-
url = baseUrl;
103
103
-
inherit passthru;
104
104
-
derivationArgs = {
105
105
-
inherit
106
106
-
domain
107
107
-
owner
108
108
-
repo
109
109
-
;
110
110
-
};
111
111
-
}
112
112
-
else
71
71
+
gitRepoUrl = baseUrl;
72
72
+
73
73
+
fetchZipArgs =
113
74
let
114
75
revWithTag = finalAttrs.rev;
115
76
in
116
77
{
117
78
url = "${baseUrl}/archive/${revWithTag}";
118
79
extension = "tar.gz";
80
80
+
};
119
81
120
120
-
derivationArgs = {
121
121
-
inherit
122
122
-
domain
123
123
-
owner
124
124
-
repo
125
125
-
tag
126
126
-
;
127
127
-
rev = fetchgit.getRevWithTag {
128
128
-
inherit (finalAttrs) tag;
129
129
-
rev = finalAttrs.revCustom;
130
130
-
};
131
131
-
revCustom = rev;
132
132
-
};
133
133
-
134
134
-
passthru = {
135
135
-
gitRepoUrl = baseUrl;
136
136
-
}
137
137
-
// passthru;
138
138
-
}
139
139
-
)
140
140
-
// {
141
141
-
name =
142
142
-
args.name
143
143
-
or (repoRevToNameMaybe finalAttrs.repo (lib.revOrTag finalAttrs.revCustom finalAttrs.tag) "github");
144
82
meta = newMeta;
145
83
};
146
146
-
in
147
147
-
148
148
-
fetcher fetcherArgs
84
84
+
}
149
85
)
+1
-1
flake.nix
···
1
1
{
2
2
inputs = {
3
3
-
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
3
3
+
nixpkgs.url = "github:nixos/nixpkgs/pull/462034/head";
4
4
};
5
5
6
6
outputs =