Skip to content

Conversation

@adamcstephens
Copy link
Contributor

@adamcstephens adamcstephens commented Sep 2, 2025

I opted to use deps_nix as it simplifies hash management, and allows re-use of dependencies as they're individual fixed output derivations (FOD). Unfortunately, it makes this first diff quite large.

I can go back to straight hashes if this feels too invasive for the non-nix users, but it shouldn't affect them outside an extra dep. I also added to all apps even though it seems it may not be necessary for forge and expert_credo?

I've seen issues with builds failing during the release stage, but it's likely a timing issue as re-build works.

cc @mhanberg

This is an alternative to #96
fixes #95

@adamcstephens adamcstephens force-pushed the nix-package branch 2 times, most recently from 2818fa3 to b09b3a7 Compare September 2, 2025 13:49
@adamcstephens adamcstephens changed the title nix: buildable package fix: nix package Sep 2, 2025
@mhanberg
Copy link
Member

mhanberg commented Sep 2, 2025

Do you know why the deps.nix files has a bunch of dependencies we don't have like rustler and explorer?

@adamcstephens
Copy link
Contributor Author

Do you know why the deps.nix files has a bunch of dependencies we don't have like rustler and explorer?

There's some nix code in deps.nix for handling rustler and some overrides. These aren't actually being used in this case but are indeed in this file. If you focus solely on the packages attribute you can see what packages are actually being included.

Or here's a view from the repl:

nix-repl> packages.aarch64-darwin.expert.passthru.mixNixDeps
{
  burrito = «derivation /nix/store/9i02pscamc3r97cdfdm5p51321xcw1im-burrito-1.4.0.drv»;
  finch = «derivation /nix/store/c21mgb9d151r8kx3f9b63mny8knbcpb0-finch-0.20.0.drv»;
  gen_lsp = «derivation /nix/store/h99k1n7szga5x0ypq9w4smjaphayzclb-gen_lsp-0.11.0.drv»;
  hpax = «derivation /nix/store/zb6xmaa8bqq2b564v5rmfg25dvf79x8j-hpax-1.0.3.drv»;
  jason = «derivation /nix/store/8m0qh1afkca668bh4i14a8hyc0jx0ai0-jason-1.4.4.drv»;
  logger_file_backend = «derivation /nix/store/q4lxq4jnbdz8gxgp8451pcrqcb3np2kh-logger_file_backend-0.0.14.drv»;
  mime = «derivation /nix/store/wb2sj5v7ky2czzd8iinrgqv233np12j2-mime-2.0.7.drv»;
  mint = «derivation /nix/store/dhldz73fpvkibr4rpdfqxfziawyy6lxf-mint-1.7.1.drv»;
  nimble_options = «derivation /nix/store/q4cvd8aqisp2qwbkswa5saaf99nizz1m-nimble_options-1.1.1.drv»;
  nimble_parsec = «derivation /nix/store/m9j677z65iw48iyv66hszfg7dqcfxgaf-nimble_parsec-1.2.3.drv»;
  nimble_pool = «derivation /nix/store/swffphbiwaynfygk7xzvlxr9yc39japz-nimble_pool-1.1.0.drv»;
  path_glob = «derivation /nix/store/55hwn8bbns0fifslh2zg4nf4h4vnjnjh-path_glob-0.2.0.drv»;
  req = «derivation /nix/store/rxa63xh4hfr7frn07x344skddhzg8w1d-req-0.5.15.drv»;
  schematic = «derivation /nix/store/aq39whqirp182lq387vyi76g522sjc9v-schematic-0.2.1.drv»;
  snowflake = «derivation /nix/store/kckhxlmxg8kak8319s938xqs0h6gwmar-snowflake-1.0.4.drv»;
  sourceror = «derivation /nix/store/04alxga3s8wg0y59xcliy1ffynw86s94-sourceror-1.10.0.drv»;
  telemetry = «derivation /nix/store/4vh71gahwjpirm9qasndqddixhf810nx-telemetry-1.3.0.drv»;
  typed_struct = «derivation /nix/store/kkysmw7p2clr7fhnnp5lmmk68g9c6kfz-typed_struct-0.3.0.drv»;
}

nix-repl> packages.aarch64-darwin.expert.passthru.engineDeps 
{
  elixir_sense = «derivation /nix/store/mxm9kjz2s9fs9b4s6yrjjb3jl0qd18gq-elixir_sense-e3ddc403554050221a2fd19a10a896fa7525bc02.drv»;
  gen_lsp = «derivation /nix/store/ycvdr58p40nw8cj6rq020pnwszkmpxa1-gen_lsp-0.11.0.drv»;
  jason = «derivation /nix/store/q3pqxbkxdrblx53qr8sy5x5m7jl1vn2v-jason-1.4.4.drv»;
  nimble_options = «derivation /nix/store/6bl0pdjifi8wvc0r2wafnq9k7lv3bayx-nimble_options-1.1.1.drv»;
  nimble_parsec = «derivation /nix/store/yd7b099v9jwn1fksj9b0413mnakzhn1c-nimble_parsec-1.2.3.drv»;
  path_glob = «derivation /nix/store/rgq3cxil1nj2gp6wvm4s3ks3vmx6z61a-path_glob-0.2.0.drv»;
  refactorex = «derivation /nix/store/1a569a8plylzbk3pz8lzsmxr2yrjz2f9-refactorex-0.1.52.drv»;
  schematic = «derivation /nix/store/fax6q4mbvxgbvmsdj3083nfnjm4x2p8k-schematic-0.2.1.drv»;
  snowflake = «derivation /nix/store/4siibhny4630wibb8rfs9fshsgk9ahjp-snowflake-1.0.4.drv»;
  sourceror = «derivation /nix/store/2p443qfcp2v6qsp16yzqg1v4ap38655v-sourceror-1.10.0.drv»;
  telemetry = «derivation /nix/store/4vh71gahwjpirm9qasndqddixhf810nx-telemetry-1.3.0.drv»;
  typed_struct = «derivation /nix/store/03xiv0cajfhg4wrvd4h8j3hg8x6lmr48-typed_struct-0.3.0.drv»;
}

