Fix icons not showing when using flake

This commit is contained in:
Julian Mutter 2024-06-04 22:12:54 +02:00
parent 367997839c
commit 41f79a992e
5 changed files with 55 additions and 34 deletions

View File

@ -7,7 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
# Core library # Core library
relm4 = "0.8.1" relm4 = { version = "0.8.1" }
# relm4-macros = "0.6.2" # relm4-macros = "0.6.2"
# Optional: reusable components # Optional: reusable components
relm4-components = "0.8.1" relm4-components = "0.8.1"

6
flake.lock generated
View File

@ -7,11 +7,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1716745752, "lastModified": 1717469187,
"narHash": "sha256-8K1R9Yg4r08rYk86Yq+lu3E9L3uRUb4xMqYHgl0VGS0=", "narHash": "sha256-UVvFGiWFGPfVXG7Xr6HPKChx9hhtzkGaGAS/Ph1Khjg=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "19ca94ec2d288de334ae932107816b4a97736cd8", "rev": "7e86136dc729cdf237aa59a5a02687bc0d1144b6",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -12,17 +12,24 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, crane, flake-utils, ... }: outputs =
flake-utils.lib.eachDefaultSystem (system: {
self,
nixpkgs,
crane,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs; craneLib = crane.mkLib pkgs;
dbMigrationsFilter = path: _type: builtins.match ".*sql$" path != null; dbMigrationsFilter = path: _type: builtins.match ".*sql$" path != null;
dbMigrationsOrCargoFilter = path: type: dbMigrationsOrCargoFilter =
(dbMigrationsFilter path type) path: type: (dbMigrationsFilter path type) || (craneLib.filterCargoSources path type);
|| (craneLib.filterCargoSources path type);
dbMigrations = pkgs.lib.cleanSourceWith { dbMigrations = pkgs.lib.cleanSourceWith {
src = craneLib.path ./db-migrations; # The original, unfiltered source src = craneLib.path ./db-migrations; # The original, unfiltered source
@ -36,7 +43,6 @@
src = craneLib.path ./.; # The original, unfiltered source src = craneLib.path ./.; # The original, unfiltered source
filter = dbMigrationsOrCargoFilter; filter = dbMigrationsOrCargoFilter;
}; };
# src = craneLib.cleanCargoSource (craneLib.path ./.);
# Add icons.toml to $src when compiling dependencies (needed by relm4-icons) # Add icons.toml to $src when compiling dependencies (needed by relm4-icons)
# Add db-migrations to $src when compiling dependencies (needed by sqlx) # Add db-migrations to $src when compiling dependencies (needed by sqlx)
@ -46,25 +52,36 @@
cp -r --no-preserve=mode,ownership ${dbMigrations} --no-target-dir $out/db-migrations/ cp -r --no-preserve=mode,ownership ${dbMigrations} --no-target-dir $out/db-migrations/
''; '';
nativeBuildInputs = with pkgs; [ pkg-config gtk4 ]; nativeBuildInputs = with pkgs; [
pkg-config
gtk4
];
buildInputs = [ buildInputs =
[
# Add additional build inputs here # Add additional build inputs here
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ ]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here # Additional darwin specific inputs can be set here
pkgs.libiconv pkgs.libiconv
]; ];
}; };
my-crate = craneLib.buildPackage (commonArgs // { my-crate = craneLib.buildPackage (
commonArgs
// {
cargoArtifacts = craneLib.buildDepsOnly commonArgs; cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Additional environment variables or build phases/hooks can be set # Additional environment variables or build phases/hooks can be set
# here *without* rebuilding all dependency crates # here *without* rebuilding all dependency crates
# MY_CUSTOM_VAR = "some value"; # MY_CUSTOM_VAR = "some value";
}); }
in { );
checks = { inherit my-crate; }; in
{
checks = {
inherit my-crate;
};
packages.default = my-crate; packages.default = my-crate;
@ -78,12 +95,12 @@
# MY_CUSTOM_DEVELOPMENT_VAR = "something else"; # MY_CUSTOM_DEVELOPMENT_VAR = "something else";
# Extra inputs can be added here; cargo and rustc are provided by default. # Extra inputs can be added here; cargo and rustc are provided by default.
packages = with pkgs; packages = with pkgs; [
[
# rustPackages.clippy # rustPackages.clippy
# rustfmt # rustfmt
# pre-commit # pre-commit
]; ];
}; };
}); }
);
} }

View File

@ -1,5 +1,5 @@
# Recommended: Specify your app ID *OR* your base resource path for more robust icon loading # Recommended: Specify your app ID *OR* your base resource path for more robust icon loading
# app_id = "de.frajul.sheet-organizer" base_resource_path = "/org/gtkrs/"
# List of icon names you found (shipped with this crate) # List of icon names you found (shipped with this crate)
# Note: the file ending `-symbolic.svg` isn't part of the icon name. # Note: the file ending `-symbolic.svg` isn't part of the icon name.

View File

@ -4,7 +4,7 @@ use chrono::Utc;
use gtk::prelude::*; use gtk::prelude::*;
use relm4::{ use relm4::{
component::{AsyncComponent, AsyncComponentParts, AsyncController}, component::{AsyncComponent, AsyncComponentParts, AsyncController},
gtk::Adjustment, gtk::{gdk, Adjustment},
prelude::*, prelude::*,
AsyncComponentSender, AsyncComponentSender,
}; };
@ -115,6 +115,10 @@ impl AsyncComponent for AppModel {
sender: AsyncComponentSender<Self>, sender: AsyncComponentSender<Self>,
) -> AsyncComponentParts<Self> { ) -> AsyncComponentParts<Self> {
relm4_icons::initialize_icons(); relm4_icons::initialize_icons();
let display = gdk::Display::default().unwrap();
let theme = gtk::IconTheme::for_display(&display);
theme.add_resource_path("/org/gtkrs/icons/");
theme.add_resource_path("/org/gtkrs/icons/scalable/actions/");
let mcdu = McduModel::builder() let mcdu = McduModel::builder()
.launch(()) .launch(())