diff options
| author | Xe <me@christine.website> | 2022-04-28 02:31:05 +0000 |
|---|---|---|
| committer | Xe <me@christine.website> | 2022-04-28 02:31:05 +0000 |
| commit | 4d5379e7b0cc83d125d2c43bcd5507f11eba304d (patch) | |
| tree | 2156b2bb928ff0db346eff7eff8570ad20998b43 | |
| parent | d56721be6bac66729362384853761d6f962a5b4b (diff) | |
| download | x-4d5379e7b0cc83d125d2c43bcd5507f11eba304d.tar.xz x-4d5379e7b0cc83d125d2c43bcd5507f11eba304d.zip | |
start the nixification of robocadey-gpt2
Signed-off-by: Xe <me@christine.website>
| -rw-r--r-- | flake.lock | 17 | ||||
| -rw-r--r-- | flake.nix | 18 | ||||
| -rwxr-xr-x | mastodon/robocadey/gpt2/main.py | 2 | ||||
| -rw-r--r-- | run/robocadey-gpt2.service.in | 10 | ||||
| -rw-r--r-- | run/robocadey-gpt2.socket | 9 |
5 files changed, 53 insertions, 3 deletions
@@ -1,5 +1,21 @@ { "nodes": { + "ckiee": { + "locked": { + "lastModified": 1651110803, + "narHash": "sha256-je/Q14AwFYRbkQP9vC7Kl3lJOkCHBkq+hDDSXaeq9/M=", + "owner": "ckiee", + "repo": "nixpkgs", + "rev": "c052ad4d9c567930223b52f638d0e03b17d9d744", + "type": "github" + }, + "original": { + "owner": "ckiee", + "ref": "gpt2simple-py-init", + "repo": "nixpkgs", + "type": "github" + } + }, "gomod2nix": { "inputs": { "nixpkgs": "nixpkgs", @@ -86,6 +102,7 @@ }, "root": { "inputs": { + "ckiee": "ckiee", "gomod2nix": "gomod2nix", "nixpkgs": "nixpkgs_2", "portable-svc": "portable-svc", @@ -6,9 +6,10 @@ utils.url = "github:numtide/flake-utils"; gomod2nix.url = "github:tweag/gomod2nix"; portable-svc.url = "git+https://tulpa.dev/cadey/portable-svc.git?ref=main"; + ckiee.url = "github:ckiee/nixpkgs?ref=gpt2simple-py-init"; }; - outputs = { self, nixpkgs, utils, gomod2nix, portable-svc }: + outputs = { self, nixpkgs, utils, gomod2nix, portable-svc, ckiee }: utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" @@ -27,6 +28,7 @@ portable-svc.overlay ]; }; + ckieepkgs = import ckiee { inherit system; }; everything = pkgs.buildGoApplication { pname = "xe-x-composite"; @@ -46,6 +48,8 @@ cp $src/bin/$pname $out/bin/$path ''; }; + + python = (ckieepkgs.python310.withPackages(ps: with ps; [ gpt-2-simple ])); in { packages = rec { default = everything; @@ -69,6 +73,9 @@ }; robocadey = copyFile { pname = "robocadey"; }; + robocadey-gpt2 = pkgs.writeShellScriptBin "robocadey-gpt2" '' + ${python}/bin/python3 ${./mastodon/robocadey/gpt2/main.py} + ''; robocadey-psvc = let preflight = pkgs.writeShellApplication { name = "cadeybot-preflight"; @@ -81,11 +88,17 @@ inherit preflight; robocadey = self.packages.${system}.robocadey; }; + gpt2-service = pkgs.substituteAll { + name = "robocadey-gpt2.service"; + src = ./run/robocadey-gpt2.service.in; + inherit python; + main = ./mastodon/robocadey/gpt2/main.py; + }; in pkgs.portableService { inherit (self.packages.${system}.robocadey) version; name = "robocadey"; description = "Robotic twitter shitposting bot"; - units = [ service ]; + units = [ service gpt2-service ./run/robocadey-gpt2.socket ]; symlinks = [{ object = "${pkgs.cacert}/etc/ssl"; symlink = "/etc/ssl"; @@ -100,6 +113,7 @@ gotools go-tools gomod2nix.defaultPackage.${system} + python ]; }; }); diff --git a/mastodon/robocadey/gpt2/main.py b/mastodon/robocadey/gpt2/main.py index aa7b30d..82d4e5e 100755 --- a/mastodon/robocadey/gpt2/main.py +++ b/mastodon/robocadey/gpt2/main.py @@ -39,4 +39,4 @@ while True: connection.close() server.close() -os.remove("/xe/gpt2/checkpoint/server.sock") +os.remove(sockpath) diff --git a/run/robocadey-gpt2.service.in b/run/robocadey-gpt2.service.in new file mode 100644 index 0000000..988119a --- /dev/null +++ b/run/robocadey-gpt2.service.in @@ -0,0 +1,10 @@ +[Unit] +Description=Robo-Cadey GPT2 sidecar + +[Service] +ExecStart=@python@/bin/python3 @main@ +StateDirectory=xeserv.robocadey-gpt2 +CacheDirectory=xeserv.robocadey-gpt2 + +[Install] +WantedBy=multi-user.target diff --git a/run/robocadey-gpt2.socket b/run/robocadey-gpt2.socket new file mode 100644 index 0000000..f720f27 --- /dev/null +++ b/run/robocadey-gpt2.socket @@ -0,0 +1,9 @@ +[Unit] +Description=RoboCadey activation socket +PartOf=robocadey-gpt2.service + +[Socket] +ListenStream=/run/robocadey-gpt2.sock + +[Install] +WantedBy=sockets.target
\ No newline at end of file |
