{ description = "gbs-downloader"; inputs = { # Nix Inputs nixpkgs.follows = "hs-flake-utils/nixpkgs"; flake-utils.url = github:numtide/flake-utils; hs-flake-utils.url = "git+https://whetstone.private.storage/jcalderone/hs-flake-utils.git?ref=main"; tahoe-directory = { url = "git+https://whetstone.private.storage/PrivateStorage/tahoe-directory.git?ref=refs/tags/0.1.0.0"; inputs.nixpkgs.follows = "hs-flake-utils/nixpkgs"; }; tahoe-chk.follows = "tahoe-directory/tahoe-chk"; tahoe-ssk.follows = "tahoe-directory/tahoe-ssk"; tahoe-capabilities.follows = "tahoe-directory/tahoe-capabilities"; tahoe-great-black-swamp = { url = "git+https://whetstone.private.storage/PrivateStorage/tahoe-great-black-swamp?ref=refs/tags/0.3.0.0"; inputs.nixpkgs.follows = "hs-flake-utils/nixpkgs"; inputs.tahoe-chk.follows = "tahoe-chk"; }; }; outputs = { self, nixpkgs, flake-utils, hs-flake-utils, tahoe-chk, tahoe-ssk, tahoe-capabilities, tahoe-directory, tahoe-great-black-swamp, }: let ulib = flake-utils.lib; ghcVersion = "ghc8107"; in ulib.eachSystem ["x86_64-linux" "aarch64-darwin"] (system: let # Get a nixpkgs customized for this system and including our overlay. pkgs = import nixpkgs { inherit system; }; hslib = hs-flake-utils.lib { inherit pkgs; src = ./.; compilerVersion = ghcVersion; packageName = "gbs-downloader"; hsPkgsOverrides = hfinal: hprev: { tahoe-chk = tahoe-chk.outputs.packages.${system}.default; tahoe-ssk = tahoe-ssk.outputs.packages.${system}.default; tahoe-directory = tahoe-directory.outputs.packages.${system}.default; tahoe-capabilities = tahoe-capabilities.outputs.packages.${system}.default; tahoe-great-black-swamp = tahoe-great-black-swamp.outputs.packages.${system}.default; # A broken dependency of a tahoe-great-black-swamp executable that # we don't use. Flip the broken bit so we can get a build. language-ecmascript = pkgs.haskell.unmarkBroken hprev.language-ecmascript; }; }; in { checks = hslib.checks {}; devShells = hslib.devShells { shellHook = '' nix run .#generate-cabal-project ''; extraBuildInputs = pkgs: with pkgs; [ # We configure cabal to use zlib:pkg-config so we better supply # pkg-config in the dev shell or `cabal ...` builds will surely # fail. pkg-config # And also that pesky zlib dependency. zlib ]; }; packages = hslib.packages {}; apps.hlint = hslib.apps.hlint {}; apps.generate-cabal-project = { type = "app"; program = "${ pkgs.writeShellApplication { name = "generate-cabal-project"; text = '' cat >cabal.project.local <<EOF -- This file is auto-generated by the flake devShell's shellHook. Do -- not edit this file. Make changes in flake.nix. EOF ''; } }/bin/generate-cabal-project"; }; apps.entr-test = { type = "app"; program = "${ pkgs.writeShellApplication { name = "entr-test"; runtimeInputs = with pkgs; [ entr cabal-install haskell.compiler.${ghcVersion} ]; text = '' find . -iname '*.hs' -or -iname '*.cabal' | entr bash -c "cabal run tests; if [ \$? != 0 ]; then printf '\e[31m%s\e[0m\n' \"FAILED: \$?\"; else printf '\e[32m%s\e[0m\n' 'SUCCESS'; fi" ''; } }/bin/entr-test"; }; apps.release = hslib.apps.release {}; # Using the working directory of `nix run`, do a build with cabal and # then run the test suite. apps.cabal-test = hslib.apps.cabal-test { preBuild = '' # Refresh the cabal.project.local file to point to the correct # dependencies, if necessary. nix run .#generate-cabal-project # Here we make zlib discoverable by pkg-config so cabal can find # headers and stuff. export PKG_CONFIG_PATH=${pkgs.lib.makeSearchPath "lib/pkgconfig" [pkgs.zlib.dev]} ''; }; }); }