How to retrieve a specific package or module from an URL in a flake


I have a flake in which I would like to pick one package definition from another repo to be used in the installation. I use an overlay to do so but it ends up with an error:

> error: The store path /nix/store/0ixi2fkb0s84zgapfbi96y4209a72jjb-default.nix is a file and can't be merged into an environment using pkgs.buildEnv! at /nix/store/ line 122.
       For full logs, run 'nix log /nix/store/9m9k5aw27lwbvg9nrxgp39vgjqvl4774-system-path.drv'.

Here is my definition:

  nixpkgs.overlays = [
    (final: prev: {
      teams-for-linux = builtins.fetchurl {
        url = "";
        sha256 = "sha256:07v9nzmg05g50jmknr72wbr37r92y3slaf08q2kw8if70yxxd4yf";
 systemPackages = with pkgs; [

I have the same issue if I want to add a module and not a package for instance with:

   (builtins.fetchurl {
              url = "";
              sha256 = "sha256:0v02xyjkx1mhh00w5f9b0rviny1mz5gzxv25crf9c2z8xw9mwdq5";

I am maybe not using correctly the overlays. Any idea?

  • You don’t need overlays for this. Overlays are specifically for replacing packages that are depended on by other things in nixpkgs, and having it propogate through. You can just put an expression directly in environment.systemPackages in this case.
  • You need to import it: environment.systemPackages = [ (import (builtins.fetchurl { ... })) ];

Thanks ! This helped me solve the problem