Hacker News new | past | comments | ask | show | jobs | submit login

Maybe I'm not understanding your question, but this is what the inputs of flakes are for.

You can pull in arbitrary code from pretty much anywhere as an input




The question is if there actually _is_ a rich ecosystem of such libraries - similar to the rich ecosystem of Maven plugins.


I think something got lost along the way. Nix does not replace maven, you call maven from nix.

https://ryantm.github.io/nixpkgs/languages-frameworks/maven/

nix is a build tool a similae way that docker is a build tool. You define build scripts that call the tools you already use. The major difference is that a docker file gives you no way tl be sure you can reproduce that build in the future. A flake on the other hand gives you a high degree of trust.


Nothing got lost: both Nix and Maven are dependency management tools. Both are also build tools. The difference is that Maven was created as a Java build tool (and it stayed that way in general).

What we have today is that there is a multitude of dependency managers and - what's worse - all of them are _also_ build tools targeted at specific language.

Nix has a unique position because it is not language specific. Where it is lacking is missing standards and reusable libraries that would simplify common tasks.

I am comparing to Maven because I am looking for multi-platform Maven alternative. There is Bazel but its dependency management is non-existent. There is Buck2 which is great in theory but the lack of ecosystem makes it a non-starter.

Nix is the only contender in the space that offers almost everything and has a chance to become a de-facto standard of software delivery thanks to this.

What's missing though is... easy to use canned solutions similar to maven plugins.

EDIT: grammar


In the link I referenced, it shows you how to use maven plugins in nix.

Nix has composable, reusable, and shareable functions. Nix is a full, be awkward, programming language. You'll find functions and flakes for nearly everything you might want to do. An example of one that is more plugin like is sops-nix.

Though have never used maven or maven plugins, I may be missing your overall point.


In Java/Maven ecosystem a lot of things is simple because there is a huge ecosystem of easy to integrate libraries/plugins.

Want a packaged spring boot application? There is a plugin for that. Want to package it in a container image? Just add a plugin dependency. Want to build an RPM or deb package? Add another two plugin dependencies. All various artifacts are going to be uploaded to a repository and made available as dependencies.

Missing a specific plugin? You can easily implement it in Java as a module and use it inside your project (and expose it as a standalone artifact as well).

I can’t find anything similar in Nix ecosystem.

Having a language allowing for this is not the same as having solutions already available.


I was reading this thread and now I finally understood what you mean by plugins. Plugins kind of exist in Nix, except they're not called that. They are functions available in some specific module.

For example, `dockerTools` provides different functions like creating an image and other things. There is a module of fetchers, functions that retrieve source files from GitHub and other sources.

But I don't think there are many language-specific functions, like the ones you are describing. I can't think of any, except for the ones that build a Nix package from a language-specific package.


There are attempts like

https://flake.parts/

or

https://github.com/nix-community/flakelight

Their aim is to create an ecosystem of reusable Nix libraries. But it is tiny.


Yes, I know about flake.parts (didn't know about the other one). But I'm not aware of the kind of libraries you mentioned. There's FlakeHub[0], which is like a package index for flakes, so maybe we'll start to see there reusable stuff.

[0]: https://flakehub.com/flakes


To be honest, now when I'm thinking about it - it seems to me Nix main weakness here is that it is a separate language and runtime.

Writing a Maven plugin (ie. a reusable piece of configuration management logic) is easy because you can use any library from the vast Java ecosystem (just add a library as a dependency of your plugin).

Doing the same in Nix requires recreating these libraries in Nix.

Looks like Maven might simply be the right choice...


You can have a hybrid approach, where you use Nix to provide the build environment (which includes Maven, for example). Then you use the Java-specific tools for the build itself. This should ensure your build has a high degree of reproducibility.


That won't cut it as I need a multi-language build.

And don't get me wrong - I know it _can_ be done in Nix (as it is a programming language) - the question is _how easy_ it is to create/maintain it.

Let's say my solution requires a Java Spring Boot application, React client, custom Postgres extension and Python ML code.


Well, you can provide in your environment all the binaries needed:

- Java stuff

- node and npm

- I don't know what you would need for Postgres extensions

- Python, pip or poetry (or whatever you use for Python package management)

Here is an example flake: https://bpa.st/ZUQQ

Under `devShells`, you have `packages`. You can put there any package from nixpkgs, not just Python packages like I have there.

To make it cleaner, you could have a variable for each platform and concatenate them under packages like

    `packages = javaPkgs ++ nodePkgs ++ pgPkgs ++ pyPkgs`.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: