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
|
|
|
|
2024-12-19 10:51:37 +00:00
|
|
|
revision ? null,
|
2023-03-25 14:58:20 +00:00
|
|
|
releaseName ? "dev",
|
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;
|
|
|
|
};
|
|
|
|
|
2024-12-15 14:33:47 +00:00
|
|
|
garageNix = (import ./nix/garage);
|
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
|
|
|
|
2024-12-19 16:49:10 +00:00
|
|
|
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 {
|
2023-08-05 21:53:17 +00:00
|
|
|
name = "isle-version";
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2024-12-19 10:51:37 +00:00
|
|
|
inherit buildSystem hostSystem revisionFile releaseName;
|
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
|
|
|
|
|
2024-12-19 10:51:37 +00:00
|
|
|
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"
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2024-12-19 19:57:09 +00:00
|
|
|
mkdir -p "$out"
|
|
|
|
cp "$versionFile" "$out"/version
|
2021-04-20 21:31:37 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-12-19 19:57:09 +00:00
|
|
|
entrypoint = {
|
|
|
|
systemRoot ? null,
|
|
|
|
}: (pkgs.buildGoModule {
|
|
|
|
pname = "isle-entrypoint";
|
|
|
|
version = builtins.readFile revisionFile;
|
2023-08-25 13:19:31 +00:00
|
|
|
|
|
|
|
# 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.
|
2024-12-19 19:57:09 +00:00
|
|
|
src = pkgs.runCommand "isle-go-src" {} ''cp -r "${./go}" "$out"'';
|
2023-08-25 13:19:31 +00:00
|
|
|
|
2024-12-18 21:20:28 +00:00
|
|
|
vendorHash = "sha256-uq+UgoVKqMUE4hEVlMFQnZuyFOilUyZDmiy7ASrq338=";
|
2024-12-19 19:57:09 +00:00
|
|
|
subPackages = [ "./cmd/entrypoint" ];
|
|
|
|
}).overrideAttrs (prev: {
|
|
|
|
ldflags = prev.ldflags ++
|
|
|
|
(if builtins.isNull systemRoot
|
|
|
|
then []
|
|
|
|
else [ "-X main.systemRoot=${systemRoot}" ]);
|
|
|
|
});
|
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
|
|
|
|
2024-12-19 16:49:10 +00:00
|
|
|
garage = garageNix.package {
|
|
|
|
inherit pkgsNix buildSystem hostSystem;
|
2023-02-15 12:56:22 +00:00
|
|
|
};
|
|
|
|
|
2024-12-19 19:57:09 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
cp ${./AppDir}/* "$out"/
|
|
|
|
|
|
|
|
mkdir -p "$out"/usr/share/isle
|
|
|
|
cp ${version}/* "$out"/usr/share/isle
|
|
|
|
'';
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2024-12-19 19:57:09 +00:00
|
|
|
appDir = { systemRoot ? null, }: pkgs.stdenv.mkDerivation {
|
2024-10-05 19:12:29 +00:00
|
|
|
name = "isle-AppDir";
|
2023-04-23 14:30:47 +00:00
|
|
|
|
2024-10-05 19:12:29 +00:00
|
|
|
src = appDirBase;
|
2024-12-19 19:57:09 +00:00
|
|
|
entrypoint = entrypoint { inherit systemRoot; };
|
2023-04-23 14:30:47 +00:00
|
|
|
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
cp -rL "$src" "$out"
|
|
|
|
chmod +w "$out" -R
|
|
|
|
|
|
|
|
cd "$out"
|
2024-12-19 19:57:09 +00:00
|
|
|
mkdir -p ./usr/bin
|
|
|
|
cp $entrypoint/bin/entrypoint ./usr/bin/isle
|
|
|
|
ln -s ./usr/bin/isle ./AppRun
|
2023-04-23 14:30:47 +00:00
|
|
|
'';
|
2021-04-20 21:31:37 +00:00
|
|
|
};
|
|
|
|
|
2024-10-05 19:12:29 +00:00
|
|
|
devShell = pkgs.mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
pkgs.go
|
|
|
|
pkgs.golangci-lint
|
2024-10-07 19:12:47 +00:00
|
|
|
pkgs.gopls
|
2024-10-05 19:12:29 +00:00
|
|
|
(pkgs.callPackage ./nix/gowrap.nix {})
|
2024-11-09 22:17:10 +00:00
|
|
|
pkgs.go-mockery
|
2024-10-05 19:12:29 +00:00
|
|
|
];
|
|
|
|
shellHook = ''
|
|
|
|
true # placeholder
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
testShell = pkgs.mkShell {
|
|
|
|
APPDIR = appDirBase;
|
|
|
|
buildInputs = [
|
|
|
|
pkgs.go
|
|
|
|
];
|
|
|
|
};
|
2024-11-03 14:23:43 +00:00
|
|
|
|
2024-12-19 16:49:10 +00:00
|
|
|
appimagekit = pkgsNative.callPackage ./nix/appimagetool {
|
|
|
|
inherit hostSystem;
|
|
|
|
};
|
|
|
|
|
2024-11-03 14:23:43 +00:00
|
|
|
build = rec {
|
|
|
|
appImage = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "isle-AppImage";
|
2024-12-19 19:57:09 +00:00
|
|
|
src = appDir {};
|
2024-12-19 16:49:10 +00:00
|
|
|
inherit revisionFile;
|
2024-11-03 14:23:43 +00:00
|
|
|
|
2024-12-19 16:49:10 +00:00
|
|
|
nativeBuildInputs = [ appimagekit ];
|
2024-11-03 14:23:43 +00:00
|
|
|
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
cp -rL "$src" isle.AppDir
|
|
|
|
chmod +w isle.AppDir -R
|
|
|
|
|
2024-12-19 16:49:10 +00:00
|
|
|
export VERSION=$(cat $revisionFile)
|
2024-11-03 14:23:43 +00:00
|
|
|
mkdir -p "$out"/bin
|
2024-12-19 16:49:10 +00:00
|
|
|
appimagetool ./isle.AppDir "$out"/bin/isle
|
2024-11-03 14:23:43 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
archPkg = ((import ./dist/linux/arch) {
|
2024-12-19 19:57:09 +00:00
|
|
|
inherit hostSystem releaseName;
|
2024-11-03 14:23:43 +00:00
|
|
|
pkgs = pkgsNative;
|
2024-12-19 19:57:09 +00:00
|
|
|
appDir = appDir { systemRoot = "/"; };
|
2024-11-03 14:23:43 +00:00
|
|
|
});
|
|
|
|
};
|
2021-04-20 21:31:37 +00:00
|
|
|
}
|