Make pkg expressions more idiomatic, store scripts in separate files
This commit is contained in:
parent
6d0534b319
commit
a2f66ba293
4 changed files with 47 additions and 36 deletions
|
|
@ -1,30 +1,32 @@
|
|||
{ pkgs, stdenvNoCC }:
|
||||
{
|
||||
# Build tools.
|
||||
installShellFiles, stdenvNoCC,
|
||||
|
||||
# Packages.
|
||||
systemd, zsh,
|
||||
}:
|
||||
|
||||
with pkgs;
|
||||
with stdenvNoCC;
|
||||
|
||||
mkDerivation {
|
||||
pname = "journalctl-last-invocation";
|
||||
version = "2026-04-29";
|
||||
name = "journalctl-last-invocation";
|
||||
|
||||
phases = [ "createSourcesPhase" "installPhase" ];
|
||||
src = ./.;
|
||||
|
||||
createSourcesPhase = ''
|
||||
# Same directory structure that `unpackPhase` would use.
|
||||
mkdir -p /build/source
|
||||
|
||||
cat <<- EOF > /build/source/journalctl-last-invocation
|
||||
#!${bash}/bin/sh
|
||||
|
||||
exec ${systemd}/bin/journalctl _SYSTEMD_INVOCATION_ID=\$(${systemd}/bin/systemctl show --value --property=InvocationID \$1)
|
||||
EOF
|
||||
'';
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
buildInputs = [ zsh ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
runHook preInstall
|
||||
|
||||
cp /build/source/journalctl-last-invocation $out/bin/
|
||||
installBin journalctl-last-invocation
|
||||
|
||||
chmod +x $out/bin/journalctl-last-invocation
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
substituteInPlace $out/bin/journalctl-last-invocation \
|
||||
--replace-fail journalctl ${systemd}/bin/journalctl \
|
||||
--replace-fail systemctl ${systemd}/bin/systemctl
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue