tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
requireFile: Make more flexible
Shea Levy
10 years ago
e987d1c1
957390ec
+17
-7
1 changed file
expand all
collapse all
unified
split
pkgs
build-support
trivial-builders.nix
+17
-7
pkgs/build-support/trivial-builders.nix
···
88
88
(lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries));
89
89
90
90
# Require file
91
91
-
requireFile = {name, sha256, url ? null, message ? null} :
91
91
+
requireFile = { name ? null
92
92
+
, sha256 ? null
93
93
+
, sha1 ? null
94
94
+
, url ? null
95
95
+
, message ? null
96
96
+
} :
92
97
assert (message != null) || (url != null);
98
98
+
assert (sha256 != null) || (sha1 != null);
99
99
+
assert (name != null) || (url != null);
93
100
let msg =
94
101
if message != null then message
95
102
else ''
96
96
-
Unfortunately, we may not download file ${name} automatically.
103
103
+
Unfortunately, we may not download file ${name_} automatically.
97
104
Please, go to ${url}, download it yourself, and add it to the Nix store
98
105
using either
99
99
-
nix-store --add-fixed sha256 ${name}
106
106
+
nix-store --add-fixed ${hashAlgo} ${name_}
100
107
or
101
101
-
nix-prefetch-url file://path/to/${name}
108
108
+
nix-prefetch-url --type ${hashAlgo} file://path/to/${name_}
102
109
'';
110
110
+
hashAlgo = if sha256 != null then "sha256" else "sha1";
111
111
+
hash = if sha256 != null then sha256 else sha1;
112
112
+
name_ = if name == null then baseNameOf (toString url) else name;
103
113
in
104
114
stdenv.mkDerivation {
105
105
-
inherit name;
106
106
-
outputHashAlgo = "sha256";
107
107
-
outputHash = sha256;
115
115
+
name = name_;
116
116
+
outputHashAlgo = hashAlgo;
117
117
+
outputHash = hash;
108
118
builder = writeScript "restrict-message" ''
109
119
source ${stdenv}/setup
110
120
cat <<_EOF_