diff --git a/src/scaffold/app/nix.rs b/src/scaffold/app/nix.rs index 55864e390..57fda1978 100644 --- a/src/scaffold/app/nix.rs +++ b/src/scaffold/app/nix.rs @@ -7,10 +7,11 @@ use std::process::{Command, Stdio}; use crate::error::{ScaffoldError, ScaffoldResult}; use crate::file_tree::*; +use crate::scaffold::web_app::package_manager::PackageManager; use super::git::is_inside_work_tree; -pub fn flake_nix(holo_enabled: bool) -> FileTree { +pub fn flake_nix(holo_enabled: bool, package_manager: &PackageManager) -> FileTree { let holo_inputs = holo_enabled .then_some( r#" @@ -52,17 +53,17 @@ pub fn flake_nix(holo_enabled: bool) -> FileTree { rust # For Rust development, with the WASM target included for zome builds ]) ++ (with pkgs; [ nodejs_20 - nodePackages.pnpm - yarn-berry - bun binaryen {} + {} ]); }}; }}; }}; }}"#, - holo_inputs, holo_packages + holo_inputs, + package_manager.nixpkg().unwrap_or_default(), + holo_packages )) } diff --git a/src/scaffold/web_app.rs b/src/scaffold/web_app.rs index f76a95d9d..9b948ac01 100644 --- a/src/scaffold/web_app.rs +++ b/src/scaffold/web_app.rs @@ -42,7 +42,10 @@ pub fn scaffold_web_app( app_file_tree .dir_content_mut() .ok_or(ScaffoldError::PathNotFound(PathBuf::new()))? - .insert("flake.nix".into(), flake_nix(holo_enabled)); + .insert( + "flake.nix".into(), + flake_nix(holo_enabled, &package_manager), + ); } if package_manager == PackageManager::Pnpm { diff --git a/src/scaffold/web_app/package_manager.rs b/src/scaffold/web_app/package_manager.rs index c5939f417..6755679fe 100644 --- a/src/scaffold/web_app/package_manager.rs +++ b/src/scaffold/web_app/package_manager.rs @@ -46,6 +46,18 @@ impl PackageManager { Ok(managers[selection]) } + /// Get's the the package manager's nixpkg that should be used with the generated + /// flake.nix + pub fn nixpkg(&self) -> Option<&str> { + match self { + PackageManager::Bun => Some("bun"), + PackageManager::Pnpm => Some("nodePackages.pnpm"), + PackageManager::Yarn => Some("yarn-berry"), + // npm is already included with nodejs_20 + PackageManager::Npm => None, + } + } + /// Checks if the specified lockfile exists in the provided file tree. pub fn lockfile_exists(app_file_tree: &FileTree, path: &Path) -> bool { let v = path diff --git a/templates/custom-template/custom-template/flake.nix b/templates/custom-template/custom-template/flake.nix index fe9fcc2c3..9e90f5bc5 100644 --- a/templates/custom-template/custom-template/flake.nix +++ b/templates/custom-template/custom-template/flake.nix @@ -25,9 +25,6 @@ rust # For Rust development, with the WASM target included for zome builds ]) ++ (with pkgs; [ nodejs_20 - nodePackages.pnpm - yarn - bun binaryen ]); };