issuu / ocaml-protoc-plugin

ocaml-protoc-plugin
https://issuu.github.io/ocaml-protoc-plugin/
Other
48 stars 19 forks source link

Add Nix support #40

Closed Nymphium closed 1 year ago

Nymphium commented 1 year ago

This PR adds flake.nix and its lock to setup develop environment easily with Nix.

andersfugmann commented 1 year ago

I'm not sure this actually belongs in source repositories. Could you provide a motivation for the PR?

In general, packaging rules for Linux distributions should reside in a distribution specific repository, e.g. Debian nor rpm rules are not added here, but provided by the distribution.

Nymphium commented 1 year ago

The motivation is to provide a reproducable develop environment easily to developers. Comparing to opam local switch, nix with flake tracks depexts versions and its dependencies, then adjusts environment difference.

In general, packaging rules for Linux distributions should reside in a distribution specific repository, e.g. Debian nor rpm rules are not added here, but provided by the distribution.

This PR is not for distributing, but just for developing.

andersfugmann commented 1 year ago

First of all, thanks for suggesting this and creating the PR!

Personally I think adding this is the wrong approach and will not scale well. I have zero experience with Nix, but it seems that the flake.lock references other Nix packages, and pins specific versions. Two questions:

  1. Where are the nix configuration files for the dependencies listed
  2. If dependencies are pinned, who will keep the lock files up to date with bug fixes.

But if the Ocaml community is in favor of adding this Nix packages, I will not object to this PR. Have you considered opening a thread on Ocaml discuss to see how other developers feels about adding Nix package descriptions?

Nymphium commented 1 year ago

Where are the nix configuration files for the dependencies listed

The dependencies are tracked by its child (and its child, recursively) flake.lock files (e.g. opam-nix's flake ).

If dependencies are pinned, who will keep the lock files up to date with bug fixes.

Automation with CI like dependabot would be available.

But if the Ocaml community is in favor of adding this Nix packages, I will not object to this PR. Have you considered opening a thread on Ocaml discuss to see how other developers feels about adding Nix package descriptions?

For examle dune and ocaml-lsp can be developed with nix. But it's good idea to listen to the community how others feel.

andersfugmann commented 1 year ago

I still do not get it. Package locks are needed when creating reproducible application builds - not for libraries, and not for development. There are multiple reasons for this to be a problem:

Imagine you are building application X, which uses Library L1 and L2. L1 depends on L3 version v1 (specified in a lock file), and library L2 also depends on L3, but with version v2. These two libraries then cannot co-exist.

Libraries can exclude compatibility with some dependencies - but individual locking in each library will be impossible to maintain!

If you argue that we could use automation like dependabot to keep lock files in sync with latest versions - then it completely defeats the purpose of a lock file - and we should not have one.

The repositories you referenced (dune and ocaml-lsp) are applications - not libraries. And even if there are examples of libraries with lock-files, I still maintain that its a bad design to have lock files of any kind in libraries because it imposes unneeded restrictions on any system depending on the libraries.

If the community can present a clear use case and a compelling argument, please reopen the issue.