Compare commits
3 Commits
848ed362be
...
9934b11766
Author | SHA1 | Date |
---|---|---|
Oystein Kristoffer Tveit | 9934b11766 | |
Oystein Kristoffer Tveit | cfb6bbd7a7 | |
Oystein Kristoffer Tveit | b1f8cf9ba2 |
|
@ -4,6 +4,7 @@
|
||||||
, rustPlatform
|
, rustPlatform
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, mpv
|
, mpv
|
||||||
|
, wrapped ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
|
@ -36,7 +37,7 @@ rustPlatform.buildRustPackage rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = lib.optionalString wrapped ''
|
||||||
wrapProgram $out/bin/greg-ng \
|
wrapProgram $out/bin/greg-ng \
|
||||||
--prefix PATH : '${lib.makeBinPath [ mpv ]}'
|
--prefix PATH : '${lib.makeBinPath [ mpv ]}'
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
apps = forAllSystems (system: pkgs: _: {
|
apps = forAllSystems (system: pkgs: _: {
|
||||||
default = self.apps.${system}.greg-ng;
|
default = self.apps.${system}.greg-ng;
|
||||||
greg-ng = let
|
greg-ng = let
|
||||||
package = self.packages.${system}.greg-ng;
|
package = self.packages.${system}.greg-ng-wrapped;
|
||||||
in {
|
in {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = lib.getExe package;
|
program = lib.getExe package;
|
||||||
|
@ -63,6 +63,9 @@
|
||||||
packages = forAllSystems (system: pkgs: _: {
|
packages = forAllSystems (system: pkgs: _: {
|
||||||
default = self.packages.${system}.greg-ng;
|
default = self.packages.${system}.greg-ng;
|
||||||
greg-ng = pkgs.callPackage ./default.nix { };
|
greg-ng = pkgs.callPackage ./default.nix { };
|
||||||
|
greg-ng-wrapped = pkgs.callPackage ./default.nix {
|
||||||
|
wrapped = true;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
} // {
|
} // {
|
||||||
nixosModules.default = ./module.nix;
|
nixosModules.default = ./module.nix;
|
||||||
|
|
|
@ -109,7 +109,8 @@ in
|
||||||
|
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = 3;
|
RestartSec = 3;
|
||||||
WatchdogSec = 15;
|
WatchdogSec = lib.mkDefault 15;
|
||||||
|
TimeoutStartSec = lib.mkDefault 30;
|
||||||
|
|
||||||
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
|
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
|
||||||
AmbientCapabilities = [ "" ];
|
AmbientCapabilities = [ "" ];
|
||||||
|
|
|
@ -89,6 +89,8 @@ async fn setup_systemd_watchdog_thread() -> anyhow::Result<()> {
|
||||||
|
|
||||||
async fn shutdown(mpv: Mpv, proc: Option<tokio::process::Child>) {
|
async fn shutdown(mpv: Mpv, proc: Option<tokio::process::Child>) {
|
||||||
log::info!("Shutting down");
|
log::info!("Shutting down");
|
||||||
|
sd_notify::notify(false, &[sd_notify::NotifyState::Stopping])
|
||||||
|
.unwrap_or_else(|e| log::warn!("Failed to notify systemd that the service is stopping: {}", e));
|
||||||
|
|
||||||
mpv.disconnect()
|
mpv.disconnect()
|
||||||
.await
|
.await
|
||||||
|
@ -167,7 +169,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if systemd_mode {
|
if systemd_mode {
|
||||||
match sd_notify::notify(true, &[sd_notify::NotifyState::Ready])
|
match sd_notify::notify(false, &[sd_notify::NotifyState::Ready])
|
||||||
.context("Failed to notify systemd that the service is ready")
|
.context("Failed to notify systemd that the service is ready")
|
||||||
{
|
{
|
||||||
Ok(_) => log::trace!("Notified systemd that the service is ready"),
|
Ok(_) => log::trace!("Notified systemd that the service is ready"),
|
||||||
|
|
Loading…
Reference in New Issue