Skip to content

Commit 5898284

Browse files
committed
treewide: clang and nix format
1 parent 674832a commit 5898284

File tree

6 files changed

+125
-94
lines changed

6 files changed

+125
-94
lines changed

default.nix

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
(import
2-
(
3-
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
4-
fetchTarball {
5-
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
6-
sha256 = lock.nodes.flake-compat.locked.narHash;
7-
}
8-
)
9-
{ src = ./.; }
10-
).defaultNix
1+
(import (
2+
let
3+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
4+
in
5+
fetchTarball {
6+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
7+
sha256 = lock.nodes.flake-compat.locked.narHash;
8+
}
9+
) { src = ./.; }).defaultNix

flake.nix

+78-46
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,83 @@
1313
};
1414
};
1515

16-
outputs = { self, nixpkgs, treefmt-nix, ... }:
16+
outputs =
17+
{
18+
self,
19+
nixpkgs,
20+
treefmt-nix,
21+
...
22+
}:
1723
let
1824
inherit (nixpkgs) lib;
19-
genSystems = func: lib.genAttrs [
20-
"x86_64-linux"
21-
"aarch64-linux"
22-
]
23-
(system: func (import nixpkgs {
24-
inherit system;
25-
overlays = with self.overlays; [
26-
waybar
27-
];
28-
}));
25+
genSystems =
26+
func:
27+
lib.genAttrs
28+
[
29+
"x86_64-linux"
30+
"aarch64-linux"
31+
]
32+
(
33+
system:
34+
func (
35+
import nixpkgs {
36+
inherit system;
37+
overlays = with self.overlays; [
38+
waybar
39+
];
40+
}
41+
)
42+
);
2943

30-
mkDate = longDate: (lib.concatStringsSep "-" [
31-
(builtins.substring 0 4 longDate)
32-
(builtins.substring 4 2 longDate)
33-
(builtins.substring 6 2 longDate)
34-
]);
44+
mkDate =
45+
longDate:
46+
(lib.concatStringsSep "-" [
47+
(builtins.substring 0 4 longDate)
48+
(builtins.substring 4 2 longDate)
49+
(builtins.substring 6 2 longDate)
50+
]);
3551

36-
treefmtEval = genSystems (pkgs: treefmt-nix.lib.evalModule pkgs {
37-
# Formatting configuration
38-
programs = {
39-
clang-format.enable = true;
40-
nixfmt.enable = true;
41-
};
42-
});
52+
treefmtEval = genSystems (
53+
pkgs:
54+
treefmt-nix.lib.evalModule pkgs {
55+
# Formatting configuration
56+
programs = {
57+
clang-format.enable = true;
58+
nixfmt.enable = true;
59+
};
60+
}
61+
);
4362
in
4463
{
45-
devShells = genSystems
46-
(pkgs:
47-
{
48-
default =
49-
pkgs.mkShell
50-
{
51-
name = "waybar-shell";
64+
devShells = genSystems (pkgs: {
65+
default = pkgs.mkShell {
66+
name = "waybar-shell";
5267

53-
# inherit attributes from upstream nixpkgs derivation
54-
inherit (pkgs.waybar) buildInputs depsBuildBuild depsBuildBuildPropagated depsBuildTarget
55-
depsBuildTargetPropagated depsHostHost depsHostHostPropagated depsTargetTarget
56-
depsTargetTargetPropagated propagatedBuildInputs propagatedNativeBuildInputs strictDeps;
68+
# inherit attributes from upstream nixpkgs derivation
69+
inherit (pkgs.waybar)
70+
buildInputs
71+
depsBuildBuild
72+
depsBuildBuildPropagated
73+
depsBuildTarget
74+
depsBuildTargetPropagated
75+
depsHostHost
76+
depsHostHostPropagated
77+
depsTargetTarget
78+
depsTargetTargetPropagated
79+
propagatedBuildInputs
80+
propagatedNativeBuildInputs
81+
strictDeps
82+
;
5783

58-
# overrides for local development
59-
nativeBuildInputs = pkgs.waybar.nativeBuildInputs ++ (with pkgs; [
60-
clang-tools
61-
gdb
62-
]);
63-
};
64-
});
84+
# overrides for local development
85+
nativeBuildInputs =
86+
pkgs.waybar.nativeBuildInputs
87+
++ (with pkgs; [
88+
clang-tools
89+
gdb
90+
]);
91+
};
92+
});
6593

6694
formatter = genSystems (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
6795

@@ -72,11 +100,15 @@
72100
waybar = prev.waybar;
73101
# take the first "version: '...'" from meson.build
74102
version =
75-
(builtins.head (builtins.split "'"
76-
(builtins.elemAt
77-
(builtins.split " version: '" (builtins.readFile ./meson.build))
78-
2)))
79-
+ "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
103+
(builtins.head (
104+
builtins.split "'" (
105+
builtins.elemAt (builtins.split " version: '" (builtins.readFile ./meson.build)) 2
106+
)
107+
))
108+
+ "+date="
109+
+ (mkDate (self.lastModifiedDate or "19700101"))
110+
+ "_"
111+
+ (self.shortRev or "dirty");
80112
};
81113
};
82114
};

nix/default.nix

+26-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
{ lib
2-
, pkgs
3-
, waybar
4-
, version
1+
{
2+
lib,
3+
pkgs,
4+
waybar,
5+
version,
56
}:
67
let
78
libcava = rec {
@@ -14,31 +15,29 @@ let
1415
};
1516
};
1617
in
17-
(waybar.overrideAttrs (
18-
oldAttrs: {
19-
inherit version;
18+
(waybar.overrideAttrs (oldAttrs: {
19+
inherit version;
2020

21-
src = lib.cleanSourceWith {
22-
filter = name: type: type != "regular" || !lib.hasSuffix ".nix" name;
23-
src = lib.cleanSource ../.;
24-
};
21+
src = lib.cleanSourceWith {
22+
filter = name: type: type != "regular" || !lib.hasSuffix ".nix" name;
23+
src = lib.cleanSource ../.;
24+
};
2525

26-
mesonFlags = lib.remove "-Dgtk-layer-shell=enabled" oldAttrs.mesonFlags;
26+
mesonFlags = lib.remove "-Dgtk-layer-shell=enabled" oldAttrs.mesonFlags;
2727

28-
# downstream patch should not affect upstream
29-
patches = [];
30-
# nixpkgs checks version, no need when building locally
31-
nativeInstallCheckInputs = [];
28+
# downstream patch should not affect upstream
29+
patches = [ ];
30+
# nixpkgs checks version, no need when building locally
31+
nativeInstallCheckInputs = [ ];
3232

33-
buildInputs = (builtins.filter (p: p.pname != "wireplumber") oldAttrs.buildInputs) ++ [
34-
pkgs.wireplumber
35-
];
33+
buildInputs = (builtins.filter (p: p.pname != "wireplumber") oldAttrs.buildInputs) ++ [
34+
pkgs.wireplumber
35+
];
3636

37-
postUnpack = ''
38-
pushd "$sourceRoot"
39-
cp -R --no-preserve=mode,ownership ${libcava.src} subprojects/cava-${libcava.version}
40-
patchShebangs .
41-
popd
42-
'';
43-
}
44-
))
37+
postUnpack = ''
38+
pushd "$sourceRoot"
39+
cp -R --no-preserve=mode,ownership ${libcava.src} subprojects/cava-${libcava.version}
40+
patchShebangs .
41+
popd
42+
'';
43+
}))

src/modules/sni/item.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#include "modules/sni/item.hpp"
2-
#include "modules/sni/icon_manager.hpp"
32

43
#include <gdkmm/general.h>
54
#include <glibmm/main.h>
65
#include <gtkmm/tooltip.h>
76
#include <spdlog/spdlog.h>
87

8+
#include <filesystem>
99
#include <fstream>
1010
#include <map>
11-
#include <filesystem>
1211

1312
#include "gdk/gdk.h"
13+
#include "modules/sni/icon_manager.hpp"
1414
#include "util/format.hpp"
1515
#include "util/gtk_icon.hpp"
1616

@@ -206,10 +206,10 @@ void Item::setCustomIcon(const std::string& id) {
206206
std::string custom_icon = IconManager::instance().getIconForApp(id);
207207
if (!custom_icon.empty()) {
208208
if (std::filesystem::exists(custom_icon)) {
209-
Glib::RefPtr<Gdk::Pixbuf> custom_pixbuf = Gdk::Pixbuf::create_from_file(custom_icon);
210-
icon_name = ""; // icon_name has priority over pixmap
211-
icon_pixmap = custom_pixbuf;
212-
} else { // if file doesn't exist it's most likely an icon_name
209+
Glib::RefPtr<Gdk::Pixbuf> custom_pixbuf = Gdk::Pixbuf::create_from_file(custom_icon);
210+
icon_name = ""; // icon_name has priority over pixmap
211+
icon_pixmap = custom_pixbuf;
212+
} else { // if file doesn't exist it's most likely an icon_name
213213
icon_name = custom_icon;
214214
}
215215
}

src/modules/sni/tray.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "modules/sni/tray.hpp"
2-
#include "modules/sni/icon_manager.hpp"
32

43
#include <spdlog/spdlog.h>
54

5+
#include "modules/sni/icon_manager.hpp"
6+
67
namespace waybar::modules::SNI {
78

89
Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)

src/modules/temperature.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ float waybar::modules::Temperature::getTemperature() {
115115
auto zone = config_["thermal-zone"].isInt() ? config_["thermal-zone"].asInt() : 0;
116116

117117
// First, try with dev.cpu
118-
if ( (sysctlbyname(fmt::format("dev.cpu.{}.temperature", zone).c_str(), &temp, &size,
119-
NULL, 0) == 0) ||
120-
(sysctlbyname(fmt::format("hw.acpi.thermal.tz{}.temperature", zone).c_str(), &temp, &size,
121-
NULL, 0) == 0) ) {
118+
if ((sysctlbyname(fmt::format("dev.cpu.{}.temperature", zone).c_str(), &temp, &size, NULL, 0) ==
119+
0) ||
120+
(sysctlbyname(fmt::format("hw.acpi.thermal.tz{}.temperature", zone).c_str(), &temp, &size,
121+
NULL, 0) == 0)) {
122122
auto temperature_c = ((float)temp - 2732) / 10;
123123
return temperature_c;
124124
}

0 commit comments

Comments
 (0)