Remove API key requirement

This commit is contained in:
NeilClack
2026-08-17 20:36:59 -05:00
parent 359ae905d7
commit 74245ee07d
16 changed files with 74 additions and 194 deletions
+13 -20
View File
@@ -34,18 +34,16 @@
};
in
{
# Version and API key are injected from the ambient environment on
# impure evals (CI sets APP_VERSION/API_KEY from the git ref and a
# secret). Pure evals (`nix flake check`, local `nix build`) can't
# see the environment, so builtins.getEnv returns "" and the
# package falls back to its 0.1.0 default / no auth header.
# Version is injected from the ambient environment on
# impure evals (CI sets APP_VERSION from the git ref). Pure evals
# (`nix flake check`, local `nix build`) can't see the
# environment, so builtins.getEnv returns "" and the package
# falls back to its 0.1.0 default.
packages.default =
let
envVersion = builtins.getEnv "APP_VERSION";
envApiKey = builtins.getEnv "API_KEY";
packageArgs =
{ apiKey = envApiKey; }
// (nixpkgs.lib.optionalAttrs (envVersion != "") { version = envVersion; });
nixpkgs.lib.optionalAttrs (envVersion != "") { version = envVersion; };
in
pkgs.callPackage ./nix/package.nix packageArgs;
@@ -53,22 +51,17 @@
inputsFrom = [ self.packages.${system}.default ];
packages = [ ];
env = {
# APP_VERSION and API_KEY are CMake cache variables with no
# default; on a fresh configure cmake seeds their cache from
# environment variables of the same name, so a plain
# `cmake -S . -B build` bakes them into the binary.
# APP_VERSION is a CMake cache variable with no default; on a
# fresh configure cmake seeds its cache from the environment
# variable of the same name, so a plain `cmake -S . -B build`
# bakes it into the binary.
APP_VERSION = "dev";
};
shellHook = ''
# Never commit the real key. Export API_KEY (or the CI name
# RWT_LIVE_API_KEY) in your ambient environment and this shell
# picks it up; empty by default (no auth header).
export API_KEY="''${API_KEY:-''${RWT_LIVE_API_KEY:-}}"
echo "RadiantWave dev shell (APP_VERSION=dev, API_KEY=$([[ -n "$API_KEY" ]] && echo set || echo unset))"
echo "RadiantWave dev shell (APP_VERSION=dev)"
echo " Configure: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug"
echo " Bake version+key: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DAPP_VERSION=\"1.2.3\" -DAPI_KEY=\"<key>\""
echo " Nix build (env version+key, impure): APP_VERSION=... API_KEY=... nix build --impure .#default"
echo " Bake version: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DAPP_VERSION=\"1.2.3\""
echo " Nix build (env version, impure): APP_VERSION=... nix build --impure .#default"
echo " Build: cmake --build build"
echo " Run: ./build/radiantwave"
echo " Tests: ./build/test_assets && ./build/test_<name>"