From 3fb8782296eb04761811defc4beaff9c910a1300 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sat, 10 Oct 2020 21:27:48 +0200 Subject: [PATCH] Allow overriding the source used for evaluation --- nix/arion.nix | 1 + nix/upstreamable/default.nix | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/nix/arion.nix b/nix/arion.nix index 0374853..e43fd9e 100644 --- a/nix/arion.nix +++ b/nix/arion.nix @@ -9,4 +9,5 @@ import ./upstreamable/default.nix { inherit pkgs lib haskell runCommand; haskellPackages = haskellPackages // { inherit arion-compose; }; + evalSrc = ./..; } diff --git a/nix/upstreamable/default.nix b/nix/upstreamable/default.nix index 8f874ec..a06b42d 100644 --- a/nix/upstreamable/default.nix +++ b/nix/upstreamable/default.nix @@ -1,8 +1,14 @@ +args@ { pkgs , lib , haskellPackages , haskell , runCommand + + # Allow this expression file to be used more efficiently in situations where + # the sources are more readily available. Unpacking haskellPackages.arion-compose.src + # is not always the best choice for arion.eval. +, evalSrc ? null }: let @@ -57,14 +63,8 @@ let }; # Unpacked sources for evaluation by `eval` - srcUnpacked = pkgs.stdenv.mkDerivation { - name = "arion-src"; - inherit (arion-compose) src; - buildPhase = '' - cp -r $src $out - ''; - installPhase = ""; - }; + evalSrc' = args.evalSrc or (runCommand "arion-src" {} + "mkdir $out; tar -C $out --strip-components=1 -xf ${arion-compose.src}"); /* Function for evaluating a composition @@ -73,7 +73,7 @@ let Returns the module system's `config` and `options` variables. */ eval = args@{...}: - import (srcUnpacked + "/src/nix/eval-composition.nix") + import (evalSrc' + "/src/nix/eval-composition.nix") ({ inherit pkgs; } // args); /* Function to derivation of the docker compose yaml file