Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
Add Nix Flake (#1)
Browse files Browse the repository at this point in the history
* Add Nix Flake for development builds

Signed-off-by: Sefa Eyeoglu <[email protected]>

* Add Nix formatter

Ensure Nix code style is formatted using Alejandra.
https://github.com/kamadorueda/alejandra

Signed-off-by: Sefa Eyeoglu <[email protected]>

* Add garnix CI config

https://garnix.io/

Signed-off-by: Sefa Eyeoglu <[email protected]>

* Add Nix info to README.md

Signed-off-by: Sefa Eyeoglu <[email protected]>

* Add GitHub Action for Flake updates

Signed-off-by: Sefa Eyeoglu <[email protected]>

* Add Nix overlay

Signed-off-by: Sefa Eyeoglu <[email protected]>

* Add info about Nix outputs to README.md

Signed-off-by: Sefa Eyeoglu <[email protected]>

---------

Signed-off-by: Sefa Eyeoglu <[email protected]>
  • Loading branch information
Scrumplex authored Sep 24, 2023
1 parent 59c8dc1 commit dace93e
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/update-flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Update Flake Lockfile

on:
schedule:
# run weekly at noon on sundays
- cron: "0 12 * * 0"
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-flake:
if: github.owner == 'galister'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@main
with:
pr-title: "Update flake.lock"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/target
.gdb_history
result
reuslt-*
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ Move screen: Grab using grip. Adjust distace using stick up/down while gripping.

Resize screen: Same as Move screen but turn your controller to get the yellow laser.

## Nix Flake

A Nix Flake is availabe as `github:galister/wlx-overlay-x`. Cached builds are available using [garnix](https://garnix.io/). See [garnix docs](https://garnix.io/docs/caching) to see how to utilize this binary cache.

Run `nix flake show github:galister/wlx-overlay-x` to see all outputs of this flake.

# Known Issues

StereoKit fails to build with OpenXR version 1.0.29. You can downgrade your OpenXR syetem package to fix this.
Expand Down
48 changes: 48 additions & 0 deletions flake.lock

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

21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
description = "A lightweight OpenXR overlay for Wayland desktops, inspired by XSOverlay";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
};

outputs = inputs @ {
self,
flake-parts,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux"];
imports = [./nix/packages.nix ./nix/dev.nix];
};
}
5 changes: 5 additions & 0 deletions garnix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
builds:
exclude: []
include:
- "checks.*.*"
- "packages.*.*"
70 changes: 70 additions & 0 deletions nix/derivation.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
lib,
rustPlatform,
alsa-lib,
cmake,
cpm-cmake,
fontconfig,
freetype,
libglvnd,
libxkbcommon,
mesa,
openxr-loader,
pipewire,
pkg-config,
wayland,
xorg,
# flake
self,
version,
}:
rustPlatform.buildRustPackage {
pname = "wlx-overlay-x";
inherit version;

src = lib.cleanSource self;

cargoLock = {
lockFile = ../Cargo.lock;
allowBuiltinFetchGit = true;
};

nativeBuildInputs = [
cmake
pkg-config
rustPlatform.bindgenHook
];

buildInputs = [
alsa-lib
fontconfig
freetype
libglvnd
libxkbcommon
mesa
openxr-loader
pipewire
wayland
xorg.libX11
];

# From https://github.com/StardustXR/server/blob/0dc5b1a92f5707efa16c251602935bdfc47ee7f0/nix/stardust-xr-server.nix
CPM_SOURCE_CACHE = "./build";
postPatch = ''
sk=$(echo $cargoDepsCopy/stereokit-sys-*/StereoKit)
mkdir -p $sk/build/cpm
# This is not ideal, the original approach was to fetch the exact cmake
# file version that was wanted from GitHub directly, but at least this way it comes from Nixpkgs.. so meh
cp ${cpm-cmake}/share/cpm/CPM.cmake $sk/build/cpm/CPM_0.32.2.cmake
'';

meta = with lib; {
description = "WlxOverlay for OpenXR, written in Rust";
homepage = "https://github.com/galister/wlx-overlay-x";
license = licenses.gpl3Only;
platforms = platforms.linux;
maintainers = with maintainers; [Scrumplex];
mainProgram = "wlx-overlay-x";
};
}
5 changes: 5 additions & 0 deletions nix/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
perSystem = {pkgs, ...}: {
formatter = pkgs.alejandra;
};
}
18 changes: 18 additions & 0 deletions nix/packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{self, ...}: let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in {
perSystem = {
config,
pkgs,
...
}: {
packages = {
default = config.packages.wlx-overlay-x;
wlx-overlay-x = pkgs.callPackage ./derivation.nix {inherit self version;};
};
};

flake.overlays.default = final: _: {
wlx-overlay-x = final.callPackage ./derivation.nix {inherit self version;};
};
}

0 comments on commit dace93e

Please sign in to comment.