3 ms·
Your translation is incomplete. You're ending with: > ({ pkgs }) => ({ deps = [ pkgs.cowsay ]; }) But the syntax for declaring objects in javascript differs
by TheDong 5y ago
Your translation is incomplete. You're ending with:
> ({ pkgs }) => ({ deps = [ pkgs.cowsay ]; })
But the syntax for declaring objects in javascript differs. It would be:
({ pkgs }) => ({ deps: pkgs.cowsay })
The fact that '{ x = 1; }' is declaring an object, identical to '{x: 1}' in javascript, is important.
It's also worth pointing out that, while '{ pkgs }:' is idiomatic nix, idiomatically in javascript you'd probably just take multiple arguments (so '(pkgs) =>', not '({ pkgs }) =>' in js). The reason nix uses an object there is because a nix function only takes one argument, so there's a fairly common convention to make that argument an attr in order to simulate multiple arguments. That convention doesn't exist in quite the same way in js.
- ronenlh 5y agoYou forgot the array ({ pkgs }) => ({ deps: [pkgs.cowsay] }) I also translate all nix to JavaScript in my brain