Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sempruijs/json2nix
A json to nix converterwritten in Haskell
https://github.com/sempruijs/json2nix
converter flake haskell json nix
Last synced: 25 days ago
JSON representation
A json to nix converterwritten in Haskell
- Host: GitHub
- URL: https://github.com/sempruijs/json2nix
- Owner: sempruijs
- License: mit
- Created: 2024-07-02T21:27:14.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-13T12:07:09.000Z (3 months ago)
- Last Synced: 2024-09-30T09:03:27.966Z (about 1 month ago)
- Topics: converter, flake, haskell, json, nix
- Language: Haskell
- Homepage:
- Size: 69.3 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json2nix
A json to nix converter written in Haskell.
You can use this easily with a flake.
Unformatted json is also supported.## Usage
If you have something like this:
```
{
"name": "Alice",
"age": 21,
"length_in_meters": 1.8,
"best_friends": [
{
"name": "bob",
"age": 19,
},
{
"name": "Sem",
"age": 19,
}
],
"favorite_movie": null
}
```And you want something like this:
```nix
{
name = "Alice";
age = 21;
length_in_meters = 1.8;
best_friends = [
{
name = "Bob";
age = 19;
}
{
name = "Sem";
age = 19;
}
];
favorite_movie = null;
}
```You can do so by enabling nix flakes and run the following command in your shell:
```shell
nix run github:sempruijs/json2nix
```This will install the required tools.
json2nix will ask two questions:1. Choose a file path.
This could be something like: ```config.json```.2. Choose a file name for the new nix file.
You can type something or hit enter for the suggestion.
This would be something like: ```config.nix```## Contributing
If you find a bug please submit [an issue](https://github.com/sempruijs/json2nix/issues) or [pull request](https://github.com/sempruijs/json2nix/pulls).
MIT license