-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,44 @@ | ||
{ | ||
outputs = { nixpkgs, ... }@inputs: | ||
let | ||
pkgs = import nixpkgs { | ||
system = "x86_64-darwin"; | ||
}; | ||
|
||
mkDenoDrv = { name, src, lockfile, entrypoint }@args: | ||
let | ||
inherit (builtins) split hashString; | ||
inherit (pkgs) lib fetchurl linkFarm writeText runCommand deno; | ||
inherit (pkgs.lib) elemAt flatten mapAttrsToList importJSON; | ||
inherit (pkgs.stdenv) mkDerivation; | ||
outputs = inputs: | ||
{ | ||
overlay = final: prev: { | ||
mkDenoDrv = { name, src, lockfile, entrypoint }@args: | ||
let | ||
inherit (builtins) split hashString; | ||
inherit (prev) lib fetchurl linkFarm writeText runCommand deno; | ||
inherit (prev.lib) elemAt flatten mapAttrsToList importJSON; | ||
inherit (prev.stdenv) mkDerivation; | ||
|
||
urlPart = url: elemAt (flatten (split "://([a-z0-9\.]*)" url)); | ||
artifactPath = url: "${urlPart url 0}/${urlPart url 1}/${hashString "sha256" (urlPart url 2)}"; | ||
urlPart = url: elemAt (flatten (split "://([a-z0-9\.]*)" url)); | ||
artifactPath = url: "${urlPart url 0}/${urlPart url 1}/${hashString "sha256" (urlPart url 2)}"; | ||
|
||
dep = url: sha256: [ | ||
{ | ||
name = artifactPath url; | ||
path = fetchurl { inherit url sha256; }; | ||
} | ||
{ | ||
name = (artifactPath url) + ".metadata.json"; | ||
path = writeText "metadata.json" ''{"headers": {}, "url": ""}''; | ||
} | ||
]; | ||
dep = url: sha256: [ | ||
{ | ||
name = artifactPath url; | ||
path = fetchurl { inherit url sha256; }; | ||
} | ||
{ | ||
name = (artifactPath url) + ".metadata.json"; | ||
path = writeText "metadata.json" ''{"headers": {}, "url": ""}''; | ||
} | ||
]; | ||
|
||
deps = linkFarm "deps" (flatten (mapAttrsToList dep (importJSON lockfile))); | ||
in | ||
mkDerivation | ||
({ | ||
buildPhase = '' | ||
export DENO_DIR=`mktemp -d` | ||
ln -s "${deps}" "$DENO_DIR/deps" | ||
deps = linkFarm "deps" (flatten (mapAttrsToList dep (importJSON lockfile))); | ||
in | ||
mkDerivation | ||
({ | ||
buildPhase = '' | ||
export DENO_DIR=`mktemp -d` | ||
ln -s "${deps}" "$DENO_DIR/deps" | ||
${deno}/bin/deno compile --unstable --lock="$lockfile" --cached-only -o "$name" "$entrypoint" | ||
''; | ||
${deno}/bin/deno compile --unstable --lock="$lockfile" --cached-only -o "$name" "$entrypoint" | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p "$out/bin" | ||
mv "$name" "$out/bin/" | ||
''; | ||
} // args); | ||
in | ||
{ | ||
overlay = final: prev: { inherit mkDenoDrv; }; | ||
installPhase = '' | ||
mkdir -p "$out/bin" | ||
mv "$name" "$out/bin/" | ||
''; | ||
} // args); | ||
}; | ||
}; | ||
} |