a46486a67e
* fix(builder/crane): remove code that triggers IFD, remove dependency on full project source for deps only drv * fix(rust/builders): pass pkgs to utils.nix * fix(builder/crane): break dependency on whole project source in dependency derivation * refactor(rust/builders): change nix version to be more close to when reading toFile paths was made non-IFD * docs(translator/cargo-lock): make the safety comment about unsafeDiscardStringContext usage more clear * chore(deps): update crane * fix: use builtins.path to make paths content addressed and named properly in a few places, fix cargo-lock path replacements * refactor(rust/builders): remove nix version check for writing cargo.lock to store * tests: update dream2nix input before overriding it * tests: remove 'flake.lock's, overriding input generates flake.lock correctly * tests: use nixpkgs from dream2nix input in d2n-init-pkgs * refactor: remove useless builtins.path calls * fix: use writeText for writing generated Cargo.lock, toFile causes problems |
||
---|---|---|
.github/workflows | ||
docs | ||
examples | ||
notes | ||
overrides/nodejs | ||
src | ||
templates/simple | ||
tests | ||
.envrc | ||
.gitignore | ||
ci.nix | ||
flake.lock | ||
flake.nix | ||
LICENSE | ||
README.md | ||
shell.nix | ||
treefmt.toml |
[WIP] dream2nix - A framework for automated nix packaging
dream2nix is a framework for automatically converting packages from other build systems to nix. It focuses on the following aspects:
- Modularity
- Customizability
- Maintainability
- Nixpkgs Compatibility, by not enforcing IFD (import from derivation)
- Code de-duplication across 2nix converters
- Code de-duplication in nixpkgs
- Risk-free opt-in aggregated fetching (larger FODs, less checksums)
- Common UI across 2nix converters
- Reduce effort to develop new 2nix solutions
- Exploration and adoption of new nix features
- Simplified updating of packages
The goal of this project is to create a standardized, generic, modular framework for automated packaging solutions, aiming for better flexibility, maintainability and usability.
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.
Test the experimental version of dream2nix
(Currently only nodejs and rust packaging is supported)
- Make sure you use a nix version >= 2.4 and have
experimental-features = "nix-command flakes"
set. - Navigate to to the project intended to be packaged and initialize a dream2nix flake:
cd ./my-project nix flake init -t github:nix-community/dream2nix#simple
- List the packages that can be built
nix flake show
Minimal Example flake.nix
:
{
inputs.dream2nix.url = "github:nix-community/dream2nix";
outputs = { self, dream2nix }:
dream2nix.lib.makeFlakeOutputs {
systems = ["x86_64-linux"];
config.projectRoot = ./.;
source = ./.;
};
}
Extensive Example flake.nix
:
{
inputs.dream2nix.url = "github:nix-community/dream2nix";
outputs = { self, dream2nix }:
dream2nix.lib.makeFlakeOutputs {
systems = ["x86_64-linux"];
config.projectRoot = ./.;
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";
}
];
# configure package builds via overrides
# (see docs for override system below)
packageOverrides = {
# name of the package
package-name = {
# name the override
add-pre-build-steps = {
# override attributes
preBuild = "...";
# update attributes
buildInputs = old: old ++ [pkgs.hello];
};
};
};
# Inject missing dependencies
inject = {
# Make foo depend on bar and baz
# from
foo."6.4.1" = [
# to
["bar" "13.2.0"]
["baz" "1.0.0"]
];
# 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"]
];
};
# add sources for `bar` and `baz`
sourceOverrides = oldSources: {
bar."13.2.0" = builtins.fetchTarball {url = ""; sha256 = "";};
baz."1.0.0" = builtins.fetchTarball {url = ""; sha256 = "";};
};
};
}
An example for instancing dream2nix per pkgs and using it to create outputs
can be found at examples/d2n-init-pkgs
.
Watch the presentation
(The code examples of the presentation are outdated)
Further Reading
- Summary of the core concepts and benefits
- How would this improve the packaging situation in nixpkgs
- Override System
- Contributors Guide
- Extending dream2nix
Funding
This project receives financial support by NLNet as part of the NGI Assure Programme 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.