Howto merge a derivation.nix to /etc/nixos/configuration.nix

hi all,
I wrote a simple derivation to install an epub reader (thorium):
https://discourse.nixos.org/t/howto-install-epub-reader-thorium/12794

Currently I just install it via nix-build in the directory containing the derivation.nix.
Is there a way to merge the derivation.nix with my /etc/nixos/configuration, so that thorium would build via nixos-rebuild?

One way is to commit to nixpkgs for review, and then once you’ve gone through that , you learn a lot about how nixpkgs hangs together. Mainly how the ‘toplevel.nix’ operates and the function abstraction that is called 'callpackage'.

The best thing about that , is that others can then use your work to install it themselves. However if you don’t want to interface with the love/hate of git, then you still have options to get your package into nixpkgs.

Once it’s merged into nixpkgs then it’s easy for other to just build into their systems. However this something that flakes of the future will means to address.

I recommend you go down the commit to nixpkgs route, and there plenty of help available.

1 Like

Just do the same you showed in your post in your configuration.nix.

{ pkgs, ... }:
{
  environment.systemPackages = [
    (pkgs.callPackage ./path/to/derivation.nix)
  ];
}

Then your package will be available for all users of that system.

3 Likes