172 lines
4.0 KiB
Nix
172 lines
4.0 KiB
Nix
{
|
|
buildSystem ? builtins.currentSystem,
|
|
hostSystem ? buildSystem,
|
|
pkgsNix ? (import ./nix/pkgs.nix),
|
|
|
|
revision ? null,
|
|
releaseName ? "dev",
|
|
}: let
|
|
|
|
pkgs = pkgsNix.default {
|
|
inherit buildSystem hostSystem;
|
|
};
|
|
|
|
pkgsNative = pkgsNix.default {
|
|
inherit buildSystem;
|
|
hostSystem = buildSystem;
|
|
};
|
|
|
|
garageNix = (import ./nix/garage);
|
|
|
|
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 releaseName;
|
|
|
|
goVersion = pkgs.go.version;
|
|
garageVersion = garageNix.version;
|
|
nixpkgsVersion = pkgsNix.version;
|
|
|
|
builder = builtins.toFile "builder.sh" ''
|
|
source $stdenv/setup
|
|
|
|
versionFile=version
|
|
|
|
echo "Release: $releaseName" >> "$versionFile"
|
|
echo "Platform: $hostSystem" >> "$versionFile"
|
|
echo "Git Revision: $(cat $revisionFile)" >> "$versionFile"
|
|
echo "Go Version: $goVersion" >> "$versionFile"
|
|
echo "Garage Version: $garageVersion" >> "$versionFile"
|
|
echo "NixPkgs Version: $nixpkgsVersion" >> "$versionFile"
|
|
echo "Build Platform: $buildSystem" >> "$versionFile"
|
|
|
|
mkdir -p "$out"/share
|
|
cp "$versionFile" "$out"/share
|
|
'';
|
|
};
|
|
|
|
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"
|
|
'';
|
|
};
|
|
|
|
vendorHash = "sha256-uq+UgoVKqMUE4hEVlMFQnZuyFOilUyZDmiy7ASrq338=";
|
|
|
|
subPackages = [
|
|
"./cmd/entrypoint"
|
|
];
|
|
};
|
|
|
|
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
|
|
stdenv = pkgs.pkgsStatic.stdenv;
|
|
});
|
|
|
|
nebula = pkgs.callPackage ./nix/nebula.nix {};
|
|
|
|
garage = garageNix.package {
|
|
inherit pkgsNix buildSystem hostSystem;
|
|
};
|
|
|
|
appDirBase = pkgs.buildEnv {
|
|
name = "isle-AppDir-base";
|
|
paths = [
|
|
./AppDir
|
|
version
|
|
dnsmasq
|
|
nebula
|
|
garage
|
|
pkgs.minio-client
|
|
];
|
|
};
|
|
|
|
appDir = pkgs.stdenv.mkDerivation {
|
|
name = "isle-AppDir";
|
|
|
|
src = appDirBase;
|
|
inherit goBinaries;
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
source $stdenv/setup
|
|
cp -rL "$src" "$out"
|
|
chmod +w "$out" -R
|
|
|
|
cd "$out"
|
|
cp $goBinaries/bin/entrypoint ./AppRun
|
|
'';
|
|
};
|
|
|
|
devShell = pkgs.mkShell {
|
|
buildInputs = [
|
|
pkgs.go
|
|
pkgs.golangci-lint
|
|
pkgs.gopls
|
|
(pkgs.callPackage ./nix/gowrap.nix {})
|
|
pkgs.go-mockery
|
|
];
|
|
shellHook = ''
|
|
true # placeholder
|
|
'';
|
|
};
|
|
|
|
testShell = pkgs.mkShell {
|
|
APPDIR = appDirBase;
|
|
buildInputs = [
|
|
pkgs.go
|
|
];
|
|
};
|
|
|
|
appimagekit = pkgsNative.callPackage ./nix/appimagetool {
|
|
inherit hostSystem;
|
|
};
|
|
|
|
build = rec {
|
|
appImage = pkgs.stdenv.mkDerivation {
|
|
name = "isle-AppImage";
|
|
src = appDir;
|
|
inherit revisionFile;
|
|
|
|
nativeBuildInputs = [ appimagekit ];
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
source $stdenv/setup
|
|
cp -rL "$src" isle.AppDir
|
|
chmod +w isle.AppDir -R
|
|
|
|
export VERSION=$(cat $revisionFile)
|
|
mkdir -p "$out"/bin
|
|
appimagetool ./isle.AppDir "$out"/bin/isle
|
|
'';
|
|
};
|
|
|
|
archPkg = ((import ./dist/linux/arch) {
|
|
inherit hostSystem releaseName appImage;
|
|
pkgs = pkgsNative;
|
|
});
|
|
};
|
|
}
|