hyprpm: add full nix integration (#13189)
Adds nix integration to hyprpm: hyprpm will now detect nix'd hyprland and use nix develop instead --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
339661229d
commit
857a78ce4e
5 changed files with 150 additions and 34 deletions
|
|
@ -35,9 +35,13 @@ static std::string validSubinsAsStr() {
|
|||
}
|
||||
|
||||
static bool executableExistsInPath(const std::string& exe) {
|
||||
return NSys::findInPath(exe).has_value();
|
||||
}
|
||||
|
||||
std::optional<std::string> NSys::findInPath(const std::string& exe) {
|
||||
const char* PATHENV = std::getenv("PATH");
|
||||
if (!PATHENV)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
|
||||
CVarList paths(PATHENV, 0, ':', true);
|
||||
std::error_code ec;
|
||||
|
|
@ -52,10 +56,10 @@ static bool executableExistsInPath(const std::string& exe) {
|
|||
if (ec)
|
||||
continue;
|
||||
if ((perms & std::filesystem::perms::others_exec) != std::filesystem::perms::none)
|
||||
return true;
|
||||
return candidate.string();
|
||||
}
|
||||
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static std::string subin() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
namespace NSys {
|
||||
bool isSuperuser();
|
||||
int getUID();
|
||||
int getEUID();
|
||||
bool isSuperuser();
|
||||
int getUID();
|
||||
int getEUID();
|
||||
std::optional<std::string> findInPath(const std::string& exe);
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
namespace root {
|
||||
|
|
@ -20,4 +22,4 @@ namespace NSys {
|
|||
// Do not use this unless absolutely necessary!
|
||||
std::string runAsSuperuserUnsafe(const std::string& cmd);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue