dream2nix/docs/contributors-guide.md

74 lines
2.0 KiB
Markdown
Raw Normal View History

2021-09-29 22:05:17 +03:00
# dream2nix contributers guide
2022-05-19 18:58:08 +03:00
## Translator Notes
2021-09-29 22:05:17 +03:00
In general there are 3 different types of translators
1. pure translator
- translation logic is implemented in nix lang only
- does not invoke build or read from any build output
2022-05-19 18:58:08 +03:00
2. pure translator utilizing IFD (import from derivation)
2021-09-29 22:05:17 +03:00
- part of the logic is integrated as a nix build
- nix code is used to invoke a nix build and parse its results
- same interface as pure translator
3. impure
- translator can be any executable program running outside of a nix build
- not constrained in any way (can do arbitrary network access etc.)
2022-05-19 18:58:08 +03:00
## Initialize a new translator
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
Clone dream2nix repo and execute:
```shell
nix run .#contribute
```
... then select `translator` and answer all questions. This will generate a template.
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
Further instructions are contained in the template in form of code comments.
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
## Debug or test a translator
### Unit tests (pure translators only)
Unit tests will automatically be generated as soon as your translator specifies `generateUnitTestsForProjects`.
Unit tests can be executed via `nix run .#tests-unit`
### Repl debugging
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
- temporarily expose internal functions of your translator
- use nix repl `nix repl ./.`
- invoke a function via
`translators.translators.{subsystem}.{type}.{translator-name}.some_function`
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
### Tested example flake
Add an example flake under `./examples/name-of-example`.
The flake can be tested via:
```command
nix run .#tests-examples name-of-example --show-trace
```
The flake will be tested in the CI-pipeline as well.
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
---
2021-09-29 22:05:17 +03:00
2022-05-19 18:58:08 +03:00
## Initialize a new builder
2022-05-19 18:58:08 +03:00
Clone dream2nix repo and execute:
```shell
nix run .#contribute
```
... then select `builder` and answer all questions. This will generate a template.
2022-05-19 18:58:08 +03:00
Further instructions are contained in the template in form of code comments.
2022-05-19 18:58:08 +03:00
## Debug or test a builder
2022-05-19 18:58:08 +03:00
### Tested example flake
Add an example flake under `./examples/name-of-example`.
The flake can be tested via:
```command
nix run .#tests-examples name-of-example --show-trace
```
2022-05-19 18:58:08 +03:00
The flake will be tested in the CI-pipeline as well.