Compare commits

..

No commits in common. "main" and "v0.0.3" have entirely different histories.
main ... v0.0.3

26 changed files with 180 additions and 283 deletions

View File

@ -3,13 +3,8 @@
hostSystem ? buildSystem,
pkgsNix ? (import ./nix/pkgs.nix),
# We allow passing in the revision because nix flakes have their own mechanism
# for determining the git revision, and they don't have the git repo present
# to determine it off of the normal way.
revision ? null,
revision ? "dev",
releaseName ? "dev",
buildNumber ? "1",
}: let
pkgs = pkgsNix.default {
@ -25,22 +20,12 @@
in rec {
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;
inherit buildSystem hostSystem revision releaseName;
nativeBuildInputs = [ pkgsNative.git ];
goVersion = pkgs.go.version;
garageVersion = garageNix.version;
@ -51,37 +36,41 @@ in rec {
versionFile=version
echo "Version: $(cat $revisionFile)" >> "$versionFile"
echo "Platform: $hostSystem" >> "$versionFile"
echo "Go Version: $goVersion" >> "$versionFile"
echo "Garage Version: $garageVersion" >> "$versionFile"
echo "NixPkgs Version: $nixpkgsVersion" >> "$versionFile"
echo "Build Platform: $buildSystem" >> "$versionFile"
echo "Release: $releaseName" >> "$versionFile"
echo "Platform: $hostSystem" >> "$versionFile"
echo "Git Revision: $revision" >> "$versionFile"
echo "Go Version: $goVersion" >> "$versionFile"
echo "Garage Version: $garageVersion" >> "$versionFile"
echo "NixPkgs Version: $nixpkgsVersion" >> "$versionFile"
echo "Build Platform: $buildSystem" >> "$versionFile"
mkdir -p "$out"
cp "$versionFile" "$out"/version
mkdir -p "$out"/share
cp "$versionFile" "$out"/share
'';
};
entrypoint = {
systemRoot ? null,
}: (pkgs.buildGoModule {
pname = "isle-entrypoint";
version = builtins.readFile revisionFile;
goBinaries = pkgs.buildGoModule {
pname = "isle-go-binaries";
version = "unstable";
# If this seems pointless, that's because it is! buildGoModule doesn't like
# it if the src derivation's name ends in "-go". So this mkDerivation here
# only serves to give buildGoModule a src derivation with a name it likes.
src = pkgs.runCommand "isle-go-src" {} ''cp -r "${./go}" "$out"'';
src = pkgs.stdenv.mkDerivation {
name = "isle-go-src";
src = ./go;
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
cp -r "$src" "$out"
'';
};
vendorHash = "sha256-uq+UgoVKqMUE4hEVlMFQnZuyFOilUyZDmiy7ASrq338=";
subPackages = [ "./cmd/entrypoint" ];
}).overrideAttrs (prev: {
ldflags = prev.ldflags ++
(if builtins.isNull systemRoot
then []
else [ "-X main.systemRoot=${systemRoot}" ]);
});
subPackages = [
"./cmd/entrypoint"
];
};
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
stdenv = pkgs.pkgsStatic.stdenv;
@ -89,28 +78,30 @@ in rec {
nebula = pkgs.callPackage ./nix/nebula.nix {};
garage = garageNix.package {
inherit pkgsNix buildSystem hostSystem;
garage = let
hostPlatform = pkgs.stdenv.hostPlatform.parsed;
in garageNix.package {
inherit pkgsNix buildSystem;
hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl";
};
appDirBase = pkgs.runCommand "isle-AppDir-base" {} ''
mkdir -p "$out"/usr/libexec/isle
cp ${dnsmasq}/bin/* "$out"/usr/libexec/isle
cp ${nebula}/bin/* "$out"/usr/libexec/isle
cp ${garage}/bin/* "$out"/usr/libexec/isle
cp ${pkgs.minio-client}/bin/* "$out"/usr/libexec/isle
appDirBase = pkgs.buildEnv {
name = "isle-AppDir-base";
paths = [
./AppDir
version
dnsmasq
nebula
garage
pkgs.minio-client
];
};
cp ${./AppDir}/* "$out"/
mkdir -p "$out"/usr/share/isle
cp ${version}/* "$out"/usr/share/isle
'';
appDir = { systemRoot ? null, }: pkgs.stdenv.mkDerivation {
appDir = pkgs.stdenv.mkDerivation {
name = "isle-AppDir";
src = appDirBase;
entrypoint = entrypoint { inherit systemRoot; };
inherit goBinaries;
builder = builtins.toFile "build.sh" ''
source $stdenv/setup
@ -118,9 +109,7 @@ in rec {
chmod +w "$out" -R
cd "$out"
mkdir -p ./usr/bin
cp $entrypoint/bin/entrypoint ./usr/bin/isle
ln -s ./usr/bin/isle ./AppRun
cp $goBinaries/bin/entrypoint ./AppRun
'';
};
@ -144,40 +133,36 @@ in rec {
];
};
appimagekit = pkgsNative.callPackage ./nix/appimagetool {
inherit hostSystem;
};
build = rec {
appImage = pkgs.stdenv.mkDerivation {
name = "isle-AppImage";
src = appDir {};
inherit revisionFile;
src = appDir;
nativeBuildInputs = [ appimagekit ];
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=$(cat $revisionFile)
export VERSION=debug
# https://github.com/probonopd/go-appimage/issues/155
unset SOURCE_DATE_EPOCH
appimagetool ./isle.AppDir
mkdir -p "$out"/bin
appimagetool ./isle.AppDir "$out"/bin/isle
mv Isle-* "$out"/bin/isle
'';
};
archPkg = ((import ./dist/linux/arch) {
inherit hostSystem releaseName buildNumber;
inherit hostSystem releaseName appImage;
pkgs = pkgsNative;
appDir = appDir { systemRoot = "/"; };
});
debPkg = ((import ./dist/linux/deb) {
inherit hostSystem releaseName buildNumber;
pkgs = pkgsNative;
appDir = appDir { systemRoot = "/"; };
});
};
}

View File

@ -2,8 +2,7 @@
pkgs,
hostSystem,
releaseName,
buildNumber ? "1",
appDir,
appImage,
}: let
cpuArch = (pkgs.lib.systems.parse.mkSystemFromString hostSystem).cpu.name;
@ -11,25 +10,33 @@
pkgbuild = pkgs.writeText "isle-arch-PKGBUILD-${releaseName}-${cpuArch}" ''
pkgname=isle
pkgver=${builtins.replaceStrings ["-"] ["_"] releaseName}
pkgrel=${buildNumber}
pkgdesc="The foundation for an autonomous community cloud infrastructure"
pkgrel=0
pkgdesc="The foundation for an autonomous community cloud infrastructure."
arch=('${cpuArch}')
url="https://code.betamike.com/micropelago/isle"
license=('AGPL-3.0-or-later')
source=('src.tar.zst')
md5sums=('SKIP')
depends=(
'fuse2'
)
# The appImage is deliberately kept separate from the src.tar.zst. For some
# reason including the appImage within the archive results in a large part
# of the binary being stripped away and some weird skeleton appImage comes
# out the other end.
source=('isle' 'src.tar.zst')
md5sums=('SKIP' 'SKIP')
noextract=('isle')
package() {
cp -r etc "$pkgdir"/etc
cp -r usr "$pkgdir"/usr
mkdir -p "$pkgdir"/usr/bin/
cp isle "$pkgdir"/usr/bin/
}
'';
linuxRoot = (import ../default.nix).buildRoot {
inherit pkgs appDir;
};
in
pkgs.stdenv.mkDerivation {
name = "isle-arch-pkg-${releaseName}-${cpuArch}";
@ -42,13 +49,28 @@ in
];
inherit pkgbuild;
src = linuxRoot;
src = appImage;
defaultDaemonYml = ../../../go/daemon/daecommon/daemon.yml;
systemdService = ../isle.service;
dontUnpack = true;
buildPhase = ''
tar -cf src.tar.zst --zstd --mode=a+rX,u+w -C "$src" .
mkdir -p root/etc/isle/
cp "$defaultDaemonYml" root/etc/isle/daemon.yml
mkdir -p root/usr/lib/sysusers.d/
cat >root/usr/lib/sysusers.d/isle.conf <<EOF
u isle - "isle Daemon"
EOF
mkdir -p root/usr/lib/systemd/system
cp "$systemdService" root/usr/lib/systemd/system/isle.service
cp $pkgbuild PKGBUILD
tar -cf src.tar.zst --zstd --mode=a+rX,u+w -C root .
cp "$src"/bin/isle isle
PKGEXT=".pkg.tar.zst" CARCH="${cpuArch}" makepkg \
--nodeps \
--config ${pkgs.pacman}/etc/makepkg.conf

View File

@ -1,73 +0,0 @@
{
pkgs,
hostSystem,
releaseName,
buildNumber ? "1",
appDir,
}: let
debArch = builtins.getAttr hostSystem {
"x86_64-linux" = "amd64";
"aarch64-linux" = "arm64";
"armv6l-linux" = "armhf";
"i686-linux" = "i386";
};
control = pkgs.writeTextDir "DEBIAN/control" ''
Package: isle
Version: ${releaseName}-${buildNumber}
Section: net
Priority: optional
Architecture: ${debArch}
Maintainer: Brian Picciano <me@mediocregopher.com>
Description: The foundation for an autonomous community cloud infrastructure
Homepage: https://code.betamike.com/micropelago/isle
'';
postinst = pkgs.writeTextDir "DEBIAN/postinst" ''
#!/bin/sh
systemctl daemon-reload
systemd-sysusers /usr/lib/sysusers.d/isle.conf
'';
postrm = pkgs.writeTextDir "DEBIAN/postrm" ''
#!/bin/sh
systemctl daemon-reload
'';
linuxRoot = (import ../default.nix).buildRoot {
inherit pkgs appDir;
};
root = pkgs.buildEnv {
name = "isle-deb-pkg-root";
paths = [
linuxRoot
control
postinst
postrm
];
};
in pkgs.stdenv.mkDerivation {
name = "isle-deb-pkg";
nativeBuildInputs = [
pkgs.zstd
pkgs.dpkg
];
src = root;
buildPhase = ''
cp -rL "$src" root
chmod +w -R root
chmod +x root/DEBIAN/post*
dpkg-deb \
--root-owner-group \
-Z zstd \
-b root isle_${releaseName}-${buildNumber}_${debArch}.deb
'';
installPhase = ''
mkdir -p "$out"
cp *.deb "$out"
'';
}

View File

@ -1,18 +0,0 @@
{
buildRoot = { pkgs, appDir}: pkgs.runCommand "isle-linux-root" {} ''
mkdir -p "$out"
cp -r ${appDir}/usr "$out"/
chmod +w -R "$out"/usr
mkdir -p "$out"/etc/isle
cp "${../../go/daemon/daecommon/daemon.yml}" "$out"/etc/isle/daemon.yml
mkdir -p "$out"/usr/lib/sysusers.d/
cat >"$out"/usr/lib/sysusers.d/isle.conf <<EOF
u isle - "isle Daemon"
EOF
mkdir -p "$out"/usr/lib/systemd/system
cp "${./isle.service}" "$out"/usr/lib/systemd/system/isle.service
'';
}

View File

@ -8,21 +8,12 @@ A release consists of:
- A file containing a signature of the hash file, created by whoever is building
the release.
Releases are named using semantic versioning: <major>.<minor>.<patch>. A
preceding "v" is NOT a part of the canonical release name, though it use used in
specific contexts.
Release artifacts are also be labeled with a suffix indicating build number, eg
"0.1.3-2" which indicates that this is of release "0.1.3". The first build of a
release is always "1". Different build numbers of the same release indicate that
no code is different, only the packaging.
## Building
*NOTE: This has only been tested from an x86_64 linux machine*
To create a release only a functional nix installation is required. Simply run
the `./release.sh` script, providing the release name and build number.
the `./release.sh` script, and input a release name when prompted.
From here an `isle` binary will be cross-compiled for all supported
platforms. This will take a long time the first time you perform it on your
@ -34,13 +25,12 @@ create the signature.
## Releasing
Release artifacts are hosted at `micropelago.net` under
`/isle/releases/v<release name>`. An `index.gmi` page should be created in that
Release artifactes are hosted at `micropelago.net` under
`/isle/releases/<release name>`. An `index.gmi` page should be created in that
directory which includes links to each artifact, as well as a changelog
detailing all new features and fixes included since the previous release.
A link to the new release should be included at `/isle/releases/index.gmi`.
Each release should be tagged in the git repo using the release name and build
number prefixed with a "v". If the build number of the release is "1" then the
tag notes should link to the `micropelago.net` release page for the release.
The release shoulld be tagged in the git repo using its release name as well,
with the tag notes linking to the `micropelago.net` page.

View File

@ -9,7 +9,6 @@ supported:
- `x86_64` (aka `amd64`)
- `aarch64` (aka `arm64`)
- `i686`
- `armv6l` (For older Raspberry Pis)
(`i686` has not been tested.)

View File

@ -43,7 +43,7 @@ var subCmdDaemon = subCmd{
networkLoader, err := network.NewLoader(
ctx,
ctx.logger.WithNamespace("network-loader"),
getBinDirPath(),
envBinDirPath,
nil,
)
if err != nil {

View File

@ -15,30 +15,18 @@ import (
"github.com/adrg/xdg"
)
const systemRootPath = ""
func getSystemRootPath() string {
if systemRootPath != "" {
return systemRootPath
func getAppDirPath() string {
appDirPath := os.Getenv("APPDIR")
if appDirPath == "" {
appDirPath = "."
}
if appDirPath := os.Getenv("APPDIR"); appDirPath != "" {
return appDirPath
}
return "/"
}
func getBinDirPath() string {
return filepath.Join(getSystemRootPath(), "usr/libexec/isle")
}
func getShareDirPath() string {
return filepath.Join(getSystemRootPath(), "usr/share/isle")
return appDirPath
}
var (
envCacheDir = sync.OnceValue(func() toolkit.Dir {
envAppDirPath = getAppDirPath()
envBinDirPath = filepath.Join(envAppDirPath, "bin")
envCacheDir = sync.OnceValue(func() toolkit.Dir {
cacheHome, err := toolkit.MkDir(xdg.CacheHome, true)
if err != nil {
panic(fmt.Errorf("creating cache directory %q: %w", xdg.CacheHome, err))
@ -54,7 +42,7 @@ var (
)
func binPath(name string) string {
return filepath.Join(getBinDirPath(), name)
return filepath.Join(envBinDirPath, name)
}
var rootCmd = subCmd{

View File

@ -17,7 +17,7 @@ var subCmdVersion = subCmd{
return fmt.Errorf("parsing flags: %w", err)
}
versionPath := filepath.Join(getShareDirPath(), "version")
versionPath := filepath.Join(envAppDirPath, "share/version")
version, err := os.ReadFile(versionPath)
if err != nil {

View File

@ -28,7 +28,7 @@ var (
if appDirPath == "" {
panic("APPDIR not set")
}
return filepath.Join(appDirPath, "usr/libexec/isle")
return filepath.Join(appDirPath, "bin")
})
ipNetCounter = new(atomic.Uint64)

40
nix/appimagetool.nix Normal file
View File

@ -0,0 +1,40 @@
{ 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
'';
}

View File

@ -1,22 +0,0 @@
{ 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} "$@"
''

View File

@ -8,13 +8,6 @@ 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;
};
@ -38,7 +31,7 @@ rec {
compile = (import "${src}/nix/compile.nix") {
system = buildSystem;
target = hostSystemTarget;
target = hostSystem;
pkgsSrc = pkgsNix.src;
cargo2nixOverlay = common.cargo2nixOverlay;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -20,7 +20,7 @@
vendorHash = "sha256-GvMiOEC3Y/pGG++Z+XCgLVADKymUR9shDxjx3xIz8u0=";
subPackages = [ "cmd/nebula" ];
subPackages = [ "cmd/nebula" "cmd/nebula-cert" ];
ldflags = [ "-X main.Build=${version}" ];
}

View File

@ -9,11 +9,6 @@ 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);
@ -40,16 +35,11 @@ rec {
sha256 = "sha256:1lr1h35prqkd1mkmzriwlpvxcb34kmhc9dnr48gkm8hh089hifmx";
};
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;
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"i686-linux"
];
default = {
buildSystem,
@ -65,6 +55,7 @@ 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 = builtins.getAttr hostSystem crossSystems;
crossSystem.config = hostSystem;
}));
}

View File

@ -1,10 +1,11 @@
{
revision ? "dev",
releaseName ? "dev",
buildNumber ? "1",
buildSystem ? builtins.currentSystem,
pkgsNix ? (import ./nix/pkgs.nix),
supportedSystems ? pkgsNix.supportedSystems,
}: let
pkgs = pkgsNix.default { inherit buildSystem; };
@ -12,24 +13,22 @@
mkRelease = hostSystem: let
build = ((import ./default.nix) {
inherit buildSystem hostSystem releaseName buildNumber;
inherit buildSystem hostSystem releaseName revision;
}).build;
in pkgs.stdenv.mkDerivation {
name = "isle-release-${hostSystem}";
inherit releaseName buildNumber hostSystem;
inherit releaseName hostSystem;
appImage = build.appImage;
archPkg = build.archPkg;
debPkg = build.debPkg;
builder = builtins.toFile "build.sh" ''
source $stdenv/setup
mkdir -p "$out"/
cp "$appImage"/bin/isle "$out"/isle-$releaseName-$buildNumber-$hostSystem.AppImage
cp "$archPkg"/* "$out"/
cp "$debPkg"/* "$out"/
cp "$appImage"/bin/isle "$out"/isle-$releaseName-$hostSystem.AppImage
cp "$archPkg"/*.tar.zst "$out"/isle-$releaseName-$hostSystem.pkg.tar.zst
'';
};

View File

@ -7,25 +7,21 @@ cd "$scriptDir"
releaseName="$1"
if [ -z "$releaseName" ]; then
echo "USAGE: $0 \"0.1.2\" [build number]"
echo "USAGE: $0 \"v0.1.2\""
exit 1
fi
buildNumber="$2"
if [ -z "$buildNumber" ]; then
buildNumber="0"
fi
releasesDir="$(pwd)/releases"
mkdir -p "$releasesDir"
echo '*' > "$releasesDir"/.gitignore
out="$releasesDir/$releaseName-$buildNumber"
rm -rf "$out"
out="$releasesDir/$releaseName"
revision=$(git rev-parse HEAD)
result=$(nix-build -v \
--argstr revision "$revision" \
--argstr releaseName "$releaseName" \
--argstr buildNumber "$buildNumber" \
--no-out-link \
release.nix \
)

View File

@ -0,0 +1,7 @@
---
type: task
---
# Raspberry Pi Build
Get Isle build system to include rpi (armv7l-linux-musl)