Hey all.
I’m trying to figure out how overlays work in flakes. I would appreciate it if you can tell me what steps to take and why.
For example, there is a package called espanso.
Currently, the version in nixos unstable repository is 0.7.3 and I’m trying to install the tag version 2.1.0-alpha from github.
I would prefer to use the services.espanso.enable in my configuration.nix for the sake of simplicity, however there is no services.espanso.package option available. (though I’m not insisting on this option if it cause more complexity than otherwise)
My dotfiles structure is as follows:
dotfiles
├── system # system level configs
│ ├── configuration.nix
│ └── ...
├── user # home-manager and other dotfiles
│ ├── home.nix #
│ ├── alacritty
│ └── ...
├── flake.nix
└── ...
Other information: espanso is at "github:federico-terzi/espanso" and it offers no flakes. It is also written in rust. Please consider that these are for the sake of example, and I really hope to learn the simplest workflow (and hopefully a bit about how flake files and overlays work).
I have read a lot of dotfiles but couldn’t understand why they did what they did, what was necessary and how I can implement similar things.
My endless appreciations, in advance
The easiest way to use overlays with a flake is to use something like flake-utils-plus to manage your flake. To add an overlay a channel, just specify it in your channels.<channel>.overlayBuilder function. You can see an example of this in my configs repo.
If you want to do things manually or don’t want to make the changes needed to move to a flake library, you can include an attribute set in the modules that you pass to the nixosSystem. For example:
# Assume that `system` specifies the current system (e.g., x86_64-linux),
# and that `espansoRepo` is an input with the `espanso` package
# in a `packages` attribute.
nixosConfigurations.<hostname> = nixpkgs.lib.nixosSystem {
modules = [
{
nixpkgs.overlays = [
(_: _: { espanso = espansoRepo.packages.${system}.espanso; })
];
}
# other modules, etc
];
};
Thanks for your suggestion.
I’m trying nix-utils-plus. I’m however not sure exactly how I should achieve it. I made a flake based on the examples on the github page + your dotfiles. And I got this error:
error: source tree referenced by 'github:federico-terzi/espanso/f7fdb06db89fe6f33c92c9bb2568cbfa40761028' does not contain a '/flake.nix' file
I’d probably just copy the derivation, update it to build the build the 2.1.0-alpha, and include that in the overlay.
I put together a gist of what that might look like. It’s still building, so I don’t know if it works (though I don’t have a desktop Linux system to test anyway).
Alas, the build failed again. It looks like Espanso also depends on wxWidgets. I updated the gist to add wxGTK31. Hopefully that’s the last of them. I think the other ones mentioned on the project’s GitHub page are already included.