Config: use hyprutils helper (#77)

* flake.lock: update

* config: use hyprutils helper

* Nix: add hyprutils dep

flake.lock: update
This commit is contained in:
Mihai Fufezan 2024-07-16 23:36:07 +03:00 committed by GitHub
parent 7c5747b785
commit fc4e3bd2dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 57 additions and 35 deletions

View file

@ -33,7 +33,7 @@ message(STATUS "Checking deps...")
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols hyprlang>=0.4.0 sdbus-c++) pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols hyprlang>=0.4.0 hyprutils>=0.2.0 sdbus-c++)
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(hypridle ${SRCFILES}) add_executable(hypridle ${SRCFILES})

View file

@ -2,17 +2,22 @@
"nodes": { "nodes": {
"hyprlang": { "hyprlang": {
"inputs": { "inputs": {
"hyprutils": [
"hyprutils"
],
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
"systems": "systems" "systems": [
"systems"
]
}, },
"locked": { "locked": {
"lastModified": 1713121246, "lastModified": 1720381373,
"narHash": "sha256-502X0Q0fhN6tJK7iEUA8CghONKSatW/Mqj4Wappd++0=", "narHash": "sha256-lyC/EZdHULsaAKVryK11lgHY9u6pXr7qR4irnxNWC7k=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "hyprlang", "repo": "hyprlang",
"rev": "78fcaa27ae9e1d782faa3ff06c8ea55ddce63706", "rev": "5df0174fd09de4ac5475233d65ffc703e89b82eb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -21,13 +26,36 @@
"type": "github" "type": "github"
} }
}, },
"hyprutils": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1721071737,
"narHash": "sha256-qmC9jGfbE4+EIBbbSAkrfR/p49wShjpv4/KztgE/P54=",
"owner": "hyprwm",
"repo": "hyprutils",
"rev": "eb1ceff2b87f6820789249f63faa8e9dcb54d05f",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprutils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1712963716, "lastModified": 1720957393,
"narHash": "sha256-WKm9CvgCldeIVvRz87iOMi8CFVB1apJlkUT4GGvA0iM=", "narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "cfd6b5fc90b15709b780a5a1619695a88505a176", "rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -40,8 +68,9 @@
"root": { "root": {
"inputs": { "inputs": {
"hyprlang": "hyprlang", "hyprlang": "hyprlang",
"hyprutils": "hyprutils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"systems": "systems_2" "systems": "systems"
} }
}, },
"systems": { "systems": {
@ -58,21 +87,6 @@
"repo": "default-linux", "repo": "default-linux",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -8,6 +8,14 @@
hyprlang = { hyprlang = {
url = "github:hyprwm/hyprlang"; url = "github:hyprwm/hyprlang";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
};
hyprutils = {
url = "github:hyprwm/hyprutils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
}; };
}; };

View file

@ -4,6 +4,7 @@
cmake, cmake,
pkg-config, pkg-config,
hyprlang, hyprlang,
hyprutils,
sdbus-cpp, sdbus-cpp,
systemd, systemd,
wayland, wayland,
@ -22,6 +23,7 @@ stdenv.mkDerivation {
buildInputs = [ buildInputs = [
hyprlang hyprlang
hyprutils
sdbus-cpp sdbus-cpp
systemd systemd
wayland wayland

View file

@ -12,6 +12,7 @@ in {
hypridle = lib.composeManyExtensions [ hypridle = lib.composeManyExtensions [
inputs.hyprlang.overlays.default inputs.hyprlang.overlays.default
inputs.hyprutils.overlays.default
(final: prev: { (final: prev: {
hypridle = prev.callPackage ./default.nix { hypridle = prev.callPackage ./default.nix {
stdenv = prev.gcc13Stdenv; stdenv = prev.gcc13Stdenv;

View file

@ -1,20 +1,17 @@
#include "ConfigManager.hpp" #include "ConfigManager.hpp"
#include <hyprutils/path/Path.hpp>
#include <filesystem> #include <filesystem>
static std::string getConfigDir() {
static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if (xdgConfigHome && std::filesystem::path(xdgConfigHome).is_absolute())
return xdgConfigHome;
return getenv("HOME") + std::string("/.config");
}
static std::string getMainConfigPath() { static std::string getMainConfigPath() {
return getConfigDir() + "/hypr/hypridle.conf"; static const auto paths = Hyprutils::Path::findConfig("hypridle");
if (paths.first.has_value())
return paths.first.value();
else
throw std::runtime_error("Could not find config in HOME, XDG_CONFIG_HOME, XDG_CONFIG_DIRS or /etc/hypr.");
} }
CConfigManager::CConfigManager(std::string configPath) : m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) { CConfigManager::CConfigManager(std::string configPath) :
m_config(configPath.empty() ? getMainConfigPath().c_str() : configPath.c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = false}) {
; ;
} }