diff --git a/default.nix b/default.nix index 31280c0..78634e6 100644 --- a/default.nix +++ b/default.nix @@ -65,7 +65,7 @@ in rec { ''; }; - vendorHash = "sha256-R+8uCjWnWCDG7WLuSnjKnVfZwYSbjKqMPqJfMnnj6G0="; + vendorHash = "sha256-xAm2DqgXpZEErjASSZQoEH9GPwFbBh4h2cY4FWzPVZM="; subPackages = [ "./cmd/entrypoint" @@ -118,41 +118,9 @@ in rec { ''; }; - appimagetool = pkgs.callPackage ./nix/appimagetool.nix {}; - - appImage = pkgs.stdenv.mkDerivation { - name = "isle-AppImage"; - src = appDir; - - nativeBuildInputs = [ - appimagetool - ]; - - ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name; - - 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 - mv Isle-* "$out" - ''; - }; - - appImageBin = pkgs.runCommand "isle-AppImage-bin" {} '' - mkdir -p "$out"/bin - cp ${appImage} "$out"/bin/isle - ''; - tests = pkgs.writeScript "isle-tests" '' export PATH=${pkgs.lib.makeBinPath [ - appImageBin + build.appImage pkgs.busybox pkgs.yq-go pkgs.jq @@ -181,4 +149,37 @@ in rec { pkgs.go ]; }; + + build = rec { + appImage = pkgs.stdenv.mkDerivation { + name = "isle-AppImage"; + src = appDir; + + nativeBuildInputs = [ + (pkgsNative.callPackage ./nix/appimagetool.nix {}) + ]; + + ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name; + + 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 + mkdir -p "$out"/bin + mv Isle-* "$out"/bin/isle + ''; + }; + + archPkg = ((import ./dist/linux/arch) { + inherit hostSystem releaseName appImage; + pkgs = pkgsNative; + }); + }; } diff --git a/dist/linux/arch/default.nix b/dist/linux/arch/default.nix index 47e8d2f..fb44ef1 100644 --- a/dist/linux/arch/default.nix +++ b/dist/linux/arch/default.nix @@ -1,6 +1,5 @@ { pkgs, - buildSystem, hostSystem, releaseName, appImage, @@ -70,7 +69,7 @@ in cp $pkgbuild PKGBUILD tar -cf src.tar.zst --zstd --mode=a+rX,u+w -C root . - cp "$src" isle + cp "$src"/bin/isle isle PKGEXT=".pkg.tar.zst" CARCH="${cpuArch}" makepkg \ --nodeps \ diff --git a/docs/dev/building.md b/docs/dev/building.md index f3cd71c..895745e 100644 --- a/docs/dev/building.md +++ b/docs/dev/building.md @@ -18,7 +18,7 @@ You can build an AppImage for your current system by running the following from the project's root: ``` -nix-build -A appImageBin +nix-build -A build.appImage ``` The resulting binary can be found under `result/bin`. @@ -28,7 +28,20 @@ The resulting binary can be found under `result/bin`. An AppImage can be cross-compiled by passing the `hostSystem` argument: ``` -nix-build --argstr hostSystem "x86_64-linux" -A appImageBin +nix-build --argstr hostSystem "x86_64-linux" -A build.appImage ``` Supported system strings are enumerated in `nix/pkgs.nix`. + +## Alternative Build Targets + +Besides AppImage, Isle supports building alternative package types which are +targetted at different specific operating systems. Each of these has its own +`build.*` target. + +* AppImage (all OSs): `nix-build -A build.appImage` +* Arch Linux package: `nix-build -A build.archPkg` + +All targets theoretically support passing in a `hostSystem` argument to +cross-compile to a different architecture or OS, but some targets may not make +sense with some `hostSystem` values. diff --git a/flake.nix b/flake.nix index 79bfa43..93a9c87 100644 --- a/flake.nix +++ b/flake.nix @@ -1,3 +1,5 @@ +# TODO this is currently broken, garage is using builtins.currentSystem for some +# reason. { description = "isle provides the foundation for an autonomous community cloud infrastructure"; @@ -16,7 +18,7 @@ }; in - defaultAttrs.appImage + defaultAttrs.build.appImage ); pkgsForBuildSystem = (buildSystem: { diff --git a/release.nix b/release.nix index 1ee9c07..172f33d 100644 --- a/release.nix +++ b/release.nix @@ -12,24 +12,22 @@ mkRelease = hostSystem: let - appImage = ((import ./default.nix) { + build = ((import ./default.nix) { inherit buildSystem hostSystem releaseName revision; - }).appImage; - - archPkg = ((import ./dist/linux/arch) { - inherit pkgs buildSystem hostSystem releaseName appImage; - }); + }).build; in pkgs.stdenv.mkDerivation { name = "isle-release-${hostSystem}"; inherit releaseName hostSystem; - inherit appImage archPkg; + + appImage = build.appImage; + archPkg = build.archPkg; builder = builtins.toFile "build.sh" '' source $stdenv/setup mkdir -p "$out"/ - cp "$appImage" "$out"/isle-$releaseName-$hostSystem.AppImage + cp "$appImage"/bin/isle "$out"/isle-$releaseName-$hostSystem.AppImage cp "$archPkg"/*.tar.zst "$out"/isle-$releaseName-$hostSystem.pkg.tar.zst ''; };