Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: implement a validation system for builders / translators, reorganize files #155

Merged
merged 56 commits into from
May 29, 2022

Conversation

yusdacra
Copy link
Member

@yusdacra yusdacra commented May 22, 2022

TODOs:

  • actually implement the validation functions (or leave it for later PR)
  • update documentation
  • comment out the code?

This reorganizes translators, builders, discoverers and adds validation for these. These are also made extensible through the dream2nix config.

Example:

dream2nix.lib.init {
  # declare extras from a nix file
  # the file should have a nix function that takes {dlib, lib, config} as arg
  # and should return an attrset like below
  config.extra = ./nix/d2n/extras.nix;
  # declare extras as an attrset
  config.extra = {
    subsystems = {
      # add new modules
      ruby.discoverers.default = ./nix/d2n/ruby/discoverer.nix;
      ruby.translators.bundix = ./nix/d2n/ruby/bundix.nix;
      # existing modules can be overrided
      rust.builders.crane = ./nix/d2n/rust/crane.nix;
    };
    # add new fetchers
    fetchers.ipfs = ./nix/d2n/fetchers/ipfs.nix;
    fetchers.gitea = ./nix/d2n/fetchers/gitea.nix;
    # existing fetchers can be overrided
    fetchers.http = ./nix/d2n/fetchers/http-proxied.nix;
  };
  # compose multiple extras
  # note: .dream2nixExtras is a hypothetical standardized output
  config.extra = [
    haskellSubsystemFlake.dream2nixExtras
    crystalSubsystemFlake.dream2nixExtras
    gleamSubsystemFlake.dream2nixExtras
  ];
}

If modules are to be used, this could be able to easily modified to use lib.evalModules for validation and evaluating. Personally I'd prefer using something like https://github.com/divnix/yants for validation and keep the code currently as is.

Supersedes #151

@jaen
Copy link
Contributor

jaen commented May 23, 2022

Well, that's certainly nicer than my shit attempts xD

I think it would be useful to get this in even without validation or even if the eventual plan is to go full on modules like #156 suggests, just for the external extensibility it affords. So a +1 on incorporating this, maybe even with postponing actual validation to a follow-up PR – would be nice to base my Ruby (and other) stuff on actual upstream extensibility implementation.

Copy link
Member

@DavHau DavHau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like many files have been moved and edited but git doesn't show them as moved files, instead files are deleted and re-created. This breaks the git history of these files.
I'm not sure if this is easy to fix now, retrospectively.
Next time please do the move and the modify in separate commits, so git won't get confused.

I still think we would benefit a lot by just using evalModules from nixpkgs/nixos/lib/eval-config-minimal.nix. But I will keep this discussion in #156 as it might explode the scope here.

docs/extending-dream2nix.md Outdated Show resolved Hide resolved
docs/extending-dream2nix.md Show resolved Hide resolved
src/default.nix Outdated Show resolved Hide resolved
src/default.nix Outdated Show resolved Hide resolved
src/lib/modules.nix Outdated Show resolved Hide resolved
@yusdacra yusdacra requested a review from DavHau May 29, 2022 13:12
@DavHau DavHau merged commit 645c6fd into nix-community:main May 29, 2022
@DavHau
Copy link
Member

DavHau commented May 29, 2022

Thanks a lot!

@yusdacra yusdacra deleted the refactor/organize-code branch May 29, 2022 19:47
DavHau added a commit that referenced this pull request May 30, 2022
DavHau added a commit that referenced this pull request Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants