-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinit.sh
executable file
·41 lines (33 loc) · 1.1 KB
/
init.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
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gnused
# shellcheck shell=bash
set -euo pipefail
# Start in project root
cd "$(dirname "${BASH_SOURCE[0]}")/"
# Make sure the git repo is in fact Nixkell's before nuking stuff
repo_url=$(git config --get remote.origin.url)
if [[ $(basename -s .git "$repo_url") != "nixkell" ]]; then
echo "Not a nixkell repository, aborting..."
exit 1
fi
# Nuke nixkell's .git, assets and init new repo
rm -rf .git
rm -rf assets
git init .
project_name=${PWD##*/}
# Blank slate readme
echo "# $project_name" >README.md
# Replace all dummy "nixkell" with the project name
for i in $(find . -type f -name "*.nix"); do
sed -i "s/nixkell/$project_name/g" "$i"
done
sed -i "s/nixkell/$project_name/g" ./package.yaml
sed -i "s/nixkell/$project_name/g" ./bin/Main.hs
# un-replace the name of the config
sed -i "s/$project_name.toml/nixkell.toml/g" ./nix/packages.nix
# comment out the Nixkell specific cachix entry from the CI config
sed -i -e '/Install Cachix/,+4 s/.*/# &/' '.github/workflows/nix.yml'
# Fire up the nix shell
direnv allow .
# Finally delete this script
rm -f init.sh