Determine syntax issue, during binary file provisioning into NixOS

I’m trying to provision binary file into NixOS and make it as a usable package inside a system. For this purposes, I created config file with usage of pkgs.overlays:

{ pkgs, ... }:
{
  nixpkgs.overlays = [(self: super: {
    nginxAuth = pkgs.fetchurl = {
      url = "https://github.com/dcmediahosting/nginx-mail-auth-http/releases/download/1.0.1/nginx-mail-auth-http-linux-amd64";
      sha256 = "1687ee47e687b181e761840226dce6f1d03f5442dee105a1a1958fd2bb82bc79";
    };
  })];

  environment.systemPackages = [ pkgs.nginxAuth ];
}

But, while trying to perform nixos-rebuild switch, I obtain:

error: syntax error, unexpected '=', expecting ';', at /etc/nixos/nginx-auth.nix:4:31
(use '--show-trace' to show detailed location information)
building Nix...

What can be a problem in my file, that prevents from it being built and orchestrated into NixOS?

The first thing is that you have an extra = here:

pkgs.fetchurl = {
              ^

pkgs.fetchurl is a function that takes an arguments. Function calls are written foo arg, so there shouldn’t have been a =. (In the error message at /etc/nixos/nginx-auth.nix:4:31 points to line 4 column 31, which is exactly this character.)

Another thing is that whatever file you downloaded probably doesn’t have executable permission and isn’t put into the right directory. An executable needs to be in the bin directory of the output path to be ‘installed’ and recognized, and a bare file probably wouldn’t work. A little runCommand trick should do the job, I’ll see if I can cough up something.

Well I haven’t tried yet but this wiki page should get you going: https://nixos.wiki/wiki/Packaging/Binaries