Compare commits
11 Commits
6b6556cd80
...
0652389078
| Author | SHA1 | Date | |
|---|---|---|---|
| 0652389078 | |||
| 2913e9578e | |||
| b72c1d5e86 | |||
| 1c844adf91 | |||
| fdbe4366e1 | |||
| a9ffcc12ee | |||
| 9765d93f9f | |||
| 42dbe5ade2 | |||
| bab2c35bff | |||
| ce26b1c206 | |||
| 2d26d6ebd8 |
@@ -40,6 +40,7 @@ in
|
||||
];
|
||||
|
||||
secrets.username = username;
|
||||
docker.user = username;
|
||||
|
||||
disko.devices = {
|
||||
disk.data = {
|
||||
|
||||
@@ -1,9 +1,44 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.docker;
|
||||
in
|
||||
{
|
||||
virtualisation.docker = {
|
||||
enable = false;
|
||||
rootless = {
|
||||
enable = true;
|
||||
setSocketVariable = true;
|
||||
options.docker = {
|
||||
rootless = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
user = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
warnings = lib.flatten [
|
||||
(lib.optional (
|
||||
cfg.rootless && cfg.user != null
|
||||
) "'virtualisation.docker.user' is ignored when rootless mode is enabled")
|
||||
(lib.optional (
|
||||
!cfg.rootless && cfg.user == null
|
||||
) "'virtualisation.docker.user' is not set (no user is added to the docker group)")
|
||||
];
|
||||
}
|
||||
(lib.mkIf cfg.rootless {
|
||||
virtualisation.docker = {
|
||||
enable = false;
|
||||
rootless = {
|
||||
enable = true;
|
||||
setSocketVariable = true;
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (!cfg.rootless && cfg.user != null) {
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
};
|
||||
users.users.${cfg.user}.extraGroups = [ "docker" ];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user