Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
9b9d5297
Unverified
Commit
9b9d5297
authored
4 years ago
by
Eelco Dolstra
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #3909 from matthewbauer/readd-hashed-mirrors
Add hashed-mirrors back
parents
d81f13f7
96c158d6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/manual/command-ref/conf-file.xml
+27
-0
27 additions, 0 deletions
doc/manual/command-ref/conf-file.xml
src/libstore/builtins/fetchurl.cc
+14
-0
14 additions, 0 deletions
src/libstore/builtins/fetchurl.cc
src/libstore/globals.hh
+3
-0
3 additions, 0 deletions
src/libstore/globals.hh
with
44 additions
and
0 deletions
doc/manual/command-ref/conf-file.xml
+
27
−
0
View file @
9b9d5297
...
...
@@ -370,6 +370,33 @@ false</literal>.</para>
</varlistentry>
<varlistentry
xml:id=
"conf-hashed-mirrors"
><term><literal>
hashed-mirrors
</literal></term>
<listitem><para>
A list of web servers used by
<function>
builtins.fetchurl
</function>
to obtain files by hash.
Given a hash type
<replaceable>
ht
</replaceable>
and a base-16 hash
<replaceable>
h
</replaceable>
, Nix will try to download the file
from
<literal>
hashed-mirror/
<replaceable>
ht
</replaceable>
/
<replaceable>
h
</replaceable></literal>
.
This allows files to be downloaded even if they have disappeared
from their original URI. For example, given the hashed mirror
<literal>
http://tarballs.example.com/
</literal>
, when building the
derivation
<programlisting>
builtins.fetchurl {
url = "https://example.org/foo-1.2.3.tar.xz";
sha256 = "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae";
}
</programlisting>
Nix will attempt to download this file from
<literal>
http://tarballs.example.com/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae
</literal>
first. If it is not available there, if will try the original URI.
</para></listitem>
</varlistentry>
<varlistentry
xml:id=
"conf-http-connections"
><term><literal>
http-connections
</literal></term>
<listitem><para>
The maximum number of parallel TCP connections
...
...
This diff is collapsed.
Click to expand it.
src/libstore/builtins/fetchurl.cc
+
14
−
0
View file @
9b9d5297
...
...
@@ -58,6 +58,20 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
}
};
/* Try the hashed mirrors first. */
if
(
getAttr
(
"outputHashMode"
)
==
"flat"
)
for
(
auto
hashedMirror
:
settings
.
hashedMirrors
.
get
())
try
{
if
(
!
hasSuffix
(
hashedMirror
,
"/"
))
hashedMirror
+=
'/'
;
std
::
optional
<
HashType
>
ht
=
parseHashTypeOpt
(
getAttr
(
"outputHashAlgo"
));
Hash
h
=
newHashAllowEmpty
(
getAttr
(
"outputHash"
),
ht
);
fetch
(
hashedMirror
+
printHashType
(
h
.
type
)
+
"/"
+
h
.
to_string
(
Base16
,
false
));
return
;
}
catch
(
Error
&
e
)
{
debug
(
e
.
what
());
}
/* Otherwise try the specified URL. */
fetch
(
mainUrl
);
}
...
...
This diff is collapsed.
Click to expand it.
src/libstore/globals.hh
+
3
−
0
View file @
9b9d5297
...
...
@@ -335,6 +335,9 @@ public:
"setuid/setgid bits or with file capabilities."
};
#endif
Setting
<
Strings
>
hashedMirrors
{
this
,
{},
"hashed-mirrors"
,
"A list of servers used by builtins.fetchurl to fetch files by hash."
};
Setting
<
uint64_t
>
minFree
{
this
,
0
,
"min-free"
,
"Automatically run the garbage collector when free disk space drops below the specified amount."
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment