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

Revamp nix flake #215

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

Revamp nix flake #215

wants to merge 33 commits into from

Conversation

nixith
Copy link

@nixith nixith commented Apr 22, 2024

I decided to go with crane instead, it apparently has better caching capabilities. The check capabilities are nice as well if you ever want to add some stuff to gh actions, for example. If you ever add another cargo subprjoct or some random directory stuff it might need some extra work but it should mostly be fine. Happy to explain, at least at a high level, whatever is going on.

Also given how I did the commits it might be a good idea to just squash this down during the pull request, at least I think you can.

Currently this PR is waiting on #214, it works if you remove the Build.rs script locally.

@Ottatop
Copy link
Collaborator

Ottatop commented Apr 24, 2024

Alright this should be unblocked, if it's ready then rebase/merge with main and request a review

@nixith
Copy link
Author

nixith commented Apr 25, 2024

do we want to merge with the lua api complete or have that as a separate pull?

@Ottatop
Copy link
Collaborator

Ottatop commented Apr 25, 2024

Probably best to do it in a different pull considering the hell you're going through trying to make that work lol

@nixith
Copy link
Author

nixith commented Apr 28, 2024

Alright, we now have functional nix builds! I think the metaconfig.toml writer needs to be fixed up, for now it just pulls from the user's directory, but it's completely functional otherwise. I have examples here in case anyone wants some.

@Ottatop
Copy link
Collaborator

Ottatop commented Apr 29, 2024

Missed a slash omegalul

I'll try to review the parts I can figure out sometime this week, got a lot of stuff to do currently.

@@ -13,7 +13,7 @@ require("pinnacle").setup(function(Pinnacle)
---@type Modifier
local mod_key = "ctrl"

local terminal = "alacritty"
local terminal = "kitty"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm gonna need a very good reason why this has been changed to kitty because I like alacritty better and I will die on that hill

Copy link
Author

@nixith nixith May 1, 2024

Choose a reason for hiding this comment

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

Ah, see, the reason is because I'm a creature of habit who forgot to remove that change before commiting. V easy remove lol. It also looks like I forgot to remove some other changes I made in that file for testing purposes.

@@ -73,7 +73,7 @@ install-protos-root:
proto_dir="{{root_xdg_data_dir}}/protobuf"
rm -rf "${proto_dir}"
mkdir -p "{{root_xdg_data_dir}}"
cp -r "{{rootdir}}/api/protocol" "${proto_dir}"
cp -r "{{rootdir}}pinnacle-api-defs/protocol" "${proto_dir}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
cp -r "{{rootdir}}pinnacle-api-defs/protocol" "${proto_dir}"
cp -r "{{rootdir}}/pinnacle-api-defs/protocol" "${proto_dir}"

Also line 35 hasn't been updated

@Ottatop
Copy link
Collaborator

Ottatop commented May 1, 2024

@LogicalOverflow Seeing as you're the other Nix person here, do you have anything to comment on regarding all this Nix stuff I'm not familiar with?

Copy link
Contributor

@LogicalOverflow LogicalOverflow left a comment

Choose a reason for hiding this comment

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

(I didn't look much into the lua stuff, because I don't know lua)

Overall, I think most of the hard stuff is done, i.e building pinnacle and the config. Only how the two are merged together, and how the metaconfig.toml is handled throughout, to produce a pinnacle-with-config looks incomplete to me.

@@ -1,42 +1,58 @@
{
description =
"A WIP Smithay-based Wayland compositor, inspired by AwesomeWM and configured in Lua or Rust";
description = "Build a cargo workspace";
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is a copy-paste error :)

runtimeDependencies = with pkgs; [
wayland
mesa
libglvnd # libEGL
];

LD_LIBRARY_PATH =
"${pkgs.wayland}/lib:${pkgs.libGL}/lib:${pkgs.libxkbcommon}/lib";
"${pkgs.wayland}/lib:${pkgs.libGL}/lib:${pkgs.libxkbcommon}/${pkgs.libglvnd}/lib:${pkgs.mesa.drivers}/lib";
Copy link
Contributor

Choose a reason for hiding this comment

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

${pkgs.libxkbcommon}/${pkgs.libglvnd}/lib should probably be ${pkgs.libxkbcommon}/lib:${pkgs.libglvnd}/lib

devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};

