laamaa / m8c

Cross-platform M8 tracker headless client
Other
409 stars 85 forks source link

Use a Nix Flake for m8c #160

Closed pope closed 1 month ago

pope commented 2 months ago

Flakes are a different way to specify a Nix project/configuration. It provides a few benefits over the existing solution:

  1. The exact versions of inputs are snapshot. This should mean that a build on one machine will use the exact same packages as the build on another.
  2. Flakes can be consumed by other Flakes. This would mean that folks could use this Flake as an import and then declaritively configure their m8c setup.
  3. While not used here now, this could make versioning easier. There wouldn't need to be a fetchFromGitHub step because someone could just use/run the app for that tagged branch. Ex: nix run github:laamaa/m8c?ref=v1.7.7

That said, this PR does rely on flake-compat to provide backward compatibility with default.nix and shell.nix. So a user could use nix-shell as before, or they could use nix develop (and potentially devenv in the future).

pope commented 2 months ago

Hi. This was a shot in the dark to see if this is something you would be interested in leveraging in the Nix part of the codebase. If not, no hard feelings or anything like that.

I also didn't mention that one thing this flake does differently is that it installs treefmt. With it, you can run nix fmt or treefmt from install a shell and then the nix files will get formatted and checked for unused values. There's also a clang format option that can easily be turned on to quickly format all C files in the source too.

laamaa commented 2 months ago

Hi! Thanks for the PR. I personally haven't ever used Nix so I don't have much of an opinion on this... The current system is nice for (at least for me) in the way, that it updates the package definition file automatically on new releases and I'd hope to keep it so that there's no manual work required.

Maybe some other Nix users could comment on this too?

pope commented 1 month ago

Good point about the self-updating package definition. I missed that it was done in a workflow and I added that change. That said, I am not totally sure how to test that flow. I don't want to add something that changes what you're used to - but adds some extra nix things for flake users.

laamaa commented 1 month ago

Thanks, looks good to me :)