Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysbox: init at 0.6.2 #273241

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9143,6 +9143,12 @@
githubId = 1792886;
name = "Julien Malka";
};
juliosueiras = {
email = "[email protected]";
github = "juliosueiras";
githubId = 3680302;
name = "Julio Tain Sueiras";
};
juliusrickert = {
email = "[email protected]";
github = "juliusrickert";
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,7 @@
./virtualisation/cri-o.nix
./virtualisation/docker-rootless.nix
./virtualisation/docker.nix
./virtualisation/sysbox.nix
./virtualisation/ecs-agent.nix
./virtualisation/hyperv-guest.nix
./virtualisation/incus.nix
Expand Down
73 changes: 73 additions & 0 deletions nixos/modules/virtualisation/sysbox.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{ config, lib, pkgs, ... }:

with lib;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to address #208242 for this module, uses of with such as this should be avoided.
consider inherits where you find yourself using lib.foo excessively.


let
cfg = config.virtualisation.sysbox;
in

{
###### interface

options.virtualisation.sysbox = {
enable =
mkOption {
type = types.bool;
default = false;
description =
lib.mdDoc ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib.mdDoc is now just an alias and can be safely removed everywhere.
see d36f950 and #237557

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib.mkEnableOption would be nice.

This option enables sysbox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to be a little bit more precise what this does =).
e.g.

Suggested change
This option enables sysbox
Enables the container runtime `sysbox-runc` from `nestybox`.
Starts a `sysbox-mgr` manager service and makes the runtime available
for `docker` to be used in `docker run --runtime=sysbox-runc ...`.

'';
};

package = mkPackageOption pkgs "sysbox" { };
};

###### implementation

config = mkIf cfg.enable {
systemd.services.sysbox-mgr = {
description = "Sysbox Manager Service";
wantedBy = [ "multi-user.target" ];

path = [ pkgs.rsync pkgs.kmod pkgs.iptables ];
script = "${cfg.package}/bin/sysbox-mgr";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would lib.getExe not be more appropriate here? ( and all following uses like this )


preStart = ''
mkdir /sbin || true
cp ${pkgs.iptables}/bin/* /sbin || true
'';

serviceConfig = {
User = "root";
Group = "root";
};
};

systemd.services.sysbox-fs = {
description = "Sysbox FileSystem Service";
wantedBy = [ "multi-user.target" ];

path = [ pkgs.rsync pkgs.kmod pkgs.fuse pkgs.iptables ];
script = "${cfg.package}/bin/sysbox-fs";

serviceConfig = {
User = "root";
Group = "root";
};
};

virtualisation.docker.extraOptions = ''--add-runtime=sysbox=${cfg.package}/bin/sysbox-runc'';

security.unprivilegedUsernsClone = true;

assertions = [
{ assertion = !virtualisation.docker.enable;
message = "Sysbox require docker to be functional";
}
{ assertion = virtualisation.podman.enable;
message = "Sysbox require docker to be functional";
}
];
};
}
33 changes: 33 additions & 0 deletions pkgs/applications/virtualization/sysbox/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ stdenv
, lib
, fetchurl
, dpkg
}:

stdenv.mkDerivation rec {
pname = "sysbox";
version = "0.6.2";

src = fetchurl {
url = "https://downloads.nestybox.com/sysbox/releases/v0.6.2/sysbox-ce_${version}-0.linux_amd64.deb";
sha256 = "/Sh/LztaBytiw3j54e7uqizK0iu0jLOB0w2MhVxRtAE=";
};

nativeBuildInputs = [ dpkg ];

unpackPhase = ''
dpkg-deb -R $src .
'';

installPhase = ''
mkdir -p $out/bin
cp -rf usr/bin/* $out/bin/
'';

meta = with lib; {
homepage = "https://github.com/nestybox/sysbox";
description = "An open-source, next-generation 'runc' that empowers rootless containers to run workloads such as Systemd, Docker, Kubernetes, just like VMs.";
license = licenses.asl20;
maintainers = with maintainers; [ juliosueiras ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@ with pkgs;

docker-slim = callPackage ../applications/virtualization/docker-slim { };

sysbox = callPackage ../applications/virtualization/sysbox { };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed? pkgs/by-name should likely be used instead.


doc2go = callPackage ../development/tools/doc2go { };

docker-sync = callPackage ../tools/misc/docker-sync { };
Expand Down