diff options
author | sterni <sternenseemann@systemli.org> | 2022-12-01T16·24+0100 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2022-12-01T23·50+0000 |
commit | 7b87b2ccbb77658617f008306828dd16459fa63a (patch) | |
tree | 9926810ba5e800ba6ebe504d97be442474d9251e /users/sterni/exercises/aoc/2022/default.nix | |
parent | 6abea467e2023a63e3413317c90409d11175f9a9 (diff) |
feat(sterni/exercises/aoc/2022): add basic scaffolding r/5363
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 <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'users/sterni/exercises/aoc/2022/default.nix')
-rw-r--r-- | users/sterni/exercises/aoc/2022/default.nix | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/users/sterni/exercises/aoc/2022/default.nix b/users/sterni/exercises/aoc/2022/default.nix new file mode 100644 index 000000000000..ef03cd87e173 --- /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" + ''; +} |