about summary refs log tree commit diff
path: root/users/sterni/exercises/aoc/2022/default.nix
blob: 23dc2ef70103a4644c4cbc16ba4ff9c765495d66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ depot, pkgs, lib, ... }:

let
  inherit (pkgs.buildPackages) cbqn ngn-k;

  # input files are not checked in
  meta.ci.skip = true;
in

depot.nix.readTree.drvTargets {
  shell = pkgs.mkShell {
    name = "aoc-2022-shell";
    packages = [
      cbqn
      ngn-k
      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"
    '';
}