-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hugo Lecomte
committed
Jun 21, 2021
1 parent
73ab48a
commit 074a5e3
Showing
20 changed files
with
773 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"""BuildPack for guix environments""" | ||
import os | ||
|
||
from ..base import BuildPack, BaseImage | ||
|
||
|
||
class GuixBuildPack(BaseImage): | ||
"""A guix Package Manager BuildPack""" | ||
|
||
def get_path(self): | ||
"""Return paths to be added to PATH environment variable""" | ||
return super().get_path() + ["/home/${NB_USER}/.guix-profile/bin"] | ||
|
||
|
||
def get_build_scripts(self): | ||
""" | ||
Install guix package manager version 1.3.0.x86_64-linux, using | ||
an unmodified installation script found at | ||
https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh | ||
""" | ||
return super().get_build_scripts() + [ | ||
( | ||
"root", | ||
""" | ||
yes | BIN_VER=1.3.0.x86_64-linux \ | ||
bash /home/${NB_USER}/.local/bin/guix-install.bash | ||
""", | ||
), | ||
|
||
] | ||
|
||
def get_build_script_files(self): | ||
|
||
"""Copying guix installation script on the image""" | ||
return { | ||
"guix/guix-install.bash": | ||
"/home/${NB_USER}/.local/bin/guix-install.bash", | ||
} | ||
|
||
def get_assemble_scripts(self): | ||
""" | ||
Wake up the guix daemon with root permission, set guix environnement | ||
variables, make sure we never use debian's python by error by | ||
renaming it, then, as an user install packages listed in | ||
manifest.scm, use guix time-machine if channels.scm file exists | ||
""" | ||
assemble_script =""" | ||
/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon \ | ||
--build-users-group=guixbuild --disable-chroot & \ | ||
mv /usr/bin/python /usr/bin/python.debian && \ | ||
su - $NB_USER -c '{}' && \ | ||
echo 'GUIX_PROFILE="$HOME/.guix-profile" ; \ | ||
source "$GUIX_PROFILE/etc/profile"'>> ~/.bash_profile | ||
""" | ||
|
||
if os.path.exists(self.binder_path("channels.scm")): | ||
assemble_script = assemble_script.format( | ||
"guix time-machine -C " + self.binder_path("channels.scm") + | ||
" -- package -m " + self.binder_path("manifest.scm") | ||
) | ||
else: | ||
assemble_script = assemble_script.format( | ||
"guix package -m " + self.binder_path("manifest.scm") | ||
) | ||
return super().get_assemble_scripts() + [ | ||
( "root", | ||
assemble_script, | ||
) | ||
] | ||
|
||
def detect(self): | ||
"""Check if current repo should be built with the guix BuildPack""" | ||
return os.path.exists(self.binder_path("manifest.scm")) | ||
|
Oops, something went wrong.