Skip to content

feat(shell): add OpenSSL env vars for cargo builds on Linux - #630

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/openssl-env-vars
Jan 20, 2026
Merged

feat(shell): add OpenSSL env vars for cargo builds on Linux#630
shunkakinoki merged 1 commit into
mainfrom
fix/openssl-env-vars

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jan 20, 2026

Copy link
Copy Markdown
Owner

Summary

Set OpenSSL environment variables in bash and fish shells on Linux so cargo can find OpenSSL without needing nix-shell -p gcc pkg-config openssl.

Environment variables added:

  • PKG_CONFIG_PATH - points to openssl.dev pkgconfig
  • OPENSSL_DIR - openssl dev directory
  • OPENSSL_LIB_DIR - openssl library directory
  • OPENSSL_INCLUDE_DIR - openssl headers

Problem

Cargo builds for crates depending on openssl-sys fail with:

The system library `openssl` required by crate `openssl-sys` was not found.

Test plan

  • make build passes
  • cargo build --release works for projects with openssl-sys dependency

🤖 Generated with Claude Code


Summary by cubic

Set OpenSSL env vars in bash and fish on Linux so cargo can find OpenSSL during builds. Fixes openssl-sys build failures and removes the need to enter nix-shell.

  • Bug Fixes
    • Exports PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, and OPENSSL_INCLUDE_DIR from pkgs.openssl.
    • Applies to both bash and fish; cargo builds now work without nix-shell.

Written for commit 94ed1ec. Summary will update on new commits.

Copilot AI review requested due to automatic review settings January 20, 2026 12:42
@mesa-dot-dev

mesa-dot-dev Bot commented Jan 20, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the development experience for Rust projects on Linux by streamlining the process of locating OpenSSL dependencies during Cargo builds. It addresses a common issue where openssl-sys dependent crates fail to compile due to missing OpenSSL configurations, thereby simplifying the build environment and reducing setup friction for developers.

Highlights

  • OpenSSL Environment Variables: This pull request introduces the automatic setting of several OpenSSL-related environment variables (PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, OPENSSL_INCLUDE_DIR) within both bash and fish shells on Linux systems.
  • Improved Cargo Build Reliability: By setting these variables, Rust projects that depend on openssl-sys can now successfully build with Cargo without requiring manual nix-shell commands or encountering 'system library openssl not found' errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Set PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, OPENSSL_INCLUDE_DIR
in both bash and fish so cargo can find OpenSSL without nix-shell.

Fixes: cargo build failing with "openssl-sys: system library not found"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jan 20, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Improved OpenSSL environment configuration for Bash and Fish shells on Linux, enabling better support for builds requiring OpenSSL dependencies.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Environment variables for OpenSSL are added to both Bash and Fish shell initialization scripts in Linux. The changes configure PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, and OPENSSL_INCLUDE_DIR to support cargo builds with OpenSSL dependencies.

Changes

Cohort / File(s) Summary
Shell Configuration
home-manager/programs/bash/default.nix, home-manager/programs/fish/default.nix
Added OpenSSL-related environment exports (PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, OPENSSL_INCLUDE_DIR) within Linux-specific conditional blocks to enable cargo builds with OpenSSL dependencies.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 With OpenSSL paths now clear,
Our shells compile without a tear,
Cargo builds shall swiftly run,
On Linux systems, one by one!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding OpenSSL environment variables for cargo builds on Linux in shell configuration files.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, solution, environment variables added, and test plan.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/openssl-env-vars

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Jan 20, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Added OpenSSL environment variables to bash and fish shells on Linux to enable cargo builds that depend on openssl-sys.

What changed?

File summaries were undefined.
Set PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, and OPENSSL_INCLUDE_DIR environment variables in bash and fish shells on Linux. These changes allow cargo to find the OpenSSL system library without requiring nix-shell -p gcc pkg-config openssl.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds necessary OpenSSL environment variables for Cargo builds on Linux, which is a great improvement. The changes for both bash and fish shells are mostly correct. However, there is a small but critical syntax error in the Nix configuration for bash related to string escaping, which will likely cause the build to fail. I've provided a specific comment with a suggested fix.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@home-manager/programs/bash/default.nix`:
- Around line 38-43: The PKG_CONFIG_PATH export line is over 100 chars; split it
into multiple concatenated strings to keep lines under the limit while
preserving the same value. Update the export statement that sets PKG_CONFIG_PATH
(the line referencing pkgs.openssl.dev and
${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}) by breaking the string interpolation into
two or more quoted pieces (e.g., separate the
"${pkgs.openssl.dev}/lib/pkgconfig" segment from the
"${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" segment) so the resulting export
PKG_CONFIG_PATH assignment still produces the same final string but each source
line stays <=100 chars.
🧹 Nitpick comments (1)
home-manager/programs/fish/default.nix (1)

14-19: OpenSSL exports look correct, minor inconsistency with bash version.

The fish implementation is functionally correct. However, there's a subtle difference from the bash version:

  • Bash (line 40): Uses ${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} which only appends if the variable is non-empty
  • Fish (line 16): Always appends $PKG_CONFIG_PATH, which may be empty/unset

