From dd6614566142577735e8c6c101b2397d5f7bb6b5 Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sun, 3 Sep 2023 22:23:58 -0700 Subject: [PATCH 1/2] `nix flake update` latest `haskell-flake` also uses https://github.com/thomashoneyman/purescript-overlay --- cabal.project | 4 +-- flake.lock | 87 ++++++++++++++++++++++++++++++++++++++++++--------- flake.nix | 60 +++++++++++++++++++++-------------- 3 files changed, 112 insertions(+), 39 deletions(-) diff --git a/cabal.project b/cabal.project index 40ee02c0..13f1d515 100644 --- a/cabal.project +++ b/cabal.project @@ -1,3 +1,3 @@ packages: - purescript-bridge.cabal - example/example.cabal \ No newline at end of file + . + example/. diff --git a/flake.lock b/flake.lock index a6d30f98..2b86bc72 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1679737941, - "narHash": "sha256-srSD9CwsVPnUMsIZ7Kt/UegkKUEBcTyU1Rev7mO45S0=", + "lastModified": 1693611461, + "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3502ee99d6dade045bdeaf7b0cd8ec703484c25c", + "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", "type": "github" }, "original": { @@ -18,13 +18,28 @@ "type": "github" } }, + "flake-root": { + "locked": { + "lastModified": 1692742795, + "narHash": "sha256-f+Y0YhVCIJ06LemO+3Xx00lIcqQxSKJHXT/yk1RTKxw=", + "owner": "srid", + "repo": "flake-root", + "rev": "d9a70d9c7a5fd7f3258ccf48da9335e9b47c3937", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, "haskell-flake": { "locked": { - "lastModified": 1679690126, - "narHash": "sha256-u6pQejlTLC1QSKLMB/8Ch+2VvgILlxuZsBHAbDn0zHM=", + "lastModified": 1694478711, + "narHash": "sha256-zW/saV4diypxwP56b8l93Nw8fR7tXLbOFku2I+xYCxU=", "owner": "srid", "repo": "haskell-flake", - "rev": "d63943b612dbe30e2aba8aab0e60f1011c369973", + "rev": "ddc704f3f62d3d3569ced794b534e8fd065c379c", "type": "github" }, "original": { @@ -35,16 +50,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1679734080, - "narHash": "sha256-z846xfGLlon6t9lqUzlNtBOmsgQLQIZvR6Lt2dImk1M=", + "lastModified": 1695427891, + "narHash": "sha256-SjwKEwxoIzNNNnREajxfozy0+sStEKyVnUHBzTwR3fg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "dbf5322e93bcc6cfc52268367a8ad21c09d76fea", + "rev": "c7e7b8497d030b52632cba51334a2320fb0655f6", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", + "ref": "haskell-updates", "repo": "nixpkgs", "type": "github" } @@ -52,11 +67,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1678375444, - "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "lastModified": 1693471703, + "narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85", "type": "github" }, "original": { @@ -67,11 +82,55 @@ "type": "github" } }, + "purescript-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "slimlock": "slimlock" + }, + "locked": { + "lastModified": 1695218028, + "narHash": "sha256-oAu9RmKS16rwBBAFxcnMcmoO4t6XQ31x95Ud1TR5fr4=", + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "rev": "401552c582779260472f2111bc98f146790b19be", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", + "flake-root": "flake-root", "haskell-flake": "haskell-flake", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "purescript-overlay": "purescript-overlay" + } + }, + "slimlock": { + "inputs": { + "nixpkgs": [ + "purescript-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688610262, + "narHash": "sha256-Wg0ViDotFWGWqKIQzyYCgayeH8s4U1OZcTiWTQYdAp4=", + "owner": "thomashoneyman", + "repo": "slimlock", + "rev": "b5c6cdcaf636ebbebd0a1f32520929394493f1a6", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "slimlock", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 7600beb1..44465547 100644 --- a/flake.nix +++ b/flake.nix @@ -1,48 +1,62 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/haskell-updates"; flake-parts.url = "github:hercules-ci/flake-parts"; haskell-flake.url = "github:srid/haskell-flake"; + flake-root.url = "github:srid/flake-root"; + purescript-overlay.url = "github:thomashoneyman/purescript-overlay"; + purescript-overlay.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + outputs = inputs@{ self, nixpkgs, haskell-flake, flake-root, flake-parts, purescript-overlay }: flake-parts.lib.mkFlake { inherit inputs; } { systems = nixpkgs.lib.systems.flakeExposed; - # systems = ["x86_64-linux" "x86_64-darwin"]; - imports = [ inputs.haskell-flake.flakeModule ]; + imports = [ + haskell-flake.flakeModule + flake-root.flakeModule + ]; - perSystem = { self', pkgs, ... }: { + perSystem = { self', pkgs, system, config,... }: { - haskellProjects.default = { - - packages = { - purescript-bridge.root = ./.; - example.root = ./example; - }; + # https://flake.parts/overlays#consuming-an-overlay + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + purescript-overlay.overlays.default + ]; + }; + haskellProjects.default = { basePackages = pkgs.haskellPackages; - - # Dependency overrides go here. See https://haskell.flake.page/dependency - # source-overrides = { }; - # overrides = self: super: { }; - devShell = { enable = true; - mkShellArgs = { shellHook = '' export LD_LIBRARY_PATH=${pkgs.zlib.out}/lib:LD_LIBRARY_PATH ''; }; - - tools = hp: { - inherit (pkgs) - purescript - spago + tools = haskellPackages: { + inherit (haskellPackages) zlib; }; - hlsCheck.enable = false; }; + + # exclude devShell, fixes duplicate definition + autoWire = [ "packages" "apps" "checks" ]; + }; + + devShells.default = pkgs.mkShell { + inputsFrom = [ + config.haskellProjects.default.outputs.devShell + ]; + buildInputs = [ + pkgs.hello + pkgs.purs + pkgs.spago + pkgs.purs-tidy-bin.purs-tidy-0_10_0 + pkgs.purs-backend-es + pkgs.purescript-language-server + ]; }; packages.default = self'.packages.example; From 1716627e1dc8492244f878f50ea4f795a6cea2d7 Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sat, 23 Sep 2023 17:45:36 -0700 Subject: [PATCH 2/2] fix Purescript LSP server in `example` In Emacs with Projectile the `purescript-language-server` was not finding `example/spago.dhall`. I'm assuming this also applies to some other editors. The solution is to duplicate `spago.dhall` so it is found at the root of the project: https://github.com/purescript/spago/issues/692#issuecomment-703139731 --- .gitignore | 14 +++++++++++++- example/.gitignore | 10 ---------- spago.dhall | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 11 deletions(-) delete mode 100644 example/.gitignore create mode 100644 spago.dhall diff --git a/.gitignore b/.gitignore index ba1ec8cf..9e7215ab 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,16 @@ stack.yaml example/**/*.js .direnv -result \ No newline at end of file +result + + +bower_components/ +node_modules/ +.pulp-cache/ +output/ +generated-docs/ +.psc-package/ +.psc* +.purs* +.psa* +.spago diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 30efe199..00000000 --- a/example/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/bower_components/ -/node_modules/ -/.pulp-cache/ -/output/ -/generated-docs/ -/.psc-package/ -/.psc* -/.purs* -/.psa* -/.spago diff --git a/spago.dhall b/spago.dhall new file mode 100644 index 00000000..23a5c262 --- /dev/null +++ b/spago.dhall @@ -0,0 +1,23 @@ +{ name = "purescript-bridge-example" +, dependencies = + [ "console" + , "effect" + , "foreign-generic" + , "profunctor-lenses" + , "aff" + , "affjax" + , "affjax-web" + , "argonaut-aeson-generic" + , "ordered-collections" + , "argonaut-codecs" + , "argonaut-generic" + , "either" + , "foldable-traversable" + , "foreign-object" + , "maybe" + , "newtype" + , "prelude" + ] +, packages = ./example/packages.dhall +, sources = [ "example/src/**/*.purs", "example/test/**/*.purs" ] +}