diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 6bfdde9..b5f0c38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .spago/ output/ node_modules/ +.psci_modules + +# Nix +.direnv/ diff --git a/README.md b/README.md index 72f8b97..972e9f4 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ instance graphqlReactFinlandConference :: } ) -client :: GraphQLClient +client :: GraphQLClientAff client = graphQL "https://api.react-finland.fi/graphql" [] driver main ∷ Effect Unit @@ -57,3 +57,40 @@ main = ``` You can check out the [test](./test/Main.purs) for a full example. + +## Development + +You can either use the nix shell, or the npm package. + +### Nix shell + +Having set up [flakes](https://nixos.wiki/wiki/Flakes), either using [direnv](https://direnv.net/) (`direnv allow`) or `nix develop` + +Buliding: + +``` +spago build +``` + +Testing: + +``` +spago -x test.dhall test +``` + + +### Npm + +Just run `npm i` and then: + +Building: + +``` +spago build +``` + +Testing: + +``` +npm run test +``` diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8a2701c --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "easy-purescript-nix": { + "flake": false, + "locked": { + "lastModified": 1686900973, + "narHash": "sha256-9whTjp8BYy8ZzyghhgbawS06/dVESduME3wsdNH/mpk=", + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "rev": "8cf400656945b2f2bacfd6a8775792aa701f60e9", + "type": "github" + }, + "original": { + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687829761, + "narHash": "sha256-QRe1Y8SS3M4GeC58F/6ajz6V0ZLUVWX3ZAMgov2N3/g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9790f3242da2152d5aa1976e3e4b8b414f4dd206", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "easy-purescript-nix": "easy-purescript-nix", + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cbae14e --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + easy-purescript-nix = { + url = "github:justinwoo/easy-purescript-nix"; + flake = false; + }; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, easy-purescript-nix, ... }@inputs: + let + name = "purescript-graphql-fundeps"; + + supportedSystems = [ + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + ]; + + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); + in + { + devShell = forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + + easy-ps = import easy-purescript-nix { inherit pkgs; }; + in + pkgs.mkShell { + inherit name; + buildInputs = (with pkgs; [ + nodejs_20 + nixpkgs-fmt + ]) ++ (with easy-ps; [ + purs + purs-tidy + psa + spago + purescript-language-server + ]) ++ (pkgs.lib.optionals (system == "aarch64-darwin") + (with pkgs.darwin.apple_sdk.frameworks; [ + Cocoa + CoreServices + ])); + }); + }; +}