From 3fc3dab44467eb0884257cca5ac56dd18a2b39d2 Mon Sep 17 00:00:00 2001 From: John Soo Date: Sun, 15 Aug 2021 12:43:23 -0700 Subject: [PATCH 1/4] Add nix shell. Use opam2nix in the build process. --- .gitignore | 3 +- opam-selection.nix | 556 +++++++++++++++++++++++++++++++++++++++++++++ opam2nix-shell.nix | 1 + pin.nix | 71 ++++++ shell.nix | 10 + wlroots.opam | 5 +- 6 files changed, 644 insertions(+), 2 deletions(-) create mode 100644 opam-selection.nix create mode 100644 opam2nix-shell.nix create mode 100644 pin.nix create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 89fa9b6..48bcdc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ _build *.install -*.merlin \ No newline at end of file +*.merlin +/result diff --git a/opam-selection.nix b/opam-selection.nix new file mode 100644 index 0000000..ebeebc5 --- /dev/null +++ b/opam-selection.nix @@ -0,0 +1,556 @@ +### This file is generated by opam2nix. + +self: +let + lib = self.lib; + pkgs = self.pkgs; + repoPath = self.repoPath; + repos = + { + opam-repository = + rec { + fetch = + { + owner = "ocaml"; + repo = "opam-repository"; + rev = "ba60112b1addd60f567874e75a31a0c9477a8dce"; + sha256 = "1pn57fi26js2w2s7kjr8kyyi3qj65l11qdjzlsd58vaxrwi6a4za"; + }; + src = (pkgs.fetchFromGitHub) fetch; + }; + }; + selection = self.selection; +in +{ + format-version = 4; + ocaml-version = "4.08.1"; + repos = repos; + selection = + { + base = + { + opamInputs = + { + dune = selection.dune; + dune-configurator = selection.dune-configurator; + ocaml = selection.ocaml; + sexplib0 = selection.sexplib0; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:014xlh33ayf440lf9yx62z43q9977254911p3jyncw2hrmarny4h"; + package = "packages/base/base.v0.14.1"; + }; + pname = "base"; + src = pkgs.fetchurl + { + sha256 = "13b0xc62ka8i2ry2r62gc194wzfdq1vqf2qygwrrk26pvqn8a9l9"; + url = "https://github.com/janestreet/base/archive/v0.14.1.tar.gz"; + }; + version = "v0.14.1"; + }; + base-bytes = + { + opamInputs = + { + ocaml = selection.ocaml; + ocamlfind = selection.ocamlfind; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0a68lmbf68jgm1i3b59j2sc3ha9yhv4678f9mfwwvczw88prq7l3"; + package = "packages/base-bytes/base-bytes.base"; + }; + pname = "base-bytes"; + src = null; + version = "base"; + }; + base-threads = + { + opamInputs = { + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1c4bpyh61ampjgk5yh3inrgcpf1z1xv0pshn54ycmpn4dyzv0p2x"; + package = "packages/base-threads/base-threads.base"; + }; + pname = "base-threads"; + src = null; + version = "base"; + }; + base-unix = + { + opamInputs = { + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0mpsvb7684g723ylngryh15aqxg3blb7hgmq2fsqjyppr36iyzwg"; + package = "packages/base-unix/base-unix.base"; + }; + pname = "base-unix"; + src = null; + version = "base"; + }; + conf-libffi = + { + buildInputs = [ (pkgs.libffi or null) (pkgs.libffi-dev or null) + (pkgs.libffi-devel or null) ]; + opamInputs = + { + conf-pkg-config = selection.conf-pkg-config; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1knn18qyrqmyx61nczz8mssrx0ssis6kpxdrmp2k6743l0sw7jr9"; + package = "packages/conf-libffi/conf-libffi.2.0.0"; + }; + pname = "conf-libffi"; + src = null; + version = "2.0.0"; + }; + conf-pkg-config = + { + buildInputs = [ (pkgs.pkgconfig) ]; + opamInputs = { + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1rli6809glz5g9xwp4wsjidc39za4n58xcpkamy6fymfnqha225n"; + package = "packages/conf-pkg-config/conf-pkg-config.2"; + }; + pname = "conf-pkg-config"; + src = null; + version = "2"; + }; + csexp = + { + opamInputs = + { + dune = selection.dune; + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:01lc95kz13gpki4xazyh6n20kv1g9inyb5myv240wl2n9v50z8fl"; + package = "packages/csexp/csexp.1.5.1"; + }; + pname = "csexp"; + src = pkgs.fetchurl + { + sha256 = "00mc19f89pxpmjl62862ya5kjcfrl8rjzvs00j05h2m9bw3f81fn"; + url = "https://github.com/ocaml-dune/csexp/releases/download/1.5.1/csexp-1.5.1.tbz"; + }; + version = "1.5.1"; + }; + ctypes = + { + opamInputs = + { + conf-pkg-config = selection.conf-pkg-config; + ctypes-foreign = selection.ctypes-foreign or null; + integers = selection.integers; + mirage-xen = selection.mirage-xen or null; + ocaml = selection.ocaml; + ocamlfind = selection.ocamlfind; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1cx2lcx24nwmv0szdii6xgvysnbvy395h9y8lq2ig7ypscw64ip2"; + package = "packages/ctypes/ctypes.0.17.1"; + }; + pname = "ctypes"; + src = pkgs.fetchurl + { + sha256 = "1sd74bcsln51bnz11c82v6h6fv23dczfyfqqvv9rxa9wp4p3qrs1"; + url = "https://github.com/ocamllabs/ocaml-ctypes/archive/0.17.1.tar.gz"; + }; + version = "0.17.1"; + }; + ctypes-foreign = + { + opamInputs = + { + conf-libffi = selection.conf-libffi; + conf-pkg-config = selection.conf-pkg-config; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0mr8z6hjdd8073zya2w0v5m5yv8scq90vw2d1paanib66m4y5sgm"; + package = "packages/ctypes-foreign/ctypes-foreign.0.18.0"; + }; + pname = "ctypes-foreign"; + src = null; + version = "0.18.0"; + }; + dune = + { + opamInputs = + { + base-threads = selection.base-threads; + base-unix = selection.base-unix; + ocaml = selection.ocaml or null; + ocamlfind-secondary = selection.ocamlfind-secondary or null; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:09s6k6kiw081kdh96zhp8ccgf8niw0391brfjl7gva7fansfqaqd"; + package = "packages/dune/dune.2.9.1"; + }; + pname = "dune"; + src = pkgs.fetchurl + { + sha256 = "09lzq04b642iy0ljp59p32lgk3q8iphjh8fkdp69q29l5frgwx5k"; + url = "https://github.com/ocaml/dune/releases/download/2.9.1/dune-2.9.1.tbz"; + }; + version = "2.9.1"; + }; + dune-configurator = + { + opamInputs = + { + csexp = selection.csexp; + dune = selection.dune; + ocaml = selection.ocaml; + result = selection.result; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1aik9w82r8vbb9fsfphpb0vam68s19ggkxprnqr99ygyalp2b71j"; + package = "packages/dune-configurator/dune-configurator.2.9.1"; + }; + pname = "dune-configurator"; + src = pkgs.fetchurl + { + sha256 = "09lzq04b642iy0ljp59p32lgk3q8iphjh8fkdp69q29l5frgwx5k"; + url = "https://github.com/ocaml/dune/releases/download/2.9.1/dune-2.9.1.tbz"; + }; + version = "2.9.1"; + }; + integers = + { + opamInputs = + { + dune = selection.dune; + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1n15jqsbgd9xp7xn68sb52m4jdw66l6rlnsza67nw0r164i2nj00"; + package = "packages/integers/integers.0.5.1"; + }; + pname = "integers"; + src = pkgs.fetchurl + { + sha256 = "1f1nkgpqjnavyw5vqlgrgsqaqdgzp0xngs4hx97dn7glraccw27n"; + url = "https://github.com/ocamllabs/ocaml-integers/archive/0.5.1.tar.gz"; + }; + version = "0.5.1"; + }; + mtime = + { + opamInputs = + { + js_of_ocaml = selection.js_of_ocaml or null; + ocaml = selection.ocaml; + ocamlbuild = selection.ocamlbuild; + ocamlfind = selection.ocamlfind; + topkg = selection.topkg; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1pvlkp6n3z75mjc5y0nvhf2s7fmzj8k84chwzvmyrpb786s9gqyh"; + package = "packages/mtime/mtime.1.2.0"; + }; + pname = "mtime"; + src = pkgs.fetchurl + { + sha256 = "0zm1jvqkz3ghznfsm3bbv9q2zinp9grggdf7k9phjazjvny68xb8"; + url = "https://erratique.ch/software/mtime/releases/mtime-1.2.0.tbz"; + }; + version = "1.2.0"; + }; + ocaml = + { + opamInputs = + { + ocaml-base-compiler = selection.ocaml-base-compiler or null; + ocaml-config = selection.ocaml-config; + ocaml-system = selection.ocaml-system or null; + ocaml-variants = selection.ocaml-variants or null; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0b1jl7a1jwl3pymdxcdh9mlqpd72zszy7kcmpczsd4fr8j71jxka"; + package = "packages/ocaml/ocaml.4.08.1"; + }; + pname = "ocaml"; + src = null; + version = "4.08.1"; + }; + ocaml-base-compiler = + { + opamInputs = { + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:08vkdkzb63m4f304ijb0x0ddxcqdk67wdl71559mr2yzs4amrnvj"; + package = "packages/ocaml-base-compiler/ocaml-base-compiler.4.08.1"; + }; + pname = "ocaml-base-compiler"; + src = pkgs.fetchurl + { + sha256 = "11fvsm861lr73lk181gl5iczprp8d83fvgc1q6dx8gxqhzad6gmm"; + url = "https://github.com/ocaml/ocaml/archive/4.08.1.tar.gz"; + }; + version = "4.08.1"; + }; + ocaml-config = + { + opamInputs = + { + ocaml-base-compiler = selection.ocaml-base-compiler or null; + ocaml-system = selection.ocaml-system or null; + ocaml-variants = selection.ocaml-variants or null; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1gc3pyhb64j8a91bgbpy9fzljpb1ps2ylgw31ldx879vdkk46nhp"; + package = "packages/ocaml-config/ocaml-config.1"; + }; + pname = "ocaml-config"; + src = null; + version = "1"; + }; + ocamlbuild = + { + opamInputs = { + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1r5qnrcxfypzyvjvb3zd9f66kr5ldxdl3g9rsi3pb6040krqb5w7"; + package = "packages/ocamlbuild/ocamlbuild.0.14.0"; + }; + pname = "ocamlbuild"; + src = pkgs.fetchurl + { + sha256 = "0y1fskw9rg2y1zgb7whv3v8v4xw04svgxslf3856q2aqd7lrrcl7"; + url = "https://github.com/ocaml/ocamlbuild/archive/0.14.0.tar.gz"; + }; + version = "0.14.0"; + }; + ocamlfind = + { + opamInputs = + { + graphics = selection.graphics or null; + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:11avrzm0gdc6mz7dazr8q18ir5429ckc36s2mv0l8722znq8lc3k"; + package = "packages/ocamlfind/ocamlfind.1.9.1"; + }; + pname = "ocamlfind"; + src = pkgs.fetchurl + { + sha256 = "1qhgk25avmz4l4g47g8jvk0k1g9p9d5hbdrwpz2693a8ajyvhhib"; + url = "http://download.camlcity.org/download/findlib-1.9.1.tar.gz"; + }; + version = "1.9.1"; + }; + result = + { + opamInputs = + { + dune = selection.dune; + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0ybmvlisfz5swvbcq855czz1ysv9zxmb79f1m0x8284hczmfm98f"; + package = "packages/result/result.1.5"; + }; + pname = "result"; + src = pkgs.fetchurl + { + sha256 = "0cpfp35fdwnv3p30a06wd0py3805qxmq3jmcynjc3x2qhlimwfkw"; + url = "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz"; + }; + version = "1.5"; + }; + sexplib0 = + { + opamInputs = + { + dune = selection.dune; + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0k9vkjbiibja48c0yayal7xwyik3h3c3v4dwd3j7jbmras63ig2c"; + package = "packages/sexplib0/sexplib0.v0.14.0"; + }; + pname = "sexplib0"; + src = pkgs.fetchurl + { + sha256 = "0adrc0r1vvvr41dcpj8jwkzh1dfgqf0mks9xlnnskqfm3a51iavg"; + url = "https://ocaml.janestreet.com/ocaml-core/v0.14/files/sexplib0-v0.14.0.tar.gz"; + }; + version = "v0.14.0"; + }; + stdio = + { + opamInputs = + { + base = selection.base; + dune = selection.dune; + ocaml = selection.ocaml; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:19hlf6bgx1avq4ifwji2rj2f2j26v3nf8ywjnwh2m3dpvfqc4pvk"; + package = "packages/stdio/stdio.v0.14.0"; + }; + pname = "stdio"; + src = pkgs.fetchurl + { + sha256 = "1hj5hraprqy2i90a690l11yjszvb99j818q3d684ryx6p2lddk0l"; + url = "https://ocaml.janestreet.com/ocaml-core/v0.14/files/stdio-v0.14.0.tar.gz"; + }; + version = "v0.14.0"; + }; + tgls = + { + opamInputs = + { + base-bytes = selection.base-bytes; + ctypes = selection.ctypes; + ctypes-foreign = selection.ctypes-foreign; + ocaml = selection.ocaml; + ocamlbuild = selection.ocamlbuild; + ocamlfind = selection.ocamlfind; + topkg = selection.topkg; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1qiqs27kly2izxgc5a19wr7gnbg5lry7z06ggxp5ncd5kaxmd1dx"; + package = "packages/tgls/tgls.0.8.5"; + }; + pname = "tgls"; + src = pkgs.fetchurl + { + sha256 = "0xdc8j3grir91mbwigz9jhjgnlhy5g0sm9wdcsh3ih3fzzkjrdd3"; + url = "http://erratique.ch/software/tgls/releases/tgls-0.8.5.tbz"; + }; + version = "0.8.5"; + }; + topkg = + { + opamInputs = + { + ocaml = selection.ocaml; + ocamlbuild = selection.ocamlbuild; + ocamlfind = selection.ocamlfind; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:1asjip3cr84b1n1n4q8b5zrcki87niz6imb9m9zaj2kqdywmp0m5"; + package = "packages/topkg/topkg.1.0.3"; + }; + pname = "topkg"; + src = pkgs.fetchurl + { + sha256 = "0b77gsz9bqby8v77kfi4lans47x9p2lmzanzwins5r29maphb8y6"; + url = "http://erratique.ch/software/topkg/releases/topkg-1.0.3.tbz"; + }; + version = "1.0.3"; + }; + unix-errno = + { + opamInputs = + { + base-bytes = selection.base-bytes; + base-unix = selection.base-unix or null; + ctypes = selection.ctypes; + ocaml = selection.ocaml; + ocamlbuild = selection.ocamlbuild; + ocamlfind = selection.ocamlfind; + result = selection.result; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:0vmvwvvymyb1xp2zqwk3l5xsp8hbrma95r9kyqlm286phql4mm4g"; + package = "packages/unix-errno/unix-errno.0.5.2"; + }; + pname = "unix-errno"; + src = pkgs.fetchurl + { + sha256 = "0gx8nr33ycqlvahi0r91a79xa3k5an1c4l3qza2xa1vnmndbjp7q"; + url = "https://github.com/dsheets/ocaml-unix-errno/archive/0.5.2.tar.gz"; + }; + version = "0.5.2"; + }; + unix-time = + { + opamInputs = + { + base-unix = selection.base-unix or null; + ctypes = selection.ctypes; + ocaml = selection.ocaml; + ocamlbuild = selection.ocamlbuild; + ocamlfind = selection.ocamlfind; + unix-errno = selection.unix-errno; + }; + opamSrc = repoPath (repos.opam-repository.src) + { + hash = "sha256:11wcl244svn0vy813qkay4a5n8cvjy47gyddghf1y1614v35dynw"; + package = "packages/unix-time/unix-time.0.1.0"; + }; + pname = "unix-time"; + src = pkgs.fetchurl + { + sha256 = "1j98p7h5p5560pfhn3kn8y7vkx3mp5si3g2jvd0x7mm9jlfg3kvi"; + url = "https://github.com/dsheets/ocaml-unix-time/archive/0.1.0.tar.gz"; + }; + version = "0.1.0"; + }; + wlroots = + { + opamInputs = + { + base = selection.base; + ctypes = selection.ctypes; + ctypes-foreign = selection.ctypes-foreign; + dune = selection.dune; + mtime = selection.mtime; + ocaml = selection.ocaml; + stdio = selection.stdio; + tgls = selection.tgls; + unix-time = selection.unix-time; + xkbcommon = selection.xkbcommon; + }; + opamSrc = "wlroots.opam"; + pname = "wlroots"; + src = self.directSrc "wlroots"; + version = "development"; + }; + xkbcommon = + { + opamInputs = + { + base = selection.base; + ctypes = selection.ctypes; + ctypes-foreign = selection.ctypes-foreign; + dune = selection.dune; + ocaml = selection.ocaml; + stdio = selection.stdio; + }; + opamSrc = "xkbcommon.opam"; + pname = "xkbcommon"; + src = self.directSrc "xkbcommon"; + version = "development"; + }; + }; +} + diff --git a/opam2nix-shell.nix b/opam2nix-shell.nix new file mode 100644 index 0000000..7ea3d9f --- /dev/null +++ b/opam2nix-shell.nix @@ -0,0 +1 @@ +let pkgs = import ./pin.nix; in { resolve = pkgs.opam2nix-resolve; } diff --git a/pin.nix b/pin.nix new file mode 100644 index 0000000..bb70ede --- /dev/null +++ b/pin.nix @@ -0,0 +1,71 @@ +let + nix-rev = "3ab8ce12c2db31268f579c11727d9c63cfee2eee"; # 2021-08-15 + nix-src = builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/${nix-rev}.tar.gz"; + sha256 = "13fx0yb95gxyk0jyvgrxv2yp4fj54g7nzrlvjfc8slx9ccqd2v86"; + }; +in import nix-src { + overlays = [ + (_: super: { ocamlPackages = super.ocaml-ng.ocamlPackages_4_08; }) + (self: super: + let + opam2nix = import (super.fetchFromGitHub { + owner = "timbertson"; + repo = "opam2nix"; + rev = "c9192288543be9ea17ba8a568e41258082016768"; + sha256 = "1ii2v08r7xkqf35ra0niqkzyqwx45vi7bzm7c0kcq83sl46qirlp"; + }) { pkgs = self; }; + xkbcommon = self.fetchFromGitHub { + owner = "Armael"; + repo = "ocaml-xkbcommon"; + rev = "af0cd8c938938db3e67b65ac13b6444102756ba0"; + sha256 = "0zh80aczdn821xkwjn8m74mjcqb6f1hj0qfh1kxrz2z9h5as2r8k"; + }; + opam2nix-args = { + inherit (super.ocamlPackages) ocaml; + selection = ./opam-selection.nix; + src = { + inherit xkbcommon; + wlroots = ./.; + }; + override = { pkgs }: { + xkbcommon = super: + super.overrideAttrs (attrs: { + nativeBuildInputs = [ pkgs.pkg-config ]; + buildInputs = [ self.libxkbcommon ]; + }); + tgls = super: + super.overrideAttrs (attrs: { + nativeBuildInputs = [ self.pkg-config ]; + buildInputs = [ self.libGL ]; + }); + wlroots = super: + super.overrideAttrs (attrs: { + nativeBuildInputs = + [ pkgs.pkg-config pkgs.ocamlPackages.dune-configurator ]; + buildInputs = [ + pkgs.libGL + pkgs.libudev # Should libudev be upstreamed as an input for wlroots? + pkgs.libxkbcommon + pkgs.mesa + pkgs.pixman + pkgs.wayland-protocols + pkgs.wayland + pkgs.wlroots_0_12 + ]; + }); + }; + }; + opam-selection = opam2nix.build opam2nix-args; + in { + inherit opam2nix opam-selection; + opam2nix-resolve = opam2nix.resolve opam2nix-args [ + "${xkbcommon}/xkbcommon.opam" + "wlroots.opam" + ]; + ocamlPackages = super.ocamlPackages // { + inherit (opam-selection) tgls xkbcommon wlroots; + }; + }) + ]; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..47e89b5 --- /dev/null +++ b/shell.nix @@ -0,0 +1,10 @@ +{ wlroots-version ? "0.12" }: +let pkgs = import ./pin.nix; +in pkgs.mkShell { + name = "wlroots-ocaml-shell"; + inputsFrom = [ pkgs.ocamlPackages.wlroots ]; + nativeBuildInputs = [ pkgs.nixfmt ]; + shellHook = '' + export NIX_PATH=nixpkgs=${pkgs.path} + ''; +} diff --git a/wlroots.opam b/wlroots.opam index 76622d0..c5383a1 100644 --- a/wlroots.opam +++ b/wlroots.opam @@ -13,7 +13,10 @@ depends: [ "mtime" "base" { build } "stdio" { build } - "tgls" { with-test } + # Should have { with-test }. + # Can't because of opam2nix. + # https://github.com/timbertson/opam2nix/issues/36 + "tgls" ] build: [ ["dune" "build" "-p" name "-j" jobs "@install"] From 6e473a822482a7d7f23cd3a02f6641b712cb3395 Mon Sep 17 00:00:00 2001 From: John Soo Date: Sun, 5 Sep 2021 16:45:23 -0700 Subject: [PATCH 2/4] nix: Add default.nix. --- default.nix | 1 + 1 file changed, 1 insertion(+) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ecea4ae --- /dev/null +++ b/default.nix @@ -0,0 +1 @@ +(import ./pin.nix).ocamlPackages.wlroots From c727b3380483b830b19006be02c52fb3e24791b9 Mon Sep 17 00:00:00 2001 From: John Soo Date: Sun, 5 Sep 2021 17:32:29 -0700 Subject: [PATCH 3/4] nix: Add parameter for wlroots-version. Add definition for wlroots@0.13 as it was dropped upstream. --- default.nix | 3 +- opam2nix-shell.nix | 2 +- pin.nix | 15 +++++++++- shell.nix | 2 +- wlroots-13.nix | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 wlroots-13.nix diff --git a/default.nix b/default.nix index ecea4ae..5543575 100644 --- a/default.nix +++ b/default.nix @@ -1 +1,2 @@ -(import ./pin.nix).ocamlPackages.wlroots +{ wlroots-version ? "0.12" }: +(import ./pin.nix { inherit wlroots-version; }).ocamlPackages.wlroots diff --git a/opam2nix-shell.nix b/opam2nix-shell.nix index 7ea3d9f..4d125ef 100644 --- a/opam2nix-shell.nix +++ b/opam2nix-shell.nix @@ -1 +1 @@ -let pkgs = import ./pin.nix; in { resolve = pkgs.opam2nix-resolve; } +let pkgs = import ./pin.nix { }; in { resolve = pkgs.opam2nix-resolve; } diff --git a/pin.nix b/pin.nix index bb70ede..2279c8e 100644 --- a/pin.nix +++ b/pin.nix @@ -1,3 +1,4 @@ +{ wlroots-version ? "0.12" }: let nix-rev = "3ab8ce12c2db31268f579c11727d9c63cfee2eee"; # 2021-08-15 nix-src = builtins.fetchTarball { @@ -7,6 +8,9 @@ let in import nix-src { overlays = [ (_: super: { ocamlPackages = super.ocaml-ng.ocamlPackages_4_08; }) + (_: super: { + wlroots_0_13 = super.callPackage (import ./wlroots-13.nix) { }; + }) (self: super: let opam2nix = import (super.fetchFromGitHub { @@ -51,7 +55,16 @@ in import nix-src { pkgs.pixman pkgs.wayland-protocols pkgs.wayland - pkgs.wlroots_0_12 + (if wlroots-version == "0.12" then + pkgs.wlroots_0_12 + else if wlroots-version == "0.13" then + pkgs.wlroots_0_13 + else if wlroots-version == "0.14" then + pkgs.wlroots + else + throw '' + wlroots-version must be one of 0.12, 0.13 or 0.14. Got ${wlroots-version} + '') ]; }); }; diff --git a/shell.nix b/shell.nix index 47e89b5..b860d8c 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,5 @@ { wlroots-version ? "0.12" }: -let pkgs = import ./pin.nix; +let pkgs = import ./pin.nix { inherit wlroots-version; }; in pkgs.mkShell { name = "wlroots-ocaml-shell"; inputsFrom = [ pkgs.ocamlPackages.wlroots ]; diff --git a/wlroots-13.nix b/wlroots-13.nix new file mode 100644 index 0000000..73d7a5a --- /dev/null +++ b/wlroots-13.nix @@ -0,0 +1,68 @@ +{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, wayland-scanner, libGL +, wayland, wayland-protocols, libinput, libxkbcommon, pixman, xcbutilwm, libX11 +, libcap, xcbutilimage, xcbutilerrors, mesa, libpng, ffmpeg, libuuid +, xcbutilrenderutil, xwayland }: + +stdenv.mkDerivation rec { + pname = "wlroots"; + version = "0.13.0"; + + src = fetchFromGitHub { + owner = "swaywm"; + repo = "wlroots"; + rev = version; + sha256 = "01plhbnsp5yg18arz0v8fr0pr9l4w4pdzwkg9px486qdvb3s1vgy"; + }; + + # $out for the library and $examples for the example programs (in examples): + outputs = [ "out" "examples" ]; + + nativeBuildInputs = [ meson ninja pkg-config wayland-scanner ]; + + buildInputs = [ + libGL + wayland + wayland-protocols + libinput + libxkbcommon + pixman + xcbutilwm + libX11 + libcap + xcbutilimage + xcbutilerrors + mesa + libpng + ffmpeg + libuuid + xcbutilrenderutil + xwayland + ]; + + mesonFlags = [ "-Dlogind-provider=systemd" "-Dlibseat=disabled" ]; + + postFixup = '' + # Install ALL example programs to $examples: + # screencopy dmabuf-capture input-inhibitor layer-shell idle-inhibit idle + # screenshot output-layout multi-pointer rotation tablet touch pointer + # simple + mkdir -p $examples/bin + cd ./examples + for binary in $(find . -executable -type f -printf '%P\n' | grep -vE '\.so'); do + cp "$binary" "$examples/bin/wlroots-$binary" + done + ''; + + meta = with lib; { + description = "A modular Wayland compositor library"; + longDescription = '' + Pluggable, composable, unopinionated modules for building a Wayland + compositor; or about 50,000 lines of code you were going to write anyway. + ''; + inherit (src.meta) homepage; + changelog = "https://github.com/swaywm/wlroots/releases/tag/${version}"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ ]; + }; +} From df43d81a04cd52e569dc1591cea7b5cadf5e3f93 Mon Sep 17 00:00:00 2001 From: John Soo Date: Sun, 5 Sep 2021 17:38:29 -0700 Subject: [PATCH 4/4] nix: Document usage. --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 27efdbc..079eae5 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,26 @@ opam install -t --deps-only . Then, you can use `make` to build the library, and `make examples` to build the example programs. + +### Development using nix + +wlroots-ocaml can be compiled with nix: + + $ nix-build + +To specify the version of wlroots - supported version are 0.12, 0.13 and 0.14: + + $ nix-build --argstr wlroots-version 0.14 + +Open a nix shell with the program dependencies managed by nix: + + $ nix-shell + $ make + +The wlroots version can be specified for the nix shell, too: + + $ nix-shell --argstr wlroots-version 0.14 + +To update the opam dependencies used by the nix system: + + $ nix-shell opam2nix-shell.nix