treewide: clang and nix format
This commit is contained in:
19
default.nix
19
default.nix
@ -1,10 +1,9 @@
|
||||
(import
|
||||
(
|
||||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
)
|
||||
{ src = ./.; }
|
||||
).defaultNix
|
||||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
) { src = ./.; }).defaultNix
|
||||
|
106
flake.nix
106
flake.nix
@ -9,48 +9,68 @@
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }:
|
||||
outputs =
|
||||
{ self, nixpkgs, ... }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
genSystems = func: lib.genAttrs [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
]
|
||||
(system: func (import nixpkgs {
|
||||
inherit system;
|
||||
overlays = with self.overlays; [
|
||||
waybar
|
||||
];
|
||||
}));
|
||||
genSystems =
|
||||
func:
|
||||
lib.genAttrs
|
||||
[
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
]
|
||||
(
|
||||
system:
|
||||
func (
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = with self.overlays; [
|
||||
waybar
|
||||
];
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
mkDate = longDate: (lib.concatStringsSep "-" [
|
||||
(builtins.substring 0 4 longDate)
|
||||
(builtins.substring 4 2 longDate)
|
||||
(builtins.substring 6 2 longDate)
|
||||
]);
|
||||
mkDate =
|
||||
longDate:
|
||||
(lib.concatStringsSep "-" [
|
||||
(builtins.substring 0 4 longDate)
|
||||
(builtins.substring 4 2 longDate)
|
||||
(builtins.substring 6 2 longDate)
|
||||
]);
|
||||
in
|
||||
{
|
||||
devShells = genSystems
|
||||
(pkgs:
|
||||
{
|
||||
default =
|
||||
pkgs.mkShell
|
||||
{
|
||||
name = "waybar-shell";
|
||||
devShells = genSystems (pkgs: {
|
||||
default = pkgs.mkShell {
|
||||
name = "waybar-shell";
|
||||
|
||||
# inherit attributes from upstream nixpkgs derivation
|
||||
inherit (pkgs.waybar) buildInputs depsBuildBuild depsBuildBuildPropagated depsBuildTarget
|
||||
depsBuildTargetPropagated depsHostHost depsHostHostPropagated depsTargetTarget
|
||||
depsTargetTargetPropagated propagatedBuildInputs propagatedNativeBuildInputs strictDeps;
|
||||
# inherit attributes from upstream nixpkgs derivation
|
||||
inherit (pkgs.waybar)
|
||||
buildInputs
|
||||
depsBuildBuild
|
||||
depsBuildBuildPropagated
|
||||
depsBuildTarget
|
||||
depsBuildTargetPropagated
|
||||
depsHostHost
|
||||
depsHostHostPropagated
|
||||
depsTargetTarget
|
||||
depsTargetTargetPropagated
|
||||
propagatedBuildInputs
|
||||
propagatedNativeBuildInputs
|
||||
strictDeps
|
||||
;
|
||||
|
||||
# overrides for local development
|
||||
nativeBuildInputs = pkgs.waybar.nativeBuildInputs ++ (with pkgs; [
|
||||
nixfmt-rfc-style
|
||||
clang-tools
|
||||
gdb
|
||||
]);
|
||||
};
|
||||
});
|
||||
# overrides for local development
|
||||
nativeBuildInputs =
|
||||
pkgs.waybar.nativeBuildInputs
|
||||
++ (with pkgs; [
|
||||
nixfmt-rfc-style
|
||||
clang-tools
|
||||
gdb
|
||||
]);
|
||||
};
|
||||
});
|
||||
|
||||
formatter = genSystems (
|
||||
pkgs:
|
||||
@ -61,7 +81,7 @@
|
||||
clang-format = {
|
||||
options = [ "-i" ];
|
||||
command = lib.getExe' pkgs.clang-tools "clang-format";
|
||||
excludes = [];
|
||||
excludes = [ ];
|
||||
includes = [
|
||||
"*.c"
|
||||
"*.cpp"
|
||||
@ -87,11 +107,15 @@
|
||||
waybar = prev.waybar;
|
||||
# take the first "version: '...'" from meson.build
|
||||
version =
|
||||
(builtins.head (builtins.split "'"
|
||||
(builtins.elemAt
|
||||
(builtins.split " version: '" (builtins.readFile ./meson.build))
|
||||
2)))
|
||||
+ "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
||||
(builtins.head (
|
||||
builtins.split "'" (
|
||||
builtins.elemAt (builtins.split " version: '" (builtins.readFile ./meson.build)) 2
|
||||
)
|
||||
))
|
||||
+ "+date="
|
||||
+ (mkDate (self.lastModifiedDate or "19700101"))
|
||||
+ "_"
|
||||
+ (self.shortRev or "dirty");
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,8 @@
|
||||
{ lib
|
||||
, pkgs
|
||||
, waybar
|
||||
, version
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
waybar,
|
||||
version,
|
||||
}:
|
||||
let
|
||||
libcava = rec {
|
||||
@ -14,31 +15,29 @@ let
|
||||
};
|
||||
};
|
||||
in
|
||||
(waybar.overrideAttrs (
|
||||
oldAttrs: {
|
||||
inherit version;
|
||||
(waybar.overrideAttrs (oldAttrs: {
|
||||
inherit version;
|
||||
|
||||
src = lib.cleanSourceWith {
|
||||
filter = name: type: type != "regular" || !lib.hasSuffix ".nix" name;
|
||||
src = lib.cleanSource ../.;
|
||||
};
|
||||
src = lib.cleanSourceWith {
|
||||
filter = name: type: type != "regular" || !lib.hasSuffix ".nix" name;
|
||||
src = lib.cleanSource ../.;
|
||||
};
|
||||
|
||||
mesonFlags = lib.remove "-Dgtk-layer-shell=enabled" oldAttrs.mesonFlags;
|
||||
mesonFlags = lib.remove "-Dgtk-layer-shell=enabled" oldAttrs.mesonFlags;
|
||||
|
||||
# downstream patch should not affect upstream
|
||||
patches = [];
|
||||
# nixpkgs checks version, no need when building locally
|
||||
nativeInstallCheckInputs = [];
|
||||
# downstream patch should not affect upstream
|
||||
patches = [ ];
|
||||
# nixpkgs checks version, no need when building locally
|
||||
nativeInstallCheckInputs = [ ];
|
||||
|
||||
buildInputs = (builtins.filter (p: p.pname != "wireplumber") oldAttrs.buildInputs) ++ [
|
||||
pkgs.wireplumber
|
||||
];
|
||||
buildInputs = (builtins.filter (p: p.pname != "wireplumber") oldAttrs.buildInputs) ++ [
|
||||
pkgs.wireplumber
|
||||
];
|
||||
|
||||
postUnpack = ''
|
||||
pushd "$sourceRoot"
|
||||
cp -R --no-preserve=mode,ownership ${libcava.src} subprojects/cava-${libcava.version}
|
||||
patchShebangs .
|
||||
popd
|
||||
'';
|
||||
}
|
||||
))
|
||||
postUnpack = ''
|
||||
pushd "$sourceRoot"
|
||||
cp -R --no-preserve=mode,ownership ${libcava.src} subprojects/cava-${libcava.version}
|
||||
patchShebangs .
|
||||
popd
|
||||
'';
|
||||
}))
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "modules/sni/item.hpp"
|
||||
#include "modules/sni/icon_manager.hpp"
|
||||
|
||||
#include <gdkmm/general.h>
|
||||
#include <glibmm/main.h>
|
||||
#include <gtkmm/tooltip.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <filesystem>
|
||||
|
||||
#include "gdk/gdk.h"
|
||||
#include "modules/sni/icon_manager.hpp"
|
||||
#include "util/format.hpp"
|
||||
#include "util/gtk_icon.hpp"
|
||||
|
||||
@ -206,10 +206,10 @@ void Item::setCustomIcon(const std::string& id) {
|
||||
std::string custom_icon = IconManager::instance().getIconForApp(id);
|
||||
if (!custom_icon.empty()) {
|
||||
if (std::filesystem::exists(custom_icon)) {
|
||||
Glib::RefPtr<Gdk::Pixbuf> custom_pixbuf = Gdk::Pixbuf::create_from_file(custom_icon);
|
||||
icon_name = ""; // icon_name has priority over pixmap
|
||||
icon_pixmap = custom_pixbuf;
|
||||
} else { // if file doesn't exist it's most likely an icon_name
|
||||
Glib::RefPtr<Gdk::Pixbuf> custom_pixbuf = Gdk::Pixbuf::create_from_file(custom_icon);
|
||||
icon_name = ""; // icon_name has priority over pixmap
|
||||
icon_pixmap = custom_pixbuf;
|
||||
} else { // if file doesn't exist it's most likely an icon_name
|
||||
icon_name = custom_icon;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "modules/sni/tray.hpp"
|
||||
#include "modules/sni/icon_manager.hpp"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include "modules/sni/icon_manager.hpp"
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
|
@ -115,10 +115,10 @@ float waybar::modules::Temperature::getTemperature() {
|
||||
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
|
||||
|
||||
// First, try with dev.cpu
|
||||
if ( (sysctlbyname(fmt::format("dev.cpu.{}.temperature", zone).c_str(), &temp, &size,
|
||||
NULL, 0) == 0) ||
|
||||
(sysctlbyname(fmt::format("hw.acpi.thermal.tz{}.temperature", zone).c_str(), &temp, &size,
|
||||
NULL, 0) == 0) ) {
|
||||
if ((sysctlbyname(fmt::format("dev.cpu.{}.temperature", zone).c_str(), &temp, &size, NULL, 0) ==
|
||||
0) ||
|
||||
(sysctlbyname(fmt::format("hw.acpi.thermal.tz{}.temperature", zone).c_str(), &temp, &size,
|
||||
NULL, 0) == 0)) {
|
||||
auto temperature_c = ((float)temp - 2732) / 10;
|
||||
return temperature_c;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ std::string Task::state_string(bool shortened) const {
|
||||
return res.substr(0, res.size() - 1);
|
||||
}
|
||||
|
||||
void Task::handle_title(const char* title) {
|
||||
void Task::handle_title(const char *title) {
|
||||
if (title_.empty()) {
|
||||
spdlog::debug(fmt::format("Task ({}) setting title to {}", id_, title_));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user