1{ stdenvNoCC, lib, bower2nix, cacert }:
2let
3 bowerVersion = version:
4 let
5 components = lib.splitString "#" version;
6 hash = lib.last components;
7 ver = if builtins.length components == 1 then (cleanName version) else hash;
8 in ver;
9
10 cleanName = name: lib.replaceStrings ["/" ":"] ["-" "-"] name;
11
12 fetchbower = name: version: target: outputHash: stdenvNoCC.mkDerivation {
13 name = "${cleanName name}-${bowerVersion version}";
14 buildCommand = ''
15 fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
16 # In some cases, the result of fetchBower is different depending
17 # on the output directory (e.g. if the bower package contains
18 # symlinks). So use a local output directory before copying to
19 # $out.
20 cp -R out $out
21 '';
22 outputHashMode = "recursive";
23 outputHashAlgo = "sha256";
24 inherit outputHash;
25 nativeBuildInputs = [ bower2nix cacert ];
26 };
27
28in fetchbower