Nixify software with less effort [maintainer=@DavHau]
Go to file
2023-07-08 11:59:49 +02:00
.github/workflows feat(tests): run .#update-locks before nix flake check 2023-03-23 17:29:53 +08:00
docs docs/rust: Fix syntax error in fenix example (#541) 2023-07-01 22:28:40 +03:00
examples rust: add support for workspace-inherited crate versions 2023-07-04 21:43:35 +03:00
notes haskell: add notes on haskell.nix 2022-06-23 11:17:13 +02:00
overrides fix: remove rollup patch 2023-03-04 13:46:16 -08:00
src rust: add support for workspace-inherited crate versions 2023-07-04 21:43:35 +03:00
templates feat(templates): add template v1-python 2023-05-04 16:53:22 +02:00
tests Merge pull request #494 from raboof/php_transitive_with_target_dir 2023-03-25 21:07:54 +08:00
v1/nix fix(v1/php): use simpleTranslate2 instead of simpleTranslate 2023-07-08 11:59:49 +02:00
.envrc add .envrc 2022-02-27 15:20:11 +07:00
.gitignore nodejs: init new builder 2022-12-28 13:47:35 +01:00
ci.nix treewide: format with alejandra 1.0.0 2022-03-07 18:06:18 +07:00
default.nix feat(flake-compat): manage default.nix and shell.nix via flake-compat 2023-03-24 12:04:04 +08:00
flake-compat.nix chore: manage all-cabal-json via flake input 2022-10-14 18:10:35 +02:00
flake.lock update flake input nixpkgsV1 2023-06-21 14:49:19 +02:00
flake.nix update flake input nixpkgsV1 2023-06-21 14:49:19 +02:00
LICENSE Initial commit 2021-09-03 17:30:52 +02:00
README.md Fix README link for "Contributing" 2023-04-27 16:57:40 +08:00
shell.nix fix: fix shell.nix 2023-03-27 12:52:38 +08:00
treefmt.toml refactor(utils): vendor semver.nix from poetry2nix 2023-03-26 17:53:02 +08:00

dream2nix - A framework for automated nix packaging
Automate reproducible packaging for various language ecosystems
Documentation | Contributing | Overriding Packages | Examples

!!! Warning: dream2nix is unstable software. While simple UX is one of our main focus points, the APIs are still under development. Do expect changes that will break your setup.

Ecosystem stats:



Funding

This project was funded through the NGI Assure Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 957073. Applications are still open, you can apply today.

Besides that, the project also receives private funding and support from Platonic.Systems.

If your organization wants to support the project with extra funding in order to add support for more languages or new features, please contact one of the maintainers.

Goals

dream2nix 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)

  1. Make sure you use a nix version >= 2.4 and have experimental-features = "nix-command flakes" set.
  2. 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
    
  3. 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 = ./.;
      projects = ./projects.toml;
    };
}

Extensive Example flake.nix:

{
  inputs.dream2nix.url = "github:nix-community/dream2nix";
  outputs = { self, dream2nix }:
    dream2nix.lib.makeFlakeOutputs {
      systems = ["x86_64-linux"];
      config.projectRoot = ./.;

      source = ./.;

      # `projects` can alternatively be an attrset.
      # `projects` can be omitted if `autoProjects = true` is defined.
      projects = ./projects.toml;

      # 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";
          subsystemInfo.nodejs = 18;
        }
      ];

      # 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.

Documentation

Documentation for main branch is deployed to https://nix-community.github.io/dream2nix.

A CLI app is available if you want to read documentation in your terminal. The app is available as d2n-docs if you enter the development shell, otherwise you can access it with nix run .#docs. d2n-docs can be used to access all available documentation. To access a specific document you can use d2n-docs doc-name where doc-name is the name of the document. For example, to access Rust subsystem documentation, you can use d2n-docs rust.

You can also build documentation by running nix build .#docs. Or by entering the development shell (nix develop) and running mdbook build docs.

Watch the presentation

(The code examples of the presentation are outdated) dream2nix - A generic framework for 2nix tools

Community

matrix: https://matrix.to/#/#dream2nix:nixos.org