Profpatsch/third_party/overlays/sam/pkgs/tcl-modules/sycl/default.nix
 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
57
58
59
60
61
62
{ lib
, stdenv
, buildNimSbom
, pkg-config
, tcl
, alt
}:

buildNimSbom
  (finalAttrs: {
    outputs = [
      "out"
      "man"
    ];

    src = alt.sam.fetchFromSyndicateLang {
      owner = "ehmry";
      repo = "sycl";
      rev = finalAttrs.version;
      hash = "sha256-zp2EnIY6iL3FwwmVMP8JZd5jjZ7RcBKuCQoziBTQpe8=";
    };

    nativeBuildInputs = [
      pkg-config
    ];

    buildInputs = [
      tcl
      tcl.tclPackageHook
    ];

    nimFlags = lib.optional (lib.versionOlder tcl.version "9.0") "--define:tcl8";

    env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=incompatible-pointer-types";
    env.PRESERVES_SAMPLES = "${alt.sam.preserves}/tests/samples.bin";

    postBuild = "mv *.so src/";

    doCheck = true;
    checkPhase = ''
      runHook preCheck
      export TCLLIBPATH="$(realpath src) $TCLLIBPATH"
      pushd tests
      ${tcl}/bin/tclsh test.tcl
      popd
      runHook postCheck
    '';

    installPhase = ''
      runHook preInstall
      install -D -t $out/lib/$name src/*.tcl src/*.so
      install -D -t $man/share/man/mann *.n.gz
      runHook postInstall
    '';

    meta = {
      description = "Syndicate Command Language";
      homepage = "https://git.syndicate-lang.org/ehmry/sycl";
      license = lib.licenses.unlicense;
      maintainers = with lib.maintainers; [ ehmry ];
    };
  }) ./sbom.json