Commit 9d2f747c authored by Justin Woo's avatar Justin Woo

use psc-package-nix for project nix building

* uses scripts in ./nix/ to generate packages.json and purs-packages.nix
* build-purs now builds with dependencies in nix store
* PURS_IDE_SOURCES set in nix shell, so those are directly usable from latest versions of purescript-langauge-server and psc-ide-emacs
* regular psc-package usage is still supported
parent 680db391
{ pkgs ? import ./pinned.nix { } }:
import
(
pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "14e7d85431e9f9838d7107d18cb79c7fa534f54e";
sha256 = "0lmkppidmhnayv0919990ifdd61f9d23dzjzr8amz7hjgc74yxs0";
}
) {
inherit pkgs;
}
#!/usr/bin/env nix-shell
#!nix-shell ./generate-packages-json.nix --run 'exit'
{ pkgs ? import ./pinned.nix { } }:
let
easy-dhall = import (
pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-dhall-nix";
rev = "288ee825c326f352a5db194a024bd3e1f2f735b2";
sha256 = "12v4ql1nm1famz8r80k1xkkdgj7285vy2vn16iili0qwvz3i98ah";
}
) {
inherit pkgs;
};
in
pkgs.mkShell {
buildInputs = [ easy-dhall.dhall-simple easy-dhall.dhall-json-simple ];
shellHook = ''
dhall-to-json --file packages.dhall --output ./.psc-package/local/.set/packages.json
echo "generated packages.json"
'';
}
#!/usr/bin/env nix-shell
#!nix-shell ./generate-purs-packages.nix --run 'exit'
{ pkgs ? import ./pinned.nix { } }:
let
psc-package-nix = import ./psc-package-nix.nix { inherit pkgs; };
purs-project = import ./purs-project.nix { inherit pkgs; };
generatePursPackages = import "${psc-package-nix}/nix/generate-purs-packages.nix" {
inherit pkgs;
inherit (purs-project) packagesJson inputNames;
};
in
pkgs.mkShell {
buildInputs = [ generatePursPackages ];
shellHook = ''
generate-purs-packages > ./nix/purs-packages.nix
echo "generated purs-packages.nix"
'';
}
{ pkgs ? import ./pinned.nix { } }:
pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "psc-package-nix";
rev = "0f1f001e2ea17ad461871a1873050f6aef5f1284";
sha256 = "0gbwcvw8rvxhlg9p6avd0812y263jzim1sra5frbdi0s6q0ngsgi";
}
This diff is collapsed.
#!/usr/bin/env nix-shell
{ pkgs ? import ./pinned.nix { } }:
let
packagesJson = ../.psc-package/local/.set/packages.json;
inputNames = (pkgs.lib.importJSON ../psc-package.json).depends;
pursPackages = import ./purs-packages.nix { inherit pkgs; };
getUnquotedSourceGlob = x: ''${x.src}/src/**/*.purs'';
unquotedSourceGlobs = map getUnquotedSourceGlob (builtins.attrValues pursPackages);
quote = x: ''"${x}"'';
sourceGlobs = map quote unquotedSourceGlobs;
in
{
inherit packagesJson inputNames sourceGlobs unquotedSourceGlobs;
}
This diff is collapsed.
{ pkgs ? import ./pinned.nix {} }: { pkgs ? import ./nix/pinned.nix {} }:
let let
easy-ps = import ( easy-ps = import ./nix/easy-ps.nix { inherit pkgs; };
pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "14e7d85431e9f9838d7107d18cb79c7fa534f54e";
sha256 = "0lmkppidmhnayv0919990ifdd61f9d23dzjzr8amz7hjgc74yxs0";
}
) {
inherit pkgs;
};
soba = import (
pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "soba";
rev = "2add8804bce7e7c1ab5eb1c3d8f6783e938a04d3";
sha256 = "1qagyklcllr2sxdb315prw33af6g37762zgk2ahh3ifxpns6ifxx";
}
) {
inherit pkgs;
};
purs-packages = import ./purs-packages.nix { inherit pkgs; }; purs-packages = import ./purs-packages.nix { inherit pkgs; };
cpPackage = pp: purs-project = import ./nix/purs-project.nix { inherit pkgs; };
let
target = ".psc-package/local/${pp.name}/${pp.version}";
in
''
mkdir -p ${target}
cp --no-preserve=mode,ownership,timestamp -r ${pp.fetched.outPath}/* ${target}
'';
install-purs-packages = pkgs.writeShellScriptBin "install-purs-packages" ''
#!/usr/bin/env bash
${builtins.toString (builtins.map cpPackage (builtins.attrValues purs-packages))}
echo done installing deps.
'';
build-purs = pkgs.writeShellScriptBin "build-purs" '' build-purs = pkgs.writeShellScriptBin "build-purs" ''
#!/usr/bin/env bash #!/usr/bin/env bash
purs compile "src/**/*.purs" ".psc-package/*/*/*/src/**/*.purs" purs compile ${toString purs-project.sourceGlobs} "src/**/*.purs" "test/**/*.purs"
'';
storePath = x: ''"${x.fetched.outPath}/src/**/*.purs"'';
build-purs-from-store = pkgs.writeShellScriptBin "build-purs-from-store" ''
#!/usr/bin/env bash
purs compile "src/**/*.purs" \
${builtins.toString (builtins.map storePath (builtins.attrValues purs-packages))}
''; '';
build = pkgs.writeShellScriptBin "build" '' build = pkgs.writeShellScriptBin "build" ''
...@@ -72,28 +31,28 @@ pkgs.mkShell { ...@@ -72,28 +31,28 @@ pkgs.mkShell {
buildInputs = [ buildInputs = [
easy-ps.purs easy-ps.purs
easy-ps.psc-package easy-ps.psc-package
soba
install-purs-packages
build-purs build-purs
build-purs-from-store
build build
repl repl
pkgs.yarn pkgs.yarn
]; ];
shellHook = ''
export PURS_IDE_SOURCES='${toString purs-project.unquotedSourceGlobs}'
'';
} }
## how to build the project with nix dependencies: ## how to build the project with nix dependencies:
# #
# 1. start a nix shell (e.g. `nix-shell -j 20`, this uses 20 jobs to fetch deps) # 1. start a nix shell (e.g. `nix-shell -j 20`, this uses 20 jobs to fetch deps)
# 2. run `yarn` to install npm deps # 2. run `yarn` to install npm deps
# 3. run `install-purs-packages` if you want dependencies locally, available for psc-package and for inspection # 3a. run `build-purs` to build using nix store dependencies, and make sure to update your purescript ide tooling as necesssary
# 4. run `build-purs` to build from local sources. otherwise use `build-purs-from-store`. # 3b. or simply use `psc-package` as you might want to anyway
# #
# note that the purescript compiler uses filepaths and timestamps, so using the above two commands # note that the purescript compiler uses filepaths and timestamps, so using the above two commands
# interchangeably will lead to constant rebuilding of the entire project. # interchangeably will lead to constant rebuilding of the entire project.
# #
## how to update purs-packages.nix ## how to update purs-packages.nix
# #
# 1. run `soba insdhall` to generate packages.json # 1. run `nix/generate-packages-json.nix` to generate packages.json
# 2. run `soba nix` to generate a nix derivation from packages.json # 2. run `nix/generate-purs-packages.nix` to generate purs-packages.nix
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment