This commit is contained in:
justinwoo 2019-06-14 14:45:49 +02:00
commit 2cb67b064b
14 changed files with 8772 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
/.spago
/.spago2nix

45
README.md Normal file
View File

@ -0,0 +1,45 @@
# Spago2Nix
### Does not yet work with a released version of Spago
Generate a derivation of Spago dependencies, and use them to install them into the directory structure used by Spago.
To skip Spago altogether, you can also use the following to build:
```
purs compile '.spago/*/*/src/**/*.purs' 'src/**/*.purs'
```
## Installation
For now, simply clone this repo and run `npm link`. Requires a Node runtime and nix-prefetch-git.
Remember to set npm prefix to something like `~/.npm`.
## Usage
First, generate the spago-packages.nix:
```bash
$ spago2nix generate
getting packages..
got 65 packages from Spago list-packages.
# ...
wrote spago-packages.nix
```
Then install these, optionally with more jobs provided to Nix:
```bash
$ spago2nix install -j 100
installing...
# ...
done
```
Then build however you'd like.
```
$ spago build --global-cache=skip
$ purs compile '.spago/*/*/src/**/*.purs' 'src/**/*.purs'
```

2
bin/index.js Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./output.js');

7451
bin/output.js Normal file

File diff suppressed because it is too large Load Diff

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "spago2nix",
"version": "0.1.0",
"description": "",
"bin": {
"spago2nix": "bin/index.js"
},
"directories": {
"test": "test"
},
"scripts": {
"mkbin": "spago bundle-app -t bin/output.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Justin Woo",
"license": "MIT"
}

4
packages.dhall Normal file
View File

@ -0,0 +1,4 @@
let upstream =
https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.0-20190614/src/packages.dhall sha256:5cbf2418298e7de762401c5719c6eb18eda4c67ba512b3f076b50a793a7fc482
in upstream

812
spago-packages.nix Normal file
View File

