From 4cc2b50e15b06d84a97414544887f79ed9976ccd Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 18:40:25 +0800 Subject: [PATCH] feat(nixos): add podman module --- nix/modules/options/virtualisation.nix | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 nix/modules/options/virtualisation.nix diff --git a/nix/modules/options/virtualisation.nix b/nix/modules/options/virtualisation.nix new file mode 100644 index 0000000..f01e3c2 --- /dev/null +++ b/nix/modules/options/virtualisation.nix @@ -0,0 +1,37 @@ +{ lib, config, ... }: +let + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; + inherit (cfg.lib.modules) forAllUsers; + cfg = config.flake; +in +{ + flake.modules.nixos.default = + { pkgs, config, ... }: + { + options = { + podman.enable = mkEnableOption ""; + podman.distrobox.enable = mkEnableOption ""; + }; + config = mkIf config.podman.enable { + virtualisation = { + containers.enable = true; + podman = { + enable = true; + dockerCompat = true; + defaultNetwork.settings.dns_enabled = true; + }; + }; + users.users = forAllUsers { + extraGroups = [ "podman" ]; + autoSubUidGidRange = true; + }; + home-manager.sharedModules = [ + { + home.packages = [ pkgs.distrobox ]; + persistDirs = [ ".local/share/containers" ]; + } + ]; + }; + }; +}