chaotic-cx/nyx

[Request] Zed - Code Editor

urioTV opened this issue ยท 11 comments

Link to the package upstream website/repository

https://zed.dev/
https://github.com/zed-industries/zed

Utility this package has for you

Modern alternative to VS-Code that is not Vim ;)

Do you consider the package(s) to be useful for every Chaotic-Nyx user?

YES!

Do you consider the package to be useful for feature testing/preview?

  • Yes

Are you sure the package isn't available upstream already?

  • Yes

Does the package's license allow redistributing it?

YES!

Have you searched the issues to ensure this request is unique?

  • YES!

Have you read the README to ensure this package is not banned?

  • YES!

More information

It's a new code editor that got open-sourced recently. It's only available on MacOS BUT you can actually run it on Linux if you compile it from source. Since Nix is source-based I think it would be nice to have it here with most recent version from git.

It has a Cargo.lock, and by looking at the Dockerfile cargo is all it needs to build (and libcurl).

If you can make it work with buildRustPackage, post the code here. And then I'll make sure it builds a fresh version every day.

So I guess It's a great opportunity to improve Nix knowledge because I've never done it before. I'll let you know when I manage to do it.

You should note that just because it compiles does not mean it's ready. See https://github.com/zed-industries/zed/issues/7015

zed-industries/zed#7015

If it compiles, it looks enough to have it here ๐Ÿ˜„

You should note that just because it compiles does not mean it's ready. See https://github.com/zed-industries/zed/issues/7015

That's why I thought It would belong here because it's chaotic. Right now I'm fighting with rust development on Nix so I hope I will make it work :)

Okay after some digging i have a good news and bad news. Good news is that (i think) I created working Nix expression to build it. Bad news is that it is not actually working but not because of me but there is an issue with linux build in general.

zed-industries/zed#7015 <---- there is current Linux support status.
https://aur.archlinux.org/packages/zed-editor <----- and there is AUR repo with exactly same problem that i have.

The problem is "protoc failed: Could not make proto path relative: protocol/livekit_room.proto: No such file or directory\n""
It seems that this livekit is not cross-platform so no linux support yet...

Anyway I want to send what I created with Nix and If someone want to bother I would really appreciate feedback.
I know that this code is probably terrible. However, it's encouraging to see that I reached the same moment as AUR.

Flake.nix

{
  description = "A flake for the Zed Code Editor";

  # Specifies the Nix flake inputs
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  # Utilizes flake-utils to simplify flake creation for multiple systems
  outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
        };
        # Your package as a function that accepts nixpkgs as an argument
        zed = pkgs.callPackage ./default.nix { pkgs;};
      in
      {
        packages.zed = zed;
        defaultPackage = zed;
        devShell = pkgs.mkShell {
          nativeBuildInputs = [ pkgs.pkg-config ];
          buildInputs = [ zed pkgs.openssl ];
        };
      });
}

default.nix

{ lib, fetchFromGitHub, rustPlatform, nixpkgs, pkgs }:

rustPlatform.buildRustPackage rec {
  pname = "zed";
  version = "v0.122.2";

  src = fetchFromGitHub {
    owner = "zed-industries";
    repo = pname;
    rev = version;
    hash = "sha256-9yrlRhifOCSv++14ZHcKZCfLja3H2oc3Ttx3ltkLUvQ=";
  };

  cargoLock = {
    lockFile = "${src}/Cargo.lock";
    allowBuiltinFetchGit = true;
  };
  nativeBuildInputs = [ pkgs.pkg-config pkgs.wayland pkgs.cmake pkgs.fontconfig pkgs.alsa-lib pkgs.vulkan-validation-layers pkgs.libxkbcommon pkgs.protobuf ];
  buildInputs = [ pkgs.openssl pkgs.wayland pkgs.cmake pkgs.fontconfig pkgs.alsa-lib pkgs.vulkan-validation-layers pkgs.libxkbcommon pkgs.protobuf ];


  meta = with lib; {
    description = "Zed Code Editor";
    homepage = "https://zed.dev";
    license = licenses.unlicense;
    maintainers = [];
  };
}

On https://aur.archlinux.org/packages/zed-editor I see that they managed to build it so I will test if it works now

Okay so I had some progress. I managed to build Livekit Protocol from source with this.

{ lib, fetchFromGitHub, pkgs, buildGoModule }:

buildGoModule rec {
  pname = "protocol";
  version = "a2f6423fd17cb73d1b19a1161f2daa7869f1391d";

  src = fetchFromGitHub {
    owner = "livekit";
    repo = pname;
    rev = version;
    hash = "sha256-2NzCBIDbm8PiDHjDiQEEH1p+CxMvRzinM0hnyAG+kgE=";
  };

  vendorHash = "sha256-fBGJjeXJa8Wtx1yTO56r+3tm+6IPoG+4Vh0TRORwzsQ=";

  

  meta = with lib; {
    description = "Livekit Protocol";
    homepage = "https://github.com/livekit/protocol/";
    license = licenses.unlicense;
    maintainers = [];
  };
}

PKGBUILD from aur replaces default Livekit with the one built from source(If I understand it correctly). So I guess the only thing to do is to replace it in default.nix file... but I have no idea how to do it right now.

On aur they do something like this

cd "$_archive"
rm -r crates/live_kit_server/protocol
ln -sT "$srcdir/protocol-${_tags[protocol]}" crates/live_kit_server/protocol

I already have this protocol built but I don't know how to use it to replace this crates/live_kit_server/protocol file.

If someone could help I'll be glad but I will still investigate it in my free-time.

FYI, Zed has been merged in nixpkgs : NixOS/nixpkgs#284010

I need to rewrite my generic git update script to properly account cargo hashes, maven hashes, and Cargo lock bumps.

Done. Going to bump the hashes by hand, but rust compilation is slow so it will take some time to cache.