From 536a74ec976b5f7b655f5eedd3bdfeec744d13fd Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 11 Jul 2024 23:23:16 +0300 Subject: [PATCH 1/2] meson: init Install with meson, so that we can also install icons. --- icons/meson.build | 14 ++++++ icons/tailscale-offline.svg | 98 +++++++++++++++++++++++++++++++++++++ icons/tailscale-online.svg | 98 +++++++++++++++++++++++++++++++++++++ meson.build | 17 +++++++ src/meson.build | 31 ++++++++++++ src/tray/menu.rs | 6 +-- 6 files changed, 259 insertions(+), 5 deletions(-) create mode 100644 icons/meson.build create mode 100644 icons/tailscale-offline.svg create mode 100644 icons/tailscale-online.svg create mode 100644 meson.build create mode 100644 src/meson.build diff --git a/icons/meson.build b/icons/meson.build new file mode 100644 index 0000000..15abe7e --- /dev/null +++ b/icons/meson.build @@ -0,0 +1,14 @@ +states = ['online', 'offline'] + +install_data( + 'tailscale-online.svg', + install_dir: iconsdir / 'hicolor' / 'scalable' / 'apps', + rename: 'tailscale.svg', +) + +foreach state : states + install_data( + 'tailscale-@0@.svg'.format(state), + install_dir: iconsdir / 'hicolor' / 'symbolic' / 'apps', + ) +endforeach diff --git a/icons/tailscale-offline.svg b/icons/tailscale-offline.svg new file mode 100644 index 0000000..5c7469c --- /dev/null +++ b/icons/tailscale-offline.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/icons/tailscale-online.svg b/icons/tailscale-online.svg new file mode 100644 index 0000000..976abac --- /dev/null +++ b/icons/tailscale-online.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..4694e39 --- /dev/null +++ b/meson.build @@ -0,0 +1,17 @@ +project( + 'tailray', + 'rust', + version: '0.2.1', + license: 'MIT', + meson_version: '>=0.59.0' +) + +cargo = find_program('cargo', required: true) + +prefix = get_option('prefix') +bindir = prefix / get_option('bindir') +datadir = prefix / get_option('datadir') +iconsdir = datadir / 'icons' + +subdir('src') +subdir('icons') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..42ea3a2 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,31 @@ +cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] +cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] + +if get_option('buildtype') == 'release' or get_option('buildtype') == 'plain' + cargo_options += [ '--release' ] + rust_target = 'release' + message('Building in release mode') +else + rust_target = 'debug' + message('Building in debug mode') +endif + +cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] + +custom_target( + 'cargo-build', + build_by_default: true, + build_always_stale: true, + output: meson.project_name(), + console: true, + install: true, + install_dir: bindir, + command: [ + 'env', + cargo_env, + cargo, 'build', + cargo_options, + '&&', + 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', + ], +) diff --git a/src/tray/menu.rs b/src/tray/menu.rs index 02280a6..59e3cf8 100644 --- a/src/tray/menu.rs +++ b/src/tray/menu.rs @@ -74,11 +74,7 @@ impl SysTray { ); if output.status.success() { - let verb_result = if verb.eq("up") { - "connected" - } else { - "disconnected" - }; + let verb_result = if verb.eq("up") { "online" } else { "offline" }; // send notification through dbus let _result = Notification::new() From bc7f659df1a51d8bbfae39c222593004d633f2df Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 11 Jul 2024 23:26:43 +0300 Subject: [PATCH 2/2] nix/package: update derivation --- nix/package.nix | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/nix/package.nix b/nix/package.nix index 80cf180..06f3f36 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,31 +1,29 @@ { lib, + stdenv, + cargo, dbus, + meson, + ninja, python3, pkg-config, + rustc, rustPlatform, xorg, rev ? "dirty", }: let cargoToml = builtins.fromTOML (builtins.readFile ../Cargo.toml); in - rustPlatform.buildRustPackage { + stdenv.mkDerivation { pname = "tailray"; version = "${cargoToml.package.version}-${rev}"; - src = lib.fileset.toSource { - root = ../.; - fileset = - lib.fileset.intersection - (lib.fileset.fromSource (lib.sources.cleanSource ../.)) - (lib.fileset.unions [ - ../src - ../Cargo.toml - ../Cargo.lock - ]); + src = builtins.path { + name = "tailray"; + path = ../.; }; - cargoLock = { + cargoDeps = rustPlatform.importCargoLock { lockFile = ../Cargo.lock; outputHashes = { "ksni-0.2.1" = "sha256-CKjOUGsqlMdgnNY6j29pP6S8wdZ73/v1dMyiIurlltI="; @@ -34,13 +32,25 @@ in strictDeps = true; - nativeBuildInputs = [pkg-config python3]; - buildInputs = [dbus xorg.libxcb]; + nativeBuildInputs = [ + meson + ninja + pkg-config + rustPlatform.cargoSetupHook + cargo + rustc + python3 + ]; + + buildInputs = [ + dbus + xorg.libxcb + ]; meta = { description = "Rust implementation of tailscale-systray"; homepage = "https://github.com/notashelf/tailray"; - license = lib.licenses.gpl3Plus; + license = lib.licenses.mit; mainProgram = "tailray"; maintainers = with lib.maintainers; [NotAShelf]; };