Add documentation for nix expressions
This commit is contained in:
parent
f970a9a536
commit
85c7429f0c
28
nix/README.md
Normal file
28
nix/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Nix expressions for building LIGO
|
||||||
|
|
||||||
|
Nix is a declarative package manager. Get it here: https://nixos.org/nix
|
||||||
|
|
||||||
|
These expressions are used on CI to reproducibly build the LIGO compiler, as well as WebIDE and https://ligolang.org .
|
||||||
|
|
||||||
|
If you wish to build it yourself with `nix build -f. $thing`, where `$thing` is
|
||||||
|
|
||||||
|
- `ligo`: executables, libraries, documentation, coverage reports
|
||||||
|
- `ligo-bin`: a dynamically linked binary (Linux, Mac)
|
||||||
|
- `ligo-static`: a statically linked binary (Linux only)
|
||||||
|
- `ligo-doc`: documentation generated by odoc
|
||||||
|
- `ligo-editor`: WebIDE, it can be started with `result/bin/ligo-editor`
|
||||||
|
- `ligo-website`: the website, website root is `result`
|
||||||
|
- `ligo-docker`: a docker image with LIGO binaries
|
||||||
|
- `ligo-editor-docker`: a docker image with webide
|
||||||
|
- `ligo-deb`: debian package with static binaries
|
||||||
|
|
||||||
|
## Quick maintenance guide
|
||||||
|
|
||||||
|
- `opam-repository` and `tezos-opam-repository` are pinned. To update them when required, run `niv update` (you can get niv with `nix shell nixpkgs#niv`)
|
||||||
|
- `ocaml` version is pinned in `ocaml-overlay.nix`. If you want to update it, go there and change the version.
|
||||||
|
- If something fails, `nix repl pkgs.nix` can be very useful to investigate it.
|
||||||
|
|
||||||
|
## Known caveats
|
||||||
|
|
||||||
|
- This is not a nix flake. This will never be a flake if we want to keep this low-maintenance, because of the way `opam` sources are defined. Sometimes, the checksum is omitted there, so we have to use `fetchTarball` without the checksum, which won't work in restricted mode (which is required for flakes). The only solution would be to generate nix expressions for opam-repository separately, but it means a manual step in the process (and it's also impossible to make this work as a flake).
|
||||||
|
- For the same reason as above, evaluation can take a while because we need to download all the sources every `tarball-ttl` seconds. This can be mitigated by setting `tarball-ttl` to a high value.
|
@ -1,5 +1,6 @@
|
|||||||
{ dockerTools, writeShellScriptBin, runCommand, mcpp, bash, coreutils, ligo, name ? "ligo" }:
|
{ dockerTools, writeShellScriptBin, runCommand, mcpp, bash, coreutils, ligo, name ? "ligo" }:
|
||||||
let
|
let
|
||||||
|
# LIGO requires /tmp for compilation, which is missing in the default image
|
||||||
tmp = runCommand "tmp" {} "mkdir -p $out/tmp";
|
tmp = runCommand "tmp" {} "mkdir -p $out/tmp";
|
||||||
in
|
in
|
||||||
dockerTools.buildLayeredImage {
|
dockerTools.buildLayeredImage {
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
, writeShellScriptBin, makeFontsConf, buildEnv, rsync, sources
|
, writeShellScriptBin, makeFontsConf, buildEnv, rsync, sources
|
||||||
, chromium ? null }:
|
, chromium ? null }:
|
||||||
let
|
let
|
||||||
|
# Use a common yarn.lock for everything
|
||||||
yarnLock = ../tools/webide/yarn.lock;
|
yarnLock = ../tools/webide/yarn.lock;
|
||||||
|
|
||||||
installPhase = "mkdir $out; cp -Lr node_modules $out/node_modules";
|
installPhase = "mkdir $out; cp -Lr node_modules $out/node_modules";
|
||||||
|
|
||||||
|
# node_modules of the server
|
||||||
server = mkYarnPackage {
|
server = mkYarnPackage {
|
||||||
name = "webide-server";
|
name = "webide-server";
|
||||||
src = ../tools/webide/packages/server;
|
src = ../tools/webide/packages/server;
|
||||||
@ -19,6 +21,8 @@ let
|
|||||||
distPhase = "true";
|
distPhase = "true";
|
||||||
inherit yarnLock installPhase;
|
inherit yarnLock installPhase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# node_modules of the client
|
||||||
client = mkYarnPackage rec {
|
client = mkYarnPackage rec {
|
||||||
name = "webide-client";
|
name = "webide-client";
|
||||||
src = ../tools/webide/packages/client;
|
src = ../tools/webide/packages/client;
|
||||||
@ -42,6 +46,7 @@ let
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Perform the e2e tests; output is empty on purpose
|
||||||
e2e = mkYarnPackage rec {
|
e2e = mkYarnPackage rec {
|
||||||
name = "webide-e2e";
|
name = "webide-e2e";
|
||||||
src = ../tools/webide/packages/e2e;
|
src = ../tools/webide/packages/e2e;
|
||||||
@ -61,6 +66,7 @@ let
|
|||||||
inherit yarnLock;
|
inherit yarnLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Run the WebIDE server with all the needed env variables
|
||||||
ligo-editor = writeShellScriptBin "ligo-editor" ''
|
ligo-editor = writeShellScriptBin "ligo-editor" ''
|
||||||
set -e
|
set -e
|
||||||
LIGO_CMD=${ligo-bin}/bin/ligo \
|
LIGO_CMD=${ligo-bin}/bin/ligo \
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
self: super: {
|
self: super: {
|
||||||
|
# Note: this overlay doesn't apply to nix-npm-buildpackage
|
||||||
nodejs = super.nodejs-12_x;
|
nodejs = super.nodejs-12_x;
|
||||||
nodePackages = super.nodePackages_12_x;
|
nodePackages = super.nodePackages_12_x;
|
||||||
nodejs-slim = super.nodejs-slim-12_x;
|
nodejs-slim = super.nodejs-slim-12_x;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# An overlay that adds ligo to ocamlPackages
|
||||||
|
|
||||||
{ sources ? import ./sources.nix
|
{ sources ? import ./sources.nix
|
||||||
, CI_COMMIT_SHA ? builtins.getEnv "CI_COMMIT_SHA"
|
, CI_COMMIT_SHA ? builtins.getEnv "CI_COMMIT_SHA"
|
||||||
, COMMIT_DATE ? builtins.getEnv "COMMIT_DATE" }:
|
, COMMIT_DATE ? builtins.getEnv "COMMIT_DATE" }:
|
||||||
@ -6,6 +8,7 @@ let
|
|||||||
opam-nix = import sources.opam-nix (import sources.nixpkgs { });
|
opam-nix = import sources.opam-nix (import sources.nixpkgs { });
|
||||||
inherit (import sources."gitignore.nix" { inherit (self) lib; })
|
inherit (import sources."gitignore.nix" { inherit (self) lib; })
|
||||||
gitignoreSource;
|
gitignoreSource;
|
||||||
|
# Remove list of directories or files from source (to stop unneeded rebuilds)
|
||||||
filterOut = xs:
|
filterOut = xs:
|
||||||
self.lib.cleanSourceWith {
|
self.lib.cleanSourceWith {
|
||||||
filter = p: type: !(builtins.elem (builtins.baseNameOf p) xs);
|
filter = p: type: !(builtins.elem (builtins.baseNameOf p) xs);
|
||||||
@ -14,6 +17,7 @@ let
|
|||||||
in {
|
in {
|
||||||
ocamlPackages = self.ocaml-ng.ocamlPackages_4_07.overrideScope'
|
ocamlPackages = self.ocaml-ng.ocamlPackages_4_07.overrideScope'
|
||||||
(builtins.foldl' self.lib.composeExtensions (_: _: { }) [
|
(builtins.foldl' self.lib.composeExtensions (_: _: { }) [
|
||||||
|
# Both opam-repository and tezos-opam-repository are updated manually with `niv update`
|
||||||
(opam-nix.traverseOPAMRepo' sources.opam-repository)
|
(opam-nix.traverseOPAMRepo' sources.opam-repository)
|
||||||
(opam-nix.traverseOPAMRepo sources.tezos-opam-repository)
|
(opam-nix.traverseOPAMRepo sources.tezos-opam-repository)
|
||||||
(opam-nix.callOPAMPackage (filterOut [
|
(opam-nix.callOPAMPackage (filterOut [
|
||||||
@ -26,19 +30,23 @@ in {
|
|||||||
"gitlab-pages"
|
"gitlab-pages"
|
||||||
]))
|
]))
|
||||||
(oself: osuper: {
|
(oself: osuper: {
|
||||||
|
# Strange naming in nixpkgs
|
||||||
ocamlfind = oself.findlib;
|
ocamlfind = oself.findlib;
|
||||||
lablgtk = null;
|
lablgtk = null;
|
||||||
lwt = oself.lwt4;
|
lwt = oself.lwt4;
|
||||||
|
|
||||||
|
# Native dependencies
|
||||||
conf-gmp = self.gmp;
|
conf-gmp = self.gmp;
|
||||||
conf-libev = self.libev;
|
conf-libev = self.libev;
|
||||||
conf-hidapi = self.hidapi;
|
conf-hidapi = self.hidapi;
|
||||||
conf-pkg-config = self.pkg-config;
|
conf-pkg-config = self.pkg-config;
|
||||||
|
|
||||||
|
# Strange problems
|
||||||
bigstring = osuper.bigstring.overrideAttrs (_: { doCheck = false; });
|
bigstring = osuper.bigstring.overrideAttrs (_: { doCheck = false; });
|
||||||
xmldiff = osuper.xmldiff.overrideAttrs (_: { src = sources.xmldiff; });
|
xmldiff = osuper.xmldiff.overrideAttrs (_: { src = sources.xmldiff; });
|
||||||
getopt = osuper.getopt.overrideAttrs (_: { configurePhase = "true"; });
|
getopt = osuper.getopt.overrideAttrs (_: { configurePhase = "true"; });
|
||||||
|
|
||||||
|
# Force certain versions
|
||||||
ipaddr = osuper.ipaddr.versions."4.0.0";
|
ipaddr = osuper.ipaddr.versions."4.0.0";
|
||||||
conduit = osuper.conduit.versions."2.1.0";
|
conduit = osuper.conduit.versions."2.1.0";
|
||||||
conduit-lwt-unix = osuper.conduit-lwt-unix.versions."2.0.2";
|
conduit-lwt-unix = osuper.conduit-lwt-unix.versions."2.0.2";
|
||||||
@ -64,6 +72,7 @@ in {
|
|||||||
propagatedBuildInputs = buildInputs;
|
propagatedBuildInputs = buildInputs;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# A combination of executables, libraries, documentation and test coverage
|
||||||
ligo = self.buildEnv {
|
ligo = self.buildEnv {
|
||||||
name = "ligo";
|
name = "ligo";
|
||||||
paths = with oself; [
|
paths = with oself; [
|
||||||
@ -74,6 +83,7 @@ in {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# LIGO executable and public libraries
|
||||||
ligo-out = osuper.ligo.overrideAttrs (oa: {
|
ligo-out = osuper.ligo.overrideAttrs (oa: {
|
||||||
name = "ligo-out";
|
name = "ligo-out";
|
||||||
inherit CI_COMMIT_SHA COMMIT_DATE;
|
inherit CI_COMMIT_SHA COMMIT_DATE;
|
||||||
@ -82,6 +92,8 @@ in {
|
|||||||
nativeBuildInputs = oa.nativeBuildInputs
|
nativeBuildInputs = oa.nativeBuildInputs
|
||||||
++ [ self.buildPackages.rakudo ];
|
++ [ self.buildPackages.rakudo ];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
# LIGO test suite; output empty on purpose
|
||||||
ligo-tests = osuper.ligo.overrideAttrs (oa: {
|
ligo-tests = osuper.ligo.overrideAttrs (oa: {
|
||||||
name = "ligo-tests";
|
name = "ligo-tests";
|
||||||
src = filterOut [
|
src = filterOut [
|
||||||
@ -98,6 +110,7 @@ in {
|
|||||||
++ [ self.buildPackages.rakudo ];
|
++ [ self.buildPackages.rakudo ];
|
||||||
installPhase = "mkdir $out";
|
installPhase = "mkdir $out";
|
||||||
});
|
});
|
||||||
|
# LIGO odoc documentation
|
||||||
ligo-doc = osuper.ligo.overrideAttrs (oa: {
|
ligo-doc = osuper.ligo.overrideAttrs (oa: {
|
||||||
name = "ligo-doc";
|
name = "ligo-doc";
|
||||||
buildInputs = oa.buildInputs
|
buildInputs = oa.buildInputs
|
||||||
@ -109,6 +122,7 @@ in {
|
|||||||
installPhase =
|
installPhase =
|
||||||
"mkdir $out; cp -r _build/default/_doc/_html/ $out/doc";
|
"mkdir $out; cp -r _build/default/_doc/_html/ $out/doc";
|
||||||
});
|
});
|
||||||
|
# LIGO test coverage reports
|
||||||
ligo-coverage = oself.ligo-tests.overrideAttrs (oa: {
|
ligo-coverage = oself.ligo-tests.overrideAttrs (oa: {
|
||||||
name = "ligo-coverage";
|
name = "ligo-coverage";
|
||||||
nativeBuildInputs = oa.nativeBuildInputs
|
nativeBuildInputs = oa.nativeBuildInputs
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# Create a debian package from static executable
|
||||||
{ stdenv, lib, writeTextFile, ligo-static, dpkg }:
|
{ stdenv, lib, writeTextFile, ligo-static, dpkg }:
|
||||||
let
|
let
|
||||||
project = "ligo";
|
project = "ligo";
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
|
# nixpkgs extended with all the overlays for LIGO
|
||||||
{ sources ? import ./sources.nix }:
|
{ sources ? import ./sources.nix }:
|
||||||
let
|
let
|
||||||
ocaml-overlay = import ./ocaml-overlay.nix { inherit sources; };
|
ocaml-overlay = import ./ocaml-overlay.nix { inherit sources; };
|
||||||
static-overlay = import ./static-overlay.nix pkgs;
|
static-overlay = import ./static-overlay.nix pkgs;
|
||||||
mac-overlay = import ./mac-overlay.nix;
|
mac-overlay = import ./mac-overlay.nix;
|
||||||
nodejs-overlay = import ./nodejs-overlay.nix;
|
nodejs-overlay = import ./nodejs-overlay.nix;
|
||||||
|
nix-npm-buildpackage = pkgs.callPackage sources.nix-npm-buildpackage { };
|
||||||
|
|
||||||
pkgs = import sources.nixpkgs {
|
pkgs = import sources.nixpkgs {
|
||||||
overlays = [ ocaml-overlay nodejs-overlay ]
|
overlays = [ ocaml-overlay nodejs-overlay ]
|
||||||
|
# This is done here to prevent the need for bootstrap nixpkgs
|
||||||
++ (if builtins.currentSystem == "x86_64-darwin"
|
++ (if builtins.currentSystem == "x86_64-darwin"
|
||||||
then [ mac-overlay ]
|
then [ mac-overlay ]
|
||||||
else [ ]);
|
else [ ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Takes $pkg/ligo and creates a new package with $pkg/bin/ligo
|
||||||
separateBinary = pkg:
|
separateBinary = pkg:
|
||||||
pkgs.runCommandNoCC "${pkg.name}-bin" { }
|
pkgs.runCommandNoCC "${pkg.name}-bin" { }
|
||||||
"mkdir -p $out/bin; cp -Lr ${pkg}/ligo $out/bin";
|
"mkdir -p $out/bin; cp -Lr ${pkg}/ligo $out/bin";
|
||||||
|
|
||||||
nix-npm-buildpackage = pkgs.callPackage sources.nix-npm-buildpackage { };
|
|
||||||
in pkgs.extend (self: super: {
|
in pkgs.extend (self: super: {
|
||||||
inherit (self.ocamlPackages) ligo ligo-out ligo-tests ligo-doc ligo-coverage;
|
inherit (self.ocamlPackages) ligo ligo-out ligo-tests ligo-doc ligo-coverage;
|
||||||
ligo-bin = separateBinary self.ligo-out.bin;
|
ligo-bin = separateBinary self.ligo-out.bin;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# An overlay that adds flags needed to build LIGO statically;
|
||||||
|
# Supposed to be applied to pkgsMusl
|
||||||
|
# Takes `native` as a package set that doesn't cause mass rebuilds (so that we don't have to build perl with musl)
|
||||||
native: self: super:
|
native: self: super:
|
||||||
let dds = x: x.overrideAttrs (o: { dontDisableStatic = true; });
|
let dds = x: x.overrideAttrs (o: { dontDisableStatic = true; });
|
||||||
in {
|
in {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
diff --git a/src/bin/dune b/src/bin/dune
|
diff --git a/src/bin/dune b/src/bin/dune
|
||||||
index 162963b4b..29dfa5191 100644
|
index 162963b4b..29dfa5191 100644
|
||||||
|
With this patch, a static executable is produced
|
||||||
--- a/src/bin/dune
|
--- a/src/bin/dune
|
||||||
+++ b/src/bin/dune
|
+++ b/src/bin/dune
|
||||||
@@ -34,5 +34,6 @@
|
@@ -34,5 +34,6 @@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user