diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8d68527 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1683408522, + "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f5ab8ba --- /dev/null +++ b/flake.nix @@ -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 + ''; + }; + }); +} diff --git a/stack.yaml b/stack.yaml index 1e33dd9..de794bc 100644 --- a/stack.yaml +++ b/stack.yaml @@ -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] @@ -86,7 +86,3 @@ arch: x86_64 # ghc-options: "$locals": -fwarn-incomplete-patterns - -nix: - enable: true - packages: [libff, secp256k1, zlib]