diff --git a/flake.nix b/flake.nix index 9bcf3de6..764aed43 100644 --- a/flake.nix +++ b/flake.nix @@ -153,8 +153,6 @@ src = ./.; }; - - maintainers-sorted = pkgs.callPackage ./stylix/check-maintainers-sorted.nix { }; } self.packages.${system}; devShells = { @@ -200,6 +198,7 @@ runtimeInputs = with pkgs; [ nixfmt-rfc-style stylish-haskell + keep-sorted ]; settings = { @@ -216,6 +215,10 @@ options = [ "--width=80" ]; includes = [ "*.nix" ]; }; + keep-sorted = { + command = "keep-sorted"; + includes = [ "*" ]; + }; }; }; }; diff --git a/stylix/check-maintainers-sorted.nix b/stylix/check-maintainers-sorted.nix deleted file mode 100644 index 55b8bc12..00000000 --- a/stylix/check-maintainers-sorted.nix +++ /dev/null @@ -1,89 +0,0 @@ -# Slight modification from nixpkgs's script: https://github.com/NixOS/nixpkgs/commit/4a694fc50007076566a204d6ea623fd5fc7ddbfa -# Copyright (c) 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors - -{ lib, runCommandLocal }: -let - inherit (lib) - add - attrNames - attrValues - elemAt - foldl' - genList - length - replaceStrings - sort - toLower - trace - ; - - maintainers = import ./maintainers.nix; - simplify = replaceStrings [ "-" "_" ] [ "" "" ]; - namesSorted = sort (a: b: a.key < b.key) ( - map ( - n: - let - pos = builtins.unsafeGetAttrPos n maintainers; - in - assert pos == null -> throw "maintainers entry ${n} is malformed"; - { - name = n; - inherit (pos) line; - key = toLower (simplify n); - } - ) (attrNames maintainers) - ); - before = - { - key, - ... - }: - foldl' ( - acc: n: if n.key < key && (acc == null || n.key > acc.key) then n else acc - ) null namesSorted; - errors = foldl' add 0 ( - map ( - i: - let - a = elemAt namesSorted i; - b = elemAt namesSorted (i + 1); - lim = - let - t = before a; - in - if t == null then "the initial {" else t.name; - in - if a.line >= b.line then - trace ( - "maintainer ${a.name} (line ${toString a.line}) should be listed " - + "after ${lim}, not after ${b.name} (line ${toString b.line})" - ) 1 - else - 0 - ) (genList (i: i) (length namesSorted - 1)) - ); -in -assert length (attrValues maintainers) < 1 || errors == 0; -runCommandLocal "maintainers-sorted" { } "mkdir $out" - -# generate edit commands to sort the list. -# may everything following the last current entry (closing } ff) in the wrong place -# with lib; -# concatStringsSep -# "\n" -# (let first = foldl' (acc: n: if n.line < acc then n.line else acc) 999999999 namesSorted; -# commands = map -# (i: let e = elemAt namesSorted i; -# begin = foldl' -# (acc: n: if n.line < e.line && n.line > acc then n.line else acc) -# 1 -# namesSorted; -# end = -# foldl' (acc: n: if n.line > e.line && n.line < acc then n.line else acc) -# 999999999 -# namesSorted; -# in "${toString e.line},${toString (end - 1)} p") -# (genList (i: i) (length namesSorted)); -# in map -# (c: "sed -ne '${c}' maintainers/maintainer-list.nix") -# ([ "1,${toString (first - 1)} p" ] ++ commands)) diff --git a/stylix/home-manager-integration.nix b/stylix/home-manager-integration.nix index 2ab4d69a..a8af8e3a 100644 --- a/stylix/home-manager-integration.nix +++ b/stylix/home-manager-integration.nix @@ -20,6 +20,7 @@ let ) ) [ + # keep-sorted start block=yes { path = [ "stylix" @@ -50,14 +51,7 @@ let path = [ "stylix" "fonts" - "serif" - ]; - } - { - path = [ - "stylix" - "fonts" - "sansSerif" + "emoji" ]; } { @@ -71,15 +65,14 @@ let path = [ "stylix" "fonts" - "emoji" + "sansSerif" ]; } { path = [ "stylix" "fonts" - "sizes" - "desktop" + "serif" ]; } { @@ -95,7 +88,7 @@ let "stylix" "fonts" "sizes" - "terminal" + "desktop" ]; } { @@ -106,6 +99,14 @@ let "popups" ]; } + { + path = [ + "stylix" + "fonts" + "sizes" + "terminal" + ]; + } { path = [ "stylix" @@ -118,13 +119,6 @@ let "imageScalingMode" ]; } - { - path = [ - "stylix" - "opacity" - "desktop" - ]; - } { path = [ "stylix" @@ -136,7 +130,7 @@ let path = [ "stylix" "opacity" - "terminal" + "desktop" ]; } { @@ -146,6 +140,13 @@ let "popups" ]; } + { + path = [ + "stylix" + "opacity" + "terminal" + ]; + } { path = [ "stylix" @@ -168,6 +169,7 @@ let "platform" ]; } + # keep-sorted end ]; in diff --git a/stylix/maintainers.nix b/stylix/maintainers.nix index 4d933db5..44cf01a6 100644 --- a/stylix/maintainers.nix +++ b/stylix/maintainers.nix @@ -6,6 +6,7 @@ # # [1]: https://github.com/NixOS/nixpkgs/blob/1da63e6cc622a0cb6fd5b86d49923e4eb1e33b70/maintainers/maintainer-list.nix { + # keep-sorted start case=no numeric=no block=yes butzist = { email = "adam@szalkowski.de"; name = "Adam M. Szalkowski"; @@ -55,4 +56,5 @@ github = "skoove"; githubId = 53106860; }; + # keep-sorted end }