atagen

monolith

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