In practice, fish handles empty variables gracefully in set -gx, so this works fine. But for strict consistency, you could use:

Optional: Match bash behavior for empty PKG_CONFIG_PATH
-          set -gx PKG_CONFIG_PATH "${pkgs.openssl.dev}/lib/pkgconfig" $PKG_CONFIG_PATH
+          if set -q PKG_CONFIG_PATH
+              set -gx PKG_CONFIG_PATH "${pkgs.openssl.dev}/lib/pkgconfig" $PKG_CONFIG_PATH
+          else
+              set -gx PKG_CONFIG_PATH "${pkgs.openssl.dev}/lib/pkgconfig"
+          end

Comment on lines +38 to +43

# OpenSSL for cargo builds (rust crates like openssl-sys)
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export OPENSSL_DIR="${pkgs.openssl.dev}"
export OPENSSL_LIB_DIR="${pkgs.openssl.out}/lib"
export OPENSSL_INCLUDE_DIR="${pkgs.openssl.dev}/include"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the file to see the full context
head -n 50 home-manager/programs/bash/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 1563


🏁 Script executed:

# Also check if the file exists and its size
wc -l home-manager/programs/bash/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 106


🏁 Script executed:

# Let's examine the exact lines mentioned (38-43) with more context
sed -n '30,50p' home-manager/programs/bash/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 858


🏁 Script executed:

# Check the module structure - look at the beginning of the file
head -n 10 home-manager/programs/bash/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 245


🏁 Script executed:

# Check the exact length of line 40
sed -n '40p' home-manager/programs/bash/default.nix | wc -c

Repository: shunkakinoki/dotfiles

Length of output: 68


🏁 Script executed:

# Check if openssl is declared as a dependency in this file
grep -n "openssl" home-manager/programs/bash/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 432


🏁 Script executed:

# Check if there are home.packages or similar dependencies declared
grep -n "home\." home-manager/programs/bash/default.nix | head -20

Repository: shunkakinoki/dotfiles

Length of output: 47


🏁 Script executed:

# Let's look at the entire file to see if there are any package dependencies
cat home-manager/programs/bash/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 2302


🏁 Script executed:

# Check if there's a flake.nix that defines nixpkgs inputs
if [ -f "flake.nix" ]; then
  head -30 flake.nix | grep -A5 "nixpkgs"
fi

Repository: shunkakinoki/dotfiles

Length of output: 756


Line 40 exceeds the 100-character limit—refactor the PKG_CONFIG_PATH export.

The OpenSSL environment variable setup is technically sound: Nix string interpolation is correct, bash variable escaping with ''$ is proper, and the .dev/.out package split follows Nix conventions. The comment adequately documents the purpose. However, line 40 is 108 characters, violating the guideline of keeping lines under 100 characters in Nix files. Split this line for compliance with the style requirements.

🤖 Prompt for AI Agents
In `@home-manager/programs/bash/default.nix` around lines 38 - 43, The
PKG_CONFIG_PATH export line is over 100 chars; split it into multiple
concatenated strings to keep lines under the limit while preserving the same
value. Update the export statement that sets PKG_CONFIG_PATH (the line
referencing pkgs.openssl.dev and ${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}) by
breaking the string interpolation into two or more quoted pieces (e.g., separate
the "${pkgs.openssl.dev}/lib/pkgconfig" segment from the
"${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" segment) so the resulting export
PKG_CONFIG_PATH assignment still produces the same final string but each source
line stays <=100 chars.

@shunkakinoki
shunkakinoki merged commit a212e3e into main Jan 20, 2026
30 of 31 checks passed
@shunkakinoki
shunkakinoki deleted the fix/openssl-env-vars branch January 20, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds OpenSSL environment variables to bash and fish shell configurations on Linux systems to enable cargo builds for Rust crates with OpenSSL dependencies without requiring explicit nix-shell invocations.

Changes:

  • Added four OpenSSL-related environment variables (PKG_CONFIG_PATH, OPENSSL_DIR, OPENSSL_LIB_DIR, OPENSSL_INCLUDE_DIR) to bash and fish shells
  • Variables are conditionally set only on Linux systems where OpenSSL packages are available

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
home-manager/programs/bash/default.nix Added OpenSSL environment variables within the existing Linux-specific conditional block in bashrcExtra
home-manager/programs/fish/default.nix Added OpenSSL environment variables within the existing Linux-specific conditional block in shellInit

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +43
# OpenSSL for cargo builds (rust crates like openssl-sys)
export PKG_CONFIG_PATH="${pkgs.openssl.dev}/lib/pkgconfig''${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export OPENSSL_DIR="${pkgs.openssl.dev}"
export OPENSSL_LIB_DIR="${pkgs.openssl.out}/lib"
export OPENSSL_INCLUDE_DIR="${pkgs.openssl.dev}/include"

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zsh configuration (home-manager/programs/zsh/default.nix) also has the same Linux-specific XDG_RUNTIME_DIR setup pattern but is missing the OpenSSL environment variables that are being added to bash and fish. For consistency, zsh should also receive the same OpenSSL environment variable configuration since it's an active shell in this repository.

Copilot uses AI. Check for mistakes.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants