From 7b28e2d1ad9aef608362fe80504b1426eb259aa3 Mon Sep 17 00:00:00 2001 From: Christopher James Hayward Date: Fri, 24 Nov 2023 17:55:36 -0500 Subject: [PATCH] Add docker-nuke command --- README.org | 16 +++++++++++++++- modules/docker.nix | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 5ae0266..9f2c6f6 100644 --- a/README.org +++ b/README.org @@ -302,7 +302,8 @@ mkShell { flutter ]; shellHook = '' - FLUTTER_SDK_DIR=${flutter}/bin/cache/dart-sdk/ + export FLUTTER_SDK_DIR=${flutter}/bin/cache/dart-sdk/ + export PATH="$HOME/.pub-cache/bin":"$PATH" ''; } #+END_SRC @@ -939,6 +940,17 @@ in { with lib; with lib.types; let cfg = config.modules.docker; + + myDockerNuke = pkgs.writeShellScriptBin "docker-nuke" '' + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) + + docker network prune -f + docker rmi -f $(docker images --filter dangling=true -qa) + docker volume rm $(docker volume ls --filter dangling=true -q) + docker rmi -f $(docker images -qa) + ''; + in { options.modules.docker = { enable = mkOption { @@ -960,6 +972,7 @@ in { # Add docker extensions. environment.systemPackages = [ + myDockerNuke pkgs.docker-compose pkgs.docker-machine ]; @@ -984,6 +997,7 @@ with lib; with lib.types; let cfg = config.modules.firefox; + myFirefox = pkgs.writeShellScriptBin "firefox" '' HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox ''; diff --git a/modules/docker.nix b/modules/docker.nix index 1df6719..cc3189b 100644 --- a/modules/docker.nix +++ b/modules/docker.nix @@ -4,6 +4,17 @@ with lib; with lib.types; let cfg = config.modules.docker; + + myDockerNuke = pkgs.writeShellScriptBin "docker-nuke" '' + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) + + docker network prune -f + docker rmi -f $(docker images --filter dangling=true -qa) + docker volume rm $(docker volume ls --filter dangling=true -q) + docker rmi -f $(docker images -qa) + ''; + in { options.modules.docker = { enable = mkOption { @@ -25,6 +36,7 @@ in { # Add docker extensions. environment.systemPackages = [ + myDockerNuke pkgs.docker-compose pkgs.docker-machine ];