mirror of
https://github.com/traxys/Nixfiles.git
synced 2026-02-13 02:40:20 +01:00
templates: Add gui template
This commit is contained in:
parent
ac956d4627
commit
960efd4cf6
6 changed files with 90 additions and 0 deletions
|
|
@ -134,6 +134,10 @@
|
|||
path = ./templates/webserver;
|
||||
description = "A template for a web server (using templates for the frontend)";
|
||||
};
|
||||
gui = {
|
||||
path = ./templates/gui;
|
||||
description = "A template for rust GUI applications";
|
||||
};
|
||||
};
|
||||
packages.x86_64-linux = pkgList "x86_64-linux" nixpkgs.legacyPackages.x86_64-linux.callPackage;
|
||||
packages.aarch64-linux = pkgList "aarch64-linux" nixpkgs.legacyPackages.aarch64-linux.callPackage;
|
||||
|
|
|
|||
1
templates/gui/.envrc
Normal file
1
templates/gui/.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use flake
|
||||
3
templates/gui/.gitignore
vendored
Normal file
3
templates/gui/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
/target
|
||||
/.direnv
|
||||
|
||||
8
templates/gui/Cargo.toml
Normal file
8
templates/gui/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "todo_change_name"
|
||||
version = "0.1.0"
|
||||
authors = ["traxys <quentin@familleboyer.net>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
iced = "0.10.0"
|
||||
43
templates/gui/flake.nix
Normal file
43
templates/gui/flake.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
description = "A basic flake with a shell";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.naersk.url = "github:nix-community/naersk";
|
||||
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
naersk,
|
||||
rust-overlay,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [(import rust-overlay)];
|
||||
};
|
||||
rust = pkgs.rust-bin.stable.latest.default;
|
||||
naersk' = pkgs.callPackage naersk {
|
||||
cargo = rust;
|
||||
rustc = rust;
|
||||
};
|
||||
libPath = with pkgs; lib.makeLibraryPath [libxkbcommon wayland];
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = [rust];
|
||||
RUST_PATH = "${rust}";
|
||||
RUST_DOC_PATH = "${rust}/share/doc/rust/html/std/index.html";
|
||||
LD_LIBRARY_PATH = libPath;
|
||||
};
|
||||
|
||||
defaultPackage = naersk'.buildPackage {
|
||||
src = ./.;
|
||||
nativeBuildInputs = [pkgs.makeWrapper];
|
||||
postInstall = ''
|
||||
wrapProgram "$out/bin/todo_change_name" --prefix LD_LIBRARY_PATH : "${libPath}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
31
templates/gui/src/main.rs
Normal file
31
templates/gui/src/main.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use iced::{widget::column, Sandbox, Settings};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum Message {}
|
||||
|
||||
struct App {}
|
||||
|
||||
impl Sandbox for App {
|
||||
type Message = Message;
|
||||
|
||||
fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
||||
fn title(&self) -> String {
|
||||
"TODO change name".into()
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Self::Message) {
|
||||
match message {}
|
||||
}
|
||||
|
||||
fn view(&self) -> iced::Element<'_, Self::Message> {
|
||||
column![].into()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> iced::Result {
|
||||
App::run(Settings::default())
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue