Skip to content

Commit ce0ef3d

Browse files
Add kup gc command (#99)
Co-authored-by: Bruce Collie <brucecollie82@gmail.com>
1 parent f5ae40b commit ce0ef3d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/kup/__main__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,10 @@ def main() -> None:
900900
publish.add_argument('uri', type=str)
901901
publish.add_argument('--keep-days', type=int, help='keep package cached for N days')
902902

903+
subparser.add_parser(
904+
'gc', help='Call Nix garbage collector to remove previously uninstalled packages', add_help=False
905+
)
906+
903907
args = parser.parse_args()
904908

905909
if args.command is None:
@@ -919,6 +923,14 @@ def main() -> None:
919923
ask_install_substituters('k-framework', [K_FRAMEWORK_CACHE], [K_FRAMEWORK_PUBLIC_KEY])
920924
elif args.command == 'publish':
921925
publish_package(args.cache, args.uri, args.keep_days)
926+
elif args.command == 'gc':
927+
try:
928+
subprocess.check_output(
929+
['nix-collect-garbage', '-d'],
930+
)
931+
except subprocess.CalledProcessError as exc:
932+
print(exc)
933+
sys.exit(exc.returncode)
922934
else:
923935
package_name = PackageName.parse(args.package)
924936

0 commit comments

Comments
 (0)