atagen

monolith

public
Star0
Watch0
e9ef7cdfe55ae04885f11cd22b81e4249b34a788
1
ssh://brewery@pls.lobotomise.me:33/atagen/monolith.git
flake.nixNix112 lines2.9 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
              libinput
44
              seatd
45
              libgbm
46
              libdrm
47
              udev
48
            ];
49
          };
50
          cargoArtifacts = craneLib.buildDepsOnly commonArgs;
51
        in
52
        {
53
          inherit craneLib lavapipeIcd commonArgs;
54
55
          package = craneLib.buildPackage (
56
            commonArgs
57
            // {
58
              inherit cargoArtifacts;
59
              doCheck = false;
60
            }
61
          );
62
63
          checks = {
64
            clippy = craneLib.cargoClippy (
65
              commonArgs
66
              // {
67
                inherit cargoArtifacts;
68
                cargoClippyExtraArgs = "--all-targets -- --deny warnings";
69
              }
70
            );
71
            fmt = craneLib.cargoFmt { inherit src; pname = "monolith"; version = "0.0.0"; };
72
            test = craneLib.cargoTest (
73
              commonArgs
74
              // {
75
                inherit cargoArtifacts;
76
                VK_DRIVER_FILES = lavapipeIcd;
77
                LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.vulkan-loader ];
78
              }
79
            );
80
          };
81
        };
82
    in
83
    {
84
      packages = forAllSystems (pkgs: {
85
        default = (mkProject pkgs).package;
86
      });
87
88
      checks = forAllSystems (pkgs: (mkProject pkgs).checks);
89
90
      devShells = forAllSystems (
91
        pkgs:
92
        let
93
          project = mkProject pkgs;
94
        in
95
        {
96
          default = project.craneLib.devShell {
97
            inputsFrom = [ project.package ];
98
            packages = with pkgs; [
99
              rust-analyzer
100
              vulkan-tools
101
              vulkan-validation-layers
102
              tracy
103
            ];
104
            LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.vulkan-loader ];
105
            LAVAPIPE_ICD = project.lavapipeIcd;
106
          };
107
        }
108
      );
109
110
      formatter = forAllSystems (pkgs: pkgs.nixfmt);
111
    };
112
}