runtimeDependencies = with pkgs; [
Copy link
Contributor

Choose a reason for hiding this comment

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

the wlcs wrapper script and cargo-outdated got lost along the way, I think

lib = pinnacleLib;
packages = {
inherit pinnacle protobuffs;
inherit (pinnacleLib) pinnacleWithRust pinnacleWithLua;
Copy link
Contributor

Choose a reason for hiding this comment

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

Having these two functions directly in packages, breaks nix flake check, because that expects all the packages to be derivations. Maybe we can move them to pinnacle.withRust and pinnacle.withLua using passthru.


fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do? (I've never seen a follows set to "")

};
#provide a default Toml, just in case. It may be more desireable to use

# NOTE: as of now I can't figure out a way to check if a file exists in another derivaion.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably not really possible at the nix level, i.e. in nix code, but you can probably use some bash in the postBuild on the symlinkJoin to select the correct metaconfig.toml.

pinnacle-unwrapped
pinnacle-config
protobuffs # protobuffs
#(manifestDerivation) # currently treated as a function rather than a derivation, should be fixable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, the passed manifest just isn't used. Also, symlinkJoin might just fails, if there is a collision between the joined derivations (which would be the case if both manifests are there).

mkdir $out/bin
mv target/release/${pname} $out/bin/
mv metaconfig.toml $out/share/pinnacle/config/
ln $out/bin/${pname} $out/share/pinnacle/config/${pname};
Copy link
Contributor

Choose a reason for hiding this comment

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

I do find this structure in the derivation a bit weird, with the config being in both share/pinnacle/config/pinnacle-config and bin/pinnacle-config. I would expected only next to the metaconfig.toml.

@nixith
Copy link
Author

nixith commented May 2, 2024

Pinnacle-with-config is partially working. For now it manages to get them all in the same closure and set up protobuf stuff, the main issue is that I can't figure out how to write from the toml generator to where I want correctly. It probably needs to be out of the symlink and linked in with ln manually if I had to guess, for now it uses the metaconfig.toml at the root of the config build directory.

@nixith
Copy link
Author

nixith commented May 2, 2024

I think metaconfig.toml's nix attrset should probably be moved into it's own lib output, that way people can debug that on its own, get type hints, etc. when this is all done I think nix has official doc comments now, so I'll go through and add them to make poking around for people a little easier as needed.

@Ottatop Ottatop mentioned this pull request May 8, 2024
33 tasks
@KDanisme
Copy link

Hi guys, any way I can help in this PR?
I really want to try out pinnacle, really like the concept.
@nixith If your busy I can pick off from where you left, or create a PR to your fork, LMK

@nixith
Copy link
Author

nixith commented Jul 14, 2024

Hi guys, any way I can help in this PR?
I really want to try out pinnacle, really like the concept.
@nixith If your busy I can pick off from where you left, or create a PR to your fork, LMK

Feel free to, I have been a little busy so the help is appreciated. If you also want to rework much of what I've done feel free. My solution relies on some wacky IFD that i've since learned is not great practice, but I really don't have a better way to conceive of this beyond having a directory to link to the configuration spot for Lia and 0 ideas on how to manage this without IFD for Rust. Thanks for pitching in!

@KDanisme
Copy link

KDanisme commented Jul 14, 2024

Hi guys, any way I can help in this PR?
I really want to try out pinnacle, really like the concept.
@nixith If your busy I can pick off from where you left, or create a PR to your fork, LMK

Feel free to, I have been a little busy so the help is appreciated. If you also want to rework much of what I've done feel free. My solution relies on some wacky IFD that i've since learned is not great practice, but I really don't have a better way to conceive of this beyond having a directory to link to the configuration spot for Lia and 0 ideas on how to manage this without IFD for Rust. Thanks for pitching in!

Happy to help
Whenever you get the chance, I would love for a tldr on the issue you had here.
Im not really sure what exactly is the blocker here.
Tried going through the comments but couldn't really figure it out, especially with this being a new project and all.

@nixith
Copy link
Author

nixith commented Jul 14, 2024

Hi guys, any way I can help in this PR?
I really want to try out pinnacle, really like the concept.
@nixith If your busy I can pick off from where you left, or create a PR to your fork, LMK

Feel free to, I have been a little busy so the help is appreciated. If you also want to rework much of what I've done feel free. My solution relies on some wacky IFD that i've since learned is not great practice, but I really don't have a better way to conceive of this beyond having a directory to link to the configuration spot for Lia and 0 ideas on how to manage this without IFD for Rust. Thanks for pitching in!

Happy to help
Whenever you get the chance, I would love for a tldr on the issue you had here.
Im not really sure what exactly is the blocker here.
Tried going through the comments but couldn't really figure it out, especially with this being a new project and all.

The tl;Dr is we need to wait for the lua or rust derivation to build flake-side, then wait for the user's configuration derivation to build, then finish building their config in place. I've learned since building this that this is generally considered bad practice, but it works for now. I think it was mostly style stuff that I never got around to fixing.

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