alejandra-custom: rebase patches; re-add spaced-elements patch

This commit is contained in:
raf 2024-07-22 00:59:15 +03:00
parent 0e360fa999
commit b6209c17d5
Signed by: NotAShelf
GPG key ID: AF26552424E53993
3 changed files with 480 additions and 16 deletions

View file

@ -1,14 +1,14 @@
diff --git a/src/alejandra_cli/src/cli.rs b/src/alejandra_cli/src/cli.rs
diff --git i/src/alejandra_cli/src/cli.rs w/src/alejandra_cli/src/cli.rs
index bab102c..b90bf1d 100644
--- a/src/alejandra_cli/src/cli.rs
+++ b/src/alejandra_cli/src/cli.rs
--- i/src/alejandra_cli/src/cli.rs
+++ w/src/alejandra_cli/src/cli.rs
@@ -7,7 +7,6 @@ use futures::future::RemoteHandle;
use futures::stream::FuturesUnordered;
use futures::task::SpawnExt;
-use crate::ads::random_ad;
use crate::verbosity::Verbosity;
/// The Uncompromising Nix Code Formatter.
@@ -203,11 +202,6 @@ pub fn main() -> std::io::Result<()> {
(true, false) => "requires formatting",
@ -20,7 +20,7 @@ index bab102c..b90bf1d 100644
- eprint!("{}", random_ad());
- }
}
std::process::exit(if in_place { 0 } else { 2 });
@@ -218,8 +212,6 @@ pub fn main() -> std::io::Result<()> {
eprintln!(
@ -29,16 +29,14 @@ index bab102c..b90bf1d 100644
- eprintln!();
- eprint!("{}", random_ad());
}
std::process::exit(0);
diff --git a/src/alejandra_cli/src/lib.rs b/src/alejandra_cli/src/lib.rs
diff --git i/src/alejandra_cli/src/lib.rs w/src/alejandra_cli/src/lib.rs
index fd49ce8..258f656 100644
--- a/src/alejandra_cli/src/lib.rs
+++ b/src/alejandra_cli/src/lib.rs
--- i/src/alejandra_cli/src/lib.rs
+++ w/src/alejandra_cli/src/lib.rs
@@ -1,4 +1,3 @@
-mod ads;
pub mod cli;
mod find;
mod verbosity;

View file

@ -0,0 +1,460 @@
diff --git i/src/alejandra/src/rules/attr_set.rs w/src/alejandra/src/rules/attr_set.rs
index 9459977..8b637a1 100644
--- i/src/alejandra/src/rules/attr_set.rs
+++ w/src/alejandra/src/rules/attr_set.rs
@@ -62,6 +62,8 @@ pub(crate) fn rule(
steps.push_back(crate::builder::Step::Format(child));
if vertical {
steps.push_back(crate::builder::Step::Indent);
+ } else if items_count >= 1 {
+ steps.push_back(crate::builder::Step::Whitespace);
}
let mut item_index: usize = 0;
@@ -120,6 +122,8 @@ pub(crate) fn rule(
steps.push_back(crate::builder::Step::Dedent);
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
+ } else if items_count >= 1 {
+ steps.push_back(crate::builder::Step::Whitespace);
}
steps.push_back(crate::builder::Step::Format(child));
diff --git i/src/alejandra/src/rules/list.rs w/src/alejandra/src/rules/list.rs
index 3e33e14..df9b9e6 100644
--- i/src/alejandra/src/rules/list.rs
+++ w/src/alejandra/src/rules/list.rs
@@ -23,7 +23,9 @@ pub(crate) fn rule(
steps.push_back(crate::builder::Step::Format(child));
if vertical {
steps.push_back(crate::builder::Step::Indent);
- }
+ } else if items_count >= 1 {
+ steps.push_back(crate::builder::Step::Whitespace);
+ }
let mut item_index: usize = 0;
let mut inline_next_comment = false;
@@ -90,6 +92,8 @@ pub(crate) fn rule(
steps.push_back(crate::builder::Step::Dedent);
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
+ } else if items_count >= 1 {
+ steps.push_back(crate::builder::Step::Whitespace);
}
steps.push_back(crate::builder::Step::Format(child));
diff --git i/src/alejandra/tests/cases/apply/out.nix w/src/alejandra/tests/cases/apply/out.nix
index 77a7d97..7a0bd11 100644
--- i/src/alejandra/tests/cases/apply/out.nix
+++ w/src/alejandra/tests/cases/apply/out.nix
@@ -41,19 +41,19 @@
name1 =
function
arg
- {asdf = 1;};
+ { asdf = 1; };
name2 =
function
arg
- {asdf = 1;}
+ { asdf = 1; }
argument;
name3 =
function
arg
- {asdf = 1;}
- {qwer = 12345;}
+ { asdf = 1; }
+ { qwer = 12345; }
argument;
}
{
@@ -79,7 +79,7 @@
name4 =
function
arg
- {asdf = 1;}
+ { asdf = 1; }
{
qwer = 12345;
qwer2 = 54321;
@@ -88,21 +88,21 @@
}
{
option1 =
- function arg {asdf = 1;} {
+ function arg { asdf = 1; } {
qwer = 12345;
qwer2 = 54321;
}
lastArg;
option2 =
- function arg {asdf = 1;} {
+ function arg { asdf = 1; } {
qwer = 12345;
qwer2 = 54321;
}
lastArg;
option3 =
- function arg {asdf = 1;}
+ function arg { asdf = 1; }
{
qwer = 12345;
qwer2 = 54321;
diff --git i/src/alejandra/tests/cases/attr_set/out.nix w/src/alejandra/tests/cases/attr_set/out.nix
index 18e6026..e5ac999 100644
--- i/src/alejandra/tests/cases/attr_set/out.nix
+++ w/src/alejandra/tests/cases/attr_set/out.nix
@@ -5,12 +5,12 @@
a
*/
}
- {a = 1;}
+ { a = 1; }
{
a = 1;
}
- {b = 1;}
+ { b = 1; }
{
b = 1;
/*
@@ -33,7 +33,7 @@
*/
}
- rec {c = 1;}
+ rec { c = 1; }
rec {
c = 1;
/*
@@ -101,7 +101,7 @@
a = {
a = rec {
a = {
- a = rec {a = {a = rec {a = {a = rec {a = {};};};};};};
+ a = rec { a = { a = rec { a = { a = rec { a = {}; }; }; }; }; };
};
};
};
diff --git i/src/alejandra/tests/cases/idioms_lib_2/out.nix w/src/alejandra/tests/cases/idioms_lib_2/out.nix
index 9911edf..2a3b2d8 100644
--- i/src/alejandra/tests/cases/idioms_lib_2/out.nix
+++ w/src/alejandra/tests/cases/idioms_lib_2/out.nix
@@ -387,7 +387,7 @@
Type: string -> a -> a
*/
warn =
- if lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") ["1" "true" "yes"]
+ if lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") [ "1" "true" "yes" ]
then msg: builtins.trace "warning: ${msg}" (abort "NIX_ABORT_ON_WARN=true; warnings are treated as unrecoverable errors.")
else msg: builtins.trace "warning: ${msg}";
@@ -526,12 +526,12 @@
toBaseDigits = base: i: let
go = i:
if i < base
- then [i]
+ then [ i ]
else let
r = i - ((i / base) * base);
q = (i - r) / base;
in
- [r] ++ go q;
+ [ r ] ++ go q;
in
assert (base >= 2);
assert (i >= 0);
diff --git i/src/alejandra/tests/cases/idioms_nixos_1/out.nix w/src/alejandra/tests/cases/idioms_nixos_1/out.nix
index ae087c2..27f0329 100644
--- i/src/alejandra/tests/cases/idioms_nixos_1/out.nix
+++ w/src/alejandra/tests/cases/idioms_nixos_1/out.nix
@@ -33,7 +33,7 @@ in {
boot.kernelPackages = mkOption {
default = pkgs.linuxPackages;
- type = types.unspecified // {merge = mergeEqualOption;};
+ type = types.unspecified // { merge = mergeEqualOption; };
apply = kernelPackages:
kernelPackages.extend (self: super: {
kernel = super.kernel.override (originalArgs: {
@@ -134,7 +134,7 @@ in {
boot.initrd.availableKernelModules = mkOption {
type = types.listOf types.str;
default = [];
- example = ["sata_nv" "ext3"];
+ example = [ "sata_nv" "ext3" ];
description = ''
The set of kernel modules in the initial ramdisk used during the
boot process. This set must include all modules necessary for
@@ -263,22 +263,22 @@ in {
})
(mkIf (!config.boot.isContainer) {
- system.build = {inherit kernel;};
+ system.build = { inherit kernel; };
- system.modulesTree = [kernel] ++ config.boot.extraModulePackages;
+ system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
# Implement consoleLogLevel both in early boot and using sysctl
# (so you don't need to reboot to have changes take effect).
boot.kernelParams =
- ["loglevel=${toString config.boot.consoleLogLevel}"]
- ++ optionals config.boot.vesa ["vga=0x317" "nomodeset"];
+ [ "loglevel=${toString config.boot.consoleLogLevel}" ]
+ ++ optionals config.boot.vesa [ "vga=0x317" "nomodeset" ];
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
- boot.kernelModules = ["loop" "atkbd"];
+ boot.kernelModules = [ "loop" "atkbd" ];
# The Linux kernel >= 2.6.27 provides firmware.
- hardware.firmware = [kernel];
+ hardware.firmware = [ kernel ];
# Create /etc/modules-load.d/nixos.conf, which is read by
# systemd-modules-load.service to load required kernel modules.
@@ -287,8 +287,8 @@ in {
};
systemd.services.systemd-modules-load = {
- wantedBy = ["multi-user.target"];
- restartTriggers = [kernelModulesConf];
+ wantedBy = [ "multi-user.target" ];
+ restartTriggers = [ kernelModulesConf ];
serviceConfig = {
# Ignore failed module loads. Typically some of the
# modules in boot.kernelModules are "nice to have but
diff --git i/src/alejandra/tests/cases/idioms_pkgs_1/out.nix w/src/alejandra/tests/cases/idioms_pkgs_1/out.nix
index dbee48d..129d59d 100644
--- i/src/alejandra/tests/cases/idioms_pkgs_1/out.nix
+++ w/src/alejandra/tests/cases/idioms_pkgs_1/out.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
url = "example/${version}";
};
meta = with lib; {
- maintainers = with maintainers; [someone];
+ maintainers = with maintainers; [ someone ];
description = "something";
};
}
diff --git i/src/alejandra/tests/cases/idioms_pkgs_2/out.nix w/src/alejandra/tests/cases/idioms_pkgs_2/out.nix
index dd0a2b5..2448b6e 100644
--- i/src/alejandra/tests/cases/idioms_pkgs_2/out.nix
+++ w/src/alejandra/tests/cases/idioms_pkgs_2/out.nix
@@ -19,13 +19,13 @@ stdenv.mkDerivation rec {
doCheck = true;
passthru.tests = {
- version = testVersion {package = hello;};
+ version = testVersion { package = hello; };
invariant-under-noXlibs =
testEqualDerivation
"hello must not be rebuilt when environment.noXlibs is set."
hello
- (nixos {environment.noXlibs = true;}).pkgs.hello;
+ (nixos { environment.noXlibs = true; }).pkgs.hello;
};
meta = with lib; {
@@ -37,7 +37,7 @@ stdenv.mkDerivation rec {
homepage = "https://www.gnu.org/software/hello/manual/";
changelog = "https://git.savannah.gnu.org/cgit/hello.git/plain/NEWS?h=v${version}";
license = licenses.gpl3Plus;
- maintainers = [maintainers.eelco];
+ maintainers = [ maintainers.eelco ];
platforms = platforms.all;
};
}
diff --git i/src/alejandra/tests/cases/idioms_pkgs_3/out.nix w/src/alejandra/tests/cases/idioms_pkgs_3/out.nix
index ae087c2..27f0329 100644
--- i/src/alejandra/tests/cases/idioms_pkgs_3/out.nix
+++ w/src/alejandra/tests/cases/idioms_pkgs_3/out.nix
@@ -33,7 +33,7 @@ in {
boot.kernelPackages = mkOption {
default = pkgs.linuxPackages;
- type = types.unspecified // {merge = mergeEqualOption;};
+ type = types.unspecified // { merge = mergeEqualOption; };
apply = kernelPackages:
kernelPackages.extend (self: super: {
kernel = super.kernel.override (originalArgs: {
@@ -134,7 +134,7 @@ in {
boot.initrd.availableKernelModules = mkOption {
type = types.listOf types.str;
default = [];
- example = ["sata_nv" "ext3"];
+ example = [ "sata_nv" "ext3" ];
description = ''
The set of kernel modules in the initial ramdisk used during the
boot process. This set must include all modules necessary for
@@ -263,22 +263,22 @@ in {
})
(mkIf (!config.boot.isContainer) {
- system.build = {inherit kernel;};
+ system.build = { inherit kernel; };
- system.modulesTree = [kernel] ++ config.boot.extraModulePackages;
+ system.modulesTree = [ kernel ] ++ config.boot.extraModulePackages;
# Implement consoleLogLevel both in early boot and using sysctl
# (so you don't need to reboot to have changes take effect).
boot.kernelParams =
- ["loglevel=${toString config.boot.consoleLogLevel}"]
- ++ optionals config.boot.vesa ["vga=0x317" "nomodeset"];
+ [ "loglevel=${toString config.boot.consoleLogLevel}" ]
+ ++ optionals config.boot.vesa [ "vga=0x317" "nomodeset" ];
boot.kernel.sysctl."kernel.printk" = mkDefault config.boot.consoleLogLevel;
- boot.kernelModules = ["loop" "atkbd"];
+ boot.kernelModules = [ "loop" "atkbd" ];
# The Linux kernel >= 2.6.27 provides firmware.
- hardware.firmware = [kernel];
+ hardware.firmware = [ kernel ];
# Create /etc/modules-load.d/nixos.conf, which is read by
# systemd-modules-load.service to load required kernel modules.
@@ -287,8 +287,8 @@ in {
};
systemd.services.systemd-modules-load = {
- wantedBy = ["multi-user.target"];
- restartTriggers = [kernelModulesConf];
+ wantedBy = [ "multi-user.target" ];
+ restartTriggers = [ kernelModulesConf ];
serviceConfig = {
# Ignore failed module loads. Typically some of the
# modules in boot.kernelModules are "nice to have but
diff --git i/src/alejandra/tests/cases/inherit/out.nix w/src/alejandra/tests/cases/inherit/out.nix
index c3b983d..65da28b 100644
--- i/src/alejandra/tests/cases/inherit/out.nix
+++ w/src/alejandra/tests/cases/inherit/out.nix
@@ -7,7 +7,7 @@
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
;
}
- {inherit b d;}
+ { inherit b d; }
{
inherit
b
diff --git i/src/alejandra/tests/cases/inherit_from/out.nix w/src/alejandra/tests/cases/inherit_from/out.nix
index 0155df5..7252bc4 100644
--- i/src/alejandra/tests/cases/inherit_from/out.nix
+++ w/src/alejandra/tests/cases/inherit_from/out.nix
@@ -1,5 +1,5 @@
[
- {inherit (c) f h;}
+ { inherit (c) f h; }
{
inherit
(c)
diff --git i/src/alejandra/tests/cases/key_value/out.nix w/src/alejandra/tests/cases/key_value/out.nix
index af2f520..f817892 100644
--- i/src/alejandra/tests/cases/key_value/out.nix
+++ w/src/alejandra/tests/cases/key_value/out.nix
@@ -4,7 +4,7 @@ rec
a = 4;
a = a: b;
- a = {a = 1;};
+ a = { a = 1; };
b = {
a =
@@ -79,7 +79,7 @@ rec
*/
;
};
- j = a: {b = 1;};
+ j = a: { b = 1; };
k = a: {
b = 1;
c = 2;
@@ -88,7 +88,7 @@ rec
/*
b
*/
- {b = 1;};
+ { b = 1; };
m = a:
/*
b
diff --git i/src/alejandra/tests/cases/lists/out.nix w/src/alejandra/tests/cases/lists/out.nix
index dedee64..43a9de3 100644
--- i/src/alejandra/tests/cases/lists/out.nix
+++ w/src/alejandra/tests/cases/lists/out.nix
@@ -1,11 +1,11 @@
[
- [1]
+ [ 1 ]
[
1
]
- [b d]
+ [ b d ]
[
b
d
diff --git i/src/alejandra/tests/cases/monsters_3/out.nix w/src/alejandra/tests/cases/monsters_3/out.nix
index 25ff805..fd242fb 100644
--- i/src/alejandra/tests/cases/monsters_3/out.nix
+++ w/src/alejandra/tests/cases/monsters_3/out.nix
@@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
wrapGAppsHook4
glib # for glib-compile-resources
];
- buildInputs = [cairo glib gtk4 libadwaita pango];
+ buildInputs = [ cairo glib gtk4 libadwaita pango ];
postPatch = ''
patchShebangs build-aux/meson_post_install.py
# https://gitlab.gnome.org/World/design/contrast/-/merge_requests/23
@@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
description = "Checks whether the contrast between two colors meet the WCAG requirements";
homepage = "https://gitlab.gnome.org/World/design/contrast";
license = licenses.gpl3Plus;
- maintainers = with maintainers; [jtojnar];
+ maintainers = with maintainers; [ jtojnar ];
platforms = platforms.unix;
};
}
diff --git i/src/alejandra/tests/cases/with/out.nix w/src/alejandra/tests/cases/with/out.nix
index cd15509..b31b2f0 100644
--- i/src/alejandra/tests/cases/with/out.nix
+++ w/src/alejandra/tests/cases/with/out.nix
@@ -21,9 +21,9 @@
c)
(with b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
(with b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
- {a = with b; 1;}
- {a = with b; 1 + 1;}
- {a = with b; {c = 1;};}
+ { a = with b; 1; }
+ { a = with b; 1 + 1; }
+ { a = with b; { c = 1; }; }
{
a = with b; {
c = 1;
@@ -40,7 +40,7 @@
a = with b; 1;
# comment
}
- (with a; with b; with c; {a = 1;})
+ (with a; with b; with c; { a = 1; })
(with a;
with b;
with c; {

View file

@ -1,4 +1,8 @@
{alejandra, ...}:
{
lib,
alejandra,
...
}:
alejandra.overrideAttrs (prev: {
pname = "alejandra-custom";
version = "0-unstable-2024-07-21";
@ -7,7 +11,9 @@ alejandra.overrideAttrs (prev: {
(prev.patches or [])
++ [./0001-no-ads.patch];
meta.description = ''
Patched version of Alejandra that removes ads and adds spaces in attrsets & lists
'';
meta = {
description = "Custom build of Alejandra without ads & spaces around lists and attrsets";
mainProgram = "alejandra";
maintainers = [lib.maintainers.NotAShelf];
};
})