isle/default.nix

137 lines
3.0 KiB
Nix
Raw Normal View History

# TODO
# - allow injecting a bootstrap file
2023-02-15 13:58:47 +00:00
{
2023-02-15 13:58:47 +00:00
buildSystem ? builtins.currentSystem,
hostSystem ? builtins.currentSystem,
revision ? "",
releaseName ? "debug",
}: let
pkgsNix = (import ./nix/pkgs.nix);
pkgs = pkgsNix.default {
inherit buildSystem hostSystem;
};
2023-02-15 13:58:47 +00:00
garageNix = (import ./nix/garage.nix);
2023-02-15 13:58:47 +00:00
in rec {
2022-10-20 20:30:30 +00:00
version = pkgs.stdenv.mkDerivation {
name = "cryptic-net-version";
2023-02-15 13:58:47 +00:00
inherit revision hostSystem releaseName;
repoSrc = ./.;
nativeBuildInputs = [ pkgs.git ];
2022-10-20 20:30:30 +00:00
# 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;
2023-02-15 13:58:47 +00:00
garageVersion = garageNix.version;
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
versionFile=version
2023-02-15 13:58:47 +00:00
if [ "$revision" = "" ]; then
cp -r "$repoSrc" repoSrcCp
2023-02-15 13:58:47 +00:00
revision="$(cd repoSrcCp && git rev-parse HEAD)"
fi
2022-10-20 20:30:30 +00:00
echo "Release $releaseName" >> "$versionFile"
echo "System: $hostSystem" >> "$versionFile"
2023-02-15 13:58:47 +00:00
echo "Git Revision: $revision" >> "$versionFile"
echo "Go Version: $goVersion" >> "$versionFile"
echo "Garage Version: $garageVersion" >> "$versionFile"
mkdir -p "$out"/share
cp "$versionFile" "$out"/share
'';
};
entrypoint = pkgs.callPackage ./entrypoint {};
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
stdenv = pkgs.pkgsStatic.stdenv;
});
nebula = pkgs.callPackage ./nix/nebula.nix {};
garage = let
hostPlatform = pkgs.stdenv.hostPlatform.parsed;
2023-02-15 13:58:47 +00:00
in pkgs.callPackage garageNix.package {
inherit buildSystem;
hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl";
pkgsSrc = pkgsNix.src;
};
appDir = pkgs.buildEnv {
name = "cryptic-net-AppDir";
paths = [
./AppDir
version
dnsmasq
nebula
garage
pkgs.minio-client
entrypoint
];
};
appimagetool = pkgs.callPackage ./nix/appimagetool.nix {};
appImage = pkgs.stdenv.mkDerivation {
name = "cryptic-net-AppImage";
src = appDir;
nativeBuildInputs = [
appimagetool
];
2023-02-15 13:58:47 +00:00
ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name;
builder = builtins.toFile "build.sh" ''
source $stdenv/setup
cp -rL "$src" cryptic-net.AppDir
chmod +w cryptic-net.AppDir -R
export VERSION=debug
# https://github.com/probonopd/go-appimage/issues/155
unset SOURCE_DATE_EPOCH
appimagetool ./cryptic-net.AppDir
mkdir -p "$out"/bin
chmod +w "$out" -R
mv Cryptic_Net-* "$out"/bin/cryptic-net
'';
};
2022-11-16 16:43:41 +00:00
release = pkgs.stdenv.mkDerivation {
name = "cryptic-net-release";
inherit appImage;
2022-11-16 16:43:41 +00:00
nativeBuildInputs = [ pkgs.coreutils ];
2022-11-16 16:43:41 +00:00
builder = builtins.toFile "build.sh" ''
source $stdenv/setup
mkdir -p "$out"
cp "$appImage" "$out"/cryptic-net
2022-11-16 16:43:41 +00:00
(cd "$out" && sha256sum * > sha256.txt)
'';
};
}