Nixify software with less effort [maintainer=@DavHau]
Go to file
2022-05-20 15:35:22 +02:00
.github/workflows remove tests-impure 2022-03-28 23:34:56 +07:00
docs update contributors guide 2022-05-19 17:58:08 +02:00
examples fix(examples): remove dream-lock.json files from git 2022-05-18 19:10:31 +03:00
notes fix node2nix builder 2021-09-22 00:30:56 +01:00
overrides/nodejs Merge pull request #127 from happysalada/fix_electron_darwin_hook 2022-04-24 21:05:43 +02:00
src Merge remote-tracking branch 'nrdxp/yarn-fix' 2022-05-20 15:35:22 +02:00
templates/simple add flake template 2022-04-08 11:59:24 +01:00
tests fix escaping problem in tests-examples 2022-05-18 20:45:26 +02:00
.envrc add .envrc 2022-02-27 15:20:11 +07:00
.gitignore formatting: add flake apps + prepare hooks 2022-03-07 13:57:22 +07:00
ci.nix treewide: format with alejandra 1.0.0 2022-03-07 18:06:18 +07:00
flake.lock update alejandra code formatter 2022-05-19 17:27:20 +02:00
flake.nix remove deprecated tests in ./tests/pure 2022-04-20 16:41:37 +02:00
LICENSE Initial commit 2021-09-03 17:30:52 +02:00
README.md readme: fix typo 2022-05-19 16:07:34 +02:00
shell.nix add pre-commit shellHook 2022-03-07 18:25:38 +07:00
treefmt.toml fixup formatting issues 2022-03-07 18:06:28 +07:00

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

  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 }@inputs:
    let
      dream2nix = inputs.dream2nix.lib.init {
        # modify according to your supported systems
        systems = [ "x86_64-linux" ];
        config.projectRoot = ./. ;
      };
    in dream2nix.makeFlakeOutputs {
      source = ./.;
    };
}

Extensive Example flake.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";
        }
      ];

      # 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 = "";};
      };
    };
}

Watch the presentation

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

Further Reading

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.

Community

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