core/pkgs/build-support/fetchbower/default.nix

53 lines
1.1 KiB
Nix
Raw Normal View History

2024-06-30 08:12:46 +00:00
{
stdenvNoCC,
lib,
bower2nix,
cacert,
}:
2024-05-02 00:46:19 +00:00
let
2024-06-30 08:12:46 +00:00
bowerVersion =
version:
2024-05-02 00:46:19 +00:00
let
components = lib.splitString "#" version;
hash = lib.last components;
ver = if builtins.length components == 1 then (cleanName version) else hash;
2024-06-30 08:12:46 +00:00
in
ver;
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
cleanName =
name:
lib.replaceStrings
[
"/"
":"
]
[
"-"
"-"
]
name;
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
fetchbower =
name: version: target: outputHash:
stdenvNoCC.mkDerivation {
name = "${cleanName name}-${bowerVersion version}";
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;
nativeBuildInputs = [
bower2nix
cacert
];
};
2024-05-02 00:46:19 +00:00
2024-06-30 08:12:46 +00:00
in
fetchbower