Skip to content

Commit 4a50de2

Browse files
committed
cdrip tools and versions bump
1 parent 48c4485 commit 4a50de2

8 files changed

Lines changed: 315 additions & 24 deletions

File tree

flake.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

home/abcde.nix

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{pkgs, ...}: {
2+
# CD ripping toolchain: abcde + encoders + helpers.
3+
# Album art via glyrc, MusicBrainz tagging via cd-discid + libdiscid.
4+
home.packages = with pkgs; [
5+
abcde
6+
cdparanoia-iii
7+
flac
8+
lame
9+
vorbis-tools
10+
id3v2 # MP3 tagger (replaces flaky eyeD3)
11+
eject
12+
glyr # cover art fetcher used by the post-encode hook below
13+
];
14+
15+
home.file.".abcde.conf".text = ''
16+
# ~/.abcde.conf — declarative config managed by home-manager
17+
18+
# --- Drive ---
19+
CDROM=/dev/sr0
20+
CDROMREADERSYNTAX=cdparanoia
21+
CDPARANOIA=cdparanoia
22+
CDPARANOIAOPTS="--never-skip=40"
23+
24+
# --- Metadata ---
25+
CDDBMETHOD=musicbrainz
26+
MUSICBRAINZSERVER=musicbrainz.org
27+
28+
# --- Encoding ---
29+
# Default to FLAC. Override per-run with: abcde -o flac,mp3
30+
OUTPUTTYPE=flac
31+
FLACENCODERSYNTAX=flac
32+
FLAC=flac
33+
FLACOPTS="--best --verify"
34+
35+
LAMEENCODERSYNTAX=lame
36+
LAME=lame
37+
LAMEOPTS="-V 0 --vbr-new --add-id3v2"
38+
39+
# eyeD3 fails on genre code 255 (unknown). Use id3v2 instead.
40+
MP3TAGGER=id3v2
41+
ID3V2=id3v2
42+
43+
# --- Output layout: ~/Music/Artist/Album/01 - Track.flac ---
44+
OUTPUTDIR="$HOME/Music"
45+
# Escape $ so bash leaves vars alone at source time; abcde substitutes later.
46+
OUTPUTFORMAT="\''${ARTISTFILE}/\''${ALBUMFILE}/\''${TRACKNUM} - \''${TRACKFILE}"
47+
VAOUTPUTFORMAT="Various/\''${ALBUMFILE}/\''${TRACKNUM} - \''${ARTISTFILE} - \''${TRACKFILE}"
48+
ONETRACKOUTPUTFORMAT="\''${ARTISTFILE}/\''${ALBUMFILE}/\''${ALBUMFILE}"
49+
VAONETRACKOUTPUTFORMAT="Various/\''${ALBUMFILE}/\''${ALBUMFILE}"
50+
PADTRACKS=y
51+
MAXPROCS=4
52+
53+
# Spaces are friendlier than underscores for browsing.
54+
mungefilename ()
55+
{
56+
echo "$@" | sed 's/[\\\/\:\*\?\"\<\>\|]/-/g'
57+
}
58+
59+
# --- Behavior ---
60+
EJECTCD=y
61+
KEEPWAVS=n
62+
BATCHNORM=n
63+
NOGAP=n
64+
PLAYLISTFORMAT="\''${ARTISTFILE}/\''${ALBUMFILE}/\''${ALBUMFILE}.m3u"
65+
66+
# --- Album art via glyrc ---
67+
POST_ENCODE=do_getalbumart
68+
do_getalbumart ()
69+
{
70+
cover_dir="$OUTPUTDIR/$(mungefilename "$TRACKARTIST")/$(mungefilename "$DALBUM")"
71+
mkdir -p "$cover_dir"
72+
${pkgs.glyr}/bin/glyrc cover \
73+
--artist "$TRACKARTIST" \
74+
--album "$DALBUM" \
75+
--write "$cover_dir/cover.jpg" \
76+
--from 'all' >/dev/null 2>&1 || true
77+
}
78+
'';
79+
}

