Files
ccpkgs/release.nix
Tyson Whitehead c4382fa872 The unpack-channel.nix core function is in flux for 20.09
Once hydra and nixpkgs are on the same nix this we can settle on
the newer builtin-based src/nix-channel/unpack-channel.nix.
2021-02-02 14:48:03 -05:00

168 lines
6.1 KiB
Nix

{ ccpkgs # Checked out ccpkgs git repo
? { outPath = ./.;
revCount = 1234 + 149;
shortRev = "gabcdef";
}
, nixpkgs # Checked out nixpkgs git repe
? { outPath = ./upstream;
revCount = 5678 + 242760;
shortRev = "gfedcba";
}
, nixpkgsArgs ? { config = { allowUnfree = true; inHydra = true; }; }
, stableBranch ? false
, supportedSystems ? [ "x86_64-linx" ] }:
# Free up the nixpkgs and ccpkgs name for binding to final product.
#
let
# *Git - git checkout
#
nixpkgsGit = nixpkgs;
ccpkgsGit = ccpkgs;
# Tarball hydra release product for the ccpkgs channel.
#
# 1. Generate an unpacked channel for the associated nixpkgs in the store.
# 2. Symlink this into the top-level directory as upstream (nixpkgs is used).
# 3. Stick in the standard version files.
# 4. Let releaseTools.sourceTarball handle the details of exposing it as a hydra product.
#
in let
# pkgs - Packages sucked in from the given ccpkgs git version.
#
pkgs = import ccpkgsGit ( nixpkgsArgs // { upstream = nixpkgsGit; } );
# version - Version number (e.g., "17.09")
# version*Suffix - Version suffix (e.g., "5678.gfedcba")
#
# Code lifted from nixos/release.nix.
#
version =
let
versionNixpkgs = pkgs.lib.fileContents (nixpkgsGit + /.version);
versionCcpkgs = pkgs.lib.fileContents ./.version;
in
assert (versionNixpkgs == versionCcpkgs); versionCcpkgs;
versionSeparator = if stableBranch then "." else "pre";
mkVersion = base: git: rec {
count = toString (git.revCount - base);
commit = git.shortRev;
suffix = "${versionSeparator}${count}.${commit}";
};
nixpkgsVersion = mkVersion 242760 nixpkgsGit;
ccpkgsVersion = mkVersion 149 ccpkgsGit;
versionSuffix = "${versionSeparator}${ccpkgsVersion.count}.${nixpkgsVersion.count}.${ccpkgsVersion.commit}.${nixpkgsVersion.commit}";
# nixpkgs - The store path containing the unpacked nixpkgs channel.
#
# 1. Generate a channel tarball from the git repo via the nixos/release.nix expression for hydra.
# 2. Unpack this into the store using the nix/unpack-channel.nix expression used by nix-channel.
#
nixpkgs =
let
# channel - Store path containing the channel release tarballs.
#
# The nixos.channel attribute from nixos/release.nix builds the nixpkgs channel tarballs.
#
channel =
( import (nixpkgsGit + /nixos/release.nix) {
inherit stableBranch supportedSystems;
nixpkgs = nixpkgsGit;
} ).channel;
# nixpkgs - The store path containing the unpacked nixpkgs channel.
#
# The nix provided nix/unpack-channel.nix function extracts the nixpkgs from the channel,
#
nixpkgs =
( pkgs.callPackage ./unpack-channel.nix { } rec {
name = "nixos";
channelName = "${name}-${version}";
src = channel + /tarballs + "/${name}-${version}${nixpkgsVersion.suffix}.tar.xz";
} );
in
nixpkgs;
# jobs - The jobs hydra is to run.
#
jobs =
let
# Extract the valid derivations from an overlay
#
# nameSet - the attribute set the uncomposed overlay (just the names are required)
# valueSet - the final attribute from the composed overlay (the values are required)
#
extractDerivations = valueSet: nameSet:
builtins.listToAttrs
( builtins.map
( name: { inherit name; value = valueSet.${name}; } )
( pkgs.lib.filter
( name: ( builtins.tryEval (pkgs.lib.isDerivation valueSet.${name}) ).value )
( pkgs.lib.attrNames nameSet ) ) );
# Provided overlays
pkgsNamesTopLevel = let self = import ./pkgs/all-packages.nix self { } self; in self;
pkgsNamesPython = let self = import ./pkgs/python-packages.nix { } self { } ; in self;
pkgsNamesR = let self = import ./pkgs/r-modules.nix { } self { } ; in self;
temporaryNamesTopLevel = let self = import ./temporary/all-packages.nix self { } self; in self;
temporaryNamesPython = let self = import ./temporary/python-packages.nix { } self { } ; in self;
temporaryNamesR = let self = import ./temporary/r-modules.nix { } self { } ; in self;
in {
# Tweak the nixos make-channel code to include the upstream channel.
#
# 1. Replace the git repo nixpkgs with a copy of the unpacked nixpkgs channel.
#
channel =
( import (nixpkgsGit + /nixos/lib/make-channel.nix) {
inherit pkgs version versionSuffix;
nixpkgs = ccpkgsGit;
} ).overrideAttrs ( original: {
name = "ccpkgs-channel";
distPhase =
''
rm -fr upstream
cp -rd ${nixpkgs}/nixos-${version} upstream
'' + original.distPhase;
} );
# tested - Aggregate package set required to built for automatic channel release
#
tested = pkgs.lib.hydraJob (pkgs.releaseTools.aggregate {
name = "ccpkgs-${version}";
constituents = builtins.map ( pkgs.lib.collect pkgs.lib.isDerivation ) [ jobs.pkgs jobs.temporary ];
meta = {
description = "Release-critical builds for the ccpkgs channel";
maintainers = with pkgs.lib.maintainers; [ ];
};
});
# pkgs - Attribute set of overlayed pkgs.
#
pkgs = extractDerivations pkgs pkgsNamesTopLevel // {
python2Packages = extractDerivations pkgs.python2Packages pkgsNamesPython;
python3Packages = extractDerivations pkgs.python3Packages pkgsNamesPython;
rPackages = extractDerivations pkgs.rPackages pkgsNamesR;
};
# temporary - Attribute set of overlayed pkgs.
#
temporary = extractDerivations pkgs temporaryNamesTopLevel // {
python2Packages = extractDerivations pkgs.python2Packages temporaryNamesPython;
python3Packages = extractDerivations pkgs.python3Packages temporaryNamesPython;
rPackages = extractDerivations pkgs.rPackages temporaryNamesR;
};
};
in jobs