-
Notifications
You must be signed in to change notification settings - Fork 362
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
Jul 5, 2021
1 parent
73ab48a
commit fc4cc45
Showing
20 changed files
with
172 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,75 @@ | ||
"""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() + [ | ||
"/var/guix/profiles/per-user/$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?id=a0178d34f582b50e9bdbb0403943129ae5b560ff | ||
""" | ||
return super().get_build_scripts() + [ | ||
( | ||
"root", | ||
""" | ||
bash /tmp/.local/bin/guix-install.bash | ||
""", | ||
), | ||
|
||
] | ||
|
||
def get_build_script_files(self): | ||
|
||
"""Copying guix installation script on the image""" | ||
return { | ||
"guix/guix-install.bash": | ||
"/tmp/.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="/var/guix/profiles/per-user/$NB_USER/.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")) | ||
|
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,8 @@ | ||
#!/bin/bash | ||
# This downloads and installs a pinned version of Guix | ||
set -ex | ||
|
||
wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh?id=a0178d34f582b50e9bdbb0403943129ae5b560ff | ||
|
||
yes | BIN_VER=1.3.0x86_64-linux \ | ||
bash guix-install.sh?id=a0178d34f582b50e9bdbb0403943129ae5b560ff |
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,4 @@ | ||
`manifest.scm` in a binder/ directory | ||
------------------------------------- | ||
|
||
Check if we can find and use `manifest.scm` when it is ina `binder/` sub-directory. |
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,3 @@ | ||
(specifications->manifest | ||
'("jupyter" | ||
"hello")) |
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,3 @@ | ||
#!/bin/sh | ||
|
||
hello |
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,4 @@ | ||
`manifest.scm` in main directory and in `binder/` | ||
------------------------------------------------- | ||
|
||
Check if `manifest.scm` located in the `binder/` sub-directory is prefered to the one in the main directory. |
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,4 @@ | ||
(specifications->manifest | ||
'("jupyter" | ||
"python" | ||
"python-numpy")) |
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,2 @@ | ||
(specifications->manifest | ||
'("jupyter")) |
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,3 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import numpy |
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,4 @@ | ||
`manifest.scm` and `channels.scm` in main directory | ||
--------------------------------------------------- | ||
|
||
CHeck if we can use `manifest.scm` alongside a `channels.scm` file using `guix time-machine ...` |
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,20 @@ | ||
(list (channel | ||
(name 'guix) | ||
(url "https://git.savannah.gnu.org/git/guix.git") | ||
(commit | ||
"f1bfd9f1948a5ff336d737c0614b9a30c2bb3097") | ||
(introduction | ||
(make-channel-introduction | ||
"9edb3f66fd807b096b48283debdcddccfea34bad" | ||
(openpgp-fingerprint | ||
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))) | ||
(channel | ||
(name 'nonguix) | ||
(url "https://gitlab.com/nonguix/nonguix") | ||
(commit | ||
"46c1d8bcca674d3a71cd077c52dde9552a89873d") | ||
(introduction | ||
(make-channel-introduction | ||
"897c1a470da759236cc11798f4e0a5f7d4d59fbc" | ||
(openpgp-fingerprint | ||
"2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5"))))) |
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,3 @@ | ||
(specifications->manifest | ||
'("jupyter" | ||
"hello")) |
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,3 @@ | ||
#!/bin/sh | ||
|
||
hello |
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,5 @@ | ||
|
||
`manifest.scm` in the main directory | ||
---------------------------------- | ||
|
||
Check if we can find and use `manifest.scm` when it is in the main directory. |
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,3 @@ | ||
(specifications->manifest | ||
'("jupyter" | ||
"hello")) |
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,3 @@ | ||
#!/bin/sh | ||
|
||
hello |