servant/scripts/generate-nix-files.sh

49 lines
1.5 KiB
Bash
Raw Permalink Normal View History

2015-12-25 15:50:28 +01:00
#!/usr/bin/env bash
2015-07-29 16:06:47 +02:00
#===============================================================================
#
# FILE: generate-nix-files.sh
2015-07-29 16:06:47 +02:00
#
# USAGE: ./generate-nix-files.sh
2015-07-29 16:06:47 +02:00
#
# DESCRIPTION: Update nix files at top-level and add all packages
#
# REQUIREMENTS: bash >= 4, cabal2nix(nix tool)
#===============================================================================
set -o nounset
set -o errexit
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "$DIR"/lib/common.sh
SHELLNIX="shell.nix"
write-package-shell-nix () {
rm -rf $SHELLNIX
echo -e "let" >> $SHELLNIX
echo -e " pkgs = import <nixpkgs> {};" >> $SHELLNIX
echo -e "" >> $SHELLNIX
echo -e " haskellPackages = pkgs.haskellPackages.override {" >> $SHELLNIX
echo -e " overrides = self: super: {" >> $SHELLNIX
for n in ${SOURCES[@]} ; do
if [[ $1 != $n ]]; then
echo -e " $n = pkgs.haskell.lib.dontCheck (pkgs.haskell.lib.appendConfigureFlag (self.callPackage ../$n {}) \"--ghc-options=-Werror\");" >> $SHELLNIX
fi
done
echo -e " $1 = pkgs.haskell.lib.appendConfigureFlag (self.callPackage ./. {}) \"--ghc-options=-Werror\";" >> $SHELLNIX
echo -e " };" >> $SHELLNIX
echo -e " };" >> $SHELLNIX
echo -e "" >> $SHELLNIX
echo -e "in haskellPackages.$s.env" >> $SHELLNIX
}
update-nix-files () {
for s in ${SOURCES[@]} ; do
pushd "$s" > /dev/null
cabal2nix . > default.nix
2015-07-29 16:06:47 +02:00
write-package-shell-nix $s
popd > /dev/null
2015-07-29 16:06:47 +02:00
done
}
update-nix-files