From 2749626e4a2d281349723450f4d4af095504b072 Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 7 Dec 2022 16:33:34 +0700 Subject: [PATCH] fix app detect-projects --- src/apps/detect-projects/default.nix | 5 +++-- src/lib.nix | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/apps/detect-projects/default.nix b/src/apps/detect-projects/default.nix index 26b2c80f..8ff39398 100644 --- a/src/apps/detect-projects/default.nix +++ b/src/apps/detect-projects/default.nix @@ -13,9 +13,10 @@ utils.writePureShellScriptBin '' set -e - export source=$(realpath .) + # Use $1 as source if set. Otherwise default to ./. + export source=$(realpath ''${1:-.}) ${apps.callNixWithD2N} eval --json \ - "dream2nix.framework.functions.discoverers.discoverProjects2 {source = builtins.getEnv \"source\";}" \ + "dream2nix.functions.discoverers.discoverProjects2 {source = builtins.getEnv \"source\";}" \ | yq --toml-output '' diff --git a/src/lib.nix b/src/lib.nix index 6b704f06..cd40c854 100644 --- a/src/lib.nix +++ b/src/lib.nix @@ -71,7 +71,7 @@ }: initDream2nix (loadConfig config) pkgs; - missingProjectsError = '' + missingProjectsError = source: '' Please pass `projects` to makeFlakeOutputs. `projects` can be: - an attrset @@ -80,7 +80,7 @@ To generate a projects.toml file automatically: 1. execute: - nix run github:nix-community/dream2nix#discover-projects > projects.toml + nix run github:nix-community/dream2nix#detect-projects ${source} > projects.toml 2. review the ./projects.toml and edit it if necessary. 3. pass `projects = ./projects.toml` to makeFlakeOutputs. @@ -129,7 +129,7 @@ else if l.isPath givenProjects then if ! l.pathExists givenProjects - then throw missingProjectsError + then throw (missingProjectsError source) else if l.hasSuffix ".toml" (l.toString givenProjects) then l.fromTOML (l.readFile givenProjects) else l.fromJSON (l.readFile givenProjects) @@ -164,7 +164,7 @@ }) else if autoProjects == true then discoveredProjects - else throw missingProjectsError; + else throw (missingProjectsError source); allBuilderOutputs = l.mapAttrs