Skip to content

Instantly share code, notes, and snippets.

@bgamari
Last active December 26, 2017 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgamari/1346827ddf49560d5bf1846ba6c62e97 to your computer and use it in GitHub Desktop.
Save bgamari/1346827ddf49560d5bf1846ba6c62e97 to your computer and use it in GitHub Desktop.
let
pkgs = import <nixpkgs> { };
inherit (pkgs.stdenv) mkDerivation;
collectSymlinks = { name, inputs, include ? null }: mkDerivation {
name = "collect-${name}";
buildInputs = inputs;
buildCommand =
let
copyInput = input:
let outs = builtins.attrNames (builtins.readDir input.outPath);
in "ln -s ${input}/${builtins.elemAt outs 0} $out/${input.name}";
in ''
mkdir $out
${pkgs.lib.concatMapStringsSep "\n" copyInput inputs} '';
};
testIt =
let
testDrv = i: mkDerivation {
name = "drv-${builtins.toString i}";
buildCommand = ''
echo Building $i
sleep 5
mkdir $out
cp ${./test.nix} $out/
'';
};
in collectSymlinks { name = "testit"; inputs = pkgs.lib.genList testDrv 5; };
in testIt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment