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

Hi,

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/yznq148yxflnvvafmdljbxf689vzrf7q-builder.pl 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 = "https://raw.githubusercontent.com/aacebedo/nixpkgs/913ca72e58d6d176b9813e190d618b2c7910552d/pkgs/applications/networking/instant-messengers/teams-for-linux/default.nix";
        sha256 = "sha256:07v9nzmg05g50jmknr72wbr37r92y3slaf08q2kw8if70yxxd4yf";
      };
    })
  ];
....
 systemPackages = with pkgs; [
     teams-for-linux
]

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

   (builtins.fetchurl {
              url = "https://raw.githubusercontent.com/aacebedo/nixpkgs/a148e728c9decbfcac401e7cb38a23208f3a2bb1/nixos/modules/services/desktops/playerctld.nix";
              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