Next: (maak i18n), Previous: (maak git), Up: API
Guix asked for values. The helpers in ‘(maak dsl)’ build command lines – ‘guix shell’, ‘guix pack’, ‘guix time-machine’ – because that is what a task usually wants: the environment, the container, the binary. The helpers here answer the other question: what *is* the package at this-pin, and where did building it put the result? ‘guix time-machine’ answers that by starting a whole second Guix; a Scheme program can ask it directly, and keep the answer as a value.
The asking happens in ‘guix repl’, which is Guix’s own Guile with Guix’s own modules on the load path. Nothing in maak imports ‘(guix ...)‘: a maak built on a machine without Guix has to compile and run exactly like one built with it, so the dependency is on the *program* at the moment a task calls one of these, not on the build. A machine without Guix gets a one-line error with a hint, from the call that needed it, and every other part of maak is unaffected.
The price is a process per query: about a third of a second for the repl plus the store connection. ‘cached-channel-instance’ keeps the second query against the same pins cheap, because the channel checkout is already in the store.
Return #t when a ‘guix’ program is on ‘PATH’.
Build PACKAGE as CHANNELS pins it and return its output path.
Building is what makes the answer usable: the output path is the directory the package installed into, with its ‘bin’, ‘lib’ and ‘share’ underneath.
(guix-build "hello") ⇒ "/gnu/store/…-hello-2.12.3"
Guix’s own build log goes to standard error as it does for ‘guix build’, so a long build still shows its progress.
Build PACKAGE at Guix REVISION and return its output path.
The pinned form of ‘guix-build’: REVISION is a commit of the Guix repository at URL, and no channels file is read.
Return the channel pins FILE names, as an alist of name and commit.
(guix-channels)
⇒ (("guix" . "0fb918d61609f3aadc2d8ecc212926b3bdfabb4c"))
The file is a normal ‘channels.scm’, the one ‘guix describe -f channels’ writes; the answer names every channel it lists, in the order they appear. This is the pin the ‘-at’ helpers replace, and the one ‘guix time-machine’ would read.
Return the derivation file name of PACKAGE as CHANNELS pins it.
PACKAGE is a package name, looked up in the Guix that CHANNELS names rather than in the one running. SYSTEM is the target system, or #f for this machine’s. Nothing is built: the derivation is the recipe, and its file name is enough for ‘guix build’ or for a later ‘build-derivations’.
(guix-derivation "hello") ⇒ "/gnu/store/…-hello-2.12.3.drv"
A channels file that has never been fetched is fetched here, with the network and the time that takes; afterwards Guix’s channel cache answers at once.
Return the derivation file name of PACKAGE at Guix REVISION.
REVISION is a commit of the Guix repository at URL, which defaults to the canonical one. This is the ‘guix time-machine –commit=REVISION’ question asked as a value: which Guix is not the one running, and no channels file has to exist for it.
(guix-derivation-at "0fb918d61609f3aadc2d8ecc212926b3bdfabb4c" "hello")
Run a program from PACKAGE as CHANNELS pins it.
ARGS are the arguments the program gets, each a string. PROGRAM names the program inside the package’s output and defaults to the package’s own name: a bare name is looked for in ‘bin’, and a name with a slash in it is taken as a path from the output’s root. The package is built first, so the program that runs is the one that pin names and not whatever the machine happens to have installed.
(guix-program "hello" '("--version"))
(guix-program "coreutils" '("-l" "/gnu/store") #:program "ls")
(guix-program "diffutils" (list "-u" a b) #:program "diff" #:async? #t)
The decorations are ‘run”s: ‘#:env’, ‘#:sudo?’, ‘#:dev-null?’, ‘#:allow-failure?’ and ‘#:async?’, so the program can be a job like any other.
In a dry run the store query is printed instead of the program line, because the path is only known once Guix has answered; #t is returned.
Run a program from PACKAGE, built by Guix REVISION, with ARGS.
The pinned form of ‘guix-program’: the package comes from the Guix at REVISION of URL rather than from the pinned channels file, which is what a task wants when it has to run one old tool for one step. PROGRAM and the decorations are ‘guix-program”s.
(guix-program-at "0fb918d61609f3aadc2d8ecc212926b3bdfabb4c"
"hello" '(--version))
Next: (maak i18n), Previous: (maak git), Up: API