about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/misc/resholve/resholve-package.nix
blob: 89852efb8bac839d8a1a1f0897027421cfc0c6ab (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
{ stdenv, lib, resholve, resholve-utils }:

{ pname
, src
, version
, passthru ? { }
, solutions
, ...
}@attrs:
let
  inherit stdenv;

  self = (stdenv.mkDerivation ((removeAttrs attrs [ "solutions" ])
    // {
    inherit pname version src;
    buildInputs = (lib.optionals (builtins.hasAttr "buildInputs" attrs) attrs.buildInputs) ++ [ resholve ];

    # enable below for verbose debug info if needed
    # supports default python.logging levels
    # LOGLEVEL="INFO";
    /*
      subshell/PS4/set -x and : command to output resholve envs
      and invocation. Extra context makes it clearer what the
      Nix API is doing, makes nix-shell debugging easier, etc.
    */
    preFixup = ''
      (
        cd "$out"
        PS4=$'\x1f'"\033[33m[resholve context]\033[0m "
        set -x
        : changing directory to $PWD
        ${builtins.concatStringsSep "\n" (resholve-utils.makeCommands solutions)}
      )
    '';
  }));
in
lib.extendDerivation true passthru self