Skip to content

Commit cc9fcc6

Browse files
committed
nix-flakes
1 parent db481dd commit cc9fcc6

20 files changed

+169
-1750
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use_flake

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
result
22
result-*
33
dist-newstyle/
4+
.direnv/

default.nix

+10-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
{ system ? builtins.currentSystem , ... }:
2-
3-
let
4-
rev = "fd364d268852561223a5ada15caad669fd72800e";
5-
nixpkgs = builtins.fetchTarball {
6-
name = "nixpkgs-unstable-22-04-11";
7-
url = "https://github.com/nixos/nixpkgs/tarball/${rev}";
8-
sha256 = "133i5fsx0gix37q4nxm1vfsl9hqbfzv458xykilqhgxmv45jmfl2";
9-
};
10-
in
11-
# Now return the Nixpkgs configured to use our overlay.
12-
import nixpkgs {
13-
inherit system;
14-
15-
overlays = [(import ./overlay.nix)];
16-
}
1+
(import
2+
(
3+
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
4+
fetchTarball {
5+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6+
sha256 = lock.nodes.flake-compat.locked.narHash;
7+
}
8+
)
9+
{ src = ./.; }
10+
).defaultNix

flake.lock

+60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
description = "HEVM";
3+
4+
inputs = {
5+
flake-utils.url = "github:numtide/flake-utils";
6+
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
7+
flake-compat = {
8+
url = "github:edolstra/flake-compat";
9+
flake = false;
10+
};
11+
};
12+
13+
outputs = { self, nixpkgs, flake-utils, ... }:
14+
flake-utils.lib.eachDefaultSystem (system:
15+
let
16+
pkgs = nixpkgs.legacyPackages.${system};
17+
dontCheck = x: y:
18+
pkgs.haskell.lib.dontCheck
19+
(pkgs.haskellPackages.callCabal2nix x y {});
20+
in rec {
21+
22+
# --- packages ----
23+
24+
packages = flake-utils.lib.flattenTree {
25+
libff = pkgs.callPackage (import ./nix/libff.nix) {};
26+
hevm = pkgs.haskell.lib.dontHaddock ((
27+
pkgs.haskellPackages.callCabal2nix "hevm" (./src/hevm) {
28+
# Haskell libs with the same names as C libs...
29+
# Depend on the C libs, not the Haskell libs.
30+
# These are system deps, not Cabal deps.
31+
inherit (pkgs) secp256k1;
32+
}
33+
).overrideAttrs (attrs: {
34+
hardeningDisable = ["pic"];
35+
postInstall = ''
36+
wrapProgram $out/bin/hevm --prefix PATH \
37+
: "${pkgs.lib.makeBinPath (with pkgs; [bash coreutils git solc])}"
38+
'';
39+
40+
enableSeparateDataOutput = true;
41+
buildInputs = attrs.buildInputs ++ [
42+
pkgs.solc
43+
pkgs.z3
44+
pkgs.cvc4
45+
];
46+
nativeBuildInputs = attrs.nativeBuildInputs ++ [pkgs.makeWrapper];
47+
configureFlags = attrs.configureFlags ++ [
48+
"--ghc-option=-O2"
49+
"--enable-executable-static"
50+
"--extra-lib-dirs=${pkgs.gmp.override { withStatic = true; }}/lib"
51+
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
52+
"--extra-lib-dirs=${packages.libff.override { enableStatic = true; }}/lib"
53+
"--extra-lib-dirs=${pkgs.ncurses.override {enableStatic = true; }}/lib"
54+
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
55+
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
56+
];
57+
}));
58+
};
59+
defaultPackage = packages.hevm;
60+
61+
# --- apps ----
62+
63+
apps.hevm = flake-utils.lib.mkApp { drv = packages.hevm; };
64+
defaultApp = apps.hevm;
65+
66+
# --- shell ---
67+
68+
devShell = (pkgs.haskellPackages.shellFor {
69+
packages = _: [
70+
packages.hevm
71+
];
72+
buildInputs = with pkgs.haskellPackages; [
73+
pkgs.z3
74+
pkgs.cvc4
75+
cabal-install
76+
haskell-language-server
77+
];
78+
withHoogle = true;
79+
}).overrideAttrs (_: {
80+
LD_LIBRARY_PATH = "${pkgs.secp256k1}/lib:${pkgs.libff}/lib";
81+
});
82+
}
83+
);
84+
}

src/upload-haskell-package scripts/upload-haskell-package

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ rm -rf dist/*.tar.gz dist/docs
1010
nix-shell --command "cabal haddock --builddir=dist/docs --haddock-for-hackage \
1111
--haddock-option=--hyperlinked-source"
1212
cabal sdist
13-
cabal upload $FLAGS dist-newstyle/sdist/*.tar.gz
14-
cabal upload $FLAGS -d dist/docs/*-docs.tar.gz
13+
cabal upload "$FLAGS" dist-newstyle/sdist/*.tar.gz
14+
cabal upload "$FLAGS" -d dist/docs/*-docs.tar.gz
1515

shell.nix

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(import
2+
(
3+
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
4+
fetchTarball {
5+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6+
sha256 = lock.nodes.flake-compat.locked.narHash;
7+
}
8+
)
9+
{ src = ./.; }
10+
).shellNix

0 commit comments

Comments
 (0)