mirror of
https://github.com/imgurbot12/rmenu.git
synced 2025-01-12 23:36:29 +01:00
Merge pull request #5 from LordGrimmauld/feat/v1.1.0
Add nix tooling and fix XDG path search
This commit is contained in:
commit
9236afb93a
9 changed files with 5012 additions and 5 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
target
|
target
|
||||||
Cargo.lock
|
# Cargo.lock
|
||||||
|
result
|
||||||
|
.idea
|
||||||
|
|
4776
Cargo.lock
generated
Normal file
4776
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
26
flake.lock
Normal file
26
flake.lock
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1711655175,
|
||||||
|
"narHash": "sha256-1xiaYhC3ul4y+i3eicYxeERk8ZkrNjLkrFSb/UW36Zw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "64c81edb4b97a51c5bbc54c191763ac71a6517ee",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
99
flake.nix
Normal file
99
flake.nix
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
{
|
||||||
|
description = "rmenu: Another customizable Application-Launcher written in Rust";
|
||||||
|
|
||||||
|
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
nixpkgs,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
||||||
|
in {
|
||||||
|
devShells = forAllSystems (system: let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml));
|
||||||
|
libPath = with pkgs; lib.makeLibraryPath [
|
||||||
|
# load external libraries that you need in your rust project here
|
||||||
|
glib
|
||||||
|
gtk3
|
||||||
|
libsoup_3
|
||||||
|
networkmanager
|
||||||
|
webkitgtk_4_1
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
llvmPackages.bintools
|
||||||
|
rustup
|
||||||
|
];
|
||||||
|
RUSTC_VERSION = overrides.toolchain.channel;
|
||||||
|
# https://github.com/rust-lang/rust-bindgen#environment-variables
|
||||||
|
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
|
||||||
|
shellHook = ''
|
||||||
|
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
|
||||||
|
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Add precompiled library to rustc search path
|
||||||
|
RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
|
||||||
|
# add libraries here (e.g. pkgs.libvmi)
|
||||||
|
]);
|
||||||
|
LD_LIBRARY_PATH = libPath;
|
||||||
|
# Add glibc, clang, glib, and other headers to bindgen search path
|
||||||
|
BINDGEN_EXTRA_CLANG_ARGS =
|
||||||
|
# Includes normal include path
|
||||||
|
(builtins.map (a: ''-I"${a}/include"'') [
|
||||||
|
# add dev libraries here (e.g. pkgs.libvmi.dev)
|
||||||
|
pkgs.glibc.dev
|
||||||
|
])
|
||||||
|
# Includes with special directory paths
|
||||||
|
++ [
|
||||||
|
''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
|
||||||
|
''-I"${pkgs.glib.dev}/include/glib-2.0"''
|
||||||
|
''-I${pkgs.glib.out}/lib/glib-2.0/include/''
|
||||||
|
];
|
||||||
|
packages = with pkgs; [
|
||||||
|
# base toolchain
|
||||||
|
pkg-config
|
||||||
|
rustup
|
||||||
|
|
||||||
|
# runtime deps
|
||||||
|
glib
|
||||||
|
gtk3
|
||||||
|
libsoup_3
|
||||||
|
networkmanager
|
||||||
|
webkitgtk_4_1
|
||||||
|
|
||||||
|
# nix utils
|
||||||
|
self.formatter.${pkgs.system}
|
||||||
|
nil
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
formatter = forAllSystems (system: let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in pkgs.alejandra);
|
||||||
|
packages = forAllSystems (system: let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
rmenu-pkg = (pkgs.callPackage ./nix/package.nix {});
|
||||||
|
in {
|
||||||
|
rmenu = rmenu-pkg;
|
||||||
|
default = rmenu-pkg;
|
||||||
|
});
|
||||||
|
|
||||||
|
nixosModules = let
|
||||||
|
rmenu-module = (import ./nix/rmenu.nix);
|
||||||
|
in {
|
||||||
|
rmenu = rmenu-module;
|
||||||
|
default = rmenu-module;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
91
nix/package.nix
Normal file
91
nix/package.nix
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
{ cargo
|
||||||
|
, fetchFromGitHub
|
||||||
|
, glib
|
||||||
|
, gnused
|
||||||
|
, gtk3
|
||||||
|
, lib
|
||||||
|
, libsoup_3
|
||||||
|
, networkmanager
|
||||||
|
, pkg-config
|
||||||
|
, rustPlatform
|
||||||
|
, rustc
|
||||||
|
, stdenv
|
||||||
|
, webkitgtk_4_1
|
||||||
|
, wrapGAppsHook
|
||||||
|
}:
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
version = "1.1.0";
|
||||||
|
pname = "rmenu";
|
||||||
|
|
||||||
|
src = lib.cleanSource ../.;
|
||||||
|
|
||||||
|
# src = fetchFromGitHub {
|
||||||
|
# rev = "188f542"; # "v${version}";
|
||||||
|
# owner = "imgurbot12";
|
||||||
|
# repo = pname;
|
||||||
|
# hash = "sha256-IRwYxjyHdP6794pQjyyUmofO8uakMY22pqdFkJZ5Mdo=";
|
||||||
|
# };
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = ../Cargo.lock;
|
||||||
|
outputHashes = {
|
||||||
|
"gio-0.19.0" = "sha256-+PAQNJ9sTk8aKAhA/PLQWDCKDT/cQ+ukdbem7g1J+pU=";
|
||||||
|
"nm-0.4.0" = "sha256-53ipJU10ZhIKIF7PCw5Eo/e/reUK0qpyTyE7uIrCD88=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkg-config
|
||||||
|
wrapGAppsHook
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
glib
|
||||||
|
gtk3
|
||||||
|
libsoup_3
|
||||||
|
networkmanager
|
||||||
|
webkitgtk_4_1
|
||||||
|
gnused
|
||||||
|
];
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
# copy themes and plugins
|
||||||
|
mkdir $out/themes
|
||||||
|
mkdir $out/plugins
|
||||||
|
cp -vfr $src/themes/* $out/themes/.
|
||||||
|
cp -vfr $src/other-plugins/* $out/plugins/.
|
||||||
|
mv $out/bin/* $out/plugins # everything is a plugin by default
|
||||||
|
|
||||||
|
# rmenu and rmenu-build are actual binaries
|
||||||
|
mv $out/plugins/rmenu $out/bin/rmenu
|
||||||
|
mv $out/plugins/rmenu-build $out/bin/rmenu-build
|
||||||
|
|
||||||
|
# fix plugin names
|
||||||
|
# desktop network pactl-audio.sh powermenu.sh run window
|
||||||
|
mv $out/plugins/run $out/plugins/rmenu-run
|
||||||
|
mv $out/plugins/desktop $out/plugins/rmenu-desktop
|
||||||
|
mv $out/plugins/network $out/plugins/rmenu-network
|
||||||
|
mv $out/plugins/window $out/plugins/rmenu-window
|
||||||
|
|
||||||
|
# fix config and theme
|
||||||
|
mkdir -p $out/etc/xdg/rmenu
|
||||||
|
cp -vf $src/rmenu/public/config.yaml $out/etc/xdg/rmenu/config.yaml
|
||||||
|
sed -i "s@~\/\.config\/rmenu\/themes@$out\/themes@g" $out/etc/xdg/rmenu/config.yaml
|
||||||
|
sed -i "s@~\/\.config\/rmenu@$out\/plugins@g" $out/etc/xdg/rmenu/config.yaml
|
||||||
|
ln -sf $out/themes/dark.css $out/etc/xdg/rmenu/style.css
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
changelog = "https://github.com/imgurbot12/rmenu/commits/master/";
|
||||||
|
description = "Another customizable Application-Launcher written in Rust ";
|
||||||
|
homepage = "https://github.com/imgurbot12/rmenu";
|
||||||
|
mainProgram = "rmenu";
|
||||||
|
maintainers = [ maintainers.grimmauld ];
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
8
nix/rmenu.nix
Normal file
8
nix/rmenu.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
rmenu-pkg = pkgs.callPackage ./package.nix {};
|
||||||
|
in {
|
||||||
|
config.environment.systemPackages = [ rmenu-pkg ];
|
||||||
|
|
||||||
|
meta.maintainers = with lib.maintainers; [ grimmauld ];
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rmenu"
|
name = "rmenu"
|
||||||
version = "0.0.1"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -30,3 +30,4 @@ shellexpand = "3.1.0"
|
||||||
strfmt = "0.2.4"
|
strfmt = "0.2.4"
|
||||||
thiserror = "1.0.43"
|
thiserror = "1.0.43"
|
||||||
which = "4.4.0"
|
which = "4.4.0"
|
||||||
|
xdg = "2.5.2"
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rmenu_plugin::{Entry, Message};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::config::{cfg_replace, Config, Keybind};
|
use crate::config::{cfg_replace, Config, Keybind};
|
||||||
use crate::{CONFIG_DIR, DEFAULT_CONFIG, DEFAULT_THEME};
|
use crate::{DEFAULT_CONFIG, DEFAULT_THEME};
|
||||||
|
|
||||||
/// Allowed Formats for Entry Ingestion
|
/// Allowed Formats for Entry Ingestion
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -182,8 +182,10 @@ impl Args {
|
||||||
/// Find Configuration Path
|
/// Find Configuration Path
|
||||||
pub fn find_config(&self) -> PathBuf {
|
pub fn find_config(&self) -> PathBuf {
|
||||||
self.config.clone().unwrap_or_else(|| {
|
self.config.clone().unwrap_or_else(|| {
|
||||||
let cfgdir = std::env::var("XDG_CONFIG_DIR").unwrap_or_else(|_| CONFIG_DIR.to_string());
|
xdg::BaseDirectories::with_prefix("rmenu")
|
||||||
PathBuf::from(cfgdir).join(DEFAULT_CONFIG)
|
.expect("Failed to read xdg base dirs")
|
||||||
|
.find_config_file(DEFAULT_CONFIG)
|
||||||
|
.unwrap_or_else(PathBuf::new)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "stable"
|
Loading…
Reference in a new issue