Repository: railwayapp/nixpacks (rust)

Issue:
Support OpenSSL 3
In the latest version of the Nix unstable channel, openssl version 3 is the default instead of version. This breaks a few of our examples that depend on openssl 1 (e.g. node prisma). For now, the nixpkgs archive can be pinned to an older version, but we should do a few things to improve how Nixpacks handles openssl.

- Improved clarity around where openssl comes from. Our base debian image installs openssl with apt-get. However, this version can conflict with openssl from nixpkgs
- Allow users to specify which version of openssl they want. If version 1 is specified, this version should be used for all Nix packages that get installed

https://github.com/NixOS/nixpkgs/compare/a0b7e70db7a55088d3de0cc370a59f9fbcc906c3...8a5b9ee7b7a2b38267c9481f5c629c015108ab0d

Pull request description:
Default to Ubuntu base image
This PR sets the default base image for all Nixpacks build to use Ubuntu. The old debian base image can be used by setting the variable `NIXPACKS_DEBIAN=1`.

As part of this change I've also updated the node provider to always install the openssl nix package

Fixes https://github.com/railwayapp/nixpacks/issues/649
Fixes #574 

Patch:
diff --git a/src/nixpacks/images.rs b/src/nixpacks/images.rs
index b84b852..a89a137 100644
--- a/src/nixpacks/images.rs
+++ b/src/nixpacks/images.rs
@@ -1,2 +1,5 @@
-pub const DEFAULT_BASE_IMAGE: &str = "ghcr.io/railwayapp/nixpacks:debian-1670889918";
-pub const DEBIAN_SLIM_IMAGE: &str = "debian:bullseye-slim";
+pub const UBUNTU_BASE_IMAGE: &str = "ghcr.io/railwayapp/nixpacks:ubuntu-1671044363";
+pub const DEBIAN_BASE_IMAGE: &str = "ghcr.io/railwayapp/nixpacks:debian-1670889918";
+pub const DEFAULT_BASE_IMAGE: &str = UBUNTU_BASE_IMAGE;
+
+pub const STANDALONE_IMAGE: &str = "ubuntu:jammy";
diff --git a/src/nixpacks/nix/mod.rs b/src/nixpacks/nix/mod.rs
index a8625ae..e902b31 100644
--- a/src/nixpacks/nix/mod.rs
+++ b/src/nixpacks/nix/mod.rs
@@ -7,8 +7,8 @@ pub mod pkg;
 
 // This line is automatically updated.
 // Last Modified: 2022-09-12 17:11:54 UTC+0000
-// https://github.com/NixOS/nixpkgs/commit/a0b7e70db7a55088d3de0cc370a59f9fbcc906c3
-pub const NIXPKGS_ARCHIVE: &str = "a0b7e70db7a55088d3de0cc370a59f9fbcc906c3";
+// https://github.com/NixOS/nixpkgs/commit/ffca9ffaaafb38c8979068cee98b2644bd3f14cb
+pub const NIXPKGS_ARCHIVE: &str = "ffca9ffaaafb38c8979068cee98b2644bd3f14cb";
 
 #[derive(Eq, PartialEq, Default, Debug, Clone)]
 struct NixGroup {
diff --git a/src/nixpacks/plan/generator.rs b/src/nixpacks/plan/generator.rs
index 51b1dfc..bb5a84b 100644
--- a/src/nixpacks/plan/generator.rs
+++ b/src/nixpacks/plan/generator.rs
@@ -77,7 +77,7 @@ impl NixpacksBuildPlanGenerator<'_> {
             plan.add_variables(Environment::clone_variables(env));
         }
 
-        plan.pin();
+        plan.pin(env.is_config_variable_truthy("DEBIAN"));
 
         Ok(plan)
     }
diff --git a/src/nixpacks/plan/mod.rs b/src/nixpacks/plan/mod.rs
index ea37c51..03fa5b5 100644
--- a/src/nixpacks/plan/mod.rs
+++ b/src/nixpacks/plan/mod.rs
@@ -3,7 +3,7 @@ use self::{
     phase::{Phase, Phases, StartPhase},
     topological_sort::topological_sort,
 };
