summaryrefslogtreecommitdiff
path: root/nix-turing/loop.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix-turing/loop.nix')
-rw-r--r--nix-turing/loop.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/nix-turing/loop.nix b/nix-turing/loop.nix
new file mode 100644
index 0000000..2849d6a
--- /dev/null
+++ b/nix-turing/loop.nix
@@ -0,0 +1,26 @@
+# defeats the recursion checks of nix and will cause it to
+# loop infinitely. well, almost, anyways.
+#
+# annoyingly, nix doesn't have tail recursion, so actually
+# it'll eventually terminate with a stack overflow.
+let
+ pkgs = import <nixpkgs> {};
+ writeTextVerbose = file: content: pkgs.stdenv.mkDerivation {
+ name = file;
+ src = pkgs.hello;
+ buildPhase = ''
+ echo ${pkgs.lib.escapeShellArg content} > $out
+ '';
+ installPhase = ''
+ echo wrote file to $name
+ '';
+ };
+ storefile = v: writeTextVerbose "nixfile" ''
+ {
+ x = ${toString v};
+ }
+ '';
+ loop = a:
+ let file = import (storefile a);
+ in if file.x == 1 then loop a else "done";
+in loop 1