linux-utils/packages/journalctl-last-invocation/package.nix

30 lines
654 B
Nix
Raw Normal View History

{ pkgs, stdenv }:
2025-03-10 23:54:40 +01:00
with pkgs;
with stdenv;
2025-03-10 23:54:40 +01:00
mkDerivation {
pname = "journalctl-last-invocation";
version = "2026-04-29";
2025-03-10 23:54:40 +01:00
phases = [ "createSourcesPhase" "installPhase" ];
2025-03-10 23:54:40 +01:00
createSourcesPhase = ''
# Same directory structure that `unpackPhase` would use.
mkdir -p /build/source
cat <<- EOF > /build/source/journalctl-last-invocation
2025-03-10 23:54:40 +01:00
#!${bash}/bin/sh
exec ${systemd}/bin/journalctl _SYSTEMD_INVOCATION_ID=\$(${systemd}/bin/systemctl show --value --property=InvocationID \$1)
2025-03-10 23:54:40 +01:00
EOF
'';
installPhase = ''
mkdir -p $out/bin
cp /build/source/journalctl-last-invocation $out/bin/
2025-03-10 23:54:40 +01:00
chmod +x $out/bin/journalctl-last-invocation
'';
2025-03-10 23:54:40 +01:00
}