diff options
Diffstat (limited to 'pkgs/build-support/trivial-builders.nix')
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 7e73f98db78..d9eeaa31359 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -88,23 +88,33 @@ rec { (lib.concatMapStrings (x: "ln -s '${x.path}' '${x.name}';\n") entries)); # Require file - requireFile = {name, sha256, url ? null, message ? null} : + requireFile = { name ? null + , sha256 ? null + , sha1 ? null + , url ? null + , message ? null + } : assert (message != null) || (url != null); + assert (sha256 != null) || (sha1 != null); + assert (name != null) || (url != null); let msg = if message != null then message else '' - Unfortunately, we may not download file ${name} automatically. + Unfortunately, we may not download file ${name_} automatically. Please, go to ${url}, download it yourself, and add it to the Nix store using either - nix-store --add-fixed sha256 ${name} + nix-store --add-fixed ${hashAlgo} ${name_} or - nix-prefetch-url file://path/to/${name} + nix-prefetch-url --type ${hashAlgo} file://path/to/${name_} ''; + hashAlgo = if sha256 != null then "sha256" else "sha1"; + hash = if sha256 != null then sha256 else sha1; + name_ = if name == null then baseNameOf (toString url) else name; in stdenv.mkDerivation { - inherit name; - outputHashAlgo = "sha256"; - outputHash = sha256; + name = name_; + outputHashAlgo = hashAlgo; + outputHash = hash; builder = writeScript "restrict-message" '' source ${stdenv}/setup cat <<_EOF_ |