Repository: railwayapp/nixpacks
Pull request #429 (2022-08-22 17:06:28)

Update nixpkgs archive
[`54060e816971276da05970a983487a25810c38a7`](https://github.com/NixOS/nixpkgs/commit/54060e816971276da05970a983487a25810c38a7)


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 12d5203..3127cfd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -367,7 +367,7 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
 [[package]]
 name = "nixpacks"
-version = "0.3.3"
+version = "0.3.4"
 dependencies = [
  "anyhow",
  "base64",
diff --git a/Cargo.toml b/Cargo.toml
index 5a19ad9..7664bde 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "nixpacks"
-version = "0.3.3"
+version = "0.3.4"
 edition = "2021"
 license = "MIT"
 authors = ["Railway <contact@railway.app>"]
diff --git a/src/nixpacks/plan/generator.rs b/src/nixpacks/plan/generator.rs
index bb41e48..2dda15e 100644
--- a/src/nixpacks/plan/generator.rs
+++ b/src/nixpacks/plan/generator.rs
@@ -7,9 +7,9 @@ use anyhow::{bail, Context, Ok, Result};
 use std::collections::HashMap;
 
 // This line is automatically updated.
-// Last Modified: 2022-08-15 17:08:57 UTC+0000
-// https://github.com/NixOS/nixpkgs/commit/441dc5d512153039f19ef198e662e4f3dbb9fd65
-pub const NIXPKGS_ARCHIVE: &str = "441dc5d512153039f19ef198e662e4f3dbb9fd65";
+// Last Modified: 2022-08-22 17:06:26 UTC+0000
+// https://github.com/NixOS/nixpkgs/commit/54060e816971276da05970a983487a25810c38a7
+pub const NIXPKGS_ARCHIVE: &str = "54060e816971276da05970a983487a25810c38a7";
 
 #[derive(Clone, Default, Debug)]
 pub struct GeneratePlanOptions {
diff --git a/src/providers/node/mod.rs b/src/providers/node/mod.rs
index 3f964ed..9b4c8b6 100644
--- a/src/providers/node/mod.rs
+++ b/src/providers/node/mod.rs
@@ -289,7 +289,16 @@ impl NodeProvider {
     /// Returns the nodejs nix package and the appropriate package manager nix image.
     pub fn get_nix_packages(app: &App, env: &Environment) -> Result<Vec<Pkg>> {
         let package_json: PackageJson = app.read_json("package.json")?;
-        let node_pkg = NodeProvider::get_nix_node_pkg(&package_json, env)?;
+        let mut node_pkg = NodeProvider::get_nix_node_pkg(&package_json, env)?;
+
+        // If node-canvas is used, we want to default to node 16
+        // https://github.com/Automattic/node-canvas/issues/2025
+        if NodeProvider::uses_node_dependency(app, "canvas")
+            && node_pkg.name == DEFAULT_NODE_PKG_NAME
+        {
+            node_pkg = Pkg::new("nodejs-16_x");
+        }
+
         let pm_pkg: Pkg;
         let mut pkgs = Vec::<Pkg>::new();
 
diff --git a/src/providers/python.rs b/src/providers/python.rs
index e085ecd..3c63907 100644
--- a/src/providers/python.rs
+++ b/src/providers/python.rs
@@ -30,9 +30,10 @@ impl Provider for PythonProvider {
     }
 
     fn detect(&self, app: &App, _env: &Environment) -> Result<bool> {
-        Ok(app.includes_file("main.py")
+        let has_python = app.includes_file("main.py")
             || app.includes_file("requirements.txt")
-            || app.includes_file("pyproject.toml"))
+            || app.includes_file("pyproject.toml");
+        Ok(has_python)
     }
 
     fn get_build_plan(&self, app: &App, env: &Environment) -> Result<Option<BuildPlan>> {
@@ -188,11 +189,14 @@ impl PythonProvider {
     }
 
     fn is_django(app: &App, _env: &Environment) -> Result<bool> {
-        Ok(app.includes_file("manage.py")
-            && app
-                .read_file("requirements.txt")?
+        let has_manage = app.includes_file("manage.py");
+        let imports_django = vec!["requirements.txt", "pyproject.toml"].iter().any(|f| {
+            app.read_file(f)
+                .unwrap_or_default()
                 .to_lowercase()
-                .contains("django"))
+                .contains("django")
+        });
+        Ok(has_manage && imports_django)
     }
 
     fn is_using_postgres(app: &App, _env: &Environment) -> Result<bool> {


Test patch:
diff --git a/tests/snapshots/generate_plan_tests__node_no_lockfile_canvas.snap b/tests/snapshots/generate_plan_tests__node_no_lockfile_canvas.snap
index 09fba10..0469700 100644
--- a/tests/snapshots/generate_plan_tests__node_no_lockfile_canvas.snap
+++ b/tests/snapshots/generate_plan_tests__node_no_lockfile_canvas.snap
@@ -30,7 +30,7 @@ expression: plan
       "name": "setup",
       "nixPackages": [
         {
-          "name": "nodejs"
+          "name": "nodejs-16_x"
         },
         {
           "name": "npm-8_x",