From d7b738eea555bb63026279589d4b835f8459b9f0 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Thu, 6 Sep 2018 08:10:57 +1000 Subject: refactor conda stuff --- conda.nix | 41 +++++++++++++++++++++++++---------------- test.nix | 15 ++++++++++----- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/conda.nix b/conda.nix index 4006218..daffc8e 100644 --- a/conda.nix +++ b/conda.nix @@ -1,19 +1,28 @@ -{pkgs ? import {}}: +{ stdenv, lib, writeScript, conda }: -with pkgs; +{ + buildCondaEnv = { depends ? [], run }: stdenv.mkDerivation { + name = "conda-env"; + buildInputs = [ conda ] ++ depends; + buildCommand = '' + mkdir $out + HOME=$out + conda-shell-4.3.31 << EOF + conda-install + ${run} + EOF + ''; + }; -stdenv.mkDerivation { - name = "conda"; - src = ./conda.nix; - phases = [ "buildPhase" ]; - buildInputs = [ conda ]; - buildPhase = '' - HOME=$TMPDIR - conda-shell-4.3.31 << EOF - conda-install - conda config --add channels bioconda - conda install -y bwa - bwa - EOF - ''; + withCondaEnv = env: run: stdenv.mkDerivation { + name = "with-conda-env"; + buildCommand = '' + #!${stdenv.shell} + export HOME=${env} + ${conda}/bin/conda-shell-4.3.31 << EOF + ${run} + EOF + ''; + }; } + diff --git a/test.nix b/test.nix index 84c95b3..dd5ce75 100644 --- a/test.nix +++ b/test.nix @@ -3,6 +3,7 @@ with pkgs; let + conda = callPackage ./conda.nix {}; qsub = drv: lib.overrideDerivation drv ({ ppn ? 1, mem ? 1, walltime ? "24:00:00", args, builder, ... }: { builder = "/bin/bash"; @@ -63,10 +64,14 @@ let buildCommand = "sleep 5 && echo ${toString x} > $out"; }; + condaEnv = conda.buildCondaEnv { + run = '' + conda config --add channels bioconda + conda install -y bwa + ''; + }; + + condaTest = conda.withCondaEnv condaEnv "bwa"; -in stdenv.mkDerivation rec { - name = "dummies"; - dummies = map dummy [1 2 3 4 5]; - buildCommand = "for f in ${toString dummies} ; cat $f >> $out"; -} +in condaTest -- cgit v1.2.3