treewide: clang and nix format

This commit is contained in:
Austin Horstman
2025-04-15 14:56:28 -05:00
parent 5c48373cfe
commit 55f52c3457
7 changed files with 113 additions and 90 deletions

View File

@ -1,10 +1,9 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
(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
) { src = ./.; }).defaultNix

View File

@ -9,42 +9,62 @@
};
};
outputs = { self, nixpkgs, ... }:
outputs =
{ self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
genSystems = func: lib.genAttrs [
genSystems =
func:
lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
]
(system: func (import nixpkgs {
(
system:
func (
import nixpkgs {
inherit system;
overlays = with self.overlays; [
waybar
];
}));
}
)
);
mkDate = longDate: (lib.concatStringsSep "-" [
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
{
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 (pkgs.waybar)
buildInputs
depsBuildBuild
depsBuildBuildPropagated
depsBuildTarget
depsBuildTargetPropagated
depsHostHost
depsHostHostPropagated
depsTargetTarget
depsTargetTargetPropagated
propagatedBuildInputs
propagatedNativeBuildInputs
strictDeps
;
# overrides for local development
nativeBuildInputs = pkgs.waybar.nativeBuildInputs ++ (with pkgs; [
nativeBuildInputs =
pkgs.waybar.nativeBuildInputs
++ (with pkgs; [
nixfmt-rfc-style
clang-tools
gdb
@ -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");
};
};
};

View File

@ -1,7 +1,8 @@
{ lib
, pkgs
, waybar
, version
{
lib,
pkgs,
waybar,
version,
}:
let
libcava = rec {
@ -14,8 +15,7 @@ let
};
};
in
(waybar.overrideAttrs (
oldAttrs: {
(waybar.overrideAttrs (oldAttrs: {
inherit version;
src = lib.cleanSourceWith {
@ -40,5 +40,4 @@ in
patchShebangs .
popd
'';
}
))
}))

View File

@ -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"

View File

@ -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)

View File

@ -115,8 +115,8 @@ 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) ||
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;