Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jorsn/flakegen

Flake inputs with the full power of Nixlang
https://github.com/jorsn/flakegen

Last synced: 1 day ago
JSON representation

Flake inputs with the full power of Nixlang

Awesome Lists containing this project

README

        

# flakegen

In Nix flakes, inputs must be written as pure data, without functions or thunks
(see issues [NixOS/nix#3966](https://github.com/NixOS/nix/issues/3966)
and [NixOS/nix#4945](https://github.com/NixOS/nix/issues/4945)).
To generate inputs with the full power of the Nix language,
one can create a template file, e.g. `flake.in.nix` and generate the
`flake.nix` by evaluating and pretty-printing the `inputs` attribute.

This flake is a convenience wrapper around that.

## Usage

To start using this, run
```
nix flake init -t github:jorsn/flakegen
```

This will create the files `flake.nix` and `flake.in.nix`.
It will not overwrite existing files.
After editing `flake.in.nix` as you like, run
```
nix run .#genflake flake.nix
```
to update the `flake.nix`.
To preview the new `flake.nix` without replacing it, run the following:
```
nix run .#genflake
```

## Repair broken `flake.nix`

You can repair a broken `flake.nix` by
deleting `flake.nix` and running
```
nix flake init -t github:jorsn/flakegen
nix run .#genflake flake.nix
```
as long as `flake.in.nix` works.