-use super::images::DEFAULT_BASE_IMAGE;
+use super::images::{DEBIAN_BASE_IMAGE, UBUNTU_BASE_IMAGE};
 use crate::nixpacks::{
     app::{App, StaticAssets},
     environment::{Environment, EnvironmentVariables},
@@ -268,10 +268,15 @@ impl BuildPlan {
         BuildPlan::new(&phases, start)
     }
 
-    pub fn pin(&mut self) {
+    pub fn pin(&mut self, use_debian: bool) {
         self.providers = Some(Vec::new());
         if self.build_image.is_none() {
-            self.build_image = Some(DEFAULT_BASE_IMAGE.to_string());
+            let base_image = if use_debian {
+                DEBIAN_BASE_IMAGE
+            } else {
+                UBUNTU_BASE_IMAGE
+            };
+            self.build_image = Some(base_image.to_string());
         }
 
         self.resolve_phase_names();
@@ -410,7 +415,7 @@ mod test {
         )
         .unwrap();
 
-        plan.pin();
+        plan.pin(false);
         assert_eq!(
             plan.get_phase("setup").unwrap().nix_pkgs,
             Some(vec!["nodejs".to_string(), "yarn".to_string()])
diff --git a/src/nixpacks/plan/phase.rs b/src/nixpacks/plan/phase.rs
index 6699772..7d17166 100644
--- a/src/nixpacks/plan/phase.rs
+++ b/src/nixpacks/plan/phase.rs
@@ -1,5 +1,5 @@
 use crate::nixpacks::{
-    images::{DEBIAN_SLIM_IMAGE, DEFAULT_BASE_IMAGE},
+    images::{DEFAULT_BASE_IMAGE, STANDALONE_IMAGE},
     nix::{pkg::Pkg, NIXPKGS_ARCHIVE},
 };
 use serde::{Deserialize, Serialize};
@@ -219,7 +219,7 @@ impl StartPhase {
     }
 
     pub fn run_in_slim_image(&mut self) {
-        self.run_image = Some(DEBIAN_SLIM_IMAGE.to_string());
+        self.run_image = Some(STANDALONE_IMAGE.to_string());
     }
 
     pub fn add_file_dependency<S: Into<String>>(&mut self, file: S) {
diff --git a/src/providers/clojure.rs b/src/providers/clojure.rs
index 6cf514f..33f4a91 100644
--- a/src/providers/clojure.rs
+++ b/src/providers/clojure.rs
@@ -42,7 +42,7 @@ impl Provider for ClojureProvider {
         };
 
         // based on project config, uberjar can be created under ./target/uberjar or ./target, This ensure file will be found on the same place whatevery the project config is
-        let move_file_cmd = "if [ -f /app/target/uberjar/*standalone.jar ]; then  mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi";
+        let move_file_cmd = "if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi";
         let mut build = Phase::build(Some(format!("{build_cmd}; {move_file_cmd}")));
         build.depends_on_phase("setup");
 


Test patch:
diff --git a/tests/snapshots/generate_plan_tests__clojure.snap b/tests/snapshots/generate_plan_tests__clojure.snap
index 8ebe036..70e267c 100644
--- a/tests/snapshots/generate_plan_tests__clojure.snap
+++ b/tests/snapshots/generate_plan_tests__clojure.snap
@@ -16,7 +16,7 @@ expression: plan
         "setup"
       ],
       "cmds": [
-        "lein uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then  mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
+        "lein uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
       ]
     },
     "setup": {
diff --git a/tests/snapshots/generate_plan_tests__clojure_jdk11.snap b/tests/snapshots/generate_plan_tests__clojure_jdk11.snap
index 2860fe4..de854bb 100644
--- a/tests/snapshots/generate_plan_tests__clojure_jdk11.snap
+++ b/tests/snapshots/generate_plan_tests__clojure_jdk11.snap
@@ -16,7 +16,7 @@ expression: plan
         "setup"
       ],
       "cmds": [
-        "lein uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then  mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
+        "lein uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
       ]
     },
     "setup": {
diff --git a/tests/snapshots/generate_plan_tests__clojure_jdk_latest.snap b/tests/snapshots/generate_plan_tests__clojure_jdk_latest.snap
index a9f7c4e..3106e97 100644
--- a/tests/snapshots/generate_plan_tests__clojure_jdk_latest.snap
+++ b/tests/snapshots/generate_plan_tests__clojure_jdk_latest.snap
@@ -16,7 +16,7 @@ expression: plan
         "setup"
       ],
       "cmds": [
-        "lein uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then  mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
+        "lein uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
       ]
     },
     "setup": {
diff --git a/tests/snapshots/generate_plan_tests__clojure_ring_app.snap b/tests/snapshots/generate_plan_tests__clojure_ring_app.snap
index ee64ca8..801bc53 100644
--- a/tests/snapshots/generate_plan_tests__clojure_ring_app.snap
+++ b/tests/snapshots/generate_plan_tests__clojure_ring_app.snap
@@ -16,7 +16,7 @@ expression: plan
         "setup"
       ],
       "cmds": [
-        "lein ring uberjar; if [ -f /app/target/uberjar/*standalone.jar ]; then  mv /app/target/uberjar/*standalone.jar /app/target/*standalone.jar; fi"
+        "lein ring uberjar; if [ -f /app/target/default+uberjar/*standalone.jar ]; then mv /app/target/default+uberjar/*standalone.jar /app/target/*standalone.jar; fi"
       ]
     },
     "setup": {
diff --git a/tests/snapshots/generate_plan_tests__go.snap b/tests/snapshots/generate_plan_tests__go.snap
index 62607d4..1067773 100644
--- a/tests/snapshots/generate_plan_tests__go.snap
+++ b/tests/snapshots/generate_plan_tests__go.snap
@@ -34,6 +34,6 @@ expression: plan
   },
   "start": {
     "cmd": "./out",
-    "runImage": "debian:bullseye-slim"
+    "runImage": "ubuntu:jammy"
   }
 }
