Skip to content

Commit

Permalink
Attempt a rootless container after all
Browse files Browse the repository at this point in the history
  • Loading branch information
antifuchs committed Aug 29, 2023
1 parent cfae929 commit ca27e88
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ in {
users.users.tsnsrv-sidecar = {
isSystemUser = true;
group = config.users.groups.tsnsrv.name;
subUidRanges = [
{
startUid = 200000;
count = 100000;
}
];
subGidRanges = [
{
startGid = 200000;
count = 100000;
}
];
};

virtualisation.oci-containers.containers =
Expand All @@ -276,19 +288,9 @@ in {
# The tsnet auth key.
"${config.virtualisation.oci-sidecars.tsnsrv.authKeyPath}:${config.virtualisation.oci-sidecars.tsnsrv.authKeyPath}"
];
extraOptions =
[
"--network=container:${sidecar.forContainer}"
]
++ (
if (config.virtualisation.oci-containers.backend == "podman")
then [
"--passwd"
"--hostuser=${config.users.users.tsnsrv-sidecar.name}"
"--group-add=keep-groups"
]
else []
);
extraOptions = [
"--network=container:${sidecar.forContainer}"
];
cmd =
["-stateDir=/state"]
++ (serviceArgs {
Expand All @@ -308,11 +310,19 @@ in {
in {
name = serviceName;
value = {
path = ["/run/wrappers"];
serviceConfig = {
User = config.users.users.tsnsrv-sidecar.name;
Group = config.users.groups.tsnsrv.name;
StateDirectory = serviceName;
RuntimeDirectory = serviceName;
StateDirectoryMode = "0700";
SupplementaryGroups = [config.users.groups.tsnsrv.name] ++ service.supplementalGroups;
};
environment = {
HOME = "%S";
XDG_RUNTIME_DIR = "%t";
};
};
})
config.virtualisation.oci-sidecars.tsnsrv.containers
Expand Down

0 comments on commit ca27e88

Please sign in to comment.