Got flake set up for cross-compilation, but it still doesn't work

This commit is contained in:
Brian Picciano 2023-01-29 18:57:55 +01:00
parent 05f9064d10
commit 1379291c1e
3 changed files with 56 additions and 25 deletions

View File

@ -4,7 +4,6 @@
garage, garage,
selfRev, selfRev,
hostSystem, hostSystem,
#buildSystem,
}: rec { }: rec {
@ -15,9 +14,12 @@
inherit selfRev hostSystem; inherit selfRev hostSystem;
src = ./version.txt; src = ./version.txt;
garageVersion = garage.version; garageVersion = garage.version;
nativeBuildInputs = [ pkgs.go ]; # TODO it'd be nice to be able to call `go version`, but that doesn't work
# when crossSystem is being used for some unknown reason.
goVersion = pkgs.go.version;
builder = builtins.toFile "builder.sh" '' builder = builtins.toFile "builder.sh" ''
source $stdenv/setup source $stdenv/setup
@ -29,7 +31,7 @@
echo "System: $hostSystem" >> "$versionFile" echo "System: $hostSystem" >> "$versionFile"
echo "Git Revision: $selfRev" >> "$versionFile" echo "Git Revision: $selfRev" >> "$versionFile"
echo "Go Version: $(go version)" >> "$versionFile" echo "Go Version: $goVersion" >> "$versionFile"
echo "Garage Version: $garageVersion" >> "$versionFile" echo "Garage Version: $garageVersion" >> "$versionFile"
mkdir -p "$out"/share mkdir -p "$out"/share

View File

@ -7,8 +7,7 @@
# v0.8.1 # v0.8.1
inputs.garage.url = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?ref=main&rev=76230f20282e73a5a5afa33af68152acaf732cf5"; inputs.garage.url = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?ref=main&rev=76230f20282e73a5a5afa33af68152acaf732cf5";
description = "cryptic-net provides the foundation for an autonomous community description = "cryptic-net provides the foundation for an autonomous community cloud infrastructure";
cloud infrastructure";
outputs = { outputs = {
@ -23,31 +22,61 @@ cloud infrastructure";
"i686-linux" "i686-linux"
]; ];
in utils.lib.eachSystem supportedSystems (system: let mkPkg = (buildSystem: hostSystem: let
pkgs = import pkgsSrc { pkgs = import pkgsSrc {
inherit system; system = buildSystem;
#crossSystem = { crossSystem = {
# config = system; config = hostSystem;
#}; };
overlays = [ overlays = [
(import ./nix/overlays/go.nix) (import ./nix/overlays/go.nix)
]; ];
}; };
defaultAttrs = (import ./default.nix) { defaultAttrs = (import ./default.nix) {
inherit pkgs; inherit pkgs;
hostSystem = system; hostSystem = hostSystem;
#buildSystem = self.system; garage = garage.packages."${hostSystem}".default;
garage = garage.packages."${system}".default; selfRev = if self ? rev then self.rev else "UNKNOWN";
selfRev = if self ? rev then self.rev else "UNKNOWN"; };
};
in
defaultAttrs.garage
);
# TODO Once everything else is prepared for cross compilation this can be
# re-enabled. Things left to do:
#
# - Revert to not using flake for garage, we'll need to compile it
# ourselves because flakes don't actually support cross-compilation in a
# nice way.
#
# - Set ARCH arg for appimagetool target in default.nix
#
# - Test builds in QEMU or something.
#
# - Probably other things which will come up
#pkgsForBuildSystem = (buildSystem: builtins.foldl'
# (sysPkgs: hostSystem:
# sysPkgs // { "compiled-for-${hostSystem}" = mkPkg buildSystem hostSystem; })
# { default = mkPkg buildSystem buildSystem; }
# supportedSystems
#);
pkgsForBuildSystem = (buildSystem:
{ default = mkPkg buildSystem buildSystem; });
in { in {
defaultPackage = defaultAttrs.appImage; packages = (builtins.foldl'
(pkgs: buildSystem:
pkgs // { "${buildSystem}" = pkgsForBuildSystem buildSystem; })
{}
supportedSystems
);
}); };
} }

View File

@ -4,7 +4,7 @@ let
version = "745"; version = "745";
cpuArch = stdenv.buildPlatform.parsed.cpu.arch; cpuArch = stdenv.buildPlatform.parsed.cpu.name;
src = { src = {