summaryrefslogtreecommitdiff
path: root/nix/package/nixtamal.nix
blob: 0cd464e7b80750fc94cf8f24078b65adebdd1069 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#──────────────────────────────────────────────────────────────────────────────┐
# SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/>             │
# SPDX-License-Identifier: LGPL-2.1-or-later                                   │
#──────────────────────────────────────────────────────────────────────────────┘
{
   lib,
   coreutils,
   python3Packages,
   nix-prefetch-darcs,
   nix-prefetch-git,
   nix-prefetch-pijul,
   ocamlPackages,
   testers,
   nixtamal,
}:

ocamlPackages.buildDunePackage {
   pname = "nixtamal";
   version = "0.0.6-alpha";
   release_year = 2025;

   src =
      let
         fs = lib.fileset;

         ocaml_project =
            file:
            lib.lists.elem file.name [
               "dune"
               "dune-project"
               "dune-workspace"
            ]
            || file.hasExt "opam";

         ocaml_src =
            file:
            lib.lists.any file.hasExt [
               "ml"
               "mld"
               "mli"
               "mly"
            ];
      in
      fs.toSource {
         root = ../..;
         fileset = fs.difference (fs.unions [
            ../../LICENSE.txt
            (fs.fileFilter (file: file.hasExt "txt") ../../license)
            (fs.fileFilter ocaml_project ../..)
            (fs.fileFilter ocaml_src ../../bin)
            (fs.fileFilter ocaml_src ../../lib)
            (fs.fileFilter ocaml_src ../../test)
            ../../doc/manifest.rst
         ]) (fs.maybeMissing ../../_build);
      };

   env = {
      DUNE_PROFILE = "release";
   };

   nativeBuildInputs = [
      python3Packages.docutils
      # NOTE: no KDL support
      python3Packages.pygments
   ];

   buildInputs = [
      # required since the prefetcher scripts presently don’t specify all of
      # their inputs
      coreutils
      nix-prefetch-darcs
      nix-prefetch-git
      nix-prefetch-pijul
   ]
   ++ (with ocamlPackages; [
      camomile
      cmdliner
      eio
      eio_main
      fmt
      jingoo
      (jsont.override {
         withBrr = false;
         withBytesrw = true;
      })
      kdl
      logs
      ppx_deriving
      ppx_deriving_qcheck
      saturn
      uri
   ]);

   postPatch = ''
      substituteInPlace bin/main.ml \
         --subst-var version
      substituteInPlace lib/lock_loader.ml \
         --subst-var release_year
   '';

   doCheck = true;

   checkInputs = with ocamlPackages; [
      alcotest
      qcheck
      qcheck-alcotest
   ];

   passthru.tests.version = testers.testVersion {
      package = nixtamal;
      command = "${nixtamal.meta.mainProgram} --version";
   };

   meta = {
      license = with lib.licenses; [ gpl3Plus ];
      platforms = lib.platforms.unix;
      mainProgram = "nixtamal";
   };
}