See https://discourse.nixos.org/t/no-hashes-starting-with-e-t-o-or-u-in-nix-store/4906/33 for context
Generate a fortunes
file with quotes to pick from:
nix-shell -p fortune --run "rot < $(dirname $(which fortune))/../share/fortunes/off/sex > fortunes"
Find a derivation with the desired prefix:
$ ./run hi 8
Brute forcing a store path with prefix "hi"
The prefix length 2 means that on average 32^2 = 1024 tries are necessary
Using 8 cores in parallel
No hit for n = 7
No hit for n = 5
No hit for n = 4
No hit for n = 2
No hit for n = 1
No hit for n = 3
[...]
No hit for n = 1459
No hit for n = 1455
No hit for n = 1452
No hit for n = 1458
No hit for n = 1456
No hit for n = 1461
No hit for n = 1449
Successfully found target in path "/nix/store/hi3crcn3fkjhzjcd725b9fsjxi9vl2b5-hi" with try n = 1462, saving fortune to hits/hi/1462
$ nix-build --argstr name hi --argstr fortune "$(cat hits/hi/1462)"
this derivation will be built:
/nix/store/0b5wh73jhnrfb1q9n7j7lq2dnvwc2b1l-hi.drv
building '/nix/store/0b5wh73jhnrfb1q9n7j7lq2dnvwc2b1l-hi.drv'...
/nix/store/hi3crcn3fkjhzjcd725b9fsjxi9vl2b5-hi
GPL 3.0 or later