-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
flakes: allow composing from multiple files #4218
Comments
This could be fixed if flakes supported relative paths. As long as the relative path doesn't contain |
Related: #3978 |
Yeah, relative inputs might work but for a feature we are designing from
scratch it looks awfully close to a hack.
…On Wed, 4 Nov 2020, 09:27 zimbatm, ***@***.***> wrote:
This could be fixed if flakes supported relative paths. inputs = { a = {
url = "./a"; }; };
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4218 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE365DZT5GJOFGHU74RBUTSOEF6XANCNFSM4TJQFFRQ>
.
|
Would something like the following work?
|
That seems to be a hack and not a solution. As mentioned in #4089 (comment) for a format that isn't yet stabilized we shouldn't have to resort to all kinds of hacks already. |
What would you consider a non-hacky solution? |
As given in the initial comment but to stay in inline with the In a basic variant it could look like this: Example 1: {
inputs = {
someInternalFlakeA = ./a;
};
outputs = { someInternalFlakeA }: {
a = someInternalFlakeA;
};
} but this wouldn't allow specifying any kind of Example 2: {
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
someInternalFlakeA = {
src = ./a; # could also be `url` but should just accept a path instead of requiring a string.
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { someInternalFlakeA }: {
a = someInternalFlakeA;
};
} Using a I am not yet sure about the lockfile behavior of "Example 2". It could be either of these (or something else):
I can (now) see how That being said I still think having support for |
You mean Yeah, |
No, I mean it as an attribute set. Imagine you have a few teams/products and each of them has a flake in their root directory (which itself then refers to the flake of each of the individual programs). The directory layout in that repository could be something like this:
So from the root of the repository you want to be able to do |
Small nit: I don't think a valid lockfile should be required, since flakes that don't specify any inputs other than |
I think that could be an optimisation in an edge-case. I could also imagine that you have only a lockfile in your "root flake" while all the other flakes do not have one (and do not need one as long as they are just leafs). |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/wild-idea-how-about-splitting-nixpkgs-and-nixos/11487/11 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/possibility-for-subflakes/11589/5 |
I marked this as stale due to inactivity. → More info |
`builtins.getFlake` does not accept paths to `/nix/store`.. Kind of relates to NixOS/nix#4218. Patch for systemd-boot will come with 21.11, so not worth the hassle for now.
Still relevant. |
I marked this as stale due to inactivity. → More info |
https://github.com/hercules-ci/flake-parts helps a lot with that issue |
An issue i'm running into, and which isn't solvable with just Nix hacks, is nested flake.lock files. I don't want to commit them to the repo, because the master flake.lock is the only one that matters, but I can't put them in .gitignore and still use the flake directly, because:
This means I can only use the flakes from the "parent" directory. I guess that's still a minor win, but it's very tempting to support nix run and nix shell etc right there in the subdirectory. (Alternatively you can just "mentally ignore" them but it's not ideal, now you risk accidentally adding them on a |
@deemp but you end up with flake.lock files everywhere, instead of just top level. Is my assumption correct that these lock files reflect "the last time I happened to run a nix command in that sub directory", rather than "the actual version this flake is pinned to when included from top level"? I can import subdirectory flakes no problem (thanks to recent work allowing relative path inputs in flakes), but I want to:
Having a bunch of subdirectory What do you think? What's your approach? |
@hraban, my current approach is to lock as little as possible.
|
Very interesting. A bit too idiosyncratic for me but I love the creativity here. |
Is your feature request related to a problem? Please describe.
Commonly I have multiple Nix files in my repository to keep certain matters isolated to some files only. Some complex haskell build doesn't have to be mixed up with the code for my rust program.
Describe the solution you'd like
I would like to declare dependencies aka. inputs in various files across my project. On the root of my project I'd just like to aggregate all the outputs of my projects. e.g. via something like this:
(curently failes with
value is a path while a string was expected
)or maybe something like this:
(currently this failes with
the string '/nix/store/3zl72j46y56q5wb2vizl8vsnr9bwpya2-source/something' is not allowed to refer to a store path (such as '/nix/store/3zl72j46y56q5wb2vizl8vsnr9bwpya2-source')
)Describe alternatives you've considered
I could obviously put everything into one flake.nix but that is really messy in the long run and not really scalable in larger repositories.
The text was updated successfully, but these errors were encountered: