style: format code

This commit is contained in:
tux
2026-09-11 02:10:39 +05:30
parent f2268f65e7
commit 352eb99568
2 changed files with 102 additions and 107 deletions

111
flake.nix
View File

@@ -15,66 +15,63 @@
}; };
}; };
outputs = outputs = {
{ self,
self, nixpkgs,
nixpkgs, quickshell,
quickshell, treefmt-nix,
treefmt-nix, }: let
}: system = "x86_64-linux";
let pkgs = nixpkgs.legacyPackages.${system};
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
quickshellWithModules = quickshell.packages.${system}.default.withModules [ quickshellWithModules = quickshell.packages.${system}.default.withModules [
pkgs.qt6.qtbase pkgs.qt6.qtbase
pkgs.qt6.qtdeclarative pkgs.qt6.qtdeclarative
pkgs.qt6.qtmultimedia pkgs.qt6.qtmultimedia
pkgs.qt6.qttranslations pkgs.qt6.qttranslations
]; ];
treefmtEval = treefmt-nix.lib.evalModule pkgs { treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix"; projectRootFile = "flake.nix";
programs = { programs = {
nixfmt.enable = true; alejandra.enable = true;
qmlformat.enable = true; qmlformat.enable = true;
clang-format.enable = true; clang-format.enable = true;
};
};
in
rec {
formatter.${system} = treefmtEval.config.build.wrapper;
packages.${system} = {
tshell = pkgs.callPackage ./package.nix {
inherit quickshellWithModules;
};
default = packages.${system}.tshell;
};
devShells.${system}.default = pkgs.mkShell {
packages = [
quickshellWithModules
pkgs.cava
pkgs.wallust
pkgs.dbus
pkgs.cmake
pkgs.ninja
pkgs.qt6.qtbase
pkgs.qt6.qtdeclarative
];
shellHook = ''
if [ -d "$PWD/plugin/dist/lib/qt-6/qml" ]; then
export NIXPKGS_QT6_QML_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}"
export QML2_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${QML2_IMPORT_PATH:+:$QML2_IMPORT_PATH}"
else
echo "gpu plugin is not built; run from the repo root to enable 'import Tshell.Cardwire':"
echo " cmake -S plugin -B plugin/dist -DCMAKE_INSTALL_PREFIX=\$PWD/plugin/dist"
echo " cmake --build plugin/dist --target install"
fi
'';
}; };
}; };
in rec {
formatter.${system} = treefmtEval.config.build.wrapper;
packages.${system} = {
tshell = pkgs.callPackage ./package.nix {
inherit quickshellWithModules;
};
default = packages.${system}.tshell;
};
devShells.${system}.default = pkgs.mkShell {
packages = [
quickshellWithModules
pkgs.cava
pkgs.wallust
pkgs.dbus
pkgs.cmake
pkgs.ninja
pkgs.qt6.qtbase
pkgs.qt6.qtdeclarative
];
shellHook = ''
if [ -d "$PWD/plugin/dist/lib/qt-6/qml" ]; then
export NIXPKGS_QT6_QML_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${NIXPKGS_QT6_QML_IMPORT_PATH:+:$NIXPKGS_QT6_QML_IMPORT_PATH}"
export QML2_IMPORT_PATH="$PWD/plugin/dist/lib/qt-6/qml''${QML2_IMPORT_PATH:+:$QML2_IMPORT_PATH}"
else
echo "gpu plugin is not built; run from the repo root to enable 'import Tshell.Cardwire':"
echo " cmake -S plugin -B plugin/dist -DCMAKE_INSTALL_PREFIX=\$PWD/plugin/dist"
echo " cmake --build plugin/dist --target install"
fi
'';
};
};
} }

View File

@@ -10,73 +10,71 @@
cava, cava,
wallust, wallust,
nerd-fonts, nerd-fonts,
extraRuntimeDeps ? [ ], extraRuntimeDeps ? [],
}: }: let
let
version = "0.1.0"; version = "0.1.0";
runtimeDeps = [ runtimeDeps =
cava [
wallust cava
] wallust
++ extraRuntimeDeps; ]
++ extraRuntimeDeps;
fontconfig = makeFontsConf { fontconfig = makeFontsConf {
fontDirectories = [ nerd-fonts.fira-code ]; fontDirectories = [nerd-fonts.fira-code];
}; };
# Unlike lib.fileset, this keeps untracked files (the flake only sees # Unlike lib.fileset, this keeps untracked files (the flake only sees
# git-tracked paths) while dropping build artifacts. # git-tracked paths) while dropping build artifacts.
src = lib.cleanSourceWith { src = lib.cleanSourceWith {
src = lib.cleanSource ./.; src = lib.cleanSource ./.;
filter = filter = path: _: let
path: _: name = baseNameOf path;
let in
name = baseNameOf path;
in
!(name == "dist" || name == "result" || name == "result-bin" || lib.hasPrefix "build" name); !(name == "dist" || name == "result" || name == "result-bin" || lib.hasPrefix "build" name);
}; };
in in
stdenv.mkDerivation { stdenv.mkDerivation {
inherit version src; inherit version src;
pname = "tshell"; pname = "tshell";
dontWrapQtApps = true; dontWrapQtApps = true;
preConfigure = '' preConfigure = ''
cd plugin cd plugin
''; '';
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
ninja ninja
makeWrapper makeWrapper
]; ];
buildInputs = [ buildInputs = [
qt6.qtbase qt6.qtbase
qt6.qtdeclarative qt6.qtdeclarative
]; ];
propagatedBuildInputs = runtimeDeps; propagatedBuildInputs = runtimeDeps;
postInstall = '' postInstall = ''
mkdir -p $out/bin $out/share/tshell mkdir -p $out/bin $out/share/tshell
for entry in shell.qml assets config modules services ui windows; do for entry in shell.qml assets config modules services ui windows; do
cp -r "$src/$entry" $out/share/tshell/ cp -r "$src/$entry" $out/share/tshell/
done done
makeWrapper ${quickshellWithModules}/bin/qs $out/bin/tshell \ makeWrapper ${quickshellWithModules}/bin/qs $out/bin/tshell \
--prefix PATH : "${lib.makeBinPath runtimeDeps}" \ --prefix PATH : "${lib.makeBinPath runtimeDeps}" \
--set FONTCONFIG_FILE "${fontconfig}" \ --set FONTCONFIG_FILE "${fontconfig}" \
--suffix NIXPKGS_QT6_QML_IMPORT_PATH : "$out/lib/qt-6/qml" \ --suffix NIXPKGS_QT6_QML_IMPORT_PATH : "$out/lib/qt-6/qml" \
--add-flags "-p $out/share/tshell" --add-flags "-p $out/share/tshell"
''; '';
meta = { meta = {
description = "tux's widgets for wayland"; description = "tux's widgets for wayland";
homepage = "https://github.com/tuxdotrs/tshell"; homepage = "https://github.com/tuxdotrs/tshell";
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
mainProgram = "tshell"; mainProgram = "tshell";
platforms = lib.platforms.linux; platforms = lib.platforms.linux;
}; };
} }