Compare commits

15 Commits

Author SHA1 Message Date
c0111f2720 [docs] include README.md into docs 2023-10-31 00:46:57 +01:00
bcaacc1634 [readme] WIP update 2023-10-31 00:46:10 +01:00
abbd1561f2 [docs] add README for triggers and actions 2023-10-31 00:45:44 +01:00
b9b7c0bf3b [docs] change docbuilder markdown output 2023-10-31 00:44:49 +01:00
8898565ff8 [docs] add Examples to each trigger/action 2023-10-31 00:41:59 +01:00
06534e0bbd [readme] init 2023-10-30 23:08:02 +01:00
d4a660383e [docs] rm unused file 2023-10-30 23:00:32 +01:00
e96bbb5f49 [gitignore] update 2023-10-30 23:00:22 +01:00
ad9060c8f6 [gokill] mv main 2023-10-30 23:00:05 +01:00
58946000e1 [docs] add docbuilder.go 2023-10-30 22:57:34 +01:00
b08446bbff [gitignore] update 2023-10-30 22:57:34 +01:00
6c750a947f [docs] setup flake and dir 2023-10-30 22:57:34 +01:00
b2e20c5d75 [nix] add devShell 2023-10-30 22:57:34 +01:00
737b90d597 [actions] handle errors via channel 2023-10-30 22:57:34 +01:00
e9969abf1c [docs] init 2023-10-30 19:34:16 +01:00
7 changed files with 57 additions and 69 deletions

View File

@@ -49,7 +49,7 @@ func (p Printer) GetExample() string {
return ` return `
{ {
type: "Print", type: "Print",
"options": { "options: {
"message": "Hello World!" "message": "Hello World!"
} }
} }

View File

@@ -15,7 +15,9 @@ Actions have the following syntax:
"type": "SomeAction", "type": "SomeAction",
"options": { //each action defines its own options "options": { //each action defines its own options
"firstOption": "someValue", "firstOption": "someValue",
"stage": 2 //this (positive) number defines the order of multiple actions "Stage": 2 //this (positive) number defines the order of multiple actions
} }
} }
``` ```
To get a list of all actions and their options from the commandline run ``` gokill -d ```

View File

@@ -17,3 +17,5 @@ Triggers have the following syntax:
"actions": [] //list actions that should be executed here "actions": [] //list actions that should be executed here
} }
``` ```
To get a list of all triggers and their options from the commandline run ```gokill -d```

112
flake.nix
View File

@@ -47,7 +47,7 @@
nixosModules.gokill = { config, lib, pkgs, ... }: nixosModules.gokill = { config, lib, pkgs, ... }:
let let
cfg = config.services.gokill; cfg = config.services.gokill;
configFile = pkgs.writeText "config.json" (builtins.toJSON cfg.triggers); configFile = pkgs.writeText "config.json" ''${cfg.extraConfig}'';
gokill-pkg = self.packages.x86_64-linux.gokill; gokill-pkg = self.packages.x86_64-linux.gokill;
in in
{ {
@@ -61,45 +61,6 @@
''; '';
}; };
triggers = lib.mkOption {
description = "list of triggers";
default = [];
type = with lib.types; lib.types.listOf ( submodule {
options = {
type = lib.mkOption {
type = lib.types.str;
};
name = lib.mkOption {
type = lib.types.str;
};
options = lib.mkOption {
type = lib.types.attrs;
};
actions = lib.mkOption {
description = "list of actions";
type = with lib.types; lib.types.listOf ( submodule {
options = {
type = lib.mkOption {
type = lib.types.str;
};
options = lib.mkOption {
type = lib.types.attrs;
};
stage = lib.mkOption {
type = lib.types.int;
};
};
});
};
};
});
};
extraConfig = lib.mkOption { extraConfig = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = lib.mdDoc '' description = lib.mdDoc ''
@@ -131,30 +92,53 @@
self.nixosModules.gokill self.nixosModules.gokill
{ {
services.gokill.enable = true; services.gokill.enable = true;
services.gokill.triggers = [ services.gokill.extraConfig = ''
{ [
type = "Timeout"; {
name = "custom timeout"; "type": "Timeout",
options = { "name": "custom timeout",
duration = 10; "options": {
}; "duration": 30
actions = [ },
{ "actions": [
type = "Timeout"; {
options = { "type": "Print",
duration = 5; "options": {
}; "message": "Stage 1 triggered. Waiting 25 seconds"
stage = 1; },
} "stage": 1
{ },
type = "Shutdown"; {
options = { "type": "Timeout",
}; "options": {
stage = 2; "duration": 20
} },
]; "stage": 1
} },
]; {
"type": "Timeout",
"options": {
"duration": 5
},
"stage": 2
},
{
"type": "Print",
"options": {
"message": "Shutdown in 5 seconds..."
},
"stage": 2
},
{
"type": "Shutdown",
"options": {
},
"stage": 3
}
]
}
]
'';
users.users.root.password = "root"; users.users.root.password = "root";
virtualisation.vmVariant.virtualisation.graphics = false; virtualisation.vmVariant.virtualisation.graphics = false;
} }

View File

@@ -95,7 +95,7 @@ func (p EthernetDisconnect) GetExample() string {
"options": { "options": {
"interfaceName": "eth0", "interfaceName": "eth0",
"waitTillConnected": true "waitTillConnected": true
}, }
"actions": [ "actions": [
] ]
} }

View File

@@ -54,7 +54,7 @@ func (p TimeOut) GetExample() string {
"name": "Example Trigger", "name": "Example Trigger",
"options": { "options": {
"duration": 5 "duration": 5
}, }
"actions": [ "actions": [
] ]
} }

View File

@@ -96,7 +96,7 @@ func (p UsbDisconnect) GetExample() string {
"options": { "options": {
"deviceId": "ata-Samsung_SSD_860_EVO_1TB_S4AALKWJDI102", "deviceId": "ata-Samsung_SSD_860_EVO_1TB_S4AALKWJDI102",
"waitTillConnected": true "waitTillConnected": true
}, }
"actions": [ "actions": [
] ]
} }