atagen

monolith

public
Star0
Watch0
57f44a63d99fcb7fd41d1b2b40ec8f7e2149cea9
1
ssh://brewery@pls.lobotomise.me:33/atagen/monolith.git
flake.nixNix97 lines2.4 KB
1
{
2
  inputs = {
3
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4
    crane.url = "github:ipetkov/crane";
5
  };
6
7
  outputs =
8
    {
9
      self,
10
      nixpkgs,
11
      crane,
12
    }:
13
    let
14
      lib = nixpkgs.lib;
15
      systems = [
16
        "x86_64-linux"
17
        "aarch64-linux"
18
      ];
19
      forAllSystems = f: lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
20
21
      mkProject =
22
        pkgs:
23
        let
24
          craneLib = crane.mkLib pkgs;
25
          src = craneLib.cleanCargoSource ./.;
26
          lavapipeIcd = "${pkgs.mesa}/share/vulkan/icd.d/lvp_icd.${pkgs.stdenv.hostPlatform.parsed.cpu.name}.json";
27
          commonArgs = {
28
            inherit src;
29
            strictDeps = true;
30
            nativeBuildInputs = [ pkgs.pkg-config ];
31
            buildInputs = with pkgs; [
32
              libxkbcommon
33
              vulkan-loader
34
            ];
35
          };
36
          cargoArtifacts = craneLib.buildDepsOnly commonArgs;
37
        in
38
        {
39
          inherit craneLib lavapipeIcd commonArgs;
40
41
          package = craneLib.buildPackage (
42
            commonArgs
43
            // {
44
              inherit cargoArtifacts;
45
              doCheck = false;
46
            }
47
          );
48
49
          checks = {
50
            clippy = craneLib.cargoClippy (
51
              commonArgs
52
              // {
53
                inherit cargoArtifacts;
54
                cargoClippyExtraArgs = "--all-targets -- --deny warnings";
55
              }
56
            );
57
            fmt = craneLib.cargoFmt { inherit src; };
58
            test = craneLib.cargoTest (
59
              commonArgs
60
              // {
61
                inherit cargoArtifacts;
62
                VK_DRIVER_FILES = lavapipeIcd;
63
              }
64
            );
65
          };
66
        };
67
    in
68
    {
69
      packages = forAllSystems (pkgs: {
70
        default = (mkProject pkgs).package;
71
      });
72
73
      checks = forAllSystems (pkgs: (mkProject pkgs).checks);
74
75
      devShells = forAllSystems (
76
        pkgs:
77
        let
78
          project = mkProject pkgs;
79
        in
80
        {
81
          default = project.craneLib.devShell {
82
            inputsFrom = [ project.package ];
83
            packages = with pkgs; [
84
              rust-analyzer
85
              vulkan-tools
86
              vulkan-validation-layers
87
              tracy
88
            ];
89
            LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.vulkan-loader ];
90
            LAVAPIPE_ICD = project.lavapipeIcd;
91
          };
92
        }
93
      );
94
95
      formatter = forAllSystems (pkgs: pkgs.nixfmt);
96
    };
97
}