Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flake support #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
description = "Opt-in Stack Flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};

hPkgs =
pkgs.haskell.packages."ghc927"; # need to match Stackage LTS version from stack.yaml resolver

myDevTools = [
hPkgs.ghc # GHC compiler in the desired version (will be available on PATH)
stack-wrapped
pkgs.zlib # External C library needed by some Haskell packages
pkgs.secp256k1
pkgs.libff
];

stack-wrapped = pkgs.symlinkJoin {
name = "stack"; # will be available as the usual `stack` in terminal
paths = [ pkgs.stack ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--no-nix \
--system-ghc \
--no-install-ghc \
"
'';
};
in {
devShells.default = pkgs.mkShell {
buildInputs = myDevTools;

# Make external Nix c libraries like zlib known to GHC, like
# pkgs.haskell.lib.buildStackProject does
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath myDevTools;

shellHook = ''
if test -f "REPO_UNINITIALIZED.sh"; then
chmod +x REPO_UNINITIALIZED.sh
./REPO_UNINITIALIZED.sh
rm REPO_UNINITIALIZED.sh
fi
'';
};
});
}
6 changes: 1 addition & 5 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ allow-newer: true
#
# Override the architecture used by stack, especially useful on Windows
# Change to x86_64 for Intel and aarch64 for ARM/apple silicon
arch: x86_64
arch: aarch64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
Expand All @@ -86,7 +86,3 @@ arch: x86_64
#
ghc-options:
"$locals": -fwarn-incomplete-patterns

nix:
enable: true
packages: [libff, secp256k1, zlib]