Skip to content

Commit 52223e0

Browse files
Refactor Nix setup to be simpler (#132)
1 parent 45bbb4f commit 52223e0

13 files changed

+554
-529
lines changed

flake.nix

Lines changed: 66 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919
eachDefaultSystem =
2020
perSystem:
2121
lib.pipe
22-
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]
22+
[
23+
"x86_64-linux"
24+
"x86_64-darwin"
25+
"aarch64-linux"
26+
"aarch64-darwin"
27+
]
2328
[
2429
(map (sys: builtins.mapAttrs (_: value: { ${sys} = value; }) (perSystem sys)))
25-
(builtins.foldl' nixpkgs.lib.recursiveUpdate { })
30+
(builtins.foldl' lib.recursiveUpdate { })
2631
];
2732
in
2833
eachDefaultSystem (
@@ -36,25 +41,28 @@
3641
};
3742
in
3843
{
39-
packages = {
40-
inherit (pkgs)
41-
purs
42-
purs-unstable
43-
spago
44-
spago-unstable
45-
purs-tidy
46-
purs-tidy-unstable
47-
purs-backend-es
48-
purs-backend-es-unstable
49-
purescript-language-server
50-
purescript-language-server-unstable
51-
;
52-
}
53-
// pkgs.purs-bin
54-
// pkgs.spago-bin
55-
// pkgs.purs-tidy-bin
56-
// pkgs.purs-backend-es-bin
57-
// pkgs.purescript-language-server-bin;
44+
# Filter out null values (packages unavailable on this system)
45+
packages = lib.filterAttrs (_: v: v != null) (
46+
{
47+
inherit (pkgs)
48+
purs
49+
purs-unstable
50+
spago
51+
spago-unstable
52+
purs-tidy
53+
purs-tidy-unstable
54+
purs-backend-es
55+
purs-backend-es-unstable
56+
purescript-language-server
57+
purescript-language-server-unstable
58+
;
59+
}
60+
// pkgs.purs-bin
61+
// pkgs.spago-bin
62+
// pkgs.purs-tidy-bin
63+
// pkgs.purs-backend-es-bin
64+
// pkgs.purescript-language-server-bin
65+
);
5866

5967
apps =
6068
let
@@ -64,61 +72,49 @@
6472
meta = bin.meta or { };
6573
};
6674
in
67-
pkgs.lib.mapAttrs (_: mkApp) self.packages.${system};
75+
lib.mapAttrs (_: mkApp) self.packages.${system};
6876

6977
checks =
7078
let
71-
package-checks =
72-
lib.mapAttrs
73-
(
74-
key: bin:
75-
let
76-
name = bin.pname or bin.name;
77-
version = bin.version or "0.0.0";
78-
in
79-
pkgs.runCommand "test-${name}-${version}" { } ''
80-
touch $out
81-
set -e
82-
set -x
83-
84-
# Some package versions are not supported on some systems, ie. the
85-
# "stable" version of Spago is not supported on aarch64.
86-
if [ ${builtins.toString (builtins.hasAttr "unsupported" bin)} ]; then
87-
echo "Skipping ${bin.name} because it is not supported on ${system}"
88-
exit 0
89-
fi
79+
package-checks = lib.mapAttrs (
80+
_: bin:
81+
let
82+
name = bin.pname or bin.name;
83+
version = bin.version or "0.0.0";
84+
in
85+
pkgs.runCommand "test-${name}-${version}" { } ''
86+
touch $out
87+
set -e
88+
set -x
9089
91-
# Different packages at different versions use different 'version'
92-
# flags to print their version
93-
if [ ${builtins.toString (name == "spago" && pkgs.lib.versionOlder version "0.90.0")} ]; then
94-
VERSION="$(${lib.getExe bin} version --global-cache skip)"
95-
# [email protected] incorrectly reports its version
96-
elif [ ${builtins.toString (name == "spago" && version == "0.93.21")} ]; then
97-
VERSION="0.93.21"
98-
else
99-
# spago-next writes --version to stderr, oddly enough, so we need to
100-
# capture both in the VERSION var.
101-
VERSION="$(${lib.getExe bin} --version 2>&1)"
102-
fi
90+
# Different packages at different versions use different 'version'
91+
# flags to print their version
92+
if [ ${builtins.toString (name == "spago" && lib.versionOlder version "0.90.0")} ]; then
93+
VERSION="$(${lib.getExe bin} version --global-cache skip)"
94+
# [email protected] incorrectly reports its version
95+
elif [ ${builtins.toString (name == "spago" && version == "0.93.21")} ]; then
96+
VERSION="0.93.21"
97+
else
98+
# spago-next writes --version to stderr, oddly enough, so we need to
99+
# capture both in the VERSION var.
100+
VERSION="$(${lib.getExe bin} --version 2>&1)"
101+
fi
103102
104-
# purs-tidy includes a 'v' prefix in its output beginning with version 0.9.0
105-
if [ ${builtins.toString (name == "purs-tidy" && !(pkgs.lib.versionOlder version "0.9.0"))} ]; then
106-
EXPECTED_VERSION="v${version}"
107-
# purs-backend-es always includes it
108-
elif [ ${builtins.toString (name == "purs-backend-es")} ]; then
109-
EXPECTED_VERSION="v${version}"
110-
else
111-
EXPECTED_VERSION="${version}"
112-
fi
103+
# purs-tidy includes a 'v' prefix in its output beginning with version 0.9.0
104+
if [ ${builtins.toString (name == "purs-tidy" && !(lib.versionOlder version "0.9.0"))} ]; then
105+
EXPECTED_VERSION="v${version}"
106+
# purs-backend-es always includes it
107+
elif [ ${builtins.toString (name == "purs-backend-es")} ]; then
108+
EXPECTED_VERSION="v${version}"
109+
else
110+
EXPECTED_VERSION="${version}"
111+
fi
113112
114-
echo "$VERSION should match expected output $EXPECTED_VERSION"
115-
test "$VERSION" = "$EXPECTED_VERSION"
116-
''
117-
)
118-
# TODO: Remove once the purescript build of spago is stable
119-
(
120-
pkgs.lib.filterAttrs (k: v: !(k == "spago" && system == "aarch64-darwin")) self.packages.${system}
121-
);
113+
echo "$VERSION should match expected output $EXPECTED_VERSION"
114+
test "$VERSION" = "$EXPECTED_VERSION"
115+
''
116+
) (lib.filterAttrs (k: _: !(k == "spago" && system == "aarch64-darwin")) self.packages.${system});
117+
# TODO: Remove filter once the purescript build of spago is stable on aarch64-darwin
122118

123119
format-checks = {
124120
nix-format =

manifests/build-support/mkDerivation.nix

Lines changed: 0 additions & 126 deletions
This file was deleted.

manifests/build-support/mkDerivationBasic.nix

Lines changed: 0 additions & 39 deletions
This file was deleted.

manifests/build-support/mkLegacySpagoDerivation.nix

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)