treewide: alejandra -> nixfmt

This commit is contained in:
Mihai Fufezan 2026-03-02 20:56:00 +02:00
parent d98f7ffaf5
commit 52ece2b017
No known key found for this signature in database
8 changed files with 521 additions and 460 deletions

View file

@ -88,23 +88,28 @@
};
};
outputs = inputs @ {
outputs =
inputs@{
self,
nixpkgs,
systems,
...
}: let
}:
let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
pkgsFor = eachSystem (
system:
import nixpkgs {
localSystem = system;
overlays = with self.overlays; [
hyprland-packages
hyprland-extras
];
});
pkgsCrossFor = eachSystem (system: crossSystem:
}
);
pkgsCrossFor = eachSystem (
system: crossSystem:
import nixpkgs {
localSystem = system;
inherit crossSystem;
@ -112,29 +117,36 @@
hyprland-packages
hyprland-extras
];
});
pkgsDebugFor = eachSystem (system:
}
);
pkgsDebugFor = eachSystem (
system:
import nixpkgs {
localSystem = system;
overlays = with self.overlays; [
hyprland-debug
];
});
pkgsDebugCrossFor = eachSystem (system: crossSystem:
}
);
pkgsDebugCrossFor = eachSystem (
system: crossSystem:
import nixpkgs {
localSystem = system;
inherit crossSystem;
overlays = with self.overlays; [
hyprland-debug
];
});
in {
}
);
in
{
overlays = import ./nix/overlays.nix { inherit self lib inputs; };
checks = eachSystem (system:
(lib.filterAttrs
(n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n))
self.packages.${system})
checks = eachSystem (
system:
(lib.filterAttrs (
n: _: (lib.hasPrefix "hyprland" n) && !(lib.hasSuffix "debug" n)
) self.packages.${system})
// {
inherit (self.packages.${system}) xdg-desktop-portal-hyprland;
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
@ -150,12 +162,12 @@
};
};
}
// (import ./nix/tests inputs pkgsFor.${system}));
// (import ./nix/tests inputs pkgsFor.${system})
);
packages = eachSystem (system: {
default = self.packages.${system}.hyprland;
inherit
(pkgsFor.${system})
inherit (pkgsFor.${system})
# hyprland-packages
hyprland
hyprland-unwrapped
@ -170,9 +182,11 @@
devShells = eachSystem (system: {
default =
pkgsFor.${system}.mkShell.override {
pkgsFor.${system}.mkShell.override
{
inherit (self.packages.${system}.default) stdenv;
} {
}
{
name = "hyprland-shell";
hardeningDisable = [ "fortify" ];
inputsFrom = [ pkgsFor.${system}.hyprland ];

View file

@ -60,12 +60,23 @@
hidpiXWayland ? false,
legacyRenderer ? false,
withHyprtester ? false,
}: let
}:
let
inherit (builtins) foldl' readFile;
inherit (lib.asserts) assertMsg;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten concatLists optional optionals;
inherit (lib.strings) makeBinPath optionalString cmakeBool trim;
inherit (lib.lists)
flatten
concatLists
optional
optionals
;
inherit (lib.strings)
makeBinPath
optionalString
cmakeBool
trim
;
fs = lib.fileset;
adapters = flatten [
@ -77,9 +88,14 @@
in
assert assertMsg (!nvidiaPatches) "The option `nvidiaPatches` has been removed.";
assert assertMsg (!enableNvidiaPatches) "The option `enableNvidiaPatches` has been removed.";
assert assertMsg (!hidpiXWayland) "The option `hidpiXWayland` has been removed. Please refer https://wiki.hypr.land/Configuring/XWayland";
assert assertMsg (!legacyRenderer) "The option `legacyRenderer` has been removed. Legacy renderer is no longer supported.";
assert assertMsg (!withHyprtester) "The option `withHyprtester` has been removed. Hyprtester is always built now.";
assert assertMsg (!hidpiXWayland)
"The option `hidpiXWayland` has been removed. Please refer https://wiki.hypr.land/Configuring/XWayland";
assert assertMsg (
!legacyRenderer
) "The option `legacyRenderer` has been removed. Legacy renderer is no longer supported.";
assert assertMsg (
!withHyprtester
) "The option `withHyprtester` has been removed. Hyprtester is always built now.";
customStdenv.mkDerivation (finalAttrs: {
pname = "hyprland${optionalString debug "-debug"}";
inherit version withTests;
@ -90,7 +106,8 @@ in
fs.intersection
# allows non-flake builds to only include files tracked by git
(fs.gitTracked ../.)
(fs.unions (flatten [
(
fs.unions (flatten [
../assets/hyprland-portals.conf
../assets/install
../hyprctl
@ -106,8 +123,12 @@ in
(fs.fileFilter (file: file.hasExt "conf" || file.hasExt "in") ../example)
(fs.fileFilter (file: file.hasExt "sh") ../scripts)
(fs.fileFilter (file: file.name == "CMakeLists.txt") ../.)
(optional withTests [../tests ../hyprtester])
]));
(optional withTests [
../tests
../hyprtester
])
])
);
};
postPatch = ''
@ -190,10 +211,7 @@ in
strictDeps = true;
cmakeBuildType =
if debug
then "Debug"
else "RelWithDebInfo";
cmakeBuildType = if debug then "Debug" else "RelWithDebInfo";
# we want as much debug info as possible
dontStrip = debug;
@ -218,12 +236,14 @@ in
postInstall = ''
${optionalString wrapRuntimeDeps ''
wrapProgram $out/bin/Hyprland \
--suffix PATH : ${makeBinPath [
--suffix PATH : ${
makeBinPath [
binutils
hyprland-guiutils
pciutils
pkgconf
]}
]
}
''}
${optionalString withTests ''

View file

@ -2,7 +2,7 @@
writeShellApplication,
deadnix,
statix,
alejandra,
nixfmt,
llvmPackages_19,
fd,
}:
@ -11,7 +11,7 @@ writeShellApplication {
runtimeInputs = [
deadnix
statix
alejandra
nixfmt
llvmPackages_19.clang-tools
fd
];
@ -24,14 +24,14 @@ writeShellApplication {
nix_format() {
if [ "$*" = 0 ]; then
fd '.*\.nix' . -E "$excludes" -x statix fix -- {} \;
fd '.*\.nix' . -E "$excludes" -X deadnix -e -- {} \; -X alejandra {} \;
fd '.*\.nix' . -E "$excludes" -X deadnix -e -- {} \; -X nixfmt {} \;
elif [ -d "$1" ]; then
fd '.*\.nix' "$1" -E "$excludes" -i -x statix fix -- {} \;
fd '.*\.nix' "$1" -E "$excludes" -i -X deadnix -e -- {} \; -X alejandra {} \;
fd '.*\.nix' "$1" -E "$excludes" -i -X deadnix -e -- {} \; -X nixfmt {} \;
else
statix fix -- "$1"
deadnix -e "$1"
alejandra "$1"
nixfmt "$1"
fi
}

View file

@ -1,13 +1,15 @@
self: {
config,
self:
{
lib,
pkgs,
...
}: let
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
package = self.packages.${system}.default;
in {
in
{
config = {
wayland.windowManager.hyprland.package = lib.mkDefault package;
};

View file

@ -1,4 +1,5 @@
lib: let
lib:
let
inherit (lib)
attrNames
filterAttrs
@ -81,11 +82,19 @@ lib: let
:::
*/
toHyprlang = {
topCommandsPrefixes ? ["$" "bezier"],
toHyprlang =
{
topCommandsPrefixes ? [
"$"
"bezier"
],
bottomCommandsPrefixes ? [ ],
}: attrs: let
toHyprlang' = attrs: let
}:
attrs:
let
toHyprlang' =
attrs:
let
# Specially configured `toKeyValue` generator with support for duplicate keys
# and a legible key-value separator.
mkCommands = generators.toKeyValue {
@ -99,8 +108,7 @@ lib: let
commands = flattenAttrs (p: k: "${p}:${k}") attrs;
# General filtering function to check if a key starts with any prefix in a given list.
filterCommands = list: n:
foldl (acc: prefix: acc || hasPrefix prefix n) false list;
filterCommands = list: n: foldl (acc: prefix: acc || hasPrefix prefix n) false list;
# Partition keys into top commands and the rest
result = partition (filterCommands topCommandsPrefixes) (attrNames commands);
@ -174,24 +182,19 @@ lib: let
```
:::
*/
flattenAttrs = pred: attrs: let
flattenAttrs' = prefix: attrs:
flattenAttrs =
pred: attrs:
let
flattenAttrs' =
prefix: attrs:
builtins.foldl' (
acc: key: let
acc: key:
let
value = attrs.${key};
newKey =
if prefix == ""
then key
else pred prefix key;
newKey = if prefix == "" then key else pred prefix key;
in
acc
// (
if builtins.isAttrs value
then flattenAttrs' newKey value
else {"${newKey}" = value;}
)
acc // (if builtins.isAttrs value then flattenAttrs' newKey value else { "${newKey}" = value; })
) { } (builtins.attrNames attrs);
in
flattenAttrs' "" attrs;

View file

@ -1,13 +1,16 @@
inputs: {
inputs:
{
config,
lib,
pkgs,
...
}: let
}:
let
inherit (pkgs.stdenv.hostPlatform) system;
selflib = import ./lib.nix lib;
cfg = config.programs.hyprland;
in {
in
{
options = {
programs.hyprland = {
plugins = lib.mkOption {
@ -20,7 +23,9 @@ in {
};
settings = lib.mkOption {
type = with lib.types; let
type =
with lib.types;
let
valueType =
nullOr (oneOf [
bool
@ -92,8 +97,15 @@ in {
topPrefixes = lib.mkOption {
type = with lib.types; listOf str;
default = ["$" "bezier"];
example = ["$" "bezier" "source"];
default = [
"$"
"bezier"
];
example = [
"$"
"bezier"
"source"
];
description = ''
List of prefix of attributes to put at the top of the config.
'';
@ -117,20 +129,22 @@ in {
};
}
(lib.mkIf cfg.enable {
environment.etc."xdg/hypr/hyprland.conf" = let
environment.etc."xdg/hypr/hyprland.conf" =
let
shouldGenerate = cfg.extraConfig != "" || cfg.settings != { } || cfg.plugins != [ ];
pluginsToHyprlang = plugins:
selflib.toHyprlang {
pluginsToHyprlang =
_plugins:
selflib.toHyprlang
{
topCommandsPrefixes = cfg.topPrefixes;
bottomCommandsPrefixes = cfg.bottomPrefixes;
}
{
"exec-once" = let
mkEntry = entry:
if lib.types.package.check entry
then "${entry}/lib/lib${entry.pname}.so"
else entry;
"exec-once" =
let
mkEntry =
entry: if lib.types.package.check entry then "${entry}/lib/lib${entry.pname}.so" else entry;
hyprctl = lib.getExe' config.programs.hyprland.package "hyprctl";
in
map (p: "${hyprctl} plugin load ${mkEntry p}") cfg.plugins;
@ -138,14 +152,13 @@ in {
in
lib.mkIf shouldGenerate {
text =
lib.optionalString (cfg.plugins != [])
(pluginsToHyprlang cfg.plugins)
+ lib.optionalString (cfg.settings != {})
(selflib.toHyprlang {
lib.optionalString (cfg.plugins != [ ]) (pluginsToHyprlang cfg.plugins)
+ lib.optionalString (cfg.settings != { }) (
selflib.toHyprlang {
topCommandsPrefixes = cfg.topPrefixes;
bottomCommandsPrefixes = cfg.bottomPrefixes;
}
cfg.settings)
} cfg.settings
)
+ lib.optionalString (cfg.extraConfig != "") cfg.extraConfig;
};
})

View file

@ -2,20 +2,27 @@
self,
lib,
inputs,
}: let
mkDate = longDate: (lib.concatStringsSep "-" [
}:
let
mkDate =
longDate:
(lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
ver = lib.removeSuffix "\n" (builtins.readFile ../VERSION);
in {
in
{
# Contains what a user is most likely to care about:
# Hyprland itself, XDPH and the Share Picker.
default = lib.composeManyExtensions (with self.overlays; [
default = lib.composeManyExtensions (
with self.overlays;
[
hyprland-packages
hyprland-extras
]);
]
);
# Packages for variations of Hyprland, dependencies included.
hyprland-packages = lib.composeManyExtensions [
@ -33,10 +40,13 @@ in {
self.overlays.glaze
# Hyprland packages themselves
(final: _prev: let
(
final: _prev:
let
date = mkDate (self.lastModifiedDate or "19700101");
version = "${ver}+date=${date}_${self.shortRev or "dirty"}";
in {
in
{
hyprland = final.callPackage ./default.nix {
stdenv = final.gcc15Stdenv;
commit = self.rev or "";
@ -47,35 +57,28 @@ in {
hyprland-with-tests = final.hyprland.override { withTests = true; };
hyprland-with-hyprtester =
builtins.trace ''
hyprland-with-hyprtester = builtins.trace ''
hyprland-with-hyprtester was removed. Please use the hyprland package.
Hyprtester is always built now.
''
final.hyprland;
'' final.hyprland;
# deprecated packages
hyprland-legacy-renderer =
builtins.trace ''
hyprland-legacy-renderer = builtins.trace ''
hyprland-legacy-renderer was removed. Please use the hyprland package.
Legacy renderer is no longer supported.
''
final.hyprland;
'' final.hyprland;
hyprland-nvidia =
builtins.trace ''
hyprland-nvidia = builtins.trace ''
hyprland-nvidia was removed. Please use the hyprland package.
Nvidia patches are no longer needed.
''
final.hyprland;
'' final.hyprland;
hyprland-hidpi =
builtins.trace ''
hyprland-hidpi = builtins.trace ''
hyprland-hidpi was removed. Please use the hyprland package.
For more information, refer to https://wiki.hypr.land/Configuring/XWayland.
''
final.hyprland;
})
'' final.hyprland;
}
)
];
# Debug
@ -83,7 +86,7 @@ in {
# Dependencies
self.overlays.hyprland-packages
(final: prev: {
(_final: prev: {
aquamarine = prev.aquamarine.override { debug = true; };
hyprutils = prev.hyprutils.override { debug = true; };
hyprland-debug = prev.hyprland.override { debug = true; };
@ -100,7 +103,8 @@ in {
# this version is the one used in the git submodule, and allows us to
# fetch the source without '?submodules=1'
udis86 = final: prev: {
udis86-hyprland = prev.udis86.overrideAttrs (_self: _super: {
udis86-hyprland = prev.udis86.overrideAttrs (
_self: _super: {
src = final.fetchFromGitHub {
owner = "canihavesomecoffee";
repo = "udis86";
@ -109,12 +113,13 @@ in {
};
patches = [ ];
});
}
);
};
# Even though glaze itself disables it by default, nixpkgs sets ENABLE_SSL set to true.
# Since we don't include openssl, the build failes without the `enableSSL = false;` override
glaze = final: prev: {
glaze = _final: prev: {
glaze-hyprland = prev.glaze.override {
enableSSL = false;
enableInterop = false;

View file

@ -1,11 +1,15 @@
inputs: pkgs: let
inputs: pkgs:
let
flake = inputs.self.packages.${pkgs.stdenv.hostPlatform.system};
hyprland = flake.hyprland-with-tests;
in {
in
{
tests = pkgs.testers.runNixOSTest {
name = "hyprland-tests";
nodes.machine = {pkgs, ...}: {
nodes.machine =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
# Programs needed for tests
jq