Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pkg_check_modules(LIBWAYLAND_CLIENT REQUIRED wayland-client)

execute_process(COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_subdirectory(modules/xrealInterfaceLibrary/interface_lib)

# Set the library directory based on architecture
Expand Down
9 changes: 9 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) {src = ./.;}).defaultNix
78 changes: 78 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
description = "Nix Flake for XRLinuxDriver";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
];
in
flake-utils.lib.eachSystem systems
(
system: let
pkgs = import nixpkgs {
inherit system;
};
in {
packages = {
xrlinuxdriver = pkgs.callPackage ./nix {inherit self;};
default = self.packages.${pkgs.system}.xrlinuxdriver;
};

devShells.default = pkgs.mkShell {inputsFrom = with self.packages.${pkgs.system}; [default];};
}
)
// {
overlays.default = final: prev: {inherit (self.packages.${final.system}) xrlinuxdriver;};
};
}
2 changes: 1 addition & 1 deletion modules/xrealInterfaceLibrary
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be downgrading the submodule, d101fa is the latest commit

Submodule xrealInterfaceLibrary updated from d101fa to 3225fc
112 changes: 112 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
self,
lib,
pkgs,
stdenv,
fetchFromGitLab,
libusb1,
curl,
openssl,
libevdev,
json_c,
hidapi,
wayland,
cmake,
pkg-config,
python3,
libffi,
autoPatchelfHook,
...
}: let
pythonEnv = python3.withPackages (ps: [ps.pyyaml]);
buildInputs = [
curl
hidapi
json_c
libevdev
libffi
libusb1
openssl
stdenv.cc.cc.lib
wayland
];
arch =
if pkgs.system == "aarch64-linux"
then "aarch64"
else if pkgs.system == "x86_64-linux"
then "x86_64"
else throw "Unsupported system ${pkgs.system}";
in
stdenv.mkDerivation rec {
pname = "xrlinuxdriver";
version = "unstable";

srcs = [
(fetchFromGitLab rec {
domain = "gitlab.com";
owner = "TheJackiMonster";
repo = "nrealAirLinuxDriver";
rev = "3225fcc575e19a8407d5019903567cff1c3ed1a8";
hash = "sha256-NRbcANt/CqREQZoYIYtTGVbvkZ7uo2Tm90s6prlsrQE=";
fetchSubmodules = true;
name = "${repo}-src";
})
(lib.cleanSourceWith {
src = self;
name = "${pname}-src";
})
];
sourceRoot = "${(builtins.elemAt srcs 1).name}";

postUnpack = let
nrealAirLinuxDriver = (builtins.elemAt srcs 0).name;
in ''
mkdir -p $sourceRoot/modules/xrealInterfaceLibrary
cp -R ${nrealAirLinuxDriver}/* $sourceRoot/modules/xrealInterfaceLibrary
chmod -R u+w $sourceRoot
'';

nativeBuildInputs = [
cmake
pkg-config
pythonEnv
autoPatchelfHook
];
inherit buildInputs;

cmakeFlags = [
"-DCMAKE_SKIP_RPATH=ON"
];
cmakeBuildDir = "build";
cmakeBuildType = "RelWithDebInfo";

installPhase = ''
mkdir -p $out/bin $out/lib/systemd/user $out/lib/udev/rules.d $out/lib/${arch}
cp xrDriver ../bin/xr_driver_cli ../bin/xr_driver_verify $out/bin
cp ../udev/* $out/lib/udev/rules.d/
cp ../lib/${arch}/* $out/lib/${arch}/
cp ../systemd/xr-driver.service $out/lib/systemd/user/xr-driver.service
cp ${hidapi}/lib/libhidapi-hidraw.so.0 $out/lib/
substituteInPlace \
$out/lib/systemd/user/xr-driver.service \
--replace-fail "ExecStart={bin_dir}/xrDriver" "ExecStart=$out/bin/xrDriver" \
--replace-fail "{ld_library_path}" "$out/lib/${arch}"
'';

preBuild = ''
addAutoPatchelfSearchPath $out/usr/lib/${arch}
'';

doInstallCheck = false;
# The default release is a script which will do an impure download
# just ensure that the application can run without network

meta = {
homepage = "https://github.com/wheaney/XRLinuxDriver";
license = lib.licenses.mit;
description = "Linux service for interacting with XR devices.";
mainProgram = "xrDriver";
maintainers = with lib.maintainers; [shymega];
platforms = lib.platforms.linux;
};
}
12 changes: 12 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2023 Dom Rodriguez <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-only
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) {src = ./.;}).shellNix