From 7b87b2ccbb77658617f008306828dd16459fa63a Mon Sep 17 00:00:00 2001 From: sterni Date: Thu, 1 Dec 2022 17:24:54 +0100 Subject: feat(sterni/exercises/aoc/2022): add basic scaffolding I currently plan doing BQN and Nix (where it is not too annoying, respectively). All solutions can either be executed together in a derivation using CBQN and Tvix (!!!) or executed individually (I'll do one file per solution for BQN and an attribute set of solutions for Nix in a single file). Change-Id: I7cff2ea60d06ae0f586d07779f14f5edd8f87aae Reviewed-on: https://cl.tvl.fyi/c/depot/+/7489 Reviewed-by: sterni Tested-by: BuildkiteCI --- users/sterni/exercises/aoc/.gitignore | 3 +- users/sterni/exercises/aoc/2022/.skip-subtree | 1 + users/sterni/exercises/aoc/2022/README.md | 8 ++++ users/sterni/exercises/aoc/2022/default.nix | 67 +++++++++++++++++++++++++++ users/sterni/exercises/aoc/2022/nix.nix | 3 ++ 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 users/sterni/exercises/aoc/2022/.skip-subtree create mode 100644 users/sterni/exercises/aoc/2022/README.md create mode 100644 users/sterni/exercises/aoc/2022/default.nix create mode 100644 users/sterni/exercises/aoc/2022/nix.nix diff --git a/users/sterni/exercises/aoc/.gitignore b/users/sterni/exercises/aoc/.gitignore index de53cfc531..b9720d7451 100644 --- a/users/sterni/exercises/aoc/.gitignore +++ b/users/sterni/exercises/aoc/.gitignore @@ -1 +1,2 @@ -/*/input \ No newline at end of file +/*/input +/*/*/input \ No newline at end of file diff --git a/users/sterni/exercises/aoc/2022/.skip-subtree b/users/sterni/exercises/aoc/2022/.skip-subtree new file mode 100644 index 0000000000..39d1894495 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/.skip-subtree @@ -0,0 +1 @@ +nix solutions don't use readTree and the rest is non-nix diff --git a/users/sterni/exercises/aoc/2022/README.md b/users/sterni/exercises/aoc/2022/README.md new file mode 100644 index 0000000000..9274265305 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/README.md @@ -0,0 +1,8 @@ +# sterni's [Advent of Code 2022](adventofcode.com/2022) + +I'm trying to do it in BQN again to redeem myself for my unfinished [AoC 2021](../2021), +but will allow myself falling back to another language if I get stuck, so I actually +complete this one. +I also plan to write additional solutions in Nix (when I have the time) in order to +throw `//tvix/eval` against some new problems. +We'll see how it goes, as my December promises to be quite busy. diff --git a/users/sterni/exercises/aoc/2022/default.nix b/users/sterni/exercises/aoc/2022/default.nix new file mode 100644 index 0000000000..ef03cd87e1 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/default.nix @@ -0,0 +1,67 @@ +{ depot, pkgs, lib, ... }: + +let + inherit (pkgs.buildPackages) cbqn; + + # input files are not checked in + meta.ci.skip = true; +in + +depot.nix.readTree.drvTargets { + shell = pkgs.mkShell { + name = "aoc-2022-shell"; + packages = [ + cbqn + depot.tvix.eval + ]; + }; + + bqn = pkgs.runCommand "bqn-aoc-2022" + { + nativeBuildInputs = [ + cbqn + ]; + + aoc = builtins.path { + name = "bqn-aoc-2022"; + path = ./../.; + # Need lib.bqn from ../ and all inputs as well as bqn files from ./* + filter = path: type: + lib.hasSuffix ".bqn" path || ( + lib.hasPrefix (toString ./.) path + && ( + type == "directory" + || lib.hasSuffix "/input" path + ) + ); + }; + + inherit meta; + } + '' + find "$aoc/2022" -name '*.bqn' -exec BQN {} \; | tee "$out" + ''; + + nix = import ./nix.nix { inherit lib; }; + + tvixed-nix = pkgs.runCommand "tvix-aoc-2022" + { + nativeBuildInputs = [ + depot.tvix.eval + ]; + solutions = builtins.path { + name = "nix-aoc-2022"; + path = ./.; + filter = path: type: + type == "directory" + || lib.hasSuffix "nix.nix" path + || lib.hasSuffix "/input" path; + }; + + inherit meta; + } + '' + tvix-eval -E "import $solutions/nix.nix { lib = import ${pkgs.path}/lib; }" \ + | tee "$out" + ''; +} diff --git a/users/sterni/exercises/aoc/2022/nix.nix b/users/sterni/exercises/aoc/2022/nix.nix new file mode 100644 index 0000000000..5bd3e36b53 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/nix.nix @@ -0,0 +1,3 @@ +{ ... }: + +{ } -- cgit 1.4.1