I need to create shell script inside NixOS, and then use it declaratively. For such situation, NixOS can provision shell script inside the system, but I bumped into troubles of invoking this script after installation. For putting shell script inside the system, I used this code snippet:
{ pkgs, ... }:
let
helloWorld = pkgs.writeScriptBin "helloWorld" ''
#!${pkgs.stdenv.shell}
echo Hello World
'';
in {
environment.systemPackages = [ helloWorld ];
}
package, named helloWorld
successfully installed into the system, but then, when I try to put it inside another file, this way
environment.etc."webhook.conf".text = ''
[
{
"id": "webhook",
"execute-command": "${pkgs.systemPackages}/bin/helloWorld",
"command-working-directory": "/tmp"
}
]
or
environment.etc."webhook.conf".text = ''
[
{
"id": "webhook",
"execute-command": "${pkgs.helloWorld}/bin/helloWorld",
"command-working-directory": "/tmp"
}
]
on nixos-rebuild switch
it bumps into this error: error: attribute 'systemPackages' missing
(or error: attribute 'helloWorld' missing
for second variant of invokation)
What I'm doing wrong? I need path to helloWorld package appear inside webhook.conf
file in /etc
directory