Skip to content
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

Versions proposal #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions build-support/mkgeneric/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{ lib, config }:

{
# Intended to be an attrset of { "<exposed version>" = { version = "<full version>"; src = <path>; } }
# or a file containing such version information
# Type: AttrSet AttrSet
versions,

# Similar to versions, but instead contain deprecation and removal messages
# Only added when `config.allowAliases` is true
# This is passed the versions attr set to allow for directly referencing the version entries
# Type: AttrSet AttrSet -> AttrSet AttrSet.
aliases ? { ... }: { },

# A "projection" from the version set to a version to be used as the default
# Type: AttrSet package -> package
defaultSelector,

# Nix expression which takes version and package args, and returns an attrset to pass to mkDerivation
# Type: AttrSet -> AttrSet -> AttrSet
genericBuilder,
}:

# Some assertions as poor man's type checking
assert builtins.isFunction defaultSelector;

let
versionsRaw = if builtins.isPath versions then import versions else versions;
aliasesExpr = if builtins.isPath aliases then import aliases else aliases;
genericExpr = if builtins.isPath genericBuilder then import genericBuilder else genericBuilder;

aliases' = aliasesExpr { inherit lib; versions = versionsRaw; };
versions' = if config.allowAliases then
# Not sure if aliases or versions should have priority
versionsRaw // aliases'
else versionsRaw;

# This also allows for additional attrs to be passed through besides version and src
mkVersionArgs = { version, ... }@args: args // rec {
# Some helpers commonly used to determine packaging behavior
packageOlder = lib.versionOlder version;
packageAtLeast = lib.versionAtLeast version;
packageBetween = lower: higher: packageAtLeast lower && packageOlder higher;
mkVersionPassthru = packageArgs: let
versions = builtins.mapAttrs (_: v: mkPackage v packageArgs) versions';
in versions // { inherit versions; };
};

# Re-call the generic builder with new version args, re-wrap with makeOverridable
# to give it the same appearance as being called by callPackage
mkPackage = version: lib.makeOverridable (genericExpr (mkVersionArgs version));
in
# The partially applied function doesn't need to be called with makeOverridable
# As callPackage will be wrapping this in makeOverridable as well
genericExpr (mkVersionArgs (defaultSelector versions'))
9 changes: 9 additions & 0 deletions pkgs/openssl/aliases.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ lib
, versions
}:

{
# Compatibility with upstream nixpkgs
v3 = versions.v3_0;
v1_0 = throw "Openssl 1.0.x is EOL, and no longer supported";
}
Loading