forked from HigherOrderCO/HVM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
105 lines (105 loc) · 2.89 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
# Resources:
# https://github.com/serokell/templates/blob/master/rust-crate2nix/flake.nix
# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix
# https://github.com/oxalica/rust-overlay#use-in-devshell-for-nix-develop
# https://nest.pijul.com/pijul/pijul:main/SXEYMYF7P4RZM.BKPQ6
# https://github.com/srid/rust-nix-template/blob/master/flake.nix
{
description = "A lazy, beta-optimal, massively-parallel, non-garbage-collected and strongly-confluent functional compilation target.";
inputs = {
crate2nix = {
url = "github:kolloch/crate2nix";
flake = false;
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ crate2nix
, flake-compat
, flake-utils
, nixpkgs
, rust-overlay
, self
, ...
}:
let
name = "hvm";
rustChannel = "stable";
rustVersion = "latest";
inherit (builtins)
attrValues
listToAttrs
map
;
in
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [
(import rust-overlay)
(after: before:
(listToAttrs (map
(element: {
name = element;
value = before.rust-bin.${rustChannel}.${rustVersion}.default;
}) [
"cargo"
"rustc"
])))
];
pkgs = import nixpkgs {
inherit system overlays;
};
buildInputs = [
pkgs.hyperfine
pkgs.nodejs
pkgs.time
];
nativeBuildInputs = [
pkgs.clang
pkgs.ghc
];
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
generatedCargoNix;
cargoNix = import
(generatedCargoNix {
inherit name;
src = ./.;
})
{
inherit pkgs;
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
${name} = attrs: {
inherit buildInputs nativeBuildInputs;
};
};
};
in
{
packages.${name} = cargoNix.rootCrate.build;
# `nix build`
defaultPackage = self.packages.${system}.${name};
# `nix flake check`
checks.${name} = cargoNix.rootCrate.build.override {
runTests = true;
};
# `nix run`
apps.${name} = flake-utils.lib.mkApp {
inherit name;
drv = self.packages.${system}.${name};
};
defaultApp = self.apps.${system}.${name};
# `nix develop`
devShell = pkgs.mkShell {
inputsFrom = attrValues self.packages.${system};
inherit buildInputs nativeBuildInputs;
};
}
);
}