nixpkgs/pkgs/build-support/fetchbower/default.nix
Rodney Lorrimar 9b0d50e3d0 fetchbower: clean common uri characters from version string
Some bower.json files have URL dependencies missing a version.

Fixes rvl/bower2nix#18
2017-10-30 18:23:45 +01:00

30 lines
998 B
Nix

{ stdenv, lib, bower2nix, cacert }:
let
bowerVersion = version:
let
components = lib.splitString "#" version;
hash = lib.last components;
ver = if builtins.length components == 1 then (cleanName version) else hash;
in ver;
cleanName = name: lib.replaceStrings ["/" ":"] ["-" "-"] name;
fetchbower = name: version: target: outputHash: stdenv.mkDerivation {
name = "${cleanName name}-${bowerVersion version}";
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
buildCommand = ''
fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
# In some cases, the result of fetchBower is different depending
# on the output directory (e.g. if the bower package contains
# symlinks). So use a local output directory before copying to
# $out.
cp -R out $out
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
inherit outputHash;
buildInputs = [ bower2nix ];
};
in fetchbower