diff --git a/default.nix b/default.nix index 2063e75..dfb5e3a 100644 --- a/default.nix +++ b/default.nix @@ -20,19 +20,19 @@ in rec { - version = let - revisionFile = if builtins.isNull revision - then pkgsNative.stdenv.mkDerivation { - name = "revision.txt"; - nativeBuildInputs = [ pkgsNative.git ]; - src = ./.git; - phases = [ "installPhase" ]; - installPhase = '' - git -c safe.directory='*' -C $src describe --tags > $out - ''; - } - else pkgsNative.writeText "revision.txt" revision; - in pkgs.stdenv.mkDerivation { + revisionFile = if builtins.isNull revision + then pkgsNative.stdenv.mkDerivation { + name = "revision.txt"; + nativeBuildInputs = [ pkgsNative.git ]; + src = ./.git; + phases = [ "installPhase" ]; + installPhase = '' + git -c safe.directory='*' -C $src describe --tags > $out + ''; + } + else pkgsNative.writeText "revision.txt" revision; + + version = pkgs.stdenv.mkDerivation { name = "isle-version"; inherit buildSystem hostSystem revisionFile releaseName; @@ -88,11 +88,8 @@ in rec { nebula = pkgs.callPackage ./nix/nebula.nix {}; - garage = let - hostPlatform = pkgs.stdenv.hostPlatform.parsed; - in garageNix.package { - inherit pkgsNix buildSystem; - hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl"; + garage = garageNix.package { + inherit pkgsNix buildSystem hostSystem; }; appDirBase = pkgs.buildEnv { @@ -143,30 +140,26 @@ in rec { ]; }; + appimagekit = pkgsNative.callPackage ./nix/appimagetool { + inherit hostSystem; + }; + build = rec { appImage = pkgs.stdenv.mkDerivation { name = "isle-AppImage"; src = appDir; + inherit revisionFile; - nativeBuildInputs = [ - (pkgsNative.callPackage ./nix/appimagetool.nix {}) - ]; - - ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name; + nativeBuildInputs = [ appimagekit ]; builder = builtins.toFile "build.sh" '' source $stdenv/setup cp -rL "$src" isle.AppDir chmod +w isle.AppDir -R - export VERSION=debug - - # https://github.com/probonopd/go-appimage/issues/155 - unset SOURCE_DATE_EPOCH - - appimagetool ./isle.AppDir + export VERSION=$(cat $revisionFile) mkdir -p "$out"/bin - mv Isle-* "$out"/bin/isle + appimagetool ./isle.AppDir "$out"/bin/isle ''; }; diff --git a/docs/install.md b/docs/install.md index fba12ed..33c3460 100644 --- a/docs/install.md +++ b/docs/install.md @@ -9,6 +9,7 @@ supported: - `x86_64` (aka `amd64`) - `aarch64` (aka `arm64`) - `i686` +- `armv6l` (For older Raspberry Pis) (`i686` has not been tested.) diff --git a/nix/appimagetool.nix b/nix/appimagetool.nix deleted file mode 100644 index a6b2706..0000000 --- a/nix/appimagetool.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ stdenv, fetchurl }: - -let - - version = "765"; - - cpuArch = stdenv.buildPlatform.parsed.cpu.name; - - srcDir = ./go-appimage; - - # https://github.com/probonopd/go-appimage - # The author of go-appimage has set up some crazy continuous integration build - # system with github, which is really cool, except that it doesn't preserve - # any older builds of the project. And it's pretty difficult to build it - # ourselves. So fuck it, just embed the build artifacts directly in this - # project. - src = { - "x86_64" = "${srcDir}/appimagetool-${version}-x86_64.AppImage"; - "aarch64" = "${srcDir}/go-appimage/appimagetool-${version}-aarch64.AppImage"; - "armv7l" = "${srcDir}/go-appimage/appimagetool-${version}-armhf.AppImage"; - "i686" = "${srcDir}/go-appimage/appimagetool-${version}-i686.AppImage"; - }."${cpuArch}"; - -in stdenv.mkDerivation rec { - - pname = "go-appimage"; - inherit version src; - sourceRoot = "squashfs-root"; - - unpackPhase = '' - cp $src appimagetool - chmod u+wx appimagetool - ./appimagetool --appimage-extract - ''; - - installPhase = '' - mkdir -p $out - cp -r usr/* $out - ''; -} diff --git a/nix/appimagetool/default.nix b/nix/appimagetool/default.nix new file mode 100644 index 0000000..e8db2a8 --- /dev/null +++ b/nix/appimagetool/default.nix @@ -0,0 +1,22 @@ +{ appimagekit, hostSystem, writeScriptBin }: let + + arch = builtins.getAttr hostSystem { + "x86_64-linux" = "x86_64"; + "aarch64-linux" = "aarch64"; + "armv6l-linux" = "armhf"; + "i686-linux" = "i686"; + }; + + # https://github.com/AppImage/type2-runtime + # The author has set up some crazy continuous integration build system with + # github, which is really cool, except that it doesn't preserve any older + # builds of the project. And it's pretty difficult to build it ourselves. So + # fuck it, just embed the build artifacts directly in this project. + runtimeFileVersion = "81de3e1"; + runtimeFile = "${./.}/runtime-${arch}-${runtimeFileVersion}"; + +in writeScriptBin "appimagetool" '' + export PATH=$PATH:${appimagekit}/bin + export ARCH=${arch} + exec ${appimagekit}/bin/appimagetool --runtime-file ${runtimeFile} "$@" +'' diff --git a/nix/appimagetool/runtime-aarch64-81de3e1 b/nix/appimagetool/runtime-aarch64-81de3e1 new file mode 100644 index 0000000..42e4fbc Binary files /dev/null and b/nix/appimagetool/runtime-aarch64-81de3e1 differ diff --git a/nix/appimagetool/runtime-armhf-81de3e1 b/nix/appimagetool/runtime-armhf-81de3e1 new file mode 100644 index 0000000..860047b Binary files /dev/null and b/nix/appimagetool/runtime-armhf-81de3e1 differ diff --git a/nix/appimagetool/runtime-i686-81de3e1 b/nix/appimagetool/runtime-i686-81de3e1 new file mode 100644 index 0000000..51ef09e Binary files /dev/null and b/nix/appimagetool/runtime-i686-81de3e1 differ diff --git a/nix/appimagetool/runtime-x86_64-81de3e1 b/nix/appimagetool/runtime-x86_64-81de3e1 new file mode 100644 index 0000000..9a11608 Binary files /dev/null and b/nix/appimagetool/runtime-x86_64-81de3e1 differ diff --git a/nix/garage/default.nix b/nix/garage/default.nix index b08bd9f..c700f6d 100644 --- a/nix/garage/default.nix +++ b/nix/garage/default.nix @@ -8,6 +8,13 @@ rec { hostSystem, }: let + hostSystemTarget = builtins.getAttr hostSystem { + "x86_64-linux" = "x86_64-unknown-linux-musl"; + "aarch64-linux" = "aarch64-unknown-linux-musl"; + "i686-linux" = "i686-unknown-linux-musl"; + "armv6l-linux" = "armv6l-unknown-linux-musleabihf"; + }; + pkgs = pkgsNix.default { inherit buildSystem hostSystem; }; @@ -31,7 +38,7 @@ rec { compile = (import "${src}/nix/compile.nix") { system = buildSystem; - target = hostSystem; + target = hostSystemTarget; pkgsSrc = pkgsNix.src; cargo2nixOverlay = common.cargo2nixOverlay; diff --git a/nix/go-appimage/appimagetool-765-aarch64.AppImage b/nix/go-appimage/appimagetool-765-aarch64.AppImage deleted file mode 100755 index 8ac2829..0000000 Binary files a/nix/go-appimage/appimagetool-765-aarch64.AppImage and /dev/null differ diff --git a/nix/go-appimage/appimagetool-765-armhf.AppImage b/nix/go-appimage/appimagetool-765-armhf.AppImage deleted file mode 100755 index 795a6fa..0000000 Binary files a/nix/go-appimage/appimagetool-765-armhf.AppImage and /dev/null differ diff --git a/nix/go-appimage/appimagetool-765-i686.AppImage b/nix/go-appimage/appimagetool-765-i686.AppImage deleted file mode 100755 index 360dc7c..0000000 Binary files a/nix/go-appimage/appimagetool-765-i686.AppImage and /dev/null differ diff --git a/nix/go-appimage/appimagetool-765-x86_64.AppImage b/nix/go-appimage/appimagetool-765-x86_64.AppImage deleted file mode 100755 index 9454195..0000000 Binary files a/nix/go-appimage/appimagetool-765-x86_64.AppImage and /dev/null differ diff --git a/nix/nebula.nix b/nix/nebula.nix index b4774c5..6d2f9d6 100644 --- a/nix/nebula.nix +++ b/nix/nebula.nix @@ -20,7 +20,7 @@ vendorHash = "sha256-GvMiOEC3Y/pGG++Z+XCgLVADKymUR9shDxjx3xIz8u0="; - subPackages = [ "cmd/nebula" "cmd/nebula-cert" ]; + subPackages = [ "cmd/nebula" ]; ldflags = [ "-X main.Build=${version}" ]; } diff --git a/nix/pkgs.nix b/nix/pkgs.nix index bfab72f..e58f192 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -9,6 +9,11 @@ rec { CGO_ENABLED=0; tags = [ "netgo" "timetzdata" ]; ldflags = [ "-w" "-extldflags=-static" ]; + + # Not sure why buildGoModule doesn't handle this correctly. + GOARM = if prev.stdenv.hostPlatform.parsed.cpu.name == "armv6l" + then "6,hardfloat" + else null; }; in { buildGoModule = args: prev.buildGoModule (buildArgs // args); @@ -35,11 +40,16 @@ rec { sha256 = "sha256:1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx"; }; - supportedSystems = [ - "x86_64-linux" - "aarch64-linux" - "i686-linux" - ]; + lib = import "${src}/lib"; + + crossSystems = { + "x86_64-linux" = {config = "x86_64-linux";}; + "aarch64-linux" = lib.systems.examples.aarch64-multiplatform; + "i686-linux" = {config = "i686-linux";}; + "armv6l-linux" = lib.systems.examples.raspberryPi; + }; + + supportedSystems = builtins.attrNames crossSystems; default = { buildSystem, @@ -55,7 +65,6 @@ rec { # enabled, even if the target platform is actually the same as the build # platform (and therefore it's not really cross-compiling). So we only set # up the cross-compiling config if the target platform is different. - crossSystem.config = hostSystem; - + crossSystem = builtins.getAttr hostSystem crossSystems; })); } diff --git a/tasks/soon/code/raspberry-pi-build.md b/tasks/soon/code/raspberry-pi-build.md deleted file mode 100644 index 989d907..0000000 --- a/tasks/soon/code/raspberry-pi-build.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -type: task ---- - -# Raspberry Pi Build - -Get Isle build system to include rpi (armv7l-linux-musl)