From 8fc680055fd44dd0278ee097000eee5e0dac7c12 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 26 Apr 2020 05:33:10 +0000 Subject: [PATCH] Add a wrapper around buildCrystalPackage to allow for nonstandard shard configurations. --- custom-crystal/default.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 custom-crystal/default.nix diff --git a/custom-crystal/default.nix b/custom-crystal/default.nix new file mode 100644 index 0000000..e7bd270 --- /dev/null +++ b/custom-crystal/default.nix @@ -0,0 +1,25 @@ +{ stdenv, lib, linkFarm, fetchgit, fetchFromGitHub }: + +{ crystal, + gitShardsFile ? null, + lockFile ? null, + shardsFile ? null, ...}@args: + +let + buildArgs = builtins.removeAttrs args [ "crystal" ]; + githubLinks = lib.mapAttrsToList (name: value: { + inherit name; + path = fetchFromGitHub value; + }) (import shardsFile); + gitLinks = lib.mapAttrsToList (name: value: { + inherit name; + path = fetchgit { inherit (value) url rev sha256; }; + }) (import gitShardsFile); + crystalLib = linkFarm "crystal-lib" (githubLinks ++ gitLinks); + configurePhase = args.configurePhase or lib.concatStringsSep "\n" ([ + "runHook preConfigure" + ] ++ lib.optional (lockFile != null) "ln -s ${lockFile} ./shard.lock" + ++ lib.optional (shardsFile != null) "ln -s ${crystalLib} lib" + ++ [ "runHook postConfigure "]); +in + crystal.buildCrystalPackage (buildArgs // { inherit configurePhase; })