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

toolbox: init at 0.0.99 #110473

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions pkgs/applications/virtualization/toolbox/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{ lib
, fetchFromGitHub
, buildGoModule
, go-md2man
, installShellFiles
, fetchpatch
, glibc
}:

buildGoModule rec {
pname = "toolbox";
version = "0.0.99";

src = fetchFromGitHub {
owner = "containers";
repo = "toolbox";
rev = version;
sha256 = "CKjndWXDLxQ5epco/+TwRFxftbeMhYp/7NOWglF6EL8=";
};

modRoot = "src";

patches = [
./toolbox_glibc.patch
(fetchpatch {
url = "https://github.com/containers/toolbox/commit/14cacc4ea6dc8fc51cb1e6bffa221e2dbcb61a0b.patch";
sha256 = "DFakCVBj/RgKU5pem3KxKgjorl8FNlHApR56wxWpkpA=";
})
(fetchpatch {
url = "https://github.com/containers/toolbox/commit/a0f34e65c0c6b25b9300ed5f511403a29943a06a.patch";
sha256 = "9PZ7pDKlvkpEBQMyfR089nkDvRNRQ4Xzcij3ku1cdqE=";
})
];

postPatch = ''
substituteInPlace src/cmd/create.go --subst-var-by glibc ${glibc}
'';

vendorSha256 = "06s97kpbw40571jjp96jpld1qxb2frd4akcrwwxi1minvs24lb5p";

mjlbach marked this conversation as resolved.
Show resolved Hide resolved
buildFlagsArray = [
"-ldflags=-X github.com/containers/toolbox/pkg/version.currentVersion=${version}"
];
Comment on lines +41 to +43
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
buildFlagsArray = [
"-ldflags=-X github.com/containers/toolbox/pkg/version.currentVersion=${version}"
];
ldflags = [
"-X github.com/containers/toolbox/pkg/version.currentVersion=${version}"
"-s" "-w"
];


nativeBuildInputs = [
go-md2man
installShellFiles
];

preConfigure = ''
substituteInPlace src/cmd/create.go \
--replace '"/etc/profile.d/toolbox.sh"}' '"${placeholder "out"}/share/profile.d/toolbox.sh"}'
'';

postInstall = ''
cd ..
for d in doc/*.md; do
go-md2man -in $d -out ''${d%.md}
done
installManPage doc/*.[1-9]
installShellCompletion --bash completion/bash/toolbox
install profile.d/toolbox.sh -Dt $out/share/profile.d
'';

meta = with lib; {
description = "Unprivileged development environment";
homepage = "https://github.com/containers/toolbox";
license = licenses.asl20;
maintainers = with maintainers; [ mjlbach ];
platforms = platforms.linux;
};
}
21 changes: 21 additions & 0 deletions pkgs/applications/virtualization/toolbox/toolbox_glibc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/src/cmd/create.go b/src/cmd/create.go
index 74e90b1..113ef80 100644
--- a/src/cmd/create.go
+++ b/src/cmd/create.go
@@ -207,6 +207,8 @@ func createContainer(container, image, release string, showCommandToEnter bool)
toolboxPathEnvArg := "TOOLBOX_PATH=" + toolboxPath
toolboxPathMountArg := toolboxPath + ":/usr/bin/toolbox:ro"

+ glibcMountArg := "@glibc@:@glibc@:ro"
zowoq marked this conversation as resolved.
Show resolved Hide resolved
+
var runtimeDirectory string
var xdgRuntimeDirEnv []string

@@ -423,6 +425,7 @@ func createContainer(container, image, release string, showCommandToEnter bool)
"--volume", toolboxPathMountArg,
"--volume", usrMountArg,
"--volume", runtimeDirectoryMountArg,
+ "--volume", glibcMountArg,
}...)

createArgs = append(createArgs, avahiSocketMount...)
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7056,6 +7056,8 @@ in

podiff = callPackage ../tools/text/podiff { };

toolbox = callPackage ../applications/virtualization/toolbox { };

podman = if stdenv.isDarwin then
callPackage ../applications/virtualization/podman { }
else
Expand Down