Can't nix copy - `bash: line 1: nix-store: command not found`

Hey, I’m running this script

#!/bin/bash
target_path=$(nix build .#packages.aarch64-linux.default --no-link --print-out-paths -L)
nix copy .#packages.aarch64-linux.default --to ssh://AAA@AAA.BBB.CCC.DDD

build is done just fine, but then this happens:

AAA@AAA.BBB.CCC.DDD’s password:
bash: line 1: nix-store: command not found
error: cannot connect to ‘AAA@AAA.BBB.CCC.DDD’

Any ideas on what i should check? I looked through the internet, some people seem to be having problems with not sourcing some files, but none of them worked for me. Thanks!