Browse Source

create portable service image

Signed-off-by: Xe <[email protected]>
main v0.3.0
Cadey Ratio 3 months ago
parent
commit
e73b5e43bf
  1. 35
      flake.lock
  2. 18
      flake.nix
  3. 13
      shell.nix
  4. 10
      systemd/printerfacts.service.in

35
flake.lock

@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
},
"original": {
@ -35,11 +35,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1640418986,
"narHash": "sha256-a8GGtxn2iL3WAkY5H+4E0s3Q7XJt6bTOvos9qqxT5OQ=",
"lastModified": 1645866791,
"narHash": "sha256-okyN8nAb0gFfF2rjjJnMiIuOM+nZXxZ9Wc2PyoYYKWo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5c37ad87222cfc1ec36d6cd1364514a9efc2f7f2",
"rev": "607178a179d6943cb64970882511c24b2a983c2b",
"type": "github"
},
"original": {
@ -49,11 +49,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1640418986,
"narHash": "sha256-a8GGtxn2iL3WAkY5H+4E0s3Q7XJt6bTOvos9qqxT5OQ=",
"lastModified": 1645866791,
"narHash": "sha256-okyN8nAb0gFfF2rjjJnMiIuOM+nZXxZ9Wc2PyoYYKWo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5c37ad87222cfc1ec36d6cd1364514a9efc2f7f2",
"rev": "607178a179d6943cb64970882511c24b2a983c2b",
"type": "github"
},
"original": {
@ -77,11 +77,28 @@
"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": {
"inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"portable-svc": "portable-svc",
"xess": "xess"
}
},

18
flake.nix

@ -3,12 +3,13 @@
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
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:
let
pkgs = nixpkgs.legacyPackages."${system}";
pkgs = import nixpkgs { overlays = [ portable-svc.overlay ]; inherit system; };
naersk-lib = naersk.lib."${system}";
src = ./.;
in rec {
@ -19,7 +20,7 @@
root = ./.;
};
printerfacts = pkgs.stdenv.mkDerivation {
inherit (printerfacts-bin) name;
inherit (printerfacts-bin) pname version;
inherit src;
phases = "installPhase";
@ -33,6 +34,17 @@
}/static/css/xess.css $out/static/gruvbox.css
'';
};
printerfacts-service = pkgs.substituteAll {
name = "printerfacts.service";
src = ./systemd/printerfacts.service.in;
printerfacts = self.packages.${system}.printerfacts;
};
portable-service = pkgs.portableService {
inherit (self.packages.${system}.printerfacts) version;
name = "printerfacts";
description = "Printer facts";
units = [ self.packages.${system}.printerfacts-service ];
};
};
defaultPackage = packages.printerfacts;

13
shell.nix

@ -0,0 +1,13 @@
let
pkgs = import <nixpkgs> { };
in pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo
cargo-watch
rls
rustfmt
];
RUST_LOG = "info";
}

10
systemd/printerfacts.service.in

@ -0,0 +1,10 @@
[Unit]
Description=The Printerfacts service
[Service]
DynamicUser=yes
Environment=PORT=32042
ExecStart=@[email protected]/bin/printerfacts
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save