diff --git a/main.c b/main.c index 4179baa..9468e84 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,8 @@ #include "config.h" #include "dyn_array.h" +const char *ENV_SPEC_ROOT_DIR = "SPEC_ROOT_DIR"; + int main(int argc, char **argv) { int num = 0; @@ -12,8 +14,10 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + const char *root_dir = getenv(ENV_SPEC_ROOT_DIR); + struct Config config; - switch (load_config(argv[1], &config)) { + switch (load_config(root_dir, argv[1], &config)) { case ENV_SPEC_ROOT_DIR_MISSING: fprintf(stderr, "Must specify $SPEC_ROOT_DIR environment variable."); exit(EXIT_FAILURE); @@ -23,9 +27,6 @@ int main(int argc, char **argv) { case INVALID_TARGET: fprintf(stderr, "Target spec `%s` is invalid.", argv[1]); exit(EXIT_FAILURE); - default: - // A return value of `0` indicates no issue. - break; } free_config(&config); diff --git a/specs/clang/run.sh b/specs/clang/run.sh index fcdce00..a8741c7 100644 --- a/specs/clang/run.sh +++ b/specs/clang/run.sh @@ -1,7 +1,3 @@ #!/usr/bin/env bash -if [ -z "$VERSION" ]; then - VERSION="default" -fi - -cp "$VERSION/flake.nix" "$OUT" +cp -r "template/*" "$OUT" diff --git a/specs/clang/spec.json b/specs/clang/spec.json deleted file mode 100644 index 61b562d..0000000 --- a/specs/clang/spec.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "versions": [ - "default" - ] -} diff --git a/specs/clang/template/.envrc b/specs/clang/template/.envrc new file mode 100644 index 0000000..b9238c3 --- /dev/null +++ b/specs/clang/template/.envrc @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +use flake diff --git a/specs/clang/default/flake.nix b/specs/clang/template/flake.nix similarity index 93% rename from specs/clang/default/flake.nix rename to specs/clang/template/flake.nix index 0b6771f..8d05f24 100644 --- a/specs/clang/default/flake.nix +++ b/specs/clang/template/flake.nix @@ -1,6 +1,6 @@ { description = '' - An opinionated clang flake. + An opinionated clang flake. ''; inputs = { @@ -14,7 +14,6 @@ pkgs = nixpkgs.legacyPackages.${system}; codelldb = pkgs.writeShellScriptBin "codelldb" '' - #!/usr/bin/env bash exec ${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb "$@" ''; in diff --git a/specs/clang/template/main.c b/specs/clang/template/main.c new file mode 100644 index 0000000..7cbc9bc --- /dev/null +++ b/specs/clang/template/main.c @@ -0,0 +1,3 @@ +#include + +int main(int argc, char **argv) { return EXIT_SUCCESS; }