difficult-purescript-nix
is a flakes-friendly (and more … difficult) alternative to easy-purescript-nix.
difficult-purescript-nix
is intended to be consumed as a flake input. You can then apply inputs.difficult-purescript-nix.overlays.default
, which will add the attribute set purescriptPackages
to your package set. This contains the following packages:
purs
spago
purs-tidy
purescript-language-server
purescript-psa
/psa
pulp
purty
pscid
Most of these also contain specific versions. For non-versioned packages, e.g. purescriptPackages.pscid
, the package is simply an alias to nodePackages_latest
. For versioned dependencies (excluding purs
and spago
) pre-built packages are fetched from NPM using an indirect invocation of buildNpmPackage
(each versioned dependency corresponds to a directory in pkgs/<pkgs>/<version>
that contains a dummy package.json
and package-lock.json
, each containing only the target package in its dependencies
field).
Here is a (contrived) example of using difficult-purescript-nix
in your own flake:
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
difficult-purescript-nix = "github:ngua/difficult-purescript-nix";
# You can also easily do the opposite to make `difficult-purescript-nix`
# use your own version of `nixpkgs`
nixpkgs.follows = "difficult-purescript-nix/nixpkgs";
};
outputs = { self, nixpkgs, flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
perSystem = { config, pkgs, lib, system, ... }:
{
# This is just an example to demonstrate applying
# the overlay exposed by the flake
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.difficult-purescript-nix.overlays.default
];
};
legacyPackages = {
inherit (pkgs.purescriptPackages) purs-0_15_4;
};
};
};
}
You can also run, try, or install packages from difficult-purescript-nix
conveniently using the new nix
CLI. All of the Purescript packages available from overlays.default
are also exposed by the flake via the legacyPackages
(under the namespace purescriptPackages
) and packages
outputs. For example:
nix run github:ngua/difficult-purescript-nix#purs-0_14_2 -- --version
nix profile install github:ngua/difficult-purescript-nix#purs-tidy-0_7_2
nix flake show github:ngua/difficult-purescript-nix
As mentioned above, this project is a flake-native adaptation of easy-purescript-nix
. I would recommend using difficult-purescript-nix
over the latter in the following situations:
- You want or require a flakes-first workflow
- You explicitly want Purescript packages exposed as an overlay
In contract, I would recommend easy-purescript-nix
instead, if:
- You can’t or don’t want to use flakes
- You want more options for Purescript packages (
easy-purescript-nix
exposes a few more packages than this repository)
As with easy-purescript-nix
and indeed nixpkgs
, difficult-purescript-nix
fetches pre-built binaries for spago
and purs
from their GitHub releases. This has the definite advantage of never requiring a build from source, but also means that only x86_64-linux
and x86_64-darwin
are really supported. In the future, I’d like to try to see if it’s possible to build both projects from source, at least on aarch64
platforms, and expand the number of systems that difficult-purescript-nix
supports (this will also be affected by Spago’s ongoing Purescript rewrite).