2021-10-13 03:23:32 +03:00
< p align = "center" >
2021-10-15 19:39:35 +03:00
< img width = "400" src = "https://gist.githubusercontent.com/DavHau/755fed3774e89c0b9b8953a0a25309fa/raw/e2a12a60ae49aa5eb11b42775abdd1652dbe63c0/dream2nix-01.png" >
2021-10-13 03:23:32 +03:00
< / p >
2022-04-24 12:26:36 +03:00
## [WIP] dream2nix - A framework for automated nix packaging
2021-09-29 20:27:49 +03:00
2022-04-24 12:26:36 +03:00
dream2nix is a framework for automatically converting packages from other build systems to nix.
2021-09-03 18:32:00 +03:00
It focuses on the following aspects:
2021-09-29 20:27:49 +03:00
- Modularity
- Customizability
- Maintainability
2022-05-03 23:33:08 +03:00
- Nixpkgs Compatibility, by not enforcing IFD (import from derivation)
2021-09-29 20:27:49 +03:00
- Code de-duplication across 2nix converters
- Code de-duplication in nixpkgs
2022-05-03 23:33:08 +03:00
- Risk-free opt-in aggregated fetching (larger [FODs ](https://nixos.wiki/wiki/Glossary ), less checksums)
2021-09-29 20:27:49 +03:00
- Common UI across 2nix converters
- Reduce effort to develop new 2nix solutions
- Exploration and adoption of new nix features
- Simplified updating of packages
2021-09-03 18:32:00 +03:00
2022-04-24 12:26:36 +03:00
The goal of this project is to create a standardized, generic, modular framework for automated packaging solutions, aiming for better flexibility, maintainability and usability.
2021-09-03 18:32:00 +03:00
2022-02-14 09:19:38 +03:00
The intention is to integrate many existing 2nix converters into this framework, thereby improving many of the previously named aspects and providing a unified UX for all 2nix solutions.
2021-09-07 00:49:40 +03:00
2022-02-09 05:58:07 +03:00
### Test the experimental version of dream2nix
2022-04-24 12:26:36 +03:00
(Currently only nodejs and rust packaging is supported)
1. Make sure you use a nix version >= 2.4 and have `experimental-features = "nix-command flakes"` set.
1. Navigate to to the project indended to be packaged and initialize a dream2nix flake:
```command
cd ./my-project
nix flake init -t github:nix-community/dream2nix#simple
```
1. List the packages that can be built
```command
nix flake show
```
Minimal Example `flake.nix` :
2022-02-09 05:58:07 +03:00
```nix
{
inputs.dream2nix.url = "github:nix-community/dream2nix";
2022-02-09 11:12:08 +03:00
outputs = { self, dream2nix }@inputs:
2022-02-09 05:58:07 +03:00
let
dream2nix = inputs.dream2nix.lib.init {
2022-02-22 16:21:33 +03:00
# modify according to your supported systems
2022-02-09 11:12:08 +03:00
systems = [ "x86_64-linux" ];
2022-02-22 16:21:33 +03:00
config.projectRoot = ./. ;
2022-02-09 05:58:07 +03:00
};
2022-02-22 16:21:33 +03:00
in dream2nix.makeFlakeOutputs {
2022-02-09 11:12:08 +03:00
source = ./.;
2022-04-24 12:26:36 +03:00
};
}
```
Extensive Example `flake.nix` :
```nix
{
inputs.dream2nix.url = "github:nix-community/dream2nix";
outputs = { self, dream2nix }@inputs:
let
system = "x86_64-linux";
pkgs = inputs.dream2nix.nixpkgs.legacyPackages.${system};
dream2nix = inputs.dream2nix.lib.init {
# modify according to your supported systems
systems = [ system ];
config.projectRoot = ./. ;
};
in dream2nix.makeFlakeOutputs {
source = ./.;
# Configure the behavior of dream2nix when translating projects.
# A setting applies to all discovered projects if `filter` is unset,
# or just to a subset or projects if `filter` is used.
settings = [
# prefer aggregated source fetching (large FODs)
{
aggregate = true;
}
# for all impure nodejs projects with just a `package.json` ,
# add arguments for the `package-json` translator
{
filter = project: project.translator == "package-json";
subsystemInfo.npmArgs = "--legacy-peer-deps";
}
];
2022-03-08 06:31:32 +03:00
# configure package builds via overrides
2022-04-24 12:26:36 +03:00
# (see docs for override system below)
2022-03-08 06:31:32 +03:00
packageOverrides = {
# name of the package
package-name = {
# name the override
add-pre-build-steps = {
# override attributes
preBuild = "...";
# update attributes
buildInputs = old: old ++ [ pkgs.hello ];
};
};
};
2022-04-24 12:26:36 +03:00
# Inject missing dependencies
inject = {
2022-04-24 16:10:56 +03:00
# Make foo depend on bar and baz
2022-04-24 12:26:36 +03:00
# from
foo."6.4.1" = [
# to
["bar" "13.2.0"]
["baz" "1.0.0"]
];
2022-04-24 16:10:56 +03:00
# dependencies with @ and slash require quoting
# the format is the one that is in the lockfile
"@tiptap/extension-code"."2.0.0-beta.26" = [
["@tiptap/core" "2.0.0-beta.174"]
];
2022-04-24 12:26:36 +03:00
};
# add sources for `bar` and `baz`
2022-04-29 12:17:34 +03:00
sourceOverrides = oldSources: {
2022-04-24 12:26:36 +03:00
bar."13.2.0" = builtins.fetchTarball {url = ""; sha256 = "";};
baz."1.0.0" = builtins.fetchTarball {url = ""; sha256 = "";};
};
2022-02-09 05:58:07 +03:00
};
}
```
2022-04-24 12:26:36 +03:00
### Watch the presentation
(The code examples of the presentation are outdated)
2021-10-15 19:39:35 +03:00
[![dream2nix - A generic framework for 2nix tools ](https://gist.githubusercontent.com/DavHau/755fed3774e89c0b9b8953a0a25309fa/raw/3c8b2c56f5fca3bf5c343ffc179136eef39d4d6a/dream2nix-youtube-talk.png )](https://www.youtube.com/watch?v=jqCfHMvCsfQ)
2021-09-23 20:51:55 +03:00
### Further Reading
2021-09-29 20:27:49 +03:00
2021-09-23 20:51:55 +03:00
- [Summary of the core concepts and benefits ](/docs/concepts-and-benefits.md )
- [How would this improve the packaging situation in nixpkgs ](/docs/nixpkgs-improvements.md )
2021-11-07 10:48:53 +03:00
- [Override System ](/docs/override-system.md )
2021-09-29 22:05:17 +03:00
- [Contributors Guide ](/docs/contributors-guide.md )
2022-03-12 17:07:27 +03:00
2022-05-15 20:04:07 +03:00
### Funding
This project receives financial support by [NLNet ](https://nlnet.nl/ ) as part of the [NGI Assure Programme ](https://nlnet.nl/assure/ ) funded by the European Commission.
If your organization wants to support the project with extra funding in order to add support for more languages or new featuress, please contact one of the maintainers.
2022-03-12 17:07:27 +03:00
### Community
matrix: https://matrix.to/#/#dream2nix:nixos.org