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

How to make default.nix directory import work properly? #43

Open
emanueljg opened this issue Apr 25, 2024 · 1 comment
Open

How to make default.nix directory import work properly? #43

emanueljg opened this issue Apr 25, 2024 · 1 comment

Comments

@emanueljg
Copy link

emanueljg commented Apr 25, 2024

I want Haumea to automatically convert directoryToImport imports to directoryToImport.default imports IF the directory contains a default.nix.

Reason is as follows:

Let's say I have two types of directories:

  1. Directories without default.nix in them
  2. Directories withdefault.nix in them.

In the first scenario, it's a case where I want all files in the dir without question (which is why I started using Haumea in the first place). But the second scenario is more for when I want a more portable directory structure and/or want to be more precise in what modules I want to import in the dir (example in this case being NixOS configuration). This second scenario becomes a bit clunky to solve. I have to write directoryToImport.default to actually import the directory, which is unneccessary, ugly and removes the dynamic ability in going back and forth between importing a loose nix file and a directory without changing its file path.

How do I do this?

@ratorx
Copy link

ratorx commented Aug 22, 2024

I'm not 100% sure which of these 2 you want:

  1. Given a directory with a default.nix, add all attributes from default.nix and also have 1 attribute per non-default.nix file.
  2. Given a directory with a default.nix, add all attributes from default.nix and ignore all non-default.nix files.

If you want 1), then you can use the haumea.transformers.liftDefault.

If you want 2), you can implement it yourself using your own transformer, but possibly it might be a bit tricky to determine which of the attributes are sub-directories vs nix files.

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

No branches or pull requests

2 participants