summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-07-01 16:21:37 -0700
committerIrene Knapp <ireneista@irenes.space>2026-07-02 03:11:11 -0700
commit627dc10a30b9ff136fc938570820ff82c7f49489 (patch)
treee94fea8f6a50a50db6b7f68a6694b77bbb04e98a /flake.nix
initial
Force-Push: yes
Change-Id: I8ad20ee63db338119a3f54de36b4f8c6fc1feb52
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..4e03888
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,62 @@
+{
+  inputs = {
+    nixpkgs = {
+      type = "github";
+      owner = "NixOS";
+      repo = "nixpkgs";
+      ref = "nixos-26.05";
+    };
+
+    crane = {
+      url = "github:ipetkov/crane";
+    };
+  };
+
+  outputs = { self, nixpkgs, crane }:
+  let supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
+      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
+      nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
+      buildInputsFor = pkgs: with pkgs; [
+        #   The list of packages needed feels more than a little bit random;
+        # it's because winit relies on packages that differ vastly in how and
+        # when they find the C libraries.
+        pkg-config
+        libgcc
+        libxcursor
+        libxi
+        libxkbcommon
+        # mesa
+        # wayland
+        # vulkan-loader
+      ];
+  in {
+    packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in {
+      default = ((crane.mkLib pkgs).buildPackage {
+        src = ./.;
+
+        buildInputs = buildInputsFor pkgs;
+
+        nativeBuildInputs = with pkgs; [ autoPatchelfHook ];
+      }).overrideAttrs {
+        preFixup = ''
+          patchelf --add-needed libxkbcommon-x11.so $out/bin/surreality
+        '';
+      };
+    });
+
+    devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in {
+      default = pkgs.mkShell {
+        nativeBuildInputs = with pkgs; [
+          cargo
+          rustc
+          vulkan-tools
+        ] ++ buildInputsFor pkgs;
+
+        #   This makes cargo run work; mind that you don't let it mask a
+        # problem with the nix build.
+        LD_LIBRARY_PATH = "${pkgs.libxkbcommon}/lib";
+      };
+    });
+  };
+}
+