@mhanberg
Copy link
Member

mhanberg commented Sep 2, 2025

Gotcha, okay.

I tested locally on NixOS, seemed to start up. Need to actually test it tho still (I'm about to board an airplane).

Is this implementation able to be upstreamed to nixpkgs?

When it is put into nixpkgs, do you recommend removing our local package here?

@adamcstephens
Copy link
Contributor Author

adamcstephens commented Sep 2, 2025

This is pretty close to what would be in nixpkgs, but likely we'd switch back to mixFodDeps there with hashes. A nixpkgs package can't import deps.nix from the repo, since that would be IFD (import from derivation). (The source is a derivation, and then we'd be trying to import from within the source). I think deps_nix is great for in-project packages though which is why I suggested it here.

There are benefits for keeping a package in repo here, in that users can easily access and build from any commit in the repo. But there's the downside of keeping deps.nix (or hashes) up to date with the mix.exs/mix.lock. If they drift, the nix package will fail to build, so ideally they're updated together. It's up to you and the other maintainers whether it stays though. :)

I'd be interested in if this package works for you. In my testing with neovim it only generates errors


[ERROR][2025-09-02 09:12:38] ...lsp/handlers.lua:562	"** (ErlangError) Erlang error: {:erpc, :noconnection}\n    (kernel 10.2.7.2) erpc.erl:1376: :erpc.call/5\n    (xp_expert 0.1.0) lib/expert/provider/handlers/go_to_definition.ex:17: XPExpert.Provider.Handlers.GoToDefinition.handle/2\n    (xp_expert 0.1.0) lib/expert.ex:94: XPExpert.handle_request/2\n    (xp_gen_lsp 0.11.0) lib/gen_lsp.ex:372: anonymous fn/2 in XPGenLSP.loop/3\n    (xp_telemetry 1.3.0) telemetry.erl:324: :xp_telemetry.span/3\n    (xp_gen_lsp 0.11.0) lib/gen_lsp.ex:371: anonymous fn/5 in XPGenLSP.loop/3\n    (xp_gen_lsp 0.11.0) lib/gen_lsp.ex:601: anonymous fn/4 in XPGenLSP.attempt/4\n    (elixir 1.18.4) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2\n"
[ERROR][2025-09-02 09:12:40] ...lsp/handlers.lua:562	"** (ErlangError) Erlang error: {:erpc, :noconnection}\n    (kernel 10.2.7.2) erpc.erl:1376: :erpc.call/5\n    (xp_expert 0.1.0) lib/expert/state.ex:122: XPExpert.State.apply/2\n    (xp_expert 0.1.0) lib/expert.ex:200: XPExpert.apply_to_state/2\n    (xp_expert 0.1.0) lib/expert.ex:139: XPExpert.handle_notification/2\n    (xp_gen_lsp 0.11.0) lib/gen_lsp.ex:528: anonymous fn/2 in XPGenLSP.loop/3\n    (xp_telemetry 1.3.0) telemetry.erl:324: :xp_telemetry.span/3\n    (xp_gen_lsp 0.11.0) lib/gen_lsp.ex:524: anonymous fn/4 in XPGenLSP.loop/3\n    (xp_gen_lsp 0.11.0) lib/gen_lsp.ex:601: anonymous fn/4 in XPGenLSP.attempt/4\n"

@adamcstephens
Copy link
Contributor Author

I will port this to nixpkgs as an unstable release once I see it working fully. :) Then move to stable versioning once y'all do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you recommend renaming this file from expert.nix to package.nix? Or does that not really matter. I think we named it package.nix in Next LS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really matter.

@mhanberg mhanberg changed the title fix: nix package chore(nix): nix package Sep 4, 2025
@mhanberg
Copy link
Member

mhanberg commented Sep 4, 2025

I'm getting the same error as #59, but it can start and load.

@mhanberg mhanberg merged commit 6f928c4 into elixir-lang:main Sep 4, 2025
2 checks passed
@mhanberg
Copy link
Member

mhanberg commented Sep 4, 2025

@adamcstephens in another PR, if you have time could you add a CI check for the nix build?

@adamcstephens adamcstephens deleted the nix-package branch September 4, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Nix build is broken

2 participants