HigherOrderCO / Kind

A modern proof language
https://higherorderco.com
MIT License
3.55k stars 141 forks source link

Nixos install instructions don't work anymore / dist directory is missing during runtime #61

Closed LoPoHa closed 4 years ago

LoPoHa commented 4 years ago

Because of the removal of dist in https://github.com/moonad/Formality/commit/59ef91e387de7707085fb1994efbb80cf6c575ca, installing with the provided nix instructions doesn't work anymore. Installing works, but when executing fm, it cant find ../dist/cli.

The creator of node2nix has a blog post explaining how to run task runners here. (At the bottom, with grunt instead of gulp)

the command node2nix -d -i package.json --supplement-input supplement.json works correctly. but nix-build override.nix -A package wields the following error:

npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.

> gulp-cli@2.2.0 prepublish /nix/store/qwd0b8m39nsnfr804bpmc0kvji3jyin5-node_gulp-cli-2.2.0/lib/node_modhttps://github.com/moonad/Formality/commit/59ef91e387de7707085fb1994efbb80cf6c575caules/gulp-cli
> marked-man --name gulp docs/CLI.md > gulp.1

/nix/store/qwd0b8m39nsnfr804bpmc0kvji3jyin5-node_gulp-cli-2.2.0/lib/node_modules/gulp-cli/node_modules/marked-man/bin/marked-man:8
        if (err) throw err;
                 ^

[Error: ENOENT: no such file or directory, open 'docs/CLI.md'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'docs/CLI.md'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gulp-cli@2.2.0 prepublish: `marked-man --name gulp docs/CLI.md > gulp.1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gulp-cli@2.2.0 prepublish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /build/.npm/_logs/2019-12-25T13_28_56_419Z-debug.log

builder for '/nix/store/076740c77bhid7b2cw4wazbsz3l6ywg2-node_gulp-cli-2.2.0.drv' failed with exit code 1
cannot build derivation '/nix/store/cgg9njbis9i8kxin6bmcd1c76j01xm7n-node_formality-lang-0.1.228.drv': 1 dependencies couldn't be built
error: build of '/nix/store/cgg9njbis9i8kxin6bmcd1c76j01xm7n-node_formality-lang-0.1.228.drv' failed

I have to investigate why this error occurs. Maybe we should/could use the gulp that is already packaged for nix. After Christmas I should have a bit more time to investigate further...


supplement.json

[
  "gulp-cli"
]

override.nix

{ pkgs ? import <nixpkgs> {}
, system ? builtins.currentSystem
}:

let
  nodePackages = import ./default.nix {
    inherit pkgs system;
  };
in
  nodePackages // {
    package = nodePackages.package.override {
      postInstall = "gulp";
    };
  }
VictorTaelin commented 4 years ago

@johnchandlerburnham can you take a look?

johnchandlerburnham commented 4 years ago

Yes, I will take a look tomorrow when I'm home from Christmas. In the meantime @LoPoHa, you should be able to install directly from npm on NixOS with

$ npm set prefix ~/.npm-global
$ export PATH="$HOME/.npm-global:$PATH"
$ npm i -g formality-lang

as described here.

That should fix the immediate problem of getting fm working, but it's a global install, which isn't ideal. Will investigate.

LoPoHa commented 4 years ago

Ok, removing supplement.json and using the packaged gulp allows the package to be build.

new override.nix

{ pkgs ? import <nixpkgs> {}
, system ? builtins.currentSystem
}:

let
  nodePackages = import ./default.nix {
    inherit pkgs system;
  };
in
  nodePackages // {
    package = nodePackages.package.override (oldAttrs: {
      buildInputs = oldAttrs.buildInputs or [] ++  [ pkgs.nodePackages.gulp ];
      postInstall = ''
        mkdir $out/dist
        gulp build
        cp -R $out/lib/node_modules/formality-lang/dist/* $out/dist
      '';
    });
  }

Now i only have to make it available to the path. I'll make a pull request later (maybe tomorrow) when i got it running.

And maybe we should copy lib/bin/ to bin/ and remove lib/. Just for cleanup reasons.

LoPoHa commented 4 years ago

I'm dumb. You can use the override above and nix-env -i -f override.nix to install it. I'll make a pull request in a few hours with this.