Skip to content

Conversation

@LiGoldragon
Copy link

To use atom with flakes

@srid
Copy link

srid commented Dec 16, 2024

Would be great if there's also an example of consuming this flake.

@LiGoldragon
Copy link
Author

Sure. I'm working on a modification so it's still in motion for me. Will document when I get minimal working model.

@LiGoldragon
Copy link
Author

I'm testing here: https://github.com/LiGoldragon/aidiyz/blob/main/flake.nix

I want to introduce a new way to deal with system which will be passed in before nix eval. Inspired by top comment in compose.nix and the principle beind eka

{
description = "Composable Nix Modules";
outputs = _: {
importAtom = import ./src/core/importAtom.nix;
Copy link
Owner

Choose a reason for hiding this comment

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

should probably be referenced in terms of core, i.e. self.core.importAtom

Copy link
Author

Choose a reason for hiding this comment

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

On my clean flake branch, it fails:

       error: attribute 'importAtom' missing
       at /nix/store/gswph6rcxlv7inl1f0wwl1v3viz4wyb6-source/flake.nix:4:18:
            3|   outputs = { self }: {
            4|     importAtom = self.core.importAtom;
             |                  ^
            5|     core = import ./src/core/mod.nix;

Copy link
Owner

@nrdxp nrdxp left a comment

Choose a reason for hiding this comment

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

Not 100% sure if I actually want to support this. Atom is supposed to be a viable alternative to flakes, supporting a flakes interface sort of belies that purpose a bit.

If you wanted to use atom in a flake, you easily could by just importing the nix expression so I'm not sure this adds much value. I'll have to think about it 🤔

@whs-dot-hk
Copy link

inputs.atom = ...
flake = false;
importAtom = inputs.atom + /src/core/importAtom.nix;

@LiGoldragon
Copy link
Author

Not 100% sure if I actually want to support this. Atom is supposed to be a viable alternative to flakes, supporting a flakes interface sort of belies that purpose a bit.

If you wanted to use atom in a flake, you easily could by just importing the nix expression so I'm not sure this adds much value. I'll have to think about it 🤔

It is easy to maintain a situation while it is still secure; It is easy to deal with a situation before symptoms develop; It is easy to break a thing when it is yet brittle; It is easy to dissolve a thing when it is yet minute. Deal with a thing while it is still nothing; Keep a thing in order before disorder sets in. A tree that can fill the span of a man's arms grows from a downy tip; A terrace nine storeys high rises from hodfuls of earth; A journey of a thousand miles starts from beneath one's feet. Whoever does anything to it will ruin it; whoever lays hold of it will lose it. Therefore the sage, because he does nothing, never ruins anything; and, because he does not lay hold of anything, loses nothing. In their enterprises the people always ruin them when on the verge of success. Be as careful at the end as at the beginning and there will be no ruined enterprises. Therefore the sage desires not to desire and does not value goods which are hard to come by; learns to be without learning and makes good the mistakes of the multitude, in order to help the myriad creatures to be natural and to refrain from daring to act.

The reason why the River and the Sea are able to be king of the hundred valleys is that they excel in taking the lower position. Hence they are able to be king of the hundred valleys. Therefore, desiring to rule over the people, One must in one's words humble oneself before them; And, desiring to lead the people, One must, in one's person, follow behind them. Therefore the sage takes his place over the people yet is no burden; takes his place ahead of the people yet causes no obstruction. That is why the empire supports him joyfully and never tires of doing so. It is because he does not contend that no one in the empire is in a position to contend with him.

Dao De Jing, 64-65

@nrdxp
Copy link
Owner

nrdxp commented Dec 18, 2024

Not 100% sure if I actually want to support this. Atom is supposed to be a viable alternative to flakes, supporting a flakes interface sort of belies that purpose a bit.
If you wanted to use atom in a flake, you easily could by just importing the nix expression so I'm not sure this adds much value. I'll have to think about it 🤔

It is easy to maintain a situation while it is still secure; It is easy to deal with a situation before symptoms develop; It is easy to break a thing when it is yet brittle; It is easy to dissolve a thing when it is yet minute. Deal with a thing while it is still nothing; Keep a thing in order before disorder sets in. A tree that can fill the span of a man's arms grows from a downy tip; A terrace nine storeys high rises from hodfuls of earth; A journey of a thousand miles starts from beneath one's feet. Whoever does anything to it will ruin it; whoever lays hold of it will lose it. Therefore the sage, because he does nothing, never ruins anything; and, because he does not lay hold of anything, loses nothing. In their enterprises the people always ruin them when on the verge of success. Be as careful at the end as at the beginning and there will be no ruined enterprises. Therefore the sage desires not to desire and does not value goods which are hard to come by; learns to be without learning and makes good the mistakes of the multitude, in order to help the myriad creatures to be natural and to refrain from daring to act.

The reason why the River and the Sea are able to be king of the hundred valleys is that they excel in taking the lower position. Hence they are able to be king of the hundred valleys. Therefore, desiring to rule over the people, One must in one's words humble oneself before them; And, desiring to lead the people, One must, in one's person, follow behind them. Therefore the sage takes his place over the people yet is no burden; takes his place ahead of the people yet causes no obstruction. That is why the empire supports him joyfully and never tires of doing so. It is because he does not contend that no one in the empire is in a position to contend with him.

Dao De Jing, 64-65

Emminently valuable wisdom, but perhaps I'm missing the relevance here? If you are suggesting I "humbly" support the legacy interface, well I already do that.

Atom was designed intentionally to evaluate inside a flake context (pure evaluation). I could have broken this with path handling but chose explicitly to support it so those on the fence and still wanting to use flakes could try it out and hopefully derive some value from the added structure.

However, fetching atom-nix with flakes breaks my intended usecase significantly. While early adopters like yourself might pick it up and use it immediately, fetching an atom with flakes or even having a flake.nix in the repo might give the wrong impression and encourage the wrong usage patterns.

Atom-nix1 should be fetched and handled with eka, not flakes. You can still fetch it with a flake by just adding flake = false which I think is a sufficient compromise for those wanting to do so. This isn't just because I say so, but because the atom isn't just a manifest format, but also a publishing format which eka implements.

In short, having a flake.nix in place sends the wrong signal and is, imho, not a good idea long term. Keep in mind, users will not even have to know this repo exists when using eka. Of course, advanced users will be able to pass in a specific version of via a configuration flag, but it won't be necessary. It will simply use the latest version and handle all the boilerplate internally.

In other words, atom is more a low-level interface which is purposely designed to be hidden behind a higher level, user friendly API2 (eka and any other frontends which consume the atom rust library). Using it directly is possible and even supported, but doing so reduces its efficiency (since it cannot leverage the significant network advantages of the atom format).

Footnotes

  1. https://github.com/ekala-project/atom/pull/43

  2. https://github.com/ekala-project/atom/pull/42

@LiGoldragon
Copy link
Author

@nrdxp
Copy link
Owner

nrdxp commented Dec 21, 2024

https://www.youtube.com/watch?v=uzxcILudFWM

if you could perhaps summarize what you are trying to say here, that might be helpful

@ic4-y
Copy link

ic4-y commented Dec 22, 2024

However, fetching atom-nix with flakes breaks my intended usecase significantly. While early adopters like yourself might pick it up and use it immediately, fetching an atom with flakes or even having a flake.nix in the repo might give the wrong impression and encourage the wrong usage patterns.

I think this is a very valid point @nrdxp

@LiGoldragon
Copy link
Author

https://www.youtube.com/watch?v=uzxcILudFWM

if you could perhaps summarize what you are trying to say here

The brief input was the first one. This video is the next level of brevity, until I record one myself. The benefit/cost ratio is extremely high. Enjoy 🙏 ☀️

@nrdxp
Copy link
Owner

nrdxp commented Dec 22, 2024

https://www.youtube.com/watch?v=uzxcILudFWM

if you could perhaps summarize what you are trying to say here

The brief input was the first one. This video is the next level of brevity, until I record one myself. The benefit/cost ratio is extremely high. Enjoy 🙏 ☀️

I will catch the video at some point, but I meant specifically in relation to providing a flake.nix in this repo. I understand the impulse to "just make it work", but atom and eka are purposely designed as a fundamental rearchitecting of dependency handling in Nix.

The absence of a flake.nix speaks more, imho, to the fact that we lose absolutely nothing, and that's sort of the point for something like atom to exist in the first place.

That said, I feel comfortable closing this issue for now. I think the proper interface with flakes should be a compatibility layer #46, on which I left a further comment...

@nrdxp nrdxp closed this Dec 22, 2024
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.

5 participants