Compare commits
No commits in common. "b49044c9a5a461d1da87a9dc6662700a1964d3f3" and "829199f91a9bff85f2a69221fa0f9d55fe1f3c86" have entirely different histories.
b49044c9a5
...
829199f91a
15 changed files with 73 additions and 132 deletions
19
flake.nix
19
flake.nix
|
|
@ -4,10 +4,9 @@
|
||||||
outputs = {nixpkgs, ...}: let
|
outputs = {nixpkgs, ...}: let
|
||||||
systems = ["x86_64-linux" "aarch64-linux"];
|
systems = ["x86_64-linux" "aarch64-linux"];
|
||||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
pkgsFor = system: nixpkgs.legacyPackages.${system};
|
|
||||||
in {
|
in {
|
||||||
devShells = forAllSystems (system: let
|
devShells = forAllSystems (system: let
|
||||||
pkgs = pkgsFor system;
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in {
|
in {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
name = "nixir";
|
name = "nixir";
|
||||||
|
|
@ -35,21 +34,5 @@
|
||||||
env.NIX_PLUGINABI = "0.2";
|
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 '{}'
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
let
|
let
|
||||||
x = 10;
|
x = 10;
|
||||||
in {a = x;}
|
in
|
||||||
|
{ a = x; }
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,4 @@ let
|
||||||
a = 10;
|
a = 10;
|
||||||
b = 20;
|
b = 20;
|
||||||
in
|
in
|
||||||
if a < b
|
if a < b then true else false
|
||||||
then true
|
|
||||||
else false
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,2 @@
|
||||||
# Conditional test
|
# Conditional test
|
||||||
if true
|
if true then 1 else 2
|
||||||
then 1
|
|
||||||
else 2
|
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,16 @@
|
||||||
let
|
let
|
||||||
x = 10;
|
x = 10;
|
||||||
y = 20;
|
y = 20;
|
||||||
attrs = {
|
attrs = { a = 1; b = 2; c = 3; };
|
||||||
a = 1;
|
in
|
||||||
b = 2;
|
{
|
||||||
c = 3;
|
# Basic inherit from outer scope
|
||||||
};
|
inherit x y;
|
||||||
in {
|
|
||||||
# Basic inherit from outer scope
|
|
||||||
inherit x y;
|
|
||||||
|
|
||||||
# Inherit from expression
|
# Inherit from expression
|
||||||
inherit (attrs) a b;
|
inherit (attrs) a b;
|
||||||
|
|
||||||
# Mixed
|
# Mixed
|
||||||
z = 30;
|
z = 30;
|
||||||
inherit (attrs) c;
|
inherit (attrs) c;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
let
|
let
|
||||||
attrs = {a = 1;};
|
attrs = { a = 1; };
|
||||||
in {inherit (attrs) a;}
|
in
|
||||||
|
{ inherit (attrs) a; }
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
let
|
let
|
||||||
x = 10;
|
x = 10;
|
||||||
in {inherit x;}
|
in
|
||||||
|
{ inherit x; }
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1,36 @@
|
||||||
# Test lambda patterns
|
# Test lambda patterns
|
||||||
let
|
let
|
||||||
# Basic destructuring
|
# Basic destructuring
|
||||||
f1 = {
|
f1 = { a, b }: a + b;
|
||||||
a,
|
|
||||||
b,
|
|
||||||
}:
|
|
||||||
a + b;
|
|
||||||
|
|
||||||
# With default values
|
# With default values
|
||||||
f2 = {
|
f2 = { a, b ? 10 }: a + b;
|
||||||
a,
|
|
||||||
b ? 10,
|
|
||||||
}:
|
|
||||||
a + b;
|
|
||||||
|
|
||||||
# With ellipsis (extra fields allowed)
|
# With ellipsis (extra fields allowed)
|
||||||
f3 = {a, ...}: a * 2;
|
f3 = { a, ... }: a * 2;
|
||||||
|
|
||||||
# Named pattern with ellipsis to allow extra fields
|
# Named pattern with ellipsis to allow extra fields
|
||||||
f4 = arg @ {
|
f4 = arg@{ a, b, ... }: a + b + arg.c;
|
||||||
a,
|
|
||||||
b,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
a + b + arg.c;
|
|
||||||
|
|
||||||
# Simple lambda (not a pattern)
|
# Simple lambda (not a pattern)
|
||||||
f5 = x: x + 1;
|
f5 = x: x + 1;
|
||||||
in {
|
in
|
||||||
# Test basic destructuring
|
{
|
||||||
test1 = f1 {
|
# Test basic destructuring
|
||||||
a = 3;
|
test1 = f1 { a = 3; b = 4; };
|
||||||
b = 4;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Test with defaults (provide both)
|
# Test with defaults (provide both)
|
||||||
test2a = f2 {
|
test2a = f2 { a = 5; b = 6; };
|
||||||
a = 5;
|
|
||||||
b = 6;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Test with defaults (use default for b)
|
# Test with defaults (use default for b)
|
||||||
test2b = f2 {a = 5;};
|
test2b = f2 { a = 5; };
|
||||||
|
|
||||||
# Test ellipsis (extra field ignored)
|
# Test ellipsis (extra field ignored)
|
||||||
test3 = f3 {
|
test3 = f3 { a = 7; extra = 999; };
|
||||||
a = 7;
|
|
||||||
extra = 999;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Test named pattern
|
# Test named pattern
|
||||||
test4 = f4 {
|
test4 = f4 { a = 1; b = 2; c = 3; };
|
||||||
a = 1;
|
|
||||||
b = 2;
|
|
||||||
c = 3;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Test simple lambda
|
# Test simple lambda
|
||||||
test5 = f5 10;
|
test5 = f5 10;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,4 @@
|
||||||
let
|
let
|
||||||
x = 10;
|
x = 10;
|
||||||
y = 20;
|
y = 20;
|
||||||
in
|
in x
|
||||||
x
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,4 @@ let
|
||||||
x = true;
|
x = true;
|
||||||
y = false;
|
y = false;
|
||||||
in
|
in
|
||||||
if x && y
|
if x && y then 1 else if x || y then 2 else 3
|
||||||
then 1
|
|
||||||
else if x || y
|
|
||||||
then 2
|
|
||||||
else 3
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
# Test operator precedence
|
# Test operator precedence
|
||||||
let
|
let
|
||||||
a = 1 + 2 * 3; # Should be 1 + (2 * 3) = 7
|
a = 1 + 2 * 3; # Should be 1 + (2 * 3) = 7
|
||||||
b = 10 - 5 - 2; # Should be (10 - 5) - 2 = 3
|
b = 10 - 5 - 2; # Should be (10 - 5) - 2 = 3
|
||||||
c = true && false || true; # Should be (true && false) || true = true
|
c = true && false || true; # Should be (true && false) || true = true
|
||||||
d = 1 < 2 && 3 > 2; # Should be (1 < 2) && (3 > 2) = true
|
d = 1 < 2 && 3 > 2; # Should be (1 < 2) && (3 > 2) = true
|
||||||
in {
|
in
|
||||||
a = a;
|
{ a = a; b = b; c = c; d = d; }
|
||||||
b = b;
|
|
||||||
c = c;
|
|
||||||
d = d;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ let
|
||||||
alwaysFalse = false;
|
alwaysFalse = false;
|
||||||
alwaysTrue = true;
|
alwaysTrue = true;
|
||||||
x = 10;
|
x = 10;
|
||||||
in {
|
in
|
||||||
and_false = alwaysFalse && alwaysTrue;
|
{
|
||||||
or_true = alwaysTrue || alwaysFalse;
|
and_false = alwaysFalse && alwaysTrue;
|
||||||
impl_false = alwaysFalse -> alwaysFalse;
|
or_true = alwaysTrue || alwaysFalse;
|
||||||
}
|
impl_false = alwaysFalse -> alwaysFalse;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
1 + 2
|
1 + 2
|
||||||
|
|
@ -3,20 +3,17 @@ let
|
||||||
name = "world";
|
name = "world";
|
||||||
x = 42;
|
x = 42;
|
||||||
bool_val = true;
|
bool_val = true;
|
||||||
in {
|
in
|
||||||
# Simple interpolation
|
{
|
||||||
greeting = "Hello ${name}!";
|
# Simple interpolation
|
||||||
|
greeting = "Hello ${name}!";
|
||||||
|
|
||||||
# Multiple interpolations
|
# Multiple interpolations
|
||||||
multi = "x is ${x} and name is ${name}";
|
multi = "x is ${x} and name is ${name}";
|
||||||
|
|
||||||
# Nested expression
|
# Nested expression
|
||||||
nested = "Result: ${
|
nested = "Result: ${if bool_val then "yes" else "no"}";
|
||||||
if bool_val
|
|
||||||
then "yes"
|
|
||||||
else "no"
|
|
||||||
}";
|
|
||||||
|
|
||||||
# Just a string (no interpolation)
|
# Just a string (no interpolation)
|
||||||
plain = "plain text";
|
plain = "plain text";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,5 @@
|
||||||
let
|
let
|
||||||
x = 10;
|
x = 10;
|
||||||
y = true;
|
y = true;
|
||||||
in {
|
in
|
||||||
neg = -x;
|
{ neg = -x; not = !y; }
|
||||||
not = !y;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue