summaryrefslogtreecommitdiffstats
path: root/pkgs/development/gnuradio-modules/mkDerivation.nix
blob: 7a3b32563d1042e47a5de7c740e79906a12e917c (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
{
  lib,
  unwrapped,
}:

mkDerivation:

args:

let
  # Common validation and processing logic
  processArgs =
    args:
    # Check if it's supposed to not get built for the current gnuradio version
    if (builtins.hasAttr "disabled" args) && args.disabled then
      let
        name = args.name or "${args.pname}";
      in
      throw "Package ${name} is incompatible with GNURadio ${unwrapped.versionAttr.major}"
    else

    if builtins.hasAttr "disabledForGRafter" args then
      throw ''
        `disabledForGRafter` is superseded by `disabled`.
        Use `disabled = gnuradioAtLeast "${args.disabledForGRafter}";` instead.
      ''
    else

      let
        args_ = {
          enableParallelBuilding = args.enableParallelBuilding or true;
          nativeBuildInputs = (args.nativeBuildInputs or [ ]);
          # We add gnuradio and volk itself by default - most gnuradio based packages
          # will not consider it a dependency worth mentioning and it will almost
          # always be needed
          buildInputs = (args.buildInputs or [ ]) ++ [
            unwrapped
            unwrapped.volk
          ];
        };
      in
      args // args_;

in
if builtins.isFunction args then
  # Function form: args is (finalAttrs -> attrset)
  mkDerivation (finalAttrs: processArgs (args finalAttrs))
else
  # Attrset form: args is attrset
  mkDerivation (processArgs args)