# How to install OpenSSL to compile against?

**URL:** https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249
**Category:** Help
**Created:** [October 25, 2018, 7:06am UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249 "2018-10-25T07:06:11Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![gilescope](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gilescope/32/1909_2.png) [@gilescope](https://discourse.nixos.org/u/gilescope)
#### Post date: [October 25, 2018, 7:06am UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/1 "2018-10-25T07:06:11Z")

</div>

Hi nix community, loving the idea behind nix/nixos.

I’m trying out nixos and nix (in docker) to host a rust program. It’s asking me to set OPENSSL\_DIR or OPENSSL\_LIB\_DIR, I installed:

nix-env -iA nixos.openssl

1. Is that the right package or is there a -dev package somewhere?
2. Do I need to give it some flags (somehow) for nix to install the openssl lib and includes?
3. Is there a recommended way to pick up the dir that nix is using for openssl?

Thanks in advance,

Giles

---

<div class="post-metadata">

### Author: ![gilescope](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gilescope/32/1909_2.png) [@gilescope](https://discourse.nixos.org/u/gilescope)
#### Post date: [October 25, 2018, 7:33am UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/2 "2018-10-25T07:33:09Z")

</div>

This lead me to the answers:  
[https://github.com/NixOS/nixpkgs/issues/15011](https://github.com/NixOS/nixpkgs/issues/15011)

The lib, includes are in a dir with ‘-dev’ appended in the /nix/store rather than in the standard dir.  
TODO: Find nice way to pick up that dir.

---

<div class="post-metadata">

### Author: ![lheckemann](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lheckemann/32/415_2.png) [@lheckemann](https://discourse.nixos.org/u/lheckemann)
#### Post date: [October 25, 2018, 8:00am UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/3 "2018-10-25T08:00:35Z")

</div>

[https://nixos.wiki/wiki/FAQ/Libraries](https://nixos.wiki/wiki/FAQ/Libraries)

---

<div class="post-metadata">

### Author: ![c0bw3b](https://discourse.nixos.org/user_avatar/discourse.nixos.org/c0bw3b/32/543_2.png) [@c0bw3b](https://discourse.nixos.org/u/c0bw3b)
#### Post date: [October 26, 2018, 5:12pm UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/4 "2018-10-26T17:12:45Z")

</div>

`openssl` is a split package (with multiple outputs). Read [more about it there](https://nixos.org/nixpkgs/manual/#chap-multiple-output) especially “using a split package”  
The dir your are looking for is actually the attribute `openssl.dev` in nix parlance.

Side comment: `openssl` still points to v1.0.2. If you are starting a fresh project you might want to use `openssl_1_1_0` :

```auto
nix-env -iA nixos.openssl_1_1_0

```

---

<div class="post-metadata">

### Author: ![vcunat](https://discourse.nixos.org/user_avatar/discourse.nixos.org/vcunat/32/11_2.png) [@vcunat](https://discourse.nixos.org/u/vcunat)
#### Post date: [October 29, 2018, 5:54pm UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/5 "2018-10-29T17:54:14Z")

</div>

Adding to the answer from Linus, you probably don’t want to use `nix-env` for this. Typical cases

- you want to do the full build of the program via a `nix-build` (you need to write a nix expression for that); or
- you want a development environment via `nix-shell -p openssl` (writing `shell.nix` can be useful for complex cases or repeated usage).

---

<div class="post-metadata">

### Author: ![gilescope](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gilescope/32/1909_2.png) [@gilescope](https://discourse.nixos.org/u/gilescope)
#### Post date: [January 11, 2020, 4:20pm UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/6 "2020-01-11T16:20:57Z")

</div>

That’s really working well.

---

<div class="post-metadata">

### Author: ![gilescope](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gilescope/32/1909_2.png) [@gilescope](https://discourse.nixos.org/u/gilescope)
#### Post date: [September 5, 2023, 4:33pm UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/7 "2023-09-05T16:33:28Z")

</div>

or not. thread ‘main’ panicked at /home/gilescope/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.93/build/main.rs:79:9:  
OpenSSL include directory does not exist: /home/gilescope/.nix-profile/bin/openssl/include

The answer is to get every project in the world to compile with rustls by default. That’s the only way right? Or could I perhaps get into a shell that has the includes hanging about? I just want cargo install cargo-raze to work. I get this with every tool that tries to use openssl. It’s so boring. (no pun intended)

---

<div class="post-metadata">

### Author: ![vcunat](https://discourse.nixos.org/user_avatar/discourse.nixos.org/vcunat/32/11_2.png) [@vcunat](https://discourse.nixos.org/u/vcunat)
#### Post date: [September 6, 2023, 2:06pm UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/8 "2023-09-06T14:06:41Z")

</div>

> [@gilescope](#):
>
> /home/gilescope/.nix-profile/bin/openssl/include

This directory seems really suspicious. Even searching includes inside bin. And you surely don’t want to involve nix-profile anyway, as that brings more issues than advantages (I wrote about that in my previous post).

---

<div class="post-metadata">

### Author: ![gilescope](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gilescope/32/1909_2.png) [@gilescope](https://discourse.nixos.org/u/gilescope)
#### Post date: [December 13, 2023, 9:34pm UTC](https://discourse.nixos.org/t/how-to-install-openssl-to-compile-against/1249/9 "2023-12-13T21:34:05Z")

</div>

Good spot. I was overriding in my .zshrc the OPENSSL\_DIR to try and point it to somewhere to make it work. Clearly that short term fix tripped me up!