home/desktop.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ in {
1111
./wezterm.nix
1212
./cava.nix
1313
./cmus.nix
14+
./abcde.nix
1415
./qt.nix
1516
./chrome.nix
1617
./helix.nix

home/distrobox.nix

Lines changed: 166 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,142 @@
4141
mkdir -p "$(dirname "$SUDO_BIN")"
4242
cat > "$SUDO_BIN" <<'WRAPPER'
4343
#!/bin/sh
44-
exec distrobox-host-exec podman exec -it -u root "$CONTAINER_ID" "$@"
44+
# Use whichever container runtime distrobox picked (podman or docker).
45+
RUNTIME="''${DBX_CONTAINER_MANAGER:-}"
46+
if [ -z "$RUNTIME" ]; then
47+
if command -v podman >/dev/null 2>&1; then
48+
RUNTIME=podman
49+
elif command -v docker >/dev/null 2>&1; then
50+
RUNTIME=docker
51+
else
52+
echo "sudo-fix: no podman or docker on host" >&2
53+
exit 1
54+
fi
55+
fi
56+
exec distrobox-host-exec "$RUNTIME" exec -it -u root "$CONTAINER_ID" "$@"
4557
WRAPPER
4658
chmod +x "$SUDO_BIN"
4759
'';
4860

61+
# ONE-TIME bootstrap for the rhel10 container.
62+
# Why this exists: distrobox-init runs `dnf install` for base shell tools
63+
# immediately after creation. The rhel10 INI mounts the (empty) host
64+
# subscription dirs over /etc/rhsm and /etc/pki/entitlement, which shadows
65+
# UBI's bundled certs. With no certs, DNF falls onto subscribed RHEL repos
66+
# and fails — a chicken-and-egg the assemble flow can't break.
67+
#
68+
# The fix: register in a plain podman container (no volume shadowing),
69+
# copy the resulting certs into the host volume dirs, then let distrobox
70+
# assemble re-create rhel10 normally — now with populated volumes.
71+
#
72+
# Run once via `db-rhel-bootstrap`. After it succeeds, `db-up`/`db-rm`
73+
# cycles preserve the registration via the host volumes, and `db-rhel-init`
74+
# handles routine refresh + base package install.
75+
"distrobox/rhel10-bootstrap.sh".text = ''
76+
#!/bin/sh
77+
set -e
78+
79+
HOST_DIR="$HOME/.local/share/distrobox/rhel10"
80+
IMAGE="registry.access.redhat.com/ubi10/ubi:latest"
81+
TMP_NAME="rhel10-bootstrap"
82+
83+
# Detect whichever container runtime distrobox is using (docker on this
84+
# host today, podman on systems with virtualisation.podman.enable).
85+
RUNTIME="''${DBX_CONTAINER_MANAGER:-}"
86+
if [ -z "$RUNTIME" ]; then
87+
if command -v podman >/dev/null 2>&1; then
88+
RUNTIME=podman
89+
elif command -v docker >/dev/null 2>&1; then
90+
RUNTIME=docker
91+
else
92+
echo "!! No podman or docker on host." >&2
93+
exit 1
94+
fi
95+
fi
96+
echo ">> Using container runtime: $RUNTIME"
97+
98+
echo ">> 1/6 Pulling $IMAGE"
99+
"$RUNTIME" pull "$IMAGE"
100+
101+
echo ">> 2/6 Tearing down any previous bootstrap container"
102+
"$RUNTIME" rm -f "$TMP_NAME" >/dev/null 2>&1 || true
103+
104+
echo ">> 3/6 Starting temporary bootstrap container (no volume shadowing)"
105+
"$RUNTIME" run -d --name "$TMP_NAME" "$IMAGE" sleep infinity >/dev/null
106+
107+
echo ">> 4/6 Registering with Red Hat (interactive)"
108+
"$RUNTIME" exec -it "$TMP_NAME" subscription-manager register
109+
# RHEL 9.x+ defaults to Simple Content Access (SCA), which dropped
110+
# `subscription-manager attach`. Registration alone grants entitlements.
111+
# On older orgs that still require classic attach, opt-in with
112+
# ATTACH=1 db-rhel-bootstrap.
113+
if [ "''${ATTACH:-0}" = "1" ]; then
114+
"$RUNTIME" exec -it "$TMP_NAME" subscription-manager attach --auto
115+
fi
116+
"$RUNTIME" exec -it "$TMP_NAME" subscription-manager refresh
117+
118+
echo ">> 5/6 Copying entitlement state to $HOST_DIR"
119+
mkdir -p "$HOST_DIR"/rhsm "$HOST_DIR"/pki-entitlement "$HOST_DIR"/pki-consumer "$HOST_DIR"/var-lib-rhsm
120+
"$RUNTIME" cp "$TMP_NAME":/etc/rhsm/. "$HOST_DIR/rhsm/"
121+
"$RUNTIME" cp "$TMP_NAME":/etc/pki/entitlement/. "$HOST_DIR/pki-entitlement/"
122+
"$RUNTIME" cp "$TMP_NAME":/etc/pki/consumer/. "$HOST_DIR/pki-consumer/"
123+
"$RUNTIME" cp "$TMP_NAME":/var/lib/rhsm/. "$HOST_DIR/var-lib-rhsm/"
124+
"$RUNTIME" rm -f "$TMP_NAME" >/dev/null
125+
126+
echo ">> 6/6 Re-creating rhel10 via distrobox assemble (volumes populated)"
127+
distrobox stop rhel10 -Y >/dev/null 2>&1 || true
128+
distrobox rm rhel10 -Y >/dev/null 2>&1 || true
129+
distrobox assemble create --file "$HOME/.config/distrobox/distrobox.ini" --name rhel10
130+
131+
echo ""
132+
echo ">> Bootstrap complete. Use 'db-rhel' to enter, or 'db-rhel-init' to install base packages."
133+
'';
134+
135+
# Routine post-bootstrap setup for the rhel10 container.
136+
# Run via `db-rhel-init` after `db-rhel-bootstrap` has populated the host
137+
# volumes. Idempotent: refreshes the entitlement and installs base packages.
138+
"distrobox/rhel10-register.sh".text = ''
139+
#!/bin/sh
140+
set -e
141+
142+
# Verify subscription is active (volumes carry it across rebuilds).
143+
if ! sudo subscription-manager status >/dev/null 2>&1; then
144+
echo "!! Not registered. Run 'db-rhel-bootstrap' first." >&2
145+
exit 1
146+
fi
147+
148+
sudo subscription-manager refresh
149+
sudo dnf -y clean all
150+
sudo dnf -y makecache
151+
sudo dnf install -y git vim htop
152+
'';
153+
154+
# Enable EPEL inside the rhel10 container.
155+
# Runs from init_hooks on every db-up. Idempotent: skips work that's
156+
# already done. Requires CodeReady Builder repo for EPEL build-time deps.
157+
"distrobox/rhel10-epel.sh".text = ''
158+
#!/bin/sh
159+
set -e
160+
161+
# CodeReady Builder ships EPEL's build-time deps. Enable both the full
162+
# RHEL and UBI variants — whichever the active subscription exposes
163+
# will succeed; the other returns non-fatal "repo not found".
164+
for REPO in \
165+
codeready-builder-for-rhel-10-x86_64-rpms \
166+
codeready-builder-for-ubi-10-x86_64-rpms; do
167+
sudo subscription-manager repos --enable "$REPO" 2>&1 \
168+
| grep -v "matches no repositories" || true
169+
done
170+
171+
if rpm -q epel-release >/dev/null 2>&1; then
172+
echo ">> epel-release already installed"
173+
else
174+
echo ">> installing epel-release"
175+
sudo dnf install -y \
176+
https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm
177+
fi
178+
'';
179+
49180
"distrobox/nvidia-setup.sh".text = ''
50181
#!/bin/sh
51182
# 1. Enable 32-bit architecture and multiverse repos
@@ -95,27 +226,51 @@
95226
init_hooks="sh /home/${userConfig.username}/.config/distrobox/sudo-fix.sh"
96227
shell=/bin/bash
97228
229+
# === Alpine OpenRC Sandbox ===
230+
# For testing OpenRC service management (rc-service, rc-update, openrc-run scripts).
231+
# NVIDIA disabled: musl libc binaries don't pair with glibc host driver.
232+
# OpenRC won't run as PID 1 in distrobox — start it manually with `openrc default`.
233+
[alpy]
234+
image=alpine:latest
235+
pull=true
236+
additional_packages="openrc openrc-init bash shadow util-linux git vim curl wget fastfetch eudev"
237+
init=false
238+
nvidia=false
239+
shell=/bin/bash
240+
init_hooks="sh /home/${userConfig.username}/.config/distrobox/sudo-fix.sh"
241+
242+
# === RHEL 10 (UBI image + real Red Hat subscription) ===
243+
# Persists subscription state across db-rm/db-up via host volume mounts.
244+
# First-time bootstrap (volumes empty) MUST run `db-rhel-init` before
245+
# `db-rhel`: the helper registers with subscription-manager and installs
246+
# base packages. After that, certs live in the host volumes and every
247+
# subsequent rebuild picks them back up.
248+
# additional_packages is intentionally empty: dnf needs a working repo,
249+
# which needs subscription certs, which only exist after first register.
98250
[rhel10]
99251
image=registry.access.redhat.com/ubi10/ubi:latest
100252
pull=true
101-
additional_packages="subscription-manager git vim"
102253
init=false
103254
nvidia=true
104255
shell=/bin/bash
105256
volume="/home/${userConfig.username}/.local/share/distrobox/rhel10/rhsm:/etc/rhsm /home/${userConfig.username}/.local/share/distrobox/rhel10/pki-entitlement:/etc/pki/entitlement /home/${userConfig.username}/.local/share/distrobox/rhel10/pki-consumer:/etc/pki/consumer /home/${userConfig.username}/.local/share/distrobox/rhel10/var-lib-rhsm:/var/lib/rhsm"
106-
init_hooks="sh /home/${userConfig.username}/.config/distrobox/sudo-fix.sh && if [ ! -f /etc/rhsm/ca/redhat-uep.pem ]; then dnf reinstall -y subscription-manager-rhsm-certificates subscription-manager; fi"
257+
init_hooks="sh /home/${userConfig.username}/.config/distrobox/sudo-fix.sh && sh /home/${userConfig.username}/.config/distrobox/rhel10-epel.sh"
107258
'';
108259
};
109260

