freebsdBranches{,Cross}: Init

This creates multiple package sets for different versions. The other
versions don't yet work, but that will be fixed in subsequent PRs.

Push versionData into package set so that it can be overridden

Co-Authored-By: Audrey Dutcher <audrey@rhelmot.io>
Co-Authored-By: Artemis Tosini <me@artem.ist>
This commit is contained in:
John Ericson 2024-04-30 19:29:38 -04:00
parent 8bbf167e3b
commit b64a9bb1a9
7 changed files with 174 additions and 76 deletions

View file

@ -0,0 +1,39 @@
{
lib,
config,
freebsdBranches,
freebsdBranchesCross,
}:
let
branch =
let
fallbackBranch = "release/13.1.0";
envBranch = builtins.getEnv "NIXPKGS_FREEBSD_BRANCH";
selectedBranch =
if config.freebsdBranch != null then
config.freebsdBranch
else if envBranch != "" then
envBranch
else
null;
chosenBranch = if selectedBranch != null then selectedBranch else fallbackBranch;
in
if freebsdBranches ? ${chosenBranch} then
chosenBranch
else
throw ''
Unknown FreeBSD branch ${chosenBranch}!
FreeBSD branches normally look like one of:
* `release/<major>.<minor>.0` for tagged releases without security updates
* `releng/<major>.<minor>` for release update branches with security updates
* `stable/<major>` for stable versions working towards the next minor release
* `main` for the latest development version
Set one with the NIXPKGS_FREEBSD_BRANCH environment variable or by setting `nixpkgs.config.freebsdBranch`.
'';
in
{
freebsd = freebsdBranches.${branch};
freebsdCross = freebsdBranchesCross.${branch};
}

View file

@ -1,72 +0,0 @@
{ stdenv, lib, stdenvNoCC
, makeScopeWithSplicing', generateSplicesForMkScope
, buildPackages
, fetchgit, fetchzip
}:
let
inherit (buildPackages.buildPackages) rsync;
versions = builtins.fromJSON (builtins.readFile ./versions.json);
version = "13.1.0";
branch = "release/${version}";
in makeScopeWithSplicing' {
otherSplices = generateSplicesForMkScope "freebsd";
f = (self: lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
} // {
sourceData = versions.${branch};
ports = fetchzip {
url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
};
compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
freebsd-lib = import ./lib { inherit version; };
# The manual callPackages below should in principle be unnecessary, but are
# necessary. See note in ../netbsd/default.nix
compat = self.callPackage ./pkgs/compat/package.nix {
inherit stdenv;
inherit (buildPackages.freebsd) makeMinimal boot-install;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (buildPackages.freebsd) makeMinimal install gencat;
inherit (self) include;
};
include = self.callPackage ./pkgs/include/package.nix {
inherit (buildPackages.freebsd) makeMinimal install rpcgen;
};
install = self.callPackage ./pkgs/install.nix {
inherit (buildPackages.freebsd) makeMinimal;
inherit (self) mtree libnetbsd;
};
libc = self.callPackage ./pkgs/libc/package.nix {
inherit (buildPackages.freebsd) makeMinimal install gencat rpcgen;
inherit (self) csu include;
};
libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix {
inherit (buildPackages.freebsd) makeMinimal;
};
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildPackages.freebsd) makeMinimal install tsort;
};
makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
inherit (self) make;
};
});
}

View file

