felixfung / skippy-xd

A window selector for X11 with Exposé and live preview Alt-Tab effects and more
GNU General Public License v2.0
19 stars 2 forks source link

feat: add flake.nix #95

Closed Lenivaya closed 1 month ago

Lenivaya commented 5 months ago

Nix flake

Adds the ability to easily track and use the latest version of skippy-xd for NixOS users.

felixfung commented 5 months ago

Nice!

Can you please create on the root directory a "Packages" directory, then put in "DEBIAN" and "Nix" or "NixOS" as subdirectories?

Lenivaya commented 5 months ago

Can you please create on the root directory a "Packages" directory, then put in "DEBIAN" and "Nix" or "NixOS" as subdirectories?

In terms of functionality, flake.nix is not quite the same as the Debian package. Flake can be thought of as a function that takes some input (other directories, repositories that also contain flake.nix files), locks those input versions so that the output can be cached (flake.lock), and gives reproducible output (binary in this particular situation). Since this repository will also be used by the end user as an input, it will be necessary to fix the version of the repo by commit hash, and the flake itself (since it's the thing that's being cached) will need to have access to the source code, so it must sit at the root of repository.

Flake is not a thing used only for packaging, for example besides packaging skippy-xd it may be possible to define some auto-formatting workflow with dependencies like clang-format (or any other code formatters/linters), and then execute their cached versions (since dependencies i.e. function/flake argument versions are fixed in flake.lock) on github action to reformat code.

If you're interested, I may create such a github action workflow with other PR, which will format the code on trunk merges based on Microsoft or Linux kernel style guidelines, if it'll make your development of this useful software a bit easier.

felixfung commented 5 months ago

Stupid quesion from me: why can't we simply update https://github.com/NixOS/nixpkgs/blob/3d06f73179401bcce967c5a5b54cc7005cb26348/pkgs/tools/X11/skippy-xd/default.nix?

P.S. NixOS looks very interesting :)

Lenivaya commented 5 months ago

Stupid quesion from me: why can't we simply update NixOS/nixpkgs@3d06f73/pkgs/tools/X11/skippy-xd/default.nix?

I'll definitely create a PR in nixpkgs with proposal of migration to your fork as one being actively developed, but a bit later. Flake is different from updating package in nixpkgs, because it gives user a way to "self-maintain" a version of a package without really knowing what's going on in nixpkgs (he doesn't need to create PR if he just wants to update to the latest version, he doesn't need to wait for the update availability if it has been merged but is currently floating between unstable and stable channels, he doesn't need to update his nixpkgs input etc).

For example consider some user having such a piece of system configuration he uses:

nixpkgs.url = "nixpkgs/nixos-unstable";
skippy-xd = {
  url = "github:felixfung/skippy-xd";
  inputs.nixpkgs.follows = "nixpkgs";
};
{inputs, ...}: {nixpkgs.overlays = [inputs.skippy-xd.overlays.default];}

If he suddenly wants to update skippy-xd to latest version he will just run this update over only one input:

nix flake lock --update-input skippy-xd

Voilà! Now the system will build with the latest version of skippy, with no changes to the skippy repo, no changes to the nixpkgs repo, just this input updated on the user side.

Lenivaya commented 4 months ago

In any case, I also updated the version used in nixpkgs with nixos/nixpkgs#307305

felixfung commented 4 months ago

I messed up the git history, that's what pushed so many commits....

I'll focus on fixing that before I can review your pr

felixfung commented 3 months ago

Hi @Lenivaya I thought about it a bit. I guess I don't understand Nix enough to feel comfortable with this. I guess NixOS/nixpkgs@3d06f73/pkgs/tools/X11/skippy-xd/default.nix together with your fork would suffix?