Initial commit

This commit is contained in:
Tobias Berger 2024-01-04 16:36:41 +01:00
commit ecc51b2129
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
9 changed files with 2224 additions and 0 deletions

6
.envrc Normal file
View file

@ -0,0 +1,6 @@
watch_file shell.nix
watch_file flake.lock
# try to use flakes, if it fails use normal nix (ie. shell.nix)
use flake || use nix
eval "$shellHook"

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target
.direnv

2044
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

30
Cargo.toml Normal file
View file

@ -0,0 +1,30 @@
[package]
name = "todoodoo"
description = "todoodoo"
version = "0.1.0"
edition = "2021"
[profile.release]
strip = "symbols"
lto = true
opt-level = "s"
codegen-units = 1
[profile.dev.package."*"]
opt-level = "s"
codegen-units = 1
[profile.dev.build-override]
opt-level = "s"
codegen-units = 1
[profile.release.package."*"]
opt-level = "s"
codegen-units = 1
[profile.release.build-override]
opt-level = "s"
codegen-units = 1
[dependencies.eframe]
version = "0.24"
default-features = false
features = [ "wayland", "default_fonts", "glow", "persistence" ]

32
default.nix Normal file
View file

@ -0,0 +1,32 @@
{ pkgs ? import <nixpkgs> { } }:
let manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
packages = with pkgs; [
pkg-config
libGLU
libGL
libxkbcommon
wayland
];
in
pkgs.rustPlatform.buildRustPackage rec {
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
meta = {
description = manifest.description ? null;
};
postBuild = ''
patchelf --add-needed libxkbcommon.so target/x86_64-unknown-linux-gnu/release/todoodoo
patchelf --add-needed libwayland-client.so target/x86_64-unknown-linux-gnu/release/todoodoo
patchelf --add-needed libGLU.so target/x86_64-unknown-linux-gnu/release/todoodoo
patchelf --add-needed libEGL.so target/x86_64-unknown-linux-gnu/release/todoodoo
old_rpath=$(patchelf --print-rpath target/x86_64-unknown-linux-gnu/release/todoodoo)
if [[ -z "$old_rpath" ]]; then
patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}" target/x86_64-unknown-linux-gnu/release/todoodoo
else
patchelf --set-rpath "${pkgs.lib.makeLibraryPath packages}:$old_rpath" target/x86_64-unknown-linux-gnu/release/todoodoo
fi
'';
}

27
flake.lock Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1704194953,
"narHash": "sha256-RtDKd8Mynhe5CFnVT8s0/0yqtWFMM9LmCzXv/YKxnq4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "bd645e8668ec6612439a9ee7e71f7eac4099d4f6",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

20
flake.nix Normal file
View file

@ -0,0 +1,20 @@
{
description = "ToDooDoo";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = nixpkgs.legacyPackages;
in {
packages = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./default.nix { };
});
devShells = forAllSystems (system: {
default = pkgsFor.${system}.callPackage ./shell.nix { };
});
};
}

29
shell.nix Normal file
View file

@ -0,0 +1,29 @@
{ pkgs ? import <nixpkgs> { }, lib }:
let packages = with pkgs; [
rust-analyzer
rustfmt
clippy
clang
mold
pkg-config
libGLU
libGL
libxkbcommon
wayland
];
in
pkgs.mkShell {
# Get dependencies from the main package
inputsFrom = [ (pkgs.callPackage ./default.nix { }) ];
nativeBuildInputs = packages;
buildInputs = packages;
env = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
LD_LIBRARY_PATH = "${lib.makeLibraryPath packages}";
};
}

34
src/main.rs Normal file
View file

@ -0,0 +1,34 @@
use eframe::egui;
fn main() {
std::env::set_var("WINIT_UNIX_BACKEND", "wayland");
let native_options = eframe::NativeOptions::default();
if let Err(err) = eframe::run_native(
"My egui App",
native_options,
Box::new(|cc| Box::new(MyEguiApp::new(cc))),
) {
eprintln!("{err}");
}
}
#[derive(Default)]
struct MyEguiApp {}
impl MyEguiApp {
fn new(_cc: &eframe::CreationContext<'_>) -> Self {
// Customize egui here with cc.egui_ctx.set_fonts and cc.egui_ctx.set_visuals.
// Restore app state using cc.storage (requires the "persistence" feature).
// Use the cc.gl (a glow::Context) to create graphics shaders and buffers that you can use
// for e.g. egui::PaintCallback.
Self::default()
}
}
impl eframe::App for MyEguiApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Hello World!");
});
}
}