Skip to content

Commit 27e0125

Browse files
authored
Merge pull request #221 from jamesdbrock/flake
Flake
2 parents 0c10ff1 + d6d4aaf commit 27e0125

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2050
-8100
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,66 @@ pkgs.mkShell {
5555
}
5656
```
5757

58+
## Nix Flakes
59+
60+
There is a `flake.nix`. To see what the `flake.nix` provides,
61+
62+
```
63+
nix flake show github:justinwoo/easy-purescript-nix --allow-import-from-derivation
64+
```
65+
66+
### Deluxe `nix develop` shell
67+
68+
To get a deluxe PureScript development shell which includes the latest
69+
versions of everything,
70+
71+
```
72+
nix develop github:justinwoo/easy-purescript-nix#deluxe
73+
```
74+
75+
### Custom `nix develop` shell
76+
77+
Create a custom `nix develop` shell with a `flake.nix` like this for example:
78+
79+
```nix
80+
{
81+
inputs = {
82+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
83+
flake-utils.url = "github:numtide/flake-utils";
84+
easy-purescript-nix.url = "github:justinwoo/easy-purescript-nix";
85+
};
86+
87+
outputs = { nixpkgs, flake-utils, easy-purescript-nix, ... }:
88+
flake-utils.lib.eachDefaultSystem (system:
89+
let
90+
pkgs = nixpkgs.legacyPackages.${system};
91+
easy-ps = easy-purescript-nix.packages.${system};
92+
in
93+
{
94+
devShells = {
95+
default = pkgs.mkShell {
96+
name = "purescript-custom-shell";
97+
buildInputs = [
98+
easy-ps.purs-0_15_8
99+
easy-ps.spago
100+
easy-ps.purescript-language-server
101+
easy-ps.purs-tidy
102+
pkgs.nodejs-18_x
103+
pkgs.esbuild
104+
];
105+
shellHook = ''
106+
source <(spago --bash-completion-script `which spago`)
107+
source <(node --completion-bash)
108+
'';
109+
};
110+
};
111+
}
112+
);
113+
}
114+
```
115+
116+
117+
58118
## Why was this made?
59119

60120
See the blog post about this here: <https://github.com/justinwoo/my-blog-posts/blob/master/posts/2018-10-24-using-purescript-easily-with-nix.md>

default.nix

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,7 @@ let
146146
inherit pkgs;
147147
};
148148

149-
pulp-15_0_0 = import ./pulp/15.0.0 { inherit pkgs; };
150-
151-
pulp-16_0_0-0 = import ./pulp/16.0.0-0 { inherit pkgs; };
152-
153-
pulp-16_0_2 = import ./pulp/16.0.2 { inherit pkgs; };
154-
155-
pulp = pulp-16_0_2;
156-
157-
pulp-latest = import ./pulp/latest { inherit pkgs; };
149+
pulp = import ./pulp { inherit pkgs; };
158150

159151
purescript-language-server = import ./purescript-language-server {
160152
inherit pkgs;
@@ -164,9 +156,8 @@ let
164156
inherit pkgs;
165157
};
166158

167-
purs-backend-es-1_1_0 = import ./purs-backend-es/1.1.0 { inherit pkgs; };
159+
purs-backend-es = import ./purs-backend-es { inherit pkgs; };
168160

169-
purs-backend-es = purs-backend-es-1_1_0;
170161
};
171162

172163
buildInputs = builtins.attrValues inputs;

flake.lock

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{ inputs.flake-utils.url = "github:numtide/flake-utils";
2+
3+
outputs = { flake-utils, ... }:
4+
flake-utils.lib.eachDefaultSystem
5+
(system:
6+
let
7+
# TODO pinned.nix could be a flake input.nixpkgs instead.
8+
pkgs = import ./pinned.nix { inherit system; };
9+
packages = (import ./default.nix { inherit pkgs; }).inputs;
10+
in
11+
{
12+
inherit packages;
13+
devShells = {
14+
deluxe = pkgs.mkShell {
15+
name = "easy-purescript-nix-shell-deluxe";
16+
buildInputs = with packages; [
17+
purs
18+
pulp
19+
psc-package
20+
purp
21+
dhall-simple
22+
spago
23+
spago2nix
24+
pscid
25+
purescript-language-server
26+
purs-tidy
27+
purty
28+
zephyr
29+
purs-backend-es
30+
] ++ [
31+
pkgs.nodejs-18_x
32+
pkgs.nodePackages.bower
33+
pkgs.esbuild
34+
];
35+
shellHook = ''
36+
source <(spago --bash-completion-script `which spago`)
37+
source <(node --completion-bash)
38+
echo -e " \033[1measy-purescript-nix deluxe development environment\033[0m"
39+
echo -e " \033[1mSee https://discourse.purescript.org/t/recommended-tooling-for-purescript-in-2022\033[0m"
40+
'';
41+
};
42+
};
43+
}
44+
);
45+
}

pinned.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import (
22
builtins.fetchTarball {
3-
url = "https://github.com/nixos/nixpkgs/archive/212c4e8f7327324debecb32dc773bbadda08c3d8.tar.gz";
4-
sha256 = "0kx4sh20s37v7w0ygxwq080iscl3a3pzjlrvvw17621si1lprcwp";
3+
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz";
4+
sha256 = "10wn0l08j9lgqcw8177nh2ljrnxdrpri7bp0g7nvrsn9rkawvlbf";
55
}
66
)

pulp/latest/composition.nix renamed to psa/composition.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
{pkgs ? import <nixpkgs> {
44
inherit system;
5-
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-14_x"}:
5+
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs_18"}:
66

77
let
88
nodeEnv = import ./node-env.nix {

psa/default.nix

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
1-
{ pkgs ? import <nixpkgs> { inherit system; }
2-
, system ? builtins.currentSystem
3-
, nodejs ? pkgs."nodejs-14_x"
4-
}:
1+
# How to generate the files in this directory:
2+
#
3+
# nix run nixpkgs#node2nix -- -i <(echo '["psa"]') -c composition.nix -18
4+
#
5+
{ pkgs ? import <nixpkgs> { } }:
56

6-
let
7-
nodeEnv = import ./node-env.nix {
8-
inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
9-
inherit pkgs nodejs;
10-
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
11-
};
12-
13-
nodePackage = import ./node-packages.nix {
14-
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
15-
inherit nodeEnv;
16-
};
17-
18-
source = nodePackage.sources."purescript-psa-0.8.2".src;
19-
in
20-
nodeEnv.buildNodePackage (nodePackage.args // { src = source; })
7+
(import ./composition.nix { inherit pkgs; }).psa

0 commit comments

Comments
 (0)