├── .github
├── dependabot.yml
└── workflows
│ ├── auto-update.js
│ ├── auto-update.yml
│ └── pipeline.yml
├── LICENSE
├── README.md
├── auto-update
└── lib.js
├── ci.sh
├── ci
├── default.nix
├── filter.nix
├── hydra.nix
├── hydra_jobs.nix
├── hydra_spec.json
└── simple-pr-dummy.json
├── cockroachdb
├── default.nix
├── generic.nix
└── makefile-redact-safe-patch.patch
├── cross
├── cross_4_11.patch
├── cross_4_12.patch
├── cross_4_13.patch
├── cross_4_14.patch
├── cross_5_00.patch
├── cross_5_1.patch
├── cross_5_2.patch
├── cross_5_3.patch
├── default.nix
├── ocaml-compiler.nix
└── ocaml.nix
├── default.nix
├── flake.lock
├── flake.nix
├── format.sh
├── ocaml
├── 0001-rename-labels.patch
├── archi
│ ├── async.nix
│ ├── default.nix
│ ├── eio.nix
│ └── lwt.nix
├── camlpstreams.patch
├── camomile.patch
├── compiler-libs-flambda2.META
├── conan
│ ├── cli.nix
│ ├── database.nix
│ ├── default.nix
│ ├── lwt.nix
│ └── unix.nix
├── cookie
│ └── default.nix
├── dataloader
│ ├── default.nix
│ └── lwt.nix
├── decimal
│ └── default.nix
├── default.nix
├── dream-html
│ ├── default.nix
│ └── pure.nix
├── dream-livereload
│ └── default.nix
├── dream-serve
│ └── default.nix
├── dream
│ ├── default.nix
│ ├── httpaf.nix
│ └── pure.nix
├── dune
│ └── rpc-lwt.nix
├── eio-ssl
│ └── default.nix
├── eio
│ └── lwt_eio.nix
├── flambda2-compiler-libs.patch
├── flambda2-ocamlbuild.patch
├── flambda2.patch
├── flow_parser
│ └── default.nix
├── gluten
│ ├── async.nix
│ ├── default.nix
│ ├── eio.nix
│ ├── lwt-unix.nix
│ ├── lwt.nix
│ └── mirage.nix
├── graphql
│ ├── async.nix
│ ├── default.nix
│ ├── lwt.nix
│ └── parser.nix
├── graphql_ppx
│ └── default.nix
├── h2
│ ├── async.nix
│ ├── default.nix
│ ├── eio.nix
│ ├── hpack.nix
│ ├── lwt-unix.nix
│ ├── lwt.nix
│ └── mirage.nix
├── httpun-ws
│ ├── async.nix
│ ├── default.nix
│ ├── eio.nix
│ ├── lwt-unix.nix
│ ├── lwt.nix
│ └── mirage.nix
├── httpun
│ ├── async.nix
│ ├── default.nix
│ ├── eio.nix
│ ├── lwt-unix.nix
│ ├── lwt.nix
│ ├── mirage.nix
│ └── types.nix
├── hyper
│ ├── 0001-Unvendor-and-add-nix.patch
│ └── default.nix
├── janestreet-0.16.nix
├── janestreet-0.17.nix
├── jose
│ └── default.nix
├── kcas
│ ├── data.nix
│ └── default.nix
├── lambda-runtime
│ ├── default.nix
│ └── vercel.nix
├── ldconf.patch
├── logs-ppx
│ └── default.nix
├── lwt
│ ├── domain.nix
│ └── react.nix
├── matrix
│ ├── ctos.nix
│ ├── default.nix
│ └── stos.nix
├── melange-packages.nix
├── melange
│ └── default.nix
├── merlin
│ ├── camlp-streams.patch
│ ├── default.nix
│ ├── dot-merlin.nix
│ └── lib.nix
├── mongo
│ ├── bson.nix
│ ├── default.nix
│ ├── lwt-unix.nix
│ ├── lwt.nix
│ └── ppx.nix
├── multipart_form
│ ├── default.nix
│ └── lwt.nix
├── ocaml-index
│ └── default.nix
├── ocaml-migrate-types
│ └── default.nix
├── ocaml5.nix
├── oidc
│ └── default.nix
├── opium-status.patch
├── overlay-ocaml-packages.nix
├── pg_query
│ └── default.nix
├── piaf
│ ├── carl.nix
│ └── default.nix
├── ppx_deriving_cmdliner.patch
├── ppx_jsx_embed
│ └── default.nix
├── ppx_rapper
│ ├── async.nix
│ ├── default.nix
│ ├── eio.nix
│ └── lwt.nix
├── prometheus
│ └── default.nix
├── redemon
│ └── default.nix
├── redis
│ ├── default.nix
│ ├── lwt.nix
│ └── sync.nix
├── reenv
│ └── default.nix
├── sendfile
│ └── default.nix
├── sherlodoc
│ └── default.nix
├── sodium-cc-patch.patch
├── sqlite3-pkg-config-env-var.patch
├── subscriptions-transport-ws
│ └── default.nix
├── timere
│ ├── default.nix
│ ├── parse.nix
│ ├── timedesc-json.nix
│ ├── timedesc-sexp.nix
│ ├── timedesc-tzdb.nix
│ ├── timedesc-tzlocal.nix
│ └── timedesc.nix
├── typedppxlib
│ ├── default.nix
│ └── ppx_debug.nix
├── tyxml
│ ├── jsx.nix
│ ├── ppx.nix
│ └── syntax.nix
└── uutf-locals.patch
├── overlay
├── default.nix
└── hermes-static-link.patch
└── static
├── default.nix
└── ocaml.nix
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "github-actions"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | commit-message:
8 | prefix: "GA"
9 | include: "scope"
10 |
--------------------------------------------------------------------------------
/.github/workflows/auto-update.js:
--------------------------------------------------------------------------------
1 | module.exports = async ({ github, context, core, require }) => {
2 | const {
3 | update_flake,
4 | get_revisions,
5 | get_newest,
6 | get_ocaml_commits,
7 | escapeForGHActions,
8 | } = require("./auto-update/lib.js");
9 | const { readFileSync, writeFileSync } = require("fs");
10 |
11 | const url = get_revisions()
12 | .then(get_newest)
13 | .then(async (revision) => {
14 | const flake_path = "./flake.nix";
15 | const old_flake = readFileSync(flake_path).toString("utf8");
16 | const next_flake = old_flake.replace(
17 | /rev=[a-z0-9]+/,
18 | `rev=${revision.sha}`
19 | );
20 |
21 | writeFileSync(flake_path, next_flake);
22 |
23 | const [prev_rev, curr_rev] = await update_flake();
24 | const url = `https://github.com/NixOS/nixpkgs/compare/${prev_rev.sha}...${curr_rev.sha}`;
25 |
26 | const { commits: ocaml_commits, error } = await get_ocaml_commits(prev_rev.sha, curr_rev.sha);
27 |
28 | const ocaml_packages_text = ocaml_commits.map(({ commit, html_url }) => {
29 | const message = escapeForGHActions(commit.message);
30 | return `* ${message}
`;
31 | });
32 |
33 | const post_text = `
34 | #### Commits touching OCaml packages:
35 | ${ocaml_packages_text.join("\n")}
36 |
37 | #### Diff URL: ${url}
38 |
39 | ${error != null ? `#### Error
40 |
41 | ${error}
42 |
43 | ` : ''}
44 | `;
45 |
46 | // Only write the file if the commit hash has changed
47 | // Otherwise just cancel the workflow. We don't need to do anything
48 | if (curr_rev.sha.startsWith(prev_rev.sha)) {
49 | throw new Error("Shas were the same");
50 | }
51 |
52 | return post_text;
53 | })
54 | .catch((error) => {
55 | console.error(error);
56 | core.notice(error.message);
57 | github.rest.actions.cancelWorkflowRun({
58 | owner: context.repo.owner,
59 | repo: context.repo.repo,
60 | run_id: context.runId,
61 | });
62 |
63 | return "";
64 | });
65 |
66 | return url;
67 | };
68 |
--------------------------------------------------------------------------------
/.github/workflows/auto-update.yml:
--------------------------------------------------------------------------------
1 | name: Auto-update
2 | on:
3 | workflow_dispatch:
4 | pull_request:
5 | types:
6 | - opened
7 | - synchronize
8 | paths:
9 | - '.github/workflows/auto-update.js'
10 | - 'auto-update/lib.js'
11 | - '.github/workflows/auto-update.yml'
12 | schedule:
13 | - cron: "30 11 */2 * *"
14 |
15 | jobs:
16 | update-sources:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - uses: actions/checkout@v4
20 | - uses: cachix/install-nix-action@v31
21 | with:
22 | nix_path: nixpkgs=channel:nixpkgs-unstable
23 | - name: "Update sources"
24 | uses: actions/github-script@v7
25 | id: update-sources
26 | with:
27 | result-encoding: string
28 | script: |
29 | const script = require('./.github/workflows/auto-update.js')
30 | return await script({github, context, core, require})
31 | - name: Commit updated flake
32 | env:
33 | GITHUB_JOB: ${{ env.GITHUB_JOB }}
34 | GITHUB_RUN_ID: ${{ env.GITHUB_RUN_ID }}
35 | run: |
36 | git config --global user.name 'UpdateBot'
37 | git config --global user.email 'ulrikstrid@users.noreply.github.com'
38 | git checkout -b "auto-update-sources-$GITHUB_RUN_ID"
39 | git add flake.nix flake.lock
40 | git commit -m "Update sources"
41 | git push --set-upstream origin "auto-update-sources-$GITHUB_RUN_ID"
42 | - name: Open pull request
43 | uses: repo-sync/pull-request@v2
44 | env:
45 | GITHUB_JOB: ${{ env.GITHUB_JOB }}
46 | GITHUB_RUN_ID: ${{ env.GITHUB_RUN_ID }}
47 | with:
48 | destination_branch: "master"
49 | source_branch: auto-update-sources-${{ github.run_id }}
50 | pr_title: "Update sources"
51 | pr_body: ":robot_face: Updating sources to the latest version.\n${{steps.update-sources.outputs.result}}"
52 | github_token: ${{ secrets.GH_PAT_ANMONTEIRO }}
53 |
--------------------------------------------------------------------------------
/.github/workflows/pipeline.yml:
--------------------------------------------------------------------------------
1 | name: Pipeline
2 | on:
3 | pull_request:
4 | branches:
5 | - master
6 | push:
7 | branches:
8 | - master
9 |
10 | concurrency:
11 | group: ${{ github.workflow }}-${{ github.ref }}
12 | cancel-in-progress: true
13 |
14 | jobs:
15 | nix-fmt-check:
16 | runs-on: ubuntu-latest
17 | steps:
18 | - uses: actions/checkout@v4
19 | - uses: cachix/install-nix-action@v31
20 | with:
21 | nix_path: nixpkgs=channel:nixpkgs-unstable
22 | - name: fmt
23 | run: |
24 | find . -iname '*.nix' | xargs nix shell -f ./ nixpkgs-fmt -c nixpkgs-fmt --check
25 | - name: check
26 | run: nix flake check
27 |
28 | native-linux:
29 | strategy:
30 | fail-fast: false
31 | matrix:
32 | setup:
33 | - { ocaml-version: 4_14, continue-on-error: false }
34 | - { ocaml-version: 5_1, continue-on-error: false }
35 | - { ocaml-version: 5_2, continue-on-error: false }
36 | - { ocaml-version: 5_3, continue-on-error: true }
37 | name: Native packages (Linux, OCaml ${{ matrix.setup.ocaml-version }})
38 | runs-on: ubuntu-latest
39 | env:
40 | NIXPKGS_ALLOW_UNFREE: 1
41 | steps:
42 | - uses: actions/checkout@v4
43 | - uses: cachix/install-nix-action@v31
44 | with:
45 | extra_nix_config: |
46 | system-features = nixos-test benchmark big-parallel kvm
47 | extra-substituters = https://anmonteiro.nix-cache.workers.dev
48 | extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=
49 | - uses: nix-ocaml/nix-s3-action@fork
50 | with:
51 | skipPush: true
52 | endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com"
53 | signingKey: ${{ secrets.R2_SIGNING_KEY }}
54 | awsAccessKeyId: ${{ secrets.R2_ACCESS_KEY_ID }}
55 | awsSecretAccessKey: ${{ secrets.R2_SECRET_ACESS_KEY }}
56 | - name: Build nix packages
57 | run: ./ci.sh x86_64-linux build_${{ matrix.setup.ocaml-version }}
58 | continue-on-error: ${{ matrix.setup.continue-on-error }}
59 |
60 | top-level-packages:
61 | strategy:
62 | fail-fast: false
63 | matrix:
64 | setup:
65 | - { os: ubuntu-latest, target: x86_64-linux }
66 | - { os: macos-13, target: x86_64-darwin }
67 | - { os: macos-14, target: aarch64-darwin }
68 | name: Native (Top-level) packages (${{ matrix.setup.os }})
69 | runs-on: ${{ matrix.setup.os }}
70 | env:
71 | NIXPKGS_ALLOW_UNFREE: 1
72 | steps:
73 | - uses: actions/checkout@v4
74 | - uses: cachix/install-nix-action@v31
75 | with:
76 | extra_nix_config: |
77 | system-features = nixos-test benchmark big-parallel kvm
78 | extra-substituters = https://anmonteiro.nix-cache.workers.dev
79 | extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=
80 | - uses: nix-ocaml/nix-s3-action@fork
81 | with:
82 | skipPush: true
83 | endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com"
84 | signingKey: ${{ secrets.R2_SIGNING_KEY }}
85 | awsAccessKeyId: ${{ secrets.R2_ACCESS_KEY_ID }}
86 | awsSecretAccessKey: ${{ secrets.R2_SECRET_ACESS_KEY }}
87 | - name: Build nix packages
88 | run: ./ci.sh ${{ matrix.setup.target }} build_top-level-packages
89 |
90 | native-macos:
91 | strategy:
92 | fail-fast: false
93 | matrix:
94 | setup:
95 | - { os: macos-13, target: x86_64-darwin, ocaml-version: 5_1, continue-on-error: false }
96 | - { os: macos-13, target: x86_64-darwin, ocaml-version: 5_2, continue-on-error: false }
97 | - { os: macos-13, target: x86_64-darwin, ocaml-version: 5_3, continue-on-error: true }
98 | - { os: macos-14, target: aarch64-darwin, ocaml-version: 4_14, continue-on-error: false }
99 | - { os: macos-14, target: aarch64-darwin, ocaml-version: 5_1, continue-on-error: false }
100 | - { os: macos-14, target: aarch64-darwin, ocaml-version: 5_2, continue-on-error: false }
101 | - { os: macos-14, target: aarch64-darwin, ocaml-version: 5_3, continue-on-error: true }
102 | name: Native packages (macOS (${{ matrix.setup.os }}), OCaml ${{ matrix.setup.ocaml-version }})
103 | runs-on: ${{ matrix.setup.os }}
104 | env:
105 | NIXPKGS_ALLOW_UNFREE: 1
106 | steps:
107 | - uses: actions/checkout@v4
108 | - uses: cachix/install-nix-action@v31
109 | with:
110 | extra_nix_config: |
111 | system-features = nixos-test benchmark big-parallel kvm
112 | extra-substituters = https://anmonteiro.nix-cache.workers.dev
113 | extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=
114 | accept-flake-config = true
115 | - uses: nix-ocaml/nix-s3-action@fork
116 | with:
117 | skipPush: true
118 | endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com"
119 | signingKey: ${{ secrets.R2_SIGNING_KEY }}
120 | awsAccessKeyId: ${{ secrets.R2_ACCESS_KEY_ID }}
121 | awsSecretAccessKey: ${{ secrets.R2_SECRET_ACESS_KEY }}
122 | - name: Build nix packages
123 | run: ./ci.sh ${{ matrix.setup.target }} build_${{ matrix.setup.ocaml-version }}
124 | continue-on-error: ${{ matrix.setup.continue-on-error }}
125 |
126 | cross-compilers:
127 | # needs: [native-linux]
128 | strategy:
129 | fail-fast: false
130 | matrix:
131 | setup:
132 | - { ocaml-version: 4_14, continue-on-error: false }
133 | - { ocaml-version: 5_1, continue-on-error: false }
134 | - { ocaml-version: 5_2, continue-on-error: false }
135 | - { ocaml-version: 5_3, continue-on-error: false }
136 | target:
137 | - arm64
138 | - musl
139 | name: ${{matrix.target}} packages (OCaml ${{ matrix.setup.ocaml-version }})
140 | runs-on: ubuntu-latest
141 | env:
142 | NIXPKGS_ALLOW_UNFREE: 1
143 | steps:
144 | - uses: actions/checkout@v4
145 | - uses: cachix/install-nix-action@v31
146 | with:
147 | extra_nix_config: |
148 | system-features = nixos-test benchmark big-parallel kvm
149 | extra-substituters = https://anmonteiro.nix-cache.workers.dev
150 | extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=
151 | - uses: nix-ocaml/nix-s3-action@fork
152 | with:
153 | skipPush: true
154 | endpoint: "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com"
155 | signingKey: ${{ secrets.R2_SIGNING_KEY }}
156 | awsAccessKeyId: ${{ secrets.R2_ACCESS_KEY_ID }}
157 | awsSecretAccessKey: ${{ secrets.R2_SECRET_ACESS_KEY }}
158 | - name: Build nix packages
159 | run : ./ci.sh x86_64-linux ${{matrix.target}}_${{matrix.setup.ocaml-version}}
160 | continue-on-error: ${{ matrix.setup.continue-on-error }}
161 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2023 Antonio Nuno Monteiro
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the “Software”), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OCaml-focused custom [Nix Overlays](https://nixos.wiki/wiki/Overlays)
2 |
3 | This repo contains a set of custom overlays and upgrades over the upstream
4 | nixpkgs set of (mostly) OCaml packages, and a few other curated derivations.
5 |
6 | ## Using this set of packages
7 |
8 | ### With Flakes
9 |
10 | In your `flake.nix`:
11 |
12 | ```nix
13 | {
14 | # Use this repo as the `nixpkgs` URL
15 | inputs.nixpkgs.url = "github:nix-ocaml/nix-overlays";
16 |
17 |
18 | outputs = { self, nixpkgs }:
19 | let
20 | pkgs = nixpkg.legacyPackages.${"YOUR_SYSTEM_STRING"};
21 | in
22 | {
23 | ...
24 | };
25 | }
26 | ```
27 |
28 | #### Alternative (advanced)
29 |
30 | ```nix
31 | {
32 | inputs.nixpkgs.url = "github:nixOS/nixpkgs";
33 |
34 | inputs.ocaml-overlay.url = "github:nix-ocaml/nix-overlays";
35 | inputs.ocaml-overlay.inputs.nixpkgs.follows = "nixpkgs";
36 |
37 |
38 | outputs = { self, nixpkgs, ocaml-overlay }:
39 | let
40 | system = "YOUR_SYSTEM_STRING";
41 | pkgs = import nixpkgs {
42 | inherit system;
43 | overlays = [
44 | ocaml-overlay.overlays.default
45 | ];
46 | };
47 | in
48 | {
49 | ...
50 | };
51 | }
52 | ```
53 |
54 | ### Without Flakes
55 |
56 | ```nix
57 | let
58 | nixpkgs-sources =
59 | builtins.fetchTarball
60 | https://github.com/nix-ocaml/nix-overlays/archive/master.tar.gz;
61 | pkgs = import nixpkgs-sources { };
62 | in
63 |
64 | pkgs
65 | ```
66 |
67 | #### Alternative (advanced)
68 |
69 | ```nix
70 | let
71 | nixpkgs-sources =
72 | builtins.fetchTarball
73 | https://github.com/nix-ocaml/nix-overlays/archive/master.tar.gz;
74 |
75 | custom-nixpkgs = /path/to/custom/nixpkgs;
76 |
77 | pkgs = import custom-nixpkgs {
78 | overlays = [
79 | (import "${nixpkgs-sources}/overlay" custom-nixpkgs)
80 | ];
81 | };
82 | in
83 |
84 | pkgs
85 | ```
86 |
87 | ## License
88 |
89 | Copyright (c) 2023 António Nuno Monteiro.
90 |
91 | See the [`MIT License`](./LICENSE) text.
92 |
93 | Note: MIT license does not apply to the packages built by nix-overlays, merely
94 | to the files in this repository (the Nix expressions, build scripts, NixOS
95 | modules, etc.). It also might not apply to patches included in the repository,
96 | which may be derivative works of the packages to which they apply. The
97 | aforementioned artifacts are all covered by the licenses of the respective
98 | packages.
99 |
100 |
--------------------------------------------------------------------------------
/auto-update/lib.js:
--------------------------------------------------------------------------------
1 | const https = require("https");
2 | const {URL} = require("url");
3 |
4 | const {exec} = require("child_process");
5 |
6 | function http_request(uri) {
7 | return new Promise((resolve, reject) => {
8 | const url = new URL(uri);
9 |
10 | return https
11 | .get({
12 | port : 443,
13 | path : url.pathname + url.search,
14 | protocol : url.protocol,
15 | hostname : url.hostname,
16 | method : "GET",
17 | headers : {
18 | "User-Agent" : "GithubActions",
19 | Accept : "application/json",
20 | },
21 | url,
22 | },
23 | (res) => {
24 | const response_data = [];
25 | res.on("data", (data) => { response_data.push(data); });
26 |
27 | res.on("end", () => {
28 | const response = Buffer.concat(response_data);
29 | const response_string = response.toString();
30 |
31 | try {
32 | return resolve(JSON.parse(response_string));
33 | } catch (e) {
34 | return reject(e);
35 | };
36 | });
37 | })
38 | .on("error", reject);
39 | });
40 | };
41 |
42 | function update_flake() {
43 | return new Promise((resolve, reject) => {
44 | exec(`nix flake update`, (error, stdout, stderr) => {
45 | if (error) {
46 | return reject(error);
47 | }
48 |
49 | const shas = [
50 | ...stderr.matchAll(
51 | /NixOS\/nixpkgs\/([^?']+).*?' \(([0-9]{4}-[0-9]{2}-[0-9]{2})\)/gi),
52 | ].map(([ _, sha, date ]) => ({
53 | sha,
54 | date,
55 | }));
56 |
57 | if (shas.length < 2) {
58 | return reject(new Error("No update"));
59 | }
60 |
61 | return resolve(shas);
62 | });
63 | });
64 | }
65 |
66 | function get_revisions() {
67 | return http_request(
68 | "https://prometheus.nixos.org/api/v1/query?query=channel_revision")
69 | .then((res) => res.data.result)
70 | .then((rev) => [rev.find((d) => d.metric.channel === "nixos-unstable"),
71 | rev.find((d) =>
72 | d.metric.channel === "nixos-unstable-small"),
73 | ]);
74 | }
75 |
76 | const get_newest = (revisions) => {
77 | const urls =
78 | revisions.map((revision) => revision.metric.revision)
79 | .map((commit_sha) =>
80 | `https://api.github.com/repos/nixos/nixpkgs/commits/${
81 | commit_sha}`);
82 |
83 | return Promise.all(urls.map(http_request)).then(([ big, small ]) => {
84 | const big_date = new Date(big.commit.committer.date);
85 | const small_date = new Date(small.commit.committer.date);
86 | if (big_date > small_date) {
87 | return {
88 | date : big_date,
89 | sha : big.sha,
90 | channel : "nixos-unstable",
91 | };
92 | } else {
93 | return {
94 | date : small_date,
95 | sha : small.sha,
96 | channel : "nixos-unstable-small",
97 | };
98 | }
99 | });
100 | };
101 |
102 | function get_commits(
103 | sha1,
104 | sha2,
105 | page = 1,
106 | prev_commits = { commits: {}, files: [] }
107 | ) {
108 | return http_request(
109 | `https://api.github.com/repos/NixOS/nixpkgs/compare/${sha1}...${sha2}?per_page=100&page=${page}`
110 | ).then((res) => {
111 | res.commits.forEach(commit => prev_commits.commits[commit.sha] = commit);
112 | const next_commits = {
113 | commits: prev_commits.commits,
114 | files: prev_commits.files.concat(res.files).filter(x => x != null),
115 | };
116 | if (res.commits.length < 100) {
117 | return next_commits;
118 | } else {
119 | return get_commits(sha1, sha2, page + 1, next_commits);
120 | }
121 | }).catch(e => {
122 | return {
123 | ...prev_commits,
124 | error: 'Error occurred, there could be relevant commits missing'
125 | }});
126 | }
127 |
128 | function get_ocaml_commits(sha1, sha2) {
129 | return get_commits(sha1, sha2).then(
130 | ({ commits = {}, files = [], error }) => {
131 | const file_commits = files
132 | .filter((x) => x.filename.toLowerCase().includes("ocaml"))
133 | .map((x) => {
134 | const commit_sha = x.blob_url.split("/")[6];
135 | return commits[commit_sha];
136 | })
137 | .filter(x => x != null);
138 | return {
139 | commits: Object.values(commits).filter((c) =>
140 | c.commit.message.toLowerCase().includes("ocaml")
141 | ).concat(file_commits),
142 | error: error
143 | };
144 | }
145 | );
146 | }
147 |
148 | function escapeForGHActions(s) {
149 | // Escape `"` and `$` characters in a string to work around the following
150 | // `` ` `` and `'` seems to be problematic as well
151 | // issue:
152 | // https://github.com/repo-sync/pull-request/issues/27
153 | return s.replace(/\$/g, '\\$')
154 | .replace(/"/g, '\\"')
155 | .replace(/`/g, '\\`')
156 | .replace(/\'/g, '\\\'');
157 | }
158 |
159 | module.exports = {
160 | update_flake,
161 | get_revisions,
162 | get_newest,
163 | get_ocaml_commits,
164 | escapeForGHActions
165 | }
166 |
--------------------------------------------------------------------------------
/ci.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -euo pipefail
3 |
4 | args=(
5 | --flake ".#hydraJobs.${1}.${2}"
6 | --copy-to
7 | "s3://overlays?endpoint=https://7a53c28e9b7a91239f9ed42da04276bc.r2.cloudflarestorage.com&compression=zstd¶llel-compression=true&secret-key=${HOME}/.nix/nix-cache-key.sec"
8 | # --no-link
9 | # --eval-workers 4
10 | # --skip-cached
11 | # --no-nom
12 | # --option allow-import-from-derivation false
13 | # --eval-max-memory-size "12000"
14 | # --quiet-build
15 | )
16 |
17 | OCAMLRUNPARAM=b nix run github:nix-ocaml/nix-ci-build -- "${args[@]}"
18 |
--------------------------------------------------------------------------------
/ci/default.nix:
--------------------------------------------------------------------------------
1 | { ocamlVersion, target ? "native" }:
2 | let
3 |
4 | system = builtins.currentSystem;
5 | flake = (import
6 | (fetchTarball {
7 | url = "https://github.com/edolstra/flake-compat/archive/35bb57c0.tar.gz";
8 | sha256 = "1prd9b1xx8c0sfwnyzkspplh30m613j42l1k789s521f4kv4c2z2";
9 | })
10 | { src = ../.; }).defaultNix;
11 |
12 | pkgs = flake.legacyPackages.${system}.extend (final: prev:
13 | if ocamlVersion != null && prev.lib.hasPrefix "5_" ocamlVersion then {
14 | ocamlPackages = final.ocaml-ng."ocamlPackages_${ocamlVersion}";
15 | } else { });
16 | filter = pkgs.callPackage ./filter.nix { };
17 | inherit (pkgs) lib stdenv pkgsCross;
18 |
19 | in
20 |
21 | {
22 | top-level-packages = with pkgs;
23 | [ melange-relay-compiler ] ++
24 | lib.optionals stdenv.isLinux [ esy kubernetes ];
25 |
26 | native = lib.attrValues (filter.ocamlCandidates {
27 | inherit pkgs ocamlVersion;
28 | });
29 |
30 | musl = filter.crossTargetList pkgsCross.musl64 ocamlVersion;
31 |
32 | arm64 = filter.crossTargetList pkgsCross.aarch64-multiplatform-musl ocamlVersion;
33 | }."${target}"
34 |
--------------------------------------------------------------------------------
/ci/filter.nix:
--------------------------------------------------------------------------------
1 | { lib, stdenv }:
2 | let
3 | baseIgnoredPackages = [
4 | # not supported in 4.11+
5 | "bap"
6 | "lwt_camlp4"
7 | "config-file"
8 | "erm_xmpp"
9 | "ulex"
10 |
11 | # dune.configurator issue
12 | "google-drive-ocamlfuse"
13 |
14 | # doesn't work with cohttp 6.0
15 | "paf-cohttp"
16 |
17 | # broken since OCaml 4.13
18 | "ppx_tools_versioned"
19 |
20 | # Conflicts with cohttp v6 because of the HTTP module
21 | "eliom"
22 | "ocsigen-start"
23 | "ocsigen-toolkit"
24 | "ocsigen_server"
25 | "ocsipersist"
26 | "ocsipersist-pgsql"
27 | "ocsipersist-sqlite"
28 |
29 | "dream-serve"
30 |
31 | "gd4o"
32 |
33 | "ocaml-sat-solvers"
34 |
35 | "pgsolver"
36 | "tcslib"
37 |
38 | "biocaml"
39 | "pythonlib"
40 | "magic-trace"
41 |
42 | # too old ocamlformat versions
43 | "ocamlformat_0_19_0"
44 | "ocamlformat_0_20_0"
45 | "ocamlformat_0_20_1"
46 | "ocamlformat_0_21_0"
47 | "ocamlformat_0_22_4"
48 | "ocamlformat_0_23_0"
49 | "ocamlformat_0_24_1"
50 | "ocamlformat_0_25_1"
51 |
52 | # Incompatible with omd 2.0
53 | "sail"
54 |
55 | # Doesn't build on 4.14. Re-enable when we remove 4.14
56 | "asai"
57 |
58 | "torch"
59 |
60 | # we don't really care about these and they don't build on 4.14
61 | "spices"
62 | "gluon"
63 | "rio"
64 | "bytestring"
65 | "config"
66 | "libc"
67 | # build is broken, something with tls
68 | "riot"
69 | "minttea"
70 | "opium"
71 | "rock"
72 | "subscriptions-transport-ws"
73 |
74 | # long time to build
75 | "lambdapi"
76 | "ocaml_libvirt"
77 | "unisim_archisec"
78 | "z3"
79 |
80 | # Broken on janestreet v0.17
81 | "camlimages"
82 | "multiformats"
83 |
84 | # cstruct -> string
85 | "chacha"
86 | "hyper"
87 | "matrix-stos"
88 |
89 | # incompatible with newer conduit-lwt-unix
90 | "websocket-lwt-unix"
91 | "irmin-server"
92 |
93 | # incompatible with new ppxlib?
94 | "metapp"
95 |
96 | # not compatible with latest odoc
97 | "sherlodoc"
98 |
99 | ## Doesn't work with latest lsp on 5.2
100 | "linol"
101 | "linol-lwt"
102 | "dolmen_lsp"
103 |
104 | ## Broken on GCC14 or clang19
105 | "mopsa"
106 |
107 | "odds"
108 | "raylib"
109 | "raygui"
110 |
111 | ## host unreachable for download
112 | "functory"
113 |
114 | "ffmpeg"
115 | "ffmpeg-av"
116 | "ffmpeg-avcodec"
117 | "ffmpeg-avdevice"
118 | "ffmpeg-avfilter"
119 | "ffmpeg-avutil"
120 | "ffmpeg-swresample"
121 | "ffmpeg-swscale"
122 | "frei0r"
123 | "tsdl"
124 | "tsdl-mixer"
125 | "tsdl-image"
126 | "tsdl-ttf"
127 | ];
128 |
129 | ocaml5Ignores = [
130 | "erm_xml"
131 | "gapi-ocaml"
132 | "memprof-limits"
133 | "ocaml_oasis"
134 | "ocamlify"
135 | "ocp-build"
136 | "piqi"
137 | "piqi-ocaml"
138 |
139 | # broken on 5.1
140 | "labltk"
141 | "ocaml-migrate-parsetree-2"
142 | "ocaml-migrate-types"
143 | "ppx_debug"
144 | "typedppxlib"
145 |
146 | ];
147 |
148 | darwinIgnores = [
149 | "dssi"
150 | "elina"
151 | "augeas"
152 | "nbd"
153 |
154 | # broken on macOS?
155 | "llvm"
156 |
157 | "alsa"
158 | "mm"
159 |
160 | "uring"
161 | "eio_linux"
162 |
163 | "inotify"
164 | "async_inotify"
165 | "async_smtp"
166 | "pam"
167 | "netsnmp"
168 | "ocaml-probes"
169 | "systemd"
170 |
171 | "gapi-ocaml"
172 | "bz2"
173 | "curses"
174 | "magic"
175 | "secp256k1"
176 | "z3"
177 | "zelus"
178 | "zelus-gtk"
179 | "ocamlfuse"
180 | "wayland"
181 |
182 | # Broken on janestreet v0.17
183 | "ecaml"
184 |
185 | # broken on aarch64-darwin
186 | "janestreet_cpuid"
187 | "stog"
188 | "stog_asy"
189 | "stog_markdown"
190 |
191 | "eigen"
192 | "owl"
193 | "owl-base"
194 | ];
195 | in
196 |
197 | rec {
198 | inherit ocaml5Ignores darwinIgnores;
199 | ocamlCandidates =
200 | { pkgs
201 | , ocamlVersion
202 | , extraIgnores ? if lib.hasPrefix "5_" ocamlVersion
203 | then ocaml5Ignores
204 | else [ ]
205 | }:
206 | let
207 | ocamlPackages = pkgs.ocaml-ng."ocamlPackages_${ocamlVersion}";
208 |
209 | ignoredPackages =
210 | baseIgnoredPackages ++
211 | lib.optionals stdenv.isDarwin darwinIgnores ++
212 | extraIgnores;
213 | in
214 | lib.filterAttrs
215 | (n: v':
216 | if # don't build tezos stuff
217 | (builtins.substring 0 5 n) == "tezos"
218 | || (builtins.elem n ignoredPackages)
219 | then false
220 | else
221 | let
222 | eval_result = builtins.tryEval v';
223 | in
224 | if !eval_result.success then false
225 | else
226 | (
227 | let
228 | v = eval_result.value;
229 | broken = (v ? meta && v.meta ? broken && v.meta.broken);
230 | in
231 | (lib.isDerivation v) && !broken
232 | ))
233 | ocamlPackages;
234 |
235 | crossTarget = pkgs: ocamlVersion:
236 | with (ocamlCandidates {
237 | inherit pkgs ocamlVersion;
238 | }); ({
239 | # just build a subset of the static overlay, with the most commonly used
240 | # packages
241 | inherit
242 | caqti-driver-postgresql ppx_deriving
243 | base cohttp-lwt-unix tls core utop irmin;
244 | } // (if lib.hasPrefix "5_" ocamlVersion then {
245 | inherit piaf carl;
246 | static-carl = carl.override { static = true; };
247 | } else { }));
248 |
249 | crossTargetList = pkgs: ocamlVersion:
250 | let attrs = crossTarget pkgs ocamlVersion; in
251 | lib.attrValues attrs;
252 | }
253 |
--------------------------------------------------------------------------------
/ci/hydra.nix:
--------------------------------------------------------------------------------
1 | { pkgs, system }:
2 | let
3 | inherit (pkgs) lib stdenv;
4 | filter = pkgs.callPackage ./filter.nix { };
5 | isDarwin = system == "aarch64-darwin" || system == "x86_64-darwin";
6 | extraIgnores = if isDarwin then filter.darwinIgnores else [ ];
7 | in
8 |
9 | with filter;
10 | {
11 | build_4_14 = ocamlCandidates {
12 | inherit pkgs;
13 | ocamlVersion = "4_14";
14 | };
15 | build_5_1 = ocamlCandidates {
16 | inherit pkgs;
17 | ocamlVersion = "5_1";
18 | extraIgnores = extraIgnores ++ ocaml5Ignores;
19 | };
20 | build_5_2 = ocamlCandidates {
21 | inherit pkgs;
22 | ocamlVersion = "5_2";
23 | extraIgnores = extraIgnores ++ ocaml5Ignores;
24 | };
25 | build_5_3 = ocamlCandidates {
26 | inherit pkgs;
27 | ocamlVersion = "5_3";
28 | extraIgnores = extraIgnores ++ ocaml5Ignores;
29 | };
30 |
31 | build_top-level-packages =
32 | { inherit (pkgs) melange-relay-compiler hermes; } //
33 | (if stdenv.isLinux then {
34 | inherit (pkgs) kubernetes;
35 | # disabled after musl 1.2.5 upgrade. should be easy to find / replace
36 | # lseek{64,} but likely not worth it as we'd like to move to the static
37 | # branch in the future.
38 | # hermes-musl64 = pkgs.pkgsCross.musl64.hermes;
39 | } else { });
40 |
41 | arm64_4_14 = (if system == "x86_64-linux" then
42 | crossTarget pkgs.pkgsCross.aarch64-multiplatform-musl "4_14"
43 | else
44 | { });
45 |
46 | musl_4_14 = (if system == "x86_64-linux" then
47 | crossTarget pkgs.pkgsCross.musl64 "4_14"
48 | else
49 | { }
50 | );
51 |
52 | arm64_5_1 = (if system == "x86_64-linux" then
53 | crossTarget pkgs.pkgsCross.aarch64-multiplatform-musl "5_1"
54 | else
55 | { });
56 |
57 | musl_5_1 = (if system == "x86_64-linux" then
58 | crossTarget pkgs.pkgsCross.musl64 "5_1"
59 | else
60 | { }
61 | );
62 |
63 | arm64_5_2 = (if system == "x86_64-linux" then
64 | crossTarget pkgs.pkgsCross.aarch64-multiplatform-musl "5_2"
65 | else
66 | { });
67 |
68 | musl_5_2 = (if system == "x86_64-linux" then
69 | crossTarget pkgs.pkgsCross.musl64 "5_2"
70 | else
71 | { }
72 | );
73 |
74 | arm64_5_3 = (if system == "x86_64-linux" then
75 | crossTarget pkgs.pkgsCross.aarch64-multiplatform-musl "5_3"
76 | else
77 | { });
78 |
79 | musl_5_3 = (if system == "x86_64-linux" then
80 | crossTarget pkgs.pkgsCross.musl64 "5_3"
81 | else
82 | { }
83 | );
84 | }
85 |
--------------------------------------------------------------------------------
/ci/hydra_jobs.nix:
--------------------------------------------------------------------------------
1 | # Heavily inspired by https://github.com/cleverca22/hydra-configs
2 | { pulls ? ./simple-pr-dummy.json }:
3 |
4 | let
5 | pkgs = import { };
6 | makeSpec = contents:
7 | builtins.derivation {
8 | name = "spec.json";
9 | system = "x86_64-linux";
10 | preferLocalBuild = true;
11 | allowSubstitutes = false;
12 | builder = "/bin/sh";
13 | args = [
14 | (builtins.toFile "builder.sh" ''
15 | echo "$contents"
16 | echo "$out"
17 | echo "$contents" > $out
18 | '')
19 | ];
20 | contents = builtins.toJSON contents;
21 | };
22 | in
23 | with pkgs.lib;
24 | let
25 | defaults = {
26 | enabled = 1;
27 | hidden = false;
28 | keepnr = 1;
29 | schedulingshares = 20;
30 | checkinterval = 600;
31 | enableemail = false;
32 | emailoverride = "";
33 | type = 1;
34 | };
35 | primary_jobsets = {
36 | nix-overlays = defaults // {
37 | keepnr = 2;
38 | schedulingshares = 100;
39 | description = "nix-overlays";
40 | flake = "github:nix-ocaml/nix-overlays";
41 | };
42 | };
43 | pr_data = builtins.fromJSON (builtins.readFile pulls);
44 | makePr = num: info: {
45 | name = "nix-overlays-${num}";
46 | value = defaults // {
47 | description = "PR ${num}: ${info.title}";
48 | flake = "github:nix-ocaml/nix-overlays/${info.head.ref}";
49 | };
50 | };
51 | pull_requests = listToAttrs (mapAttrsToList makePr pr_data);
52 | jobsetsAttrs = pull_requests // primary_jobsets;
53 | in
54 | { jobsets = makeSpec jobsetsAttrs; }
55 |
--------------------------------------------------------------------------------
/ci/hydra_spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "enabled": 1,
3 | "hidden": false,
4 | "description": "nix-overlays tests",
5 | "nixexprinput": "src",
6 | "nixexprpath": "ci/hydra_jobs.nix",
7 | "checkinterval": 300,
8 | "schedulingshares": 100,
9 | "enableemail": false,
10 | "emailoverride": "",
11 | "keepnr": 10,
12 | "inputs": {
13 | "nixpkgs": {
14 | "type": "git",
15 | "value": "https://github.com/nixos/nixpkgs nixos-unstable",
16 | "emailresponsible": false
17 | },
18 | "src": {
19 | "type": "git",
20 | "value": "https://github.com/nix-ocaml/nix-overlays",
21 | "emailresponsible": false
22 | },
23 | "pulls": {
24 | "type": "githubpulls",
25 | "value": "nix-ocaml nix-overlays",
26 | "emailresponsible": false
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ci/simple-pr-dummy.json:
--------------------------------------------------------------------------------
1 | {
2 | "276": {
3 | "title": "Jst 014",
4 | "head": {
5 | "repo": {
6 | "owner": {
7 | "login": "anmonteiro"
8 | },
9 | "name": "nix-overlays"
10 | },
11 | "ref": "jst-014"
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/cockroachdb/default.nix:
--------------------------------------------------------------------------------
1 | { callPackage, go_1_18, buildGo118Module }:
2 |
3 | {
4 | cockroachdb-21_2_x = callPackage ./generic.nix (rec {
5 | go = go_1_18;
6 | buildGoModule = buildGo118Module;
7 | version = "21.2.6";
8 | src = builtins.fetchurl {
9 | url = "https://binaries.cockroachdb.com/cockroach-v${version}.src.tgz";
10 | sha256 = "0jixsbgc5azkl91cpy4j49ipv8sm6y8897gdvs2nc8waflj7kkfr";
11 | };
12 | patches = [ ./makefile-redact-safe-patch.patch ];
13 | });
14 |
15 | cockroachdb-22_x = callPackage ./generic.nix (rec {
16 | go = go_1_18;
17 | buildGoModule = buildGo118Module;
18 | version = "22.1.0-alpha.1";
19 | src = builtins.fetchurl {
20 | url = "https://binaries.cockroachdb.com/cockroach-v${version}.src.tgz";
21 | sha256 = "0w3m2wsghrzss0cx8jcp5y4ph1zjpar6piz7p9l5n1fixz3pc7r8";
22 | };
23 | patches = [ ./makefile-redact-safe-patch.patch ];
24 | });
25 | }
26 |
--------------------------------------------------------------------------------
/cockroachdb/generic.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , src
3 | , stdenv
4 | , buildGoModule
5 | , fetchurl
6 | , fetchFromGitHub
7 | , cmake
8 | , xz
9 | , which
10 | , autoconf
11 | , ncurses6
12 | , libedit
13 | , libunwind
14 | , installShellFiles
15 | , removeReferencesTo
16 | , go
17 | , version
18 | , patches ? [ ]
19 | }:
20 |
21 | buildGoModule rec {
22 | pname = "cockroach";
23 | inherit src version;
24 |
25 | vendorSha256 = null;
26 |
27 | NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [
28 | "-Wno-error=deprecated-copy"
29 | "-Wno-error=redundant-move"
30 | "-Wno-error=pessimizing-move"
31 | ];
32 |
33 | nativeBuildInputs = [ installShellFiles cmake xz which autoconf ];
34 | buildInputs = if stdenv.isDarwin then [ libunwind libedit ] else [ ncurses6 ];
35 |
36 | inherit patches;
37 |
38 | postPatch = ''
39 | patchShebangs .
40 | '';
41 | buildPhase = ''
42 | runHook preBuild
43 | export HOME=$TMPDIR
44 | make buildoss
45 | cd src/github.com/cockroachdb/cockroach
46 | for asset in man autocomplete; do
47 | ./cockroachoss gen $asset
48 | done
49 | runHook postBuild
50 | '';
51 |
52 | installPhase = ''
53 | runHook preInstall
54 |
55 | install -D cockroachoss $out/bin/cockroach
56 | installShellCompletion cockroach.bash
57 |
58 | installManPage man/man1/*
59 |
60 | runHook postInstall
61 | '';
62 |
63 | outputs = [ "out" "man" ];
64 |
65 | # fails with `GOFLAGS=-trimpath`
66 | allowGoReference = true;
67 | preFixup = ''
68 | find $out -type f -exec ${removeReferencesTo}/bin/remove-references-to -t ${go} '{}' +
69 | '';
70 |
71 | meta = with lib; {
72 | homepage = "https://www.cockroachlabs.com";
73 | description = "A scalable, survivable, strongly-consistent SQL database";
74 | license = licenses.bsl11;
75 | # platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
76 | maintainers = with maintainers; [ rushmorem thoughtpolice turion ];
77 | };
78 | }
79 |
--------------------------------------------------------------------------------
/cockroachdb/makefile-redact-safe-patch.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/github.com/cockroachdb/cockroach/Makefile b/src/github.com/cockroachdb/cockroach/Makefile
2 | index 1d00da6..54d7ee3 100644
3 | --- a/src/github.com/cockroachdb/cockroach/Makefile
4 | +++ b/src/github.com/cockroachdb/cockroach/Makefile
5 | @@ -1538,7 +1538,7 @@ bin/.docgen_http: bin/docgen bin/.bootstrap
6 | .PHONY: docs/generated/redact_safe.md
7 |
8 | docs/generated/redact_safe.md:
9 | - ./build/bazelutil/generate_redact_safe.sh >$@.tmp || { rm -f $@.tmp; exit 1; }
10 | + ./build/bazelutil/generate_redact_safe.sh >$@.tmp || true
11 | @mv -f $@.tmp $@
12 |
13 | #### WARNING ####
14 |
--------------------------------------------------------------------------------
/cross/cross_4_11.patch:
--------------------------------------------------------------------------------
1 | diff --git a/runtime/Makefile b/runtime/Makefile
2 | index 744955c0d..44ff134f4 100644
3 | --- a/runtime/Makefile
4 | +++ b/runtime/Makefile
5 | @@ -273,7 +273,9 @@ caml/version.h : $(ROOTDIR)/tools/make-version-header.sh $(ROOTDIR)/VERSION
6 | # Libraries and programs
7 |
8 | ocamlrun$(EXE): prims.$(O) libcamlrun.$(A)
9 | - $(call MAKE_OCAMLRUN,$@,$^ $(LIBS))
10 | + # $(call MAKE_OCAMLRUN,$@,$^ $(LIBS))
11 | + cp $(OCAMLRUN) $@
12 | + chmod 755 $@
13 |
14 | libcamlrun.$(A): $(libcamlrun_OBJECTS)
15 | $(call MKLIB,$@, $^)
16 | diff --git a/tools/Makefile b/tools/Makefile
17 | index dbad0b74f..2cb607c52 100644
18 | --- a/tools/Makefile
19 | +++ b/tools/Makefile
20 | @@ -352,9 +352,8 @@ CAMLTEX= $(ROOTDIR)/compilerlibs/ocamlcommon.cma \
21 |
22 | caml-tex: INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str $(UNIXLIB))
23 | caml-tex: $(CAMLTEX)
24 | - $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/ocamlc -nostdlib \
25 | - -I $(ROOTDIR)/stdlib $(LINKFLAGS) -linkall \
26 | - -o $@ -no-alias-deps $(CAMLTEX)
27 | + $(CAMLC) -I $(ROOTDIR)/stdlib $(LINKFLAGS) -linkall \
28 | + -o $@ -no-alias-deps $(CAMLTEX)
29 |
30 | # we need str and unix which depend on the bytecode version of other tools
31 | # thus we delay building caml-tex to the opt.opt stage
32 |
--------------------------------------------------------------------------------
/cross/cross_4_12.patch:
--------------------------------------------------------------------------------
1 | diff --git a/runtime/Makefile b/runtime/Makefile
2 | index 1abf2c8cd..475c530a2 100644
3 | --- a/runtime/Makefile
4 | +++ b/runtime/Makefile
5 | @@ -272,7 +272,9 @@ caml/version.h : $(ROOTDIR)/tools/make-version-header.sh $(ROOTDIR)/VERSION
6 | # Libraries and programs
7 |
8 | ocamlrun$(EXE): prims.$(O) libcamlrun.$(A)
9 | - $(call MAKE_OCAMLRUN,$@,$^ $(LIBS))
10 | + cp $(OCAMLRUN) $@
11 | + chmod 755 $@
12 | + # $(call MAKE_OCAMLRUN,$@,$^ $(LIBS))
13 |
14 | libcamlrun.$(A): $(libcamlrun_OBJECTS)
15 | $(call MKLIB,$@, $^)
16 | diff --git a/tools/Makefile b/tools/Makefile
17 | index 07e2eda1a..0e75e5844 100644
18 | --- a/tools/Makefile
19 | +++ b/tools/Makefile
20 | @@ -331,9 +331,8 @@ caml_tex := caml-tex$(EXE)
21 |
22 | $(caml_tex): INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str $(UNIXLIB))
23 | $(caml_tex): $(caml_tex_files)
24 | - $(ROOTDIR)/runtime/ocamlrun$(EXE) $(ROOTDIR)/ocamlc$(EXE) -nostdlib \
25 | - -I $(ROOTDIR)/stdlib $(LINKFLAGS) -linkall \
26 | - -o $@ -no-alias-deps $^
27 | + $(CAMLC) -nostdlib -I $(ROOTDIR)/stdlib $(LINKFLAGS) -linkall \
28 | + -o $@ -no-alias-deps $^
29 |
30 | # we need str and unix which depend on the bytecode version of other tools
31 | # thus we delay building caml-tex to the opt.opt stage
32 |
--------------------------------------------------------------------------------
/cross/cross_4_13.patch:
--------------------------------------------------------------------------------
1 | diff --git a/runtime/Makefile b/runtime/Makefile
2 | index 3e40bdc6e..e8e4bc404 100644
3 | --- a/runtime/Makefile
4 | +++ b/runtime/Makefile
5 | @@ -265,7 +265,9 @@ build_config.h: $(ROOTDIR)/Makefile.config sak$(EXE)
6 | # Libraries and programs
7 |
8 | ocamlrun$(EXE): prims.$(O) libcamlrun.$(A)
9 | - $(MKEXE) -o $@ $^ $(LIBS)
10 | + cp $(OCAMLRUN) $@
11 | + chmod 755 $@
12 | + # $(MKEXE) -o $@ $^ $(LIBS)
13 |
14 | ocamlruns$(EXE): prims.$(O) libcamlrun_non_shared.$(A)
15 | $(call MKEXE_USING_COMPILER,$@,$^ $(LIBS))
16 | diff --git a/tools/Makefile b/tools/Makefile
17 | index 094f213e0..b20cefb3e 100644
18 | --- a/tools/Makefile
19 | +++ b/tools/Makefile
20 | @@ -316,7 +316,7 @@ caml_tex := caml-tex$(EXE)
21 | # configuration.
22 | $(caml_tex): INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str $(UNIXLIB))
23 | $(caml_tex): $(caml_tex_files)
24 | - $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) -nostdlib -I $(ROOTDIR)/stdlib \
25 | + $(CAMLC) -nostdlib -I $(ROOTDIR)/stdlib \
26 | $(LINKFLAGS) -linkall -o $@ -no-alias-deps $^
27 |
28 | # we need str and unix which depend on the bytecode version of other tools
29 |
--------------------------------------------------------------------------------
/cross/cross_4_14.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Makefile b/Makefile
2 | index 5c1f23c99..9f4fdfd24 100644
3 | --- a/Makefile
4 | +++ b/Makefile
5 | @@ -565,8 +565,6 @@ ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
6 | endif
7 | $(INSTALL_DATA) \
8 | utils/*.cmx parsing/*.cmx typing/*.cmx bytecomp/*.cmx \
9 | - toplevel/*.cmx toplevel/native/*.cmx \
10 | - toplevel/native/tophooks.cmi \
11 | file_formats/*.cmx \
12 | lambda/*.cmx \
13 | driver/*.cmx asmcomp/*.cmx middle_end/*.cmx \
14 | @@ -580,7 +578,6 @@ endif
15 | $(INSTALL_DATA) \
16 | $(BYTESTART:.cmo=.cmx) $(BYTESTART:.cmo=.$(O)) \
17 | $(OPTSTART:.cmo=.cmx) $(OPTSTART:.cmo=.$(O)) \
18 | - $(TOPLEVELSTART:.cmo=.$(O)) \
19 | "$(INSTALL_COMPLIBDIR)"
20 | ifeq "$(INSTALL_OCAMLNAT)" "true"
21 | $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"
22 | diff --git a/runtime/Makefile b/runtime/Makefile
23 | index 8e527e90e..60f345391 100644
24 | --- a/runtime/Makefile
25 | +++ b/runtime/Makefile
26 | @@ -269,7 +269,9 @@ build_config.h: $(ROOTDIR)/Makefile.config sak$(EXE)
27 | # Libraries and programs
28 |
29 | ocamlrun$(EXE): prims.$(O) libcamlrun.$(A)
30 | - $(MKEXE) -o $@ $^ $(LIBS)
31 | + cp $(OCAMLRUN) $@
32 | + chmod 755 $@
33 | + # $(MKEXE) -o $@ $^ $(LIBS)
34 |
35 | ocamlruns$(EXE): prims.$(O) libcamlrun_non_shared.$(A)
36 | $(call MKEXE_USING_COMPILER,$@,$^ $(LIBS))
37 | diff --git a/tools/Makefile b/tools/Makefile
38 | index 0275e37ce..29b66fbea 100644
39 | --- a/tools/Makefile
40 | +++ b/tools/Makefile
41 | @@ -316,7 +316,7 @@ caml_tex := caml-tex$(EXE)
42 | # configuration.
43 | $(caml_tex): INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str $(UNIXLIB))
44 | $(caml_tex): $(caml_tex_files)
45 | - $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) -nostdlib -I $(ROOTDIR)/stdlib \
46 | + $(CAMLC) -nostdlib -I $(ROOTDIR)/stdlib \
47 | $(LINKFLAGS) -linkall -o $@ -no-alias-deps $^
48 |
49 | # we need str and unix which depend on the bytecode version of other tools
50 |
--------------------------------------------------------------------------------
/cross/cross_5_00.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Makefile b/Makefile
2 | index ec0fb0b2a..46ab1a74a 100644
3 | --- a/Makefile
4 | +++ b/Makefile
5 | @@ -818,7 +818,8 @@ runtime/build_config.h: $(ROOTDIR)/Makefile.config $(SAK)
6 | ## Runtime libraries and programs
7 |
8 | runtime/ocamlrun$(EXE): runtime/prims.$(O) runtime/libcamlrun.$(A)
9 | - $(MKEXE) -o $@ $^ $(BYTECCLIBS)
10 | + cp $(OCAMLRUN) $@
11 | + chmod 755 $@
12 |
13 | runtime/ocamlruns$(EXE): runtime/prims.$(O) runtime/libcamlrun_non_shared.$(A)
14 | $(call MKEXE_VIA_CC,$@,$^ $(BYTECCLIBS))
15 | @@ -1607,8 +1608,6 @@ ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
16 | endif
17 | $(INSTALL_DATA) \
18 | utils/*.cmx parsing/*.cmx typing/*.cmx bytecomp/*.cmx \
19 | - toplevel/*.cmx toplevel/native/*.cmx \
20 | - toplevel/native/tophooks.cmi \
21 | file_formats/*.cmx \
22 | lambda/*.cmx \
23 | driver/*.cmx asmcomp/*.cmx middle_end/*.cmx \
24 | @@ -1622,7 +1621,6 @@ endif
25 | $(INSTALL_DATA) \
26 | $(BYTESTART:.cmo=.cmx) $(BYTESTART:.cmo=.$(O)) \
27 | $(OPTSTART:.cmo=.cmx) $(OPTSTART:.cmo=.$(O)) \
28 | - $(TOPLEVELSTART:.cmo=.$(O)) \
29 | "$(INSTALL_COMPLIBDIR)"
30 | ifeq "$(INSTALL_OCAMLNAT)" "true"
31 | $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"
32 | diff --git a/tools/Makefile b/tools/Makefile
33 | index fffcfe6cb..75b2a1376 100644
34 | --- a/tools/Makefile
35 | +++ b/tools/Makefile
36 | @@ -323,7 +323,7 @@ caml_tex := caml-tex$(EXE)
37 | # configuration.
38 | $(caml_tex): INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str unix)
39 | $(caml_tex): $(caml_tex_files)
40 | - $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) $(STDLIBFLAGS) \
41 | + $(CAMLC) $(STDLIBFLAGS) \
42 | $(LINKFLAGS) -linkall -o $@ -no-alias-deps $^
43 |
44 | # we need str and unix which depend on the bytecode version of other tools
45 |
--------------------------------------------------------------------------------
/cross/cross_5_1.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Makefile b/Makefile
2 | index 66bd61752e..4328026cbc 100644
3 | --- a/Makefile
4 | +++ b/Makefile
5 | @@ -855,7 +855,8 @@ runtime/build_config.h: $(ROOTDIR)/Makefile.config $(SAK)
6 | ## Runtime libraries and programs
7 |
8 | runtime/ocamlrun$(EXE): runtime/prims.$(O) runtime/libcamlrun.$(A)
9 | - $(V_MKEXE)$(MKEXE) -o $@ $^ $(BYTECCLIBS)
10 | + cp $(OCAMLRUN) $@
11 | + chmod 755 $@
12 |
13 | runtime/ocamlruns$(EXE): runtime/prims.$(O) runtime/libcamlrun_non_shared.$(A)
14 | $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^ $(BYTECCLIBS))
15 | @@ -930,6 +931,8 @@ runtime/%.npic.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) $(SHAREDLIB_CFLAGS)
16 | runtime/%.npic.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS)
17 | $(DEPDIR)/runtime/%.npic.$(D): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS)
18 |
19 | +runtime/zstd.npic.$(O): CC=$(SAK_CC)
20 | +
21 | ## Compilation of runtime C files
22 |
23 | # The COMPILE_C_FILE macro below receives as argument the pattern
24 | @@ -1457,7 +1460,7 @@ ocamltex_MODULES = tools/ocamltex
25 | # configuration.
26 | # Note: the following definitions apply to all the prerequisites
27 | # of ocamltex.
28 | -$(ocamltex): CAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) $(STDLIBFLAGS)
29 | +$(ocamltex): CAMLC = $(CAMLC) $(STDLIBFLAGS)
30 | $(ocamltex): OC_COMMON_LINKFLAGS += -linkall
31 | $(ocamltex): VPATH += $(addprefix otherlibs/,str unix)
32 |
33 | @@ -1829,8 +1832,6 @@ ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
34 | endif
35 | $(INSTALL_DATA) \
36 | utils/*.cmx parsing/*.cmx typing/*.cmx bytecomp/*.cmx \
37 | - toplevel/*.cmx toplevel/native/*.cmx \
38 | - toplevel/native/tophooks.cmi \
39 | file_formats/*.cmx \
40 | lambda/*.cmx \
41 | driver/*.cmx asmcomp/*.cmx middle_end/*.cmx \
42 | @@ -1844,7 +1845,6 @@ endif
43 | $(INSTALL_DATA) \
44 | $(ocamlc_MODULES:=.cmx) $(ocamlc_MODULES:=.$(O)) \
45 | $(ocamlopt_MODULES:=.cmx) $(ocamlopt_MODULES:=.$(O)) \
46 | - $(ocaml_MODULES:=.$(O)) \
47 | "$(INSTALL_COMPLIBDIR)"
48 | ifeq "$(INSTALL_OCAMLNAT)" "true"
49 | $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"
50 |
--------------------------------------------------------------------------------
/cross/cross_5_2.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Makefile b/Makefile
2 | index 7fabd20360..ae3f93a285 100644
3 | --- a/Makefile
4 | +++ b/Makefile
5 | @@ -1306,7 +1306,8 @@ runtime/build_config.h: $(ROOTDIR)/Makefile.config $(SAK)
6 | ## Runtime libraries and programs
7 |
8 | runtime/ocamlrun$(EXE): runtime/prims.$(O) runtime/libcamlrun.$(A)
9 | - $(V_MKEXE)$(MKEXE) -o $@ $^ $(BYTECCLIBS)
10 | + cp $(OCAMLRUN) $@
11 | + chmod 755 $@
12 |
13 | runtime/ocamlruns$(EXE): runtime/prims.$(O) runtime/libcamlrun_non_shared.$(A)
14 | $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^ $(BYTECCLIBS))
15 | @@ -1384,6 +1385,8 @@ runtime/%.npic.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) $(SHAREDLIB_CFLAGS)
16 | runtime/%.npic.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS)
17 | $(DEPDIR)/runtime/%.npic.$(D): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS)
18 |
19 | +runtime/zstd.npic.$(O): CC=$(SAK_CC)
20 | +
21 | ## Compilation of runtime C files
22 |
23 | # The COMPILE_C_FILE macro below receives as argument the pattern
24 | @@ -2292,7 +2295,7 @@ ocamltex_SOURCES = tools/ocamltex.mli tools/ocamltex.ml
25 | # configuration.
26 | # Note: the following definitions apply to all the prerequisites
27 | # of ocamltex.
28 | -$(ocamltex): CAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) $(STDLIBFLAGS)
29 | +$(ocamltex): CAMLC = $(CAMLC) $(STDLIBFLAGS)
30 | $(ocamltex): OC_COMMON_LINKFLAGS += -linkall
31 | $(ocamltex): VPATH += $(addprefix otherlibs/,str unix)
32 |
33 | @@ -2690,8 +2693,6 @@ ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
34 | endif
35 | $(INSTALL_DATA) \
36 | utils/*.cmx parsing/*.cmx typing/*.cmx bytecomp/*.cmx \
37 | - toplevel/*.cmx toplevel/native/*.cmx \
38 | - toplevel/native/tophooks.cmi \
39 | file_formats/*.cmx \
40 | lambda/*.cmx \
41 | driver/*.cmx asmcomp/*.cmx middle_end/*.cmx \
42 | @@ -2705,7 +2706,6 @@ endif
43 | $(INSTALL_DATA) \
44 | $(ocamlc_CMX_FILES) $(ocamlc_CMX_FILES:.cmx=.$(O)) \
45 | $(ocamlopt_CMX_FILES) $(ocamlopt_CMX_FILES:.cmx=.$(O)) \
46 | - $(ocamlnat_CMX_FILES:.cmx=.$(O)) \
47 | "$(INSTALL_COMPLIBDIR)"
48 | ifeq "$(INSTALL_OCAMLNAT)" "true"
49 | $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"
50 | diff --git a/stdlib/Makefile b/stdlib/Makefile
51 | index 50f825a1b3..b2bce8e83e 100644
52 | --- a/stdlib/Makefile
53 | +++ b/stdlib/Makefile
54 | @@ -34,6 +34,8 @@ include $(ROOTDIR)/Makefile.common
55 | # ../runtime/ocamlrun.
56 | USE_BOOT_OCAMLC ?=
57 |
58 | +STRIP ?= strip
59 | +
60 | ifeq "$(USE_BOOT_OCAMLC)" ""
61 | CAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE)
62 | else
63 | @@ -98,7 +100,7 @@ tmpheader.exe: $(HEADERPROGRAM).$(O)
64 | $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^)
65 | # FIXME This is wrong - mingw could invoke strip; MSVC equivalent?
66 | ifneq "$(UNIX_OR_WIN32)" "win32"
67 | - strip $@
68 | + $(STRIP) $@
69 | endif
70 |
71 | stdlib.cma: $(OBJS)
72 |
--------------------------------------------------------------------------------
/cross/cross_5_3.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Makefile b/Makefile
2 | index b23c9c30de..ebb2bc7116 100644
3 | --- a/Makefile
4 | +++ b/Makefile
5 | @@ -1405,7 +1405,8 @@ runtime/build_config.h: $(ROOTDIR)/Makefile.config $(SAK)
6 | ## Runtime libraries and programs
7 |
8 | runtime/ocamlrun$(EXE): runtime/prims.$(O) runtime/libcamlrun.$(A)
9 | - $(V_MKEXE)$(MKEXE) -o $@ $^ $(BYTECCLIBS)
10 | + cp $(OCAMLRUN) $@
11 | + chmod 755 $@
12 |
13 | runtime/ocamlruns$(EXE): runtime/prims.$(O) runtime/libcamlrun_non_shared.$(A)
14 | $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^ $(BYTECCLIBS))
15 | @@ -1492,6 +1493,8 @@ runtime/%.npic.$(O): OC_CFLAGS = $(OC_NATIVE_CFLAGS) $(SHAREDLIB_CFLAGS)
16 | runtime/%.npic.$(O): OC_CPPFLAGS = $(OC_NATIVE_CPPFLAGS)
17 | $(DEPDIR)/runtime/%.npic.$(D): OC_CPPFLAGS = $(OC_NATIVE_CPPFLAGS)
18 |
19 | +runtime/zstd.npic.$(O): CC=$(SAK_CC)
20 | +
21 | ## Compilation of runtime C files
22 |
23 | # The COMPILE_C_FILE macro below receives as argument the pattern
24 | @@ -2444,7 +2447,7 @@ ocamltex_SOURCES = tools/ocamltex.mli tools/ocamltex.ml
25 | # configuration.
26 | # Note: the following definitions apply to all the prerequisites
27 | # of ocamltex.
28 | -$(ocamltex): CAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) $(STDLIBFLAGS)
29 | +$(ocamltex): CAMLC = $(CAMLC) $(STDLIBFLAGS)
30 | $(ocamltex): OC_COMMON_LINKFLAGS += -linkall
31 | $(ocamltex): VPATH += $(addprefix otherlibs/,str unix)
32 |
33 | @@ -2927,8 +2930,6 @@ ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
34 | endif
35 | $(INSTALL_DATA) \
36 | utils/*.cmx parsing/*.cmx typing/*.cmx bytecomp/*.cmx \
37 | - toplevel/*.cmx toplevel/native/*.cmx \
38 | - toplevel/native/tophooks.cmi \
39 | file_formats/*.cmx \
40 | lambda/*.cmx \
41 | driver/*.cmx asmcomp/*.cmx middle_end/*.cmx \
42 | @@ -2942,7 +2943,6 @@ endif
43 | $(INSTALL_DATA) \
44 | $(ocamlc_CMX_FILES) $(ocamlc_CMX_FILES:.cmx=.$(O)) \
45 | $(ocamlopt_CMX_FILES) $(ocamlopt_CMX_FILES:.cmx=.$(O)) \
46 | - $(ocamlnat_CMX_FILES:.cmx=.$(O)) \
47 | "$(INSTALL_COMPLIBDIR)"
48 | ifeq "$(INSTALL_OCAMLNAT)" "true"
49 | $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"
50 |
--------------------------------------------------------------------------------
/cross/default.nix:
--------------------------------------------------------------------------------
1 | { buildPackages }:
2 |
3 | self: super:
4 |
5 | super.lib.overlayOCamlPackages {
6 | inherit self super;
7 | overlays = super.callPackage ./ocaml.nix {
8 | inherit buildPackages;
9 | };
10 | updateOCamlPackages = true;
11 | }
12 |
--------------------------------------------------------------------------------
/cross/ocaml-compiler.nix:
--------------------------------------------------------------------------------
1 | { stdenv, lib, buildPackages, natocamlPackages, writeScriptBin, osuper }:
2 |
3 | let
4 | natocaml = natocamlPackages.ocaml;
5 | genWrapper = name: camlBin: writeScriptBin name ''
6 | #!${buildPackages.stdenv.shell}
7 | NEW_ARGS=""
8 |
9 | for ARG in "$@"; do NEW_ARGS="$NEW_ARGS \"$ARG\""; done
10 | eval "${camlBin} $NEW_ARGS"
11 | '';
12 | ocamlcHostWrapper = genWrapper "ocamlcHost.wrapper" "${natocaml}/bin/ocamlc.opt -I ${natocaml}/lib/ocaml -I ${natocaml}/lib/ocaml/stublibs -I +unix -nostdlib ";
13 | ocamloptHostWrapper = genWrapper "ocamloptHost.wrapper" "${natocaml}/bin/ocamlopt.opt -I ${natocaml}/lib/ocaml -I +unix -nostdlib ";
14 |
15 | ocamlcTargetWrapper = genWrapper "ocamlcTarget.wrapper" "$BUILD_ROOT/ocamlc.opt -I $BUILD_ROOT/stdlib -I $BUILD_ROOT/otherlibs/unix -I ${natocaml}/lib/ocaml/stublibs -nostdlib ";
16 | ocamloptTargetWrapper = genWrapper "ocamloptTarget.wrapper" "$BUILD_ROOT/ocamlopt.opt -I $BUILD_ROOT/stdlib -I $BUILD_ROOT/otherlibs/unix -nostdlib ";
17 |
18 | in
19 | osuper.ocaml.overrideAttrs (o:
20 | let isOCaml5 = lib.versionOlder "5.0" o.version;
21 | in {
22 | depsBuildBuild = [ buildPackages.stdenv.cc ];
23 | preConfigure = ''
24 | configureFlagsArray+=("PARTIALLD=$LD -r" "ASPP=$CC -c")
25 | installFlagsArray+=("OCAMLRUN=${natocaml}/bin/ocamlrun")
26 | '';
27 | configureFlags = o.configureFlags ++ [ "--disable-ocamldoc" ];
28 | postConfigure = ''
29 | cp Makefile.config Makefile.config.bak
30 | echo 'SAK_CC=${buildPackages.stdenv.cc}/bin/gcc' >> Makefile.config
31 | echo 'SAK_CFLAGS=$(OC_CFLAGS) $(OC_CPPFLAGS)' >> Makefile.config
32 | echo 'SAK_LINK=$(SAK_CC) $(SAK_CFLAGS) $(OUTPUTEXE)$(1) $(2)' >> Makefile.config
33 | '';
34 |
35 | buildPhase = ''
36 | runHook preBuild
37 |
38 | OCAML_HOST=${natocaml}
39 | OCAMLRUN="$OCAML_HOST/bin/ocamlrun"
40 | OCAMLLEX="$OCAML_HOST/bin/ocamllex"
41 | OCAMLYACC="$OCAML_HOST/bin/ocamlyacc"
42 | CAMLDEP="$OCAML_HOST/bin/ocamlc"
43 | DYNAMIC_LIBS="-I $OCAML_HOST/lib/ocaml/stublibs"
44 | HOST_STATIC_LIBS="-I $OCAML_HOST/lib/ocaml"
45 | TARGET_STATIC_LIBS="-I $PWD/stdlib -I $PWD/otherlibs/unix"
46 |
47 | HOST_MAKEFILE_CONFIG="$OCAML_HOST/lib/ocaml/Makefile.config"
48 | get_host_variable () {
49 | cat $HOST_MAKEFILE_CONFIG | grep "$1=" | awk -F '=' '{print $2}'
50 | }
51 |
52 | NATDYNLINK=$(get_host_variable "NATDYNLINK")
53 | NATDYNLINKOPTS=$(get_host_variable "NATDYNLINKOPTS")
54 |
55 |
56 | make_caml () {
57 | make ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} ''${enableParallelBuilding:+-l $NIX_BUILD_CORES} \
58 | CAMLDEP="$CAMLDEP -depend" \
59 | OCAMLLEX="$OCAMLLEX" \
60 | OCAMLYACC="$OCAMLYACC" CAMLYACC="$OCAMLYACC" \
61 | CAMLRUN="$OCAMLRUN" OCAMLRUN="$OCAMLRUN" \
62 | NEW_OCAMLRUN="$OCAMLRUN" \
63 | CAMLC="$CAMLC" OCAMLC="$CAMLC" \
64 | CAMLOPT="$CAMLOPT" OCAMLOPT="$CAMLOPT" \
65 | $@
66 | }
67 |
68 | make_host () {
69 | CAMLC="${ocamlcHostWrapper}/bin/ocamlcHost.wrapper"
70 | CAMLOPT="${ocamloptHostWrapper}/bin/ocamloptHost.wrapper"
71 |
72 | make_caml \
73 | NATDYNLINK="$NATDYNLINK" NATDYNLINKOPTS="$NATDYNLINKOPTS" \
74 | "$@"
75 | }
76 |
77 | make_target () {
78 | CAMLC="${ocamlcTargetWrapper}/bin/ocamlcTarget.wrapper"
79 | CAMLOPT="${ocamloptTargetWrapper}/bin/ocamloptTarget.wrapper"
80 |
81 | make_caml BUILD_ROOT="$PWD" TARGET_OCAMLC="$TARGET_OCAMLC" TARGET_OCAMLOPT="$TARGET_OCAMLOPT" "$@"
82 | }
83 |
84 | make_host runtime coreall
85 | make_host opt-core
86 | make_host ocamlc.opt
87 | make_host ocamlopt.opt
88 | make_host compilerlibs/ocamltoplevel.cma otherlibraries \
89 | ocamldebugger
90 | make_host ocamllex.opt ocamltoolsopt \
91 | ocamltoolsopt.opt ${if isOCaml5 then "othertools" else ""}
92 |
93 | rm $(find . | grep -E '\.cm.?.$')
94 | make_target -C stdlib all allopt
95 | make_target ocaml ocamlc
96 | make_target ocamlopt
97 | make_target otherlibraries otherlibrariesopt ocamltoolsopt \
98 | driver/main.cmx driver/optmain.cmx
99 |
100 | # build the compiler shared libraries with the target `zstd.npic.o`
101 | cp Makefile.config.bak Makefile.config
102 | echo 'SAK_CC=${stdenv.cc.targetPrefix}gcc' >> Makefile.config
103 | make_target compilerlibs/ocamlcommon.cmxa \
104 | compilerlibs/ocamlbytecomp.cmxa \
105 | compilerlibs/ocamloptcomp.cmxa
106 | ${if isOCaml5 then "make_target othertools" else ""}
107 |
108 | runHook postBuild
109 | '';
110 | installTargets = o.installTargets ++ [ "installoptopt" ];
111 | postInstall = "cp ${natocaml}/bin/ocamlyacc $out/bin/ocamlyacc";
112 | patches = [
113 | (if lib.versionOlder "5.3" o.version
114 | then ./cross_5_3.patch
115 | else if lib.versionOlder "5.2" o.version
116 | then ./cross_5_2.patch
117 | else if lib.versionOlder "5.1" o.version
118 | then ./cross_5_1.patch
119 | else if isOCaml5
120 | then ./cross_5_00.patch
121 | else if lib.versionOlder "4.14" o.version
122 | then ./cross_4_14.patch
123 | else if lib.versionOlder "4.13" o.version
124 | then ./cross_4_13.patch
125 | else if lib.versionOlder "4.12" o.version
126 | then ./cross_4_12.patch
127 | else if lib.versionOlder "4.11" o.version
128 | then ./cross_4_11.patch
129 | else throw "OCaml ${o.version} not supported for cross-compilation")
130 | ];
131 | })
132 |
--------------------------------------------------------------------------------
/cross/ocaml.nix:
--------------------------------------------------------------------------------
1 | # Note to the future reader:
2 | #
3 | # As opposed to the other overlays, this one effectively virtualizes an opam
4 | # switch. Dune is particular in how it finds its dependencies across build /
5 | # host platforms, and emulating an opam switch layout makes it work seamlessly.
6 | #
7 | # The only obvious downside is that there can only be one of each, even at
8 | # build time (e.g. OMP / ppxlib, etc that are possible to allow in the other
9 | # overlays).
10 |
11 | { lib, buildPackages, writeText, writeScriptBin, makeWrapper, stdenv }:
12 | let
13 | __mergeInputs = acc: names: attrs:
14 | let
15 | ret =
16 | lib.foldl' (acc: x: acc // { "${x.name}" = x; })
17 | { }
18 | (builtins.concatMap
19 | (name:
20 | builtins.filter
21 | lib.isDerivation
22 | (lib.concatLists (lib.catAttrs name attrs)))
23 | names);
24 | in
25 | if ret == { } then acc
26 | else
27 | __mergeInputs (acc // ret) names (lib.attrValues ret);
28 |
29 | mergeInputs = names: attrs:
30 | let acc = __mergeInputs { } names [ attrs ];
31 | in
32 | lib.attrValues acc;
33 |
34 | getNativeOCamlPackages = osuper:
35 | let
36 | version =
37 | lib.stringAsChars
38 | (x: if x == "." then "_" else x)
39 | (builtins.substring 0
40 | (if lib.hasPrefix "5." osuper.ocaml.version then 3 else 4)
41 | osuper.ocaml.version);
42 | in
43 | buildPackages.ocaml-ng."ocamlPackages_${version}";
44 | in
45 | [
46 | # This currently needs to be split into 2 functions, to a) avoid infinite
47 | # recursion, and b) to avoid repeating the call to `fixOCamlPackage` in case
48 | # a derivation requires more than the `OCAMLFIND_CONF` env variable override.
49 | #
50 | # The 2 overlays have the following responsibilities:
51 | # 1. We set up the build toolchain with packages from `buildPackages`. These
52 | # run on the build machine and should therefore be the same architecture.
53 | # 2. The 2nd overlay overrides package derivations (that are compiled for the
54 | # host architecture)
55 |
56 | (oself: osuper:
57 | let
58 | crossName = lib.head (lib.splitString "-" stdenv.system);
59 | natocamlPackages = getNativeOCamlPackages osuper;
60 | natocaml = natocamlPackages.ocaml;
61 | natfindlib = natocamlPackages.findlib;
62 | natdune = natocamlPackages.dune;
63 | findNativePackage = p:
64 | if p ? pname then
65 | let
66 | pname = p.pname or (throw "`p.pname' not found: ${p.name}");
67 | in
68 | natocamlPackages."${pname}" or
69 | # Some legacy packages are called `ocaml_X`, e.g. extlib and
70 | # sqlite3
71 | natocamlPackages."ocaml_${pname}" or
72 | (
73 | let
74 | prefix1 = "ocaml${osuper.ocaml.version}-";
75 | prefix2 = "ocaml-";
76 | in
77 | if lib.hasPrefix prefix1 p.pname
78 | then natocamlPackages."${(lib.removePrefix prefix1 pname)}"
79 | else if lib.hasPrefix prefix2 p.pname
80 | then natocamlPackages."${(lib.removePrefix prefix2 pname)}"
81 | else throw "Unsupported cross-pkg parsing for `${p.pname}'"
82 | )
83 | else { };
84 |
85 | makeFindlibConf = nativePackage: package:
86 | let
87 | inputs = mergeInputs [
88 | "propagatedBuildInputs"
89 | "buildInputs"
90 | "checkInputs"
91 | ]
92 | package;
93 | natInputs = mergeInputs [
94 | "propagatedBuildInputs"
95 | "buildInputs"
96 | "nativeBuildInputs"
97 | ]
98 | nativePackage;
99 |
100 | path =
101 | builtins.concatStringsSep ":"
102 | (builtins.map (x: "${x.outPath}/lib/ocaml/${natocaml.version}/${crossName}-sysroot/lib")
103 | inputs);
104 | natPath =
105 | builtins.concatStringsSep ":"
106 | (builtins.map (x: "${x.outPath}/lib/ocaml/${natocaml.version}/site-lib")
107 | natInputs);
108 |
109 | native_findlib_conf =
110 | writeText "${package.name or package.pname}-findlib.conf" ''
111 | path="${natocaml}/lib/ocaml:${natfindlib}/lib/ocaml/${natocaml.version}/site-lib:${natPath}"
112 | ldconf="ignore"
113 | stdlib = "${natocaml}/lib/ocaml"
114 | ocamlc = "${natocaml}/bin/ocamlc"
115 | ocamlopt = "${natocaml}/bin/ocamlopt"
116 | ocamlcp = "${natocaml}/bin/ocamlcp"
117 | ocamlmklib = "${natocaml}/bin/ocamlmklib"
118 | ocamlmktop = "${natocaml}/bin/ocamlmktop"
119 | ocamldoc = "${natocaml}/bin/ocamldoc"
120 | ocamldep = "${natocaml}/bin/ocamldep"
121 | '';
122 |
123 | aarch64_findlib_conf =
124 | let
125 | inherit (oself) ocaml findlib;
126 | in
127 | writeText "${package.name or package.pname}-${crossName}.conf" ''
128 | path(${crossName}) = "${ocaml}/lib/ocaml:${findlib}/lib/ocaml/${ocaml.version}/site-lib:${path}"
129 | ldconf(${crossName})="ignore"
130 | stdlib(${crossName}) = "${ocaml}/lib/ocaml"
131 | ocamlc(${crossName}) = "${ocaml}/bin/ocamlc"
132 | ocamlopt(${crossName}) = "${ocaml}/bin/ocamlopt"
133 | ocamlcp(${crossName}) = "${ocaml}/bin/ocamlcp"
134 | ocamlmklib(${crossName}) = "${ocaml}/bin/ocamlmklib"
135 | ocamlmktop(${crossName}) = "${ocaml}/bin/ocamlmktop"
136 | ocamldoc(${crossName}) = "${natocaml}/bin/ocamldoc"
137 | ocamldep(${crossName}) = "${ocaml}/bin/ocamldep"
138 | '';
139 |
140 | findlib_conf = stdenv.mkDerivation {
141 | name = "${package.name or package.pname}-findlib-conf";
142 | version = "0.0.1";
143 | unpackPhase = "true";
144 |
145 | dontBuild = true;
146 | installPhase = ''
147 | mkdir -p $out/findlib.conf.d
148 | ln -sf ${native_findlib_conf} $out/findlib.conf
149 | ln -sf ${aarch64_findlib_conf} $out/findlib.conf.d/${crossName}.conf
150 | '';
151 | };
152 |
153 | in
154 | "${findlib_conf}/findlib.conf";
155 |
156 | fixOCamlPackage = b:
157 | b.overrideAttrs (o: {
158 | OCAMLFIND_CONF = makeFindlibConf (findNativePackage b) b;
159 | });
160 | in
161 |
162 | (lib.mapAttrs
163 | (_: p: if p ? overrideAttrs then fixOCamlPackage p else p)
164 | osuper) // {
165 | ocaml = import ./ocaml-compiler.nix {
166 | inherit
167 | lib buildPackages writeScriptBin
168 | natocamlPackages osuper stdenv;
169 | };
170 |
171 | findlib = osuper.findlib.overrideAttrs (o: {
172 | postInstall = ''
173 | rm -rf $out/bin/ocamlfind
174 | cp ${natfindlib}/bin/ocamlfind $out/bin/ocamlfind
175 | '';
176 |
177 | passthru = { inherit makeFindlibConf; };
178 |
179 | setupHook = writeText "setupHook.sh" ''
180 | addOCamlPath () {
181 | if test -d "''$1/lib/ocaml/${oself.ocaml.version}/site-lib"; then
182 | export OCAMLPATH="''${OCAMLPATH-}''${OCAMLPATH:+:}''$1/lib/ocaml/${oself.ocaml.version}/site-lib/"
183 | fi
184 | if test -d "''$1/lib/ocaml/${oself.ocaml.version}/site-lib/stublibs"; then
185 | export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${oself.ocaml.version}/site-lib/stublibs"
186 | fi
187 | }
188 | exportOcamlDestDir () {
189 | export OCAMLFIND_DESTDIR="''$out/lib/ocaml/${oself.ocaml.version}/${crossName}-sysroot/lib/"
190 | }
191 | createOcamlDestDir () {
192 | if test -n "''${createFindlibDestdir-}"; then
193 | mkdir -p $OCAMLFIND_DESTDIR
194 | fi
195 | }
196 | detectOcamlConflicts () {
197 | local conflict
198 | conflict="$(ocamlfind list |& grep "has multiple definitions" | grep -vE "bigarray|unix|str|stdlib|compiler-libs|threads|bytes|dynlink|findlib" || true)"
199 | if [[ -n "$conflict" ]]; then
200 | echo "Conflicting ocaml packages detected";
201 | echo "$conflict"
202 | exit 1
203 | fi
204 | }
205 | # run for every buildInput
206 | addEnvHooks "$targetOffset" addOCamlPath
207 | # run before installPhase, even without buildInputs, and not in nix-shell
208 | preInstallHooks+=(createOcamlDestDir)
209 | # run even in nix-shell, and even without buildInputs
210 | addEnvHooks "$hostOffset" exportOcamlDestDir
211 | # runs after all calls to addOCamlPath
212 | if [[ -z "''${dontDetectOcamlConflicts-}" ]]; then
213 | postHooks+=("detectOcamlConflicts")
214 | fi
215 | '';
216 | });
217 |
218 | cppo = natocamlPackages.cppo;
219 | dune_2 = natocamlPackages.dune;
220 | dune_3 = natocamlPackages.dune;
221 | dune = natocamlPackages.dune;
222 | ocamlbuild = natocamlPackages.ocamlbuild;
223 | opaline = natocamlPackages.opaline;
224 |
225 | buildDunePackage = args: (osuper.buildDunePackage ({
226 | buildPhase = ''
227 | runHook preBuild
228 | dune build -p ${args.pname} ''${enableParallelBuilding:+-j $NIX_BUILD_CORES} -x ${crossName}
229 | runHook postBuild
230 | '';
231 |
232 | installPhase =
233 | ''
234 | runHook preInstall
235 | dune install ${args.pname} -x ${crossName} \
236 | --prefix $out --libdir $(dirname $OCAMLFIND_DESTDIR) \
237 | --docdir $out/share/doc --man $out/share/man
238 | runHook postInstall
239 | '';
240 | } // args
241 | )).overrideAttrs (o: {
242 | nativeBuildInputs =
243 | (o.nativeBuildInputs or [ ]) ++ [ buildPackages.stdenv.cc ];
244 | });
245 |
246 | topkg = natocamlPackages.topkg.overrideAttrs (o:
247 | let
248 | run = "${natocaml}/bin/ocaml -I ${natfindlib}/lib/ocaml/${osuper.ocaml.version}/site-lib pkg/pkg.ml";
249 | in
250 | {
251 | selfBuild = true;
252 |
253 | passthru = {
254 | inherit run;
255 | };
256 |
257 | buildPhase = "${run} build";
258 |
259 | setupHook = writeText "setupHook.sh" ''
260 | addToolchainVariable () {
261 | if [ -z "''${selfBuild:-}" ]; then
262 | export TOPKG_CONF_TOOLCHAIN="${crossName}"
263 | fi
264 | }
265 |
266 | addEnvHooks "$targetOffset" addToolchainVariable
267 | '';
268 | });
269 | })
270 |
271 | (oself: osuper:
272 | let
273 | crossName = lib.head (lib.splitString "-" stdenv.system);
274 | natocamlPackages = getNativeOCamlPackages osuper;
275 | in
276 | {
277 | camlzip = osuper.camlzip.overrideAttrs (_: {
278 | OCAMLFIND_TOOLCHAIN = "${crossName}";
279 | preInstall = ''
280 | mkdir -p $OCAMLFIND_DESTDIR/stublibs
281 | '';
282 | postInstall = ''
283 | ln -sfn $OCAMLFIND_DESTDIR/{,caml}zip
284 | '';
285 | });
286 |
287 | ctypes = osuper.ctypes.overrideAttrs (o: {
288 | postInstall = ''
289 | echo -e '\nversion = "${o.version}"'>> $out/lib/ocaml/${osuper.ocaml.version}/${crossName}-sysroot/lib/ctypes/META
290 | '';
291 | });
292 |
293 | cmdliner = osuper.cmdliner.overrideAttrs (o: {
294 | nativeBuildInputs = o.nativeBuildInputs ++ [ oself.findlib ];
295 |
296 | installFlags = [
297 | "LIBDIR=$(OCAMLFIND_DESTDIR)/${o.pname}"
298 | "DOCDIR=$(out)/share/doc/${o.pname}"
299 | ];
300 | postInstall = ''
301 | mv $OCAMLFIND_DESTDIR/${o.pname}/{opam,${o.pname}.opam}
302 | '';
303 | });
304 |
305 | afl-persistent = osuper.afl-persistent.overrideAttrs (o: {
306 | OCAMLFIND_TOOLCHAIN = "${crossName}";
307 |
308 | postPatch = ''
309 | ${o.postPatch}
310 | head -n -3 ./build.sh > ./temp.sh
311 | mv temp.sh build.sh
312 | chmod a+x ./build.sh
313 | '';
314 | installPhase = ''
315 | ${oself.opaline}/bin/opaline -prefix $out -libdir $OCAMLFIND_DESTDIR ${o.pname}.install
316 | '';
317 | });
318 |
319 | carl =
320 | if lib.versionAtLeast osuper.ocaml.version "5.0"
321 | then
322 | osuper.carl.overrideAttrs
323 | (o: {
324 | OCAMLFIND_TOOLCHAIN = "${crossName}";
325 | })
326 | else null;
327 |
328 | menhir = osuper.menhir.overrideAttrs (o: {
329 | postInstall = ''
330 | cp -r ${natocamlPackages.menhir}/bin/* $out/bin
331 | '';
332 | });
333 |
334 | num = osuper.num.overrideAttrs (_: {
335 | OCAMLFIND_TOOLCHAIN = "${crossName}";
336 | });
337 |
338 | ocaml-migrate-parsetree = osuper.ocaml-migrate-parsetree-2;
339 |
340 | seq = osuper.seq.overrideAttrs (o: {
341 | nativeBuildInputs = [ oself.findlib ];
342 | installPhase = ''
343 | install_dest="$OCAMLFIND_DESTDIR/seq/"
344 | mkdir -p $install_dest
345 | mv META $install_dest
346 | '';
347 | });
348 |
349 | uchar = osuper.uchar.overrideAttrs (_: {
350 | installPhase = oself.topkg.installPhase;
351 | });
352 |
353 | zarith = osuper.zarith.overrideAttrs (o: {
354 | configurePlatforms = [ ];
355 | OCAMLFIND_TOOLCHAIN = "${crossName}";
356 | configureFlags = [
357 | ];
358 | configurePhase = ''
359 | ./configure -prefixnonocaml ${stdenv.cc.targetPrefix} -installdir $OCAMLFIND_DESTDIR
360 | '';
361 | preBuild = ''
362 | buildFlagsArray+=("host=${stdenv.hostPlatform.config}")
363 | '';
364 | preInstall = "mkdir -p $OCAMLFIND_DESTDIR";
365 | });
366 | })
367 | ]
368 |
--------------------------------------------------------------------------------
/default.nix:
--------------------------------------------------------------------------------
1 | { system ? builtins.currentSystem
2 | , extraOverlays ? [ ]
3 | , ...
4 | }@args:
5 |
6 | # `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-unstable`
7 |
8 | let
9 | flake = (import
10 | (
11 | fetchTarball {
12 | url = "https://github.com/edolstra/flake-compat/archive/b4a3401.tar.gz";
13 | sha256 = "1qc703yg0babixi6wshn5wm2kgl5y1drcswgszh4xxzbrwkk9sv7";
14 | }
15 | )
16 | { src = ./.; }
17 | ).defaultNix;
18 | in
19 |
20 | flake.makePkgs {
21 | inherit system extraOverlays;
22 | }
23 |
--------------------------------------------------------------------------------
/flake.lock:
--------------------------------------------------------------------------------
1 | {
2 | "nodes": {
3 | "nixpkgs": {
4 | "locked": {
5 | "lastModified": 1749397806,
6 | "narHash": "sha256-PjSGVrOHH+2DABRJzgIt/y+zxofyfZO71pI33y0t4F4=",
7 | "owner": "NixOS",
8 | "repo": "nixpkgs",
9 | "rev": "ae91003958555b8b73c17e6536a302ff492c9d04",
10 | "type": "github"
11 | },
12 | "original": {
13 | "owner": "NixOS",
14 | "repo": "nixpkgs",
15 | "rev": "ae91003958555b8b73c17e6536a302ff492c9d04",
16 | "type": "github"
17 | }
18 | },
19 | "root": {
20 | "inputs": {
21 | "nixpkgs": "nixpkgs"
22 | }
23 | }
24 | },
25 | "root": "root",
26 | "version": 7
27 | }
28 |
--------------------------------------------------------------------------------
/flake.nix:
--------------------------------------------------------------------------------
1 | {
2 | description = "ocaml-packages-overlay";
3 |
4 | nixConfig = {
5 | extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
6 | extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
7 | };
8 |
9 | inputs = {
10 | nixpkgs.url = "github:NixOS/nixpkgs?rev=ae91003958555b8b73c17e6536a302ff492c9d04";
11 | };
12 |
13 | outputs = { self, nixpkgs }:
14 | let
15 | overlay = import ./overlay nixpkgs;
16 | in
17 | {
18 | lib = nixpkgs.lib;
19 |
20 | hydraJobs = nixpkgs.lib.genAttrs
21 | [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]
22 | (system: import ./ci/hydra.nix {
23 | inherit system;
24 | pkgs = self.legacyPackages.${system};
25 | });
26 |
27 | makePkgs = { system, extraOverlays ? [ ], ... }@attrs:
28 | let
29 | pkgs = import nixpkgs ({
30 | inherit system;
31 | overlays = [ overlay ];
32 | config = {
33 | allowUnfree = true;
34 | } // nixpkgs.lib.optionalAttrs (system == "x86_64-darwin") {
35 | config.replaceStdenv = { pkgs, ... }: pkgs.clang11Stdenv;
36 | };
37 | } // attrs);
38 | in
39 | /*
40 | You might read
41 | https://nixos.org/manual/nixpkgs/stable/#sec-overlays-argument and
42 | want to change this but because of how we're doing overlays we will
43 | be overriding any extraOverlays if we don't use `appendOverlays`
44 | */
45 | pkgs.appendOverlays extraOverlays;
46 |
47 | overlays.default = final: prev: if (prev ? __nix-ocaml-overlays-applied) then { } else overlay final prev;
48 |
49 | legacyPackages = nixpkgs.lib.genAttrs
50 | nixpkgs.lib.systems.flakeExposed
51 | (system: self.makePkgs { inherit system; });
52 | };
53 | }
54 |
--------------------------------------------------------------------------------
/format.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -x
4 |
5 | find . -iname '*.nix' | xargs nix run -f ./sources.nix nixpkgs-fmt -c nixpkgs-fmt $@
6 |
--------------------------------------------------------------------------------
/ocaml/0001-rename-labels.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/reason-parser/reason_syntax_util.cppo.ml b/src/reason-parser/reason_syntax_util.cppo.ml
2 | index 3394652..32964bd 100644
3 | --- a/src/reason-parser/reason_syntax_util.cppo.ml
4 | +++ b/src/reason-parser/reason_syntax_util.cppo.ml
5 | @@ -25,7 +25,7 @@ open Parsetree
6 | open Longident
7 |
8 | (* Rename labels in function definition/application and records *)
9 | -let rename_labels = ref false
10 | +let rename_labels = ref true
11 |
12 | (** Check to see if the string `s` is made up of `keyword` and zero or more
13 | trailing `_` characters. *)
14 |
--------------------------------------------------------------------------------
/ocaml/archi/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, archi, async }:
2 |
3 | buildDunePackage {
4 | pname = "archi-async";
5 | inherit (archi) version src;
6 | propagatedBuildInputs = [ archi async ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/archi/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, alcotest, hmap }:
2 |
3 | buildDunePackage {
4 | pname = "archi";
5 | version = "0.1.1-dev";
6 |
7 | src = fetchFromGitHub {
8 | owner = "anmonteiro";
9 | repo = "archi";
10 | rev = "d60925750d55166c799cb2685e9ed1d1382a2d6a";
11 | hash = "sha256-Ce+RXI3bo68031zqD/G5NKYg9feVXWwqmto6xZb6rwM=";
12 | };
13 |
14 | checkInputs = [ alcotest ];
15 | propagatedBuildInputs = [ hmap ];
16 | }
17 |
--------------------------------------------------------------------------------
/ocaml/archi/eio.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, archi, eio }:
2 |
3 | buildDunePackage {
4 | pname = "archi-eio";
5 | inherit (archi) version src;
6 | propagatedBuildInputs = [ archi eio ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/archi/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, archi, lwt }:
2 |
3 | buildDunePackage {
4 | pname = "archi-lwt";
5 | inherit (archi) version src;
6 | propagatedBuildInputs = [ archi lwt ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/camlpstreams.patch:
--------------------------------------------------------------------------------
1 | diff --git a/lib/dune b/lib/dune
2 | index 087f7b9..ab6ac1c 100644
3 | --- a/lib/dune
4 | +++ b/lib/dune
5 | @@ -34,4 +34,5 @@
6 | (public_name yojson)
7 | (modules yojson)
8 | (synopsis "JSON parsing and printing")
9 | + (libraries camlp-streams)
10 | (flags (-safe-string)))
11 |
--------------------------------------------------------------------------------
/ocaml/camomile.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Camomile/dune b/Camomile/dune
2 | index 8387923..7df1a75 100644
3 | --- a/Camomile/dune
4 | +++ b/Camomile/dune
5 | @@ -9,7 +9,7 @@
6 | (name camomileLibrary)
7 | (public_name camomile.library)
8 | (wrapped true)
9 | - (libraries bigarray camomileDefaultConfig)
10 | + (libraries bigarray camomileDefaultConfig camlp-streams)
11 | (modules
12 | :standard \ camomileDefaultConfig
13 | camomile_do_not_use
14 | diff --git a/Camomile/internal/byte_labeled_dag.ml b/Camomile/internal/byte_labeled_dag.ml
15 | index 48cb354..e3a1101 100644
16 | --- a/Camomile/internal/byte_labeled_dag.ml
17 | +++ b/Camomile/internal/byte_labeled_dag.ml
18 | @@ -87,7 +87,7 @@ let make_bytes def vs =
19 | branch.(Char.code c') <- Some node;
20 | scan d c leaf branch rest
21 | in
22 | - let comp (s1, _) (s2, _) = Pervasives.compare s1 s2 in
23 | + let comp (s1, _) (s2, _) = Stdlib.compare s1 s2 in
24 | let vs = List.sort comp vs in
25 | match vs with
26 | (_, _) :: _ ->
27 | diff --git a/Camomile/internal/unidata.ml b/Camomile/internal/unidata.ml
28 | index 5027a8b..d74c6cb 100644
29 | --- a/Camomile/internal/unidata.ml
30 | +++ b/Camomile/internal/unidata.ml
31 | @@ -299,13 +299,6 @@ module Make (Config : ConfigInt.Type) = struct
32 | | `Buhid
33 | | `Tagbanwa ]
34 |
35 | - (* little hack to maintain 4.02.3 compat with warnings *)
36 | - module String = struct
37 | - [@@@ocaml.warning "-3-32"]
38 | - let lowercase_ascii = StringLabels.lowercase
39 | - include String
40 | - end
41 | -
42 | let script_of_name name =
43 | match String.lowercase_ascii name with
44 | | "common" -> `Common
45 | diff --git a/Camomile/public/charEncoding.ml b/Camomile/public/charEncoding.ml
46 | index 7b7939c..f78926f 100644
47 | --- a/Camomile/public/charEncoding.ml
48 | +++ b/Camomile/public/charEncoding.ml
49 | @@ -131,12 +131,12 @@ module type Interface = sig
50 | {!OOChannel.obj_output_channel} which
51 | receives Unicode characters and outputs them to [outchan] using
52 | the encoding [enc]. *)
53 | - class out_channel : t -> Pervasives.out_channel -> [UChar.t] obj_output_channel
54 | + class out_channel : t -> Stdlib.out_channel -> [UChar.t] obj_output_channel
55 |
56 | (** [new in_channel enc inchan] creates the intput channel object
57 | {!OOChannel.obj_input_channel} which
58 | reads bytes from [inchan] and converts them to Unicode characters. *)
59 | - class in_channel : t -> Pervasives.in_channel -> [UChar.t] obj_input_channel
60 | + class in_channel : t -> Stdlib.in_channel -> [UChar.t] obj_input_channel
61 |
62 | (** [ustream_of enc chars] converts the byte stream [chars]
63 | to the Unicode character stream by the encoding [enc]. *)
64 | diff --git a/Camomile/public/charEncoding.mli b/Camomile/public/charEncoding.mli
65 | index b9e0979..07e0a16 100644
66 | --- a/Camomile/public/charEncoding.mli
67 | +++ b/Camomile/public/charEncoding.mli
68 | @@ -130,12 +130,12 @@ module type Interface = sig
69 | {!OOChannel.obj_output_channel} which
70 | receives Unicode characters and outputs them to [outchan] using
71 | the encoding [enc]. *)
72 | - class out_channel : t -> Pervasives.out_channel -> [UChar.t] obj_output_channel
73 | + class out_channel : t -> Stdlib.out_channel -> [UChar.t] obj_output_channel
74 |
75 | (** [new in_channel enc inchan] creates the intput channel object
76 | {!OOChannel.obj_input_channel} which
77 | reads bytes from [inchan] and converts them to Unicode characters. *)
78 | - class in_channel : t -> Pervasives.in_channel -> [UChar.t] obj_input_channel
79 | + class in_channel : t -> Stdlib.in_channel -> [UChar.t] obj_input_channel
80 |
81 | (** [ustream_of enc chars] converts the byte stream [chars]
82 | to the Unicode character stream by the encoding [enc]. *)
83 | diff --git a/Camomile/public/oOChannel.mli b/Camomile/public/oOChannel.mli
84 | index 716ec40..6c8b796 100644
85 | --- a/Camomile/public/oOChannel.mli
86 | +++ b/Camomile/public/oOChannel.mli
87 | @@ -113,7 +113,7 @@ class char_obj_output_channel_of : char_output_channel ->
88 | [char] obj_output_channel
89 |
90 | (** Convert an OCaml input channel to an OO-based character input channel *)
91 | -class of_in_channel : Pervasives.in_channel -> char_input_channel
92 | +class of_in_channel : Stdlib.in_channel -> char_input_channel
93 |
94 | (** Convert an OCaml output channel to an OO-based character output channel *)
95 | -class of_out_channel : Pervasives.out_channel -> char_output_channel
96 | +class of_out_channel : Stdlib.out_channel -> char_output_channel
97 | diff --git a/Camomile/public/uCS4.ml b/Camomile/public/uCS4.ml
98 | index 02f83e9..f3dbe4e 100644
99 | --- a/Camomile/public/uCS4.ml
100 | +++ b/Camomile/public/uCS4.ml
101 | @@ -140,5 +140,5 @@ end
102 |
103 | let compare (a:t) (b:t) =
104 | match Array1.dim a - Array1.dim b with
105 | - 0 -> Pervasives.compare a b
106 | + 0 -> Stdlib.compare a b
107 | | sgn -> sgn
108 | diff --git a/Camomile/public/uCol.ml b/Camomile/public/uCol.ml
109 | index cc4c0cd..752593d 100644
110 | --- a/Camomile/public/uCol.ml
111 | +++ b/Camomile/public/uCol.ml
112 | @@ -52,14 +52,14 @@ sig
113 | If [prec] is omitted, the maximum possible strength is used.
114 | If [variable] is omitted, the default of the locale
115 | (usually [`Shifted]) is used.
116 | - The meaning of the returned value is similar to Pervasives.compare *)
117 | + The meaning of the returned value is similar to Stdlib.compare *)
118 | val compare :
119 | ?locale:string -> ?prec:precision -> ?variable:variable_option ->
120 | text -> text -> int
121 |
122 | (** Binary comparison of sort_key gives the same result as [compare].
123 | i.e.
124 | - [compare t1 t2 = Pervasives.compare (sort_key t1) (sort_key t2)]
125 | + [compare t1 t2 = Stdlib.compare (sort_key t1) (sort_key t2)]
126 | If the same texts are repeatedly compared,
127 | pre-computation of sort_key gives better performance. *)
128 | val sort_key :
129 | @@ -731,7 +731,7 @@ module Make (Config : ConfigInt.Type) (Text : UnicodeString.Type) = struct
130 | | _ ->
131 | let key1 = key_of_inc prec col_info x1 in
132 | let key2 = key_of_inc prec col_info x2 in
133 | - Pervasives.compare key1 key2
134 | + Stdlib.compare key1 key2
135 |
136 | let compare ?locale ?prec ?variable t1 t2 =
137 | let col_info =
138 | @@ -782,7 +782,7 @@ module Make (Config : ConfigInt.Type) (Text : UnicodeString.Type) = struct
139 | | _ ->
140 | let key = key_of_inc prec col_info x in
141 | (* Printf.printf "key_of_inc %s\n" (String.escaped key);*)
142 | - Pervasives.compare k key
143 | + Stdlib.compare k key
144 |
145 | let compare_with_key ?locale ?prec ?variable k t =
146 | let col_info =
147 | diff --git a/Camomile/public/uTF8.ml b/Camomile/public/uTF8.ml
148 | index fc62c1a..2306cb6 100644
149 | --- a/Camomile/public/uTF8.ml
150 | +++ b/Camomile/public/uTF8.ml
151 | @@ -194,7 +194,7 @@ let rec iter_aux proc s i =
152 |
153 | let iter proc s = iter_aux proc s 0
154 |
155 | -let compare s1 s2 = Pervasives.compare s1 s2
156 | +let compare s1 s2 = Stdlib.compare s1 s2
157 |
158 | exception Malformed_code
159 |
160 | diff --git a/Camomile/tools/dune b/Camomile/tools/dune
161 | index 4e06e8f..9c1988b 100644
162 | --- a/Camomile/tools/dune
163 | +++ b/Camomile/tools/dune
164 | @@ -12,7 +12,7 @@
165 | camomilestringprep)
166 | (flags -I Camomile :standard)
167 | (modules :standard \ camomilelocaledef camomilelocaledef_lexer iana)
168 | - (libraries toolslib camomile camomile.library))
169 | + (libraries toolslib camomile camomile.library camlp-streams))
170 |
171 | (executable
172 | (name iana)
173 | @@ -21,6 +21,6 @@
174 |
175 | (executable
176 | (name camomilelocaledef)
177 | - (libraries toolslib camomile.library)
178 | + (libraries toolslib camomile.library camlp-streams)
179 | (flags -I Camomile :standard)
180 | (modules camomilelocaledef camomilelocaledef_lexer))
181 | diff --git a/Camomile/tools/parse_specialcasing.ml b/Camomile/tools/parse_specialcasing.ml
182 | index 1d0a483..d3a62ac 100644
183 | --- a/Camomile/tools/parse_specialcasing.ml
184 | +++ b/Camomile/tools/parse_specialcasing.ml
185 | @@ -49,13 +49,6 @@ let us_of_codes codes = List.map uchar_of_code codes
186 | let not_pat = Str.regexp "not_\\(.*\\)"
187 | let locale_pat = Str.regexp "\\(..\\)\\(_\\(..\\)\\)?\\(_\\(.+\\)\\)?"
188 |
189 | -(* little hack to maintain 4.02.3 compat with warnings *)
190 | -module String = struct
191 | - [@@@ocaml.warning "-3-32"]
192 | - let lowercase_ascii = StringLabels.lowercase
193 | - include String
194 | -end
195 | -
196 | let rec parse_condition condition =
197 | let s = String.lowercase_ascii condition in
198 | match s with
199 | diff --git a/Camomile/toolslib/absCe.ml b/Camomile/toolslib/absCe.ml
200 | index e18e950..8d20b84 100644
201 | --- a/Camomile/toolslib/absCe.ml
202 | +++ b/Camomile/toolslib/absCe.ml
203 | @@ -49,7 +49,7 @@ type elt =
204 | | `FirstImplicit
205 | | `FirstTrailing ]
206 |
207 | -module Elt = struct type t = elt let compare = Pervasives.compare end
208 | +module Elt = struct type t = elt let compare = Stdlib.compare end
209 | module EltMap = Map.Make (Elt)
210 |
211 | type ce = AbsOrd.point * AbsOrd.point * AbsOrd.point
212 |
--------------------------------------------------------------------------------
/ocaml/compiler-libs-flambda2.META:
--------------------------------------------------------------------------------
1 | version = "5.1.1"
2 | description = "compiler-libs support library"
3 |
4 | package "common" (
5 | requires = "compiler-libs"
6 | version = "5.1.1"
7 | description = "Common compiler routines"
8 | archive(byte) = "ocamlcommon.cma"
9 | archive(native) = "ocamlcommon.cmxa"
10 | )
11 |
12 | package "bytecomp" (
13 | requires = "compiler-libs.common"
14 | version = "5.1.1"
15 | description = "Bytecode compiler"
16 | archive(byte) = "ocamlbytecomp.cma"
17 | archive(native) = "ocamlbytecomp.cmxa"
18 | )
19 |
20 | package "optcomp" (
21 | requires = "compiler-libs.common"
22 | version = "5.1.1"
23 | description = "Native-code compiler"
24 | archive(byte) = "ocamloptcomp.cma"
25 | archive(native) = "ocamloptcomp.cmxa"
26 | exists_if = "ocamloptcomp.cma"
27 | )
28 |
29 | package "toplevel" (
30 | requires = "compiler-libs.bytecomp"
31 | version = "5.1.1"
32 | description = "Toplevel interactions"
33 | archive(byte) = "ocamltoplevel.cma"
34 | )
35 |
36 | package "native-toplevel" (
37 | requires = "compiler-libs.optcomp dynlink"
38 | version = "5.1.1"
39 | description = "Toplevel interactions"
40 | archive(native) = "ocamltoplevel.cmxa"
41 | exists_if = "ocamltoplevel.cmxa"
42 | )
43 |
44 | package "flambda-backend-utils" (
45 | requires = "compiler-libs.common"
46 | version = "5.1.1"
47 | description = "Flambda Backend tools"
48 | archive(byte) = "flambda_backend_utils.cma"
49 | archive(native) = "flambda_backend_utils.cmxa"
50 | )
51 |
--------------------------------------------------------------------------------
/ocaml/conan/cli.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, conan, conan-database, conan-unix, dune-site }:
2 |
3 | buildDunePackage {
4 | inherit (conan) version src;
5 | pname = "conan-cli";
6 | propagatedBuildInputs = [ conan conan-database conan-unix dune-site ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/conan/database.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, conan }:
2 |
3 | buildDunePackage {
4 | inherit (conan) version src;
5 | pname = "conan-database";
6 | propagatedBuildInputs = [ conan ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/conan/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , alcotest
3 | , crowbar
4 | , fetchFromGitHub
5 | , fmt
6 | , rresult
7 | , mirage
8 | , mirage-unix
9 | , mirage-bootvar-unix
10 | , mirage-clock-unix
11 | , mirage-logs
12 | , mirage-runtime
13 | , re
14 | , uutf
15 | , ptime
16 | }:
17 |
18 | buildDunePackage {
19 | pname = "conan";
20 | version = "0.0.1";
21 | src = fetchFromGitHub {
22 | owner = "mirage";
23 | repo = "conan";
24 | # https://github.com/mirage/conan/pull/34
25 | rev = "1ac2302cd2be8f40c33831b935e92dc108ef2e34";
26 | hash = "sha256-1HEqmK/HCvKxW7vv+zn40wT9TlHgEzw0cMJDXSRKTvE=";
27 | };
28 |
29 | propagatedBuildInputs = [ re uutf ptime ];
30 | }
31 |
--------------------------------------------------------------------------------
/ocaml/conan/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, conan, lwt, bigstringaf }:
2 |
3 | buildDunePackage {
4 | pname = "conan-lwt";
5 | inherit (conan) version src;
6 | propagatedBuildInputs = [ conan lwt bigstringaf ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/conan/unix.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, conan }:
2 |
3 | buildDunePackage {
4 | inherit (conan) version src;
5 | pname = "conan-unix";
6 | propagatedBuildInputs = [ conan ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/cookie/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, lib, buildDunePackage, uri, ptime, astring }:
2 |
3 | buildDunePackage {
4 | pname = "cookie";
5 | version = "0.1.8-dev";
6 |
7 | src = fetchFromGitHub {
8 | owner = "ulrikstrid";
9 | repo = "ocaml-cookie";
10 | rev = "95592ac37dc9209cf4f07544156aad7c3187dbab";
11 | sha256 = "sha256-souA7AOa59tu4Tdh7UEZm67YAz+1aR3asRZxk35WcHA=";
12 | };
13 |
14 | propagatedBuildInputs = [ uri ptime astring ];
15 |
16 | meta = {
17 | description = "Cookie parsing and serialization for OCaml";
18 | license = lib.licenses.bsd3;
19 | };
20 | }
21 |
--------------------------------------------------------------------------------
/ocaml/dataloader/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage }:
2 |
3 | buildDunePackage {
4 | pname = "dataloader";
5 | version = "0.0.1-dev";
6 |
7 | src = builtins.fetchurl {
8 | url = "https://github.com/anmonteiro/ocaml-dataloader/archive/c2e6d7d057d4453b36511a5d293e9ab502755484.tar.gz";
9 | sha256 = "1w4wnwx854358wymdd26xkccyl3lql4j3k3lbr57bd7rv5xpplwq";
10 | };
11 | }
12 |
--------------------------------------------------------------------------------
/ocaml/dataloader/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, dataloader, lwt }:
2 |
3 | buildDunePackage {
4 | pname = "dataloader-lwt";
5 | inherit (dataloader) version src;
6 |
7 | propagatedBuildInputs = [ dataloader lwt ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/decimal/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, zarith }:
2 |
3 | buildDunePackage {
4 | pname = "decimal";
5 | version = "1.0.2";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/yawaramin/ocaml-decimal/releases/download/v1.0.2/decimal-1.0.2.tbz";
8 | sha256 = "0v7y2daqzm4mq7cl16njmkglzan06zm2d2x05i146s8cixdhzfir";
9 | };
10 |
11 | propagatedBuildInputs = [ zarith ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/dream-html/default.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, dream, pure-html }:
2 |
3 | buildDunePackage {
4 | pname = "dream-html";
5 | inherit (pure-html) src version;
6 |
7 | propagatedBuildInputs = [ pure-html dream ];
8 |
9 | meta = {
10 | description =
11 | "Write HTML directly in your OCaml source files with editor support.";
12 | license = lib.licenses.gpl3;
13 | };
14 | }
15 |
--------------------------------------------------------------------------------
/ocaml/dream-html/pure.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, fetchFromGitHub, uri }:
2 |
3 | buildDunePackage {
4 | pname = "pure-html";
5 | version = "3.10.0";
6 |
7 | src = fetchFromGitHub {
8 | owner = "yawaramin";
9 | repo = "dream-html";
10 | rev = "v3.10.0";
11 | sha256 = "sha256-OlO3g+cEP27GjxJZT0jCTRkICLFRLS0jWkitqXeAVX8=";
12 | };
13 |
14 | propagatedBuildInputs = [ uri ];
15 |
16 | meta = {
17 | description =
18 | "Write HTML directly in your OCaml source files with editor support.";
19 | license = lib.licenses.gpl3;
20 | };
21 | }
22 |
--------------------------------------------------------------------------------
/ocaml/dream-livereload/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, dream, lambdasoup, lwt_ppx }:
2 |
3 | buildDunePackage rec {
4 | pname = "dream-livereload";
5 | version = "0.2.0";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/tmattio/dream-livereload/releases/download/0.2.0/dream-livereload-0.2.0.tbz";
8 | sha256 = "1ppq4j823p57w7bmzclmlb035i1mhjwz86alwjr44bjv493h6rgr";
9 | };
10 |
11 | propagatedBuildInputs = [ dream lambdasoup lwt_ppx ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/dream-serve/default.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, dream, lambdasoup, luv, lwt, lwt_ppx }:
2 |
3 | buildDunePackage rec {
4 | pname = "dream-serve";
5 | version = "1.0.0";
6 |
7 | src = builtins.fetchurl {
8 | url = "https://github.com/aantron/dream-serve/archive/refs/tags/${version}.tar.gz";
9 | sha256 = "0sqmy3jjy00laxh1skq69i7mn2lg14sa2ilap8yvjpz2bhgc7cvp";
10 | };
11 |
12 | propagatedBuildInputs = [ dream lambdasoup luv lwt lwt_ppx ];
13 |
14 | meta = {
15 | description = "Static site server with live reload";
16 | license = lib.licenses.mit;
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/ocaml/dream/default.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , buildDunePackage
3 | , caqti
4 | , caqti-lwt
5 | , cstruct
6 | , dream-httpaf
7 | , dream-pure
8 | , fmt
9 | , graphql_parser
10 | , graphql-lwt
11 | , lambdasoup
12 | , lwt
13 | , lwt_ppx
14 | , lwt_ssl
15 | , logs
16 | , magic-mime
17 | , markup
18 | , mirage-clock
19 | , mirage-crypto
20 | , mirage-crypto-rng-lwt
21 | , multipart_form
22 | , multipart_form-lwt
23 | , ptime
24 | , ssl
25 | , uri
26 | , yojson
27 | # test-inputs
28 | , bisect_ppx
29 | , alcotest
30 | , crunch
31 | , ppx_expect
32 | , ppx_yojson_conv_lib
33 | , reason
34 | , tyxml
35 | , tyxml-jsx
36 | , tyxml-ppx
37 | , ocaml
38 | }:
39 |
40 | buildDunePackage rec {
41 | pname = "dream";
42 | inherit (dream-pure) src version;
43 |
44 | postPatch = ''
45 | substituteInPlace src/http/adapt.ml \
46 | --replace-fail \
47 | "Httpun.Body.Writer.flush body" \
48 | "fun f -> Httpun.Body.Writer.flush body (fun _r -> f ())" \
49 | --replace-fail \
50 | "H2.Body.Writer.flush body" \
51 | "fun f -> H2.Body.Writer.flush body (fun _r -> f ())"
52 | '';
53 |
54 | propagatedBuildInputs = [
55 | caqti
56 | caqti-lwt
57 | cstruct
58 | dream-httpaf
59 | dream-pure
60 | fmt
61 | graphql_parser
62 | graphql-lwt
63 | lwt
64 | lwt_ppx
65 | lwt_ssl
66 | logs
67 | magic-mime
68 | mirage-clock
69 | mirage-crypto
70 | mirage-crypto-rng-lwt
71 | multipart_form
72 | multipart_form-lwt
73 | ptime
74 | ssl
75 | uri
76 | yojson
77 | lambdasoup
78 | markup
79 | ];
80 |
81 | buildInputs = [
82 | bisect_ppx
83 | ];
84 |
85 | checkInputs = [
86 | alcotest
87 | crunch
88 | ppx_expect
89 | ppx_yojson_conv_lib
90 | reason
91 | tyxml
92 | tyxml-jsx
93 | tyxml-ppx
94 | ];
95 |
96 | doCheck = !(lib.versionAtLeast ocaml.version "5.0");
97 | meta = {
98 | description = "Easy-to-use, feature-complete Web framework without boilerplate";
99 | license = lib.licenses.mit;
100 | };
101 | }
102 |
--------------------------------------------------------------------------------
/ocaml/dream/httpaf.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , buildDunePackage
3 | , dream-pure
4 | , lwt
5 | , lwt_ppx
6 | , lwt_ssl
7 | , ssl
8 | , h2-lwt-unix
9 | , httpun-lwt-unix
10 | , httpun-ws
11 | }:
12 |
13 | buildDunePackage rec {
14 | pname = "dream-httpaf";
15 | inherit (dream-pure) src version;
16 |
17 | propagatedBuildInputs = [
18 | dream-pure
19 | lwt
20 | lwt_ppx
21 | lwt_ssl
22 | ssl
23 |
24 | httpun-lwt-unix
25 | h2-lwt-unix
26 | httpun-ws
27 | ];
28 |
29 | doCheck = false;
30 |
31 | meta = {
32 | description = "Easy-to-use, feature-complete Web framework without boilerplate";
33 | license = lib.licenses.mit;
34 | };
35 | }
36 |
--------------------------------------------------------------------------------
/ocaml/dream/pure.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , fetchFromGitHub
3 | , buildDunePackage
4 | , base64
5 | , bigstringaf
6 | , hmap
7 | , lwt
8 | , lwt_ppx
9 | , ptime
10 | , uri
11 | , ppx_expect
12 | , alcotest
13 | , ppx_yojson_conv_lib
14 | , bisect_ppx
15 | }:
16 |
17 | buildDunePackage rec {
18 | pname = "dream-pure";
19 | version = "1.0.0-alpha8";
20 | src = fetchFromGitHub {
21 | owner = "aantron";
22 | repo = "dream";
23 | rev = "1.0.0-alpha8";
24 | hash = "sha256-AJBszLOUVwCXDqryNUkak4UlbmofCkxBIPEm4M0nHEI=";
25 | };
26 |
27 | propagatedBuildInputs = [
28 | base64
29 | bigstringaf
30 | hmap
31 | lwt
32 | lwt_ppx
33 | ptime
34 | uri
35 | ];
36 |
37 | checkInputs = [
38 | ppx_expect
39 | alcotest
40 | ppx_yojson_conv_lib
41 | bisect_ppx
42 | ];
43 |
44 | doCheck = false;
45 |
46 | meta = {
47 | description = "Easy-to-use, feature-complete Web framework without boilerplate";
48 | license = lib.licenses.mit;
49 | };
50 | }
51 |
--------------------------------------------------------------------------------
/ocaml/dune/rpc-lwt.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, dune, dune-rpc, lwt, csexp, dyn, result }:
2 |
3 |
4 | buildDunePackage {
5 | pname = "dune-rpc-lwt";
6 | inherit (dune) src version;
7 |
8 | propagatedBuildInputs = [ csexp dune-rpc lwt result ];
9 | dontAddPrefix = true;
10 | inherit (dyn) preBuild;
11 | }
12 |
--------------------------------------------------------------------------------
/ocaml/eio-ssl/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, ssl, eio }:
2 |
3 | buildDunePackage {
4 | pname = "eio-ssl";
5 | version = "n/a";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/anmonteiro/eio-ssl/releases/download/0.3.0/eio-ssl-0.3.0.tbz";
8 | sha256 = "02pjffsbyvsdi43948xqpnr8x65n3z00wnyq5qgj6map1d8s504v";
9 | };
10 | propagatedBuildInputs = [ ssl eio ];
11 | }
12 |
--------------------------------------------------------------------------------
/ocaml/eio/lwt_eio.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, lib, buildDunePackage, lwt, eio }:
2 |
3 | buildDunePackage {
4 | pname = "lwt_eio";
5 | version = "0.5.1";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/ocaml-multicore/lwt_eio/releases/download/v0.5.1/lwt_eio-0.5.1.tbz";
8 | sha256 = "08bc9yxdzjll0ig1fnkr3wyk0bqx6nkncjfns2xd6m3qg226flkn";
9 | };
10 |
11 | propagatedBuildInputs = [ lwt eio ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/flambda2-compiler-libs.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/read_cma/read_cma.ml b/src/read_cma/read_cma.ml
2 | --- a/src/read_cma/read_cma.ml
3 | +++ b/src/read_cma/read_cma.ml
4 | @@ -11,5 +11,6 @@ let units fn =
5 | let toc = (input_value ic : Cmo_format.library) in
6 | close_in ic;
7 |
8 | - List.map toc.lib_units ~f:(fun cu -> cu.Cmo_format.cu_name)
9 | + List.map toc.lib_units
10 | + ~f:(fun cu -> cu.Cmo_format.cu_name |> Compilation_unit.name |> Compilation_unit.Name.to_string)
11 | |> List.sort ~cmp:String.compare
12 |
--------------------------------------------------------------------------------
/ocaml/flambda2-ocamlbuild.patch:
--------------------------------------------------------------------------------
1 | diff --git a/Makefile b/Makefile
2 | index 3039625..1344f79 100644
3 | --- a/Makefile
4 | +++ b/Makefile
5 | @@ -412,10 +412,22 @@ endif
6 |
7 | # The generic rules
8 |
9 | -%.cmo: %.ml
10 | +src/%.cmo: src/%.ml
11 | + $(OCAMLC) -for-pack Ocamlbuild_pack $(OCB_COMPFLAGS) -c $<
12 | +
13 | +bin/%.cmo: bin/%.ml
14 | + $(OCAMLC) $(OCB_COMPFLAGS) -c $<
15 | +
16 | +plugin-lib/%.cmo: plugin-lib/%.ml
17 | + $(OCAMLC) $(OCB_COMPFLAGS) -c $<
18 | +
19 | +src/%.cmi: src/%.mli
20 | + $(OCAMLC) -for-pack Ocamlbuild_pack $(OCB_COMPFLAGS) -c $<
21 | +
22 | +bin/%.cmi: bin/%.mli
23 | $(OCAMLC) $(OCB_COMPFLAGS) -c $<
24 |
25 | -%.cmi: %.mli
26 | +plugin-lib/%.cmi: plugin-lib/%.mli
27 | $(OCAMLC) $(OCB_COMPFLAGS) -c $<
28 |
29 | src/%.cmx: src/%.ml
30 | diff --git a/src/configuration.ml b/src/configuration.ml
31 | index a209df5..ec620d0 100644
32 | --- a/src/configuration.ml
33 | +++ b/src/configuration.ml
34 | @@ -58,6 +58,14 @@ let apply_config s (config : t) init =
35 | List.fold_left begin fun tags (key, v) ->
36 | if key_match key s then
37 | List.fold_right add v.plus_tags (List.fold_right remove v.minus_tags tags)
38 | + else if
39 | + List.mem (Filename.extension s) [".ml"; ".mli"]
40 | + && key_match key (Filename.remove_extension s ^ ".cmx")
41 | + then
42 | + let only_for_pack l =
43 | + List.filter (fun (tag, _) -> String.length tag >= 9 && String.sub tag 0 9 = "for-pack(") l
44 | + in
45 | + List.fold_right add (only_for_pack v.plus_tags) (List.fold_right remove (only_for_pack v.minus_tags) tags)
46 | else tags
47 | end init config
48 |
49 |
--------------------------------------------------------------------------------
/ocaml/flambda2.patch:
--------------------------------------------------------------------------------
1 | diff --git a/ocaml/configure.ac b/ocaml/configure.ac
2 | index d1224de9b..f96dd706d 100644
3 | --- a/ocaml/configure.ac
4 | +++ b/ocaml/configure.ac
5 | @@ -2125,7 +2125,18 @@ AS_CASE([$host],
6 | [*-pc-windows],
7 | [PTHREAD_LIBS="-l:libpthread.lib"],
8 | [*-apple-darwin*],
9 | - [PTHREAD_LIBS="-pthread"],
10 | + [PTHREAD_LIBS="-pthread"
11 | + AX_PTHREAD(
12 | + [common_cflags="$common_cflags $PTHREAD_CFLAGS"
13 | + saved_CFLAGS="$CFLAGS"
14 | + saved_LIBS="$LIBS"
15 | + CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
16 | + LIBS="$LIBS $PTHREAD_LIBS"
17 | + AC_CHECK_FUNC([sigwait], [AC_DEFINE([HAS_SIGWAIT])])
18 | + LIBS="$saved_LIBS"
19 | + CFLAGS="$saved_CFLAGS"],
20 | + [AC_MSG_ERROR(m4_normalize([POSIX threads are required but not supported on
21 | + this platform]))])],
22 | [AX_PTHREAD(
23 | [common_cflags="$common_cflags $PTHREAD_CFLAGS"
24 | saved_CFLAGS="$CFLAGS"
25 | diff --git a/ocaml/parsing/dune b/ocaml/parsing/dune
26 | index 6933891b2..79d9cf60f 100644
27 | --- a/ocaml/parsing/dune
28 | +++ b/ocaml/parsing/dune
29 | @@ -18,14 +18,22 @@
30 | (with-stdout-to %{targets}
31 | ;; Partial applications of the form Obj.magic f x in menhirLib cause
32 | ;; an issue with locals, so rewrite these to Obj.magic (f x)
33 | - (bash "cat $(menhir --suggest-menhirLib)/menhirLib.ml |
34 | + (bash "menhir_file_path=\"$(menhir --suggest-menhirLib 2>/dev/null)/menhirLib.ml\"
35 | + if [ ! -f \"$menhir_file_path\" ]; then
36 | + menhir_file_path=\"$(ocamlfind query menhirLib)/menhirLib.ml\"
37 | + fi
38 | + cat \"$menhir_file_path\" |
39 | sed 's/\\b\\(in\\|then\\|with\\|else\\)\\b/@@@\\1/g; s/Obj.magic \\([a-z0-9_]\\+\\( [a-z0-9_]\\+\\)\\+\\)/Obj.magic (\\1)/g; s/@@@//g'"))))
40 |
41 | (rule
42 | (targets camlinternalMenhirLib.mli)
43 | (action
44 | (with-stdout-to %{targets}
45 | - (bash "cat $(menhir --suggest-menhirLib)/menhirLib.mli"))))
46 | + (bash "menhir_file_path=\"$(menhir --suggest-menhirLib 2>/dev/null)/menhirLib.mli\"
47 | + if [ ! -f \"$menhir_file_path\" ]; then
48 | + menhir_file_path=\"$(ocamlfind query menhirLib)/menhirLib.mli\"
49 | + fi
50 | + cat \"$menhir_file_path\""))))
51 |
52 | (ocamllex
53 | (modules lexer)
54 |
--------------------------------------------------------------------------------
/ocaml/flow_parser/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, base, ppx_deriving, ppx_gen_rec, sedlex, wtf8 }:
2 |
3 | buildDunePackage {
4 | pname = "flow_parser";
5 | version = "0.251.1";
6 | src = fetchFromGitHub {
7 | owner = "facebook";
8 | repo = "flow";
9 | rev = "v0.251.1";
10 | hash = "sha256-if8CTYSDi9Wh3P7JLlKV4B6hU1LFVx5kyVINJEJ6dNU=";
11 | };
12 |
13 | postPatch = ''
14 | substituteInPlace "src/parser/dune" \
15 | --replace-fail \
16 | 'public_name flow_parser)' \
17 | 'public_name flow_parser) (flags :standard -warn-error -53)'
18 | '';
19 |
20 | propagatedBuildInputs = [
21 | base
22 | ppx_deriving
23 | ppx_gen_rec
24 | sedlex
25 | wtf8
26 | ];
27 | }
28 |
--------------------------------------------------------------------------------
/ocaml/gluten/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, faraday-async, gluten }:
2 |
3 | buildDunePackage {
4 | pname = "gluten-async";
5 | inherit (gluten) src version;
6 |
7 | propagatedBuildInputs = [ faraday-async gluten ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/gluten/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, bigstringaf, faraday }:
2 |
3 | buildDunePackage {
4 | pname = "gluten";
5 | version = "0.5.2";
6 |
7 | src = builtins.fetchurl {
8 | url = "https://github.com/anmonteiro/gluten/releases/download/0.5.2/gluten-0.5.2.tbz";
9 | sha256 = "0pq1ww3p41m6dzk2cmrr7pq03kvb5hjqvk49s95vp030kygxivmi";
10 | };
11 | propagatedBuildInputs = [ bigstringaf faraday ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/gluten/eio.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, gluten, eio, eio_main, eio-ssl }:
2 |
3 | buildDunePackage {
4 | pname = "gluten-eio";
5 | inherit (gluten) src version;
6 |
7 | propagatedBuildInputs = [ gluten eio eio_main eio-ssl ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/gluten/lwt-unix.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, gluten, faraday-lwt-unix, gluten-lwt, lwt_ssl }:
2 |
3 | buildDunePackage {
4 | pname = "gluten-lwt-unix";
5 | inherit (gluten) src version;
6 |
7 | propagatedBuildInputs = [
8 | faraday-lwt-unix
9 | gluten-lwt
10 | lwt_ssl
11 | ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/gluten/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, gluten, lwt }:
2 |
3 | buildDunePackage {
4 | pname = "gluten-lwt";
5 | propagatedBuildInputs = [ gluten lwt ];
6 | inherit (gluten) src version;
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/gluten/mirage.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , faraday-lwt
3 | , gluten
4 | , gluten-lwt
5 | , mirage-flow
6 | , cstruct
7 | }:
8 |
9 | buildDunePackage {
10 | pname = "gluten-mirage";
11 | inherit (gluten) src version;
12 |
13 | propagatedBuildInputs = [
14 | faraday-lwt
15 | gluten-lwt
16 | mirage-flow
17 | cstruct
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/ocaml/graphql/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, graphql, async, alcotest }:
2 |
3 | buildDunePackage {
4 | pname = "graphql-async";
5 | inherit (graphql) src version;
6 | checkInputs = [ alcotest ];
7 | propagatedBuildInputs = [ graphql async ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/graphql/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, graphql_parser, yojson, rresult, seq, alcotest }:
2 |
3 | buildDunePackage {
4 | pname = "graphql";
5 | inherit (graphql_parser) src version;
6 | checkInputs = [ alcotest ];
7 | propagatedBuildInputs = [ graphql_parser yojson rresult seq ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/graphql/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, graphql, lwt, alcotest }:
2 |
3 | buildDunePackage {
4 | pname = "graphql-lwt";
5 | inherit (graphql) src version;
6 | checkInputs = [ alcotest ];
7 | propagatedBuildInputs = [ graphql lwt ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/graphql/parser.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, alcotest, menhir, fmt, re }:
2 |
3 | buildDunePackage {
4 | pname = "graphql_parser";
5 | version = "0.13.0-dev";
6 | src = fetchFromGitHub {
7 | owner = "anmonteiro";
8 | repo = "ocaml-graphql-server";
9 | rev = "0a5357d10364ecaf9aa17a3891c12481a713f7e2";
10 | hash = "sha256-VBkVB7EGjPECduWZlQdYO27VEFhT74MouOaz+dV5m+w=";
11 | };
12 |
13 | nativeBuildInputs = [ menhir ];
14 | checkInputs = [ alcotest ];
15 | propagatedBuildInputs = [ menhir fmt re ];
16 | }
17 |
--------------------------------------------------------------------------------
/ocaml/graphql_ppx/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, cppo, yojson, ppxlib, reason }:
2 |
3 | buildDunePackage {
4 | pname = "graphql_ppx";
5 | version = "1.2.3";
6 |
7 | src = fetchFromGitHub {
8 | owner = "teamwalnut";
9 | repo = "graphql-ppx";
10 | rev = "1345e061a92394b651b5ac65a035fda4190292e4";
11 | sha256 = "sha256-WJXEnM4/T0McoP4/S57WpMd4tjW8V+vShPOL8oCJRko=";
12 | };
13 |
14 | nativeBuildInputs = [ cppo ];
15 | propagatedBuildInputs = [ yojson ppxlib reason ];
16 |
17 | postInstall = ''
18 | mkdir -p $out/lib-runtime
19 | cp -r ./package.json ./bsconfig.json ./rescript-runtime $out/lib-runtime
20 | '';
21 | }
22 |
--------------------------------------------------------------------------------
/ocaml/h2/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, h2, async, gluten-async, faraday-async, async_ssl }:
2 |
3 | buildDunePackage {
4 | inherit (h2) src version;
5 | pname = "h2-async";
6 | doCheck = false;
7 |
8 | propagatedBuildInputs = [ h2 async gluten-async faraday-async async_ssl ];
9 | }
10 |
--------------------------------------------------------------------------------
/ocaml/h2/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, angstrom, faraday, base64, psq, hpack, httpun-types }:
2 |
3 | buildDunePackage {
4 | inherit (hpack) src;
5 | version = "0.8.0";
6 | pname = "h2";
7 | propagatedBuildInputs = [ angstrom faraday base64 psq hpack httpun-types ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/h2/eio.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , h2
3 | , gluten-eio
4 | , eio_main
5 | }:
6 |
7 | buildDunePackage {
8 | inherit (h2) version src;
9 | pname = "h2-eio";
10 | propagatedBuildInputs = [
11 | h2
12 | gluten-eio
13 | eio_main
14 | ];
15 | }
16 |
--------------------------------------------------------------------------------
/ocaml/h2/hpack.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, angstrom, faraday }:
2 |
3 | buildDunePackage {
4 | pname = "hpack";
5 | version = "0.10.0-dev";
6 |
7 | src = builtins.fetchurl {
8 | url = "https://github.com/anmonteiro/ocaml-h2/releases/download/0.13.0/h2-0.13.0.tbz";
9 | sha256 = "03q7m2ra6ch49z1vwjbmp4qzr0sv3pl3n8h7lbkr8lhpg3qvd28d";
10 | };
11 | propagatedBuildInputs = [ angstrom faraday ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/h2/lwt-unix.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, gluten-lwt-unix, h2, h2-lwt, faraday-lwt-unix, lwt_ssl }:
2 |
3 | buildDunePackage {
4 | inherit (h2) version src;
5 | pname = "h2-lwt-unix";
6 | propagatedBuildInputs = [ gluten-lwt-unix h2-lwt faraday-lwt-unix lwt_ssl ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/h2/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, gluten-lwt, h2, lwt }:
2 |
3 | buildDunePackage {
4 | inherit (h2) version src;
5 | pname = "h2-lwt";
6 | propagatedBuildInputs = [ gluten-lwt h2 lwt ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/h2/mirage.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, h2, h2-lwt, gluten-mirage }:
2 |
3 | buildDunePackage {
4 | inherit (h2) version src;
5 | pname = "h2-mirage";
6 | doCheck = false;
7 | propagatedBuildInputs = [ h2-lwt gluten-mirage ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/httpun-ws/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , httpun-ws
3 | , async
4 | , gluten-async
5 | , faraday-async
6 | , async_ssl
7 | , digestif
8 | }:
9 |
10 | buildDunePackage {
11 | pname = "httpun-ws-async";
12 | inherit (httpun-ws) src version;
13 |
14 | propagatedBuildInputs = [
15 | httpun-ws
16 | async
17 | gluten-async
18 | faraday-async
19 | async_ssl
20 | digestif
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/ocaml/httpun-ws/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub
2 | , buildDunePackage
3 | , angstrom
4 | , faraday
5 | , gluten
6 | , httpun
7 | , base64
8 | }:
9 |
10 | buildDunePackage {
11 | pname = "httpun-ws";
12 | version = "n/a";
13 | src = builtins.fetchurl {
14 | url = "https://github.com/anmonteiro/httpun-ws/releases/download/0.2.0/httpun-ws-0.2.0.tbz";
15 | sha256 = "1zcpqar4qvqfpx390hrf7d8ch3vgd88vfqnqnsfgrd5m1qpcvq7a";
16 | };
17 |
18 | propagatedBuildInputs = [ angstrom faraday gluten httpun base64 ];
19 | }
20 |
--------------------------------------------------------------------------------
/ocaml/httpun-ws/eio.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, httpun-ws, gluten-eio, eio, digestif }:
2 |
3 | buildDunePackage {
4 | pname = "httpun-ws-eio";
5 | inherit (httpun-ws) src version;
6 | propagatedBuildInputs = [ httpun-ws gluten-eio eio digestif ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/httpun-ws/lwt-unix.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , httpun-ws
3 | , httpun-ws-lwt
4 | , faraday-lwt-unix
5 | , gluten-lwt-unix
6 | }:
7 |
8 | buildDunePackage {
9 | pname = "httpun-ws-lwt-unix";
10 | inherit (httpun-ws) src version;
11 |
12 | propagatedBuildInputs = [
13 | httpun-ws
14 | httpun-ws-lwt
15 | faraday-lwt-unix
16 | gluten-lwt-unix
17 | ];
18 | }
19 |
--------------------------------------------------------------------------------
/ocaml/httpun-ws/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, httpun-ws, gluten-lwt, lwt, digestif }:
2 |
3 | buildDunePackage {
4 | pname = "httpun-ws-lwt";
5 | inherit (httpun-ws) src version;
6 | propagatedBuildInputs = [ httpun-ws gluten-lwt lwt digestif ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/httpun-ws/mirage.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , httpun-ws
3 | , httpun-ws-lwt
4 | , gluten-mirage
5 | }:
6 |
7 | buildDunePackage {
8 | pname = "httpun-ws-mirage";
9 | inherit (httpun-ws) src version;
10 |
11 | propagatedBuildInputs = [ httpun-ws-lwt gluten-mirage ];
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/httpun/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , httpun
3 | , async
4 | , gluten-async
5 | , faraday-async
6 | , async_ssl
7 | }:
8 |
9 | buildDunePackage {
10 | inherit (httpun) version src;
11 | pname = "httpun-async";
12 | doCheck = false;
13 | propagatedBuildInputs = [
14 | httpun
15 | async
16 | gluten-async
17 | faraday-async
18 | async_ssl
19 | ];
20 | }
21 |
--------------------------------------------------------------------------------
/ocaml/httpun/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, httpun-types, angstrom, faraday }:
2 |
3 | buildDunePackage {
4 | inherit (httpun-types) version src;
5 | pname = "httpun";
6 | propagatedBuildInputs = [ angstrom faraday httpun-types ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/httpun/eio.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , httpun
3 | , gluten-eio
4 | , eio_main
5 | }:
6 |
7 | buildDunePackage {
8 | inherit (httpun) version src;
9 | pname = "httpun-eio";
10 | propagatedBuildInputs = [
11 | httpun
12 | gluten-eio
13 | eio_main
14 | ];
15 | }
16 |
--------------------------------------------------------------------------------
/ocaml/httpun/lwt-unix.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , httpun
3 | , httpun-lwt
4 | , gluten-lwt-unix
5 | , faraday-lwt-unix
6 | , lwt_ssl
7 | }:
8 |
9 | buildDunePackage {
10 | inherit (httpun) version src;
11 | pname = "httpun-lwt-unix";
12 | propagatedBuildInputs = [
13 | httpun
14 | httpun-lwt
15 | gluten-lwt-unix
16 | faraday-lwt-unix
17 | lwt_ssl
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/ocaml/httpun/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, httpun, gluten-lwt, lwt }:
2 |
3 | buildDunePackage {
4 | pname = "httpun-lwt";
5 | inherit (httpun) version src;
6 | propagatedBuildInputs = [ httpun gluten-lwt lwt ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/httpun/mirage.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, httpun, httpun-lwt, gluten-mirage }:
2 |
3 | buildDunePackage {
4 | inherit (httpun) version src;
5 | pname = "httpun-mirage";
6 | doCheck = false;
7 | propagatedBuildInputs = [ httpun-lwt gluten-mirage ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/httpun/types.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, faraday }:
2 |
3 | buildDunePackage {
4 | version = "0.2.0";
5 | pname = "httpun-types";
6 | propagatedBuildInputs = [ faraday ];
7 |
8 | src = builtins.fetchurl {
9 | url = "https://github.com/anmonteiro/httpun/releases/download/0.2.0/httpun-0.2.0.tbz";
10 | sha256 = "0b5xhyv7sbwls8fnln1lp48v5mlkx3ay7l8820f8xbl59kpjgkm2";
11 | };
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/hyper/0001-Unvendor-and-add-nix.patch:
--------------------------------------------------------------------------------
1 | From ba2c920814805b4c357ad769c24cbadb293cbb2f Mon Sep 17 00:00:00 2001
2 | From: Ulrik Strid
3 | Date: Fri, 20 May 2022 10:51:56 +0200
4 | Subject: [PATCH] Unvendor and add nix
5 |
6 | ---
7 | flake.lock | 83 +++++++++++++++++++++++++++++++++++++++++++++++
8 | flake.nix | 54 ++++++++++++++++++++++++++++++
9 | nix/default.nix | 31 ++++++++++++++++++
10 | src/dune | 6 ++--
11 | src/http/dune | 12 +++----
12 | src/http/http1.ml | 7 ++--
13 | src/http/http2.ml | 12 +++----
14 | 7 files changed, 186 insertions(+), 19 deletions(-)
15 | create mode 100644 flake.lock
16 | create mode 100644 flake.nix
17 | create mode 100644 nix/default.nix
18 |
19 | diff --git a/flake.lock b/flake.lock
20 | new file mode 100644
21 | index 0000000..1f0da95
22 | --- /dev/null
23 | +++ b/flake.lock
24 | @@ -0,0 +1,83 @@
25 | +{
26 | + "nodes": {
27 | + "flake-utils": {
28 | + "locked": {
29 | + "lastModified": 1652776076,
30 | + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
31 | + "owner": "numtide",
32 | + "repo": "flake-utils",
33 | + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
34 | + "type": "github"
35 | + },
36 | + "original": {
37 | + "owner": "numtide",
38 | + "repo": "flake-utils",
39 | + "type": "github"
40 | + }
41 | + },
42 | + "nix-filter": {
43 | + "locked": {
44 | + "lastModified": 1649838635,
45 | + "narHash": "sha256-P1h48+l9vUvMz4JwHBgkTXiX6mE8oYR75vBVUbe6Cuc=",
46 | + "owner": "numtide",
47 | + "repo": "nix-filter",
48 | + "rev": "40a58baa248a8b335e2d66ca258a74248af9d834",
49 | + "type": "github"
50 | + },
51 | + "original": {
52 | + "owner": "numtide",
53 | + "repo": "nix-filter",
54 | + "type": "github"
55 | + }
56 | + },
57 | + "nixpkgs": {
58 | + "locked": {
59 | + "lastModified": 1652885393,
60 | + "narHash": "sha256-YIgvvlk4iQ1Hi7KD9o5gsojc+ApB+jiH1d5stK8uXiw=",
61 | + "owner": "nixos",
62 | + "repo": "nixpkgs",
63 | + "rev": "48037fd90426e44e4bf03e6479e88a11453b9b66",
64 | + "type": "github"
65 | + },
66 | + "original": {
67 | + "owner": "nixos",
68 | + "ref": "nixos-unstable",
69 | + "repo": "nixpkgs",
70 | + "type": "github"
71 | + }
72 | + },
73 | + "ocaml-overlay": {
74 | + "inputs": {
75 | + "flake-utils": [
76 | + "flake-utils"
77 | + ],
78 | + "nixpkgs": [
79 | + "nixpkgs"
80 | + ]
81 | + },
82 | + "locked": {
83 | + "lastModified": 1653027407,
84 | + "narHash": "sha256-XCYCfmUbP5QIU0xl+WAgkhzD88BRMygbpmhfSWSbXEI=",
85 | + "owner": "anmonteiro",
86 | + "repo": "nix-overlays",
87 | + "rev": "a42be0599f9d36b500e296c2b94eb1db57f9a9da",
88 | + "type": "github"
89 | + },
90 | + "original": {
91 | + "owner": "anmonteiro",
92 | + "repo": "nix-overlays",
93 | + "type": "github"
94 | + }
95 | + },
96 | + "root": {
97 | + "inputs": {
98 | + "flake-utils": "flake-utils",
99 | + "nix-filter": "nix-filter",
100 | + "nixpkgs": "nixpkgs",
101 | + "ocaml-overlay": "ocaml-overlay"
102 | + }
103 | + }
104 | + },
105 | + "root": "root",
106 | + "version": 7
107 | +}
108 | diff --git a/flake.nix b/flake.nix
109 | new file mode 100644
110 | index 0000000..2f8b5a9
111 | --- /dev/null
112 | +++ b/flake.nix
113 | @@ -0,0 +1,54 @@
114 | +{
115 | + inputs = {
116 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
117 | + flake-utils.url = "github:numtide/flake-utils";
118 | + nix-filter.url = "github:numtide/nix-filter";
119 | +
120 | + ocaml-overlay.url = "github:nix-ocaml/nix-overlays";
121 | + ocaml-overlay.inputs.nixpkgs.follows = "nixpkgs";
122 | + ocaml-overlay.inputs.flake-utils.follows = "flake-utils";
123 | + };
124 | +
125 | + outputs = { self, nixpkgs, flake-utils, nix-filter, ocaml-overlay }:
126 | + let
127 | + supported_ocaml_versions = [ "ocamlPackages_4_13" "ocamlPackages_5_00" ];
128 | + out = system:
129 | + let
130 | + pkgs = import nixpkgs {
131 | + inherit system;
132 | + overlays = [ ocaml-overlay.overlays."${system}".default ];
133 | + };
134 | + ocamlPackages_dev = pkgs.ocaml-ng.ocamlPackages;
135 | + hyper = (pkgs.callPackage ./nix {
136 | + inherit nix-filter;
137 | + doCheck = true;
138 | + ocamlPackages = ocamlPackages_dev;
139 | + });
140 | + in {
141 | + devShells = {
142 | + default = (pkgs.mkShell {
143 | + inputsFrom = [ hyper ];
144 | + buildInputs = with pkgs;
145 | + with ocamlPackages_dev; [
146 | + ocaml-lsp
147 | + ocamlformat
148 | + odoc
149 | + ocaml
150 | + nixfmt
151 | + ];
152 | + });
153 | + };
154 | +
155 | + formatter = pkgs.nixfmt;
156 | +
157 | + packages = { default = hyper; };
158 | + };
159 | + in with flake-utils.lib;
160 | + eachSystem [
161 | + system.x86_64-linux
162 | + system.aarch64-linux
163 | + system.x86_64-darwin
164 | + system.aarch64-darwin
165 | + ] out;
166 | +
167 | +}
168 | diff --git a/nix/default.nix b/nix/default.nix
169 | new file mode 100644
170 | index 0000000..e97dc1d
171 | --- /dev/null
172 | +++ b/nix/default.nix
173 | @@ -0,0 +1,31 @@
174 | +{ pkgs, stdenv, lib, nix-filter, ocamlPackages, doCheck }:
175 | +
176 | +with ocamlPackages;
177 | +buildDunePackage rec {
178 | + pname = "hyper";
179 | + version = "1.0.0-alpha.1";
180 | +
181 | + # Using nix-filter means we only rebuild when we have to
182 | + src = with nix-filter.lib;
183 | + filter {
184 | + root = ../.;
185 | + include = [
186 | + "dune-project"
187 | + "hyper.opam"
188 | + "README.md"
189 | + (inDirectory "example")
190 | + (inDirectory "src")
191 | + (inDirectory "test")
192 | + ];
193 | + };
194 | +
195 | + checkInputs = [ alcotest alcotest-lwt dream ];
196 | +
197 | + propagatedBuildInputs = [ dream-httpaf dream-pure mirage-crypto-rng uri ] ++ checkInputs;
198 | +
199 | + inherit doCheck;
200 | +
201 | + meta = {
202 | + description = "Web client with HTTP/1, HTTP/2, TLS, and WebSocket support";
203 | + };
204 | +}
205 | diff --git a/src/dune b/src/dune
206 | index 0711727..807e179 100644
207 | --- a/src/dune
208 | +++ b/src/dune
209 | @@ -4,14 +4,14 @@
210 | (modules hyper)
211 | (libraries
212 | dream-pure
213 | - dream-httpaf.h2-lwt-unix
214 | - dream-httpaf.httpaf-lwt-unix
215 | + h2-lwt-unix
216 | + httpaf-lwt-unix
217 | hyper.http
218 | hyper.logic
219 | lwt
220 | lwt.unix
221 | lwt_ssl
222 | ssl
223 | - dream-httpaf.websocketaf-lwt-unix
224 | + websocketaf-lwt-unix
225 | )
226 | (preprocess (pps lwt_ppx)))
227 | diff --git a/src/http/dune b/src/http/dune
228 | index f8ae2fb..ce3f765 100644
229 | --- a/src/http/dune
230 | +++ b/src/http/dune
231 | @@ -4,12 +4,12 @@
232 | (libraries
233 | dream-httpaf
234 | dream-pure
235 | - dream-httpaf.h2
236 | - dream-httpaf.h2-lwt-unix
237 | - dream-httpaf.httpaf
238 | - dream-httpaf.httpaf-lwt-unix
239 | - dream-httpaf.websocketaf
240 | - dream-httpaf.websocketaf-lwt-unix
241 | + h2
242 | + h2-lwt-unix
243 | + httpaf
244 | + httpaf-lwt-unix
245 | + websocketaf
246 | + websocketaf-lwt-unix
247 | mirage-crypto-rng
248 | mirage-crypto-rng.lwt
249 | uri
250 | diff --git a/src/http/http1.ml b/src/http/http1.ml
251 | index e2dae53..804c747 100644
252 | --- a/src/http/http1.ml
253 | +++ b/src/http/http1.ml
254 | @@ -115,6 +115,7 @@ let general send_request client connection (request : Message.request) =
255 | let httpaf_request_body_writer =
256 | send_request
257 | client
258 | + ?flush_headers_immediately:(Some true)
259 | httpaf_request
260 | ~error_handler
261 | ~response_handler
262 | @@ -161,10 +162,8 @@ let general send_request client connection (request : Message.request) =
263 |
264 | response_promise
265 |
266 | -
267 | -
268 | let http client =
269 | - general Httpaf_lwt_unix.Client.request client client.connection
270 | + general Httpaf_lwt_unix.Client.request client client.connection
271 |
272 | let https client =
273 | - general Httpaf_lwt_unix.Client.SSL.request client client.connection
274 | + general Httpaf_lwt_unix.Client.SSL.request client client.connection
275 | diff --git a/src/http/http2.ml b/src/http/http2.ml
276 | index 77a997f..419fc30 100644
277 | --- a/src/http/http2.ml
278 | +++ b/src/http/http2.ml
279 | @@ -69,7 +69,7 @@ let https (connection : H2_lwt_unix.Client.SSL.t) (request : Message.request) =
280 | exn the_exn
281 | | None ->
282 | exn_handler := exn;
283 | - H2.Body.schedule_read
284 | + H2.Body.Reader.schedule_read
285 | h2_response_body
286 | ~on_eof:(fun () ->
287 | exn_handler := ignore;
288 | @@ -79,7 +79,7 @@ let https (connection : H2_lwt_unix.Client.SSL.t) (request : Message.request) =
289 | data buffer off len true false)
290 |
291 | and close _code =
292 | - H2.Body.close_reader h2_response_body
293 | + H2.Body.Reader.close h2_response_body
294 |
295 | and abort exn =
296 | H2.Client_connection.report_exn connection.connection exn;
297 | @@ -111,7 +111,7 @@ let https (connection : H2_lwt_unix.Client.SSL.t) (request : Message.request) =
298 | (Message.server_stream request) ~data ~flush ~ping ~pong ~close ~exn
299 |
300 | and data buffer offset length _binary _fin =
301 | - H2.Body.write_bigstring
302 | + H2.Body.Writer.write_bigstring
303 | h2_request_body_writer
304 | ~off:offset
305 | ~len:length
306 | @@ -119,14 +119,14 @@ let https (connection : H2_lwt_unix.Client.SSL.t) (request : Message.request) =
307 | bytes_since_flush := !bytes_since_flush + length;
308 | if !bytes_since_flush >= 4096 then begin
309 | bytes_since_flush := 0;
310 | - H2.Body.flush h2_request_body_writer send
311 | + H2.Body.Writer.flush h2_request_body_writer send
312 | end
313 | else
314 | send ()
315 |
316 | and flush () =
317 | bytes_since_flush := 0;
318 | - H2.Body.flush h2_request_body_writer send
319 | + H2.Body.Writer.flush h2_request_body_writer send
320 |
321 | and ping _buffer _offset _length =
322 | send ()
323 | @@ -135,7 +135,7 @@ let https (connection : H2_lwt_unix.Client.SSL.t) (request : Message.request) =
324 | send ()
325 |
326 | and close _code =
327 | - H2.Body.close_writer h2_request_body_writer
328 | + H2.Body.Writer.close h2_request_body_writer
329 |
330 | and exn exn =
331 | H2.Client_connection.report_exn connection.connection exn;
332 | --
333 | 2.36.0
334 |
335 |
--------------------------------------------------------------------------------
/ocaml/hyper/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub
2 | , buildDunePackage
3 | , dream-httpaf
4 | , dream-pure
5 | , mirage-crypto-rng-lwt
6 | , uri
7 | }:
8 |
9 | buildDunePackage rec {
10 | pname = "hyper";
11 | version = "1.0.0-alpha1";
12 |
13 | src = fetchFromGitHub {
14 | owner = "aantron";
15 | repo = "hyper";
16 | rev = "ca0a287b9e4e9c7e960daa8d1ecf2d82f073e3bb";
17 | hash = "sha256-MwJdT1JzJQuM2yeRSZ6LaYqspZ4Is5K9kNoHHdOdaiw=";
18 | };
19 |
20 | propagatedBuildInputs = [
21 | dream-httpaf
22 | dream-pure
23 | uri
24 | mirage-crypto-rng-lwt
25 | ];
26 | }
27 |
--------------------------------------------------------------------------------
/ocaml/jose/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , fetchFromGitHub
3 | , base64
4 | , mirage-crypto
5 | , mirage-crypto-pk
6 | , mirage-crypto-ec
7 | , x509
8 | , cstruct
9 | , astring
10 | , yojson
11 | , zarith
12 | , ptime
13 | }:
14 |
15 | buildDunePackage {
16 | pname = "jose";
17 | version = "0.10.0";
18 | src = fetchFromGitHub {
19 | owner = "ulrikstrid";
20 | repo = "ocaml-jose";
21 | rev = "v0.10.0";
22 | hash = "sha256-bA2DAZ6N11sOOPz7bfePVtSAgIETXlgkwY3faKFqFIc=";
23 | };
24 |
25 | propagatedBuildInputs = [
26 | base64
27 | mirage-crypto
28 | mirage-crypto-pk
29 | mirage-crypto-ec
30 | x509
31 | astring
32 | yojson
33 | zarith
34 | ptime
35 | ];
36 | }
37 |
--------------------------------------------------------------------------------
/ocaml/kcas/data.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, kcas }:
2 |
3 | buildDunePackage {
4 | pname = "kcas_data";
5 | inherit (kcas) version src;
6 |
7 | propagatedBuildInputs = [ kcas ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/kcas/default.nix:
--------------------------------------------------------------------------------
1 | { backoff
2 | , buildDunePackage
3 | , domain-local-await
4 | , domain-local-timeout
5 | , multicore-magic
6 | }:
7 |
8 | buildDunePackage {
9 | pname = "kcas";
10 | version = "0.7.9";
11 | src = builtins.fetchurl {
12 | url = "https://github.com/ocaml-multicore/kcas/releases/download/0.7.0/kcas-0.7.0.tbz";
13 | sha256 = "148zgbvkq67ial8rgmz5kzyi3y8m35dw62sqr4fx9vq1g6vfi3ws";
14 | };
15 | propagatedBuildInputs = [
16 | domain-local-await
17 | domain-local-timeout
18 | multicore-magic
19 | backoff
20 | ];
21 | }
22 |
--------------------------------------------------------------------------------
/ocaml/lambda-runtime/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , fetchFromGitHub
3 | , yojson
4 | , ppx_deriving_yojson
5 | , piaf
6 | , uri
7 | , logs
8 | , lwt
9 | }:
10 |
11 | buildDunePackage {
12 | pname = "lambda-runtime";
13 | version = "0.1.0-dev";
14 | src = fetchFromGitHub {
15 | owner = "anmonteiro";
16 | repo = "aws-lambda-ocaml-runtime";
17 | rev = "57267505603cef4395906af40dfc295a3dc1efda";
18 | hash = "sha256-Hwe+KSmZIVi3GWXpabEyDb+WdT5Qb7lW9oRxJ6H2BbM=";
19 | };
20 | postPatch = ''
21 | substituteInPlace lib/context.ml lib/lambda_runtime.mli \
22 | --replace-fail "Eio.Stdenv.t" "Eio_unix.Stdenv.base"
23 | '';
24 |
25 | propagatedBuildInputs = [
26 | yojson
27 | ppx_deriving_yojson
28 | piaf
29 | uri
30 | logs
31 | lwt
32 | ];
33 | }
34 |
--------------------------------------------------------------------------------
/ocaml/lambda-runtime/vercel.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , lambda-runtime
3 | , piaf
4 | , yojson
5 | , ppx_deriving_yojson
6 | , lwt
7 | , base64
8 |
9 | }:
10 |
11 | buildDunePackage {
12 | pname = "vercel";
13 | inherit (lambda-runtime) version src;
14 | propagatedBuildInputs = [
15 | lambda-runtime
16 | piaf
17 | yojson
18 | ppx_deriving_yojson
19 | lwt
20 | base64
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/ocaml/ldconf.patch:
--------------------------------------------------------------------------------
1 | diff --git a/findlib.conf.in b/findlib.conf.in
2 | index 261d2c8..2551e76 100644
3 | --- a/findlib.conf.in
4 | +++ b/findlib.conf.in
5 | @@ -1,2 +1,3 @@
6 | destdir="@SITELIB@"
7 | path="@SITELIB@"
8 | +ldconf="ignore"
9 |
--------------------------------------------------------------------------------
/ocaml/logs-ppx/default.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, ppxlib }:
2 |
3 | buildDunePackage rec {
4 | pname = "logs-ppx";
5 | version = "0.2.0";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/ulrikstrid/${pname}/releases/download/v${version}/logs-ppx-${version}.tbz";
8 | sha256 = "1cdzq08c54b93ysw94ykhnb51h8sx61b9sh3jl3xrmjrz4z08gq5";
9 | };
10 |
11 | doCheck = true;
12 |
13 | propagatedBuildInputs = [ ppxlib ];
14 |
15 | meta = {
16 | description = "PPX to cut down on boilerplate when using Logs";
17 | license = lib.licenses.bsd3;
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/ocaml/lwt/domain.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, domainslib, fetchFromGitHub, lwt }:
2 |
3 | buildDunePackage {
4 | pname = "lwt_domain";
5 | version = "0.2.0-dev";
6 | src = fetchFromGitHub {
7 | owner = "ocsigen";
8 | repo = "lwt_domain";
9 | rev = "28319c184a648c9e79f60b8ba4f57c271f7e9606";
10 | hash = "sha256-rjjJX19/SuKUdvlE8BfV0iGdzmFLF+F8L4HzG4ja2HI=";
11 | };
12 | propagatedBuildInputs = [ domainslib lwt ];
13 |
14 | meta = {
15 | description = "Helpers for using Domainslib with Lwt";
16 | license = lib.licenses.mit;
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/ocaml/lwt/react.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, cppo, lwt, react }:
2 |
3 | buildDunePackage {
4 | pname = "lwt_react";
5 | version = "1.1.5";
6 | inherit (lwt) src;
7 |
8 | buildInputs = [ cppo ];
9 |
10 | propagatedBuildInputs = [ lwt react ];
11 |
12 | meta = {
13 | description = "Helpers for using React with Lwt";
14 | license = lib.licenses.mit;
15 | };
16 | }
17 |
--------------------------------------------------------------------------------
/ocaml/matrix/ctos.nix:
--------------------------------------------------------------------------------
1 | { lib, fetchFromGitHub, buildDunePackage, matrix-common, ezjsonm, fmt, logs, ppxlib }:
2 |
3 | buildDunePackage {
4 | pname = "matrix-ctos";
5 | inherit (matrix-common) version src doCheck;
6 |
7 | propagatedBuildInputs = [
8 | matrix-common
9 | ezjsonm
10 | fmt
11 | logs
12 | ppxlib
13 | ];
14 | }
15 |
--------------------------------------------------------------------------------
/ocaml/matrix/default.nix:
--------------------------------------------------------------------------------
1 | { lib, fetchFromGitHub, buildDunePackage, ezjsonm, fmt, logs, cmdliner, ppxlib }:
2 |
3 | buildDunePackage {
4 | pname = "matrix-common";
5 | version = "2023-07-02";
6 | src = fetchFromGitHub {
7 | repo = "ocaml-matrix";
8 | owner = "mirage";
9 | rev = "d77c5bbde67028d444551cd28c05cb44cd381265";
10 | sha256 = "sha256-i7iqtI/GFFLFIgj+bKZ5n0RrmF1RVRzolq9eVulUNeY=";
11 | };
12 |
13 | propagatedBuildInputs = [
14 | ezjsonm
15 | fmt
16 | logs
17 | cmdliner
18 | ppxlib
19 | ];
20 |
21 | doCheck = true;
22 | }
23 |
--------------------------------------------------------------------------------
/ocaml/matrix/stos.nix:
--------------------------------------------------------------------------------
1 | { lib, fetchFromGitHub, buildDunePackage, matrix-common, ezjsonm, fmt, logs, mirage-crypto-ec, x509, ppxlib }:
2 |
3 | buildDunePackage {
4 | pname = "matrix-stos";
5 | inherit (matrix-common) version src doCheck;
6 |
7 | propagatedBuildInputs = [
8 | matrix-common
9 | ezjsonm
10 | fmt
11 | logs
12 | ppxlib
13 | mirage-crypto-ec
14 | x509
15 | ];
16 | }
17 |
--------------------------------------------------------------------------------
/ocaml/melange-packages.nix:
--------------------------------------------------------------------------------
1 | { oself, fetchFromGitHub }:
2 |
3 | with oself;
4 |
5 | {
6 | melange-atdgen-codec-runtime = buildDunePackage {
7 | pname = "melange-atdgen-codec-runtime";
8 | version = "n/a";
9 | src = builtins.fetchurl {
10 | url = "https://github.com/ahrefs/melange-atdgen-codec-runtime/releases/download/3.0.1/melange-atdgen-codec-runtime-3.0.1.tbz";
11 | sha256 = "1g5axhl8cqnhwky4nnsdpk4n3vxv95fr44k71kfi3zngvl9rrpya";
12 | };
13 |
14 | nativeBuildInputs = [ melange ];
15 | propagatedBuildInputs = [ melange melange-json ];
16 | };
17 |
18 | melange-fetch = buildDunePackage {
19 | pname = "melange-fetch";
20 | version = "n/a";
21 | src = fetchFromGitHub {
22 | owner = "melange-community";
23 | repo = "melange-fetch";
24 | rev = "a876cc42c2f1c3b0cbf370f1d15bbc788a62d785";
25 | hash = "sha256-has7M1qi5AjBLHQxH2wNg4JvLBV7jHXFQAAhs0OZoLw=";
26 | };
27 | nativeBuildInputs = [ melange ];
28 | propagatedBuildInputs = [ melange ];
29 | };
30 |
31 | melange-recharts = buildDunePackage {
32 | pname = "melange-recharts";
33 | version = "4.0.1";
34 | src = fetchFromGitHub {
35 | owner = "ahrefs";
36 | repo = "melange-recharts";
37 | rev = "2ff880588550897f8e2752f71d63aed9eae67d35";
38 | hash = "sha256-+YIC5JZGEAiTufZxbA3NTy65WqS77/YROLg0Hez9LUo=";
39 | };
40 | nativeBuildInputs = [ melange reason ];
41 | propagatedBuildInputs = [ melange reason-react ];
42 | };
43 |
44 | melange-testing-library = buildDunePackage {
45 | pname = "melange-testing-library";
46 | version = "n/a";
47 | src = fetchFromGitHub {
48 | owner = "melange-community";
49 | repo = "melange-testing-library";
50 | rev = "45e0bc95270a66d9b6dd77c3ddf1ae72f36f7a19";
51 | hash = "sha256-xr8LTJwCX6IgkycKC1FBRn+YiA/HZDUmNJNsw8MM7N4=";
52 | };
53 | nativeBuildInputs = [ melange reason ];
54 | propagatedBuildInputs = [ melange reason-react ];
55 | };
56 |
57 | melange-json = buildDunePackage {
58 | inherit (melange-json-native) version src;
59 | pname = "melange-json";
60 | nativeBuildInputs = [ melange ];
61 | propagatedBuildInputs = [ melange ppxlib ];
62 | };
63 |
64 | melange-jest = buildDunePackage {
65 | pname = "melange-jest";
66 | version = "n/a";
67 | src = fetchFromGitHub {
68 | owner = "melange-community";
69 | repo = "melange-jest";
70 | rev = "b26885f193ed97ef9ab47447d21a1ddaa75d924a";
71 | hash = "sha256-PD22f/ySEwEtom5d9LNQoRQBQcCbyFIClj1wLnqk2oA=";
72 | };
73 | nativeBuildInputs = [ melange ];
74 | propagatedBuildInputs = [ melange reason-react ];
75 | };
76 |
77 | melange-numeral = buildDunePackage {
78 | pname = "melange-numeral";
79 | version = "0.0.1";
80 | src = builtins.fetchurl {
81 | url = "https://github.com/ahrefs/melange-numeral/releases/download/0.0.1/melange-numeral-0.0.1.tbz";
82 | sha256 = "1a16j014ps835xqks7mgybqqq34rpvhnzbibrh1pypcqa7hhcdnd";
83 | };
84 | nativeBuildInputs = [ melange reason ];
85 | propagatedBuildInputs = [ melange ];
86 | };
87 |
88 | melange-webapi = buildDunePackage {
89 | pname = "melange-webapi";
90 | version = "n/a";
91 | src = fetchFromGitHub {
92 | owner = "melange-community";
93 | repo = "melange-webapi";
94 | rev = "0040e288bc47706e530ed7100d6e7bd80199c6c9";
95 | hash = "sha256-S2q+8ri6jDDwOkY3IUmFMZzx1tNZWl34XdYtmI5W6eQ=";
96 | };
97 | nativeBuildInputs = [ melange reason ];
98 | propagatedBuildInputs = [ melange melange-fetch ];
99 | };
100 |
101 | melange-relay = buildDunePackage {
102 | pname = "melange-relay";
103 | version = "n/a";
104 | src = fetchFromGitHub {
105 | owner = "anmonteiro";
106 | repo = "melange-relay";
107 | rev = "18ed167f52b8c10ebefaf65534e6075614fa77b1";
108 | hash = "sha256-bA77GH80eSz0XsrEs+sgRvI9jtrSc14V6NjTsXOPoMc=";
109 | };
110 | nativeBuildInputs = [ melange ];
111 | propagatedBuildInputs = [
112 | reason-react
113 | reason-react-ppx
114 | graphql_parser
115 | melange
116 | ];
117 | };
118 |
119 | reason-react = buildDunePackage {
120 | pname = "reason-react";
121 | version = "n/a";
122 | inherit (reason-react-ppx) src;
123 | nativeBuildInputs = [ reason melange ];
124 | propagatedBuildInputs = [ reason-react-ppx melange ];
125 | };
126 |
127 | reason-react-ppx = buildDunePackage {
128 | pname = "reason-react-ppx";
129 | version = "n/a";
130 | src = fetchFromGitHub {
131 | owner = "reasonml";
132 | repo = "reason-react";
133 | rev = "2452ff8b970cdbc8d31ae9549472a07a85a7093e";
134 | hash = "sha256-N8IjA0kQiY06W8ZuEPof7tZ6re9TlChrAQ1i5AqR4BY=";
135 | };
136 | propagatedBuildInputs = [ ppxlib ];
137 | };
138 | }
139 |
--------------------------------------------------------------------------------
/ocaml/melange/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , cppo
3 | , cmdliner
4 | , dune-build-info
5 | , fetchFromGitHub
6 | , jq
7 | , lib
8 | , makeWrapper
9 | , menhir
10 | , menhirLib
11 | , merlin
12 | , nodejs_latest
13 | , ocaml
14 | , ounit2
15 | , ppxlib
16 | , reason
17 | , tree
18 | , stdenv
19 | }:
20 |
21 | buildDunePackage {
22 | pname = "melange";
23 | version = "5.1.0";
24 | duneVersion = "3";
25 |
26 | src =
27 | if lib.versionOlder "5.3" ocaml.version then
28 | builtins.fetchurl
29 | {
30 | url = "https://github.com/melange-re/melange/releases/download/5.1.0-53/melange-5.1.0-53.tbz";
31 | sha256 = "1ad4bh1jvdn2cjsp9v6zr9br999qbgdlq5p2ff1zzzm57c7w7app";
32 | }
33 | else if lib.versionOlder "5.2" ocaml.version then
34 | builtins.fetchurl
35 | {
36 | url = "https://github.com/melange-re/melange/releases/download/5.1.0-52/melange-5.1.0-52.tbz";
37 | sha256 = "1zfyd9ax55dcv6idqmvyw3h2cf8p76y9hf11cc1r1p58c2f0hqhh";
38 | }
39 | else if lib.versionOlder "5.1" ocaml.version then
40 | builtins.fetchurl
41 | {
42 | url = "https://github.com/melange-re/melange/releases/download/5.1.0-51/melange-5.1.0-51.tbz";
43 | sha256 = "14mhw78gwzv8ncicl35i48gs6fpbsdgrfvbfx9gw2an4jaypr08c";
44 | }
45 | else
46 | builtins.fetchurl {
47 | url = "https://github.com/melange-re/melange/releases/download/5.0.1-414/melange-5.0.1-414.tbz";
48 | sha256 = "10n2ds6b9ajq7ccazp0sffx9jnxlazlbkd38vyz0s2zg0la72vgh";
49 | };
50 |
51 | doCheck = false;
52 |
53 | nativeCheckInputs = [ nodejs_latest reason tree merlin jq ];
54 | checkInputs = [ ounit2 ];
55 | nativeBuildInputs = [ cppo menhir makeWrapper ];
56 | propagatedBuildInputs = [ cmdliner dune-build-info ppxlib menhirLib ];
57 |
58 | postInstall = ''
59 | wrapProgram "$out/bin/melc" \
60 | --set MELANGELIB "$OCAMLFIND_DESTDIR/melange/melange:$OCAMLFIND_DESTDIR/melange/js/melange"
61 | '';
62 |
63 | meta.mainProgram = "melc";
64 | }
65 |
--------------------------------------------------------------------------------
/ocaml/merlin/camlp-streams.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/frontend/ocamlmerlin/dune b/src/frontend/ocamlmerlin/dune
2 | index b4f149e3..6f3c2b5a 100644
3 | --- a/src/frontend/ocamlmerlin/dune
4 | +++ b/src/frontend/ocamlmerlin/dune
5 | @@ -6,7 +6,7 @@
6 | (public_name ocamlmerlin-server)
7 | (flags -open Merlin_utils -open Merlin_analysis)
8 | (modules (:standard \ gen_ccflags))
9 | - (libraries config yojson merlin_analysis merlin_kernel
10 | + (libraries config yojson merlin_analysis merlin_kernel camlp-streams
11 | merlin_utils os_ipc parsing query_protocol query_commands
12 | typing utils))
13 |
14 |
--------------------------------------------------------------------------------
/ocaml/merlin/default.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , fetchpatch
3 | , buildDunePackage
4 | , dot-merlin-reader
5 | , yojson
6 | , csexp
7 | , result
8 | , merlin-lib
9 | , camlp-streams
10 | }:
11 |
12 | buildDunePackage {
13 | pname = "merlin";
14 | inherit (dot-merlin-reader) src version;
15 |
16 | buildInputs = [ dot-merlin-reader yojson csexp result camlp-streams ];
17 | }
18 |
--------------------------------------------------------------------------------
/ocaml/merlin/dot-merlin.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , ocaml
3 | , findlib
4 | , buildDunePackage
5 | , yojson
6 | , csexp
7 | , result
8 | , merlin-lib
9 | }:
10 |
11 | buildDunePackage {
12 | pname = "dot-merlin-reader";
13 | version =
14 | if lib.versionAtLeast ocaml.version "4.14" then
15 | merlin-lib.version else "n/a";
16 |
17 | src =
18 | if lib.versionAtLeast ocaml.version "4.14" then
19 | merlin-lib.src
20 | else if (lib.versionOlder "4.13" ocaml.version)
21 | then
22 | builtins.fetchurl
23 | {
24 | url = "https://github.com/ocaml/merlin/releases/download/v4.7-413/merlin-4.7-413.tbz";
25 | sha256 = "09c3z6znj61p1mkzl9vjm7m00zgyw34jlhycqbp1490v5rcqcnb9";
26 | }
27 | else if (lib.versionOlder "4.12" ocaml.version)
28 | then
29 | builtins.fetchurl
30 | {
31 | url = "https://github.com/ocaml/merlin/releases/download/v4.7-412/merlin-4.7-412.tbz";
32 | sha256 = "0ijgc0a8hmmhpw4vcsklcfy9j018amqvj01g6w5sb50vn5mwhkfi";
33 | }
34 | else if (lib.versionOlder "4.11" ocaml.version)
35 | then
36 | builtins.fetchurl
37 | {
38 | url = "https://github.com/ocaml/merlin/releases/download/v4.1-411/merlin-v4.1-411.tbz";
39 | sha256 = "0zckb729mhp1329bcqp0mi1lxxipzbm4a5hqqzrf2g69k73nybly";
40 | }
41 | else
42 | builtins.fetchurl {
43 | url = "https://github.com/ocaml/merlin/releases/download/v3.4.2/merlin-v3.4.2.tbz";
44 | sha256 = "109ai1ggnkrwbzsl1wdalikvs1zx940m6n65jllxj68in6bvidz1";
45 | };
46 |
47 | propagatedBuildInputs = [ yojson csexp result merlin-lib findlib ];
48 | }
49 |
--------------------------------------------------------------------------------
/ocaml/merlin/lib.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub
2 | , lib
3 | , ocaml
4 | , buildDunePackage
5 | , yojson
6 | , csexp
7 | , result
8 | , merlin
9 | }:
10 |
11 | let
12 | merlinVersion = "4.12";
13 |
14 | ocamlVersionShorthand = lib.concatStrings
15 | (lib.take 2 (lib.splitVersion ocaml.version));
16 |
17 | version = "${merlinVersion}-${ocamlVersionShorthand}";
18 | isFlambda2 = lib.hasSuffix "flambda2" ocaml.version;
19 | in
20 |
21 | buildDunePackage {
22 | pname = "merlin-lib";
23 | version = version;
24 | src =
25 | if isFlambda2 then
26 | fetchFromGitHub
27 | {
28 | owner = "janestreet";
29 | repo = "merlin-jst";
30 | rev = "65b4861209ab76f065a88b59ed3fdc44b7a03f5a";
31 | hash = "sha256-+wuVILkh8xJAIdGVDwi/IjubhzBcTRcWkE8v2euaUgQ=";
32 | }
33 | else if lib.versionOlder "5.4" ocaml.version then
34 | fetchFromGitHub
35 | {
36 | owner = "ocaml";
37 | repo = "merlin";
38 | rev = "0e8190c4b7e0bcf44c6682f342416f6ad58f3db4";
39 | hash = "sha256-LuRWHRScJw2LWOhgkaDlmWsxn3A6E0ItVNAuTBBgAv0=";
40 | }
41 | else if lib.versionOlder "5.3" ocaml.version
42 | then
43 | builtins.fetchurl
44 | {
45 | url = "https://github.com/ocaml/merlin/releases/download/v5.4.1-503/merlin-5.4.1-503.tbz";
46 | sha256 = "08ihafi64rcbhga77pa9jzbxa4mkn283grq5fky2a8f1g33v9cs9";
47 | }
48 | else if lib.versionOlder "5.2" ocaml.version
49 | then
50 | builtins.fetchurl
51 | {
52 | url = "https://github.com/ocaml/merlin/releases/download/v5.3-502/merlin-5.3-502.tbz";
53 | sha256 = "1g14maryp5aw02a0chj9xqbdkky125g4y38cxwqnxylp4gqldsic";
54 | }
55 | else if lib.versionOlder "5.1" ocaml.version
56 | then
57 | builtins.fetchurl
58 | {
59 | url = "https://github.com/ocaml/merlin/releases/download/v4.17.1-501/merlin-4.17.1-501.tbz";
60 | sha256 = "0055n11ghrxypd6fjx67fnnwj8csp3jgplsnjiiyj28zhym0frrp";
61 | }
62 | else if lib.versionOlder "5.0" ocaml.version
63 | then
64 | builtins.fetchurl
65 | {
66 | url = "https://github.com/ocaml/merlin/releases/download/v4.14-500/merlin-4.14-500.tbz";
67 | sha256 = "03nps5mbh5lzf88d850903bz75g5sk33qc3zi7c0qlkmz0jg68zc";
68 | }
69 | else
70 | builtins.fetchurl {
71 | url = "https://github.com/ocaml/merlin/releases/download/v4.18-414/merlin-4.18-414.tbz";
72 | sha256 = "1h8cwdzvcyxdr6jkpsj7sn2r31aw2g4155l63a63a7hlcsiggmpn";
73 | };
74 |
75 | postPatch =
76 | if isFlambda2 then ''
77 | # not sure what this file is doing, but it causes a duplicate symbol
78 | # linking error
79 | truncate --size=0 src/runtime/float32.c
80 |
81 | substituteInPlace src/frontend/dune --replace-fail \
82 | "merlin_specific" "merlin_specific merlin_extend"
83 | '' else "";
84 | buildInputs = [ yojson csexp result ];
85 | }
86 |
--------------------------------------------------------------------------------
/ocaml/mongo/bson.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, angstrom, faraday }:
2 |
3 | buildDunePackage {
4 | pname = "bson";
5 | src = fetchFromGitHub {
6 | owner = "anmonteiro";
7 | repo = "ocaml-mongodb";
8 | rev = "91f1c6d9d47be0585245851b1f97a74ea12b2bdd";
9 | hash = "sha256-g8j/LW3h/ItpFRBmMbd8DlJsSARNfNrJh0HuQIzyDMI=";
10 | };
11 | version = "0.0.1-dev";
12 |
13 | propagatedBuildInputs = [ angstrom faraday ];
14 | }
15 |
--------------------------------------------------------------------------------
/ocaml/mongo/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, bson }:
2 |
3 | buildDunePackage {
4 | pname = "mongo";
5 | inherit (bson) src version;
6 |
7 | propagatedBuildInputs = [ bson ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/mongo/lwt-unix.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, mongo, mongo-lwt, gluten-lwt-unix }:
2 |
3 | buildDunePackage {
4 | pname = "mongo-lwt-unix";
5 | inherit (mongo) src version;
6 |
7 | propagatedBuildInputs = [ mongo-lwt gluten-lwt-unix ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/mongo/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, mongo, lwt, mirage-crypto, gluten-lwt, pbkdf, base64 }:
2 |
3 | buildDunePackage {
4 | pname = "mongo-lwt";
5 | inherit (mongo) src version;
6 |
7 | propagatedBuildInputs = [ mongo lwt mirage-crypto gluten-lwt pbkdf base64 ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/mongo/ppx.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, ppxlib, ppx_deriving, bson }:
2 |
3 | buildDunePackage {
4 | pname = "ppx_deriving_bson";
5 | inherit (bson) src version;
6 |
7 | propagatedBuildInputs = [ ppxlib ppx_deriving bson ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/multipart_form/default.nix:
--------------------------------------------------------------------------------
1 | { upstream ? false
2 | , lib
3 | , fetchFromGitHub
4 | , buildDunePackage
5 | , unstrctrd
6 | , lwt
7 | , ocaml
8 | , prettym
9 | , logs
10 | , ke
11 | , bigstringaf
12 | , astring
13 | , faraday
14 | , base64
15 | , pecu
16 | , rosetta
17 | , rresult
18 | , uutf
19 | , fmt
20 | , angstrom
21 | , alcotest
22 | }:
23 |
24 | let
25 | upstream_src = builtins.fetchurl {
26 | url = "https://github.com/dinosaure/multipart_form/releases/download/v0.6.0/multipart_form-0.6.0.tbz";
27 | sha256 = "05i10ql2zkf0v1rif3v08sas1rm1d1xghnndcx0svyng4g1jkqx0";
28 | };
29 | upstream_version = "0.4.1";
30 |
31 | src = fetchFromGitHub {
32 | owner = "anmonteiro";
33 | repo = "multipart_form";
34 | rev = "06a86ad395a4f09cdf1ac4fd1f15993521e7ac47";
35 | hash = "sha256-+bkJbwwLbYL3CTSSv6XxTaYGRRe3rlPTYRxeh1l4cXk=";
36 | };
37 | version = "0.5.0-dev";
38 |
39 | in
40 |
41 | buildDunePackage {
42 | pname = "multipart_form";
43 |
44 | version = if upstream then upstream_version else version;
45 |
46 | src = if upstream then upstream_src else src;
47 |
48 | propagatedBuildInputs = [
49 | base64
50 | pecu
51 | rosetta
52 | rresult
53 | uutf
54 | fmt
55 | angstrom
56 | bigstringaf
57 | ke
58 | logs
59 | prettym
60 | unstrctrd
61 | faraday
62 | ];
63 |
64 | doCheck = !upstream;
65 |
66 | checkInputs = [ alcotest rosetta ];
67 | }
68 |
--------------------------------------------------------------------------------
/ocaml/multipart_form/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , multipart_form
3 | , angstrom
4 | , bigarray-compat
5 | , bigstringaf
6 | , ke
7 | , lwt
8 | , alcotest
9 | , alcotest-lwt
10 | , rosetta
11 | , rresult
12 | , unstrctrd
13 | , logs
14 | }:
15 |
16 | buildDunePackage {
17 | pname = "multipart_form-lwt";
18 | inherit (multipart_form) src version;
19 |
20 | doCheck = false;
21 |
22 | propagatedBuildInputs = [
23 | angstrom
24 | bigarray-compat
25 | bigstringaf
26 | ke
27 | lwt
28 | multipart_form
29 | ];
30 |
31 | checkInputs = [
32 | alcotest
33 | alcotest-lwt
34 | rosetta
35 | rresult
36 | unstrctrd
37 | logs
38 | ];
39 | }
40 |
--------------------------------------------------------------------------------
/ocaml/ocaml-index/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, lib, csexp, merlin-lib, ocaml }:
2 |
3 | buildDunePackage {
4 | pname = "ocaml-index";
5 | version = "1.0";
6 |
7 | src =
8 | if lib.versionOlder "5.3" ocaml.version then merlin-lib.src
9 | else
10 | builtins.fetchurl {
11 | url = "https://github.com/voodoos/ocaml-index/releases/download/v1.0/ocaml-index-1.0.tbz";
12 | sha256 = "070yhxr5rnrk93hxzxy9qmk78x3ka684gbax5w0zfqfm22irrqq1";
13 | };
14 |
15 | propagatedBuildInputs = [ merlin-lib csexp ];
16 |
17 | postPatch = if lib.versionOlder "5.3" ocaml.version then "" else ''
18 | substituteInPlace lib/index.ml --replace-fail \
19 | "Misc_utils.loc_of_decl" "Merlin_analysis.Typedtree_utils.location_of_declaration"
20 | '';
21 | }
22 |
--------------------------------------------------------------------------------
/ocaml/ocaml-migrate-types/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, ppx_optcomp, ocaml-migrate-parsetree-2 }:
2 |
3 | buildDunePackage {
4 | pname = "ocaml-migrate-types";
5 | version = "n/a";
6 | src = fetchFromGitHub {
7 | owner = "EduardoRFS";
8 | repo = "ocaml-migrate-types";
9 | rev = "58919cdf10b4e0de46234f19adef6390a215e3e2";
10 | sha256 = "sha256-X3Gfuelv1ElTLfkCSXlEijKM6KxiP8S0bS5kj76Cxjs=";
11 | };
12 | propagatedBuildInputs = [ ppx_optcomp ocaml-migrate-parsetree-2 ];
13 | }
14 |
--------------------------------------------------------------------------------
/ocaml/ocaml5.nix:
--------------------------------------------------------------------------------
1 | { darwin
2 | , fetchFromGitHub
3 | , nodejs_latest
4 | , oself
5 | , osuper
6 | , nixpkgs
7 | , stdenv
8 | , overrideSDK
9 | }:
10 |
11 | with oself;
12 |
13 | {
14 | archi-eio = callPackage ./archi/eio.nix { };
15 |
16 | caqti-eio = buildDunePackage {
17 | inherit (caqti) version src;
18 | pname = "caqti-eio";
19 | propagatedBuildInputs = [ eio eio_main caqti ];
20 | };
21 |
22 | cohttp-eio = buildDunePackage {
23 | pname = "cohttp-eio";
24 | inherit (http) src version;
25 | doCheck = false;
26 | propagatedBuildInputs = [ cohttp eio_main ptime ];
27 | };
28 |
29 | eio-trace =
30 | let
31 | stdenv' =
32 | if stdenv.isDarwin && !stdenv.isAarch64
33 | then overrideSDK stdenv "11.0"
34 | else stdenv;
35 | in
36 | buildDunePackage {
37 | stdenv = stdenv';
38 | pname = "eio-trace";
39 | version = "0.4";
40 | src = builtins.fetchurl {
41 | url = "https://github.com/ocaml-multicore/eio-trace/releases/download/v0.4/eio-trace-0.4.tbz";
42 | sha256 = "1bry9v9c0izz5slhq11q7jgzg6myajfsvx3sg9h2zmcj9irr1xg5";
43 | };
44 | propagatedBuildInputs = [ eio_main lablgtk3 processor cmdliner ];
45 | };
46 |
47 | graphql-eio = buildDunePackage {
48 | pname = "graphql-eio";
49 | inherit (graphql_parser) src version;
50 | propagatedBuildInputs = [ eio_main graphql ];
51 | };
52 |
53 | kafka-eio = buildDunePackage {
54 | pname = "kafka-eio";
55 | inherit (kafka) hardeningDisable version src;
56 | propagatedBuildInputs = [ eio kafka ];
57 | };
58 |
59 | kcas = callPackage ./kcas { };
60 | kcas_data = callPackage ./kcas/data.nix { };
61 |
62 | lambda-runtime = callPackage ./lambda-runtime { };
63 | vercel = callPackage ./lambda-runtime/vercel.nix { };
64 |
65 | lwt_domain = callPackage ./lwt/domain.nix { };
66 |
67 | lwt_eio = callPackage ./eio/lwt_eio.nix { };
68 |
69 | moonpool = buildDunePackage {
70 | pname = "moonpool";
71 | version = "0.7";
72 | src = builtins.fetchurl {
73 | url = "https://github.com/c-cube/moonpool/releases/download/v0.7/moonpool-0.7.tbz";
74 | sha256 = "058vqpza66z5687n90s18pzn1cnvkwv3mphlc1zsnc0541sgk8f4";
75 | };
76 |
77 | propagatedBuildInputs = [ either picos_std ];
78 | doCheck = false;
79 | nativeCheckInputs = [ mdx ];
80 | checkInputs = [ mdx qcheck-core trace trace-tef ];
81 | };
82 |
83 | multicore-magic-dscheck = buildDunePackage {
84 | pname = "multicore-magic-dscheck";
85 | inherit (multicore-magic) src version;
86 | propagatedBuildInputs = [ dscheck ];
87 | };
88 |
89 | carl = callPackage ./piaf/carl.nix { };
90 |
91 | picos = buildDunePackage {
92 | pname = "picos";
93 | version = "0.6.0";
94 | src = builtins.fetchurl {
95 | url = "https://github.com/ocaml-multicore/picos/releases/download/0.6.0/picos-0.6.0.tbz";
96 | sha256 = "1ykx11c8jnjf24anwdzmmf7dmwbqf63z6s3x5yp2sp7nkhchhniz";
97 | };
98 | propagatedBuildInputs = [ backoff thread-local-storage ];
99 | };
100 |
101 | picos_aux = buildDunePackage {
102 | pname = "picos_aux";
103 | inherit (picos) src version;
104 | propagatedBuildInputs = [ backoff multicore-magic ];
105 | };
106 |
107 | picos_std = buildDunePackage {
108 | pname = "picos_std";
109 | inherit (picos) src version;
110 | propagatedBuildInputs = [ picos picos_aux backoff multicore-magic ];
111 | };
112 |
113 | picos_io = buildDunePackage {
114 | pname = "picos_io";
115 | inherit (picos) src version;
116 | propagatedBuildInputs = [
117 | picos_aux
118 | picos_std
119 | backoff
120 | mtime
121 | multicore-magic
122 | psq
123 | ];
124 | };
125 |
126 | picos_lwt = buildDunePackage {
127 | pname = "picos_lwt";
128 | inherit (picos) src version;
129 | propagatedBuildInputs = [ picos_aux picos_std lwt ];
130 | };
131 |
132 | picos_mux = buildDunePackage {
133 | pname = "picos_mux";
134 | inherit (picos) src version;
135 | propagatedBuildInputs = [ picos_aux picos_std multicore-magic backoff ];
136 | };
137 |
138 | ppx_rapper_eio = callPackage ./ppx_rapper/eio.nix { };
139 |
140 | runtime_events_tools = buildDunePackage {
141 | pname = "runtime_events_tools";
142 | version = "0.5.0";
143 |
144 | src = builtins.fetchurl {
145 | url = "https://github.com/tarides/runtime_events_tools/releases/download/0.5.1/runtime_events_tools-0.5.1.tbz";
146 | sha256 = "0r35cpbmj17ldpfkf4dzk4bs1knfy4hyjz6ax0ayrck25rm397dh";
147 | };
148 |
149 | propagatedBuildInputs = [ tracing cmdliner hdr_histogram ];
150 | };
151 |
152 | tar-eio = buildDunePackage {
153 | pname = "tar-eio";
154 | inherit (tar) version src;
155 | propagatedBuildInputs = [ tar eio ];
156 | };
157 |
158 | thread-local-storage = buildDunePackage {
159 | pname = "thread-local-storage";
160 | version = "0.2";
161 | src = builtins.fetchurl {
162 | url = "https://github.com/c-cube/thread-local-storage/releases/download/v0.2/thread-local-storage-0.2.tbz";
163 | sha256 = "0j83gv6iwx6w1iq6jf5pvbzh7lf45riiw53nzhzrk7vzs0g2p3m6";
164 | };
165 | };
166 |
167 | wayland = osuper.wayland.overrideAttrs (o: {
168 | src = builtins.fetchurl {
169 | url = "https://github.com/talex5/ocaml-wayland/releases/download/v2.0/wayland-2.0.tbz";
170 | sha256 = "0jw3x66yscl77w17pp31s4vhsba2xk6z2yvb30fvh0vd9p7ba8c8";
171 | };
172 | propagatedBuildInputs = [ eio ];
173 | checkInputs = o.checkInputs ++ [ eio_main ];
174 | });
175 |
176 | httpun-ws-eio = callPackage ./httpun-ws/eio.nix { };
177 | }
178 |
--------------------------------------------------------------------------------
/ocaml/oidc/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, lib, buildDunePackage, jose, uri, yojson, logs }:
2 |
3 |
4 | buildDunePackage {
5 | pname = "oidc";
6 | version = "0.2.0";
7 | src = fetchFromGitHub {
8 | owner = "ulrikstrid";
9 | repo = "ocaml-oidc";
10 | rev = "v0.2.0";
11 | hash = "sha256-j88F76W5KZVYdZHI1Im24fbbOTect7/LlNfh/KY1mU0=";
12 | };
13 |
14 | propagatedBuildInputs = [ jose uri yojson logs ];
15 |
16 | meta = {
17 | description = "Base functions and types to work with OpenID Connect.";
18 | license = lib.licenses.bsd3;
19 | };
20 | }
21 |
--------------------------------------------------------------------------------
/ocaml/opium-status.patch:
--------------------------------------------------------------------------------
1 | diff --git a/opium/src/status.mli b/opium/src/status.mli
2 | index 2eceffc..cfcec8c 100644
3 | --- a/opium/src/status.mli
4 | +++ b/opium/src/status.mli
5 | @@ -72,6 +72,9 @@ type client_error =
6 | | `Upgrade_required
7 | | `I_m_a_teapot
8 | | `Enhance_your_calm
9 | + | `Precondition_required
10 | + | `Too_many_requests
11 | + | `Request_header_fields_too_large
12 | ]
13 |
14 | (** The 5xx (Server Error) class of status code indicates that the server is aware that it
15 | @@ -84,6 +87,7 @@ type server_error =
16 | | `Service_unavailable
17 | | `Gateway_timeout
18 | | `Http_version_not_supported
19 | + | `Network_authentication_required
20 | ]
21 |
22 | (** The status codes defined in the HTTP 1.1 RFCs *)
23 |
--------------------------------------------------------------------------------
/ocaml/overlay-ocaml-packages.nix:
--------------------------------------------------------------------------------
1 | { nixpkgs, overlays, super, self, updateOCamlPackages ? false }:
2 |
3 | let
4 | inherit (super) lib callPackage ocaml-ng;
5 | ocamlVersions = [
6 | "4_12"
7 | "4_13"
8 | "4_14"
9 | "5_0"
10 | "5_1"
11 | "5_2"
12 | "5_3"
13 | "5_4"
14 | "trunk"
15 | "flambda2"
16 | "jst"
17 | ];
18 | newOCamlScope = { major_version, minor_version, patch_version, src, ... }@extraOpts:
19 | ocaml-ng.mkOcamlPackages
20 | ((callPackage
21 | (import "${nixpkgs}/pkgs/development/compilers/ocaml/generic.nix" {
22 | inherit major_version minor_version patch_version;
23 | })
24 | { }).overrideAttrs (o: {
25 | inherit src;
26 | } //
27 | (if lib.isFunction (extraOpts.overrideAttrs or null)
28 | then extraOpts.overrideAttrs o
29 | else extraOpts)));
30 |
31 | custom-ocaml-ng =
32 | ocaml-ng //
33 | (if !(ocaml-ng ? "ocamlPackages_trunk") then {
34 | ocamlPackages_4_12 = ocaml-ng.ocamlPackages_4_12.overrideScope (oself: osuper: {
35 | ocaml = osuper.ocaml.overrideAttrs (_: {
36 | src = super.fetchFromGitHub {
37 | owner = "ocaml";
38 | repo = "ocaml";
39 | rev = "4.12.1";
40 | hash = "sha256-xIBRHPG0cmhKr0mYp+wKl1a9Bo0PYX2Uc8VO7lCMVzM=";
41 | };
42 | });
43 | });
44 | ocamlPackages_4_13 = ocaml-ng.ocamlPackages_4_13.overrideScope (oself: osuper: {
45 | ocaml = osuper.ocaml.overrideAttrs (_: {
46 | src = super.fetchFromGitHub {
47 | owner = "ocaml";
48 | repo = "ocaml";
49 | rev = "4.13.1";
50 | hash = "sha256-Mq4mQ9ZgzSpw21b2s55fPsA7rKqXCESr+TAg6PfzU8Q=";
51 | };
52 | });
53 | });
54 | ocamlPackages_4_14 = ocaml-ng.ocamlPackages_4_14.overrideScope (oself: osuper: {
55 | ocaml = osuper.ocaml.overrideAttrs (_: {
56 | src = super.fetchFromGitHub {
57 | owner = "ocaml";
58 | repo = "ocaml";
59 | rev = "4.14.2";
60 | hash = "sha256-xKcFQ8vkiOTw7CAMddF8Xf82GNpg879bUdyVC63XREg=";
61 | };
62 | hardeningDisable = [ "strictoverflow" ];
63 | });
64 | });
65 | ocamlPackages_5_0 = ocaml-ng.ocamlPackages_5_0.overrideScope (oself: osuper: {
66 | ocaml = osuper.ocaml.overrideAttrs (_: {
67 | src = super.fetchFromGitHub {
68 | owner = "ocaml";
69 | repo = "ocaml";
70 | rev = "5.0.0";
71 | hash = "sha256-pQrbncjIYrrreJS7LV+Z5J0AhAikD+94MHnZ3ChHF9w=";
72 | };
73 |
74 | });
75 | });
76 | ocamlPackages_5_1 = ocaml-ng.ocamlPackages_5_1.overrideScope (oself: osuper: {
77 | ocaml = osuper.ocaml.overrideAttrs (_: {
78 | src = super.fetchFromGitHub {
79 | owner = "ocaml";
80 | repo = "ocaml";
81 | rev = "5.1.1";
82 | hash = "sha256-uSmTpDUVhj9niON65B9sc/8PBgurS3nIOx4dJjJiUqc=";
83 | };
84 | });
85 | });
86 |
87 | ocamlPackages_5_2 = ocaml-ng.ocamlPackages_5_2.overrideScope (oself: osuper: {
88 | ocaml = osuper.ocaml.overrideAttrs (_: {
89 | src = super.fetchFromGitHub {
90 | owner = "ocaml";
91 | repo = "ocaml";
92 | rev = "5.2.1";
93 | hash = "sha256-SjTHht2s9Vc5fIfkWkHwOl7qgaNY72qt1TX5hco42Zs=";
94 | };
95 | });
96 | });
97 |
98 | ocamlPackages_5_3 = newOCamlScope {
99 | major_version = "5";
100 | minor_version = "3";
101 | patch_version = "0";
102 | hardeningDisable = [ "strictoverflow" ];
103 | src = super.fetchFromGitHub {
104 | owner = "ocaml";
105 | repo = "ocaml";
106 | rev = "5.3.0";
107 | hash = "sha256-OxvfM0OF1XjtAMgAd+4Lm67iMKV7PD1sFmGPYn/yUBY=";
108 | };
109 | postPatch = ''
110 | substituteInPlace "runtime/caml/camlatomic.h" \
111 | --replace-fail "#ifdef CAML_INTERNALS" "" \
112 | --replace-fail "#endif /* CAML_INTERNALS */" ""
113 | '';
114 | };
115 |
116 | ocamlPackages_5_4 = newOCamlScope {
117 | major_version = "5";
118 | minor_version = "4";
119 | patch_version = "0+alpha1";
120 | hardeningDisable = [ "strictoverflow" ];
121 | src = super.fetchFromGitHub {
122 | owner = "ocaml";
123 | repo = "ocaml";
124 | rev = "5.4.0-alpha1";
125 | hash = "sha256-x5VjwTkYDbqWSu127GOzY+du9UZjYENZgacGrN6enzM=";
126 | };
127 | postPatch = ''
128 | substituteInPlace "runtime/caml/camlatomic.h" \
129 | --replace-fail "#ifdef CAML_INTERNALS" "" \
130 | --replace-fail "#endif /* CAML_INTERNALS */" ""
131 | '';
132 | };
133 |
134 | ocamlPackages_trunk = newOCamlScope {
135 | major_version = "5";
136 | minor_version = "5";
137 | patch_version = "0+trunk";
138 | hardeningDisable = [ "strictoverflow" ];
139 | src = super.fetchFromGitHub {
140 | owner = "ocaml";
141 | repo = "ocaml";
142 | rev = "b89105698ccbc794e9c6db1f871b493d93929624";
143 | hash = "sha256-eQjmsTzoRrclG5wYW/+TosX/6FX6X3aA0pbs+yV4eho=";
144 | };
145 | };
146 |
147 | ocamlPackages_flambda2 = newOCamlScope {
148 | major_version = "5";
149 | minor_version = "1";
150 | patch_version = "1+flambda2";
151 | src = super.fetchFromGitHub {
152 | owner = "ocaml-flambda";
153 | repo = "flambda-backend";
154 | rev = "5.1.1minus-20";
155 | hash = "sha256-r+6YzJybGMWYiKLm9Rh5GiAWgt8wI539XRcawXhNYRw=";
156 | };
157 | overrideAttrs =
158 | let
159 | ocaml14Scope = self.ocaml-ng.ocamlPackages_4_14.overrideScope (oself: osuper: {
160 |
161 | menhir = osuper.menhir.overrideAttrs (o: {
162 | buildInputs = with oself; [ menhirLib menhirSdk ];
163 | });
164 | menhirLib = osuper.menhirLib.overrideAttrs (_: {
165 | version = "20210419";
166 | src = super.fetchFromGitLab {
167 | owner = "fpottier";
168 | repo = "menhir";
169 | rev = "20210419";
170 | domain = "gitlab.inria.fr";
171 | hash = "sha256-fg4A8dobKvE4iCkX7Mt13px3AIFDL+96P9nxOPTJi0k=";
172 | };
173 | });
174 | });
175 | in
176 | o: {
177 | hardeningDisable = [ "strictoverflow" ];
178 | makefile = null;
179 | postPatch = ''
180 | substituteInPlace "tools/merge_dot_a_files.sh" --replace-fail \
181 | 'exec libtool -static -o $target $archives' \
182 | 'exec ar cr "$target" $archives && exec ranlib "$target"'
183 | substituteInPlace Makefile ocaml/Makefile.jst --replace-fail \
184 | "SHELL = /usr/bin/env bash" \
185 | "SHELL = ${super.bash}/bin/bash"
186 | cd ocaml && autoconf && cd ..
187 | autoconf
188 | '';
189 | configureFlags = [
190 | "--enable-runtime5"
191 | "--enable-middle-end=flambda2"
192 | "--disable-naked-pointers"
193 | ];
194 | buildFlags = [ "compiler" ];
195 | installPhase = ''
196 | make install
197 | cp ${./compiler-libs-flambda2.META} $out/lib/ocaml/compiler-libs/META
198 | '';
199 | patches = [ ./flambda2.patch ];
200 | nativeBuildInputs =
201 | with ocaml14Scope; [
202 | ocaml
203 | findlib
204 | dune
205 | menhir
206 | super.autoconf
207 | super.libtool
208 | super.rsync
209 | super.which
210 | ];
211 | buildInputs = o.buildInputs ++ (with ocaml14Scope; [ menhirLib ]);
212 | };
213 | };
214 |
215 | ocamlPackages_jst = ocaml-ng.ocamlPackages_4_14.overrideScope (oself: osuper: {
216 | ocaml = (callPackage
217 | (import "${nixpkgs}/pkgs/development/compilers/ocaml/generic.nix" {
218 | major_version = "4";
219 | minor_version = "14";
220 | patch_version = "1+jst";
221 | })
222 | { }).overrideAttrs (o: {
223 | src = super.fetchFromGitHub {
224 | owner = "ocaml-flambda";
225 | repo = "ocaml-jst";
226 | rev = "e3076d2e7321a8e8ff18e560ed7a55d6ff0ebf04";
227 | hash = "sha256-y5p73ZZtwkgUzvCHlE9nqA2OdlDbYWr8wnWRhYH82hE=";
228 | };
229 | hardeningDisable = [ "strictoverflow" ];
230 | });
231 |
232 | dune_3 = osuper.dune_3.overrideAttrs (_: {
233 | postPatch = ''
234 | substituteInPlace boot/bootstrap.ml --replace-fail 'v >= (5, 0, 0)' "true"
235 | substituteInPlace boot/duneboot.ml --replace-fail 'ocaml_version >= (5, 0)' "true"
236 | substituteInPlace src/ocaml-config/ocaml_config.ml --replace-fail 'version >= (5, 0, 0)' "true"
237 | substituteInPlace src/ocaml/version.ml --replace-fail 'version >= (5, 0, 0)' "true"
238 | '';
239 | });
240 | });
241 |
242 | } else { });
243 |
244 | overlaySinglePackageSet = pkgSet:
245 | builtins.foldl' (acc: x: acc.overrideScope x) pkgSet overlays;
246 |
247 | overlayOCamlPackages = version:
248 | lib.nameValuePair
249 | "ocamlPackages_${version}"
250 | (overlaySinglePackageSet custom-ocaml-ng."ocamlPackages_${version}");
251 |
252 | oPs = lib.listToAttrs (builtins.map overlayOCamlPackages ocamlVersions);
253 |
254 | in
255 |
256 | rec {
257 | ocaml-ng = custom-ocaml-ng // oPs // {
258 | ocamlPackages = overlaySinglePackageSet custom-ocaml-ng.ocamlPackages;
259 | ocamlPackages_latest = oPs.ocamlPackages_5_2;
260 | };
261 | ocamlPackages =
262 | if updateOCamlPackages then
263 | overlaySinglePackageSet super.ocamlPackages
264 | else ocaml-ng.ocamlPackages_5_2;
265 | ocamlPackages_latest =
266 | if updateOCamlPackages then
267 | overlaySinglePackageSet super.ocamlPackage_latest
268 | else
269 | ocaml-ng.ocamlPackages_latest;
270 | ocaml = ocamlPackages.ocaml;
271 | }
272 |
--------------------------------------------------------------------------------
/ocaml/pg_query/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub
2 | , buildDunePackage
3 | , alcotest
4 | , cmdliner
5 | , ppx_deriving
6 | , ctypes
7 | , ctypes-foreign
8 | }:
9 |
10 | buildDunePackage {
11 | pname = "pg_query";
12 | version = "0.9.7";
13 |
14 | src = builtins.fetchurl {
15 | url = "https://github.com/roddyyaga/pg_query-ocaml/releases/download/0.9.8/pg_query-0.9.8.tbz";
16 | sha256 = "11c31a10g44m487anwdqfnbxxjl9jlaj277845wmv1zprhcl5lmi";
17 | };
18 |
19 | propagatedBuildInputs = [
20 | ppx_deriving
21 | ctypes
22 | ctypes-foreign
23 | cmdliner
24 | ];
25 | doCheck = true;
26 | checkInputs = [ alcotest ];
27 | }
28 |
--------------------------------------------------------------------------------
/ocaml/piaf/carl.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , stdenv
3 | , overrideSDK
4 | , static ? false
5 | , piaf
6 | , ocaml
7 | , dune
8 | , findlib
9 | , cmdliner
10 | , camlzip
11 | , ezgzip
12 | , fmt
13 | }:
14 |
15 | let
16 | stdenv' =
17 | if stdenv.isDarwin && !stdenv.isAarch64
18 | then overrideSDK stdenv "11.0"
19 | else stdenv;
20 | in
21 |
22 | stdenv'.mkDerivation {
23 | name = "carl";
24 | version = "0.0.1-dev";
25 | inherit (piaf) src;
26 |
27 | # remove the piaf directories. we're depending on piaf as a lib
28 | postPatch = ''
29 | rm -rf vendor lib lib_test multipart multipart_test stream sendfile
30 | '';
31 | buildPhase = ''
32 | dune build bin/carl.exe --display=short --profile=${if static then "static" else "release"}
33 | '';
34 | installPhase = ''
35 | mkdir -p $out/bin
36 | mv _build/default/bin/carl.exe $out/bin/carl
37 | '';
38 |
39 | nativeBuildInputs = [
40 | ocaml
41 | dune
42 | findlib
43 | ];
44 |
45 | buildInputs = [
46 | piaf
47 | cmdliner
48 | fmt
49 | camlzip
50 | ezgzip
51 | ];
52 |
53 | meta = {
54 | description = "`curl` clone implemented using Piaf.";
55 | license = lib.licenses.bsd3;
56 | };
57 | }
58 |
--------------------------------------------------------------------------------
/ocaml/piaf/default.nix:
--------------------------------------------------------------------------------
1 | { stdenv
2 | , lib
3 | , fetchFromGitHub
4 | , buildDunePackage
5 | , eio
6 | , eio_main
7 | , eio-ssl
8 | , h2-eio
9 | , httpun-eio
10 | , ipaddr
11 | , magic-mime
12 | , pecu
13 | , prettym
14 | , uri
15 | , uutf
16 | , unstrctrd
17 | , httpun-ws
18 | , alcotest
19 | , dune-site
20 | , ocaml
21 | }:
22 |
23 | buildDunePackage {
24 | pname = "piaf";
25 | version = "n/a";
26 | src = fetchFromGitHub {
27 | owner = "anmonteiro";
28 | repo = "piaf";
29 | rev = "c27b38e4493e81b0a7c895c620976bf155f14d8b";
30 | hash = "sha256-3IUxX3Zax5ddMTKJufMCeRvZoFWbTYMvfHFFpN15PuA=";
31 | fetchSubmodules = true;
32 | };
33 |
34 | propagatedBuildInputs = [
35 | eio
36 | eio_main
37 | eio-ssl
38 | httpun-eio
39 | h2-eio
40 | ipaddr
41 | magic-mime
42 | pecu
43 | prettym
44 | unstrctrd
45 | uutf
46 | uri
47 | httpun-ws
48 | ];
49 |
50 | meta = {
51 | description = "An HTTP library with HTTP/2 support written entirely in OCaml";
52 | license = lib.licenses.bsd3;
53 | };
54 | }
55 |
--------------------------------------------------------------------------------
/ocaml/ppx_deriving_cmdliner.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/ppx_deriving_cmdliner_runtime.ml b/src/ppx_deriving_cmdliner_runtime.ml
2 | index bc65432..8a565b1 100644
3 | --- a/src/ppx_deriving_cmdliner_runtime.ml
4 | +++ b/src/ppx_deriving_cmdliner_runtime.ml
5 | @@ -11,5 +11,5 @@ let rec map_bind f acc xs =
6 | | x :: xs -> f x >>= fun x -> map_bind f (x :: acc) xs
7 | | [] -> Result.Ok (List.rev acc)
8 |
9 | -type 'a error_or = ('a, string) Result.result
10 | +type 'a error_or = ('a, string) result
11 |
12 | diff --git a/src/ppx_deriving_cmdliner_runtime.mli b/src/ppx_deriving_cmdliner_runtime.mli
13 | index 52bd19f..24e1076 100644
14 | --- a/src/ppx_deriving_cmdliner_runtime.mli
15 | +++ b/src/ppx_deriving_cmdliner_runtime.mli
16 | @@ -1,4 +1,4 @@
17 | -type 'a error_or = ('a, string) Result.result
18 | +type 'a error_or = ('a, string) result
19 |
20 | val ( >>= ) : 'a error_or -> ('a -> 'b error_or) -> 'b error_or
21 | val ( >|= ) : 'a error_or -> ('a -> 'b) -> 'b error_or
22 | @@ -11,8 +11,3 @@ module Int32 : (module type of Int32)
23 | module Int64 : (module type of Int64)
24 | module Nativeint : (module type of Nativeint)
25 | module Array : (module type of Array)
26 | -module Result : sig
27 | - type ('a, 'b) result = ('a, 'b) Result.result =
28 | - | Ok of 'a
29 | - | Error of 'b
30 | -end
31 |
--------------------------------------------------------------------------------
/ocaml/ppx_jsx_embed/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, reason, ppxlib }:
2 |
3 | buildDunePackage {
4 | pname = "ppx_jsx_embed";
5 | version = "0.0.0";
6 | src = fetchFromGitHub {
7 | owner = "melange-re";
8 | repo = "ppx_jsx_embed";
9 | rev = "97045c4544f25729bdc05a3cb50743c20210686c";
10 | hash = "sha256-7dPvSmpT+hU6+GlZoa/SpHVi7zRHwX/SZR7Jsk2aJ3A=";
11 | };
12 | doCheck = true;
13 | propagatedBuildInputs = [ reason ppxlib ];
14 | }
15 |
--------------------------------------------------------------------------------
/ocaml/ppx_rapper/async.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, async, caqti-async, ppx_rapper }:
2 |
3 | buildDunePackage {
4 | pname = "ppx_rapper_async";
5 | inherit (ppx_rapper) src version;
6 |
7 | propagatedBuildInputs = [ async caqti-async ppx_rapper ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/ppx_rapper/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, base, caqti, pg_query }:
2 |
3 | buildDunePackage rec {
4 | pname = "ppx_rapper";
5 | version = "3.0.0";
6 |
7 | src = fetchFromGitHub {
8 | owner = "roddyyaga";
9 | repo = "ppx_rapper";
10 | rev = "5b0e62def2d5cc6cbe3dedec1ecb289bee350f9a";
11 | hash = "sha256-Fn13E8H5+ciEIF5wIA6qzEGX5GLe0SYz7i/TSdk1g1M=";
12 | };
13 |
14 | propagatedBuildInputs = [ caqti pg_query base ];
15 | }
16 |
--------------------------------------------------------------------------------
/ocaml/ppx_rapper/eio.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, ppx_rapper, eio, caqti-eio }:
2 |
3 | buildDunePackage {
4 | pname = "ppx_rapper_eio";
5 | inherit (ppx_rapper) src version;
6 |
7 | propagatedBuildInputs = [ ppx_rapper eio caqti-eio ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/ppx_rapper/lwt.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, ppx_rapper, lwt, caqti-lwt }:
2 |
3 | buildDunePackage {
4 | pname = "ppx_rapper_lwt";
5 | inherit (ppx_rapper) src version;
6 |
7 | propagatedBuildInputs = [ ppx_rapper lwt caqti-lwt ];
8 | }
9 |
--------------------------------------------------------------------------------
/ocaml/prometheus/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage }:
2 |
3 | buildDunePackage {
4 | pname = "prometheus";
5 | version = "n/a";
6 |
7 | src = builtins.fetchurl {
8 | url = "https://github.com/ulrikstrid/prometheus/archive/5acd3509.tar.gz";
9 | sha256 = "01vxgjfydiwa5164c0l0waks3k3xj0mj2f6bxf7mjhcxj6bixhns";
10 | };
11 | }
12 |
--------------------------------------------------------------------------------
/ocaml/redemon/default.nix:
--------------------------------------------------------------------------------
1 | { lib, fetchFromGitHub, buildDunePackage, luv, cmdliner, logs, fmt }:
2 |
3 | buildDunePackage {
4 | pname = "redemon";
5 | version = "0.4.0";
6 | src = fetchFromGitHub {
7 | owner = "ulrikstrid";
8 | repo = "redemon";
9 | rev = "0.4.0";
10 | sha256 = "sha256-M3tBxNLjEkZmmVbjqBmMRMK1cmiNTzxYfnPvnk3jfAE=";
11 | };
12 |
13 | propagatedBuildInputs = [ luv cmdliner logs fmt ];
14 | postPatch = ''
15 | substituteInPlace bin/main.ml \
16 | --replace-fail '%s" file' '%s" (Option.get file)' \
17 | --replace-fail '.extension file' '.extension (Option.get file)'
18 | '';
19 |
20 | meta = {
21 | description = "nodemon replacement written in OCaml, with luv";
22 | license = lib.licenses.mit;
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/ocaml/redis/default.nix:
--------------------------------------------------------------------------------
1 | { lib, fetchFromGitHub, buildDunePackage, uuidm, re, stdlib-shims }:
2 |
3 | buildDunePackage rec {
4 | pname = "redis";
5 | version = "0.7";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/0xffea/ocaml-redis/releases/download/v0.7.1/redis-0.7.1.tbz";
8 | sha256 = "02llmcfjh8dplc456y8y3vvvslsdib1r679pn8baphfm8xn1zxqf";
9 | };
10 |
11 | propagatedBuildInputs = [ uuidm re stdlib-shims ];
12 |
13 | meta = {
14 | description = "Redis client";
15 | license = lib.licenses.bsd3;
16 | };
17 | }
18 |
--------------------------------------------------------------------------------
/ocaml/redis/lwt.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, redis, lwt, ounit, containers }:
2 |
3 | buildDunePackage {
4 | pname = "redis-lwt";
5 | inherit (redis) src version;
6 |
7 | propagatedBuildInputs = [ redis lwt ];
8 |
9 | checkInputs = [ ounit containers ];
10 |
11 | meta = {
12 | description = "Redis client (lwt interface)";
13 | license = lib.licenses.bsd3;
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/ocaml/redis/sync.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, redis, ounit, containers, camlp-streams }:
2 |
3 | buildDunePackage {
4 | pname = "redis-sync";
5 | inherit (redis) src version;
6 |
7 | propagatedBuildInputs = [ redis camlp-streams ];
8 |
9 | meta = {
10 | description = "Redis client (blocking)";
11 | license = lib.licenses.bsd3;
12 | };
13 | }
14 |
--------------------------------------------------------------------------------
/ocaml/reenv/default.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , fetchFromGitHub
3 | , buildDunePackage
4 | , alcotest
5 | , junit
6 | , junit_alcotest
7 | , reason
8 | , cmdliner
9 | , re
10 | }:
11 |
12 | buildDunePackage {
13 | pname = "reenv";
14 | version = "0.4.0-dev";
15 | src = fetchFromGitHub {
16 | owner = "ulrikstrid";
17 | repo = "reenv";
18 | rev = "64dbee58dbe01c86e24db3bdcb8961fdc178deb1";
19 | sha256 = "sha256-p+RyVAmIEhUlRhLVrWJcrlcJ4fcyVbgo8YxZ0DT2c2w=";
20 | };
21 |
22 | checkInputs = [ alcotest junit junit_alcotest ];
23 |
24 | doCheck = true;
25 |
26 | nativeBuildInputs = [ reason ];
27 | propagatedBuildInputs = [ cmdliner re ];
28 |
29 | meta = {
30 | description = "dotenv-cli written in reason";
31 | license = lib.licenses.mit;
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/ocaml/sendfile/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage }:
2 |
3 | buildDunePackage {
4 | pname = "sendfile";
5 | version = "dev";
6 | src = builtins.fetchurl {
7 | url = "https://github.com/anmonteiro/ocaml-sendfile/archive/75c37fc.tar.gz";
8 | sha256 = "0nfsyi6r22yrdm1i1la23775dfm5cingawwrl2rfhsdzx0s46j26";
9 | };
10 | }
11 |
--------------------------------------------------------------------------------
/ocaml/sherlodoc/default.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , fetchFromGitHub
3 | , buildDunePackage
4 | , js_of_ocaml-compiler
5 | , result
6 | , tyxml
7 | , ppx_blob
8 | , lwt
9 | , fpath
10 | , decompress
11 | , cmdliner
12 | , brr
13 | , bigstringaf
14 | , base64
15 | , odoc
16 | , odoc-parser
17 | , menhir
18 | , fmt
19 | , dream
20 | , enableServe ? false
21 | ,
22 | }:
23 |
24 | buildDunePackage {
25 | pname = "sherlodoc";
26 | version = "0.2";
27 | src = fetchFromGitHub {
28 | owner = "art-w";
29 | repo = "sherlodoc";
30 | rev = "0.2";
31 | sha256 = "sha256-MEYKtlVoSYZhh4ernon1FHGFykfeCmv6qQi+cyy3LX8=";
32 | };
33 | nativeBuildInputs = [ menhir js_of_ocaml-compiler ];
34 | propagatedBuildInputs = [
35 | result
36 | tyxml
37 | ppx_blob
38 | lwt
39 | fpath
40 | decompress
41 | cmdliner
42 | brr
43 | bigstringaf
44 | base64
45 | odoc
46 | odoc-parser
47 | fmt
48 | ] ++ lib.optional enableServe dream;
49 | }
50 |
--------------------------------------------------------------------------------
/ocaml/sodium-cc-patch.patch:
--------------------------------------------------------------------------------
1 | diff --git a/lib_gen/dune b/lib_gen/dune
2 | index ac538a6..982e208 100644
3 | --- a/lib_gen/dune
4 | +++ b/lib_gen/dune
5 | @@ -38,7 +38,7 @@
6 | (rule
7 | (deps sodium_types_detect.c)
8 | (targets sodium_types_detect)
9 | - (action (bash "cc -I \"$(ocamlfind query ctypes)\" -I \"$(ocamlc -where)\" -o sodium_types_detect sodium_types_detect.c")))
10 | + (action (bash "$CC -I \"$(ocamlfind query ctypes)\" -I \"$(ocamlc -where)\" -o sodium_types_detect sodium_types_detect.c")))
11 |
12 | (rule
13 | (deps sodium_types_detect)
14 |
--------------------------------------------------------------------------------
/ocaml/sqlite3-pkg-config-env-var.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/config/discover.ml b/src/config/discover.ml
2 | index 8e806a9..c9616c9 100644
3 | --- a/src/config/discover.ml
4 | +++ b/src/config/discover.ml
5 | @@ -97,12 +97,17 @@ let () =
6 | opt_map (C.ocaml_config_var c "target") ~default:"" ~f:(fun target ->
7 | "--personality=" ^ target)
8 | in
9 | - let cflags =
10 | - let cmd =
11 | - pkg_export
12 | - ^ (if is_mingw then " pkgconf " ^ personality else " pkg-config")
13 | - ^ " --cflags sqlite3"
14 | + let pkg_config =
15 | + let pkg_config =
16 | + match Sys.getenv "PKG_CONFIG" with
17 | + | s -> s
18 | + | exception Not_found -> "pkg-config"
19 | in
20 | + pkg_export
21 | + ^ if is_mingw then " pkgconf " ^ personality else " " ^ pkg_config
22 | + in
23 | + let cflags =
24 | + let cmd = pkg_config ^ " --cflags sqlite3" in
25 | match read_lines_from_cmd ~max_lines:1 cmd with
26 | | [ cflags ] ->
27 | let cflags = split_ws cflags in
28 | @@ -114,11 +119,7 @@ let () =
29 | | _ -> failwith "pkg-config failed to return cflags"
30 | in
31 | let libs =
32 | - let cmd =
33 | - pkg_export
34 | - ^ (if is_mingw then " pkgconf " ^ personality else " pkg-config")
35 | - ^ " --libs sqlite3"
36 | - in
37 | + let cmd = pkg_config ^ " --libs sqlite3" in
38 | match read_lines_from_cmd ~max_lines:1 cmd with
39 | | [ libs ] -> split_ws libs
40 | | _ -> failwith "pkg-config failed to return libs"
41 |
--------------------------------------------------------------------------------
/ocaml/subscriptions-transport-ws/default.nix:
--------------------------------------------------------------------------------
1 | { lib, fetchFromGitHub, buildDunePackage, httpun-ws, graphql }:
2 |
3 | buildDunePackage {
4 | pname = "subscriptions-transport-ws";
5 | version = "0.0.1-dev";
6 |
7 | src = fetchFromGitHub {
8 | owner = "anmonteiro";
9 | repo = "ocaml-subscriptions-transport-ws";
10 | rev = "f64a1b350cbdea98f62824429ab592c3a2031761";
11 | sha256 = "sha256-15zAWaYOM8ufYc6Ad5esXbqFHNGXZXBX2WrRZhsi0wI=";
12 | };
13 |
14 | propagatedBuildInputs = [ httpun-ws graphql ];
15 |
16 | meta = {
17 | license = lib.licenses.bsd3;
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/ocaml/timere/default.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , seq
3 | , timedesc-tzlocal
4 | , oseq
5 | , containers
6 | , fmt
7 | , timedesc
8 | , timedesc-sexp
9 | , diet
10 | }:
11 |
12 | buildDunePackage {
13 | pname = "timere";
14 | inherit (timedesc-tzlocal) src version;
15 | propagatedBuildInputs = [
16 | seq
17 | oseq
18 | containers
19 | fmt
20 | timedesc
21 | timedesc-sexp
22 | diet
23 | ];
24 | }
25 |
--------------------------------------------------------------------------------
/ocaml/timere/parse.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , timere
3 | , oseq
4 | , re
5 | , containers
6 | , timedesc
7 | , mparser
8 | }:
9 |
10 | buildDunePackage {
11 | pname = "timere-parse";
12 | inherit (timere) src version;
13 | propagatedBuildInputs = [
14 | oseq
15 | re
16 | containers
17 | timedesc
18 | timere
19 | mparser
20 | ];
21 | }
22 |
--------------------------------------------------------------------------------
/ocaml/timere/timedesc-json.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, timedesc, yojson }:
2 |
3 | buildDunePackage {
4 | pname = "timedesc-json";
5 | inherit (timedesc) src version;
6 | propagatedBuildInputs = [
7 | timedesc
8 | yojson
9 | ];
10 | }
11 |
--------------------------------------------------------------------------------
/ocaml/timere/timedesc-sexp.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , timedesc
3 | , timedesc-tzlocal
4 | , sexplib
5 | }:
6 |
7 | buildDunePackage {
8 | pname = "timedesc-sexp";
9 | inherit (timedesc-tzlocal) src version;
10 | propagatedBuildInputs = [ timedesc sexplib ];
11 | }
12 |
--------------------------------------------------------------------------------
/ocaml/timere/timedesc-tzdb.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, timedesc-tzlocal }:
2 |
3 | buildDunePackage {
4 | pname = "timedesc-tzdb";
5 | inherit (timedesc-tzlocal) src version;
6 | }
7 |
--------------------------------------------------------------------------------
/ocaml/timere/timedesc-tzlocal.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, fetchFromGitHub }:
2 |
3 | buildDunePackage {
4 | pname = "timedesc-tzlocal";
5 | version = "3.0.0";
6 | src = fetchFromGitHub {
7 | owner = "daypack-dev";
8 | repo = "timere";
9 | rev = "timedesc-3.1.0";
10 | hash = "sha256-b1tg2xtqbOkEEHsB7eRXWLSD3DTWGfJogeQZFF2/93E=";
11 | };
12 | }
13 |
--------------------------------------------------------------------------------
/ocaml/timere/timedesc.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage
2 | , timedesc-tzdb
3 | , timedesc-tzlocal
4 | , seq
5 | , angstrom
6 | , ptime
7 | , crowbar
8 | , alcotest
9 | , qcheck-alcotest
10 | , qcheck
11 | }:
12 |
13 | buildDunePackage {
14 | pname = "timedesc";
15 | inherit (timedesc-tzlocal) src version;
16 | propagatedBuildInputs = [
17 | timedesc-tzdb
18 | timedesc-tzlocal
19 | seq
20 | angstrom
21 | ptime
22 | ];
23 |
24 | doCheck = true;
25 | checkPhase = ''
26 | dune runtest -p timedesc timedesc-sexp
27 | '';
28 | checkInputs = [
29 | crowbar
30 | alcotest
31 | qcheck-alcotest
32 | qcheck
33 | ];
34 | }
35 |
--------------------------------------------------------------------------------
/ocaml/typedppxlib/default.nix:
--------------------------------------------------------------------------------
1 | { fetchFromGitHub, buildDunePackage, ppx_optcomp, ocaml-migrate-types }:
2 |
3 | buildDunePackage {
4 | pname = "typedppxlib";
5 | version = "n/a";
6 | src = fetchFromGitHub {
7 | owner = "EduardoRFS";
8 | repo = "typedppxlib";
9 | rev = "658d0b1";
10 | sha256 = "sha256-Cocy+xxeRaEztptMkxEUqwFwoMgGjm3Zti6IBXd/V7U=";
11 | };
12 | propagatedBuildInputs = [ ppx_optcomp ocaml-migrate-types ];
13 | }
14 |
--------------------------------------------------------------------------------
/ocaml/typedppxlib/ppx_debug.nix:
--------------------------------------------------------------------------------
1 | { buildDunePackage, typedppxlib }:
2 |
3 | buildDunePackage {
4 | pname = "ppx_debug";
5 | inherit (typedppxlib) version src;
6 | propagatedBuildInputs = [ typedppxlib ];
7 | }
8 |
--------------------------------------------------------------------------------
/ocaml/tyxml/jsx.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, tyxml, tyxml-syntax, ppxlib, reason, alcotest }:
2 |
3 | buildDunePackage {
4 | inherit (tyxml) src version;
5 | pname = "tyxml-jsx";
6 |
7 | propagatedBuildInputs = [ tyxml tyxml-syntax ppxlib reason ];
8 |
9 | nativeCheckInputs = [ reason ];
10 | checkInputs = [ alcotest ];
11 |
12 | # Tests are broken for some reason (pun intended)
13 | # doCheck = true;
14 |
15 | meta = {
16 | description = "JSX syntax to write TyXML documents";
17 | license = lib.licenses.lgpl21;
18 | };
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/ocaml/tyxml/ppx.nix:
--------------------------------------------------------------------------------
1 | { lib
2 | , buildDunePackage
3 | , tyxml
4 | , tyxml-syntax
5 | , ppxlib
6 | , reason
7 | , markup
8 | , alcotest
9 | }:
10 |
11 | buildDunePackage {
12 | pname = "tyxml-ppx";
13 | inherit (tyxml) src version;
14 |
15 | propagatedBuildInputs = [ tyxml tyxml-syntax ppxlib reason markup ];
16 |
17 | checkInputs = [ alcotest ];
18 | doCheck = true;
19 |
20 | meta = {
21 | description = "JSX syntax to write TyXML documents";
22 | license = lib.licenses.lgpl21;
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/ocaml/tyxml/syntax.nix:
--------------------------------------------------------------------------------
1 | { lib, buildDunePackage, ppxlib, uutf, re, tyxml, alcotest }:
2 |
3 | buildDunePackage {
4 | pname = "tyxml-syntax";
5 | inherit (tyxml) src version;
6 |
7 | propagatedBuildInputs = [ ppxlib uutf re ];
8 | checkInputs = [ alcotest ];
9 | doCheck = true;
10 |
11 | meta = {
12 | description = "Common layer for the JSX and PPX syntaxes for Tyxml";
13 | license = lib.licenses.lgpl21;
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/ocaml/uutf-locals.patch:
--------------------------------------------------------------------------------
1 | diff --git a/src/uutf.ml b/src/uutf.ml
2 | --- a/src/uutf.ml
3 | +++ b/src/uutf.ml
4 | @@ -719,7 +719,7 @@ module String = struct
5 | | `UTF_16LE d -> `UTF_16LE, (d = `BOM)
6 |
7 | type 'a folder =
8 | - 'a -> int -> [ `Uchar of Uchar.t | `Malformed of string ] -> 'a
9 | + 'a -> local_ (int -> [ `Uchar of Uchar.t | `Malformed of string ] -> 'a)
10 |
11 | let fold_utf_8 ?(pos = 0) ?len f acc s =
12 | let rec loop acc f s i last =
13 | diff --git a/src/uutf.mli b/src/uutf.mli
14 | --- a/src/uutf.mli
15 | +++ b/src/uutf.mli
16 | @@ -325,12 +325,12 @@ module String : sig
17 | {b Note.} Initial {{:http://unicode.org/glossary/#byte_order_mark}BOM}s
18 | are also folded over. *)
19 |
20 | - type 'a folder = 'a -> int -> [ `Uchar of Uchar.t | `Malformed of string ] ->
21 | - 'a
22 | + type 'a folder = 'a -> local_ (int -> [ `Uchar of Uchar.t | `Malformed of string ] ->
23 | + 'a)
24 | (** The type for character folders. The integer is the index in the
25 | string where the [`Uchar] or [`Malformed] starts. *)
26 |
27 | - val fold_utf_8 : ?pos:int -> ?len:int -> 'a folder -> 'a -> string -> 'a
28 | + val fold_utf_8 : ?pos:int -> ?len:int -> local_ 'a folder -> 'a -> string -> 'a
29 | (** [fold_utf_8 f a s ?pos ?len ()] is
30 | [f (] ... [(f (f a pos u]{_0}[) j]{_1}[ u]{_1}[)] ... [)] ... [)
31 | j]{_n}[ u]{_n}
32 | @@ -339,7 +339,7 @@ module String : sig
33 | long. The default value for [pos] is [0] and [len] is
34 | [String.length s - pos]. *)
35 |
36 | - val fold_utf_16be : ?pos:int -> ?len:int -> 'a folder -> 'a -> string -> 'a
37 | + val fold_utf_16be : ?pos:int -> ?len:int -> local_ 'a folder -> 'a -> string -> 'a
38 | (** [fold_utf_16be f a s ?pos ?len ()] is
39 | [f (] ... [(f (f a pos u]{_0}[) j]{_1}[ u]{_1}[)] ... [)] ... [)
40 | j]{_n}[ u]{_n}
41 | @@ -348,7 +348,7 @@ module String : sig
42 | long. The default value for [pos] is [0] and [len] is
43 | [String.length s - pos]. *)
44 |
45 | - val fold_utf_16le : ?pos:int -> ?len:int -> 'a folder -> 'a -> string -> 'a
46 | + val fold_utf_16le : ?pos:int -> ?len:int -> local_ 'a folder -> 'a -> string -> 'a
47 | (** [fold_utf_16le f a s ?pos ?len ()] is
48 | [f (] ... [(f (f a pos u]{_0}[) j]{_1}[ u]{_1}[)] ... [)] ... [)
49 | j]{_n}[ u]{_n}
50 |
--------------------------------------------------------------------------------
/overlay/default.nix:
--------------------------------------------------------------------------------
1 | # `nixpkgs` here are the `nixpkgs` sources, i.e. the flake input
2 | nixpkgs:
3 |
4 | # This might be helfpul later:
5 | # https://www.reddit.com/r/NixOS/comments/6hswg4/how_do_i_turn_an_overlay_into_a_proper_package_set/
6 | self: super:
7 |
8 | let
9 | inherit (super)
10 | lib
11 | stdenv
12 | fetchFromGitHub
13 | callPackage
14 | fetchpatch
15 | buildGoModule
16 | haskell
17 | haskellPackages;
18 |
19 | overlayOCamlPackages = attrs: import ../ocaml/overlay-ocaml-packages.nix (attrs // {
20 | inherit nixpkgs;
21 | });
22 | staticLightExtend = pkgSet: pkgSet.extend (self: super:
23 | super.lib.overlayOCamlPackages {
24 | inherit self super;
25 | overlays = [ (super.callPackage ../static/ocaml.nix { }) ];
26 | updateOCamlPackages = true;
27 | });
28 |
29 | in
30 |
31 | (overlayOCamlPackages {
32 | inherit self super;
33 | overlays = [
34 | (callPackage ../ocaml {
35 | inherit nixpkgs;
36 | super-opaline = super.opaline;
37 | oniguruma-lib = super.oniguruma;
38 | libgsl = super.gsl;
39 | })
40 | ];
41 | }) // {
42 | # Place a canary
43 | __nix-ocaml-overlays-applied = 1;
44 |
45 | # Cross-compilation / static overlays
46 | pkgsMusl = staticLightExtend super.pkgsMusl;
47 | pkgsStatic = staticLightExtend super.pkgsStatic;
48 |
49 | pkgsCross =
50 | let
51 | static-overlay = import ../static;
52 | cross-overlay = callPackage ../cross { };
53 | in
54 | super.pkgsCross // {
55 | musl64 = super.pkgsCross.musl64.extend static-overlay;
56 |
57 | aarch64-multiplatform =
58 | super.pkgsCross.aarch64-multiplatform.extend cross-overlay;
59 |
60 | aarch64-multiplatform-musl =
61 | (super.pkgsCross.aarch64-multiplatform-musl.appendOverlays
62 | [ cross-overlay static-overlay ]);
63 |
64 | riscv64 = super.pkgsCross.riscv64.extend cross-overlay;
65 | };
66 |
67 | # Override `pkgs.nix` to the unstable channel
68 | nix = super.nixVersions.latest;
69 |
70 | # Other packages
71 |
72 | # Stripped down postgres without the `bin` part, to allow static linking
73 | # with musl.
74 | libpq = (super.postgresql_17.override {
75 | # a new change does some shenanigans to get llvmStdenv + lld which breaks
76 | # our cross-compilation
77 | overrideCC = _: _: super.stdenv;
78 | systemdSupport = false;
79 | gssSupport = false;
80 | openssl = self.openssl-oc;
81 | jitSupport = false;
82 | pamSupport = false;
83 | perlSupport = false;
84 | pythonSupport = false;
85 | tclSupport = false;
86 | lz4 = self.lz4-oc;
87 | zstd = self.zstd-oc;
88 | zlib = self.zlib-oc;
89 | }).overrideAttrs (o:
90 | let
91 | pg_config = super.writeShellScriptBin "pg_config" (builtins.readFile "${nixpkgs}/pkgs/servers/sql/postgresql/pg_config.sh");
92 | in
93 | {
94 | env = {
95 | CFLAGS = "-fdata-sections -ffunction-sections"
96 | + (if stdenv.cc.isClang then " -flto" else " -fmerge-constants -Wl,--gc-sections");
97 | NIX_CFLAGS_COMPILE = "-UUSE_PRIVATE_ENCODING_FUNCS";
98 | };
99 | doCheck = false;
100 | doInstallCheck = false;
101 |
102 | postPatch =
103 | o.postPatch + lib.optionalString (o.dontDisableStatic or false) ''
104 | substituteInPlace src/interfaces/libpq/Makefile \
105 | --replace-fail "echo 'libpq must not be calling any function which invokes exit'; exit 1;" "echo;"
106 | '';
107 |
108 | configureFlags = [
109 | "--without-ldap"
110 | "--without-readline"
111 | "--with-openssl"
112 | "--with-libxml"
113 | "--sysconfdir=/etc"
114 | "--with-system-tzdata=${super.tzdata}/share/zoneinfo"
115 | "--enable-debug"
116 | "--with-icu"
117 | "--with-lz4"
118 | "--with-zstd"
119 | "--with-uuid=e2fs"
120 | ]
121 | ++ lib.optionals stdenv.hostPlatform.isRiscV [ "--disable-spinlocks" ]
122 | ++ lib.optionals stdenv.isLinux [ "--with-pam" ]
123 | # This could be removed once the upstream issue is resolved:
124 | # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de
125 | ++ lib.optionals stdenv.isDarwin [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ];
126 |
127 | propagatedBuildInputs = with self; [
128 | lz4-oc
129 | zstd-oc
130 | zlib-oc
131 | libuuid
132 | libxml2
133 | icu
134 | openssl-oc.dev
135 | ]
136 | ++ lib.optionals stdenv.isLinux [ linux-pam ];
137 | # Use a single output derivation. The upstream PostgreSQL derivation
138 | # produces multiple outputs (including "out" and "lib"), and then puts some
139 | # lib/ artifacts in `$lib/lib` and some in `$out/lib`. This causes the
140 | # pkg-config `--libs` flags to be invalid (since it only knows about one
141 | # such lib path, not both)
142 | outputs = [ "out" "dev" "doc" "man" ];
143 |
144 | postInstall = ''
145 | moveToOutput "bin/ecpg" "$dev"
146 | moveToOutput "lib/pgxs" "$dev"
147 | # Pretend pg_config is located in $out/bin to return correct paths, but
148 | # actually have it in -dev to avoid pulling in all other outputs. See the
149 | # pg_config.sh script's comments for details.
150 | moveToOutput "bin/pg_config" "$dev"
151 | install -c -m 755 "${pg_config}"/bin/pg_config "$out/bin/pg_config"
152 | wrapProgram "$dev/bin/pg_config" --argv0 "$out/bin/pg_config"
153 | # postgres exposes external symbols get_pkginclude_path and similar. Those
154 | # can't be stripped away by --gc-sections/LTO, because they could theoretically
155 | # be used by dynamically loaded modules / extensions. To avoid circular dependencies,
156 | # references to -dev, -doc and -man are removed here. References to -lib must be kept,
157 | # because there is a realistic use-case for extensions to locate the /lib directory to
158 | # load other shared modules.
159 | remove-references-to -t "$dev" -t "$doc" -t "$man" "$out/bin/postgres"
160 | if [ -z "''${dontDisableStatic:-}" ]; then
161 | # Remove static libraries in case dynamic are available.
162 | for i in $out/lib/*.a; do
163 | name="$(basename "$i")"
164 | ext="${stdenv.hostPlatform.extensions.sharedLibrary}"
165 | if [ -e "$out/lib/''${name%.a}$ext" ] || [ -e "''${i%.a}$ext" ]; then
166 | rm "$i"
167 | fi
168 | done
169 | fi
170 | # The remaining static libraries are libpgcommon.a, libpgport.a and related.
171 | # Those are only used when building e.g. extensions, so go to $dev.
172 | moveToOutput "lib/*.a" "$dev"
173 | '' +
174 | lib.optionalString stdenv.hostPlatform.isDarwin ''
175 | # The darwin specific Makefile for PGXS contains a reference to the postgres
176 | # binary. Some extensions (here: postgis), which are able to set bindir correctly
177 | # to their own output for installation, will then fail to find "postgres" during linking.
178 | substituteInPlace "$dev/lib/pgxs/src/Makefile.port" \
179 | --replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres"
180 | '';
181 | });
182 |
183 | gnome2 = super.gnome2 // {
184 | gtksourceview = super.gtksourceview.overrideAttrs (_: {
185 | env = lib.optionalAttrs stdenv.cc.isGNU {
186 | NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
187 | };
188 | });
189 | };
190 |
191 | opaline = null;
192 | ott = super.ott.override { opaline = self.ocamlPackages.opaline; };
193 |
194 | h2spec = super.buildGoModule {
195 | pname = "h2spec";
196 | version = "dev";
197 |
198 | src = fetchFromGitHub {
199 | owner = "summerwind";
200 | repo = "h2spec";
201 | rev = "af83a65f0b";
202 | sha256 = "sha256-z06uQiImMD4nPLp4Qxka9JT9NTmY0AurnHQKhB/kM40=";
203 | };
204 | vendorHash = "sha256-YSaLOYIHgMCK2hXSDL+aoBEfOX7j6rnJ4DMWg0jhzWY=";
205 | };
206 |
207 | h3spec = haskell.lib.compose.justStaticExecutables
208 | (haskellPackages.callPackage
209 | ({ mkDerivation
210 | , base
211 | , bytestring
212 | , hspec
213 | , hspec-core
214 | , http-types
215 | , http3
216 | , network
217 | , quic
218 | , tls
219 | , unliftio
220 | }: mkDerivation rec {
221 | pname = "h3spec";
222 | version = "0.1.8";
223 | src = fetchFromGitHub {
224 | owner = "kazu-yamamoto";
225 | repo = "h3spec";
226 | rev = "b44e487b143a45536206773b06eb2c80cbbae28e";
227 | sha256 = "sha256-nH4NaxHdnf4kaCCUnJXSkjt5Wkb8qGv3d0+sVjyatXA==";
228 | };
229 |
230 | isExecutable = true;
231 | libraryHaskellDepends = [
232 | base
233 | bytestring
234 | hspec
235 | hspec-core
236 | http-types
237 | http3
238 | network
239 | quic
240 | tls
241 | unliftio
242 | ];
243 | executableHaskellDepends = libraryHaskellDepends;
244 | mainProgram = "h3spec";
245 | license = lib.licenses.mit;
246 | })
247 | { });
248 |
249 | hermes = stdenv.mkDerivation {
250 | name = "hermes";
251 | src = super.fetchFromGitHub {
252 | owner = "facebook";
253 | repo = "hermes";
254 | rev = "ee2922a50fb719bdb378025d95dbd32ad93cd679";
255 | hash = "sha256-TXTcKAdfnznJQu2YPCRwzDlKMoV/nvp5mpsIrMUmH1c=";
256 | };
257 | patches = [ ./hermes-static-link.patch ];
258 | buildPhase = ''
259 | ninjaBuildPhase
260 | '';
261 | cmakeFlags = [
262 | "-GNinja"
263 | "-DHERMES_ENABLE_TEST_SUITE=false"
264 | ] ++ lib.optional stdenv.isDarwin [
265 | "-DHERMES_BUILD_APPLE_FRAMEWORK=false"
266 | ];
267 | nativeBuildInputs = with self; [ cmake python3 ninja ];
268 | propagatedBuildInputs = with self; [ icu readline-oc ];
269 | };
270 |
271 |
272 | lib = lib // { inherit overlayOCamlPackages; };
273 |
274 | inherit (callPackage ../cockroachdb { })
275 | cockroachdb-21_1_x
276 | cockroachdb-21_2_x
277 | cockroachdb-22_x;
278 | cockroachdb = self.cockroachdb-21_1_x;
279 |
280 | dune-dev = self.ocamlPackages.dune_3.overrideAttrs (_: {
281 | src = super.fetchFromGitHub {
282 | owner = "ocaml";
283 | repo = "dune";
284 | rev = "d6f1a2740ac584127105773a43283829ae7a39e7";
285 | hash = "sha256-tIa6mIQvhPi6B2c7aK+tq3WJkuEPiDuvRtvHkaxCC3w=";
286 | };
287 | configureFlags = [
288 | "--toolchains enable"
289 | "--pkg-build-progress enable"
290 | "--lock-dev-tool enable"
291 | ];
292 | });
293 | opam = self.ocamlPackages.opam;
294 |
295 | pnpm =
296 | let
297 | inherit (self)
298 | writeScriptBin runtimeShell nodejs_latest nodePackages_latest;
299 | in
300 | writeScriptBin "pnpm" ''
301 | #!${runtimeShell}
302 | ${nodejs_latest}/bin/node \
303 | ${nodePackages_latest.pnpm}/lib/node_modules/pnpm/bin/pnpm.cjs \
304 | "$@"
305 | '';
306 |
307 | melange-relay-compiler =
308 | let
309 | inherit (super) rustPlatform darwin pkg-config openssl;
310 | melange-relay-compiler-src = stdenv.mkDerivation {
311 | name = "melange-relay-compiler-src";
312 | src = fetchFromGitHub {
313 | owner = "anmonteiro";
314 | repo = "relay";
315 | rev = "670aae168499bc1fe8a876bdeb9f60f25f89160c";
316 | hash = "sha256-Eq804+sWG39WIdmAJIiUrUuop38fKAI8C45pqfEV01k=";
317 | sparseCheckout = [ "compiler" ];
318 | };
319 | dontBuild = true;
320 | installPhase = ''
321 | mkdir $out
322 | cp -r ./* $out
323 | '';
324 | };
325 | in
326 | rustPlatform.buildRustPackage {
327 | pname = "relay";
328 | version = "n/a";
329 | src = "${melange-relay-compiler-src}/compiler";
330 | cargoHash = "sha256-3Y7ufcT0c4Tr5J6LlqSDPCj8WUyWg8hned5SSoq1hj4=";
331 |
332 | nativeBuildInputs = lib.optionals stdenv.isLinux [ pkg-config ];
333 | # Needed to get openssl-sys to use pkg-config.
334 | # Doesn't seem to like OpenSSL 3
335 | OPENSSL_NO_VENDOR = 1;
336 |
337 | buildInputs = lib.optionals stdenv.isLinux [ openssl ];
338 | propagatedBuildInputs = lib.optionals stdenv.isDarwin [
339 | darwin.apple_sdk.frameworks.Security
340 | ];
341 |
342 | postInstall = ''
343 | mv $out/bin/relay $out/bin/melange-relay-compiler
344 | ln -sf $out/bin/melange-relay-compiler $out/bin/melrelay
345 | '';
346 | doCheck = false;
347 | meta = with lib; {
348 | description = "Melange Relay compiler";
349 | homepage = "https://github.com/anmonteiro/relay";
350 | maintainers = [ maintainers.anmonteiro ];
351 | };
352 | };
353 | } // (
354 | lib.mapAttrs'
355 | (n: p: lib.nameValuePair "${n}-oc" p)
356 | {
357 | inherit (super) gmp libev lz4 pcre rdkafka sqlite zlib zstd readline;
358 | libffi = super.libffi.overrideAttrs (_: { doCheck = false; });
359 | openssl = super.openssl_3;
360 | curl = super.curl.override { openssl = self.openssl-oc; };
361 | }
362 | )
363 |
--------------------------------------------------------------------------------
/overlay/hermes-static-link.patch:
--------------------------------------------------------------------------------
1 | diff --git a/API/hermes/CMakeLists.txt b/API/hermes/CMakeLists.txt
2 | index 0b7cbacfe..df02e0d0b 100644
3 | --- a/API/hermes/CMakeLists.txt
4 | +++ b/API/hermes/CMakeLists.txt
5 | @@ -59,7 +59,7 @@ add_hermes_library(traceInterpreter TraceInterpreter.cpp
6 |
7 | set(HERMES_LINK_COMPONENTS LLVHSupport)
8 |
9 | -add_library(libhermes SHARED ${api_sources})
10 | +add_library(libhermes ${api_sources})
11 |
12 | # This is configured using a cmake flag instead of a separate target, because
13 | # we need the output to be named "libhermes.so".
14 | @@ -76,6 +76,15 @@ target_link_libraries(libhermes
15 | )
16 | target_link_options(libhermes PRIVATE ${HERMES_EXTRA_LINKER_FLAGS})
17 |
18 | +if (NOT BUILD_SHARED_LIBS)
19 | + bundle_static_library(hermesbundled libhermes jsi)
20 | +
21 | + install(
22 | + FILES ${CMAKE_CURRENT_BINARY_DIR}/libhermesbundled.a
23 | + DESTINATION lib
24 | + )
25 | +endif ()
26 | +
27 | # Export the required header directory
28 | target_include_directories(libhermes PUBLIC .. ../../public ${HERMES_JSI_DIR})
29 |
30 | diff --git a/CMakeLists.txt b/CMakeLists.txt
31 | index 9a7b8bd93..c9ba00336 100644
32 | --- a/CMakeLists.txt
33 | +++ b/CMakeLists.txt
34 | @@ -290,6 +290,8 @@ set(HERMES_BUILD_LEAN_LIBHERMES OFF CACHE BOOL "Exclude the Hermes compiler from
35 |
36 | set(HERMES_BUILD_SHARED_JSI OFF CACHE BOOL "Build JSI as a shared library.")
37 |
38 | +option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
39 | +
40 | if (HERMES_IS_ANDROID)
41 | add_definitions(-DHERMES_PLATFORM_UNICODE=HERMES_PLATFORM_UNICODE_JAVA)
42 | endif()
43 | diff --git a/cmake/modules/Hermes.cmake b/cmake/modules/Hermes.cmake
44 | index 51abe346a..f28c12af6 100644
45 | --- a/cmake/modules/Hermes.cmake
46 | +++ b/cmake/modules/Hermes.cmake
47 | @@ -429,3 +429,98 @@ if (GCC_COMPATIBLE)
48 | check_cxx_compiler_flag("-Wrange-loop-analysis" RANGE_ANALYSIS_FLAG)
49 | append_if(RANGE_ANALYSIS_FLAG "-Wno-range-loop-analysis" CMAKE_CXX_FLAGS)
50 | endif (GCC_COMPATIBLE)
51 | +
52 | +# Based on
53 | +# https://cristianadam.eu/20190501/bundling-together-static-libraries-with-cmake/
54 | +function(bundle_static_library bundled_tgt_name tgt_name)
55 | + list(APPEND static_libs ${tgt_name} ${ARGN})
56 | +
57 | + function(_recursively_collect_dependencies input_target)
58 | + set(_input_link_libraries LINK_LIBRARIES)
59 | + get_target_property(_input_type ${input_target} TYPE)
60 | + if (${_input_type} STREQUAL "INTERFACE_LIBRARY")
61 | + set(_input_link_libraries INTERFACE_LINK_LIBRARIES)
62 | + endif()
63 | + get_target_property(public_dependencies ${input_target} ${_input_link_libraries})
64 | + foreach(dependency IN LISTS public_dependencies)
65 | + if(TARGET ${dependency})
66 | + get_target_property(alias ${dependency} ALIASED_TARGET)
67 | + if (TARGET ${alias})
68 | + set(dependency ${alias})
69 | + endif()
70 | + get_target_property(_type ${dependency} TYPE)
71 | + if (${_type} STREQUAL "STATIC_LIBRARY")
72 | + list(APPEND static_libs ${dependency})
73 | + endif()
74 | +
75 | + get_property(library_already_added
76 | + GLOBAL PROPERTY _${tgt_name}_static_bundle_${dependency})
77 | + if (NOT library_already_added)
78 | + set_property(GLOBAL PROPERTY _${tgt_name}_static_bundle_${dependency} ON)
79 | + _recursively_collect_dependencies(${dependency})
80 | + endif()
81 | + endif()
82 | + endforeach()
83 | + set(static_libs ${static_libs} PARENT_SCOPE)
84 | + endfunction()
85 | +
86 | + _recursively_collect_dependencies(${tgt_name})
87 | +
88 | + list(REMOVE_DUPLICATES static_libs)
89 | +
90 | + set(bundled_tgt_full_name
91 | + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${bundled_tgt_name}${CMAKE_STATIC_LIBRARY_SUFFIX})
92 | +
93 | + if (CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU)$")
94 | + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar.in
95 | + "CREATE ${bundled_tgt_full_name}\n" )
96 | +
97 | + foreach(tgt IN LISTS static_libs)
98 | + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar.in
99 | + "ADDLIB $\n")
100 | + endforeach()
101 | +
102 | + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar.in "SAVE\n")
103 | + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar.in "END\n")
104 | +
105 | + file(GENERATE
106 | + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar
107 | + INPUT ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar.in)
108 | +
109 | + set(ar_tool ${CMAKE_AR})
110 | + if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
111 | + set(ar_tool ${CMAKE_CXX_COMPILER_AR})
112 | + endif()
113 | +
114 | + add_custom_command(
115 | + COMMAND ${ar_tool} -M < ${CMAKE_CURRENT_BINARY_DIR}/${bundled_tgt_name}.ar
116 | + OUTPUT ${bundled_tgt_full_name}
117 | + COMMENT "Bundling ${bundled_tgt_name}"
118 | + VERBATIM)
119 | + elseif(MSVC)
120 | + find_program(lib_tool lib)
121 | +
122 | + foreach(tgt IN LISTS static_libs)
123 | + list(APPEND static_libs_full_names $)
124 | + endforeach()
125 | +
126 | + add_custom_command(
127 | + COMMAND ${lib_tool} /NOLOGO /OUT:${bundled_tgt_full_name} ${static_libs_full_names}
128 | + OUTPUT ${bundled_tgt_full_name}
129 | + COMMENT "Bundling ${bundled_tgt_name}"
130 | + VERBATIM)
131 | + else()
132 | + message(FATAL_ERROR "Unknown bundle scenario!")
133 | + endif()
134 | +
135 | + add_custom_target(bundling_target ALL DEPENDS ${bundled_tgt_full_name})
136 | + add_dependencies(bundling_target ${tgt_name} ${ARGN})
137 | +
138 | + add_library(${bundled_tgt_name} STATIC IMPORTED)
139 | + set_target_properties(${bundled_tgt_name}
140 | + PROPERTIES
141 | + IMPORTED_LOCATION ${bundled_tgt_full_name}
142 | + INTERFACE_INCLUDE_DIRECTORIES $)
143 | + add_dependencies(${bundled_tgt_name} bundling_target)
144 | +
145 | +endfunction()
146 |
--------------------------------------------------------------------------------
/static/default.nix:
--------------------------------------------------------------------------------
1 | # Loosely adapted from https://github.com/serokell/tezos-packaging/blob/b7617f99/nix/static.nix
2 |
3 | self: super:
4 |
5 | let
6 | inherit (super) stdenv lib;
7 |
8 | in
9 |
10 | {
11 | hermes = super.hermes.overrideAttrs (o: {
12 | cmakeFlags = o.cmakeFlags ++ [
13 | "-DHERMES_STATIC_LINK=true"
14 | "-DCMAKE_CROSSCOMPILING=false"
15 | "-DHERMES_USE_STATIC_ICU=true"
16 | "-DBUILD_SHARED_LIBS:BOOL=OFF"
17 | ];
18 | });
19 | icu = super.icu.overrideAttrs (o: {
20 | configureFlags = o.configureFlags ++ [ "--enable-static" ];
21 | });
22 | readline-oc = super.readline-oc.overrideAttrs (o: {
23 | configureFlags = (o.configureFlags or [ ]) ++ [ "--enable-static" "--disable-shared" ];
24 | });
25 |
26 | libev-oc = super.libev-oc.override { static = true; };
27 | libffi-oc = super.libffi-oc.overrideAttrs (_: { dontDisableStatic = true; });
28 | libpq = super.libpq.overrideAttrs (_: { dontDisableStatic = true; });
29 | lz4-oc = super.lz4-oc.overrideAttrs (_: {
30 | cmakeFlags = [ "-DBUILD_STATIC_LIBS=TRUE" ];
31 | });
32 | gmp-oc = super.gmp-oc.override { withStatic = true; };
33 | openssl-oc = super.openssl-oc.override { static = true; };
34 |
35 | pcre-oc = super.pcre-oc.overrideAttrs (_: {
36 | dontDisableStatic = true;
37 | });
38 |
39 | rdkafka-oc = (super.rdkafka-oc.override {
40 | zstd = self.zstd-oc;
41 | zlib = self.zlib-oc;
42 | openssl = self.openssl-oc;
43 | }).overrideAttrs (o: {
44 | postPatch = ''
45 | ${o.postPatch}
46 | # https://github.com/confluentinc/librdkafka/pull/4281
47 | substituteInPlace mklove/Makefile.base --replace-fail 'ar -r' '$(AR) -r'
48 | '';
49 | configureFlags = [ "--enable-static" ];
50 | STATIC_LIB_libzstd = "${self.zstd-oc}/lib/libzstd.a";
51 | propagatedBuildInputs = o.buildInputs;
52 | });
53 |
54 | sqlite-oc = (super.sqlite-oc.override { zlib = self.zlib-oc; }).overrideAttrs (o: {
55 | dontDisableStatic = true;
56 | });
57 |
58 | zlib-oc = super.zlib-oc.override {
59 | static = true;
60 | splitStaticOutput = false;
61 | };
62 |
63 | zstd-oc = super.zstd-oc.override { static = true; };
64 | } // super.lib.overlayOCamlPackages {
65 | inherit self super;
66 | overlays = [ (super.callPackage ./ocaml.nix { }) ];
67 | updateOCamlPackages = true;
68 | }
69 |
--------------------------------------------------------------------------------
/static/ocaml.nix:
--------------------------------------------------------------------------------
1 | { lib, binutils, stdenv, writeScriptBin }:
2 | let
3 | fixOCaml = ocaml:
4 | (ocaml.override { useX11 = false; }).overrideAttrs (o:
5 | let
6 | strip-script =
7 | let
8 | strip-pkg =
9 | if stdenv.cc.targetPrefix == ""
10 | then "${binutils}/bin/strip"
11 | else "${stdenv.cc.targetPrefix}strip";
12 | in
13 | writeScriptBin "strip" ''
14 | #!${stdenv.shell}
15 | ${strip-pkg} $@
16 | '';
17 | in
18 | {
19 | nativeBuildInputs = (o.nativeBuildInputs or [ ]) ++ [ strip-script ];
20 | # buildInputs = (o.buildInputs) ++ [ binutils ];
21 | dontUpdateAutotoolsGnuConfigScripts = true;
22 | dontDisableStatic = true;
23 | preConfigure = ''
24 | ${o.preConfigure or null}
25 | configureFlagsArray+=("PARTIALLD=$LD -r" "ASPP=$CC -c" "LIBS=-static" "STRIP=''${STRIP:strip}")
26 | '';
27 | });
28 |
29 | fixOCamlPackage = b:
30 | b.overrideAttrs (o: {
31 | # Static doesn't propagate `checkInputs` so we don't run the tests here
32 | doCheck = false;
33 | });
34 | in
35 |
36 | oself: osuper:
37 |
38 | lib.mapAttrs
39 | (_: p:
40 | if p ? overrideAttrs then
41 | fixOCamlPackage p
42 | else p)
43 | osuper // {
44 | ocaml = fixOCaml osuper.ocaml;
45 |
46 | kafka = osuper.kafka.overrideAttrs (o: {
47 | PKG_CONFIG_ARGN = "--static";
48 | });
49 |
50 | postgresql = osuper.postgresql.overrideAttrs (o: {
51 | PKG_CONFIG_ARGN = "--static";
52 | });
53 |
54 | zarith = osuper.zarith.overrideDerivation (o: {
55 | configureFlags = o.configureFlags ++ [
56 | "-prefixnonocaml ${o.stdenv.hostPlatform.config}-"
57 | ];
58 | });
59 | }
60 |
--------------------------------------------------------------------------------