-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathupdate-nix-from-cabal.sh
More file actions
executable file
·51 lines (46 loc) · 1.83 KB
/
Copy pathupdate-nix-from-cabal.sh
File metadata and controls
executable file
·51 lines (46 loc) · 1.83 KB
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
49
50
51
#!/usr/bin/env bash
# Regenerates default.nix files from .cabal files.
# Run this after changing any .cabal file.
#
# Why: IHP uses pre-generated nix files instead of callCabal2nix to avoid
# Import From Derivation (IFD). IFD causes nix to build cabal2nix during
# evaluation, making derivation hashes platform-dependent and breaking
# caching across machines.
# See: https://github.com/NixOS/nixpkgs/issues/36190
set -euo pipefail
cd "$(dirname "$0")"
# --- Local IHP packages ---
for cabal_file in */*.cabal; do
dir=$(dirname "$cabal_file")
echo "Generating $dir/default.nix from $cabal_file"
# Run cabal2nix from within the package directory so that src = ./. points
# to the package root (not a subdirectory). The overlay overrides src anyway,
# but this keeps the generated file correct if used standalone.
(cd "$dir" && cabal2nix .) > "./$dir/default.nix"
done
# --- Third-party Hackage packages ---
# Pre-generated to avoid IFD (Import From Derivation).
# Update versions here when upgrading dependencies.
mkdir -p NixSupport/hackage
hackage_packages=(
"wai-session-maybe 1.0.0"
"wai-session-clientsession-deferred 1.0.0"
"postgresql-connection-string 0.1.0.6"
"temporary-ospath 1.3"
"ptr-poker 0.1.3"
"postgresql-simple-postgresql-types 0.1.1"
"postgresql-types-algebra 0.1"
"postgresql-types 0.1.2"
"hasql-mapping 0.1"
"hasql-postgresql-types 0.2"
"ihp-zip 0.1.1"
)
# Note: hasql/postgresql-binary/postgresql-types/hasql-mapping and friends
# are pulled directly from nixpkgs via versioned attributes (hasql_1_10_3
# etc.) since NixOS/nixpkgs#519795. See NixSupport/overlay.nix.
for entry in "${hackage_packages[@]}"; do
name="${entry%% *}"
ver="${entry##* }"
echo "Generating NixSupport/hackage/${name}.nix from Hackage: ${name}-${ver}"
cabal2nix "cabal://${name}-${ver}" > "NixSupport/hackage/${name}.nix"
done