Now, after many articles, I finally read the nix-pill about derivations. I realized, it's actually very simple: All the nix code evaluates to data structures called derivations. A derivation is a json-like data structure which has a few fields that describe how to build a package in the nix-store. Basically build time dependencies, runtime dependencies and a command to produce artifacts.
My suggestion - try writing a Flake or package file for a simple binary project. Adjusting that same "happy path" to work for other projects is usually as simple as Googling "nix flake $LANGUAGE template".