{ pkgsAttrs ? (import ./nix/pkgs.nix), bootstrap ? null, releaseName ? "debug", }: let pkgs = pkgsAttrs.pkgs; in rec { rootedBootstrap = pkgs.stdenv.mkDerivation { name = "cryptic-net-rooted-bootstrap"; src = bootstrap; builder = builtins.toFile "builder.sh" '' source $stdenv/setup mkdir -p "$out"/share cp "$src" "$out"/share/bootstrap.yml ''; }; version = pkgs.stdenv.mkDerivation { name = "cryptic-net-version"; buildInputs = [ pkgs.git pkgs.go ]; src = ./.; inherit releaseName; nixPkgsVersion = pkgsAttrs.version; nixPkgsRev = pkgsAttrs.rev; builtByUser = builtins.getEnv "USER"; builder = builtins.toFile "builder.sh" '' source $stdenv/setup versionFile=version cp -r "$src" srcCp echo "Release: $releaseName" >> "$versionFile" echo "Git Revision: $(cd srcCp && git rev-parse HEAD)" >> "$versionFile" echo "Build date: $(date) ($(date +%s))" >> "$versionFile" echo "Built by: $builtByUser" >> "$versionFile" echo "Go version: $(go version)" >> "$versionFile" echo "Nixpkgs version: $nixPkgsVersion ($nixPkgsRev)" >> "$versionFile" mkdir -p "$out"/share cp "$versionFile" "$out"/share ''; }; entrypoint = pkgs.callPackage ./entrypoint {}; dnsmasq = (pkgs.callPackage ./nix/dnsmasq.nix { glibcStatic = pkgs.glibc.static; }); nebula = pkgs.callPackage ./nix/nebula.nix {}; garage = (pkgs.callPackage ./nix/garage.nix {}).env; waitFor = pkgs.callPackage ./nix/wait-for.nix {}; appDir = pkgs.buildEnv { name = "cryptic-net-AppDir"; paths = [ ./AppDir version dnsmasq nebula garage entrypoint ] ++ (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 appimagetool cryptic-net "$out" ''; }; 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) ''; }; }