mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-24 15:01:56 +03:00
49 lines
841 B
Nix
49 lines
841 B
Nix
{
|
|
utils ? null,
|
|
fetchurl,
|
|
lib,
|
|
hashFile ? utils.hashFile,
|
|
mkDerivation,
|
|
extractSource ?
|
|
import ../extractSource.nix {
|
|
inherit lib mkDerivation;
|
|
},
|
|
...
|
|
}: {
|
|
inputs = [
|
|
"url"
|
|
];
|
|
|
|
outputs = {url, ...}: let
|
|
b = builtins;
|
|
in {
|
|
calcHash = algo:
|
|
hashFile algo (b.fetchurl {
|
|
inherit url;
|
|
});
|
|
|
|
fetched = hash: let
|
|
drv =
|
|
if hash != null && lib.stringLength hash == 40
|
|
then
|
|
fetchurl {
|
|
inherit url;
|
|
sha1 = hash;
|
|
}
|
|
else
|
|
fetchurl {
|
|
inherit url hash;
|
|
};
|
|
|
|
drvSanitized = drv.overrideAttrs (old: {
|
|
name = lib.strings.sanitizeDerivationName old.name;
|
|
});
|
|
|
|
extracted = extractSource {
|
|
source = drvSanitized;
|
|
};
|
|
in
|
|
extracted;
|
|
};
|
|
}
|