Compare commits

...

3 Commits

Author SHA1 Message Date
Ferdinand Schober
d87a8cd60f fix icon build 2026-03-24 15:05:33 +01:00
Ferdinand Schober
7fa3d2fafd update makeicns.sh 2026-03-24 14:02:16 +01:00
onelock
cd9fc43af4 fix: nix evaluation warnings + flake improvements (#395)
* fix: nix evaluation warning

* nix: minor flake improvements/maintenance

* nix: fix macos build errors

* nix: minor cleanup/fixes

* nix: remove redundant deps

* nix: remove reliance on systems input
2026-03-24 12:55:31 +01:00
6 changed files with 124 additions and 95 deletions

View File

@@ -84,7 +84,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install dependencies - name: install dependencies
run: brew install gtk4 libadwaita imagemagick run: brew install gtk4 libadwaita imagemagick librsvg
- name: Release Build - name: Release Build
run: | run: |
cargo build --release cargo build --release
@@ -112,7 +112,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install dependencies - name: install dependencies
run: brew install gtk4 libadwaita imagemagick run: brew install gtk4 libadwaita imagemagick librsvg
- name: Release Build - name: Release Build
run: | run: |
cargo build --release cargo build --release

View File

@@ -80,7 +80,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install dependencies - name: install dependencies
run: brew install gtk4 libadwaita imagemagick run: brew install gtk4 libadwaita imagemagick librsvg
- name: Release Build - name: Release Build
run: | run: |
cargo build --release cargo build --release
@@ -108,7 +108,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install dependencies - name: install dependencies
run: brew install gtk4 libadwaita imagemagick run: brew install gtk4 libadwaita imagemagick librsvg
- name: Release Build - name: Release Build
run: | run: |
cargo build --release cargo build --release

12
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1752687322, "lastModified": 1772963539,
"narHash": "sha256-RKwfXA4OZROjBTQAl9WOZQFm7L8Bo93FQwSJpAiSRvo=", "narHash": "sha256-9jVDGZnvCckTGdYT53d/EfznygLskyLQXYwJLKMPsZs=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6e987485eb2c77e5dcc5af4e3c70843711ef9251", "rev": "9dcb002ca1690658be4a04645215baea8b95f31d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -29,11 +29,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1752806774, "lastModified": 1773025773,
"narHash": "sha256-4cHeoR2roN7d/3J6gT+l6o7J2hTrBIUiCwVdDNMeXzE=", "narHash": "sha256-Wik8+xApNfldpUFjPmJkPdg0RrvUPSWGIZis+A/0N1w=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "3c90219b3ba1c9790c45a078eae121de48a39c55", "rev": "3c06fdbbd36ff60386a1e590ee0cd52dcd1892bf",
"type": "github" "type": "github"
}, },
"original": { "original": {

139
flake.nix
View File

@@ -7,60 +7,87 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { outputs =
self, {
nixpkgs, nixpkgs,
rust-overlay, rust-overlay,
... self,
}: let ...
inherit (nixpkgs) lib; }:
genSystems = lib.genAttrs [ let
"aarch64-darwin" inherit (nixpkgs) lib;
"aarch64-linux" forEachPkgs =
"x86_64-darwin" f:
"x86_64-linux" lib.genAttrs
]; [
pkgsFor = system: "aarch64-darwin"
import nixpkgs { "aarch64-linux"
inherit system; "x86_64-darwin"
"x86_64-linux"
overlays = [ ]
rust-overlay.overlays.default (
]; system:
}; let
mkRustToolchain = pkgs: pkgs = import nixpkgs {
pkgs.rust-bin.stable.latest.default.override { inherit system;
extensions = ["rust-src"]; overlays = [ rust-overlay.overlays.default ];
}; };
pkgs = genSystems (system: import nixpkgs {inherit system;}); # Default toolchain for devshell
in { rustToolchain = pkgs.rust-bin.stable.latest.default.override {
packages = genSystems (system: rec { extensions = [
default = pkgs.${system}.callPackage ./nix {}; # includes already:
lan-mouse = default; # rustc
}); # cargo
homeManagerModules.default = import ./nix/hm-module.nix self; # rust-std
devShells = genSystems (system: let # rust-docs
pkgs = pkgsFor system; # rustfmt-preview
rust = mkRustToolchain pkgs; # clippy-preview
in { "rust-analyzer"
default = pkgs.mkShell { "rust-src"
packages = with pkgs; [ ];
rust };
rust-analyzer-unwrapped # Minimal toolchain for builds (rustc + cargo + rust-std only)
pkg-config rustToolchainForBuild = pkgs.rust-bin.stable.latest.minimal;
xorg.libX11 in
gtk4 f { inherit pkgs rustToolchain rustToolchainForBuild; }
libadwaita );
librsvg in
xorg.libXtst {
] ++ lib.optionals stdenv.isDarwin packages = forEachPkgs (
(with darwin.apple_sdk_11_0.frameworks; [ { pkgs, rustToolchainForBuild, ... }:
CoreGraphics let
ApplicationServices customRustPlatform = pkgs.makeRustPlatform {
]); cargo = rustToolchainForBuild;
rustc = rustToolchainForBuild;
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library"; };
}; lan-mouse = pkgs.callPackage ./nix { rustPlatform = customRustPlatform; };
}); in
}; {
default = lan-mouse;
inherit lan-mouse;
}
);
devShells = forEachPkgs (
{ pkgs, rustToolchain, ... }:
{
default = pkgs.mkShell {
packages =
with pkgs;
[
rustToolchain
pkg-config
gtk4
libadwaita
librsvg
]
++ lib.optionals pkgs.stdenv.isLinux [
libX11
libXtst
];
env.RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
};
}
);
homeManagerModules.default = import ./nix/hm-module.nix self;
};
} }

View File

@@ -1,34 +1,40 @@
{ {
stdenv,
rustPlatform, rustPlatform,
lib, lib,
pkgs, pkg-config,
}: let libX11,
cargoToml = builtins.fromTOML (builtins.readFile ../Cargo.toml); gtk4,
libadwaita,
libXtst,
wrapGAppsHook4,
librsvg,
git,
}:
let
cargoToml = fromTOML (builtins.readFile ../Cargo.toml);
pname = cargoToml.package.name; pname = cargoToml.package.name;
version = cargoToml.package.version; version = cargoToml.package.version;
in in
rustPlatform.buildRustPackage { rustPlatform.buildRustPackage {
pname = pname; inherit pname;
version = version; inherit version;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = [
git
pkg-config pkg-config
cmake wrapGAppsHook4
makeWrapper git
buildPackages.gtk4
]; ];
buildInputs = with pkgs; [ buildInputs = [
xorg.libX11
gtk4 gtk4
libadwaita libadwaita
xorg.libXtst librsvg
] ++ lib.optionals stdenv.isDarwin ]
(with darwin.apple_sdk_11_0.frameworks; [ ++ lib.optionals stdenv.isLinux [
CoreGraphics libX11
ApplicationServices libXtst
]); ];
src = builtins.path { src = builtins.path {
name = pname; name = pname;
@@ -40,11 +46,7 @@ rustPlatform.buildRustPackage {
# Set Environment Variables # Set Environment Variables
RUST_BACKTRACE = "full"; RUST_BACKTRACE = "full";
# Needed to enable support for SVG icons in GTK
postInstall = '' postInstall = ''
wrapProgram "$out/bin/lan-mouse" \
--set GDK_PIXBUF_MODULE_FILE ${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
install -Dm444 *.desktop -t $out/share/applications install -Dm444 *.desktop -t $out/share/applications
install -Dm444 lan-mouse-gtk/resources/*.svg -t $out/share/icons/hicolor/scalable/apps install -Dm444 lan-mouse-gtk/resources/*.svg -t $out/share/icons/hicolor/scalable/apps
''; '';

View File

@@ -29,13 +29,13 @@ iconset="${3:-./target/icon.iconset}"
set -u set -u
mkdir -p "$iconset" mkdir -p "$iconset"
magick convert -background none -resize 1024x1024 "$svg" "$iconset"/icon_512x512@2x.png magick "$svg" -background none -resize 1024x1024 "$iconset"/icon_512x512@2x.png
magick convert -background none -resize 512x512 "$svg" "$iconset"/icon_512x512.png magick "$svg" -background none -resize 512x512 "$iconset"/icon_512x512.png
magick convert -background none -resize 256x256 "$svg" "$iconset"/icon_256x256.png magick "$svg" -background none -resize 256x256 "$iconset"/icon_256x256.png
magick convert -background none -resize 128x128 "$svg" "$iconset"/icon_128x128.png magick "$svg" -background none -resize 128x128 "$iconset"/icon_128x128.png
magick convert -background none -resize 64x64 "$svg" "$iconset"/icon_32x32@2x.png magick "$svg" -background none -resize 64x64 "$iconset"/icon_32x32@2x.png
magick convert -background none -resize 32x32 "$svg" "$iconset"/icon_32x32.png magick "$svg" -background none -resize 32x32 "$iconset"/icon_32x32.png
magick convert -background none -resize 16x16 "$svg" "$iconset"/icon_16x16.png magick "$svg" -background none -resize 16x16 "$iconset"/icon_16x16.png
cp "$iconset"/icon_512x512.png "$iconset"/icon_256x256@2x.png cp "$iconset"/icon_512x512.png "$iconset"/icon_256x256@2x.png
cp "$iconset"/icon_256x256.png "$iconset"/icon_128x128@2x.png cp "$iconset"/icon_256x256.png "$iconset"/icon_128x128@2x.png
cp "$iconset"/icon_32x32.png "$iconset"/icon_16x16@2x.png cp "$iconset"/icon_32x32.png "$iconset"/icon_16x16@2x.png