2023-02-15 13:58:47 +00:00
|
|
|
{
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-02-15 13:58:47 +00:00
|
|
|
buildSystem ? builtins.currentSystem,
|
2023-03-25 14:58:20 +00:00
|
|
|
hostSystem ? buildSystem,
|
|
|
|
pkgsNix ? (import ./nix/pkgs.nix),
|
2023-02-15 13:58:47 +00:00
|
|
|
|
2023-08-30 16:24:09 +00:00
|
|
|
revision ? "dev",
|
2023-03-25 14:58:20 +00:00
|
|
|
releaseName ? "dev",
|
2023-02-15 13:58:47 +00:00
|
|
|
|
2023-02-15 14:09:31 +00:00
|
|
|
bootstrap ? null,
|
|
|
|
|
2023-02-15 13:58:47 +00:00
|
|
|
}: let
|
2023-02-14 19:46:28 +00:00
|
|
|
|
2023-02-15 12:56:22 +00:00
|
|
|
pkgs = pkgsNix.default {
|
|
|
|
inherit buildSystem hostSystem;
|
2023-02-14 19:46:28 +00:00
|
|
|
};
|
|
|
|
|
2023-03-25 14:58:20 +00:00
|
|
|
pkgsNative = pkgsNix.default {
|
|
|
|
inherit buildSystem;
|
|
|
|
hostSystem = buildSystem;
|
|
|
|
};
|
|
|
|
|
2023-02-15 13:58:47 +00:00
|
|
|
garageNix = (import ./nix/garage.nix);
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-02-15 13:58:47 +00:00
|
|
|
in rec {
|
2022-10-20 20:30:30 +00:00
|
|
|
|
2021-04-20 21:31:37 +00:00
|
|
|
version = pkgs.stdenv.mkDerivation {
|
2023-08-05 21:53:17 +00:00
|
|
|
name = "isle-version";
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-03-25 14:58:20 +00:00
|
|
|
inherit buildSystem hostSystem revision releaseName;
|
2023-01-29 17:57:55 +00:00
|
|
|
|
2023-03-25 14:58:20 +00:00
|
|
|
nativeBuildInputs = [ pkgsNative.git ];
|
2022-10-20 20:30:30 +00:00
|
|
|
|
2023-01-29 17:57:55 +00:00
|
|
|
goVersion = pkgs.go.version;
|
2023-02-15 13:58:47 +00:00
|
|
|
garageVersion = garageNix.version;
|
2023-02-15 14:09:31 +00:00
|
|
|
nixpkgsVersion = pkgsNix.version;
|
|
|
|
|
2021-04-20 21:31:37 +00:00
|
|
|
builder = builtins.toFile "builder.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
versionFile=version
|
|
|
|
|
2023-03-25 14:58:20 +00:00
|
|
|
echo "Release: $releaseName" >> "$versionFile"
|
|
|
|
echo "Platform: $hostSystem" >> "$versionFile"
|
2023-02-15 14:09:31 +00:00
|
|
|
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"
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
mkdir -p "$out"/share
|
|
|
|
cp "$versionFile" "$out"/share
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-08-25 13:19:31 +00:00
|
|
|
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.stdenv.mkDerivation {
|
|
|
|
name = "isle-go-src";
|
|
|
|
src = ./go;
|
|
|
|
builder = builtins.toFile "builder.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
cp -r "$src" "$out"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vendorSha256 = "sha256-P1TXG0fG8/6n37LmM5ApYctqoZzJFlvFAO2Zl85SVvk=";
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"./cmd/entrypoint"
|
|
|
|
];
|
|
|
|
};
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2022-10-26 20:18:16 +00:00
|
|
|
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
|
2023-01-25 17:50:36 +00:00
|
|
|
stdenv = pkgs.pkgsStatic.stdenv;
|
2022-10-26 20:18:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
nebula = pkgs.callPackage ./nix/nebula.nix {};
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-02-15 12:56:22 +00:00
|
|
|
garage = let
|
|
|
|
|
|
|
|
hostPlatform = pkgs.stdenv.hostPlatform.parsed;
|
|
|
|
|
2023-02-15 13:58:47 +00:00
|
|
|
in pkgs.callPackage garageNix.package {
|
2023-02-15 12:56:22 +00:00
|
|
|
|
|
|
|
inherit buildSystem;
|
|
|
|
hostSystem = "${hostPlatform.cpu.name}-unknown-${hostPlatform.kernel.name}-musl";
|
|
|
|
pkgsSrc = pkgsNix.src;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2023-02-15 14:09:31 +00:00
|
|
|
rootedBootstrap = pkgs.stdenv.mkDerivation {
|
2023-08-05 21:53:17 +00:00
|
|
|
name = "isle-rooted-bootstrap";
|
2023-02-15 14:09:31 +00:00
|
|
|
|
|
|
|
src = bootstrap;
|
|
|
|
|
|
|
|
builder = builtins.toFile "builder.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
mkdir -p "$out"/share
|
|
|
|
cp "$src" "$out"/share/bootstrap.yml
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-04-23 14:30:47 +00:00
|
|
|
appDir = pkgs.stdenv.mkDerivation {
|
2023-08-05 21:53:17 +00:00
|
|
|
name = "isle-AppDir";
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-04-23 14:30:47 +00:00
|
|
|
src = pkgs.buildEnv {
|
2023-08-05 21:53:17 +00:00
|
|
|
name = "isle-AppDir-base";
|
2023-04-23 14:30:47 +00:00
|
|
|
paths = [
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-04-23 14:30:47 +00:00
|
|
|
./AppDir
|
|
|
|
version
|
|
|
|
dnsmasq
|
|
|
|
nebula
|
|
|
|
garage
|
|
|
|
pkgs.minio-client
|
2023-08-25 13:19:31 +00:00
|
|
|
goBinaries
|
2023-04-23 14:30:47 +00:00
|
|
|
|
|
|
|
] ++ (if bootstrap != null then [ rootedBootstrap ] else []);
|
|
|
|
};
|
|
|
|
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
cp -rL "$src" "$out"
|
|
|
|
chmod +w "$out" -R
|
|
|
|
|
|
|
|
cd "$out"
|
|
|
|
cp ./bin/entrypoint ./AppRun
|
|
|
|
'';
|
2021-04-20 21:31:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
appimagetool = pkgs.callPackage ./nix/appimagetool.nix {};
|
|
|
|
|
|
|
|
appImage = pkgs.stdenv.mkDerivation {
|
2023-08-05 21:53:17 +00:00
|
|
|
name = "isle-AppImage";
|
2021-04-20 21:31:37 +00:00
|
|
|
src = appDir;
|
|
|
|
|
2023-01-28 21:57:06 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
appimagetool
|
|
|
|
];
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2023-02-15 13:58:47 +00:00
|
|
|
ARCH = pkgs.stdenv.hostPlatform.parsed.cpu.name;
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
|
|
source $stdenv/setup
|
2023-08-05 21:53:17 +00:00
|
|
|
cp -rL "$src" isle.AppDir
|
|
|
|
chmod +w isle.AppDir -R
|
2023-01-28 21:57:06 +00:00
|
|
|
|
|
|
|
export VERSION=debug
|
|
|
|
|
|
|
|
# https://github.com/probonopd/go-appimage/issues/155
|
|
|
|
unset SOURCE_DATE_EPOCH
|
2023-01-29 14:31:11 +00:00
|
|
|
|
2023-08-05 21:53:17 +00:00
|
|
|
appimagetool ./isle.AppDir
|
2023-01-25 17:50:36 +00:00
|
|
|
|
2023-01-28 21:57:06 +00:00
|
|
|
mkdir -p "$out"/bin
|
|
|
|
chmod +w "$out" -R
|
2023-08-05 21:53:17 +00:00
|
|
|
mv Isle-* "$out"/bin/isle
|
2021-04-20 21:31:37 +00:00
|
|
|
'';
|
|
|
|
};
|
2023-08-30 16:16:19 +00:00
|
|
|
|
|
|
|
tests = pkgs.writeShellScript "isle-tests" ''
|
|
|
|
export PATH=$PATH:${appImage}/bin
|
|
|
|
test_dir=${./tests}
|
2023-08-30 18:08:40 +00:00
|
|
|
exec $SHELL $test_dir/entrypoint.sh "$@"
|
2023-08-30 16:16:19 +00:00
|
|
|
'';
|
2021-04-20 21:31:37 +00:00
|
|
|
}
|