@ -0,0 +1,812 @@
# This file was generated by Spago2Nix
{ pkgs ? import <nixpkgs> {} }:
let
inputs = {
"aff" = pkgs.stdenv.mkDerivation {
name = "aff";
version = "v5.1.1";
src = pkgs.fetchgit {
url = "https://github.com/slamdata/purescript-aff.git";
rev = "390857f9143e1a52f7403d05b14c9ca79d356737";
sha256 = "19v5psd6jz13gr5yqyx8286b5bpfq1dax51w906y0mqgnfz92yzr";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"arraybuffer-types" = pkgs.stdenv.mkDerivation {
name = "arraybuffer-types";
version = "v2.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-contrib/purescript-arraybuffer-types.git";
rev = "505aa3de50a1400e5f2fce4a8e7b1a39abaa8fd9";
sha256 = "059a8n49yhl46l1b1j2qj4ichzq6dzj29ajkfvw88npzj5w2rshy";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"arrays" = pkgs.stdenv.mkDerivation {
name = "arrays";
version = "v5.3.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-arrays.git";
rev = "1bca4c0b8904e65d356ed6d8db8d6f7e071132d3";
sha256 = "0r991qcx69xj07iagjaxkm0ab9qi2pw8cs3qwyybhis7asd6bnz6";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"bifunctors" = pkgs.stdenv.mkDerivation {
name = "bifunctors";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-bifunctors.git";
rev = "1062425892b4a1c734ec653dded22546e3063b27";
sha256 = "1bdra5fbkraglqrrm484vw8h0wwk48kzkn586v4y7fg106q1q386";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"console" = pkgs.stdenv.mkDerivation {
name = "console";
version = "v4.2.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-console.git";
rev = "add2bdb8a4af2213d993b728805f1f2a5e76deb8";
sha256 = "1b2nykdq1dzaqyra5pi8cvvz4dsbbkg57a2c88yi931ynm19nnw6";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"const" = pkgs.stdenv.mkDerivation {
name = "const";
version = "v4.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-const.git";
rev = "bc5db27b0ed3947fa5e2074ccbab01236eec3fa4";
sha256 = "0qbd2aisax52yw6sybdhs7na943cbsd6mylhhgsamrf7hzh6v51p";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"contravariant" = pkgs.stdenv.mkDerivation {
name = "contravariant";
version = "v4.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-contravariant.git";
rev = "cb69db0253c2e2ed3fef784dad58f3418a8ee834";
sha256 = "0dd17lwlybpz4i54cxnqdgy38rjlbw9p7bw1r43is6z3kdc8983a";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"control" = pkgs.stdenv.mkDerivation {
name = "control";
version = "v4.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-control.git";
rev = "8af53eea4ecc7b185776a0f144bcd7106ed08eb1";
sha256 = "10703zvsnjm5fc74k6wzjsvpsfyc3jci3jxhm7rxf7ymya9z1z53";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"datetime" = pkgs.stdenv.mkDerivation {
name = "datetime";
version = "v4.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-datetime.git";
rev = "9e76abe96f45a68eb0bb23d0afd56031a8070bee";
sha256 = "06ghfvbvd5sd0q014qi8j8glk2g2j9f8z8cwq2318kllp92gz07q";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"distributive" = pkgs.stdenv.mkDerivation {
name = "distributive";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-distributive.git";
rev = "3a43c0690883816e9ebeac510698423cfff5c174";
sha256 = "0zbn0yq1vv7fbbf1lncg80irz0vg7wnw9b9wrzxhdzpbkw4jinsl";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"effect" = pkgs.stdenv.mkDerivation {
name = "effect";
version = "v2.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-effect.git";
rev = "6caa8e1e162a21eed025613c2c19194b996ef779";
sha256 = "1vqw5wrdxzh1ww6z7271xr4kg4mx0r3k3mwg18dmgmzj11wbn2wh";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"either" = pkgs.stdenv.mkDerivation {
name = "either";
version = "v4.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-either.git";
rev = "8b4b38a729f8e88750b03e5c7baf2b3863ce4742";
sha256 = "12j7vvjly0bgxidxmb2pflx0zy7x425dnvxk2y1pm66n0hbsq7ns";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"enums" = pkgs.stdenv.mkDerivation {
name = "enums";
version = "v4.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-enums.git";
rev = "19800105b556798ea5650f8a01bfe5ea17cfc6eb";
sha256 = "0qq0pgmq497nfml0y8xb2qdpga5xqp9sqq4ilv1rpyhg1v7nzb6v";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"exceptions" = pkgs.stdenv.mkDerivation {
name = "exceptions";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-exceptions.git";
rev = "9012eb08749e9ccd5da45bdece5d576e5fc0b0db";
sha256 = "17s0rg9k4phivhx9j3l2vqqfdhk61gpj1xfqy8w6zj3rnxj0b2cv";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"foldable-traversable" = pkgs.stdenv.mkDerivation {
name = "foldable-traversable";
version = "v4.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-foldable-traversable.git";
rev = "29d5b873cc86f17e0082d777629819a96bdbc7a1";
sha256 = "03x89xcmphckzjlp4chc7swrpw347ll5bvr2yp7x9v2jqw2jlyi1";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"foreign" = pkgs.stdenv.mkDerivation {
name = "foreign";
version = "v5.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-foreign.git";
rev = "3b8f3ae608db339ed5cff35d2017a07efb905b4d";
sha256 = "15mz2s4f8crkd721z4df2aag4s0wil6fs07cpcmi7dpnkn7a4nab";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"foreign-object" = pkgs.stdenv.mkDerivation {
name = "foreign-object";
version = "v2.0.3";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-foreign-object.git";
rev = "8a7dc21c48e3e6d31e253b0e58dd95a3bbd7f6e7";
sha256 = "07wiql59zfj901nk9526b6rykn9m24jjcs8v5dgxbr1c3hiab9n3";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"functions" = pkgs.stdenv.mkDerivation {
name = "functions";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-functions.git";
rev = "c63451ae74f6fba7a4eede5f87208a73c537af77";
sha256 = "0675k5kxxwdvsjs6a3is8pwm3hmv0vbcza1b8ls10gymmfz3k3hj";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"functors" = pkgs.stdenv.mkDerivation {
name = "functors";
version = "v3.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-functors.git";
rev = "96bcf8a970a40115a76a20d19e50aa3b524adcf3";
sha256 = "1cnn3zhk6qcyiwbbpvrdqgsbch4qihx2y9d6sv45bvd8kzrbd306";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"gen" = pkgs.stdenv.mkDerivation {
name = "gen";
version = "v2.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-gen.git";
rev = "36f36f03f082b57e402c27f1513f8935caa54101";
sha256 = "0pk68cn1s89hql30ydks9gh34gbxg391smi2albx3qvxnfkrpxca";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"generics-rep" = pkgs.stdenv.mkDerivation {
name = "generics-rep";
version = "v6.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-generics-rep.git";
rev = "aae27ba1de21dda342dcdfc8b3cc5b951bd5b3ec";
sha256 = "15vchzbcvf6byks90q14lvcwb8hnxqzm2mrlxi7v1f7has4s74kn";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"globals" = pkgs.stdenv.mkDerivation {
name = "globals";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-globals.git";
rev = "3c6251da362312d439a19c0939ae98653a7d4d65";
sha256 = "150mc0kv0cb5fkx0szicwczjr54bglmlyaynj2grf1r4gnjg967s";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"identity" = pkgs.stdenv.mkDerivation {
name = "identity";
version = "v4.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-identity.git";
rev = "1b7938abdc8cb28c0ac5f80f63405d53e3173a8e";
sha256 = "1scdgbfkphfmapw7p9rnsiynpmqzyvnal2glzj450q51f8g1dhld";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"integers" = pkgs.stdenv.mkDerivation {
name = "integers";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-integers.git";
rev = "3850da9cd96b37c71685b6bc3bf0cb489baefc93";
sha256 = "17d4bfpnrmbxlc7hhhrvnli70ydaqyr26zgvc9q52a76zgdcb4cf";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"invariant" = pkgs.stdenv.mkDerivation {
name = "invariant";
version = "v4.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-invariant.git";
rev = "b704c5bda262719ca5cc88a3f8554edff8f03256";
sha256 = "1fimpbh3yb7clvqxcdf4yf9im64z0v2s9pbspfacgq5b4vshjas9";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"js-date" = pkgs.stdenv.mkDerivation {
name = "js-date";
version = "v6.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-contrib/purescript-js-date.git";
rev = "f332c15f14322434ddd1945ca2db8040294447bf";
sha256 = "19qyzbr4a1ca8znbd8gcbz0a801f5p1v238ky3408gdx4ba32zjd";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"kishimen" = pkgs.stdenv.mkDerivation {
name = "kishimen";
version = "v1.0.1";
src = pkgs.fetchgit {
url = "https://github.com/justinwoo/purescript-kishimen.git";
rev = "8a9b11f9bcdaf4ff63c2e572def3d0b2a4e2c870";
sha256 = "153d0mlf2x7xvbql5w0s4jl56s51aq0bg8ldxd3fm2kj7m0bay22";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"lazy" = pkgs.stdenv.mkDerivation {
name = "lazy";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-lazy.git";
rev = "5bbd04f507a704f39aa756b5e12ed6665205fe2e";
sha256 = "156q89l4nvvn14imbhp6xvvm82q7kqh1pyndmldmnkhiqyr84vqv";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"lists" = pkgs.stdenv.mkDerivation {
name = "lists";
version = "v5.4.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-lists.git";
rev = "62900a56f6864638c952575dfd211a1cc55be7da";
sha256 = "0l0jiqhcjzkg4nv2a6h2vdf4izr9mf7cxc86cq1hf3j4dh6spym1";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"math" = pkgs.stdenv.mkDerivation {
name = "math";
version = "v2.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-math.git";
rev = "8be36d24f9d2d8795adf04791446bbc458297b9b";
sha256 = "1msmy9w7y6fij62sdc55w68gpwkhm6lhgc8qjisjk4sxx1wdg1rr";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"maybe" = pkgs.stdenv.mkDerivation {
name = "maybe";
version = "v4.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-maybe.git";
rev = "81f0397636bcbca28642f62421aebfd9e1afa7fb";
sha256 = "073wa0d51daxdwacfcxg5pf6ch63n4ii55xm1ih87bxrg8mp52mx";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"motsunabe" = pkgs.stdenv.mkDerivation {
name = "motsunabe";
version = "v2.0.0";
src = pkgs.fetchgit {
url = "https://github.com/justinwoo/purescript-motsunabe.git";
rev = "d016e6319fef40119abba726e31d066e7c211875";
sha256 = "03r81xs0gw5nchm93ap2lpirkng8bzgsb8xc5jxlii4sw8wn8ndh";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"newtype" = pkgs.stdenv.mkDerivation {
name = "newtype";
version = "v3.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-newtype.git";
rev = "7d85fa6a040208c010b05f7c23af6a943ba08763";
sha256 = "0qvk9p41miy806b05b4ikbr3if0fcyc35gfrwd2mflcxxp46011c";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"node-buffer" = pkgs.stdenv.mkDerivation {
name = "node-buffer";
version = "v5.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-node-buffer.git";
rev = "d279daa1b4bf9fe85d5c3aeb96512df4f12e0bc0";
sha256 = "0ih2y29srdxgn526fw2v1y95hpivjil44vkl93w6nrqsymki36y0";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"node-child-process" = pkgs.stdenv.mkDerivation {
name = "node-child-process";
version = "v6.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-node-child-process.git";
rev = "887b252ef85975f4cf31dfd9079f6d98d905fc1b";
sha256 = "1r5gx9gr5xkrbvdnv6704zmpb987dgpblmhq5yhwq2xir6w35qnn";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"node-fs" = pkgs.stdenv.mkDerivation {
name = "node-fs";
version = "v5.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-node-fs.git";
rev = "a8380b56acab3202587259ea259ea195cb440774";
sha256 = "1hkg8j4zkyq71g2bn3vpfqb8x49rdd9k0ayv3zf6l8k80gp3qigx";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"node-fs-aff" = pkgs.stdenv.mkDerivation {
name = "node-fs-aff";
version = "v6.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-node-fs-aff.git";
rev = "d02c0a209824c3fce8254dddd94d85990e9ad1b6";
sha256 = "0vjc9zag7y20yxhhv45hrwv9fbpmp0szv40vaxl5x8mnd5wv28x7";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"node-path" = pkgs.stdenv.mkDerivation {
name = "node-path";
version = "v3.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-node-path.git";
rev = "e3a704d5fc7d25fa93c6cd0eb92dbce9e5ebd69a";
sha256 = "0j1ni52m62dpcrfakl1ik131i31bkg91yv0p1c40sdw0f59fzf6x";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"node-streams" = pkgs.stdenv.mkDerivation {
name = "node-streams";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-node-streams.git";
rev = "bebf20b0e50d9a564dd98e13baaee67692b331d6";
sha256 = "098wdq0rj4nkc470fwmiaars7vxac9n1dh4d82jrji3m77n473da";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"nonempty" = pkgs.stdenv.mkDerivation {
name = "nonempty";
version = "v5.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-nonempty.git";
rev = "36ca3b2fa6d98b1c9d2ee05643341e496fbeab57";
sha256 = "1vz174sg32cqrp52nwb2vz9frrzmdwzzlgl4vc2cm5wlf2anirxj";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"now" = pkgs.stdenv.mkDerivation {
name = "now";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-contrib/purescript-now.git";
rev = "090feddf7c7dec2a812eca090cd211e87ccad606";
sha256 = "18h5pif2dy4r7w1xg2zw4mvdqlar9xqp3rawkiavmsc946ncf3zs";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"nullable" = pkgs.stdenv.mkDerivation {
name = "nullable";
version = "v4.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript-contrib/purescript-nullable.git";
rev = "8d413f02224b8281bfa8037e45fbbf9fe2e254fd";
sha256 = "14qaxxga8gqlr4pijyvqycdyhjr6qpz3h4aarficw5j75b7x8nyv";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"ordered-collections" = pkgs.stdenv.mkDerivation {
name = "ordered-collections";
version = "v1.6.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-ordered-collections.git";
rev = "54af8b281bf01acfc14e147debec76974901e93c";
sha256 = "0r48p94d3cyzni2z7ikzcap472k23dx8zq37c1prmjb01v03mfvc";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"orders" = pkgs.stdenv.mkDerivation {
name = "orders";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-orders.git";
rev = "80e22c22c72c846e09ef9dfcdb40b3eee39118d6";
sha256 = "13p1sm4dxkmxhld9x5qqg62iiajjb3qpzs66c1r24y5fs4zsfry4";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"parallel" = pkgs.stdenv.mkDerivation {
name = "parallel";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-parallel.git";
rev = "4d6c8b05041a36c300dfca2ba8f1f3443ca26bc6";
sha256 = "1d5bnagabw2k8yxywkygwrpblb2ggqh2fhpqfrx2sj1y53x332hg";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"partial" = pkgs.stdenv.mkDerivation {
name = "partial";
version = "v2.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-partial.git";
rev = "76b63a324f7eafbb859256771b5bb7404082af96";
sha256 = "11qr80989g7xmvw1brnrclsbg2wdkbr5k3cqpngfip3nnirrypcn";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"posix-types" = pkgs.stdenv.mkDerivation {
name = "posix-types";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-node/purescript-posix-types.git";
rev = "1d4cd274436cc1e470dc6bf7735bcfdf0092d884";
sha256 = "0xvxjvxr7n4dv53p8w5qfmgx37cga5bp2rjhkbfvj89rb74vm3i1";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"prelude" = pkgs.stdenv.mkDerivation {
name = "prelude";
version = "v4.1.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-prelude.git";
rev = "a96663b34364fdd0885a200955e35b99f4e58c43";
sha256 = "1frvjrv0mr508r6683l1mp5rzm1y2dz76fz40zf4k2c64sy6y1xm";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"proxy" = pkgs.stdenv.mkDerivation {
name = "proxy";
version = "v3.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-proxy.git";
rev = "4a529b1f874fa2f32fc4c575cafaf46e0ab69fb6";
sha256 = "0rqf25b1n9p5sgx7gdsxwrfv9rb3sqxgqmqpp5kdm30lfk7snz24";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"record" = pkgs.stdenv.mkDerivation {
name = "record";
version = "v2.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-record.git";
rev = "42a15ba34d860f4d8f899836956bf09659a0256b";
sha256 = "1l7ixb0gc2man36181g3hdf46sjp7xh0kv8bgrvalxfisjmd12v0";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"refs" = pkgs.stdenv.mkDerivation {
name = "refs";
version = "v4.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-refs.git";
rev = "e8b175477661e433175e76548168290c40e0ce4b";
sha256 = "08161iy1xbafzblv033v84156azpcqkiw9v9d6gliphrq5fm17gm";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"simple-json" = pkgs.stdenv.mkDerivation {
name = "simple-json";
version = "v7.0.0";
src = pkgs.fetchgit {
url = "https://github.com/justinwoo/purescript-simple-json.git";
rev = "d6c4163f6ad65be97b148ebf86c900cb821da5a8";
sha256 = "1x2f4zq1m9r3vg9hdpjld98jd56w7fss8fzvlrmnrw6xzd1gi456";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"simple-json-utils" = pkgs.stdenv.mkDerivation {
name = "simple-json-utils";
version = "v0.1.0";
src = pkgs.fetchgit {
url = "https://github.com/justinwoo/purescript-simple-json-utils.git";
rev = "ec5df413e1058959454e380de42f590046a43373";
sha256 = "05mpvn3hrl86sapns88h7k9ccv29d8xmcnll8iz6ix5ibmh9vk2v";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"st" = pkgs.stdenv.mkDerivation {
name = "st";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-st.git";
rev = "c1b9a0d47a5be1d7ea713ef1c583040eb332250a";
sha256 = "0m2jkb9dmpbr8s1c20l7sm2q11y5rx8gqfiyspnyhq5apzkknjr0";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"strings" = pkgs.stdenv.mkDerivation {
name = "strings";
version = "v4.0.1";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-strings.git";
rev = "94c843b93142d0edf1c31ec075c40b6984c3dc7b";
sha256 = "147l3l3fzn7liparhm2y3p8j4ck1lblra5j493p2hy5yy5ndznc8";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"sunde" = pkgs.stdenv.mkDerivation {
name = "sunde";
version = "v1.0.0";
src = pkgs.fetchgit {
url = "https://github.com/justinwoo/purescript-sunde.git";
rev = "0342baae7d3d175bfc089ac1d2fcc10cfef18091";
sha256 = "1s62al6ark10hqc6kdz3nqarblpa6fmdy5kb3bjlxsa8nib436pa";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"tailrec" = pkgs.stdenv.mkDerivation {
name = "tailrec";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-tailrec.git";
rev = "69f4625969e313203028968e4a9f743fa7f87883";
sha256 = "0z7k80nl8dgv8mc2w8xsl2n0637bd1l8ppxak8kaifgjjwa81hx3";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"transformers" = pkgs.stdenv.mkDerivation {
name = "transformers";
version = "v4.2.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-transformers.git";
rev = "0e473e5ef0e294615ca0d9aab0bcffee47b2870d";
sha256 = "03qmvl9s7lbvm73dy9ps6qp39pdcm91hb8yakgj7aq8hgpj7b6bg";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"tuples" = pkgs.stdenv.mkDerivation {
name = "tuples";
version = "v5.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-tuples.git";
rev = "0036bf9d99b721fd0f2e539d24e18e484b016927";
sha256 = "045nsy0r2g51gih0wjhcvhl6gfr8947mlrqwg644ygz72rjm8wq4";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"type-equality" = pkgs.stdenv.mkDerivation {
name = "type-equality";
version = "v3.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-type-equality.git";
rev = "2cdae51c394401cd5fc04b03c341273b41532b7d";
sha256 = "1b7szyca5s96gaawvgwrw7fa8r7gqsdff7xhz3vvngnylv2scl3w";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"typelevel-prelude" = pkgs.stdenv.mkDerivation {
name = "typelevel-prelude";
version = "v5.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-typelevel-prelude.git";
rev = "82b343fabfe3bf4ebf8106ce61bfe24fb3ed500c";
sha256 = "01ki39xj87kwf8j8divlzwrvfyjcgxpmzhhmxzjylqx6jarcwyg6";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"unfoldable" = pkgs.stdenv.mkDerivation {
name = "unfoldable";
version = "v4.0.2";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-unfoldable.git";
rev = "be3262a9dc48e794676b1b2883987331d4be6fd7";
sha256 = "0lzhx030c5933maxcjwk6kzlvbxky1kiwrymqf1dp5wbrar3jyv4";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"unsafe-coerce" = pkgs.stdenv.mkDerivation {
name = "unsafe-coerce";
version = "v4.0.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-unsafe-coerce.git";
rev = "fa6a5ca9b4581c00ee0b8539306a49badb7bee60";
sha256 = "0k9255mk2mz6xjb11pwkgfcblmmyvr86ig5kr92jwy95xim09zip";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"validation" = pkgs.stdenv.mkDerivation {
name = "validation";
version = "v4.2.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript/purescript-validation.git";
rev = "bef3f9da737516e69f00d35310334004c29355cb";
sha256 = "03irk6n7jgsimhp9ckrg2ns7qbc8d383ls3sslxgir5mr8xdc44g";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"variant" = pkgs.stdenv.mkDerivation {
name = "variant";
version = "v6.0.1";
src = pkgs.fetchgit {
url = "https://github.com/natefaubion/purescript-variant.git";
rev = "31e620334124d2ca8b1e608c27d74b607a5831e9";
sha256 = "0cn227q57zbqm6r1aw5kvnp1x8zkc1x7wx28yyz311lmy7k1mkql";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
};
cpPackage = pkg:
let
target = ".spago/${pkg.name}/${pkg.version}";
in ''
if [ ! -e ${target} ]; then
echo "Installing ${target}."
mkdir -p ${target}
cp --no-preserve=mode,ownership,timestamp -r ${toString pkg.outPath}/* ${target}
else
echo "${target} already exists. Skipping."
fi
'';
in {
inherit inputs;
installSpagoStyle = pkgs.stdenv.mkDerivation {
name = "install-spago-style";
shellHook = builtins.toString (
builtins.map cpPackage (builtins.attrValues inputs)
);
};
}

20
spago.dhall Normal file
View File

@ -0,0 +1,20 @@
{-
Welcome to a Spago project!
You can edit this file as you like.
-}
{ name =
"my-project"
, dependencies =
[ "console"
, "generics-rep"
, "kishimen"
, "node-fs-aff"
, "parallel"
, "prelude"
, "simple-json-utils"
, "sunde"
, "validation"
]
, packages =
./packages.dhall
}

5
src/Core.js Normal file
View File

@ -0,0 +1,5 @@
exports._exit = function(code) {
return function() {
process.exit(code);
};
};

116
src/Core.purs Normal file
View File

@ -0,0 +1,116 @@
module Core where
import Prelude
import Control.Monad.Except.Trans as ExceptT
import Data.Bifunctor (lmap)
import Data.Either (Either)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Foreign (ForeignError(..), MultipleErrors)
import Kishimen (genericSumToVariant, variantToGenericSum)
import Simple.JSON as JSON
import Simple.JSON.Utils (printMultipleErrors)
spagoPackagesNix :: String
spagoPackagesNix = "spago-packages.nix"
-- process.exit with exit code
foreign import _exit :: forall a. Int -> Effect a
exit :: forall a. Int -> Aff a
exit = liftEffect <<< _exit
-- {"packageName":"variant","version":"v6.0.1","repo":{"tag":"Remote","contents":"https://github.com/natefaubion/purescript-variant.git"}}
type Package =
{ packageName :: String
, version :: Version
, repo :: Repo
}
readPackage :: String -> Either MyError Package
readPackage = lmap mkJSONError <<< JSON.readJSON
data MyError
= SpagoRunError String
| SpagoOutputDeformed String
| JSONError String
| NixPrefetchGitFailed String
| MissingRevOrRepoResult String
| NixPrefetchGitOutputDeformed String
| FileContentsCorrupted Package String String
mkJSONError :: MultipleErrors -> MyError
mkJSONError = JSONError <<< printMultipleErrors
-- {"tag":"Remote","contents":"https://github.com/natefaubion/purescript-variant.git"}
data Repo
= Remote URL
| Local String
-- | URL from which the package can be fetched
newtype URL = URL String
-- | the actual version/tag in the package set
newtype Version = Version String
-- | the revision (git commit) of the package (at a given version)
newtype Revision = Revision String
-- | sha256 hash for nix
newtype SHA256 = SHA256 String
derive instance genericMyError :: Generic MyError _
instance showMyError :: Show MyError where show = genericShow
type NixPrefetchGitResult =
{ url :: URL
, rev :: Revision
, sha256 :: SHA256
}
data FetchResult
= CantFetchLocal Package
| Fetched { package :: Package, result :: NixPrefetchGitResult }
instance readForeignRepo :: JSON.ReadForeign Repo where
readImpl f = do
r :: { tag :: String, contents :: String } <- JSON.readImpl f
case r.tag of
"Remote" -> pure $ Remote (URL r.contents)
"Local" -> pure $ Local r.contents
_ -> ExceptT.throwError $ pure $ ForeignError $ "Unknown Repo type: " <> r.tag
instance writeForeignRepo :: JSON.WriteForeign Repo where
writeImpl (Remote url) = JSON.writeImpl { tag: "Remote", contents: JSON.writeImpl url }
writeImpl (Local s) = JSON.writeImpl { tag: "Local", contents: JSON.writeImpl s }
derive newtype instance showURL :: Show URL
derive newtype instance readForeignURL :: JSON.ReadForeign URL
derive newtype instance writeForeignURL :: JSON.WriteForeign URL
derive newtype instance showVersion :: Show Version
derive newtype instance readForeignVersion :: JSON.ReadForeign Version
derive newtype instance writeForeignVersion :: JSON.WriteForeign Version
derive newtype instance showRevision :: Show Revision
derive newtype instance readForeignRevision :: JSON.ReadForeign Revision
derive newtype instance writeForeignRevision :: JSON.WriteForeign Revision
derive newtype instance showSHA :: Show SHA256
derive newtype instance eqSHA :: Eq SHA256
derive newtype instance readForeignSHA :: JSON.ReadForeign SHA256
derive newtype instance writeForeignSHA :: JSON.WriteForeign SHA256
derive instance genericRepo :: Generic Repo _
instance showRepo :: Show Repo where show = genericShow
derive instance genericFetchResult :: Generic FetchResult _
instance showFetchResult :: Show FetchResult where show = genericShow
instance readForeignFetchResult :: JSON.ReadForeign FetchResult where
readImpl = map variantToGenericSum <<< JSON.readImpl
instance writeForeignFetchResult :: JSON.WriteForeign FetchResult where
writeImpl = JSON.writeImpl <<< genericSumToVariant

216
src/Generate.purs Normal file
View File

@ -0,0 +1,216 @@
module Generate where
import Prelude
import Control.Alt ((<|>))
import Control.Monad.Except as ExceptT
import Control.Parallel (parTraverse)
import Core (FetchResult(..), MyError(..), NixPrefetchGitResult, Package, Repo(..), Revision(..), SHA256(..), URL(..), Version(..), exit, readPackage, spagoPackagesNix)
import Data.Array as Array
import Data.Bifunctor (lmap)
import Data.Either (Either(..))
import Data.String as String
import Data.Traversable (traverse, traverse_)
import Data.Validation.Semigroup (V(..), toEither)
import Effect.Aff (Aff)
import Effect.Class.Console (error, log)
import Node.ChildProcess as CP
import Node.Encoding (Encoding(..))
import Node.FS.Aff as FS
import Simple.JSON as JSON
import Simple.JSON.Utils (printMultipleErrors)
import Sunde as S
-- | Magic SHA256 for broken fetches from nix-prefetch-git, see below notes
brokenRepoSHA :: SHA256
brokenRepoSHA = SHA256 "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"
-- # e.g. when you nix-prefetch-git
-- # when you have a valid reference:
-- $ nix-prefetch-git https://github.com/purescript/purescript-unsafe-coerce.git --rev v4.0.0 --quiet
-- {
-- "rev": "fa6a5ca9b4581c00ee0b8539306a49badb7bee60",
-- "sha256": "0k9255mk2mz6xjb11pwkgfcblmmyvr86ig5kr92jwy95xim09zip",
-- }
-- # when you don't
-- $ nix-prefetch-git https://github.com/purescript/purescript-unsafe-coerce.git --rev v4.0.j0 --quiet
-- {
-- "rev": "refs/heads/fetchgit",
-- "sha256": "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5",
-- }
spagoListPackages :: Aff (Either MyError (Array Package))
spagoListPackages = do
error "getting packages.."
output <- S.spawn "spago"
[ "list-packages"
, "-f"
, "transitive"
, "-j"
]
CP.defaultSpawnOptions
case output.exit of
CP.Normally 0 -> do
let lines = words output.stdout
error $ "got " <> show (Array.length lines) <> " packages from Spago list-packages."
pure $ traverse readPackage lines
e -> do
pure $ Left $ SpagoRunError (show e)
where
words :: String -> Array String
words = String.split (String.Pattern "\n") <<< String.trim
fetchPackage :: Package -> Aff (Either MyError FetchResult)
fetchPackage p@{ repo: Local _ } = pure $ pure $ CantFetchLocal p
fetchPackage p@{ repo: Remote (URL url), version: Version version } = ExceptT.runExceptT do
output <- ExceptT.lift $ S.spawn "nix-prefetch-git"
[ url
, "--rev"
, version
, "--quiet"
]
CP.defaultSpawnOptions
json <- case output.exit of
CP.Normally 0 -> do
pure output.stdout
x -> do
ExceptT.throwError $ NixPrefetchGitFailed (show x)
result :: NixPrefetchGitResult <- case JSON.readJSON json of
Right x -> pure x
Left e -> ExceptT.throwError $ NixPrefetchGitOutputDeformed (printMultipleErrors e)
if result.sha256 == brokenRepoSHA
then ExceptT.throwError $ MissingRevOrRepoResult (show p)
else pure $ Fetched { package: p, result }
ensureFetchPackage :: Package -> Aff (Either MyError FetchResult)
ensureFetchPackage p = do
exists <- FS.exists path
if exists
then do
error $ "already prefetched " <> p.packageName
contents <- FS.readTextFile UTF8 path
case JSON.readJSON contents of
Right x -> pure $ Right x
Left e -> pure $ Left $ FileContentsCorrupted p path (printMultipleErrors e)
else do
error $ "fetching " <> p.packageName
result <- fetchPackage p
case result of
Left e -> pure $ Left e
Right fetch -> do
FS.writeTextFile UTF8 path (JSON.writeJSON fetch)
pure result
where
path = mkPrefetchPath p
mkPrefetchPath :: Package -> String
mkPrefetchPath { packageName, version: Version version } =
"./.spago2nix/" <> packageName <> "@" <> version <> ".json"
ensureSetup :: Aff Unit
ensureSetup = do
FS.mkdir "./.spago2nix" <|> pure unit
template :: String
template = """# This file was generated by Spago2Nix
{ pkgs ? import <nixpkgs> {} }:
let
inputs = {
INPUTS
};
cpPackage = pkg:
let
target = ".spago/${pkg.name}/${pkg.version}";
in ''
if [ ! -e ${target} ]; then
echo "Installing ${target}."
mkdir -p ${target}
cp --no-preserve=mode,ownership,timestamp -r ${toString pkg.outPath}/* ${target}
else
echo "${target} already exists. Skipping."
fi
'';
in {
inherit inputs;
installSpagoStyle = pkgs.stdenv.mkDerivation {
name = "install-spago-style";
shellHook = builtins.toString (
builtins.map cpPackage (builtins.attrValues inputs)
);
};
}
"""
replace :: { from :: String, to :: String } -> String -> String
replace { from, to } = String.replaceAll (String.Pattern from) (String.Replacement to)
printResult :: FetchResult -> String
printResult (CantFetchLocal { packageName, repo })
= replace { from: "PKGNAME", to: packageName }
<<< replace { from: "PATH", to: show repo }
$ """
# PKGNAME is a Local package in PATH
"""
printResult (Fetched
{ package: { packageName, version: Version version }
, result: { url: URL url, rev: Revision rev, sha256: SHA256 sha256 }
})
= replace { from: "PKGNAME", to: packageName }
<<< replace { from: "VERSION", to: version }
<<< replace { from: "URL", to: url }
<<< replace { from: "REV", to: rev }
<<< replace { from: "SHA256", to: sha256 }
$ """
"PKGNAME" = pkgs.stdenv.mkDerivation {
name = "PKGNAME";
version = "VERSION";
src = pkgs.fetchgit {
url = "URL";
rev = "REV";
sha256 = "SHA256";
};
phases = "installPhase";
installPhase = "ln -s $src $out";
};
"""
printResults :: Array FetchResult -> String
printResults xs = replace { from: "INPUTS", to: inputs } template
where inputs = Array.foldMap printResult xs
generate :: Aff Unit
generate = do
ensureSetup
packages <- exitOnError spagoListPackages
fetches <- toResult <$> parTraverse ensureFetchPackage packages
case fetches of
Left errors -> do
error "errors from fetching packages:"
traverse_ (error <<< show) errors
exit 1
Right xs -> do
FS.writeTextFile UTF8 spagoPackagesNix (printResults xs)
log $ "wrote " <> spagoPackagesNix
exit 0
where
toResult :: forall a b. Array (Either b a) -> Either (Array b) (Array a)
toResult xs = toEither $ traverse V $ map (lmap pure) xs
exitOnError :: forall a. Aff (Either MyError a) -> Aff a
exitOnError aff = do
result <- aff
case result of
Right x -> pure x
Left e -> do
error $ show e
exit 1

1
src/Main.js Normal file
View File

@ -0,0 +1 @@
exports.argv = process.argv;

61
src/Main.purs Normal file
View File

@ -0,0 +1,61 @@
module Main where
import Prelude
import Core (_exit, spagoPackagesNix)
import Data.Array as Array
import Data.List (List, (:))
import Data.List as List
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff as Aff
import Effect.Class (liftEffect)
import Effect.Class.Console (log)
import Generate as Generate
import Node.ChildProcess as CP
foreign import argv :: Array String
args :: List String
args = List.drop 2 $ List.fromFoldable argv
main :: Effect Unit
main = Aff.launchAff_ do
case args of
"generate" : List.Nil -> Generate.generate
"install" : rest -> install rest
List.Nil -> log help
_ -> do
log $ "Unknown arguments: " <> List.intercalate " " args
install :: List String -> Aff Unit
install extraArgs = do
log "installing..."
output <- liftEffect $ CP.spawn "nix-shell" spawnArgs CP.defaultSpawnOptions
{ detached = true
, stdio = CP.inherit
}
liftEffect $ CP.onExit output \_ -> do
log "done"
_exit 0
where
spawnArgs =
[ spagoPackagesNix
, "-A"
, "installSpagoStyle"
, "--run"
, "exit"
] <> (Array.fromFoldable extraArgs)
help :: String
help = """
spago2nix - generate Nix derivations from packages required in a spago project, and allow for installing them and building them.
Usage: spago2nix (generate | install)
Available commands:
generate
Generate a Nix expression of packages from Spago
install [passthrough args for nix-shell]
Install dependencies from spago-packages.nix in Spago style
"""

11
test/Main.purs Normal file
View File

@ -0,0 +1,11 @@
module Test.Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = do
log "🍝"
log "You should add some tests."