Giter VIP home page Giter VIP logo

Comments (14)

itzmjauz avatar itzmjauz commented on August 21, 2024 1

@DieracDelta solved submodules issue somehow recently. May have used the same technique
As for jsonrpc - as I noted above workaround is to tell Nix to fetch it https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#importing-a-cargolock-file (have not tried it tho)

So this is not really relevant for naersk, but it does work(at least for fetching dependencies) - naersk has the upside of providing some form of caching, while buildRustPackage does not. I'm trying to get a build working locally.

from helix.

archseer avatar archseer commented on August 21, 2024

The jsonrpc folks tagged a new release, but did not push a new version to crates.io.

The other problem with building via flake:s submodules aren't visible during the build (NixOS/nix#4423), so all of the syntax definitions are missing and the build fails. The workaround seems to be to re-clone the repo via fetchGit

from helix.

gytis-ivaskevicius avatar gytis-ivaskevicius commented on August 21, 2024

@DieracDelta solved submodules issue somehow recently. May have used the same technique 🤔
As for jsonrpc - as I noted above workaround is to tell Nix to fetch it https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md#importing-a-cargolock-file (have not tried it tho)

from helix.

itzmjauz avatar itzmjauz commented on August 21, 2024

update: edited the snippet to include workarounds for the syntax builds; sadly this fails in checkPhase.
For some reason two tests are failing and I can't manage to reproduce this in a local nix-shell.
Something like this works by fetching the repo:

{
  description = "A port-modern text editor.";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, utils }:
    utils.lib.eachDefaultSystem (system:
      let pkgs = import nixpkgs { inherit system; };
      in {
        defaultPackage = with pkgs;
          rustPlatform.buildRustPackage {
            pname = "helix";
            version = "0.0.10";
            src = fetchgit {
              url = "https://github.com/helix-editor/helix"; # could probably pass a local git repo here
              fetchSubmodules = true;
              rev = "14830e75ff9316f8a5a428a06f3b3c8c4706d35a";
              sha256 = "sha256-6OQmkTR1c3TuIMiToWSoS8skCdNRZvXR5oWFBY/JpM8=";
            };

            cargoLock = {
              lockFile = ./Cargo.lock;

              outputHashes = {
                "jsonrpc-core-17.1.0" = "sha256-FsdoqN6GWtmDxt5fOeGcoGwywiHVO4+GJpMFzD88EAI=";
              };
            };
            nativeBuildInputs = [ ];
            buildInputs = [ cargo rustc ];
          };
        devShell = pkgs.callPackage ./shell.nix {};
      });
}

Depencies get correctly fetched but nix build is very nitpicky about the correct sha being used( the Cargo.lock has to be identical to the pinned upstream one ).

Then the build finishes correctly but fails while running tests:

   > failures:
   >     buffer::tests::index_of_panics_on_out_of_bounds
   >     buffer::tests::pos_of_panics_on_out_of_bounds

in helix-tui

from helix.

archseer avatar archseer commented on August 21, 2024

We use crate.io deps now again: d5de918

I think the test failure could be from warnings? We fixed some warnings in buffer.rs today.

from helix.

itzmjauz avatar itzmjauz commented on August 21, 2024

We use crate.io deps now again: d5de918

I think the test failure could be from warnings? We fixed some warnings in buffer.rs today.

I think you are correct here.

the following builds correctly, It pulls all submodules into the scope of the build:

{
  description = "A post-modern text editor.";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    rust-overlay.url = "github:oxalica/rust-overlay";
    naersk.url = "github:nmattia/naersk";
  };

  outputs = inputs@{ self, nixpkgs, naersk, rust-overlay, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; overlays = [ rust-overlay.overlay ]; };
        rust = (pkgs.rustChannelOf {
          date = "2021-05-01";
          channel = "nightly";
        }).minimal; # cargo, rustc and rust-std
        naerskLib = naersk.lib."${system}".override {
          # naersk can't build with stable?!
          # inherit (pkgs.rust-bin.stable.latest) rustc cargo;
          rustc = rust;
          cargo = rust;
        };
      in rec {
        packages.helix = naerskLib.buildPackage {
          pname = "helix";
          root = ./.;
          src = pkgs.fetchgit {
            url = "https://github.com/helix-editor/helix"; # could probably pass a local git repo here
            fetchSubmodules = true;
            rev = "68affa3c598723a8b9451ef3dcceda83ae161e39";
            sha256 = "sha256-6RF1GmqDNqEeiPnFDErkNc0+gPTg3KJp8JfCD1FoUCI=";
          };
        };
        defaultPackage = packages.helix;
        devShell = pkgs.callPackage ./shell.nix {};
      });
}

This flake.nix build is based on the commit 68affa3;

It is probably unfeasible to have nix-flake build from the master branch since this can often result in a cargo.lock mismatch. Updating it manually is not difficult though. (change rev, build, replace sha, build)

from helix.

archseer avatar archseer commented on August 21, 2024

I think you could use fetchGithub and fetch the latest tagged release for the time being? Then if/when the submodule support gets integrated we can switch to always building latest master.

Other than that, feel free to open a PR with these changes :)

from helix.

itzmjauz avatar itzmjauz commented on August 21, 2024

I think you could use fetchGithub and fetch the latest tagged release for the time being? Then if/when the submodule support gets integrated we can switch to always building latest master.

Other than that, feel free to open a PR with these changes :)

Latest release sadly does not have d5de918 so the build will always fail.
I will wait for v0.0.11 and start a PR, meanwhile for the hell of it:
nix shell github:itzmjauz/helix/nix-flake --command hx (if you have nix flakes enabled )
gets you helix :)

from helix.

pickfire avatar pickfire commented on August 21, 2024

I think we should add nix builds to CI to prevent regression.

from helix.

nrdxp avatar nrdxp commented on August 21, 2024

we could add helix itself as a flake input to pull submodules:

    helix = {
      flake = false;
      url = "https://github.com/helix-editor/helix";
      type = "git";
      submodules = true;
    };

Doing this, I was able to build the package from the flake like so:

        packages.helix = naerskLib.buildPackage {
          pname = "helix";
          root = inputs.helix;
        };

from helix.

itzmjauz avatar itzmjauz commented on August 21, 2024

we could add helix itself as a flake input to pull submodules:

    helix = {
      flake = false;
      url = "https://github.com/helix-editor/helix";
      type = "git";
      submodules = true;
    };

Doing this, I was able to build the package from the flake like so:

        packages.helix = naerskLib.buildPackage {
          pname = "helix";
          root = inputs.helix;
        };

Does this also work when using root = ./.; ? (since you'd want to be able to run nix build with local changes ) I will test when I have the time.

Edit:
I imagine using root = ./. , src = inputs.helix , should include local changes.

from helix.

nrdxp avatar nrdxp commented on August 21, 2024

@itzmjauz I gave it a try, but it doesn't appear to take local changes into account.

from helix.

itzmjauz avatar itzmjauz commented on August 21, 2024

@itzmjauz I gave it a try, but it doesn't appear to take local changes into account.

Yeah I'm seeing that too.. It might be building all helix modules ( helix-term helix-syntax etc) from upstream as well..

from helix.

nrdxp avatar nrdxp commented on August 21, 2024

After reviewing naersk docs, root is only used to read Cargo.toml and Cargo.lock so I guess it's no surprise. Perhaps something like a symlinkJoin could help us merge the local repo with the remote? I'll see if I can get something like that to work.

from helix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.