nix: format test fixtures via nix fmt

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia9c1e9b0a8cd9c6d834f153609baa5426a6a6964
This commit is contained in:
raf 2026-02-22 00:18:15 +03:00
commit b49044c9a5
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
15 changed files with 132 additions and 73 deletions

View file

@ -4,9 +4,10 @@
outputs = {nixpkgs, ...}: let
systems = ["x86_64-linux" "aarch64-linux"];
forAllSystems = nixpkgs.lib.genAttrs systems;
pkgsFor = system: nixpkgs.legacyPackages.${system};
in {
devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
pkgs = pkgsFor system;
in {
default = pkgs.mkShell {
name = "nixir";
@ -34,5 +35,21 @@
env.NIX_PLUGINABI = "0.2";
};
});
formatter = forAllSystems (system: let
pkgs = pkgsFor system;
in
pkgs.writeShellApplication {
name = "nix3-fmt-wrapper";
runtimeInputs = [
pkgs.alejandra
pkgs.fd
];
text = ''
fd "$@" -t f -e nix -x alejandra -q '{}'
'';
});
};
}

View file

@ -1,4 +1,3 @@
let
x = 10;
in
{ a = x; }
in {a = x;}

View file

@ -3,4 +3,6 @@ let
a = 10;
b = 20;
in
if a < b then true else false
if a < b
then true
else false

View file

@ -1,2 +1,4 @@
# Conditional test
if true then 1 else 2
if true
then 1
else 2

View file

@ -2,9 +2,12 @@
let
x = 10;
y = 20;
attrs = { a = 1; b = 2; c = 3; };
in
{
attrs = {
a = 1;
b = 2;
c = 3;
};
in {
# Basic inherit from outer scope
inherit x y;

View file

@ -1,4 +1,3 @@
let
attrs = {a = 1;};
in
{ inherit (attrs) a; }
in {inherit (attrs) a;}

View file

@ -1,4 +1,3 @@
let
x = 10;
in
{ inherit x; }
in {inherit x;}

View file

@ -1,35 +1,60 @@
# Test lambda patterns
let
# Basic destructuring
f1 = { a, b }: a + b;
f1 = {
a,
b,
}:
a + b;
# With default values
f2 = { a, b ? 10 }: a + b;
f2 = {
a,
b ? 10,
}:
a + b;
# With ellipsis (extra fields allowed)
f3 = {a, ...}: a * 2;
# Named pattern with ellipsis to allow extra fields
f4 = arg@{ a, b, ... }: a + b + arg.c;
f4 = arg @ {
a,
b,
...
}:
a + b + arg.c;
# Simple lambda (not a pattern)
f5 = x: x + 1;
in
{
in {
# Test basic destructuring
test1 = f1 { a = 3; b = 4; };
test1 = f1 {
a = 3;
b = 4;
};
# Test with defaults (provide both)
test2a = f2 { a = 5; b = 6; };
test2a = f2 {
a = 5;
b = 6;
};
# Test with defaults (use default for b)
test2b = f2 {a = 5;};
# Test ellipsis (extra field ignored)
test3 = f3 { a = 7; extra = 999; };
test3 = f3 {
a = 7;
extra = 999;
};
# Test named pattern
test4 = f4 { a = 1; b = 2; c = 3; };
test4 = f4 {
a = 1;
b = 2;
c = 3;
};
# Test simple lambda
test5 = f5 10;

View file

@ -2,4 +2,5 @@
let
x = 10;
y = 20;
in x
in
x

View file

@ -3,4 +3,8 @@ let
x = true;
y = false;
in
if x && y then 1 else if x || y then 2 else 3
if x && y
then 1
else if x || y
then 2
else 3

View file

@ -4,5 +4,9 @@ let
b = 10 - 5 - 2; # Should be (10 - 5) - 2 = 3
c = true && false || true; # Should be (true && false) || true = true
d = 1 < 2 && 3 > 2; # Should be (1 < 2) && (3 > 2) = true
in
{ a = a; b = b; c = c; d = d; }
in {
a = a;
b = b;
c = c;
d = d;
}

View file

@ -3,8 +3,7 @@ let
alwaysFalse = false;
alwaysTrue = true;
x = 10;
in
{
in {
and_false = alwaysFalse && alwaysTrue;
or_true = alwaysTrue || alwaysFalse;
impl_false = alwaysFalse -> alwaysFalse;

View file

@ -3,8 +3,7 @@ let
name = "world";
x = 42;
bool_val = true;
in
{
in {
# Simple interpolation
greeting = "Hello ${name}!";
@ -12,7 +11,11 @@ in
multi = "x is ${x} and name is ${name}";
# Nested expression
nested = "Result: ${if bool_val then "yes" else "no"}";
nested = "Result: ${
if bool_val
then "yes"
else "no"
}";
# Just a string (no interpolation)
plain = "plain text";

View file

@ -2,5 +2,7 @@
let
x = 10;
y = true;
in
{ neg = -x; not = !y; }
in {
neg = -x;
not = !y;
}