diff --git a/tests/snapshots/generate_plan_tests__go_custom_version.snap b/tests/snapshots/generate_plan_tests__go_custom_version.snap
index 6e1e25c..ceb3020 100644
--- a/tests/snapshots/generate_plan_tests__go_custom_version.snap
+++ b/tests/snapshots/generate_plan_tests__go_custom_version.snap
@@ -46,6 +46,6 @@ expression: plan
   },
   "start": {
     "cmd": "./out",
-    "runImage": "debian:bullseye-slim"
+    "runImage": "ubuntu:jammy"
   }
 }
diff --git a/tests/snapshots/generate_plan_tests__go_gin.snap b/tests/snapshots/generate_plan_tests__go_gin.snap
index 6e1e25c..ceb3020 100644
--- a/tests/snapshots/generate_plan_tests__go_gin.snap
+++ b/tests/snapshots/generate_plan_tests__go_gin.snap
@@ -46,6 +46,6 @@ expression: plan
   },
   "start": {
     "cmd": "./out",
-    "runImage": "debian:bullseye-slim"
+    "runImage": "ubuntu:jammy"
   }
 }
diff --git a/tests/snapshots/generate_plan_tests__go_mod.snap b/tests/snapshots/generate_plan_tests__go_mod.snap
index b6d74f7..453f6bc 100644
--- a/tests/snapshots/generate_plan_tests__go_mod.snap
+++ b/tests/snapshots/generate_plan_tests__go_mod.snap
@@ -46,6 +46,6 @@ expression: plan
   },
   "start": {
     "cmd": "./out",
-    "runImage": "debian:bullseye-slim"
+    "runImage": "ubuntu:jammy"
   }
 }