Nix Flakes + NixOS / configuration.nix, How to install a flake decleratively

Hello everyone,

I tried to ignore and tip-toe around flakes for so long in Nix, but it seems like they are inevitable.
What is very odd to me is, no matter any keyword I search I don’t find fast usable answer to this question: How can I install software distributed as flake on my configuration.nix without changing lots of things? and oddly, I find any sort of result, but nothing which answer this. Right now that I’m writing this, I’m checking “your topic is similar to…” section, still no real result.

At this point I questioned Is it impossible? I literally found stuff to make it easier for flake writers to ease the process of installing on configuration, but nothing for end nixos user, I would appreciate any help, maybe I’m just too bad at searching this

It depends on how your flake and the other flake are written.

Usually you add the other flake to the inputs and thread your inputs through to where you need it and use it there.

There are several ways to do this, depending on your exact use case.

  1. Pass the inputs around as an additional function argument
  2. Use specialArgs for nixos configuration or extraSpecialArgs for HM to get the inputs as additional attributes in the modules argset.
  3. Use _module.args in an inline module to do the same
  4. Use an inline overlay to get the inputs into pkgs.

Details depend on whether the foreign flake exports modules or packages or overlays.

So there is no pkg to simplify this process?
Can I implement these with 4th way?

The packages I need to get installed are emacs-ng and ACross

There are tools that abstract away a lot of inter flake management, though they do a lot more and I usually suggest to not use them.

Therefore I can’t say which can do what exactly.

I know though, emacs-ng provides an overlay already, which you could just apply.

Then you could use it directly from pkgs within your modules.

I have no clue about across. And Google doesn’t give me any useful result.

this is the GitHub repo of ACross and this is its flake.

Also, is there any fast-paced article or video about the topic?

That flake directly has an overlay as well.

And I’m not aware of any fast paced videos.

Though I know there are some Flakes out there on GitHub that use any of the 4 described methods.

As both flakes still follow the old flake scheme as far as I have seen, adding the following to your systems module list should be enough to access their respective packages via pkgs.

{ nixpkgs.overlays = [ emacs-ng.overlay across.overlay ]; }

This snippet assumes you added the individual inputs to the argset destructuring of the outputs function and that they have these obvious names.