reflex-frp / reflex-platform

A curated package set and set of tools that let you build Haskell packages so they can run on a variety of platforms. reflex-platform is built on top of the nix package manager.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
721 stars 164 forks source link

Adding haskell-ide-engine to a project #219

Open cfraz89 opened 6 years ago

cfraz89 commented 6 years ago

Hi,

I'm attempting to add haskell-ide-engine to my project. It was recently added to NixPkgs, and hopefully reflex-platform's fork will include it soon. In the meantime, I've copied the package expression from here:

https://github.com/NixOS/nixpkgs/blob/89e882f956bcddf01ea2d69a569156bf93dcb9c6/pkgs/development/haskell-modules/hie-packages.nix

However my nix-foo isn't good enough to figure out how to invoke the package within the context of reflex-platform.

My shell.nix currently looks like this:

with import <nixpkgs> {};
with import ./reflex-platform {};

let
    hie-packages = ((callPackage ./hie-packages.nix {}) {}); 
    myProject = haskell.lib.addBuildTools (ghc.callPackage ./myProject.nix {}) [hie-packages.haskell-ide-engine];
in
workOn ghc myProject

However I believe the invocation of ((callPackage ./hie-packages.nix {}) {}); is wrong, as I get

error: anonymous function at /home/chris/Projects/myProject/hie-packages.nix:217:8 called without required argument ‘mkDerivation’, at /nix/store/m3il05py3idyf4ny154zjbq23f5blpxx-nixpkgs-18.03pre125635.846b5c42f19/nixpkgs/lib/customisation.nix:74:12

Any help with this would be greatly appreciated.

Additionally, it would be great to see hie integrated into reflex-platform :D

sboosali commented 6 years ago

try the .project nix helper function:

https://github.com/reflex-frp/reflex-platform/blob/develop/docs/project-development.md#building-with-nix

Which automatically parses dependencies from your .cabal files, like stack.

Here is an example that's working for me:

https://github.com/sboosali/cards/blob/master/default.nix

Since you want the executable, I think you can add a build tool too, with an override:

https://github.com/reflex-frp/reflex-platform/blob/develop/project/default.nix#L72

(Btw, I'm sure you can get it working more simply, but like you I don't know too much nix.)

cfraz89 commented 6 years ago

Had a bit more luck using a hie derivation generated by https://github.com/input-output-hk/stack2nix. Now nix-shell works, however cabal can't find jsaddle-warp. I think somehow reflex's ghc is being overridden by hie's?

When attempting to pass reflex's ghc to the hie derivation: hie = reflex.ghc.callPackage ../../Downloads/haskell-ide-engine/hie.nix { compiler = reflex.ghc; };

I'm met with this error: error: attribute ‘overrides’ missing, at /home/chris/Projects/racebase-reflex/reflex-platform/default.nix:194:63

pshemass commented 5 years ago

i believe that haskell-ide-engine is already in reflex platform (line 417 in https://github.com/reflex-frp/reflex-platform/blob/develop/default.nix) in 0.6.0.0 version but still.

If you use Obelisk to update hie version to newest you could try

{ system ? builtins.currentSystem # TODO: Get rid of this system cruft
, iosSdkVersion ? "10.2"
}:
with import ./.obelisk/impl { inherit system iosSdkVersion; };
with import (fetchTarball https://github.com/domenkozar/hie-nix/tarball/master) {};

project ./. ({ ... }: {
  android.applicationId = "systems.obsidian.obelisk.examples.minimal";
  android.displayName = "Obelisk Minimal Example";
  ios.bundleIdentifier = "systems.obsidian.obelisk.examples.minimal";
  ios.bundleName = "Obelisk Minimal Example";
  shellToolOverrides = self: super: {
      haskell-ide-engine = hie84;
    };
})
alexfmpe commented 5 years ago

Regarding obelisk + HIE

srghma commented 3 years ago

Trying to setup haskell-language-server but getting Multi Cradle: No prefixes matched

How to reproduce

  1. on current master
  2. hack-on will remove the nix-thunk files in dir and clone project instead to that dir
./scripts/hack-on haskell-overlays/reflex-packages/dep/universe
./scripts/hack-on haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex
./scripts/hack-on haskell-overlays/reflex-packages/dep/cabal-macosx
./scripts/hack-on haskell-overlays/reflex-packages/dep/jsaddle-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/ghcjs-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/dependent-monoidal-map
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-todomvc
./scripts/hack-on haskell-overlays/reflex-packages/dep/gargoyle
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-aeson-orphans
./scripts/hack-on haskell-overlays/reflex-packages/dep/jsaddle
./scripts/hack-on haskell-overlays/reflex-packages/dep/patch
  1. apply patch
patch ```patch diff --git a/default.nix b/default.nix index 7855347..fe7af2b 100644 --- a/default.nix +++ b/default.nix @@ -14,7 +14,7 @@ , haskellOverlaysPre ? [] , haskellOverlaysPost ? haskellOverlays , hideDeprecated ? false # The moral equivalent of "-Wcompat -Werror" for using reflex-platform. +, hlsSupport ? true }: let iosSupport = system == "x86_64-darwin"; androidSupport = lib.elem system [ "x86_64-linux" ]; @@ -415,9 +415,25 @@ in let this = rec { closurecompiler ; } // lib.optionalAttrs hlsSupport { + haskell-language-server = ( + let + inherit (nixpkgs) callPackage fetchFromGitHub mkShell; + easy-hls-src = fetchFromGitHub { + owner = "jkachmar"; + repo = "easy-hls-nix"; + rev = "6cb50f04e3a61b1ec258c6849df84dae9dfd763f"; + sha256 = "1rvi6067nw64dka8kksl7f34pwkq7wx7pnhnz3y261fw9z5j4ndp"; + }; + easy-hls = callPackage easy-hls-src { + ghcVersions = [ "8.6.5" ]; + }; + in + easy-hls + ); + + # haskell-language-server = nixpkgs.haskell.lib.justStaticExecutables (nativeHaskellPackages.override { + # overrides = nixpkgs.haskell.overlays.haskell-language-server; + # }).haskell-language-server; }; workOn = haskellPackages: package: (overrideCabal package (drv: { ```
  1. add hie.yaml
hie.yaml ```yaml ### GENERATED WITH # # projectdir=$(pwd) # rm -f $projectdir/hie.yaml # touch $projectdir/hie.yaml # echo "cradle:" > $projectdir/hie.yaml # echo " multi:" >> $projectdir/hie.yaml # dojob () { # dir="$1" # cd $projectdir/$dir # output=$(/nix/store/ls47a7id24w5498cmv6djc65vbxf1ppm-implicit-hie-0.1.2.5/bin/gen-hie || true) # echo " - path: \"./$dir\"" >> $projectdir/hie.yaml # echo " config:" >> $projectdir/hie.yaml # echo "$output" | sed 's@^@ @' >> $projectdir/hie.yaml # } # dojob haskell-overlays/reflex-packages/dep/cabal-macosx # dojob haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans # dojob haskell-overlays/reflex-packages/dep/gargoyle # dojob haskell-overlays/reflex-packages/dep/ghcjs-dom # dojob haskell-overlays/reflex-packages/dep/jsaddle # dojob haskell-overlays/reflex-packages/dep/jsaddle-dom # dojob haskell-overlays/reflex-packages/dep/reflex # dojob haskell-overlays/reflex-packages/dep/reflex-aeson-orphans # dojob haskell-overlays/reflex-packages/dep/reflex-dom # dojob haskell-overlays/reflex-packages/dep/reflex-todomvc # dojob haskell-overlays/reflex-packages/dep/universe # cd $projectdir cradle: multi: # - path: "./haskell-overlays/reflex-packages/dep/cabal-macosx" # config: { cradle: { none: } } # # - path: "./haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans" # # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/gargoyle" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/ghcjs-dom" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/jsaddle" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/jsaddle-dom" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/reflex" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/reflex-aeson-orphans" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/reflex-dom" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/reflex-todomvc" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/universe" # config: { cradle: { none: } } # - path: "./haskell-overlays/reflex-packages/dep/cabal-macosx" # config: # cradle: # cabal: # - path: "./" # component: "lib:cabal-macosx" # - path: "./macosx-app.hs" # component: "cabal-macosx:exe:macosx-app" # - path: "." # component: "cabal-macosx:test:tests" # - path: "tests" # component: "cabal-macosx:test:tests" - path: "./haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans" config: cradle: cabal: - path: "./src" component: "lib:dependent-sum-universe-orphans" # - path: "./haskell-overlays/reflex-packages/dep/gargoyle" # config: # cradle: # cabal: # - path: "gargoyle/src" # component: "lib:gargoyle" # - path: "gargoyle-postgresql/src" # component: "lib:gargoyle-postgresql" # - path: "gargoyle-postgresql/src-bin/gargoyle-psql.hs" # component: "gargoyle-postgresql:exe:gargoyle-psql" # - path: "gargoyle-postgresql/src-bin/gargoyle-pg-run.hs" # component: "gargoyle-postgresql:exe:gargoyle-pg-run" # - path: "gargoyle-postgresql/src-bin/gargoyle-postgres-monitor.hs" # component: "gargoyle-postgresql:exe:gargoyle-postgres-monitor" # - path: "gargoyle-postgresql/tests" # component: "gargoyle-postgresql:test:gargoyle-psql-test" # - path: "gargoyle-postgresql-connect/src" # component: "lib:gargoyle-postgresql-connect" # - path: "gargoyle-postgresql-nix/src" # component: "lib:gargoyle-postgresql-nix" # - path: "gargoyle-postgresql-nix/src-bin/gargoyle-nix-psql.hs" # component: "gargoyle-postgresql-nix:exe:gargoyle-nix-psql" # - path: "gargoyle-postgresql-nix/src-bin/gargoyle-nix-pg-run.hs" # component: "gargoyle-postgresql-nix:exe:gargoyle-nix-pg-run" # - path: "gargoyle-postgresql-nix/src-bin/gargoyle-nix-postgres-monitor.hs" # component: "gargoyle-postgresql-nix:exe:gargoyle-nix-postgres-monitor" # - path: "./haskell-overlays/reflex-packages/dep/ghcjs-dom" # config: # - path: "./haskell-overlays/reflex-packages/dep/jsaddle" # config: # cradle: # cabal: # - path: "jsaddle/src-ghc" # component: "lib:jsaddle" # - path: "jsaddle/src" # component: "lib:jsaddle" # - path: "jsaddle-clib/src" # component: "lib:jsaddle-clib" # - path: "jsaddle-clib/src-ghcjs" # component: "lib:jsaddle-clib" # - path: "jsaddle-clib/src-ghc" # component: "lib:jsaddle-clib" # - path: "jsaddle-warp/src" # component: "lib:jsaddle-warp" # - path: "jsaddle-warp/tests" # component: "jsaddle-warp:test:test-tool" # - path: "jsaddle-webkit2gtk/src" # component: "lib:jsaddle-webkit2gtk" # - path: "jsaddle-wkwebview/src" # component: "lib:jsaddle-wkwebview" # - path: "jsaddle-wkwebview/src-ghcjs" # component: "lib:jsaddle-wkwebview" # - path: "jsaddle-wkwebview/src-ghc" # component: "lib:jsaddle-wkwebview" # - path: "./haskell-overlays/reflex-packages/dep/jsaddle-dom" # config: # cradle: # cabal: # - path: "./src" # component: "lib:jsaddle-dom" # - path: "./haskell-overlays/reflex-packages/dep/reflex" # config: # cradle: # cabal: # - path: "./src" # component: "lib:reflex" # - path: "./test" # component: "reflex:test:semantics" # - path: "./test" # component: "reflex:test:CrossImpl" # - path: "./test" # component: "reflex:test:hlint" # - path: "./test" # component: "reflex:test:EventWriterT" # - path: "./test" # component: "reflex:test:DebugCycles" # - path: "./test" # component: "reflex:test:RequesterT" # - path: "./test" # component: "reflex:test:Headless" # - path: "./test" # component: "reflex:test:Adjustable" # - path: "./test" # component: "reflex:test:QueryT" # - path: "./test" # component: "reflex:test:GC-Semantics" # - path: "./test" # component: "reflex:test:rootCleanup" # - path: "./bench/Main.hs" # component: "reflex:bench:spider-bench" # - path: "./test/Main.hs" # component: "reflex:bench:spider-bench" # - path: "./bench/Reflex/TestPlan.hs" # component: "reflex:bench:spider-bench" # - path: "./bench/Reflex/Plan/Reflex.hs" # component: "reflex:bench:spider-bench" # - path: "./bench/Reflex/Bench/Focused.hs" # component: "reflex:bench:spider-bench" # - path: "./test/Reflex/TestPlan.hs" # component: "reflex:bench:spider-bench" # - path: "./test/Reflex/Plan/Reflex.hs" # component: "reflex:bench:spider-bench" # - path: "./test/Reflex/Bench/Focused.hs" # component: "reflex:bench:spider-bench" # - path: "./bench/RunAll.hs" # component: "reflex:bench:saulzar-bench" # - path: "./test/RunAll.hs" # component: "reflex:bench:saulzar-bench" # - path: "./bench/Reflex/TestPlan.hs" # component: "reflex:bench:saulzar-bench" # - path: "./bench/Reflex/Plan/Reflex.hs" # component: "reflex:bench:saulzar-bench" # - path: "./bench/Reflex/Bench/Focused.hs" # component: "reflex:bench:saulzar-bench" # - path: "./test/Reflex/TestPlan.hs" # component: "reflex:bench:saulzar-bench" # - path: "./test/Reflex/Plan/Reflex.hs" # component: "reflex:bench:saulzar-bench" # - path: "./test/Reflex/Bench/Focused.hs" # component: "reflex:bench:saulzar-bench" # - path: "./haskell-overlays/reflex-packages/dep/reflex-aeson-orphans" # config: # cradle: # cabal: # - path: "src" # component: "lib:reflex-aeson-orphans" # - path: "./haskell-overlays/reflex-packages/dep/reflex-dom" # config: # cradle: # cabal: # - path: "chrome-test-utils/src" # component: "lib:chrome-test-utils" # - path: "reflex-dom/src" # component: "lib:reflex-dom" # - path: "reflex-dom/src-android" # component: "lib:reflex-dom" # - path: "reflex-dom/examples/sortableList.hs" # component: "reflex-dom:exe:sortableList" # - path: "reflex-dom/./benchmark.hs" # component: "reflex-dom:exe:benchmark" # - path: "reflex-dom/benchmarks/krausest.hs" # component: "reflex-dom:exe:krausest" # - path: "reflex-dom-core/src" # component: "lib:reflex-dom-core" # - path: "reflex-dom-core/src-ghc" # component: "lib:reflex-dom-core" # - path: "reflex-dom-core/src-ghcjs" # component: "lib:reflex-dom-core" # - path: "reflex-dom-core/src-ghc" # component: "lib:reflex-dom-core" # - path: "reflex-dom-core/test" # component: "reflex-dom-core:test:hlint" # - path: "reflex-dom-core/test" # component: "reflex-dom-core:test:hydration" # - path: "reflex-dom-core/test" # component: "reflex-dom-core:test:gc" # - path: "reflex-dom-test-selenium/src" # component: "lib:reflex-dom-test-selenium" # - path: "./haskell-overlays/reflex-packages/dep/reflex-todomvc" # config: # - path: "./haskell-overlays/reflex-packages/dep/universe" # config: # cradle: # cabal: # - path: "deprecated/universe-instances-base/src" # component: "lib:universe-instances-base" # - path: "deprecated/universe-instances-trans/src" # component: "lib:universe-instances-trans" # - path: "universe/src" # component: "lib:universe" # - path: "universe-base/src" # component: "lib:universe-base" # - path: "universe-base/tests" # component: "universe-base:test:tests" # - path: "universe-dependent-sum/src" # component: "lib:universe-dependent-sum" # - path: "universe-dependent-sum/test" # component: "universe-dependent-sum:test:th-test" # - path: "universe-instances-extended/src" # component: "lib:universe-instances-extended" # - path: "universe-reverse-instances/src" # component: "lib:universe-reverse-instances" ```
  1. ./try-reflex
  2. run this command and here are my logs and error
  Multi Cradle: No prefixes matched
  pwd: /home/srghma/projects/reflex-platform
  filepath:
  /home/srghma/projects/reflex-platform/haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs
  prefixes:
  ("./src",Cabal {component = Just "lib:dependent-sum-universe-orphans"})
haskell-language-server-wrapper -d haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs ```sh [nix-shell:~/projects/reflex-platform]$ haskell-language-server-wrapper -d haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs Found "/home/srghma/projects/reflex-platform/hie.yaml" for "/home/srghma/projects/reflex-platform/a" Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.3.0.0, Git revision e7c5e90b6df5dff2760d76169eddaea3bdd6a831 (dirty) x86_64 ghc-8.10.4 Current directory: /home/srghma/projects/reflex-platform Operating system: linux Arguments: ["-d","haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs"] Cradle directory: /home/srghma/projects/reflex-platform Cradle type: Cabal Tool versions found on the $PATH cabal: 3.0.0.0 stack: Not found ghc: 8.6.5 Consulting the cradle to get project GHC version... Project GHC version: 8.6.5 haskell-language-server exe candidates: ["haskell-language-server-8.6.5","haskell-language-server"] Launching haskell-language-server exe at:/nix/store/jvdjp996s728fkdrrq4wg6lk58k8h6fd-haskell-language-server-1.3.0/bin/haskell-language-server-8.6.5 haskell-language-server version: 1.3.0.0 (GHC: 8.6.5) (PATH: /nix/store/4wkv3mi2hidvbgvmibvjgyzp5nbnqzw6-haskell-language-server-1.3.0-installer/bin/haskell-language-server-8.6.5) (GIT hash: e7c5e90b6df5dff2760d76169eddaea3bdd6a831) ghcide setup tester in /home/srghma/projects/reflex-platform. Report bugs at https://github.com/haskell/haskell-language-server/issues Step 1/4: Finding files to test in /home/srghma/projects/reflex-platform Found 1 files Step 2/4: Looking for hie.yaml files that control setup Found 1 cradle (/home/srghma/projects/reflex-platform/hie.yaml) Step 3/4: Initializing the IDE 2021-08-22 19:35:16.250580398 [ThreadId 7] DEBUG hls: Initializing exports map from hiedb Step 4/4: Type checking the files 2021-08-22 19:35:16.263433672 [ThreadId 36] INFO hls: Consulting the cradle for "haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs" Output from setting up the cradle Cradle {cradleRootDir = "/home/srghma/projects/reflex-platform", cradleOptsProg = CradleAction: Cabal} 2021-08-22 19:35:16.264087682 [ThreadId 36] DEBUG hls: Session loading result: Left [CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Multi Cradle: No prefixes matched","pwd: /home/srghma/projects/reflex-platform","filepath: /home/srghma/projects/reflex-platform/haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs","prefixes:","(\"./src\",Cabal {component = Just \"lib:dependent-sum-universe-orphans\"})"]}] 2021-08-22 19:35:16.264741176 [ThreadId 44] INFO hls: File: /home/srghma/projects/reflex-platform/haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs Hidden: no Range: 1:1-2:1 Source: cradle Severity: DsError Message: Multi Cradle: No prefixes matched pwd: /home/srghma/projects/reflex-platform filepath: /home/srghma/projects/reflex-platform/haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs prefixes: ("./src",Cabal {component = Just "lib:dependent-sum-universe-orphans"}) 2021-08-22 19:35:16.265245342 [ThreadId 48] INFO hls: finish: User TypeCheck (took 0.00s) 2021-08-22 19:35:16.265474624 [ThreadId 52] INFO hls: finish: GetHie (took 0.00s) Files that failed: * /home/srghma/projects/reflex-platform/haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs Completed (0 files worked, 1 file failed) 2021-08-22 19:35:16.265886125 [ThreadId 58] INFO hls: finish: GenerateCore (took 0.00s) haskell-language-server-8.6.5: SQLite3 returned ErrorBusy while attempting to perform close: unable to close due to unfinalized statements or unfinished backups haskell-language-server-wrapper: callProcess: /nix/store/jvdjp996s728fkdrrq4wg6lk58k8h6fd-haskell-language-server-1.3.0/bin/haskell-language-server-8.6.5 "-d" "haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans/src/Data/Some/Universe/Orphans.hs" (exit 1): failed ```

Could someone help