110261
# Ensure host directories exist for shared Distrobox state.
262+
# The rhel10/* dirs hold subscription state populated by db-rhel-bootstrap.
263+
# Ownership left unset (`-`) so systemd-tmpfiles won't re-chown live certs:
264+
# after bootstrap the dirs are owned by Chief; the rhel10 distrobox runs
265+
# rootful via docker (no userns remap), so root inside the container can
266+
# still read them.
111267
systemd.user.tmpfiles.rules = [
112268
"d %h/.local/share/distrobox/bin 0755 - - - -"
113269

114-
# Persistent RHEL subscription volumes use UID/GID 100000, which maps to the container's root user.
115-
"d %h/.local/share/distrobox/rhel10/rhsm 0755 100000 100000 - -"
116-
"d %h/.local/share/distrobox/rhel10/pki-entitlement 0755 100000 100000 - -"
117-
"d %h/.local/share/distrobox/rhel10/pki-consumer 0755 100000 100000 - -"
118-
"d %h/.local/share/distrobox/rhel10/var-lib-rhsm 0750 100000 100000 - -"
270+
"d %h/.local/share/distrobox/rhel10/rhsm 0755 - - - -"
271+
"d %h/.local/share/distrobox/rhel10/pki-entitlement 0755 - - - -"
272+
"d %h/.local/share/distrobox/rhel10/pki-consumer 0755 - - - -"
273+
"d %h/.local/share/distrobox/rhel10/var-lib-rhsm 0750 - - - -"
119274
];
120275

121276
# Alias to easily create/update these containers
@@ -126,5 +281,8 @@
126281
db-ubu = "distrobox enter ubu";
127282
db-debian = "distrobox enter debi";
128283
db-rhel = "distrobox enter rhel10";
284+
db-rhel-bootstrap = "bash /home/${userConfig.username}/.config/distrobox/rhel10-bootstrap.sh";
285+
db-rhel-init = "distrobox enter rhel10 -- bash /home/${userConfig.username}/.config/distrobox/rhel10-register.sh";
286+
db-alpine = "distrobox enter alpy";
129287
};
130288
}

home/shell/programs.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
settings = {
77
command_timeout = 500;
88
add_newline = false;
9-
format = "$directory$hostname$git_branch$git_status$container$character";
9+
# The default $container module reports "Docker" generically because
10+
# /.dockerenv is empty. Distrobox exports $CONTAINER_ID with the real
11+
# box name (rhel10, ubu, alpy, ...) — surface it via env_var instead.
12+
format = "$directory$hostname$git_branch$git_status$env_var$character";
1013
character = {
1114
success_symbol = "[](bold green) ";
1215
error_symbol = "[](bold red) ";
@@ -21,6 +24,11 @@
2124
"ninja" = "󰟀 ninja";
2225
};
2326
};
27+
container.disabled = true;
28+
env_var.CONTAINER_ID = {
29+
format = "[⬢ \\[$env_value\\]]($style) ";
30+
style = "bold yellow";
31+
};
2432
};
2533
};
2634

0 commit comments

Comments
 (0)