forked from harryprayiv/purescript-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
175 lines (162 loc) · 5.58 KB
/
Copy pathflake.nix
File metadata and controls
175 lines (162 loc) · 5.58 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{
description = "Nix derivations for PureScript core language tools.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
};
outputs =
{
self,
nixpkgs,
...
}:
let
inherit (nixpkgs) lib;
eachDefaultSystem =
perSystem:
lib.pipe
[
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
]
[
(map (sys: builtins.mapAttrs (_: value: { ${sys} = value; }) (perSystem sys)))
(builtins.foldl' lib.recursiveUpdate { })
];
in
eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
in
{
# Filter out null values (packages unavailable on this system)
packages = lib.filterAttrs (_: v: v != null) (
{
inherit (pkgs)
purs
purs-unstable
spago
spago-unstable
purs-tidy
purs-tidy-unstable
purs-backend-es
purs-backend-es-unstable
purescript-language-server
purescript-language-server-unstable
;
}
// pkgs.purs-bin
// pkgs.spago-bin
// pkgs.purs-tidy-bin
// pkgs.purs-backend-es-bin
// pkgs.purescript-language-server-bin
);
apps =
let
mkApp = bin: {
type = "app";
program = "${bin}/bin/${bin.pname or bin.name}";
meta = bin.meta or { };
};
in
lib.mapAttrs (_: mkApp) self.packages.${system};
checks =
let
package-checks = lib.mapAttrs (
_: bin:
let
name = bin.pname or bin.name;
version = bin.version or "0.0.0";
in
pkgs.runCommand "test-${name}-${version}" { } ''
touch $out
set -e
set -x
# Different packages at different versions use different 'version'
# flags to print their version
if [ ${builtins.toString (name == "spago" && lib.versionOlder version "0.90.0")} ]; then
VERSION="$(${lib.getExe bin} version --global-cache skip)"
# spago@0.93.21 incorrectly reports its version
elif [ ${builtins.toString (name == "spago" && version == "0.93.21")} ]; then
VERSION="0.93.21"
else
# spago-next writes --version to stderr, oddly enough, so we need to
# capture both in the VERSION var.
VERSION="$(${lib.getExe bin} --version 2>&1)"
fi
# spago 1.x may emit Node experimental warnings; keep first line
if [ ${builtins.toString (name == "spago")} ]; then
VERSION_LINE=""
while IFS= read -r line; do
case "$line" in
[0-9]*.[0-9]*)
VERSION_LINE="$line"
break
;;
esac
done <<< "$VERSION"
if [ -n "$VERSION_LINE" ]; then
VERSION="$VERSION_LINE"
fi
fi
# purs-tidy includes a 'v' prefix in its output beginning with version 0.9.0
if [ ${builtins.toString (name == "purs-tidy" && !(lib.versionOlder version "0.9.0"))} ]; then
EXPECTED_VERSION="v${version}"
# purs-backend-es always includes it
elif [ ${builtins.toString (name == "purs-backend-es")} ]; then
EXPECTED_VERSION="v${version}"
else
EXPECTED_VERSION="${version}"
fi
echo "$VERSION should match expected output $EXPECTED_VERSION"
test "$VERSION" = "$EXPECTED_VERSION"
''
) (lib.filterAttrs (k: _: !(k == "spago" && system == "aarch64-darwin")) self.packages.${system});
# TODO: Remove filter once the purescript build of spago is stable on aarch64-darwin
format-checks = {
nix-format =
pkgs.runCommand "nix-format"
{
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.fileFilter (f: f.hasExt "nix") ./.;
};
nativeBuildInputs = [ pkgs.nixfmt ];
}
''
nixfmt --check $(find $src -type f) && touch $out
'';
};
in
package-checks // format-checks;
devShells = {
default = pkgs.mkShell {
name = "purescript-overlay";
buildInputs = [
self.packages.${system}.spago-unstable
self.packages.${system}.purs-unstable
self.packages.${system}.purs-tidy-unstable
self.packages.${system}.purs-backend-es-unstable
self.packages.${system}.purescript-language-server-unstable
pkgs.nodejs
pkgs.prefetch-npm-deps
pkgs.nixfmt
];
};
};
formatter = pkgs.nixfmt;
}
)
// {
overlays.default = import ./overlay.nix;
};
}