-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
107 lines (93 loc) · 2.47 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
105
106
107
{
description = "Utility to automate downloads of torrent series";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "github:edolstra/flake-compat";
opam-nix = {
url = "github:tweag/opam-nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
};
};
};
outputs =
{
nixpkgs,
flake-utils,
opam-nix,
...
}:
let
makeOpamPkgs =
{
devPackages,
ocamlVersion,
overlay ? (final: prev: { }),
}:
system:
let
pkgs = import nixpkgs {
inherit system;
};
opamNixLib = opam-nix.lib.${system};
localPackagesQuery = builtins.mapAttrs (_: pkgs.lib.last) (
opamNixLib.listRepo (opamNixLib.makeOpamRepo ./.)
);
devPackagesQuery = devPackages;
query = devPackagesQuery // {
ocaml-base-compiler = ocamlVersion;
};
scope = (opamNixLib.buildOpamProject' { } ./. query).overrideScope overlay;
devPackages' = builtins.attrValues (pkgs.lib.getAttrs (builtins.attrNames devPackagesQuery) scope);
packages = pkgs.lib.getAttrs (builtins.attrNames localPackagesQuery) scope;
in
{
legacyPackages = scope;
devPackages = devPackages';
inherit packages;
};
perSystem = makeOpamPkgs {
ocamlVersion = "4.14.1";
devPackages = {
ocaml-lsp-server = "*";
ocamlformat = "*";
utop = "*";
};
};
overlay = final: prev: { nene = (perSystem prev.system).packages.nene; };
in
{
nixosModules = rec {
nene = {
nixpkgs.overlays = [ overlay ];
imports = [ ./nix/module.nix ];
};
default = nene;
};
}
//
flake-utils.lib.eachSystem
[
"x86_64-linux"
"aarch64-linux"
]
(
system:
let
pkgs = import nixpkgs {
inherit system;
};
p = perSystem system;
in
{
packages = p.packages;
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues p.packages;
buildInputs = p.devPackages;
};
}
);
}