add .nix files

This commit is contained in:
theBreadCompany 2024-09-06 05:09:06 +02:00
parent 92b75a2f46
commit d23db7e336
4 changed files with 2734 additions and 1 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
/target
Cargo.lock
result

2668
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

24
default.nix Normal file
View file

@ -0,0 +1,24 @@
{ pkgs ? import <nixpkgs> { system = builtins.currentSystem; }
, lib ? pkgs.lib, rustPlatform ? pkgs.rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "pxiv";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
cargoSha256 = lib.fakeSha256; # Replace with the actual hash
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = [ pkgs.openssl ];
meta = with lib; {
description = "a pixiv embed helper";
license = licenses.mit;
maintainers = [ ];
};
}

41
pxiv.service.nix Normal file
View file

@ -0,0 +1,41 @@
# rocket-service.nix
{ config, pkgs, ... }:
let
# Import the Rocket application package
pxivApp = import ./default.nix { inherit pkgs; };
in
{
options.services.rocket = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable the Rocket application service.";
};
port = mkOption {
type = types.int;
default = 8000;
description = "Port on which the Rocket application listens.";
};
};
config = mkIf config.services.rocket.enable {
systemd.services.pxiv = {
description = "pxiv embed helper service";
wantedBy = [ "multi-user.target" ];
# Command to start the Rocket application
serviceConfig.ExecStart = "${pxivApp}/bin/pxiv";
# Set the port environment variable
serviceConfig.Environment = [ "ROCKET_PORT=${toString config.services.rocket.port}" ];
# Restart on failure
serviceConfig.Restart = "always";
# Ensure the service starts after the network is up
after = [ "network.target" ];
};
};
}