Files
Hilton Chain 9afc4e56da rosenthal: Reorganize scripts.
* README.org (Content): Move to...
* etc/docs/index.org: ...this new file.
* pre-inst-env: Prepend etc/scripts to PATH.
* etc/scripts/index.scm: Rename to...
* etc/scripts/index: ...this.
* etc/committer.scm: Rename to...
* etc/scripts/committer: ...this.
2026-10-18 15:59:34 +08:00

62 lines
2.1 KiB
Scheme

#!/bin/sh
# -*- mode: scheme; -*-
exec guix repl -- "$0" "$@"
!#
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2025-2026 Hilton Chain <hako@ultrarare.space>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;;
;;; Usage: cleanup-crates.scm [FILE] ...
;;;
(use-modules (ice-9 match)
(ice-9 regex)
(srfi srfi-26)
(system base compile)
(guix ui)
(guix utils)
(guix scripts shell))
(define (cleanup-crates file)
(define %unused
(let ((warnings (open-output-string)))
(parameterize ((current-warning-port warnings))
(compile-file file
#:optimization-level 0
#:warning-level 0
#:opts '(#:warnings (unused-toplevel))))
(map (cut match:substring <> 1)
(list-matches "`(rust-[^']*)'" (get-output-string warnings)))))
(info (G_ "removing ~a unused definitions~%") (length %unused))
(for-each (lambda (name)
(info (G_ "removing '~a'...~%") name)
(and=> (find-definition-location file (string->symbol name) #:define-prefix 'define)
delete-expression))
%unused)
(info (G_ "collapsing newlines~%"))
(guix-shell "sed" "--" "sed" "--in-place" ":a;N;$!ba;s/\\n\\n\\+/\\n\\n/g" file))
(match (program-arguments)
((_ files ..1)
(for-each cleanup-crates files))
(_
(cleanup-crates "modules/rosenthal/packages/rust-crates.scm")))