@ -0,0 +1,71 @@
{ stdenv, lib, stdenvNoCC
, fetchzip
, sourceData, versionData, buildFreebsd
}:
self:
lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
} // {
inherit sourceData versionData;
# Keep the crawled portion of Nixpkgs finite.
buildFreebsd = lib.dontRecurseIntoAttrs buildFreebsd;
ports = fetchzip {
url = "https://cgit.freebsd.org/ports/snapshot/ports-dde3b2b456c3a4bdd217d0bf3684231cc3724a0a.tar.gz";
sha256 = "BpHqJfnGOeTE7tkFJBx0Wk8ryalmf4KNTit/Coh026E=";
};
compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
freebsd-lib = import ./lib {
version = lib.concatStringsSep "." (map toString (lib.filter (x: x != null) [
self.versionData.major
self.versionData.minor
self.versionData.patch or null
]));
};
# The manual callPackages below should in principle be unnecessary, but are
# necessary. See note in ../netbsd/default.nix
compat = self.callPackage ./pkgs/compat/package.nix {
inherit stdenv;
inherit (buildFreebsd) makeMinimal boot-install;
};
csu = self.callPackage ./pkgs/csu.nix {
inherit (buildFreebsd) makeMinimal install gencat;
inherit (self) include;
};
include = self.callPackage ./pkgs/include/package.nix {
inherit (buildFreebsd) makeMinimal install rpcgen;
};
install = self.callPackage ./pkgs/install.nix {
inherit (buildFreebsd) makeMinimal;
inherit (self) mtree libnetbsd;
};
libc = self.callPackage ./pkgs/libc/package.nix {
inherit (buildFreebsd) makeMinimal install gencat rpcgen;
inherit (self) csu include;
};
libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix {
inherit (buildFreebsd) makeMinimal;
};
mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildFreebsd) makeMinimal install tsort;
};
makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
inherit (self) make;
};
}

View file

@ -0,0 +1,45 @@
{
lib,
config,
makeScopeWithSplicing',
generateSplicesForMkScope,
callPackage,
crossLibcStdenv,
}:
let
versions = builtins.fromJSON (builtins.readFile ./versions.json);
# `./package-set.nix` should never know the name of the package set we
# are constructing; just this function is allowed to know that. This
# is why we:
#
# - do the splicing for cross compilation here
#
# - construct the *anonymized* `buildFreebsd` attribute to be passed
# to `./package-set.nix`.
callFreeBSDWithAttrs =
extraArgs: branch: sourceData:
let
otherSplices = generateSplicesForMkScope [
"freebsdBranches"
branch
];
in
makeScopeWithSplicing' {
inherit otherSplices;
f = callPackage ./package-set.nix (
{
buildFreebsd = otherSplices.selfBuildHost;
inherit sourceData;
versionData = sourceData.version;
}
// extraArgs
);
};
in
{
freebsdBranches = lib.mapAttrs (callFreeBSDWithAttrs { }) versions;
freebsdBranchesCross = lib.mapAttrs (callFreeBSDWithAttrs { stdenv = crossLibcStdenv; }) versions;
}

View file

@ -40910,10 +40910,16 @@ with pkgs;
name = "bsd-setup-hook";
} ../os-specific/bsd/setup-hook.sh;
freebsd = callPackage ../os-specific/bsd/freebsd { };
freebsdCross = callPackage ../os-specific/bsd/freebsd {
stdenv = crossLibcStdenv;
};
inherit (callPackage ../os-specific/bsd/freebsd/versions.nix {}) freebsdBranches freebsdBranchesCross;
freebsd13 = freebsdBranches."release/13.2.0";
freebsd14 = freebsdBranches."release/14.0.0";
freebsdGit = freebsdBranches.main;
freebsd13Cross = freebsdBranchesCross."release/13.0.0";
freebsd14Cross = freebsdBranchesCross."release/14.0.0";
freebsdGitCross = freebsdBranchesCross.main;
inherit (callPackage ../os-specific/bsd/freebsd/default-branch.nix {}) freebsd freebsdCross;
netbsd = callPackage ../os-specific/bsd/netbsd { };
netbsdCross = callPackage ../os-specific/bsd/netbsd {

View file

@ -74,6 +74,14 @@ let
feature = "set `__contentAddressed` to true by default";
};
freebsdBranch = mkMassRebuild {
type = types.nullOr types.str;
default = null;
description = ''
Default FreeBSD release to use for FreeBSD packages
'';
};
allowAliases = mkOption {
type = types.bool;
default = true;

View file

@ -76,6 +76,7 @@ let
buildHaskellPackages = true;
buildPackages = true;
buildFreebsd = true;
generateOptparseApplicativeCompletions = true;
callPackage = true;