Skip to content

Commit

Permalink
Revised shell variables so make works inside/outside nix develop.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwbush committed Feb 19, 2024
1 parent 152a4bb commit bfe7f64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ typecheck: $(HSFILES) $(LHSFILES)

# From https://stackoverflow.com/questions/34621364/makefile-compile-o-from-c-files
$(HSDIR)/%.hs: %.agda
@$(AGDA2HS) --library-file=$(AGDA_LIBS) --compile-dir=$(HSDIR)/src $^
@$(AGDA2HS) --local-interfaces --library-file=$(AGDA_LIBS) --compile-dir=$(HSDIR)/src $^

# FIXME: this obviously won't scale...
$(HSDIR)/src/Peras/SmallStep.hs: src/Peras/SmallStep.lagda.md
@$(AGDA2HS) --library-file=$(AGDA_LIBS) --compile-dir=$(HSDIR)/src $^
@$(AGDA2HS) --local-interfaces --library-file=$(AGDA_LIBS) --compile-dir=$(HSDIR)/src $^

.PHONY : clean veryclean
clean:
@echo "Removing .agdai files"
@find src -name \*.agdai -delete;

veryclean:
@echo "Removing generated.hs files"
@rm $(HSFILES) $(LHSFILES)
22 changes: 1 addition & 21 deletions nix/agda2hs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ let
};

agdaLib = repoRoot.nix.agda-packages.mkDerivation {
pname = "agda2hs";
version = "1.2";
src = inputs.agda2nix;
meta = {
description = "agda2hs";
};
everythingFile = "./lib/Everything.agda";
preBuild = ''
# This won't compile without `--sized-types`.
sed -i '/^flags:/s/$/ --sized-types/' agda2hs.agda-lib
# Create the missing everything file.
find lib -type f -name \*.agda | sed -e 's/^lib\//import /; s/\.agda$// ; s/\//./g' > Everything.agda
sed -i '1imodule Everything where' Everything.agda
mv Everything.agda lib/
# Remove extraneous files.
rm -rf test tutorials
'';
};

altAgdaLib = repoRoot.nix.agda-packages.mkDerivation {
pname = "agda2hs";
version = "1.2";
src = inputs.agda2nix;
Expand All @@ -60,5 +40,5 @@ in

{
exe = haskellProject.hsPkgs.agda2hs.components.exes.agda2hs;
lib = altAgdaLib;
lib = agdaLib;
}
3 changes: 2 additions & 1 deletion nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ cabalProject:
# Agda hook.
echo "${repoRoot.nix.agda-stdlib}/standard-library.agda-lib" > .libraries
echo "${repoRoot.nix.agda2hs.lib}/agda2hs.agda-lib" >> .libraries
export AGDA_LIBS="--local-interfaces --library-file=$PWD/.libraries"
export AGDA_LIBS="$PWD/.libraries"
# Rust hook.
export RUSTC_VERSION=$(rustup toolchain list | sed -n -e '/ (default)$/{s/ (default)$//;p}')
export PATH=''${CARGO_HOME:-~/.cargo}/bin:$PATH
export PATH=''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION/bin/:$PATH
echo "NOTE: 'make' will use the libraries file '$AGDA_LIBS' unless 'AGDA_LIBS' is set differently."
'';

tools = {
Expand Down

0 comments on commit bfe7f64

Please sign in to comment.