iced-template: init

This commit is contained in:
electria 2026-08-03 12:02:10 -07:00
commit 8f0abd2b78
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
8 changed files with 4192 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/target
/.direnv
/result

3954
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

10
Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "iced-template"
version = "0.1.0"
edition = "2024"
license = "AGPL-3.0-or-later"
[dependencies]
[dependencies.iced]
version = "0.14.0"

77
flake.lock generated Normal file
View file

@ -0,0 +1,77 @@
{
"nodes": {
"crane": {
"locked": {
"lastModified": 1785782307,
"narHash": "sha256-MPaRdVkf6zZP5fCPxYCi8Dr4pZzgmXzg8T9nVEbp3Mw=",
"owner": "ipetkov",
"repo": "crane",
"rev": "2c71e194474d13de031d729b729c968ddbe3507f",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1785747939,
"narHash": "sha256-D740uKsMbgsfK2oaDenJLLPIZfq7W0/g4KN/Fls8eKs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "104240a772428cc2e20d8fd86c9ddbb886bbaff2",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

111
flake.nix Normal file
View file

@ -0,0 +1,111 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs { inherit system; };
lib = pkgs.lib;
craneLib = inputs.crane.mkLib pkgs;
cargoToml = fromTOML (builtins.readFile ./Cargo.toml);
name = cargoToml.package.name;
dlDeps =
with pkgs;
[
# needed for both x11 and wayland
libxkbcommon
libGL
libx11
libxcursor
libxi
libxcb
]
++ lib.optionals stdenv.hostPlatform.isLinux [
vulkan-loader
wayland
];
commonArgs = {
# all that's needed for artifacts and checks
nativeBuildInputs = with pkgs; [
# pkg-config
];
buildInputs = with pkgs; [
];
src = ./.;
};
# Build *just* the cargo dependencies,
# to reuse them for build and test derivations.
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual crate itself,
# reusing the dependency artifacts from above.
crate =
let
desktopItem = pkgs.makeDesktopItem {
inherit name;
desktopName = name;
icon = name;
exec = name;
};
in
craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
pkgs.autoPatchelfHook
];
buildInputs = commonArgs.buildInputs ++ [
pkgs.libgcc
];
runtimeDependencies = dlDeps;
doCheck = false;
postFixup = ''
mkdir -p "$out/share/applications"
ln -s "${desktopItem}"/share/applications/* "$out/share/applications/"
'';
}
);
in
{
packages.default = crate;
checks = {
crate-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
}
);
};
devShells.default = craneLib.devShell {
LD_LIBRARY_PATH = lib.makeLibraryPath dlDeps;
inputsFrom = [ crate ];
packages = [ pkgs.rust-analyzer ];
};
}
);
}

30
src/app/mod.rs Normal file
View file

@ -0,0 +1,30 @@
use iced::{Color, Element, Renderer, Task, Theme, application, theme, widget};
enum Message {}
struct State {}
impl State {
fn new() -> Self {
Self {}
}
fn update(&mut self, message: Message) -> Task<Message> {
Task::none()
}
fn view(&self) -> Element<'_, Message, Theme, Renderer> {
widget::text("hiiiiiii").into()
}
}
pub fn run() -> Result<(), impl std::error::Error> {
application(State::new, State::update, State::view)
.theme(theme::Theme::custom(
"high-contrast-dark",
theme::Palette {
background: Color::from_rgb8(10, 10, 10),
text: Color::WHITE,
..theme::Palette::DARK
},
))
.run()
}

5
src/main.rs Normal file
View file

@ -0,0 +1,5 @@
mod app;
fn main() -> Result<(), impl std::error::Error> {
app::run()
}