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]
# Core library
relm4 = "0.8.1"
relm4 = { version = "0.8.1" }
# relm4-macros = "0.6.2"
# Optional: reusable components
relm4-components = "0.8.1"

6
flake.lock generated
View File

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

View File

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

View File

@ -1,5 +1,5 @@
# 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)
# 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 relm4::{
component::{AsyncComponent, AsyncComponentParts, AsyncController},
gtk::Adjustment,
gtk::{gdk, Adjustment},
prelude::*,
AsyncComponentSender,
};
@ -115,6 +115,10 @@ impl AsyncComponent for AppModel {
sender: AsyncComponentSender<Self>,
) -> AsyncComponentParts<Self> {
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()
.launch(())