packages/build-support/fetch-asset: init

This commit is contained in:
Max Headroom 2022-08-05 21:28:53 +02:00
parent 7c199ad13b
commit 4a44f29e2b
4 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
{
imports = [
./options.nix
];
builders = {
fetchAsset = pkgs.callPackage ./fetch-asset { };
};
}

View file

@ -0,0 +1,18 @@
{ fetchurl }:
{ cdnURL ? "https://cdn.privatevoid.net/assets", index }:
let
dvc = builtins.fromJSON (builtins.readFile index);
inherit (builtins.head dvc.outs) sha256 path;
hashPrefix = builtins.substring 0 2 sha256;
hashSuffix = builtins.substring 2 (-1) sha256;
in
fetchurl {
name = path;
url = "${cdnURL}/${hashPrefix}/${hashSuffix}";
inherit sha256;
}

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
with lib;
{
options.builders = mkOption {
description = "Collection of builder functions.";
type = with types; attrsOf (functionTo package);
default = {};
};
config._module.args = { inherit (config) builders; };
}

View file

@ -24,6 +24,7 @@
imports = [
./tests
./modules/devshell.nix
./build-support
./websites/landing/project.nix
];