A Curious Adventure in Implementing RNG and Cosine in Purely Functional Nix
2025-04-15

This post details the author's experience implementing a random number generator and a cosine function within NixOS, a Linux distribution built on the Nix language. The purely functional nature of Nix presents challenges when working with system randomness and standard mathematical functions. The author explores various approaches, including using Nix's `runCommandLocal` and custom infinite list implementations, ultimately overcoming caching and function-call quirks to achieve the goal. The journey highlights Nix's flexibility and power, but also exposes some limitations of its features.
Development