Skip to content

Commit

Permalink
leave only overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
esselius committed Apr 19, 2021
1 parent 7a054db commit f65cc0b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 60 deletions.
20 changes: 1 addition & 19 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 36 additions & 41 deletions flake.nix
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);
};
};
}

0 comments on commit f65cc0b

Please sign in to comment.