-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-default-nix.sh
executable file
·35 lines (30 loc) · 1.22 KB
/
generate-default-nix.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
#!/usr/bin/env bash
set -eu
: ${GALOIS?Need path to Galois directory in GALOIS environment variable}
: ${1?First argument should be a project name}
: ${2?First argument should be a package name}
PROJECT=$1
PACKAGE=$2
# WARNING: don't rename this variable PATH as it means something to Linux!
PACKAGEPATH=`${GALOIS}/scripts/get-local-path.sh ${1} ${2}`
echo "Generating default.nix for package ${1}/${2}"
(
cd ${GALOIS}/projects/${PROJECT}/${PACKAGEPATH}
cabal2nix . > default.nix
# Replaces:
# src = ./.;
# with something filtering out non-important paths
# NOTE: you cannot just use fetchGit, because some projects live in git subdirectories,
# which creates problems.
# .ghc.environment is super important to remove, it will break packages
sed -i -e 's~src = ./.~src = builtins.filterSource (path: type:\
!(stdenv.lib.strings.hasPrefix ".ghc.environment" (baseNameOf path))\
\&\& baseNameOf path != ".git"\
\&\& baseNameOf path != ".codescape_store"\
\&\& baseNameOf path != ".stack-work"\
\&\& baseNameOf path != "dist"\
\&\& baseNameOf path != "dist-newstyle"\
\&\& baseNameOf path != "default.nix"\
\&\& baseNameOf path != "result"\
) ./.~g' default.nix
)