Importing a nix file results in an error of anonymous function called with unexpected argument 'system'

Viewed 13

I'm trying to set a variable to the result of a function defined in an external file.

Within my nixos config I have something like:

let 
  phpFile = import ./tgsend.nix (pkgs);
in
{
...
}

Where phpFile = import ./tgsend.nix (pkgs); is the new line I added. Calling this function results in an error of:

error: anonymous function at /etc/nixos/tgsend.nix:1:1 called with unexpected argument 'system'

   at /etc/nixos/services.nix:8:13:

        7|   myxmonad = import sources.XMonadLayouts {}; #
        8|   phpFile = import ./tgsend.nix (pkgs);
         |             ^
        9|   in (use '--show-trace' to show detailed location information)

What am I doing wrong?

The contents of tgsend.nix is:

{pkgs}: pkgs.writeText "test.php" "<?php echo 'hello world'; "
1 Answers

Changing the tgsend.nix file to instead be:

{pkgs, ...}: pkgs.writeText "test.php" "<?php echo 'hello world'; "

Essentially adding ,... to the function parameters. Not quite sure why this solves this though... Possibly something to do with https://nixos.org/guides/nix-pills/nixpkgs-parameters.html#idm140737319673792


Alternatively as mentioned in @BlackBeans comment: pkgs: pkgs.writeText "test.php" "<?php echo 'hello world'; " also works

Related