Skip to content

Commit a2253a6

Browse files
authored
Simplify Nix derivations, gh-actions (#50)
1 parent e05048c commit a2253a6

File tree

10 files changed

+87
-59
lines changed

10 files changed

+87
-59
lines changed

.github/workflows/test.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@ name: "Build"
22
on:
33
pull_request:
44
push:
5+
branches:
6+
- master
57
jobs:
68
tests:
79
runs-on: ubuntu-latest
810
strategy:
911
matrix:
10-
ocamlVersion: [406, 407, 408, 409]
12+
ocamlVersion: [4_06, 4_07, 4_08, 4_09]
1113
steps:
1214
- uses: actions/checkout@v2
1315
- uses: cachix/install-nix-action@v6
1416
- uses: cachix/cachix-action@v3
1517
with:
1618
name: anmonteiro
17-
file: nix/ci/${{ matrix.ocamlVersion }}.nix
19+
skipNixBuild: true
1820
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
21+
- name: Build / Test
22+
shell: bash
23+
run: nix-build ./nix/ci/test.nix --argstr ocamlVersion ${{ matrix.ocamlVersion }}
24+
1925

nix/ci/406.nix

-1
This file was deleted.

nix/ci/407.nix

-1
This file was deleted.

nix/ci/408.nix

-1
This file was deleted.

nix/ci/409.nix

-1
This file was deleted.

nix/ci/test.nix

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
{ pkgs ? import <nixpkgs> {}, ocamlVersion }:
1+
{ ocamlVersion }:
22

33
let
4-
inherit (pkgs) lib stdenv fetchTarball;
5-
overlays = builtins.fetchTarball https://github.com/anmonteiro/nix-overlays/archive/master.tar.gz;
6-
ocamlPackages = pkgs.ocaml-ng."ocamlPackages_${ocamlVersion}".overrideScope'
7-
(pkgs.callPackage "${overlays}/ocaml" { });
4+
pkgs = import ../sources.nix { inherit ocamlVersion; };
5+
inherit (pkgs) lib stdenv fetchTarball ocamlPackages;
86

97
lambda-pkgs = import ./.. { inherit pkgs ocamlVersion; };
108
lambda-drvs = lib.filterAttrs (_: value: lib.isDerivation value) lambda-pkgs;

nix/default.nix

+33-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
{ pkgs ? import <nixpkgs> {}, ocamlVersion ? "4_09" }:
1+
{ pkgs ? import ./sources.nix { inherit ocamlVersion; }
2+
, ocamlVersion ? "4_09" }:
23

34
let
4-
gitignoreSrc = pkgs.fetchFromGitHub {
5-
owner = "hercules-ci";
6-
repo = "gitignore";
7-
rev = "7415c4f";
8-
sha256 = "1zd1ylgkndbb5szji32ivfhwh04mr1sbgrnvbrqpmfb67g2g3r9i";
9-
};
10-
inherit (import gitignoreSrc { inherit (pkgs) lib; }) gitignoreSource;
11-
overlays = builtins.fetchTarball https://github.com/anmonteiro/nix-overlays/archive/master.tar.gz;
12-
13-
ocamlPackages = pkgs.ocaml-ng."ocamlPackages_${ocamlVersion}".overrideScope'
14-
(pkgs.callPackage "${overlays}/ocaml" { });
5+
inherit (pkgs) lib stdenv ocamlPackages;
156
in
16-
pkgs.callPackage ./generic.nix {
17-
inherit ocamlPackages gitignoreSource;
18-
}
197

8+
with ocamlPackages;
9+
let
10+
build-lambda-runtime = args: buildDunePackage ({
11+
version = "0.1.0-dev";
12+
src = lib.gitignoreSource ./..;
13+
} // args);
14+
15+
in rec {
16+
lambda-runtime = build-lambda-runtime {
17+
pname = "lambda-runtime";
18+
buildInputs = [ alcotest ];
19+
doCheck = false;
20+
propagatedBuildInputs = [ yojson ppx_deriving_yojson piaf uri logs lwt4 ];
21+
};
22+
23+
now = build-lambda-runtime {
24+
pname = "now";
25+
buildInputs = [ alcotest ];
26+
# tests lambda-runtime too
27+
doCheck = true;
28+
propagatedBuildInputs = [
29+
lambda-runtime
30+
httpaf
31+
yojson
32+
ppx_deriving_yojson
33+
lwt4
34+
base64
35+
];
36+
};
37+
}

nix/generic.nix

-33
This file was deleted.

nix/sources.nix

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{ ocamlVersion ? "4_09" }:
2+
3+
let
4+
overlays = builtins.fetchTarball {
5+
url = https://github.com/anmonteiro/nix-overlays/archive/98b6ee7.tar.gz;
6+
sha256 = "12vqdghlz2v7ln28jmrnxy210zv5x21g8kw2s0dvszfmz0p2inkh";
7+
};
8+
9+
pkgs = import <nixpkgs> {
10+
overlays = [
11+
(import overlays)
12+
(self: super: {
13+
ocamlPackages = super.ocaml-ng."ocamlPackages_${ocamlVersion}".overrideScope'
14+
(super.callPackage "${overlays}/ocaml" {});
15+
})
16+
];
17+
};
18+
19+
in
20+
pkgs

shell.nix

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
let
3+
pkgs = import ./nix/sources.nix {};
4+
inherit (pkgs) stdenv lib;
5+
lambdaPkgs = pkgs.recurseIntoAttrs (import ./nix { inherit pkgs; });
6+
lambdaDrvs = lib.filterAttrs (_: value: lib.isDerivation value) lambdaPkgs;
7+
8+
in
9+
(pkgs.mkShell {
10+
inputsFrom = lib.attrValues lambdaDrvs;
11+
buildInputs = with pkgs.ocamlPackages; [ merlin pkgs.ocamlformat ];
12+
}).overrideAttrs (o : {
13+
propagatedBuildInputs = lib.filter
14+
(drv:
15+
# we wanna filter our own packages so we don't build them when entering
16+
# the shell. They always have `pname`
17+
!(lib.hasAttr "pname" drv) ||
18+
drv.pname == null ||
19+
!(lib.any (name: name == drv.pname) (lib.attrNames lambdaDrvs)))
20+
o.propagatedBuildInputs;
21+
})
22+
23+

0 commit comments

Comments
 (0)