Code Monkey home page Code Monkey logo

flake_generator's Introduction

Imperative Management of Declarative Packages

Nix flakes are a really fantastic way to finely manage project dependencies. However, writing Nix expressions to specify dependencies is subtle and requires learning a whole new language. Can we do better?

Turns out yes. Demo:

asciicast

Goal: Avoid writing boilerplate code

The goal is to write an imperative CLI to automate the generation of the declarative dependencies specified in a flake.

Every time I start a project, I find myself copying a flake that works, and simply tweaking the name and list of buildInputs. The goal is to streamline that process and dodge writing any boilerplate code.

How is this any different than nix flake init ?

This is meant to be more powerful. Templates generate boilerplate code, but without interaction. Interaction is key. The end user should be able to get their project up and running with minimal effort expended towards figuring out how to get nix to play nicely with their package and set of dependencies.

How does this work?

The idea is to have the user specify the type of dependencies, flake inputs and outputs, and type of the package with skim, then to output a flake. This flake is then validated with rnix.

If the user wants to modify an existing flake to add or remove dependencies, this will also be possible. The flake shall be parsed in with rnix, and the user will be able to modify it.

As of now, basically none of the features exist. I've only got the proof of concept working: skim can be used for a cli and rnix can be used to modify the AST.

Further down the line, I'd like to make this even more interactive. This will involve querying github, crates.io, pypy, nixpkgs and more for packages, then piping them into skim for selection based on language.

The hope is to also provide automatic support for pre-existing nix expression generators such as node2nix, poetry2nix, cabal2nix, and naersk.

Dependencies

I'm using the rnix parser to generate nix expressions, and the skim fuzzy finder for the cli.

Roadmap

  • Proof of concept
  • Flake Input management
    • Add inputs
    • Remove inputs
    • Change inputs
    • Query github
  • BuildInput management
    • Query nixpkgs
    • Modify buildInputs
    • Add buildInputs
    • Delete buildInputs
  • Specify flake outputs
  • Support of specific languages:
    • Python
    • Rust
    • Haskell

flake_generator's People

Contributors

dependabot[bot] avatar dieracdelta avatar fogti avatar gytis-ivaskevicius avatar yusdacra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

yusdacra ahndmal

flake_generator's Issues

Add more options when generating inputs

We should add more options:

  • Allow the specification of the follow attribute for other inputs. I don't intend to hit this use case with #17 . Derive list of inputs by wgetting the input flake url and parsing its inputs. Error out if flake.nix does not exist in root directory.
  • Allow path inputs, and the type specification (git or https). spec
  • Allow choosing revision

Add devshell

It would be cool to specify or edit a devshell when generating or modifying a flake. We should also add in support for just generating a nix shell as well.

Other features could include editing build inputs to the devshell.

Break repo into library + binary

Idea: use the rust workspace feature to split this out into an executable that generates flakes/nix expressions, and a library for manipulating the AST. I think the AST manipulation could have applications in other places, not just limited to this project.

nixpkgs-fmt

We probably want to pull in nixpkgs-fmt and format our modified AST when we write. They seem to have a convenient API when used as a library to format the AST.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.