Skip to content

Commit

Permalink
CAD-2712 cabal-inside-nix-shell: use the script
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire authored and jutaro committed May 13, 2021
1 parent aa5929a commit 4686579
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -40,10 +40,10 @@ cluster-shell:
nix-shell --max-jobs 8 --cores 0 -A 'devops' --arg 'autoStartCluster' 'true'

cabal-setup setup:
sed -ni '1,/--- 8< ---/ p' cabal.project
./scripts/cabal-inside-nix-shell.sh

cabal-restore restore:
git checkout HEAD cabal.project
./scripts/cabal-inside-nix-shell.sh --restore

cli node:
cabal --ghc-options="+RTS -qn8 -A32M -RTS" build cardano-$@
Expand Down Expand Up @@ -71,4 +71,4 @@ full-clean: clean
cls:
echo -en "\ec"

.PHONY: stylish-haskell cabal-hashes ghcid ghcid-test run-test test-ghci test-ghcid help clean clean-profile proclean cls
.PHONY: stylish-haskell cabal-hashes ghcid ghcid-test run-test test-ghci test-ghcid help clean clean-profile proclean cls cabal-setup setup cabal-restore restore
7 changes: 4 additions & 3 deletions cabal.project
Expand Up @@ -87,9 +87,10 @@ package io-sim-classes

-- ---------------------------------------------------------

-- The two following one-liners will restore / cut off the remainder of this file (for nix-shell users):
-- git checkout HEAD "$(git rev-parse --show-toplevel)"/cabal.project
-- sed -ni '1,/--- 8< ---/ p' "$(git rev-parse --show-toplevel)"/cabal.project
-- The two following one-liners will cut off / restore the remainder of this file (for nix-shell users):
-- scripts/cabal-inside-nix-shell.sh
-- scripts/cabal-inside-nix-shell.sh --restore
-- --------------------------- 8< --------------------------
-- Please do not put any `source-repository-package` clause above this line.

source-repository-package
Expand Down
7 changes: 6 additions & 1 deletion scripts/cabal-inside-nix-shell.sh
@@ -1,3 +1,8 @@
#!/usr/bin/env bash

sed -ni '1,/--- 8< ---/ p' "$(git rev-parse --show-toplevel)"/cabal.project
case $1 in
--exit | --undo | --restore )
git checkout HEAD cabal.project;;
* )
sed -ni '1,/--- 8< ---/ p' "$(git rev-parse --show-toplevel)"/cabal.project
esac
5 changes: 3 additions & 2 deletions shell.nix
Expand Up @@ -50,10 +50,11 @@ let

shellHook = ''
echo "Setting 'cabal.project' for local builds.."
make cabal-setup
./scripts/cabal-inside-nix-shell.sh
function atexit() {
echo "Reverting 'cabal.project' to the index version.."
make cabal-restore
./scripts/cabal-inside-nix-shell.sh --restore
}
trap atexit EXIT
'';
Expand Down

0 comments on commit 4686579

Please sign in to comment.