Skip to content
Draft
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
34 changes: 34 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,37 @@ jobs:
with:
command: doc
args: --no-deps

guix-build:
name: Guix packaging (experimental)
runs-on: ubuntu-latest
steps:
- name: Guix cache
uses: actions/cache@v2
with:
path: ~/.cache/guix
# use a key that (almost) never matches
key: guix-cache-${{ github.sha }}
# Cannot use a cache for /gnu/store, since restore fails
restore-keys: |
guix-cache-
- name: Install Guix
uses: PromyLOPh/guix-install-action@v1
- uses: actions/checkout@v2
- name: Build my package
run: guix build --load-path=guix/ qrxfil
# Pack independent binary and upload as artifact
- name: Pack
run: guix pack --load-path=guix/ -RR --save-provenance --root=qrxfil.tar.bz2 --compression=bzip2 qrxfil
- name: Upload
uses: actions/upload-artifact@v2
with:
name: qrxfil
path: qrxfil.tar.bz2
- name: Pack (Docker format)
run: guix pack --load-path=guix/ --format=docker --entry-point=bin/qrxfil --root=qrxfil-docker.tar.gz qrxfil
- name: Upload Docker
uses: actions/upload-artifact@v2
with:
name: qrxfil-docker
path: qrxfil-docker.tar.gz
2 changes: 2 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ binary application not a library with a contract.

* [Unreleased]

** Added
- Experimental [[https://guix.gnu.org/][Guix]] packaging in the =guix/= folder

* [0.3.1] - 2021-04-24

Expand Down
3 changes: 3 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ make
Github Actions runs similar checks for Continuous Integration purposes
on master and in pull requests.

An experimental [[https://guix.gnu.org/en/manual/en/html_node/Invoking-guix-pack.html#index-relocatable-binaries][guix]] package definition is available in the =guix/=
folder, see the =README= in there.

* FAQ

** Why build this?
Expand Down
104 changes: 104 additions & 0 deletions guix/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#+TITLE: Packaging qrxfil in Guix

An attempt at packaging =qrxfil= as a [[https://guix.gnu.org/][Guix]] package.

* What is Guix
[[https://guix.gnu.org/en/manual/en/html_node/Invoking-guix-pack.html#index-relocatable-binaries][Guix]] is a next-generation package manager (similar to Nix), describing
packages as source + build operations, enabling [[https://reproducible-builds.org/][reproducible build]],
transactional upgrades and rollbacks, and much more.

Guix package definitions rely on the specific build system of the
target language to avoid duplication (see [[https://guix.gnu.org/en/cookbook/en/guix-cookbook.html#Packaging-Tutorial][Packaging Tutorial]]). For
Rust, this means leveraging =cargo=.

This README can't/won't explain why Guix is amazing, just read up
about it, it's great.


* Packaging qrxfil

The =qrxfil.scm= file describes a =qrxfil= package built by cloning the
Github repo at a known tag, running =cargo build --release= as needed,
skipping tests (due to dependency on =pandoc= and =pdflatex=)

Some of the dependencies of =qrxfil= aren't packaged yet in Guix, and
need porting over. Thankfully, [[https://guix.gnu.org/en/cookbook/en/guix-cookbook.html#Recursive-importers-1][Guix makes this easy]]. Imported those
via =guix import crate --recursive packagename=, but some have already
got a version to derive/inherit from. See =qrxfil-deps.scm= for the
result. Future effort will address minizing the number of such
packages, either by upstreaming them into Guix project as packages
(when package is missing altogether), by lowering the minimum version
=qrxfil= depends on to a version already available, or by making the
(newer) version derive (inherit) from existing guix versions (just
changing the git tag and checksum).

To build (but not install), run the following in a Guix
environment:

#+begin_src shell
guix build --load-path=. qrxfil # add --kep to examine failures
#+end_src
* Install

#+begin_src shell
guix install --load-path=. qrxfil
#+end_src

* Exporting the package

And exporting the built package into a tarball for running it on a
foreign machine:

#+begin_src shell
guix pack --load-path=. -RR --save-provenance --root=qrxfil.tar.bz2 --compression=bzip2 -S /mybin=bin qrxfil
# unpack the package into ./gnu and symlinks ./bin/qrxfil to ./gnu/...
tar xjvf qrxfil.tar.bz2
# Run qrxfil from the packed version:
./bin/qrxfil --help
#+end_src


* Docker image

To build an OCI-compliant docker image tarball, use this:

#+begin_src shell
guix pack --load-path=. --format=docker --entry-point=bin/qrxfil --root=qrxfil-docker.tar.gz qrxfil
docker load < qrxfil-docker.tar.gz
# Docker run invocation
docker run \
-it \
-u $(id -u):$(id -u) \
-v $(pwd):/app/ \
-w /app/ \
qrxfil \
exfil .bashrc qrxfil_out
# -it for interactive+tty
# -u to avoid root-owned files
# -v mounts the local folder in /app/
# -w sets working directory to mounted /app/
# Image name is "qrxfil"
# Last line is actual parameters of qrxfil
# aka exfiltrate the bashrc by creating qrxfil_out/
#+end_src

* Continuous integration

CI using Github Action is running on this repository, using the [[https://github.com/PromyLOPh/guix-install-action/][Guix
install Github actions]]. See the [[https://github.com/PromyLOPh/guix-install-action/blob/master/.github/workflows/test.yml][Sample CI.yml for building a guix
package]].

It's configured to build the package as tarball and a docker image,
see above for how to use it.

* Dev manifest file

See =qrxfil-dev-manifest.scm= for a manifest file, the list of guix
packages to install in a separate environment required for =make check
build=. See [[https://guix.gnu.org/en/manual/en/html_node/Invoking-guix-environment.html][Guix manual: guix environment section]], and the [[https://guix.gnu.org/en/cookbook/en/html_node/Basic-setup-with-manifests.html][Guix
cookbook: Working with profiles]].

#+begin_src shell
guix environment --manifest guix/qrxfil-dev-manifest.scm
make check build
#+end_src
Loading