Compare commits
No commits in common. "main" and "v0.3.0" have entirely different histories.
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -1,7 +1,5 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler32"
|
name = "adler32"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@ -733,7 +731,7 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "printerfacts"
|
name = "printerfacts"
|
||||||
version = "0.3.2"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"hyper",
|
"hyper",
|
||||||
@ -741,7 +739,7 @@ dependencies = [
|
|||||||
"mime",
|
"mime",
|
||||||
"pfacts",
|
"pfacts",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"rand 0.7.3",
|
"rand 0.8.3",
|
||||||
"ructe",
|
"ructe",
|
||||||
"serde",
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "printerfacts"
|
name = "printerfacts"
|
||||||
version = "0.3.2"
|
version = "0.3.0"
|
||||||
authors = ["Xe Iaso <me@christine.website>"]
|
authors = ["Christine Dodrill <me@christine.website>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
description = "Printer facts: The API"
|
description = "Printer facts: The API"
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
# Portable Service
|
|
||||||
|
|
||||||
To run this service as a [portable
|
|
||||||
service](https://systemd.io/PORTABLE_SERVICES/), you either need to build it
|
|
||||||
from source or fetch a premade image from my server. Then you need to activate
|
|
||||||
the portable service and manage it like any other systemd service.
|
|
||||||
|
|
||||||
## Getting Image
|
|
||||||
|
|
||||||
### Building From Source
|
|
||||||
|
|
||||||
To build from source, install Nix and enable flakes. Then run this command:
|
|
||||||
|
|
||||||
```
|
|
||||||
nix build "git+https://tulpa.dev/cadey/printerfacts.git?ref=main#portable-service"
|
|
||||||
```
|
|
||||||
|
|
||||||
Copy this to somewhere on your target server:
|
|
||||||
|
|
||||||
```
|
|
||||||
scp $(readlink ./result) target:printerfacts_0.3.1.raw
|
|
||||||
```
|
|
||||||
|
|
||||||
### Downloading From My Server
|
|
||||||
|
|
||||||
Visit [my portable services
|
|
||||||
repository](https://xena.greedo.xeserv.us/pkg/portable/) server and download the
|
|
||||||
most recent `printerfacts` `.raw` file. Put it somewhere on the target machine.
|
|
||||||
|
|
||||||
## Installing and Activating
|
|
||||||
|
|
||||||
If you are running Ubuntu 22.04, you will need to install `systemd-portabled`:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt -y install systemd-container
|
|
||||||
```
|
|
||||||
|
|
||||||
This may work on other distros, but I have only tested this on Ubuntu 22.04.
|
|
||||||
|
|
||||||
Then attach the service image:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo portablectl attach ./printerfacts_0.3.1.raw
|
|
||||||
```
|
|
||||||
|
|
||||||
And activate it like any other systemd service:
|
|
||||||
|
|
||||||
```
|
|
||||||
sudo systemctl enable --now printerfacts.service
|
|
||||||
```
|
|
||||||
|
|
||||||
And then fetch a printer fact:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ curl http://[::1]:32042/fact
|
|
||||||
On average, a printer will sleep for 16 hours a day.
|
|
||||||
```
|
|
||||||
|
|
||||||
Or open it in your browser: http://target:32042
|
|
77
flake.lock
generated
77
flake.lock
generated
@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689068808,
|
"lastModified": 1644229661,
|
||||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -23,11 +20,11 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1688534083,
|
"lastModified": 1639947939,
|
||||||
"narHash": "sha256-/bI5vsioXscQTsx+Hk9X5HfweeNZz/6kVKsbdqfwW7g=",
|
"narHash": "sha256-pGsM8haJadVP80GFq4xhnSpNitYNQpaXk4cnA796Cso=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "naersk",
|
"repo": "naersk",
|
||||||
"rev": "abca1fb7a6cfdd355231fc220c3d0302dbb4369a",
|
"rev": "2fc8ce9d3c025d59fee349c1f80be9785049d653",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -38,11 +35,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689631193,
|
"lastModified": 1645866791,
|
||||||
"narHash": "sha256-AGSkBZaiTODQc8eT1rZDrQIjtb8JtFwJ0wVPzArlrnM=",
|
"narHash": "sha256-okyN8nAb0gFfF2rjjJnMiIuOM+nZXxZ9Wc2PyoYYKWo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "57695599bdc4f7bfe5d28cfa23f14b3d8bdf8a5f",
|
"rev": "607178a179d6943cb64970882511c24b2a983c2b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -52,11 +49,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689631193,
|
"lastModified": 1645866791,
|
||||||
"narHash": "sha256-AGSkBZaiTODQc8eT1rZDrQIjtb8JtFwJ0wVPzArlrnM=",
|
"narHash": "sha256-okyN8nAb0gFfF2rjjJnMiIuOM+nZXxZ9Wc2PyoYYKWo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "57695599bdc4f7bfe5d28cfa23f14b3d8bdf8a5f",
|
"rev": "607178a179d6943cb64970882511c24b2a983c2b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -66,11 +63,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1678898370,
|
"lastModified": 1640319671,
|
||||||
"narHash": "sha256-xTICr1j+uat5hk9FyuPOFGxpWHdJRibwZC+ATi0RbtE=",
|
"narHash": "sha256-ZkKmakwaOaLiZOpIZWbeJZwap5CzJ30s4UJTfydYIYc=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ac718d02867a84b42522a0ece52d841188208f2c",
|
"rev": "eac07edbd20ed4908b98790ba299250b5527ecdf",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -80,36 +77,38 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"portable-svc": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1645960986,
|
||||||
|
"narHash": "sha256-XuapDz2dkUAgKaj3L2EUgzXApn6IXGtQVg/TEfhr0w8=",
|
||||||
|
"ref": "main",
|
||||||
|
"rev": "138c25c1c3ee4f7945059e05259d3fe03678e843",
|
||||||
|
"revCount": 5,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://tulpa.dev/cadey/portable-svc.git"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"ref": "main",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://tulpa.dev/cadey/portable-svc.git"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"naersk": "naersk",
|
"naersk": "naersk",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"portable-svc": "portable-svc",
|
||||||
"xess": "xess"
|
"xess": "xess"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1678901627,
|
"lastModified": 1638122382,
|
||||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -124,11 +123,11 @@
|
|||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1682266158,
|
"lastModified": 1640540322,
|
||||||
"narHash": "sha256-VK66KyF1doJ24yktb9rp7Yv7auS6i0P8EnJLhFOz+jY=",
|
"narHash": "sha256-II4raADUWKTLDAALyJSToAgL8FB1ADbRHqEr/b3JeIc=",
|
||||||
"owner": "Xe",
|
"owner": "Xe",
|
||||||
"repo": "Xess",
|
"repo": "Xess",
|
||||||
"rev": "3a85d1de06cd3420b4d56a8edd72cd57e6f0806e",
|
"rev": "5fabc96de6487a721235c4bdf18214519d9e6201",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
31
flake.nix
31
flake.nix
@ -3,14 +3,13 @@
|
|||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
naersk.url = "github:nix-community/naersk";
|
naersk.url = "github:nix-community/naersk";
|
||||||
xess.url = "github:Xe/Xess";
|
xess.url = "github:Xe/Xess";
|
||||||
|
portable-svc.url = "git+https://tulpa.dev/cadey/portable-svc.git?ref=main";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, naersk, xess }:
|
outputs = { self, nixpkgs, flake-utils, naersk, xess, portable-svc }:
|
||||||
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
|
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs { overlays = [ portable-svc.overlay ]; inherit system; };
|
||||||
inherit system;
|
|
||||||
};
|
|
||||||
naersk-lib = naersk.lib."${system}";
|
naersk-lib = naersk.lib."${system}";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
in rec {
|
in rec {
|
||||||
@ -31,32 +30,18 @@
|
|||||||
cp -rf $src/templates $out/templates
|
cp -rf $src/templates $out/templates
|
||||||
cp -rf ${printerfacts-bin}/bin $out/bin
|
cp -rf ${printerfacts-bin}/bin $out/bin
|
||||||
cp -rf ${
|
cp -rf ${
|
||||||
xess.packages."${system}".default
|
xess.defaultPackage."${system}"
|
||||||
}/static/css/xess.css $out/static/gruvbox.css
|
}/static/css/xess.css $out/static/gruvbox.css
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
docker = let
|
|
||||||
printerfacts = self.packages.${system}.printerfacts;
|
|
||||||
name = "xena/printerfacts";
|
|
||||||
tag = printerfacts.version;
|
|
||||||
in pkgs.dockerTools.buildLayeredImage {
|
|
||||||
inherit name tag;
|
|
||||||
contents = [ printerfacts ];
|
|
||||||
|
|
||||||
config = {
|
|
||||||
Cmd = [ "${printerfacts}/bin/printerfacts" ];
|
|
||||||
Env = [ "RUST_LOG=info" "PORT=32042" ];
|
|
||||||
WorkingDir = "/";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
printerfacts-service = pkgs.substituteAll {
|
printerfacts-service = pkgs.substituteAll {
|
||||||
pname = "printerfacts.service";
|
name = "printerfacts.service";
|
||||||
src = ./systemd/printerfacts.service.in;
|
src = ./systemd/printerfacts.service.in;
|
||||||
printerfacts = self.packages.${system}.printerfacts;
|
printerfacts = self.packages.${system}.printerfacts;
|
||||||
};
|
};
|
||||||
portable-service = pkgs.portableService {
|
portable-service = pkgs.portableService {
|
||||||
inherit (self.packages.${system}.printerfacts) version;
|
inherit (self.packages.${system}.printerfacts) version;
|
||||||
pname = "printerfacts";
|
name = "printerfacts";
|
||||||
description = "Printer facts";
|
description = "Printer facts";
|
||||||
units = [ self.packages.${system}.printerfacts-service ];
|
units = [ self.packages.${system}.printerfacts-service ];
|
||||||
};
|
};
|
||||||
@ -69,12 +54,12 @@
|
|||||||
defaultApp = apps.printerfacts;
|
defaultApp = apps.printerfacts;
|
||||||
|
|
||||||
# `nix develop`
|
# `nix develop`
|
||||||
devShells.default = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
rustc
|
rustc
|
||||||
cargo
|
cargo
|
||||||
cargo-watch
|
cargo-watch
|
||||||
rust-analyzer
|
rls
|
||||||
rustfmt
|
rustfmt
|
||||||
];
|
];
|
||||||
|
|
||||||
|
5
scripts/release.sh
Executable file
5
scripts/release.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#! nix-shell -p doctl -p kubectl -i bash
|
||||||
|
doctl kubernetes cluster kubeconfig save kubermemes
|
||||||
|
dhall-to-yaml-ng < ./printerfacts.dhall | kubectl apply -n apps -f -
|
||||||
|
kubectl rollout status -n apps deployment/printerfacts
|
13
shell.nix
Normal file
13
shell.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
let
|
||||||
|
pkgs = import <nixpkgs> { };
|
||||||
|
in pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
rustc
|
||||||
|
cargo
|
||||||
|
cargo-watch
|
||||||
|
rls
|
||||||
|
rustfmt
|
||||||
|
];
|
||||||
|
|
||||||
|
RUST_LOG = "info";
|
||||||
|
}
|
@ -4,8 +4,6 @@ Description=The Printerfacts service
|
|||||||
[Service]
|
[Service]
|
||||||
DynamicUser=yes
|
DynamicUser=yes
|
||||||
Environment=PORT=32042
|
Environment=PORT=32042
|
||||||
Environment=RUST_LOG=info
|
|
||||||
WorkingDirectory=@printerfacts@
|
|
||||||
ExecStart=@printerfacts@/bin/printerfacts
|
ExecStart=@printerfacts@/bin/printerfacts
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user