4 ms·
Does Nix make it difficult to properly modularise nix files (flakes or not)? Because it certainly looks like the things you listed are separate/orthogonal and
by mkleczek 3y ago
Does Nix make it difficult to properly modularise nix files (flakes or not)?
Because it certainly looks like the things you listed are separate/orthogonal and should be in separate modules/files.
Having many years of Java experience this is the reason why I stick to Maven (not moving to Gradle) - it is opinionated and strongly encourages fine grained modularisation.
- yjftsjthsd-h 3y ago> Because it certainly looks like the things you listed are separate/orthogonal and should be in separate modules/files. Nix absolutely allows that, to the point where I'm surprised that the linked example doesn't separate them. Most of my flakes have a flake.nix that's just a thin wrapper around a block that looks like devShell = import ./shell.nix { inherit pkgs; }; defaultPackage = import ./default.nix { inherit pkgs; }; ...
- yencabulator 3y agoThe thing that makes that miserable is all the inputs need to be declared in the top-level flake. They really should make using flakes in subdirectories of the same git repo painless. (Right now they're treated as if they were remote, and you need to "upgrade" them after every change; unusable.)
- mkleczek 3y agoAnd what's the story with generic libraries that can later be used in your nix files to produce desired output? I am aware of flake-parts that are supposed to offer that but the ecosystem of flake-parts is on the smaller side of things...
- lkjdsklf 3y agoMaybe 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
- mkleczek 3y agoThe question is if there actually _is_ a rich ecosystem of such libraries - similar to the rich ecosystem of Maven plugins.
- georgyo 3y agoI 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/ 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.
- mkleczek 3y agoNothing 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
- georgyo 3y agoIn 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.
- Cyph0n 3y agoYes, to the point where it can become more confusing than helpful. The fact that Nix handles merging data structures for you makes it easy to fall into over modularization.
- rfoo 3y agoThe thing I hate most about a Java codebase is 100 separate .java files with 30-50 lines each and somehow it indeed worked but I have no idea where to look at if I want to find out how is something implemented.
- mkleczek 3y agoIndeed - that’s very often the case - the right balance between too many and too big is not easy to find. Having said that - Java is in general IDE targeted language and once you have an IDE - many small files is not an issue anymore.