repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
wrap.shShell24 lines803 Braw download
#!/usr/bin/env bash
# scripts/wrap.sh FILE ATTR — turn a plain NixOS / home-manager module file
# into a flake-parts module that exports it under ATTR, in place:
#
#   # leading comment block, kept as is
#   { ... }:
#   {
#     ATTR =
#       <the original module, indented by two spaces>;
#   }
#
# The split is at the first line that is neither a `#` comment nor blank, so
# the file's header comment stays at the top where editors and readers expect it.
set -euo pipefail
file=$1
attr=$2
tmp=$(mktemp)
awk -v attr="$attr" '
  !body && ($0 ~ /^#/ || $0 ~ /^[[:space:]]*$/) { print; next }
  !body { body = 1; print "{ ... }:"; print "{"; print "  " attr " =" }
  body { if ($0 ~ /^[[:space:]]*$/) print ""; else print "  " $0 }
  END { print "  ;"; print "}" }
' "$file" > "$tmp"
mv "$tmp" "$file"