-
Notifications
You must be signed in to change notification settings - Fork 0
/
cook.sh
executable file
·48 lines (33 loc) · 1.23 KB
/
cook.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
if ! type dirname > /dev/null 2>&1; then
echo "Not even a linux or macOS, Windoze? We don't support it. Abort."
exit 1
fi
. "$(dirname "$0")"/common/common.sh
usage_and_exit () {
echo "Usage: cook.sh <project root path> <project name>"
exit 1
}
init_with_root_or_sudo "$0"
SCRIPT_ABS_PATH=$(turn_to_absolute_path $0)
if [ "$#" != 2 ]; then
usage_and_exit
fi
begin_banner "Top level" "project cooking"
"${SCRIPT_ABS_PATH}"/prepare-env/do.sh
"${SCRIPT_ABS_PATH}"/project-scaffold/do.sh "$1" "$2"
cp -R "${SCRIPT_ABS_PATH}"/build-framework/* "$1/$2/"
for FILE_TO_SED in $(grep -R MY_PROJECT_NAME "$1/$2/"*|awk -F":" '{print $1}'|sort|uniq)
do
sed -i.bak.for.sed.inplace.edit "s/MY_PROJECT_NAME/$2/g" ${FILE_TO_SED}
rm -fr ${FILE_TO_SED}.bak.for.sed.inplace.edit
done
#update index-state in the cabal.project file
echo "index-state : $(date +%Y-%m-%dT00:00:00Z)" > "$1/$2"/cabal.project
#update niv sources list
set +u
[[ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]] && . $HOME/.nix-profile/etc/profile.d/nix.sh
set -u
nix-shell '<nixpkgs>' -p haskellPackages.niv --run "cd $1/$2; niv init; niv add input-output-hk/haskell.nix"
# everything's done
done_banner "Top level" "project cooking"