atagen

monolith

public
Star0
Watch0
b563d2da1c80c99c30a88deecf70fa7ba5c00d79
1
ssh://brewery@pls.lobotomise.me:33/atagen/monolith.git
flake.nixNix99 lines2.5 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
            pname = "monolith";
30
            version = "0.0.0";
31
            strictDeps = true;
32
            nativeBuildInputs = [ pkgs.pkg-config ];
33
            buildInputs = with pkgs; [
34
              libxkbcommon
35
              vulkan-loader
36
            ];
37
          };
38
          cargoArtifacts = craneLib.buildDepsOnly commonArgs;
39
        in
40
        {
41
          inherit craneLib lavapipeIcd commonArgs;
42
43
          package = craneLib.buildPackage (
44
            commonArgs
45
            // {
46
              inherit cargoArtifacts;
47
              doCheck = false;
48
            }
49
          );
50
51
          checks = {
52
            clippy = craneLib.cargoClippy (
53
              commonArgs
54
              // {
55
                inherit cargoArtifacts;
56
                cargoClippyExtraArgs = "--all-targets -- --deny warnings";
57
              }
58
            );
59
            fmt = craneLib.cargoFmt { inherit src; pname = "monolith"; version = "0.0.0"; };
60
            test = craneLib.cargoTest (
61
              commonArgs
62
              // {
63
                inherit cargoArtifacts;
64
                VK_DRIVER_FILES = lavapipeIcd;
65
              }
66
            );
67
          };
68
        };
69
    in
70
    {
71
      packages = forAllSystems (pkgs: {
72
        default = (mkProject pkgs).package;
73
      });
74
75
      checks = forAllSystems (pkgs: (mkProject pkgs).checks);
76
77
      devShells = forAllSystems (
78
        pkgs:
79
        let
80
          project = mkProject pkgs;
81
        in
82
        {
83
          default = project.craneLib.devShell {
84
            inputsFrom = [ project.package ];
85
            packages = with pkgs; [
86
              rust-analyzer
87
              vulkan-tools
88
              vulkan-validation-layers
89
              tracy
90
            ];
91
            LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.vulkan-loader ];
92
            LAVAPIPE_ICD = project.lavapipeIcd;
93
          };
94
        }
95
      );
96
97
      formatter = forAllSystems (pkgs: pkgs.nixfmt);
98
    };
99
}