-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflake.nix
130 lines (115 loc) · 3.84 KB
/
flake.nix
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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
purescript-overlay = {
url = "github:thomashoneyman/purescript-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, ... }@inputs:
let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
config = { };
overlays = builtins.attrValues self.overlays;
});
in {
overlays = {
purescript = inputs.purescript-overlay.overlays.default;
};
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
nodeDependencies = (pkgs.callPackage ./default.nix {}).nodeDependencies;
in {
# FIXME: on Mac ARM works only with `nix build --option system x86_64-darwin`
default = pkgs.stdenv.mkDerivation {
pname = "noodle";
version = "1.0.0";
src = ./.;
buildInputs = with pkgs; [
cacert
nodejs_20
purs-tidy-bin.purs-tidy-0_10_0
git
dhall
purs-backend-es
purs-bin.purs-0_15_9
#spago-bin.spago-0_21_0
spago-unstable
];
buildPhase = ''
# Create a temporary cache directory for spago
export XDG_CACHE_HOME=$(mktemp -d)
export HOME=$(mktemp -d)
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
export PATH="${nodeDependencies}/bin:$PATH"
spago build --output output.nix
'';
installPhase = ''
mkdir -p $out
cp -r output.nix $out/
cp -r ndf $out/
'';
};
});
apps = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
nodeDependencies = (pkgs.callPackage ./default.nix {}).nodeDependencies;
in {
default = let
runCli = pkgs.writeShellApplication {
name = "run-cli";
runtimeInputs =
with pkgs; [
# cacert
nodejs_20
purs-tidy-bin.purs-tidy-0_10_0
# git
# dhall
purs-backend-es
purs-bin.purs-0_15_9
#spago-bin.spago-0_21_0
spago-unstable
];
text = ''
# spago run --demo
spago build --output output.nix
node ./.spago/run/run.js -t starter
'';
};
in {
type = "app";
program = "${runCli}/bin/run-cli";
};
});
devShells = forAllSystems (system:
# pkgs now has access to the standard PureScript toolchain
# FIXME: on Mac ARM works only with `nix develop --option system x86_64-darwin`
let
pkgs = nixpkgsFor.${system};
nodeDependencies = (pkgs.callPackage ./default.nix {}).nodeDependencies;
in {
default = pkgs.mkShell {
name = "noodle";
inputsFrom = builtins.attrValues self.packages.${system};
shellHook = ''
rm -r ./node_modules
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
export PATH="${nodeDependencies}/bin:$PATH"
'';
buildInputs = with pkgs; [
nodejs_23
purs-bin.purs-0_15_9
spago-unstable
purs-tidy-bin.purs-tidy-0_10_0
purs-backend-es
];
};
});
};
}