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

Automatically build sources #348

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Th3Whit3Wolf
Copy link

@Th3Whit3Wolf Th3Whit3Wolf commented Jul 25, 2021

This pull request does a couple things.

  1. Any package inside ./pkgs (with the exception of ./pkgs/bud, ./pkgs/_sources and ./pkgs/default.nix will be called (as in callPackage) and can use inherit (source) pname version src so long as the name of parent folder for the default.nix or the name of the nix file stripped of .nix is the same name used in sources.toml
  2. Start work on automatically building vimPlugins, vscode extension, and other development tools from prefixes in sources.toml Currently only vimPlugins are implemented. Addresses 321.

I recognize that flake.nix is not a great place for an overlay. I was unable to find a way to make an overlay that lets you import inputs, which means defining rakeTree and flattenTree before writing what's currently in the flake. It would also have had to be used as (import ./path/filename.nix).overlay.

flake.nix Outdated
Comment on lines 68 to 78
rakePkgs = dir:
let
sieve = name: val:
(name != "default" && name != "bud" && name != "_sources");

flattenFiltered = digga.lib.flattenTree
(nixos.lib.filterAttrs sieve (digga.lib.rakeLeaves dir));
getBasename = name: nixos.lib.last (nixos.lib.splitString "." name);
in
nixos.lib.mapAttrs' (n: v: nixos.lib.nameValuePair (getBasename n) v)
flattenFiltered;
Copy link
Contributor

Choose a reason for hiding this comment

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

So you do think an importPackages would be suitable addition to digga? Could be, but we'd have to make and discuss the use case over there.

Copy link
Author

Choose a reason for hiding this comment

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

Yes I do, I use the rakePkgs function exclusively to build the localPackages overlay. Which builds all packages in the ./pkgs directory so I never have to touch ./pkgs/default.nix when I add a new package. I do not know how to move it into digga and function properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

we could make pkgs complely default.nix-less and add add nvfetcher stuff separately.

We could also consider to teach rakeLeaves to not consider basenames starting with an underscore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can have a quick look at the digga impl. With a little help, it shouldn't be too hard.
https://github.com/divnix/digga/blob/main/src/importers.nix

Copy link
Author

Choose a reason for hiding this comment

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

I tried actually, rakePkgs is easy but I could not figure out how to make the localPackages overlay fit in there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd model it after

digga/src/importers.nix

Lines 120 to 127 in fb3497d

importOverlays = dir:
{
# Meant to output a module that sets the overlays option
# overlays order matters. mkAfter ensures those in-house
# overlays are loaded later (after external ones), so the latter
# can be modified via internal overlays
overlays = lib.mkAfter (builtins.attrValues (flattenTree (rakeLeaves dir)));
};

returning a module that can be importsed:

{
  overlays = {};
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can use rakeLeaves as is. the only (orthogonal) addition could be to skip on _ prefixes.

Copy link
Contributor

Choose a reason for hiding this comment

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

In theory, you could also reuse flattenTree and derive the appropriate package name from that string, and finally callPackage on its values.

pkgs/default.nix Outdated Show resolved Hide resolved
These were removed as they do not belong inside of flakes.nix.
replaced all occurrences of self/super with final/prev
@blaggacao
Copy link
Contributor

now, I got a clearer picture what this is all about 😄

@danielphan2003 Can vs-ext generalize well enough over <package set> so that we could actually inaugurate a pkgsSet lib? Or merge anything +- viable back into digga?

@danielphan2003
Copy link

Yes, it can. Head over to vs-ext for usage, assuming this PR is merged.

@blaggacao
Copy link
Contributor

I kind of see a divnix/vim-ext repo not too far on the horizon. @Th3Whit3Wolf what do you think?

It would make more sense to be able to iterate independently of the devos release cycle. 🚀

Relatively soon (v1.0) devos will become very boring and slow motion.

@Th3Whit3Wolf
Copy link
Author

I kind of see a divnix/vim-ext repo not too far on the horizon. @Th3Whit3Wolf what do you think?

We could do that, would it be better to have a repo for each <package set> or one repo that has all of them?

@blaggacao
Copy link
Contributor

would it be better to have a repo for each  or one repo that has all of them?

That depends probably on two things:

How much design overlap there is and how much does it hurt if release cycles have to be coupled.

Do you have any idea about what we could expect?

@Th3Whit3Wolf
Copy link
Author

I think multiples repos are best for now.

I think there could also be a future where one larger repo or maybe even digga creates the overlay itself as to not clutter the users' flake inputs.

@blaggacao
Copy link
Contributor

https://github.com/divnix/vim-ext the project is yours 🚀

@Th3Whit3Wolf
Copy link
Author

@blaggacao sorry it's taken me so long to respond, I've been quite busy lately.

I've been looking at vs-ext and I'm not sure it's best to make vim-ext right now. Unless I'm mistaken the goal of vs-ext updates is to take use bud to take a vscode extension unique id, query openvsx, and then update that extensions metadata.

This could be done for vim plugins however it would be a lot more work. Vim plugins aren't collectively stored in one location. You can find them on github,gitlab,(any code hosting service), vimawesome, and nvim-awesome So there would be need to create a method to query each one. If vim-ext is being described as

A kick ass library to dominate your Vim Extensions (with DevOS)

I would expect it to build vim plugins that have build requirements (could be node, rust, clojure, or really anything).

@Th3Whit3Wolf
Copy link
Author

Follow up question, how much reliant is devos on nvfetcher?

I've started playing around with something similliar to nvfetcher with a few key differences

  1. you don't have to declare fetch (just src)
  2. My intentions are to generate overlays, with metadata, using platform apis (github, gitlab, openvsx, vscode).

@Pacman99
Copy link
Member

Follow up question, how much reliant is devos on nvfetcher?

We made a general decision to use nvfetcher over flakes for updating srcs because it was a cleaner solution that was built for the use case. But if another solution is better, I'm sure minds can be changed :). We would have to run through a similar discussion/debate again.

@blaggacao
Copy link
Contributor

blaggacao commented Aug 12, 2021

@Th3Whit3Wolf this time sorry for me chiming in late for the same reason as yours.

Well, one day, if subflakes get really advanced, we might even want to switch something flake compatible, since there is a benefit in creating a SBOM easily from the flake.lock.

Ideally flakes would gain the capability to make use of a library (such as nvchecker that already has wide platform support and an upstream community momentum).

vim-ext can be also really small. The point in having it in a repo also is a bit not having it in devos or digga (for now). The reason is that all those editors might a) either have their own dynamic and benefit from a separate release schedule for the users (nix flake lock --update-input vim-ext). Another reason is that beyond some initial preferences of Tim, we would probably try to avoid being opinionated with anything that doesn't directly relate to flakes/nix. So by making it a separate repo, we essentially avoid "pissing of" those who don't use X or Y. A third reason is maintenance and support. If the project grows, then it will be helpful to forward vim-ext issues to the repo in order to create "tighter" feedback cycles between authors and users and convert users more easily into co-authors / co-maintainers once they find a tiny and easy to understand codebase. vs-ext / vim-ext can well be the 'entry drug' heheheh. 😄

@Th3Whit3Wolf
Copy link
Author

@blaggacao I have been selected for a program that will likely eat up all of my free time for the next 7 months. I do not how soon I will be able to commit to vim-ext.

@blaggacao
Copy link
Contributor

@Th3Whit3Wolf Thanks for letting us know. I think you already did a good start to kick off vim ergonomics with devos. Now the strategically most important task is maybe to broaden the user base and get morenusers of various ecosystems onvoarx.

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.

4 participants