Skip to content

Commit

Permalink
feat: refactor flake, add script to run test-transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Feb 5, 2024
1 parent 99ee50f commit cfb7705
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@
overrideCabal
;

eo-test-transformer = "eo-test-transformer";

# Here's our override
# Haskell overrides are described here: https://nixos.org/manual/nixpkgs/unstable/#haskell
override = {
overrides = self: super: {
"${packageName}" = overrideCabal (super.callCabal2nix packageName ./${packageName} { }) (x: {
librarySystemDepends = [ ] ++ (x.librarySystemDepends or [ ]);
executableSystemDepends = [ ] ++ (x.executableSystemDepends or [ ]);
});
};
override.overrides = self: super: {
"${packageName}" = super.callCabal2nix packageName ./${packageName} { };
"${eo-test-transformer}" = super.callCabal2nix eo-test-transformer ./eo/test-transformer { };
};

# --- Haskell tools ---
Expand All @@ -81,7 +79,7 @@
# GHC will be given dependencies of both A and B.
# However, we don't want B to be in the list of dependencies of GHC
# because build of GHC may fail due to errors in B.
packages = ps: [ ps.${packageName} ];
packages = ps: [ ps.${packageName} ps.${eo-test-transformer} ];
})
hls cabal fourmolu justStaticExecutable
ghcid ghc haskellPackages hpack stack;
Expand Down Expand Up @@ -110,7 +108,7 @@
# --- Packages ---

packages = mkShellApps {
eoc = pkgs.buildNpmPackage rec {
eo = pkgs.buildNpmPackage rec {
name = "";
version = "0.15.1";
src = inputs.eoc;
Expand All @@ -128,11 +126,10 @@
description = "EO compiler";
homepage = "https://github.com/objectionary/eoc";
license = licenses.mit;
mainProgram = "eoc";
};
};

#

# --- Haskell package ---

# This is a static executable with given runtime dependencies.
Expand All @@ -148,7 +145,7 @@
runtimeInputs = [
stack
pkgs.jdk21
packages.eoc
packages.eo
pkgs.maven
pkgs.perl
];
Expand All @@ -165,6 +162,32 @@
description = "Run pipeline";
excludeShellChecks = [ "SC2139" ];
};

genPhi = {
text = ''
export JAVA_HOME="${pkgs.jdk21.home}"
mkdir -p .pipeline/"$PROGRAM"
mkdir -p test/phi
cp eo-runtime/src/test/eo/org/eolang-subset/"$PROGRAM".eo .pipeline/"$PROGRAM"/app.eo
cd .pipeline/"$PROGRAM"
${lib.getExe packages.eo} -- clean
${lib.getExe packages.eo} -- phi
cp .eoc/phi/app.phi ../../test/phi/"$PROGRAM".phi
'';
};

genPhis = {
text = ''
cd eo
LANG=en_US.UTF-8
${lib.getExe stack} run eo-test-transformer
${lib.getExe pkgs.yq} -r .[].set test/config.yaml \
| xargs -I {} bash -c 'x={}; export PROGRAM=''${x%.eo}; ${lib.getExe packages.genPhi}'
'';
excludeShellChecks = [ "SC2016" ];
};
};

# --- Devshells ---
Expand Down

0 comments on commit cfb7705

Please sign in to comment.