Compare commits

...
Sign in to create a new pull request.
Author SHA1 Message Date
e489d9f812
iced-template: generalize desktopItem linking 2026-08-28 21:51:36 -07:00
9b308d6b54
iced-template: remove commonArgs
these are mostly useful for crane,
and were only acting as unnecessary complexity here
2026-08-22 17:56:48 -07:00
4d21ca0e6f
iced-template: avoid duplicating Cargo.lock in nix store 2026-08-22 17:51:54 -07:00
459eac3fff
iced-template: filter source files
(to reduce rebuilds)
crane does something similar automatically
2026-08-22 17:51:50 -07:00
e9847f58c7
iced-template: use strictDeps and __structuredAttrs 2026-08-22 17:45:14 -07:00
8ead7e6eb0
iced-template: use more efficient nixpkgs input 2026-08-22 17:36:09 -07:00
9c3419782b
iced-template: remove nonexistent icon 2026-08-22 17:36:00 -07:00
27f6371c2c
iced-template: factor out Element, explicit Error
the type alias Element is quite useful for defining subfunctions for view
and it also helps to not pull unnecessary things into scope
2026-08-22 17:35:56 -07:00
0095d05e80
iced-template: replace crane 2026-08-03 12:22:43 -07:00
3 changed files with 53 additions and 87 deletions

33
flake.lock generated
View file

@ -1,20 +1,5 @@
{
"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"
@ -35,23 +20,19 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1785747939,
"narHash": "sha256-D740uKsMbgsfK2oaDenJLLPIZfq7W0/g4KN/Fls8eKs=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "104240a772428cc2e20d8fd86c9ddbb886bbaff2",
"type": "github"
"lastModified": 1786862985,
"narHash": "sha256-kSR/jfpR4cE26YRZ8exQkoRbEA30vyWimajwZANYYaE=",
"rev": "e5bdc4a41d4c072fe1e3787eaa0320a384741d44",
"type": "tarball",
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1055335.e5bdc4a41d4c/nixexprs.tar.zst?lastModified=1786862985&rev=e5bdc4a41d4c072fe1e3787eaa0320a384741d44"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
"type": "tarball",
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst"
}
},
"root": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}

View file

@ -1,8 +1,6 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";
flake-utils.url = "github:numtide/flake-utils";
};
@ -14,7 +12,6 @@
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;
@ -36,75 +33,61 @@
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;
pkgs.rustPlatform.buildRustPackage rec {
inherit name;
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
pkgs.autoPatchelfHook
src = lib.sourceFilesBySuffices ./. [
"Cargo.toml"
"Cargo.lock"
".rs"
];
cargoLock.lockFile = "${src}/Cargo.lock";
buildInputs = commonArgs.buildInputs ++ [
pkgs.libgcc
nativeBuildInputs = with pkgs; [
autoPatchelfHook
];
buildInputs = with pkgs; [
libgcc
];
runtimeDependencies = dlDeps;
postFixup = ''
cp -rs "${desktopItem}"/* "$out"
'';
doCheck = false;
postFixup = ''
mkdir -p "$out/share/applications"
ln -s "${desktopItem}"/share/applications/* "$out/share/applications/"
'';
}
);
strictDeps = true;
__structuredAttrs = true;
};
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;
devShells.default = pkgs.mkShell {
env.LD_LIBRARY_PATH = lib.makeLibraryPath dlDeps;
inputsFrom = [ crate ];
packages = [ pkgs.rust-analyzer ];
packages = with pkgs; [
rustc
cargo
clippy
rustfmt
rust-analyzer
];
strictDeps = true;
__structuredAttrs = true;
};
}
);

View file

@ -1,4 +1,6 @@
use iced::{Color, Element, Renderer, Task, Theme, application, theme, widget};
use iced::{Color, Task, application, theme, widget};
type Element<'a> = iced::Element<'a, Message, iced::Theme, iced::Renderer>;
enum Message {}
@ -11,12 +13,12 @@ impl State {
fn update(&mut self, message: Message) -> Task<Message> {
Task::none()
}
fn view(&self) -> Element<'_, Message, Theme, Renderer> {
fn view(&self) -> Element<'_> {
widget::text("hiiiiiii").into()
}
}
pub fn run() -> Result<(), impl std::error::Error> {
pub fn run() -> Result<(), iced::Error> {
application(State::new, State::update, State::view)
.theme(theme::Theme::custom(
"high-contrast-dark",