Skip to content

Commit

Permalink
Add deluxe nix develop shell to flake.nix.
Browse files Browse the repository at this point in the history
Update inputs, including Node.js 14_x → 18_x and Nixpkgs 23.05.

New method for generating `node2nix`, based on Justin’s
`composition.nix` method.

Code reorganization.
  • Loading branch information
jamesdbrock committed Jun 4, 2023
1 parent a90bd94 commit d6d4aaf
Show file tree
Hide file tree
Showing 48 changed files with 2,027 additions and 8,113 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,66 @@ pkgs.mkShell {
}
```

## Nix Flakes

There is a `flake.nix`. To see what the `flake.nix` provides,

```
nix flake show github:justinwoo/easy-purescript-nix --allow-import-from-derivation
```

### Deluxe `nix develop` shell

To get a deluxe PureScript development shell which includes the latest
versions of everything,

```
nix develop github:justinwoo/easy-purescript-nix#deluxe
```

### Custom `nix develop` shell

Create a custom `nix develop` shell with a `flake.nix` like this for example:

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
easy-purescript-nix.url = "github:justinwoo/easy-purescript-nix";
};
outputs = { nixpkgs, flake-utils, easy-purescript-nix, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
easy-ps = easy-purescript-nix.packages.${system};
in
{
devShells = {
default = pkgs.mkShell {
name = "purescript-custom-shell";
buildInputs = [
easy-ps.purs-0_15_8
easy-ps.spago
easy-ps.purescript-language-server
easy-ps.purs-tidy
pkgs.nodejs-18_x
pkgs.esbuild
];
shellHook = ''
source <(spago --bash-completion-script `which spago`)
source <(node --completion-bash)
'';
};
};
}
);
}
```



## Why was this made?

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>
Expand Down
13 changes: 2 additions & 11 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,7 @@ let
inherit pkgs;
};

pulp-15_0_0 = import ./pulp/15.0.0 { inherit pkgs; };

pulp-16_0_0-0 = import ./pulp/16.0.0-0 { inherit pkgs; };

pulp-16_0_2 = import ./pulp/16.0.2 { inherit pkgs; };

pulp = pulp-16_0_2;

pulp-latest = import ./pulp/latest { inherit pkgs; };
pulp = import ./pulp { inherit pkgs; };

purescript-language-server = import ./purescript-language-server {
inherit pkgs;
Expand All @@ -164,9 +156,8 @@ let
inherit pkgs;
};

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

purs-backend-es = purs-backend-es-1_1_0;
};

buildInputs = builtins.attrValues inputs;
Expand Down
34 changes: 26 additions & 8 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 40 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
{ inputs.utils.url = "github:numtide/flake-utils";
{ inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { utils, ... }:
utils.lib.eachDefaultSystem
outputs = { flake-utils, ... }:
flake-utils.lib.eachDefaultSystem
(system:
{ packages =
(import ./. { pkgs = import ./pinned.nix { inherit system; }; }).inputs;
let
# TODO pinned.nix could be a flake input.nixpkgs instead.
pkgs = import ./pinned.nix { inherit system; };
packages = (import ./default.nix { inherit pkgs; }).inputs;
in
{
inherit packages;
devShells = {
deluxe = pkgs.mkShell {
name = "easy-purescript-nix-shell-deluxe";
buildInputs = with packages; [
purs
pulp
psc-package
purp
dhall-simple
spago
spago2nix
pscid
purescript-language-server
purs-tidy
purty
zephyr
purs-backend-es
] ++ [
pkgs.nodejs-18_x
pkgs.nodePackages.bower
pkgs.esbuild
];
shellHook = ''
source <(spago --bash-completion-script `which spago`)
source <(node --completion-bash)
echo -e " \033[1measy-purescript-nix deluxe development environment\033[0m"
echo -e " \033[1mSee https://discourse.purescript.org/t/recommended-tooling-for-purescript-in-2022\033[0m"
'';
};
};
}
);
}
4 changes: 2 additions & 2 deletions pinned.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import (
builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/212c4e8f7327324debecb32dc773bbadda08c3d8.tar.gz";
sha256 = "0kx4sh20s37v7w0ygxwq080iscl3a3pzjlrvvw17621si1lprcwp";
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz";
sha256 = "10wn0l08j9lgqcw8177nh2ljrnxdrpri7bp0g7nvrsn9rkawvlbf";
}
)
2 changes: 1 addition & 1 deletion pulp/latest/composition.nix → psa/composition.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

let
nodeEnv = import ./node-env.nix {
Expand Down
25 changes: 6 additions & 19 deletions psa/default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
{ pkgs ? import <nixpkgs> { inherit system; }
, system ? builtins.currentSystem
, nodejs ? pkgs."nodejs-14_x"
}:
# How to generate the files in this directory:
#
# nix run nixpkgs#node2nix -- -i <(echo '["psa"]') -c composition.nix -18
#
{ pkgs ? import <nixpkgs> { } }:

let
nodeEnv = import ./node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};

nodePackage = import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
};

source = nodePackage.sources."purescript-psa-0.8.2".src;
in
nodeEnv.buildNodePackage (nodePackage.args // { src = source; })
(import ./composition.nix { inherit pkgs; }).psa
Loading

0 comments on commit d6d4aaf

Please sign in to comment.