From 5290a0f1e825371418f8b049951c0cf9c23d55ac Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 24 Jul 2024 11:49:14 +0300 Subject: [PATCH] feat(roles/docker, roles/base): docker role --- hosts/arwen/default.nix | 2 ++ roles/base.nix | 8 ++++++-- roles/default.nix | 3 ++- roles/docker.nix | 22 ++++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 roles/docker.nix diff --git a/hosts/arwen/default.nix b/hosts/arwen/default.nix index 91c98c6..ccf2a95 100644 --- a/hosts/arwen/default.nix +++ b/hosts/arwen/default.nix @@ -37,6 +37,8 @@ roles.zellij.enable = true; roles.kitty.enable = true; + roles.docker.enable = true; + roles.graphics = { enable = true; amd.enable = true; diff --git a/roles/base.nix b/roles/base.nix index 5b843c2..ba5fb8f 100644 --- a/roles/base.nix +++ b/roles/base.nix @@ -21,7 +21,11 @@ in { username = lib.mkOption { type = lib.types.str; }; - isWheel = lib.mkEnableOption "wheter to enable admin permissions"; + isWheel = lib.mkEnableOption "admin permissions"; + extraGroups = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + }; hashedPasswordFile = lib.mkOption { type = lib.types.path; }; @@ -44,7 +48,7 @@ in { users.users.root.hashedPasswordFile = cfg.root.hashedPasswordFile; users.users.${cfg.primaryUser.username} = { isNormalUser = true; - extraGroups = lib.optional cfg.primaryUser.isWheel "wheel"; + extraGroups = cfg.primaryUser.extraGroups ++ lib.optional cfg.primaryUser.isWheel "wheel"; home = homeDirectory; hashedPasswordFile = cfg.primaryUser.hashedPasswordFile; }; diff --git a/roles/default.nix b/roles/default.nix index edeb495..4077166 100644 --- a/roles/default.nix +++ b/roles/default.nix @@ -5,8 +5,9 @@ ./shell ./audio.nix - ./bluetooth.nix ./base.nix + ./bluetooth.nix + ./docker.nix ./git.nix ./hyprland.nix ./kitty.nix diff --git a/roles/docker.nix b/roles/docker.nix new file mode 100644 index 0000000..f05d291 --- /dev/null +++ b/roles/docker.nix @@ -0,0 +1,22 @@ +{ + config, + lib, + ... +}: let + cfg = config.roles.docker; +in { + options.roles.docker = { + enable = lib.mkEnableOption "Docker"; + enableNvidia = lib.mkEnableOption "Docker NVIDIA GPU support"; + }; + + config = lib.mkIf cfg.enable { + virtualisation.docker = { + enable = true; + enableNvidia = cfg.enableNvidia; + }; + + # FIXME: make configurable + roles.base.primaryUser.extraGroups = ["docker"]; + }; +} -- 2.44.1