2021-04-20 21:31:37 +00:00
|
|
|
{
|
|
|
|
|
2022-10-20 20:30:30 +00:00
|
|
|
pkgsAttrs ? (import ./nix/pkgs.nix),
|
2021-04-20 21:31:37 +00:00
|
|
|
bootstrap ? null,
|
2022-11-16 16:43:41 +00:00
|
|
|
releaseName ? "debug",
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2022-10-20 20:30:30 +00:00
|
|
|
}: let
|
|
|
|
|
|
|
|
pkgs = pkgsAttrs.pkgs;
|
|
|
|
|
|
|
|
in rec {
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
rootedBootstrap = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "cryptic-net-rooted-bootstrap";
|
|
|
|
|
|
|
|
src = bootstrap;
|
|
|
|
|
|
|
|
builder = builtins.toFile "builder.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
mkdir -p "$out"/share
|
2022-11-02 13:34:40 +00:00
|
|
|
cp "$src" "$out"/share/bootstrap.yml
|
2021-04-20 21:31:37 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
version = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "cryptic-net-version";
|
|
|
|
|
|
|
|
buildInputs = [ pkgs.git pkgs.go ];
|
2022-10-20 20:30:30 +00:00
|
|
|
|
2021-04-20 21:31:37 +00:00
|
|
|
src = ./.;
|
2022-11-16 16:43:41 +00:00
|
|
|
inherit bootstrap releaseName;
|
2022-10-20 20:30:30 +00:00
|
|
|
nixPkgsVersion = pkgsAttrs.version;
|
|
|
|
nixPkgsRev = pkgsAttrs.rev;
|
|
|
|
builtByUser = builtins.getEnv "USER";
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
builder = builtins.toFile "builder.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
versionFile=version
|
|
|
|
|
2022-10-20 20:30:30 +00:00
|
|
|
cp -r "$src" srcCp
|
|
|
|
|
2021-04-20 21:31:37 +00:00
|
|
|
if [ "$bootstrap" != "" ]; then
|
|
|
|
hostName=$(tar -xzf "$bootstrap" --to-stdout ./hostname)
|
|
|
|
echo "Built for host: $hostName" >> "$versionFile"
|
|
|
|
fi
|
|
|
|
|
2022-11-16 16:43:41 +00:00
|
|
|
echo "Release: $releaseName" >> "$versionFile"
|
2022-10-20 20:30:30 +00:00
|
|
|
echo "Build date: $(date) ($(date +%s))" >> "$versionFile"
|
|
|
|
echo "Built by: $builtByUser" >> "$versionFile"
|
|
|
|
echo "Git rev: $(cd srcCp && git describe --always --long --dirty=' (dirty)')" >> "$versionFile"
|
2021-04-20 21:31:37 +00:00
|
|
|
echo "Go version: $(go version)" >> "$versionFile"
|
2022-10-20 20:30:30 +00:00
|
|
|
echo "Nixpkgs version: $nixPkgsVersion ($nixPkgsRev)" >> "$versionFile"
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
mkdir -p "$out"/share
|
|
|
|
cp "$versionFile" "$out"/share
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-10-20 20:06:22 +00:00
|
|
|
entrypoint = pkgs.callPackage ./entrypoint {};
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2022-10-26 20:18:16 +00:00
|
|
|
dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix {
|
2021-04-20 21:31:37 +00:00
|
|
|
glibcStatic = pkgs.glibc.static;
|
2022-10-26 20:18:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
nebula = pkgs.callPackage ./nix/nebula.nix {};
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2022-10-19 14:25:11 +00:00
|
|
|
garage = (pkgs.callPackage ./nix/garage.nix {}).env;
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
waitFor = pkgs.callPackage ./nix/wait-for.nix {};
|
|
|
|
|
|
|
|
appDir = pkgs.buildEnv {
|
|
|
|
name = "cryptic-net-AppDir";
|
|
|
|
paths = [
|
|
|
|
|
|
|
|
./AppDir
|
|
|
|
version
|
|
|
|
dnsmasq
|
2022-10-26 20:18:16 +00:00
|
|
|
nebula
|
2021-04-20 21:31:37 +00:00
|
|
|
garage
|
2022-10-20 20:06:22 +00:00
|
|
|
entrypoint
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
] ++ (if bootstrap != null then [ rootedBootstrap ] else []);
|
|
|
|
};
|
|
|
|
|
|
|
|
appimagetool = pkgs.callPackage ./nix/appimagetool.nix {};
|
|
|
|
|
|
|
|
appImage = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "cryptic-net-AppImage";
|
|
|
|
src = appDir;
|
|
|
|
|
|
|
|
buildInputs = [ appimagetool ];
|
|
|
|
|
|
|
|
ARCH = "x86_64";
|
|
|
|
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
cp -rL "$src" cryptic-net
|
|
|
|
chmod +w cryptic-net -R
|
2022-11-16 16:43:41 +00:00
|
|
|
appimagetool cryptic-net "$out"
|
2021-04-20 21:31:37 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-11-16 16:43:41 +00:00
|
|
|
release = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "cryptic-net-AppImage";
|
|
|
|
inherit appImage releaseName;
|
|
|
|
|
|
|
|
buildInputs = [ pkgs.coreutils ];
|
|
|
|
|
|
|
|
builder = builtins.toFile "build.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
mkdir -p "$out"
|
|
|
|
cp "$appImage" "$out"/cryptic-net-$releaseName-linux-amd64
|
|
|
|
(cd "$out" && sha256sum * > sha256.txt)
|
|
|
|
'';
|
|
|
|
};
|
2021-04-20 21:31:37 +00:00
|
|
|
}
|