69 lines
1.8 KiB
Nix
69 lines
1.8 KiB
Nix
{
|
|
description = "henttp - agda web library";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (sys:
|
|
let pkgs = nixpkgs.legacyPackages.${sys};
|
|
|
|
agda = pkgs.agda.withPackages {
|
|
pkgs = pkgs: [ pkgs.standard-library ];
|
|
ghc = pkgs.ghc.withPackages (pkgs: with pkgs; [ bytestring network network-run utf8-string ]);
|
|
};
|
|
buildInputs = with pkgs; [
|
|
agda
|
|
];
|
|
|
|
common = ''
|
|
build() {
|
|
mkdir -p ./artifacts
|
|
${agda}/bin/agda --compile-dir ./artifacts --compile "''${1:-./Main.agda}"
|
|
}
|
|
clean() {
|
|
fd -I '.agdai|artifacts' --exec rm -rf
|
|
}
|
|
'';
|
|
|
|
henttp = pkgs.stdenv.mkDerivation {
|
|
name = "henttp";
|
|
src = ./src;
|
|
inherit buildInputs;
|
|
buildPhase = common + ''
|
|
build
|
|
mkdir -p $out/bin
|
|
mv artifacts/main $out/bin/henttp
|
|
'';
|
|
};
|
|
|
|
check-all = pkgs.stdenv.mkDerivation {
|
|
name = "henttp-run-tests";
|
|
src = ./src;
|
|
buildInputs = buildInputs ++ [ pkgs.fd ];
|
|
buildPhase = common + ''
|
|
set -e
|
|
check() {
|
|
echo "[ Checking $1 ]"
|
|
agda "$1"
|
|
}
|
|
export -f check
|
|
fd 'Test.agda$' --exec bash -c 'check "$@"' _ {}
|
|
echo "All test passed :)"
|
|
touch $out
|
|
'';
|
|
};
|
|
in {
|
|
packages = {
|
|
henttp = henttp;
|
|
default = henttp;
|
|
};
|
|
devShell = pkgs.mkShell { packages = buildInputs; shellHook = common; };
|
|
checks = {
|
|
default = check-all;
|
|
};
|
|
}
|
|
);
|
|
}
|