3 ms·
My examples are in Nix, because that's what I'm familiar with, but everything should apply to Guix too (with some translation). > Let's say I want to have the
by Nullabillity 8y ago
My examples are in Nix, because that's what I'm familiar with, but everything should apply to Guix too (with some translation).
> Let's say I want to have the last five versions of my application installed as a mortal user, for testing purposes.
Sure, you can use linkFarm to collect multiple variants:
let
pkgs = import <nixpkgs>;
repoUrl = "https://gitlab.com/teozkr/sbtix.git";
versions = [
{
rev = "v1.0";
sha256 = "storehash1";
}
{
rev = "v1.1";
sha256 = "storehash2";
}
];
programOfVersion = version: pkgs.callPackage (pkgs.fetchgit {
inherit (version) rev sha256;
url = repoUrl;
}) {};
allBins = map (version: {
name = "sbtix-${version.rev}";
path = "${programOfVersion version}/bin/sbtix";
}) versions;
binFarm = pkgs.linkFarm "sbtix-binfarm" allBins;
in
pkgs.linkFarm "sbtix-farm" [ {
name = "bin";
path = binFarm;
} ];
That said... the Nix way would have been to just build the version you care about, when you care about it, without installing it globally. To do that you could just run `nix build` in your project directory, and then run `result/bin/my-program`.
> Let's say that my application's build system pulls in a big GUI toolkit binary because reasons.
Not sure which toolkit you're talking about, the the big ones (GTK, Qt, wxWidgets, etc) are already packaged for you.
> Let's say I don't want to create "official" packages for it, just something quick and dirty that will get me these versions installed.
This depends on what language you're using, but it's usually a matter of 1) defining your dependencies and 2) running your preferred build tool.
The usual recipe for a default.nix looks like this:
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv {
name = "my-program";
src = ./.;
buildInputs = [ pkgs.qt5 pkgs.pulseaudio ... ];
configurePhase = "./configure --prefix $out";
buildPhase = "make";
installPhase = "make install";
}
Though most languages have helpers to avoid this boilerplate (and, usually, to help with things like caching across builds).
Haskell has buildStackProject[1], Node has yarn2nix[2], etc. stdenv will default to the Autotools workflow (./configure; make; make install) if you don't define the phases yourself.
[1]: https://nixos.org/nixpkgs/manual/#how-to-build-a-haskell-project-using-stack https://nixos.org/nixpkgs/manual/#how-to-build-a-haskell-pro...
[2]: https://github.com/moretea/yarn2nix https://github.com/moretea/yarn2nix
> Can I do this with GNU Guix?
Yes ;)