forked from tweag/opam-nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
104 lines (99 loc) · 3.48 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
opam2json.url = "github:tweag/opam2json";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
# Used for examples/tests and as a default repository
opam-repository = {
url = "github:ocaml/opam-repository";
flake = false;
};
};
outputs =
{ self, nixpkgs, flake-utils, opam2json, opam-repository, ... }@inputs:
{
aux = import ./lib.nix nixpkgs.lib;
templates.simple = {
description = "Build a package from opam-repository";
path = ./templates/simple;
};
templates.local = {
description = "Build an opam package from a local directory";
path = ./templates/local;
};
defaultTemplate = self.templates.local;
overlays = {
ocaml-overlay = import ./overlays/ocaml.nix;
ocaml-static-overlay = import ./overlays/ocaml-static.nix;
};
} // flake-utils.lib.eachDefaultSystem (system:
let
opam-overlay = self: super: {
opam = super.opam.overrideAttrs
(oa: { patches = oa.patches or [ ] ++ [ ./opam.patch ]; });
};
pkgs = nixpkgs.legacyPackages.${system}.extend
(nixpkgs.lib.composeManyExtensions [
opam2json.overlay
opam-overlay
]);
opam-nix = import ./opam.nix { inherit pkgs opam-repository; };
in rec {
lib = opam-nix;
checks = packages
// (pkgs.callPackage ./examples/readme { inherit opam-nix; });
packages = let
examples = rec {
_0install = (import ./examples/0install/flake.nix).outputs {
self = _0install;
opam-nix = inputs.self;
inherit (inputs) flake-utils;
};
frama-c = (import ./examples/frama-c/flake.nix).outputs {
self = frama-c;
opam-nix = inputs.self;
inherit (inputs) flake-utils;
};
opam-ed = (import ./examples/opam-ed/flake.nix).outputs {
self = opam-ed;
opam-nix = inputs.self;
inherit (inputs) flake-utils;
};
opam2json = (import ./examples/opam2json/flake.nix).outputs {
self = opam2json;
opam-nix = inputs.self;
inherit (inputs) opam2json flake-utils;
};
opam2json-static =
(import ./examples/opam2json-static/flake.nix).outputs {
self = opam2json-static;
opam-nix = inputs.self;
inherit (inputs) opam2json flake-utils;
};
tezos = (import ./examples/tezos/flake.nix).outputs {
self = tezos;
opam-nix = inputs.self;
inherit (inputs) flake-utils;
};
materialized-opam-ed = (import ./examples/materialized-opam-ed/flake.nix).outputs {
self = materialized-opam-ed;
opam-nix = inputs.self;
inherit (inputs) flake-utils;
};
};
in {
opam-nix-gen = pkgs.substituteAll {
name = "opam-nix-gen";
src = ./scripts/opam-nix-gen.in;
dir = "bin";
isExecutable = true;
inherit (pkgs) runtimeShell;
opamNix = "${self}";
};
} // builtins.mapAttrs (_: e: e.defaultPackage.${system}) examples;
});
}