use liqwid-nix; enable checks for CI
add extra command line tool `hasktags`
This commit is contained in:
parent
968409cf34
commit
ed98172d04
2 changed files with 3362 additions and 3869 deletions
6893
flake.lock
generated
6893
flake.lock
generated
File diff suppressed because it is too large
Load diff
338
flake.nix
338
flake.nix
|
|
@ -1,263 +1,109 @@
|
|||
{
|
||||
description = "agora";
|
||||
|
||||
inputs.nixpkgs.follows = "plutarch/nixpkgs";
|
||||
inputs.haskell-nix.follows = "plutarch/haskell-nix";
|
||||
inputs.nixpkgs-latest.url = "github:NixOS/nixpkgs?rev=a0a69be4b5ee63f1b5e75887a406e9194012b492";
|
||||
# temporary fix for nix versions that have the transitive follows bug
|
||||
# see https://github.com/NixOS/nix/issues/6013
|
||||
inputs.nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; };
|
||||
inputs = {
|
||||
nixpkgs.follows = "plutarch/nixpkgs";
|
||||
nixpkgs-latest.url = "github:NixOS/nixpkgs?rev=cf63df0364f67848083ff75bc8ac9b7ca7aa5a01";
|
||||
# temporary fix for nix versions that have the transitive follows bug
|
||||
# see https://github.com/NixOS/nix/issues/6013
|
||||
nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; };
|
||||
|
||||
# Plutarch and its friends
|
||||
inputs.plutarch.url =
|
||||
"github:liqwid-labs/plutarch?rev=e7ef565645146e26e75ec29fe97122a74e52c6b7";
|
||||
inputs.plutarch.inputs.emanote.follows =
|
||||
"plutarch/haskell-nix/nixpkgs-unstable";
|
||||
inputs.plutarch.inputs.nixpkgs.follows =
|
||||
"plutarch/haskell-nix/nixpkgs-unstable";
|
||||
haskell-nix-extra-hackage.follows = "plutarch/haskell-nix-extra-hackage";
|
||||
haskell-nix.follows = "plutarch/haskell-nix";
|
||||
iohk-nix.follows = "plutarch/iohk-nix";
|
||||
haskell-language-server.follows = "plutarch/haskell-language-server";
|
||||
|
||||
inputs.liqwid-plutarch-extra.url =
|
||||
"github:Liqwid-Labs/liqwid-plutarch-extra?ref=seungheonoh/agoraUtils";
|
||||
inputs.plutarch-numeric.url =
|
||||
"github:Liqwid-Labs/plutarch-numeric?ref=main";
|
||||
inputs.plutarch-safe-money.url =
|
||||
"github:Liqwid-Labs/plutarch-safe-money?rev=9f968b80189c7e4b335527cd5b103dc26952f667";
|
||||
# Plutarch and its friends
|
||||
plutarch = {
|
||||
url = "github:Plutonomicon/plutarch-plutus?ref=staging";
|
||||
|
||||
inputs.plutarch-script-export.url =
|
||||
"github:Liqwid-Labs/plutarch-script-export?ref=main";
|
||||
inputs.emanote.follows =
|
||||
"plutarch/haskell-nix/nixpkgs-unstable";
|
||||
inputs.nixpkgs.follows =
|
||||
"plutarch/haskell-nix/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
# Testing
|
||||
inputs.plutarch-quickcheck.url =
|
||||
"github:liqwid-labs/plutarch-quickcheck?ref=staging";
|
||||
plutarch-numeric.url =
|
||||
"github:Liqwid-Labs/plutarch-numeric?ref=main";
|
||||
plutarch-safe-money.url =
|
||||
"github:Liqwid-Labs/plutarch-safe-money?ref=main";
|
||||
liqwid-plutarch-extra.url =
|
||||
"github:Liqwid-Labs/liqwid-plutarch-extra?ref=plutus-v1";
|
||||
plutarch-quickcheck.url =
|
||||
"github:liqwid-labs/plutarch-quickcheck?ref=staging";
|
||||
plutarch-context-builder.url =
|
||||
"github:Liqwid-Labs/plutarch-context-builder?ref=plutus-v1";
|
||||
plutarch-script-export.url =
|
||||
"github:Liqwid-Labs/plutarch-script-export?ref=main";
|
||||
|
||||
# PCB Rev is locked until Agora test have explicit Minting CS. Check PCB PR #12
|
||||
inputs.plutarch-context-builder.url =
|
||||
"github:Liqwid-Labs/plutarch-context-builder?ref=2a2ca72ff310788e531cbbe379ef7b0c4cb42dc9";
|
||||
liqwid-nix.url = "github:Liqwid-Labs/liqwid-nix?ref=main";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, nixpkgs-latest, haskell-nix, plutarch, ... }:
|
||||
outputs = inputs@{ liqwid-nix, ... }:
|
||||
let
|
||||
supportedSystems = nixpkgs-latest.lib.systems.flakeExposed;
|
||||
|
||||
perSystem = nixpkgs.lib.genAttrs supportedSystems;
|
||||
|
||||
pkgsFor = system: import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ haskell-nix.overlay (import "${plutarch.inputs.iohk-nix}/overlays/crypto") ];
|
||||
# This only does bad things for us...
|
||||
# inherit (haskell-nix) config;
|
||||
};
|
||||
pkgsFor' = system: import nixpkgs-latest { inherit system; };
|
||||
|
||||
fourmoluFor = system: (pkgsFor' system).haskell.packages.ghc922.fourmolu_0_6_0_0;
|
||||
|
||||
defaultGhcVersion = "ghc923";
|
||||
|
||||
nonReinstallablePkgs = [
|
||||
"array"
|
||||
"array"
|
||||
"base"
|
||||
"binary"
|
||||
"bytestring"
|
||||
"Cabal"
|
||||
"containers"
|
||||
"deepseq"
|
||||
"directory"
|
||||
"exceptions"
|
||||
"filepath"
|
||||
"ghc"
|
||||
"ghc-bignum"
|
||||
"ghc-boot"
|
||||
"ghc-boot"
|
||||
"ghc-boot-th"
|
||||
"ghc-compact"
|
||||
"ghc-heap"
|
||||
# "ghci"
|
||||
# "haskeline"
|
||||
"ghcjs-prim"
|
||||
"ghcjs-th"
|
||||
"ghc-prim"
|
||||
"ghc-prim"
|
||||
"hpc"
|
||||
"integer-gmp"
|
||||
"integer-simple"
|
||||
"mtl"
|
||||
"parsec"
|
||||
"pretty"
|
||||
"process"
|
||||
"rts"
|
||||
"stm"
|
||||
"template-haskell"
|
||||
"terminfo"
|
||||
"text"
|
||||
"time"
|
||||
"transformers"
|
||||
"unix"
|
||||
"Win32"
|
||||
"xhtml"
|
||||
];
|
||||
|
||||
haskellModules = [
|
||||
({ config, pkgs, hsPkgs, ... }: {
|
||||
inherit nonReinstallablePkgs; # Needed for a lot of different things
|
||||
packages = {
|
||||
cardano-binary.doHaddock = false;
|
||||
cardano-binary.ghcOptions = [ "-Wwarn" ];
|
||||
cardano-crypto-class.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf ] ];
|
||||
cardano-crypto-class.doHaddock = false;
|
||||
cardano-crypto-class.ghcOptions = [ "-Wwarn" ];
|
||||
cardano-crypto-praos.components.library.pkgconfig = pkgs.lib.mkForce [ [ pkgs.libsodium-vrf ] ];
|
||||
cardano-prelude.doHaddock = false; # somehow above options are not applied?
|
||||
cardano-prelude.ghcOptions = [ "-Wwarn" ];
|
||||
# Workaround missing support for build-tools:
|
||||
# https://github.com/input-output-hk/haskell.nix/issues/231
|
||||
plutarch-test.components.exes.plutarch-test.build-tools = [
|
||||
config.hsPkgs.hspec-discover
|
||||
];
|
||||
benchCheckOverlay = self: super: {
|
||||
toFlake =
|
||||
let
|
||||
inherit (self) inputs perSystem pkgsFor';
|
||||
flake = super.toFlake or { };
|
||||
name = "benchCheck";
|
||||
in
|
||||
flake // {
|
||||
checks = perSystem (system:
|
||||
flake.checks.${system} // {
|
||||
${name} =
|
||||
let
|
||||
pkgs' = pkgsFor' system;
|
||||
bench = flake.packages.${system}."agora:bench:agora-bench";
|
||||
in
|
||||
pkgs'.runCommand name
|
||||
{
|
||||
nativeBuildInputs = [ pkgs'.diffutils ];
|
||||
} ''
|
||||
export LC_CTYPE=C.UTF-8
|
||||
export LC_ALL=C.UTF-8
|
||||
export LANG=C.UTF-8
|
||||
cd ${inputs.self}
|
||||
${bench}/bin/agora-bench | diff bench.csv - \
|
||||
|| (echo "bench.csv is outdated"; exit 1)
|
||||
mkdir "$out"
|
||||
'';
|
||||
});
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
myhackage = system: compiler-nix-name: plutarch.inputs.haskell-nix-extra-hackage.mkHackageFor system compiler-nix-name (
|
||||
[
|
||||
"${inputs.plutarch.inputs.flat}"
|
||||
"${inputs.plutarch.inputs.protolude}"
|
||||
"${inputs.plutarch.inputs.cardano-prelude}/cardano-prelude"
|
||||
"${inputs.plutarch.inputs.cardano-crypto}"
|
||||
"${inputs.plutarch.inputs.cardano-base}/binary"
|
||||
"${inputs.plutarch.inputs.cardano-base}/cardano-crypto-class"
|
||||
"${inputs.plutarch.inputs.plutus}/plutus-core"
|
||||
"${inputs.plutarch.inputs.plutus}/plutus-ledger-api"
|
||||
"${inputs.plutarch.inputs.plutus}/plutus-tx"
|
||||
"${inputs.plutarch.inputs.plutus}/prettyprinter-configurable"
|
||||
"${inputs.plutarch.inputs.plutus}/word-array"
|
||||
"${inputs.plutarch.inputs.secp256k1-haskell}"
|
||||
"${inputs.plutarch.inputs.plutus}/plutus-tx-plugin" # necessary for FFI tests
|
||||
|
||||
# Custom deps as a consumer
|
||||
"${inputs.plutarch}"
|
||||
"${inputs.plutarch}/plutarch-extra"
|
||||
"${inputs.liqwid-plutarch-extra}"
|
||||
};
|
||||
in
|
||||
(liqwid-nix.buildProject
|
||||
{
|
||||
inherit inputs;
|
||||
src = ./.;
|
||||
}
|
||||
[
|
||||
liqwid-nix.haskellProject
|
||||
liqwid-nix.plutarchProject
|
||||
(liqwid-nix.addDependencies [
|
||||
"${inputs.plutarch-numeric}"
|
||||
"${inputs.plutarch-safe-money}"
|
||||
"${inputs.plutarch-quickcheck}"
|
||||
"${inputs.plutarch-context-builder}"
|
||||
"${inputs.liqwid-plutarch-extra}"
|
||||
"${inputs.plutarch-script-export}"
|
||||
]
|
||||
);
|
||||
|
||||
applyDep = pkgs: o:
|
||||
let
|
||||
h = myhackage pkgs.system o.compiler-nix-name;
|
||||
o' = (plutarch.applyPlutarchDep pkgs o);
|
||||
in
|
||||
o' // rec {
|
||||
modules = haskellModules ++ [ h.module ] ++ (o'.modules or [ ]);
|
||||
extra-hackages = [ (import h.hackageNix) ] ++ (o'.extra-hackages or [ ]);
|
||||
extra-hackage-tarballs = { _xNJUd_plutarch-hackage = h.hackageTarball; };
|
||||
cabalProjectLocal = (o'.cabalProjectLocal or "") + " , cache >= 0.1.3.0 ";
|
||||
};
|
||||
|
||||
projectForGhc = compiler-nix-name: system:
|
||||
let pkgs = pkgsFor system; in
|
||||
let pkgs' = pkgsFor' system; in
|
||||
let pkgSet = pkgs.haskell-nix.cabalProject' (applyDep pkgs {
|
||||
src = ./.;
|
||||
inherit compiler-nix-name;
|
||||
modules = [ ];
|
||||
shell = {
|
||||
withHoogle = true;
|
||||
|
||||
exactDeps = true;
|
||||
|
||||
# We use the ones from Nixpkgs, since they are cached reliably.
|
||||
# Eventually we will probably want to build these with haskell.nix.
|
||||
nativeBuildInputs = [
|
||||
pkgs'.cabal-install
|
||||
pkgs'.hlint
|
||||
pkgs'.haskellPackages.cabal-fmt
|
||||
(fourmoluFor system)
|
||||
pkgs'.nixpkgs-fmt
|
||||
(plutarch.hlsFor compiler-nix-name system)
|
||||
];
|
||||
};
|
||||
}); in
|
||||
pkgSet;
|
||||
|
||||
projectFor = projectForGhc defaultGhcVersion;
|
||||
|
||||
formatCheckFor = system:
|
||||
let
|
||||
pkgs' = pkgsFor' system;
|
||||
in
|
||||
pkgs'.runCommand "format-check"
|
||||
{
|
||||
nativeBuildInputs = [ pkgs'.haskellPackages.cabal-fmt pkgs'.nixpkgs-fmt (fourmoluFor system) pkgs'.hlint ];
|
||||
} ''
|
||||
export LC_CTYPE=C.UTF-8
|
||||
export LC_ALL=C.UTF-8
|
||||
export LANG=C.UTF-8
|
||||
cd ${self}
|
||||
make format_check || (echo " Please run 'make format'" ; exit 1)
|
||||
find -name '*.hs' -not -path './dist*/*' -not -path './haddock/*' | xargs hlint
|
||||
mkdir $out
|
||||
''
|
||||
;
|
||||
|
||||
benchCheckFor = system: agora-bench:
|
||||
let
|
||||
pkgs = pkgsFor system;
|
||||
pkgs' = pkgsFor' system;
|
||||
in
|
||||
pkgs.runCommand "bench-check"
|
||||
{
|
||||
bench = "${agora-bench}/bin/agora-bench";
|
||||
nativeBuildInputs = [
|
||||
pkgs'.diffutils
|
||||
];
|
||||
} ''
|
||||
export LC_CTYPE=C.UTF-8
|
||||
export LC_ALL=C.UTF-8
|
||||
export LANG=C.UTF-8
|
||||
cd ${self}
|
||||
make bench_check || (echo " Please run 'make bench'" ; exit 1)
|
||||
mkdir $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
project = perSystem projectFor;
|
||||
flake = perSystem (system: (projectFor system).flake { });
|
||||
|
||||
packages = perSystem (system:
|
||||
self.flake.${system}.packages // {
|
||||
haddock =
|
||||
let
|
||||
agora-doc = self.flake.${system}.packages."agora:lib:agora".doc;
|
||||
pkgs = pkgsFor system;
|
||||
in
|
||||
pkgs.runCommand "haddock-merge" { } ''
|
||||
cd ${self}
|
||||
mkdir $out
|
||||
cp -r ${agora-doc}/share/doc/* $out
|
||||
'';
|
||||
});
|
||||
|
||||
# Define what we want to test
|
||||
checks = perSystem (system:
|
||||
self.flake.${system}.checks // {
|
||||
formatCheck = formatCheckFor system;
|
||||
# benchCheck = benchCheckFor system self.flake.${system}.packages."agora:bench:agora-bench";
|
||||
agora = self.flake.${system}.packages."agora:lib:agora";
|
||||
agora-test = self.flake.${system}.packages."agora:test:agora-test";
|
||||
benchCheck = benchCheckFor system self.flake.${system}.packages."agora:bench:agora-bench";
|
||||
});
|
||||
check = perSystem (system:
|
||||
(pkgsFor system).runCommand "combined-test"
|
||||
{
|
||||
checksss = builtins.attrValues self.checks.${system};
|
||||
} ''
|
||||
echo $checksss
|
||||
touch $out
|
||||
'');
|
||||
devShell = perSystem (system: self.flake.${system}.devShell);
|
||||
};
|
||||
])
|
||||
(liqwid-nix.enableFormatCheck [
|
||||
"-XQuasiQuotes"
|
||||
"-XTemplateHaskell"
|
||||
"-XTypeApplications"
|
||||
"-XImportQualifiedPost"
|
||||
"-XPatternSynonyms"
|
||||
"-XOverloadedRecordDot"
|
||||
])
|
||||
liqwid-nix.enableLintCheck
|
||||
liqwid-nix.enableCabalFormatCheck
|
||||
liqwid-nix.enableNixFormatCheck
|
||||
liqwid-nix.addBuildChecks
|
||||
(liqwid-nix.addCommandLineTools (pkgs: _: [
|
||||
pkgs.haskellPackages.hasktags
|
||||
]))
|
||||
benchCheckOverlay
|
||||
]
|
||||
).toFlake;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue