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
4
packages/journalctl-last-invocation/journalctl-last-invocation
Executable file
4
packages/journalctl-last-invocation/journalctl-last-invocation
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/zsh --errexit
|
||||||
|
|
||||||
|
|
||||||
|
exec journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID "$1")"
|
||||||
|
|
@ -1,30 +1,32 @@
|
||||||
{ pkgs, stdenvNoCC }:
|
{
|
||||||
|
# Build tools.
|
||||||
|
installShellFiles, stdenvNoCC,
|
||||||
|
|
||||||
|
# Packages.
|
||||||
|
systemd, zsh,
|
||||||
|
}:
|
||||||
|
|
||||||
with pkgs;
|
|
||||||
with stdenvNoCC;
|
with stdenvNoCC;
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "journalctl-last-invocation";
|
name = "journalctl-last-invocation";
|
||||||
version = "2026-04-29";
|
|
||||||
|
|
||||||
phases = [ "createSourcesPhase" "installPhase" ];
|
src = ./.;
|
||||||
|
|
||||||
createSourcesPhase = ''
|
nativeBuildInputs = [ installShellFiles ];
|
||||||
# Same directory structure that `unpackPhase` would use.
|
buildInputs = [ zsh ];
|
||||||
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
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
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
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
packages/nix-store-fuzzy-find/nix-store-fuzzy-find
Executable file
4
packages/nix-store-fuzzy-find/nix-store-fuzzy-find
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/zsh --errexit
|
||||||
|
|
||||||
|
|
||||||
|
exec find /nix/store -maxdepth 1 -type d -name "*-$1-*"
|
||||||
|
|
@ -1,30 +1,31 @@
|
||||||
{ pkgs, stdenvNoCC }:
|
{
|
||||||
|
# Build tools.
|
||||||
|
installShellFiles, stdenvNoCC,
|
||||||
|
|
||||||
|
# Packages.
|
||||||
|
findutils, zsh,
|
||||||
|
}:
|
||||||
|
|
||||||
with pkgs;
|
|
||||||
with stdenvNoCC;
|
with stdenvNoCC;
|
||||||
|
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "nix-store-fuzzy-find";
|
name = "nix-store-fuzzy-find";
|
||||||
version = "2026-04-29";
|
|
||||||
|
|
||||||
phases = [ "createSourcesPhase" "installPhase" ];
|
src = ./.;
|
||||||
|
|
||||||
createSourcesPhase = ''
|
nativeBuildInputs = [ installShellFiles ];
|
||||||
# Same directory structure that `unpackPhase` would use.
|
buildInputs = [ zsh ];
|
||||||
mkdir -p /build/source
|
|
||||||
|
|
||||||
cat <<- EOF > /build/source/nix-store-fuzzy-find
|
|
||||||
#!${bash}/bin/sh
|
|
||||||
|
|
||||||
exec ${findutils}/bin/find /nix/store -maxdepth 1 -type d -name "*-\$1-*"
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
runHook preInstall
|
||||||
|
|
||||||
cp /build/source/nix-store-fuzzy-find $out/bin/
|
installBin nix-store-fuzzy-find
|
||||||
|
|
||||||
chmod +x $out/bin/nix-store-fuzzy-find
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
preFixup = ''
|
||||||
|
substituteInPlace $out/bin/nix-store-fuzzy-find \
|
||||||
|
--replace-fail find ${findutils}/bin/find
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue