"notch, groove, slit," late 15c., nyke, of unknown origin, possibly influenced by M.Fr. niche "niche." The verb is first attested 1520s. Sense of "to steal" is from 1869, probably from earlier slang sense of "to catch, take unawares, arrest" (1620s). Nick of time is first attested 1640s, possibly from an old custom of recording time as it passed by making notches on a tally stick, though the general sense of "critical moment" is older (1570s) than the phrase.
just in time. At the last moment, as in The police arrived in the nick of time, or He got there just in time for dinner. The first term began life as
in the nick and dates from the 1500s, when nick meant “the critical moment” (a meaning now obsolete). The second employs just in the sense of “precisely” or “closely,” a usage applied to time since the 1500s. Also see in time, def. 1.