cd <here>
nix-shell -p nix-prefetch-git nodejs spago
> git clone [email protected]:justinwoo/spago2nix.git
> node ./spago2nix/bin/index.js generate
exit
git add spago-packages.nix
nix build
(compiles, butspago bundle-app
fails due to FS persmissions for cache dir: tbenst/purescript-nix-example#7)nix develop
> spago bundle-app
(succeeds & createsindex.js
)
Created
November 27, 2024 23:38
-
-
Save shamansir/a213873b74b81b77ba9942a3da04e611 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nodes": { | |
"easy-purescript-nix": { | |
"inputs": { | |
"flake-utils": "flake-utils" | |
}, | |
"locked": { | |
"lastModified": 1710161569, | |
"narHash": "sha256-lcIRIOFCdIWEGyKyG/tB4KvxM9zoWuBRDxW+T+mvIb0=", | |
"owner": "justinwoo", | |
"repo": "easy-purescript-nix", | |
"rev": "117fd96acb69d7d1727df95b6fde9d8715e031fc", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "justinwoo", | |
"repo": "easy-purescript-nix", | |
"type": "github" | |
} | |
}, | |
"flake-utils": { | |
"inputs": { | |
"systems": "systems" | |
}, | |
"locked": { | |
"lastModified": 1685518550, | |
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"type": "github" | |
} | |
}, | |
"flake-utils_2": { | |
"inputs": { | |
"systems": "systems_2" | |
}, | |
"locked": { | |
"lastModified": 1731533236, | |
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "numtide", | |
"repo": "flake-utils", | |
"type": "github" | |
} | |
}, | |
"nixpkgs": { | |
"locked": { | |
"lastModified": 1704290814, | |
"narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", | |
"owner": "NixOS", | |
"repo": "nixpkgs", | |
"rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "NixOS", | |
"ref": "nixos-23.05", | |
"repo": "nixpkgs", | |
"type": "github" | |
} | |
}, | |
"root": { | |
"inputs": { | |
"easy-purescript-nix": "easy-purescript-nix", | |
"flake-utils": "flake-utils_2", | |
"nixpkgs": "nixpkgs" | |
} | |
}, | |
"systems": { | |
"locked": { | |
"lastModified": 1681028828, | |
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
"owner": "nix-systems", | |
"repo": "default", | |
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "nix-systems", | |
"repo": "default", | |
"type": "github" | |
} | |
}, | |
"systems_2": { | |
"locked": { | |
"lastModified": 1681028828, | |
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", | |
"owner": "nix-systems", | |
"repo": "default", | |
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", | |
"type": "github" | |
}, | |
"original": { | |
"owner": "nix-systems", | |
"repo": "default", | |
"type": "github" | |
} | |
} | |
}, | |
"root": "root", | |
"version": 7 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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}; | |
depSources = let | |
spagoPkgs = import ./spago-packages.nix {inherit pkgs;}; | |
in | |
builtins.toString | |
(builtins.map | |
(x: ''"${x.outPath}/src/**/*.purs"'') | |
(builtins.attrValues spagoPkgs.inputs)); | |
# cache deps in separate derivation | |
deps = pkgs.runCommand "webui-deps" {buildInputs = [ easy-ps.purs-0_15_8 ];} '' | |
purs compile ${depSources} | |
tar -cf $out output | |
''; | |
in | |
{ | |
packages = { | |
default = | |
pkgs.stdenv.mkDerivation { | |
name = "my-purescript-project"; | |
# inputsFrom = builtins.attrValues self.packages.${system}; | |
src = ./.; | |
buildInputs = [ | |
easy-ps.purs-0_15_9 | |
easy-ps.spago | |
easy-ps.purescript-language-server | |
easy-ps.purs-tidy | |
pkgs.nodejs-18_x | |
pkgs.esbuild | |
]; | |
buildPhase = '' | |
tar -xf ${deps} # populate precompiled deps | |
purs compile "$src/**/*.purs" ${depSources} | |
spago bundle-app -c skip | |
''; | |
installPhase = '' | |
mkdir -p $out | |
cp -a css images index.js index.html $out/ | |
''; | |
}; | |
}; | |
devShells = { | |
default = pkgs.mkShell { | |
name = "purescript-custom-shell"; | |
buildInputs = [ | |
easy-ps.purs-0_15_9 | |
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) | |
''; | |
}; | |
}; | |
} | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Prelude | |
import Effect (Effect) | |
import Effect.Console (log) | |
main | |
:: Effect Unit | |
main = do | |
log "No hello world here: 🍝" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Welcome to your new Dhall package-set! | |
Below are instructions for how to edit this file for most use | |
cases, so that you don't need to know Dhall to use it. | |
## Use Cases | |
Most will want to do one or both of these options: | |
1. Override/Patch a package's dependency | |
2. Add a package not already in the default package set | |
This file will continue to work whether you use one or both options. | |
Instructions for each option are explained below. | |
### Overriding/Patching a package | |
Purpose: | |
- Change a package's dependency to a newer/older release than the | |
default package set's release | |
- Use your own modified version of some dependency that may | |
include new API, changed API, removed API by | |
using your custom git repo of the library rather than | |
the package set's repo | |
Syntax: | |
where `entityName` is one of the following: | |
- dependencies | |
- repo | |
- version | |
------------------------------- | |
let upstream = -- | |
in upstream | |
with packageName.entityName = "new value" | |
------------------------------- | |
Example: | |
------------------------------- | |
let upstream = -- | |
in upstream | |
with halogen.version = "master" | |
with halogen.repo = "https://example.com/path/to/git/repo.git" | |
with halogen-vdom.version = "v4.0.0" | |
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies | |
------------------------------- | |
### Additions | |
Purpose: | |
- Add packages that aren't already included in the default package set | |
Syntax: | |
where `<version>` is: | |
- a tag (i.e. "v4.0.0") | |
- a branch (i.e. "master") | |
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977") | |
------------------------------- | |
let upstream = -- | |
in upstream | |
with new-package-name = | |
{ dependencies = | |
[ "dependency1" | |
, "dependency2" | |
] | |
, repo = | |
"https://example.com/path/to/git/repo.git" | |
, version = | |
"<version>" | |
} | |
------------------------------- | |
Example: | |
------------------------------- | |
let upstream = -- | |
in upstream | |
with benchotron = | |
{ dependencies = | |
[ "arrays" | |
, "exists" | |
, "profunctor" | |
, "strings" | |
, "quickcheck" | |
, "lcg" | |
, "transformers" | |
, "foldable-traversable" | |
, "exceptions" | |
, "node-fs" | |
, "node-buffer" | |
, "node-readline" | |
, "datetime" | |
, "now" | |
] | |
, repo = | |
"https://github.com/hdgarrood/purescript-benchotron.git" | |
, version = | |
"v7.0.0" | |
} | |
------------------------------- | |
-} | |
let upstream = | |
https://github.com/purescript/package-sets/releases/download/psc-0.15.9-20230718/packages.dhall | |
sha256:661c257c997f37bba1b169020a87ae6ea08eb998e931875cb92e86ac9ea26846 | |
in upstream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file was generated by Spago2Nix | |
{ pkgs ? import <nixpkgs> {} }: | |
let | |
inputs = { | |
"console" = pkgs.stdenv.mkDerivation { | |
name = "console"; | |
version = "v6.0.0"; | |
src = pkgs.fetchgit { | |
url = "https://github.com/purescript/purescript-console.git"; | |
rev = "3b83d7b792d03872afeea5e62b4f686ab0f09842"; | |
sha256 = "0fr5l1myhscp910mybp04cg6g8f2hy3ikjfc8fkqlb2dm2cqzdfs"; | |
}; | |
phases = "installPhase"; | |
installPhase = "ln -s $src $out"; | |
}; | |
"effect" = pkgs.stdenv.mkDerivation { | |
name = "effect"; | |
version = "v4.0.0"; | |
src = pkgs.fetchgit { | |
url = "https://github.com/purescript/purescript-effect.git"; | |
rev = "a192ddb923027d426d6ea3d8deb030c9aa7c7dda"; | |
sha256 = "0aa10lc6h9mlf4xf3g3ziig7v6kxdqvbh20kma8ay59w0b1bhmj1"; | |
}; | |
phases = "installPhase"; | |
installPhase = "ln -s $src $out"; | |
}; | |
"prelude" = pkgs.stdenv.mkDerivation { | |
name = "prelude"; | |
version = "v6.0.1"; | |
src = pkgs.fetchgit { | |
url = "https://github.com/purescript/purescript-prelude.git"; | |
rev = "f4cad0ae8106185c9ab407f43cf9abf05c256af4"; | |
sha256 = "0j6mb9w728ifcp10jdv7l9k7k5pw8j1f0fa7xyb8xmbxzc59xqpy"; | |
}; | |
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 | |
''; | |
getGlob = pkg: ''".spago/${pkg.name}/${pkg.version}/src/**/*.purs"''; | |
getStoreGlob = pkg: ''"${pkg.outPath}/src/**/*.purs"''; | |
in { | |
inherit inputs; | |
installSpagoStyle = pkgs.writeShellScriptBin "install-spago-style" '' | |
set -e | |
echo installing dependencies... | |
${builtins.toString (builtins.map cpPackage (builtins.attrValues inputs))} | |
echo "echo done." | |
''; | |
buildSpagoStyle = pkgs.writeShellScriptBin "build-spago-style" '' | |
set -e | |
echo building project... | |
purs compile ${builtins.toString (builtins.map getGlob (builtins.attrValues inputs))} "$@" | |
echo done. | |
''; | |
buildFromNixStore = pkgs.writeShellScriptBin "build-from-store" '' | |
set -e | |
echo building project using sources from nix store... | |
purs compile ${builtins.toString ( | |
builtins.map getStoreGlob (builtins.attrValues inputs))} "$@" | |
echo done. | |
''; | |
mkBuildProjectOutput = | |
{ src, purs }: | |
pkgs.stdenv.mkDerivation { | |
name = "build-project-output"; | |
src = src; | |
buildInputs = [ purs ]; | |
installPhase = '' | |
mkdir -p $out | |
purs compile "$src/**/*.purs" ${builtins.toString | |
(builtins.map | |
(x: ''"${x.outPath}/src/**/*.purs"'') | |
(builtins.attrValues inputs))} | |
mv output $out | |
''; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Welcome to a Spago project! | |
You can edit this file as you like. | |
Need help? See the following resources: | |
- Spago documentation: https://github.com/purescript/spago | |
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html | |
When creating a new Spago project, you can use | |
`spago init --no-comments` or `spago init -C` | |
to generate this file without the comments in this block. | |
-} | |
{ name = "my-project" | |
, dependencies = [ "console", "effect", "prelude" ] | |
, packages = ./packages.dhall | |
, sources = [ "src/**/*.purs", "test/**/*.purs" ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment