Newer
Older
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";
url = "git+https://whetstone.private.storage/PrivateStorage/tahoe-chk?ref=refs/tags/0.1.0.1";
inputs.nixpkgs.follows = "hs-flake-utils/nixpkgs";
};
tahoe-ssk = {
url = "git+https://whetstone.private.storage/PrivateStorage/tahoe-ssk?ref=refs/tags/0.2.0.0";
inputs.nixpkgs.follows = "hs-flake-utils/nixpkgs";
inputs.tahoe-chk.follows = "tahoe-chk";
};
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";
};
outputs = {
self,
nixpkgs,
flake-utils,
hs-flake-utils,
tahoe-chk,
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;
hsPkgsOverrides = import ./nix/haskell-packages.nix {
tahoe-chk = tahoe-chk.outputs.packages.${system}.default;
tahoe-ssk = tahoe-ssk.outputs.packages.${system}.default;
tahoe-great-black-swamp = tahoe-great-black-swamp.outputs.packages.${system}.default;
haskellLib = pkgs.haskell.lib;
};
};
in {
checks = hslib.checks {};
devShells = hslib.devShells {
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.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";
};
# Using the working directory of `nix run`, do a build with cabal and
# then run the test suite.
apps.cabal-test = {
type = "app";
program = "${
pkgs.writeShellApplication {
name = "cabal-build-and-test";
# Only put packages with things that need to be on PATH here
# because that's all that runtimeInputs buys us. Packages with
# different requirements need to be handled differently.
runtimeInputs = with pkgs; [
pkg-config
haskell.compiler.${ghcVersion}
cabal-install
];
# 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]}
# Get (or update if we have one) a package database so cabal can
# solve our dependencies.
# Configure with tests enable, build the tests (if necessary),
# and run the default test suite.
cabal run --enable-tests tests
'';
}
}/bin/cabal-build-and-test";
};
});
}