summaryrefslogtreecommitdiff
path: root/pkgs/development/ruby-modules/testing/stubs.nix
blob: 614dcd822f4a141f6a6e69c1e57398c9e76452db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
  stdenv,
  lib,
  ruby,
  callPackage,
  ...
}:
let
  mkDerivation =
    { name, ... }@argSet:
    derivation {
      inherit name;
      text = (
        builtins.toJSON (
          lib.filterAttrs (
            n: v:
            builtins.elem n [
              "name"
              "system"
            ]
          ) argSet
        )
      );
      builder = stdenv.shell;
      args = [
        "-c"
        "echo  $(<$textPath) > $out"
      ];
      system = stdenv.hostPlatform.system;
      passAsFile = [ "text" ];
    };
  fetchurl =
    {
      url ? "",
      urls ? [ ],
      ...
    }:
    "fetchurl:${if urls == [ ] then url else builtins.head urls}";

  stdenv' = stdenv // {
    inherit mkDerivation;
    stubbed = true;
  };
  ruby' = ruby // {
    stdenv = stdenv';
    stubbed = true;
  };
in
{
  ruby = ruby';
  buildRubyGem = callPackage ../gem {
    inherit fetchurl;
    ruby = ruby';
  };
  stdenv = stdenv';
}