-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
95 lines (81 loc) · 2.92 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
description = "Manage rsync deployments declaratively.";
inputs.nixpkgs.url = "nixpkgs/nixpkgs-unstable";
outputs = {
self,
nixpkgs,
...
}: let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
in {
nixosModules = {clonix = import ./modules/nixos.nix;};
homeManagerModules = {clonix = import ./modules/home-manager.nix;};
formatter.${system} = pkgs.alejandra;
template.default = {
path = ./template;
description = "A simple NixOS/Home-Manager configuration to get you started with Clonix";
};
checks.${system}.default = pkgs.nixosTest {
name = "Rsync integration test";
nodes = {
reciever = {pkgs, ...}: {
services.openssh = {
enable = true;
allowSFTP = true;
openFirewall = true;
settings = {
PermitRootLogin = "yes";
PasswordAuthentication = true;
};
};
networking.useDHCP = false;
environment.systemPackages = with pkgs; [rsync];
users.users.tester = {
isNormalUser = true;
password = "tester";
};
networking.interfaces.eth0.ipv4.addresses = [
{
address = "192.168.1.5";
prefixLength = 24;
}
];
};
sender = {
nodes,
pkgs,
...
}: {
imports = [self.nixosModules.clonix];
environment.systemPackages = with pkgs; [rsync];
users.users.tester = {
isNormalUser = true;
password = "tester";
};
services.clonix.enable = true;
services.clonix.deployments = [
{
deploymentName = "testing_deployment";
local.dir = "${nodes.sender.users.users.tester.home}/testingfiles";
targetDir = "${nodes.reciever.users.users.tester.home}/testingfiles";
timer.enable = false;
timer.OnBootSec = "1";
remote.enable = nodes.reciever.services.openssh.enable;
remote.ipOrHostname = (builtins.elemAt nodes.reciever.networking.interfaces.eth0.ipv4.addresses 0).address;
remote.user.name = nodes.reciever.users.users.tester.name;
remote.user.password = nodes.reciever.users.users.tester.password;
}
];
};
};
testScript = {nodes, ...}: ''
sender.wait_for_unit("network.target")
reciever.wait_for_unit("network.target")
reciever.succeed("mkdir ${nodes.reciever.users.users.tester.home}/testingfiles")
sender.succeed("mkdir ${nodes.reciever.users.users.tester.home}/testingfiles && echo hi!!! >> ${nodes.reciever.users.users.tester.home}/testingfiles/cheetos && systemctl start clonix@*")
reciever.succeed("sleep 5 ; ls ${nodes.reciever.users.users.tester.home}/testingfiles")
'';
};
};
}