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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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