Initial commit
This commit is contained in:
commit
cfcc57a8bd
353 changed files with 18756 additions and 0 deletions
1
flake/den/checkmate/.gitignore
vendored
Normal file
1
flake/den/checkmate/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
flake.lock
|
||||
7
flake/den/checkmate/flake.nix
Normal file
7
flake/den/checkmate/flake.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
inputs.target.url = "path:..";
|
||||
inputs.checkmate.url = "github:vic/checkmate";
|
||||
inputs.checkmate.inputs.target.follows = "target";
|
||||
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
outputs = inputs: inputs.checkmate.lib.newFlake;
|
||||
}
|
||||
198
flake/den/checkmate/tests/aspect-functor.nix
Normal file
198
flake/den/checkmate/tests/aspect-functor.nix
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
{
|
||||
lib,
|
||||
inputs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
den.lib = inputs.target.lib { inherit lib inputs config; };
|
||||
|
||||
inherit (den.lib) parametric canTake;
|
||||
|
||||
aspect-example = {
|
||||
__functor = parametric.atLeast;
|
||||
nixos.foo = 99;
|
||||
includes = [
|
||||
{ nixos.static = 100; }
|
||||
(
|
||||
{ host, ... }:
|
||||
{
|
||||
nixos.host = host;
|
||||
}
|
||||
)
|
||||
(
|
||||
{ host, user, ... }:
|
||||
{
|
||||
nixos.host-user = [
|
||||
host
|
||||
user
|
||||
];
|
||||
}
|
||||
)
|
||||
(
|
||||
{
|
||||
OS,
|
||||
user,
|
||||
host,
|
||||
...
|
||||
}:
|
||||
{
|
||||
nixos.os-user-host = [
|
||||
OS
|
||||
user
|
||||
host
|
||||
];
|
||||
}
|
||||
)
|
||||
(
|
||||
{ user, ... }:
|
||||
{
|
||||
nixos.user = user;
|
||||
}
|
||||
)
|
||||
(
|
||||
{ user, ... }@ctx:
|
||||
if canTake.exactly ctx ({ user }: user) then
|
||||
{
|
||||
nixos.user-only = user;
|
||||
}
|
||||
else
|
||||
{ nixos.user-only = false; }
|
||||
)
|
||||
(
|
||||
{ home, ... }:
|
||||
{
|
||||
nixos.home = home;
|
||||
}
|
||||
)
|
||||
(_any: {
|
||||
nixos.any = 10;
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with empty attrs" = {
|
||||
expr = (aspect-example { });
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with host only" = {
|
||||
expr = (
|
||||
aspect-example {
|
||||
host = 2;
|
||||
}
|
||||
);
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.host = 2; } # host
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with home only" = {
|
||||
expr = (
|
||||
aspect-example {
|
||||
home = 2;
|
||||
}
|
||||
);
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.home = 2; } # home
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with home and unknown" = {
|
||||
expr = (
|
||||
aspect-example {
|
||||
home = 2;
|
||||
unknown = 1;
|
||||
}
|
||||
);
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.home = 2; }
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with user only" = {
|
||||
expr = (
|
||||
aspect-example {
|
||||
user = 2;
|
||||
}
|
||||
);
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.user = 2; } # user
|
||||
{ nixos.user-only = 2; } # user-only
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with user and host" = {
|
||||
expr = (
|
||||
aspect-example {
|
||||
user = 2;
|
||||
host = 1;
|
||||
}
|
||||
);
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.host = 1; }
|
||||
{
|
||||
nixos.host-user = [
|
||||
1
|
||||
2
|
||||
];
|
||||
}
|
||||
{ nixos.user = 2; }
|
||||
{ nixos.user-only = false; }
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
flake.tests."test functor applied with host/user/OS" = {
|
||||
expr = (
|
||||
aspect-example {
|
||||
OS = 0;
|
||||
user = 2;
|
||||
host = 1;
|
||||
}
|
||||
);
|
||||
expected = {
|
||||
includes = [
|
||||
{ nixos.host = 1; }
|
||||
{
|
||||
nixos.host-user = [
|
||||
1
|
||||
2
|
||||
];
|
||||
}
|
||||
{
|
||||
nixos.os-user-host = [
|
||||
0
|
||||
2
|
||||
1
|
||||
];
|
||||
}
|
||||
{ nixos.user = 2; }
|
||||
{ nixos.user-only = false; }
|
||||
{ nixos.any = 10; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
inherit flake;
|
||||
}
|
||||
40
flake/den/checkmate/tests/den-brackets.nix
Normal file
40
flake/den/checkmate/tests/den-brackets.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{ ... }@top:
|
||||
let
|
||||
lib = top.inputs.nixpkgs.lib;
|
||||
|
||||
# deadnix: skip
|
||||
__findFile =
|
||||
if true then
|
||||
import "${top.inputs.target}/nix/den-brackets.nix" { inherit lib config inputs; }
|
||||
else
|
||||
__findFile;
|
||||
|
||||
inputs = {
|
||||
|
||||
};
|
||||
|
||||
config.den = {
|
||||
default.foo = 1;
|
||||
|
||||
provides.foo.a = 2;
|
||||
provides.foo.provides.bar.b = 3;
|
||||
provides.foo.provides.c = 4;
|
||||
|
||||
d = 5;
|
||||
|
||||
aspects.foo.a = 6;
|
||||
aspects.foo.provides.bar.b = 7;
|
||||
aspects.foo.provides.c = 8;
|
||||
|
||||
};
|
||||
in
|
||||
{
|
||||
flake.tests."<den.default>" =
|
||||
let
|
||||
expr = <den.default>;
|
||||
expected.foo = 2;
|
||||
in
|
||||
{
|
||||
inherit expr expected;
|
||||
};
|
||||
}
|
||||
85
flake/den/checkmate/tests/function_can_take.nix
Normal file
85
flake/den/checkmate/tests/function_can_take.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
lib,
|
||||
inputs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
den.lib = inputs.target.lib { inherit inputs lib config; };
|
||||
takes = den.lib.canTake;
|
||||
|
||||
flake.tests."test exactly fails" = {
|
||||
expr = takes.exactly {
|
||||
a = 1;
|
||||
b = 2;
|
||||
} ({ a }: a);
|
||||
expected = false;
|
||||
};
|
||||
|
||||
flake.tests."test exactly succeeds" = {
|
||||
expr = takes.exactly { a = 1; } ({ a }: a);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
flake.tests."test function with no named arguments can take anything" = {
|
||||
expr = takes { } (x: x);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
flake.tests."test function called with non attrs" = {
|
||||
expr = takes 22 ({ host }: [ host ]);
|
||||
expected = false;
|
||||
};
|
||||
|
||||
flake.tests."test function missing required attr" = {
|
||||
expr = takes { } ({ host }: [ host ]);
|
||||
expected = false;
|
||||
};
|
||||
|
||||
flake.tests."test function satisfied required attr" = {
|
||||
expr = takes {
|
||||
host = 1;
|
||||
} ({ host, ... }: [ host ]);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
flake.tests."test function missing second required attr" = {
|
||||
expr =
|
||||
takes
|
||||
{
|
||||
host = 1;
|
||||
}
|
||||
(
|
||||
{ host, user }:
|
||||
[
|
||||
host
|
||||
user
|
||||
]
|
||||
);
|
||||
expected = false;
|
||||
};
|
||||
|
||||
flake.tests."test function optional second attr" = {
|
||||
expr =
|
||||
takes
|
||||
{
|
||||
host = 1;
|
||||
foo = 9;
|
||||
}
|
||||
(
|
||||
{
|
||||
host,
|
||||
user ? 0,
|
||||
}:
|
||||
[
|
||||
host
|
||||
user
|
||||
]
|
||||
);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
inherit flake;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue