Browse Source

Add docker-nuke command

main
parent
commit
7b28e2d1ad
Signed by: chris GPG Key ID: 3025DCBD46F81C0F
  1. 16
      README.org
  2. 12
      modules/docker.nix

16
README.org

@ -302,7 +302,8 @@ mkShell {
flutter flutter
]; ];
shellHook = '' 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 #+END_SRC
@ -939,6 +940,17 @@ in {
with lib; with lib;
with lib.types; with lib.types;
let cfg = config.modules.docker; 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 { in {
options.modules.docker = { options.modules.docker = {
enable = mkOption { enable = mkOption {
@ -960,6 +972,7 @@ in {
# Add docker extensions. # Add docker extensions.
environment.systemPackages = [ environment.systemPackages = [
myDockerNuke
pkgs.docker-compose pkgs.docker-compose
pkgs.docker-machine pkgs.docker-machine
]; ];
@ -984,6 +997,7 @@ with lib;
with lib.types; with lib.types;
let let
cfg = config.modules.firefox; cfg = config.modules.firefox;
myFirefox = pkgs.writeShellScriptBin "firefox" '' myFirefox = pkgs.writeShellScriptBin "firefox" ''
HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox
''; '';

12
modules/docker.nix

@ -4,6 +4,17 @@
with lib; with lib;
with lib.types; with lib.types;
let cfg = config.modules.docker; 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 { in {
options.modules.docker = { options.modules.docker = {
enable = mkOption { enable = mkOption {
@ -25,6 +36,7 @@ in {
# Add docker extensions. # Add docker extensions.
environment.systemPackages = [ environment.systemPackages = [
myDockerNuke
pkgs.docker-compose pkgs.docker-compose
pkgs.docker-machine pkgs.docker-machine
]; ];

Loading…
Cancel
Save