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

Refactor Nix Flake #1093

Merged
merged 6 commits into from Jun 6, 2023
Merged

Conversation

getchoo
Copy link
Member

@getchoo getchoo commented May 27, 2023

this makes a few opinionated changes to the flake, mainly moving from flake-utils to flake-parts. i think this is a good fit for the project as we already had other functions separated into the nix/ folder, and flake-parts allows us to do this in a much more efficient way.

other notable changes include using the overlay from self to create the packages attrset (since there's not much point in fully evaluating a package function twice), adding nil as a pre-commit hook, and officially setting the formatter to alejandra after 9dff1ba

i have also enabled nix lockfile maintenance for renovate, which should help us make sure we're able to consistently build against latest unstable :)

Signed-off-by: seth <getchoo@tuta.io>
Signed-off-by: seth <getchoo@tuta.io>
Signed-off-by: seth <getchoo@tuta.io>
Signed-off-by: seth <getchoo@tuta.io>
@Scrumplex Scrumplex self-requested a review May 28, 2023 12:44
@Scrumplex Scrumplex added this to the 7.0 milestone May 28, 2023
@Scrumplex Scrumplex added packaging Issues and PRs related to packaging (CI builds or package managers) Linux Issues and PRs related to Linux specifically labels May 28, 2023
@Scrumplex Scrumplex changed the title (slightly) overhaul nix flake Refactor Nix Flake May 28, 2023
@Scrumplex
Copy link
Member

I wonder if it might be time to just override the packages from nixpkgs.

We only really need to replace version, src and some of the build inputs. Should all be doable using overrideAttrs

@getchoo
Copy link
Member Author

getchoo commented May 28, 2023

since we like to keep both packages in sync, i think that would actually be a great idea!

i would only be concerned over desynchronizations, where our locked version of nixpkgs is behind a recent change. this doesn't seem like a major deal though, as with renovate updating inputs we would only be out of sync for a week at most. plus, the user always has the option to use their own version of nixpkgs; so if we document that in NIX.md, i wouldn't really see any issue

@getchoo
Copy link
Member Author

getchoo commented May 28, 2023

i tried to also add the new unwrapped packages with the following diff, but it seems the qt5 wrapped packages attempts to build against the qt6 unwrapped package with this (with or without the prismlauncher-unwrapped input being overridden). i'm not sure what's going on here, but since unwrapped packages are a bit niche as is, i'll leave it up to you to decide if this is a blocker or not :p

index a460723a..4c1081a6 100644
--- a/nix/distribution.nix
+++ b/nix/distribution.nix
@@ -5,13 +5,13 @@
 }: {
   perSystem = {pkgs, ...}: {
     packages = {
-      inherit (pkgs) prismlauncher prismlauncher-qt5;
+      inherit (pkgs) prismlauncher prismlauncher-qt5 prismlauncher-unwrapped prismlauncher-qt5-unwrapped;
       default = pkgs.prismlauncher;
     };
   };

   flake = {
-    overlays.default = _: prev: let
+    overlays.default = final: prev: let
       # Helper function to create overrides from multiple versions of prism.
       mkPrism = prism:
         prism.overrideAttrs (_: {
@@ -20,7 +20,9 @@
         });
     in {
       prismlauncher = mkPrism prev.prismlauncher;
-      prismlauncher-qt5 = mkPrism prev.prismlauncher-qt5;
+      prismlauncher-qt5 = mkPrism (prev.prismlauncher-qt5.override {prismlauncher-unwrapped = final.prismlauncher-qt5-unwrapped;});
+      prismlauncher-unwrapped = mkPrism prev.prismlauncher-unwrapped;
+      prismlauncher-qt5-unwrapped = mkPrism prev.prismlauncher-qt5-unwrapped;
     };
   };
 }

@Scrumplex
Copy link
Member

Okay this won't work as well as I thought. We have some slight cmakeFlags changes in 7.0 as well, and it's kinda annoying overriding those without duplicating a lot of code. Let's just keep our own packages instead.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Signed-off-by: seth <getchoo@tuta.io>
@Ryex
Copy link
Contributor

Ryex commented Jun 4, 2023

I don't know enough about nix to really say yay or nay on this...

Copy link
Contributor

@Ryex Ryex left a comment

Choose a reason for hiding this comment

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

I can't see anything wrong and it has scrumps approval so... 👍

@TheKodeToad
Copy link
Member

You are one of the maintainers of all time! :P

@Scrumplex Scrumplex merged commit 7e016c4 into PrismLauncher:develop Jun 6, 2023
14 checks passed
@getchoo getchoo deleted the use-flake-parts branch June 6, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux Issues and PRs related to Linux specifically packaging Issues and PRs related to packaging (CI builds or package managers)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants