packages/build-support/fetch-asset: init
This commit is contained in:
parent
7c199ad13b
commit
4a44f29e2b
4 changed files with 43 additions and 0 deletions
11
packages/build-support/default.nix
Normal file
11
packages/build-support/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
];
|
||||
|
||||
builders = {
|
||||
fetchAsset = pkgs.callPackage ./fetch-asset { };
|
||||
};
|
||||
}
|
18
packages/build-support/fetch-asset/default.nix
Normal file
18
packages/build-support/fetch-asset/default.nix
Normal 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;
|
||||
}
|
13
packages/build-support/options.nix
Normal file
13
packages/build-support/options.nix
Normal 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; };
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
imports = [
|
||||
./tests
|
||||
./modules/devshell.nix
|
||||
./build-support
|
||||
|
||||
./websites/landing/project.nix
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue