about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/misc/resholve/default.nix
blob: 714c4ecabe082bf246de6ad2e6960ef0884cc0d8 (plain) (blame)
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
{ callPackage
, writeTextFile
}:

let
  source = callPackage ./source.nix { };
  deps = callPackage ./deps.nix { };
in
rec {
  resholve = callPackage ./resholve.nix {
    inherit (source) rSrc version;
    inherit (deps.oil) oildev;
  };
  resholve-utils = callPackage ./resholve-utils.nix {
    inherit resholve;
  };
  resholvePackage = callPackage ./resholve-package.nix {
    inherit resholve resholve-utils;
  };
  resholveScript = name: partialSolution: text:
    writeTextFile {
      inherit name text;
      executable = true;
      checkPhase = ''
        (
          PS4=$'\x1f'"\033[33m[resholve context]\033[0m "
          set -x
          ${resholve-utils.makeInvocation name (partialSolution // {
            scripts = [ "${placeholder "out"}" ];
          })}
        )
        ${partialSolution.interpreter} -n $out
      '';
    };
  resholveScriptBin = name: partialSolution: text:
    writeTextFile rec {
      inherit name text;
      executable = true;
      destination = "/bin/${name}";
      checkPhase = ''
        (
          cd "$out"
          PS4=$'\x1f'"\033[33m[resholve context]\033[0m "
          set -x
          : changing directory to $PWD
          ${resholve-utils.makeInvocation name (partialSolution // {
            scripts = [ "bin/${name}" ];
          })}
        )
        ${partialSolution.interpreter} -n $out/bin/${name}
      '';
    };
}