mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Format .nix files
... with nixfmt (rfc style)
This commit is contained in:
parent
ba6425a7d0
commit
96e550efc5
266 changed files with 7460 additions and 5138 deletions
|
@ -7,26 +7,27 @@
|
|||
];
|
||||
|
||||
/*
|
||||
Test cases
|
||||
Test cases
|
||||
|
||||
Test cases are automatically imported from ./test-cases/{name}
|
||||
Test cases are automatically imported from ./test-cases/{name}
|
||||
|
||||
The following is set up automatically for each test case:
|
||||
- a repo with the {name} is created on the gitea server
|
||||
- a repo with the {name} is created on the client
|
||||
- the client repo is configured to push to the server repo
|
||||
The following is set up automatically for each test case:
|
||||
- a repo with the {name} is created on the gitea server
|
||||
- a repo with the {name} is created on the client
|
||||
- the client repo is configured to push to the server repo
|
||||
|
||||
Python variables:
|
||||
- repo.path: the path to the directory of the client repo
|
||||
- repo.git: the git command with the client repo as the working directory
|
||||
- repo.remote: the url to the server repo
|
||||
Python variables:
|
||||
- repo.path: the path to the directory of the client repo
|
||||
- repo.git: the git command with the client repo as the working directory
|
||||
- repo.remote: the url to the server repo
|
||||
*/
|
||||
testCases =
|
||||
map
|
||||
(testCaseName: {...}: {
|
||||
testCases = map (
|
||||
testCaseName:
|
||||
{ ... }:
|
||||
{
|
||||
imports = [ (./test-cases + "/${testCaseName}") ];
|
||||
# ensures tests are named like their directories they are defined in
|
||||
name = testCaseName;
|
||||
})
|
||||
(lib.attrNames (builtins.readDir ./test-cases));
|
||||
}
|
||||
) (lib.attrNames (builtins.readDir ./test-cases));
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
script = ''
|
||||
# add a file to the repo
|
||||
client.succeed(f"""
|
||||
echo ${config.name /* to make the git tree and store path unique */} > {repo.path}/test-case \
|
||||
echo ${config.name # to make the git tree and store path unique
|
||||
} > {repo.path}/test-case \
|
||||
&& echo lutyabrook > {repo.path}/new-york-state \
|
||||
&& {repo.git} add test-case new-york-state \
|
||||
&& {repo.git} commit -m 'commit1'
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
script = ''
|
||||
# add a file to the repo
|
||||
client.succeed(f"""
|
||||
echo ${config.name /* to make the git tree and store path unique */} > {repo.path}/test-case \
|
||||
echo ${config.name # to make the git tree and store path unique
|
||||
} > {repo.path}/test-case \
|
||||
&& echo chiang-mai > {repo.path}/thailand \
|
||||
&& {repo.git} add test-case thailand \
|
||||
&& {repo.git} commit -m 'commit1'
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
script = ''
|
||||
# add a file to the repo
|
||||
client.succeed(f"""
|
||||
echo ${config.name /* to make the git tree and store path unique */} > {repo.path}/test-case \
|
||||
echo ${config.name # to make the git tree and store path unique
|
||||
} > {repo.path}/test-case \
|
||||
&& echo chiang-mai > {repo.path}/thailand \
|
||||
&& {repo.git} add test-case thailand \
|
||||
&& {repo.git} commit -m 'commit1'
|
||||
|
|
|
@ -8,25 +8,27 @@ let
|
|||
|
||||
boolPyLiteral = b: if b then "True" else "False";
|
||||
|
||||
testCaseExtension = { config, ... }: {
|
||||
options = {
|
||||
repo.enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to provide a repo variable - automatic repo creation.";
|
||||
testCaseExtension =
|
||||
{ config, ... }:
|
||||
{
|
||||
options = {
|
||||
repo.enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to provide a repo variable - automatic repo creation.";
|
||||
};
|
||||
repo.private = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether the repo should be private.";
|
||||
};
|
||||
};
|
||||
repo.private = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether the repo should be private.";
|
||||
config = mkIf config.repo.enable {
|
||||
setupScript = ''
|
||||
repo = Repo("${config.name}", private=${boolPyLiteral config.repo.private})
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = mkIf config.repo.enable {
|
||||
setupScript = ''
|
||||
repo = Repo("${config.name}", private=${boolPyLiteral config.repo.private})
|
||||
'';
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
{ lib, nixpkgs, system, pkgs, ... }: let
|
||||
{
|
||||
lib,
|
||||
nixpkgs,
|
||||
system,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
clientPrivateKey = pkgs.writeText "id_ed25519" ''
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
|
@ -9,41 +16,52 @@
|
|||
-----END OPENSSH PRIVATE KEY-----
|
||||
'';
|
||||
|
||||
clientPublicKey =
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFt5a8eH8BYZYjoQhzXGVKKHJe1pw1D0p7O2Vb9VTLzB";
|
||||
clientPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFt5a8eH8BYZYjoQhzXGVKKHJe1pw1D0p7O2Vb9VTLzB";
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../testsupport/setup.nix
|
||||
../testsupport/gitea-repo.nix
|
||||
];
|
||||
nodes = {
|
||||
gitea = { pkgs, ... }: {
|
||||
services.gitea.enable = true;
|
||||
services.gitea.settings.service.DISABLE_REGISTRATION = true;
|
||||
services.gitea.settings.log.LEVEL = "Info";
|
||||
services.gitea.settings.database.LOG_SQL = false;
|
||||
services.openssh.enable = true;
|
||||
networking.firewall.allowedTCPPorts = [ 3000 ];
|
||||
environment.systemPackages = [ pkgs.git pkgs.gitea ];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [clientPublicKey];
|
||||
|
||||
# TODO: remove this after updating to nixos-23.11
|
||||
nixpkgs.pkgs = lib.mkForce (import nixpkgs {
|
||||
inherit system;
|
||||
config.permittedInsecurePackages = [
|
||||
"gitea-1.19.4"
|
||||
gitea =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.gitea.enable = true;
|
||||
services.gitea.settings.service.DISABLE_REGISTRATION = true;
|
||||
services.gitea.settings.log.LEVEL = "Info";
|
||||
services.gitea.settings.database.LOG_SQL = false;
|
||||
services.openssh.enable = true;
|
||||
networking.firewall.allowedTCPPorts = [ 3000 ];
|
||||
environment.systemPackages = [
|
||||
pkgs.git
|
||||
pkgs.gitea
|
||||
];
|
||||
});
|
||||
};
|
||||
client = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.git ];
|
||||
};
|
||||
};
|
||||
defaults = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [ clientPublicKey ];
|
||||
|
||||
# TODO: remove this after updating to nixos-23.11
|
||||
nixpkgs.pkgs = lib.mkForce (
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
config.permittedInsecurePackages = [
|
||||
"gitea-1.19.4"
|
||||
];
|
||||
}
|
||||
);
|
||||
};
|
||||
client =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.git ];
|
||||
};
|
||||
};
|
||||
defaults =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
};
|
||||
|
||||
setupScript = ''
|
||||
import shlex
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
{ lib, config, extendModules, ... }:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
extendModules,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
||||
indent = lib.replaceStrings ["\n"] ["\n "];
|
||||
indent = lib.replaceStrings [ "\n" ] [ "\n " ];
|
||||
|
||||
execTestCase = testCase: ''
|
||||
|
||||
|
@ -35,37 +40,39 @@ in
|
|||
description = ''
|
||||
The test cases. See `testScript`.
|
||||
'';
|
||||
type = types.listOf (types.submodule {
|
||||
options.name = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
The name of the test case.
|
||||
type = types.listOf (
|
||||
types.submodule {
|
||||
options.name = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
The name of the test case.
|
||||
|
||||
A repository with that name will be set up on the gitea server and locally.
|
||||
'';
|
||||
};
|
||||
options.description = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
A description of the test case.
|
||||
'';
|
||||
};
|
||||
options.setupScript = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Python code that runs before the test case.
|
||||
'';
|
||||
default = "";
|
||||
};
|
||||
options.script = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Python code that runs the test.
|
||||
A repository with that name will be set up on the gitea server and locally.
|
||||
'';
|
||||
};
|
||||
options.description = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
A description of the test case.
|
||||
'';
|
||||
};
|
||||
options.setupScript = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Python code that runs before the test case.
|
||||
'';
|
||||
default = "";
|
||||
};
|
||||
options.script = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Python code that runs the test.
|
||||
|
||||
Variables defined by the global `setupScript`, as well as `testCases.*.setupScript` will be available here.
|
||||
'';
|
||||
};
|
||||
});
|
||||
Variables defined by the global `setupScript`, as well as `testCases.*.setupScript` will be available here.
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -74,10 +81,12 @@ in
|
|||
environment.variables = {
|
||||
_NIX_FORCE_HTTP = "1";
|
||||
};
|
||||
nix.settings.experimental-features = ["nix-command" "flakes"];
|
||||
nix.settings.experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
};
|
||||
setupScript = ''
|
||||
'';
|
||||
setupScript = '''';
|
||||
testScript = ''
|
||||
start_all();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue