add nix store receipt printer

This commit is contained in:
Infinidoge 2024-12-07 11:27:41 -05:00
parent ea894f9172
commit 5c13522445
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A

51
nix-store-receipt.py Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env python3
from printer import p
import subprocess
import sys
def get_closure(installables):
closure = subprocess.run(
["nix", "path-info", "--recursive"] + installables,
encoding="utf8",
stdout=subprocess.PIPE,
)
return closure.stdout.replace("/nix/store/", "").split("\n")
installables = sys.argv[1:]
with p:
with p.set(
align="center",
bold=True,
invert=True,
smooth=True,
custom_size=True,
width=4,
height=4,
):
p.textln(" Nix Store ")
p.ln()
with p.set(align="center", double_height=True, double_width=True):
p.textln("Everyone's favorite")
p.textln("package store")
p.ln()
p.textln("You were looking for:")
for item in installables:
p.textln(f"- {item}")
p.ln()
p.textln("Your closure today:")
with p.set(
align="left",
font=1,
):
for line in get_closure(installables):
p.textln(line)