svanderburg / nijs

NiJS: An internal DSL for Nix in JavaScript
MIT License
56 stars 4 forks source link

nijsFunProxy... source/lib/node_modules': No such file or directory #5

Open PlumpMath opened 2 years ago

PlumpMath commented 2 years ago

Hi, Thanks. svanderburg. How do I use nijsfunProxy?

flake this place version (master)

` error: getting status of '/nix/store/dpz11wfk0yfwn1lkfa2w6wc4khil73sy-source/lib/node_modules': No such file or directory (use '--show-trace' to show detailed location information) building the system configuration... error: getting status of '/nix/store/dpz11wfk0yfwn1lkfa2w6wc4khil73sy-source/lib/node_modules': No such file or directory

   … while realising the context of path '/nix/store/dpz11wfk0yfwn1lkfa2w6wc4khil73sy-source/lib/node_modules/nijs/lib/funProxy.nix'

   at /nix/store/knxfpmssnzv8lkqwlj5s8yfiarp06xxh-source/flake.nix:70:28:

       69|             js-nijs = inputs.js-nijs;
       70|             nijsFunProxy = import "${final.js-nijs}/lib/node_modules/nijs/lib/funProxy.nix" {
         |                            ^
       71|               inherit stdenv nodejs;

   … while evaluating 'nijs-sum'

   at /nix/store/knxfpmssnzv8lkqwlj5s8yfiarp06xxh-source/nijs/nijs-sum/default.nix:15:19:

       14|   NIJS-SUM = let
       15|     nijs-sum = a: b: nijsFunProxy {
         |                   ^
       16|       name = "nijs-sum";
       `
PlumpMath commented 2 years ago

nixpkgs version (nodePackages.nijs ?)

` error: attribute 'lib' missing

   at /nix/store/k92wbmi3i4cszi9szy8wfklmrc1sjivx-nijs-0.0.25/lib/node_modules/nijs/lib/funProxy.nix:18:7:

       17|     /* Import all the CommonJS modules that we like to use in this function */
       18|     ${stdenv.lib.concatMapStrings (require: "var ${require.var} = require('${require.module}');\n") requires}
         |       ^
       19|

(use '--show-trace' to show detailed location information) building the system configuration... error: attribute 'lib' missing

   at /nix/store/k92wbmi3i4cszi9szy8wfklmrc1sjivx-nijs-0.0.25/lib/node_modules/nijs/lib/funProxy.nix:18:7:

       17|     /* Import all the CommonJS modules that we like to use in this function */
       18|     ${stdenv.lib.concatMapStrings (require: "var ${require.var} = require('${require.module}');\n") requires}
         |       ^
       19|

`

PlumpMath commented 2 years ago

When will this be normal? You've already gifted us node2nix, but I hope this simpler way will be sooner rather than later. (It's really nice to be able to put it back as a nix argument right away like this)

Thanks

svanderburg commented 2 years ago

i've just regenerated the Nix expressions, so that broken reference should be gone now.

svanderburg commented 2 years ago

To try the proxy examples, the typical workflow is to clone the Git repository, and then run:

$ cd tests
$ nix-build proxytests.nix -A sum
$ cat result
3

I have never tried the flake approach before.

Keep in mind that many use-cases in NiJS were originally developed for experimentation purposes. The only "mature" aspect of NiJS is to use it as a Nix code generator.

PlumpMath commented 2 years ago

Pure didn't work, so I moved it to .config/nixpkgs/config.nix, Again move flake.. with impure it worked fine on flake.nix. . Since js is an impure language, you wouldn't do it with flake, right? If it was changed, it would be too much work?, so I was a little reluctant to answer about it. . Even on flake it runs fine with impure anyway. . One question, is it possible to load only node modules? because.. my private hope... After making a js file (cljs, purescript, or typescript es6.js files compiled into one, it would be really good if there is a way to load and run nijsfunProxy. . And I misunderstood that nijsFunProxy could make a launcher like this in installPhase as makeWrapper $out/bin/${function} $@ . Even if that doesn't work, it doesn't matter for now (if that's the case, it would be better to create a js by yourself or give it to node directly.) . Anyway, as you said, I think you should use it for its original purpose. (so In the original nix dsl use, I wonder if the all js import of the js ecosystem is able.) So, in the future, I would like to have an interop system that easily executes something with js and the nix function receives it and processes it immediately.

Thanks.