-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crate specific overrides (eg. building OpenSSL without errors out of the box) #326
Merged
nmattia
merged 7 commits into
nix-community:master
from
FireFragment:crate-specific-overrides
May 30, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7f05e93
Add crate-specific overrides
FireFragment 405249b
Document crate-specific overrides
FireFragment 8fedd23
Remove OpenSSL tip from README
FireFragment c9f5b32
Remove OpenSSL tip from readme template
FireFragment 726c4e7
Add the `autoCrateSpecificOverrides` option
FireFragment c46c694
Test OpenSSL as a dependency
FireFragment 909f97a
Disable openssl test on too old nixpkgs
FireFragment File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file contains crate-specific build inputs. | ||
# | ||
# Each of them is an attribute with name of the crate and value being a function. | ||
# This function gets as arguments: | ||
# - `crateInfo` with information about the crate, such as sha256 or version | ||
# | ||
# Currently supported fields to return are: `buildInputs`, `nativeBuildInputs` | ||
FireFragment marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
{ pkgs }: | ||
|
||
{ | ||
openssl-sys = { ... }: { | ||
nativeBuildInputs = with pkgs; [ pkg-config ]; | ||
buildInputs = with pkgs; [ openssl ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# OpenSSL needs `pkg-config` and `openssl` buildInputs. This tests whether we correctly supply them automatically. | ||
|
||
{ naersk, pkgs, ... }: | ||
|
||
let | ||
# Whether the nixpkgs is version 23 or newer, because in older nixpkgs, rustc is too old to build openssl. | ||
buildIt = with pkgs.lib; | ||
(strings.toInt ((builtins.elemAt (splitString "." trivial.version) 0)) >= 23); | ||
in | ||
|
||
if buildIt then | ||
naersk.buildPackage { | ||
src = ./fixtures; | ||
doCheck = true; | ||
} | ||
else | ||
builtins.trace '' | ||
Not building OpenSSL test, because Rust from nixpkgs under major version 23 cannot build OpenSSL | ||
Current nixpkgs version: ${pkgs.lib.trivial.version} | ||
'' | ||
|
||
pkgs.stdenv.mkDerivation { | ||
name = "not-building-openssl-test"; | ||
|
||
dontUnpack = true; | ||
|
||
buildPhase = '' | ||
echo Not building OpenSSL test, because Rust from nixpkgs under major version 23 cannot build OpenSSL | ||
echo Current nixpkgs version: ${pkgs.lib.trivial.version} | ||
''; | ||
|
||
installPhase = "mkdir $out"; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Tests that default-run doesn't break the dependency build, see | ||
# https://github.com/nmattia/naersk/issues/123 | ||
|
||
[package] | ||
name = "openssl-test" | ||
version = "0.1.0" | ||
authors = ["FireFragment <[email protected]>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
openssl = "0.10.64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having it enabled by default might create issues for users that already build with openssl and already add dependencies manually. WDYT?
EDIT: to be clear I think it's a good idea to have it enabled by default, just wondering how we can avoid breaking existing setups, esp. for people with custom openssl packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One idea I have is to emit a warning if there is already a derivation in
buildInputs
with the same name. It would not work in 100% of the cases, but it should work most of the time. Or we can just disable it by default.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having it enabled by default is much nicer!