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/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]; }; 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 bffa52a..0293969 100644 --- a/src/tray/menu.rs +++ b/src/tray/menu.rs @@ -72,11 +72,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" }; Notification::new() .summary(format!("Connection {}", verb).as_str())