create portable service image

Signed-off-by: Xe <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-02-27 11:50:55 +00:00
parent 5436c081ae
commit e73b5e43bf
4 changed files with 64 additions and 12 deletions

View File

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

View File

@ -3,12 +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 = nixpkgs.legacyPackages."${system}"; pkgs = import nixpkgs { overlays = [ portable-svc.overlay ]; inherit system; };
naersk-lib = naersk.lib."${system}"; naersk-lib = naersk.lib."${system}";
src = ./.; src = ./.;
in rec { in rec {
@ -19,7 +20,7 @@
root = ./.; root = ./.;
}; };
printerfacts = pkgs.stdenv.mkDerivation { printerfacts = pkgs.stdenv.mkDerivation {
inherit (printerfacts-bin) name; inherit (printerfacts-bin) pname version;
inherit src; inherit src;
phases = "installPhase"; phases = "installPhase";
@ -33,6 +34,17 @@
}/static/css/xess.css $out/static/gruvbox.css }/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; defaultPackage = packages.printerfacts;

13
shell.nix Normal file
View File

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

View File

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