@@ -8,10 +8,11 @@
outputs = { self , nixpkgs , nixpkgs-regression , lowdown-src }:
let
inherit ( nixpkgs ) lib ;
officialRelease = false ;
version = nixpkgs . lib . fileContents ./.version + versionSuffix ;
version = lib . fileContents ./.version + versionSuffix ;
versionSuffix =
if officialRelease
then " "
@@ -25,34 +26,36 @@
stdenvs = [ " g c c S t d e n v " " c l a n g S t d e n v " " c l a n g 1 1 S t d e n v " " s t d e n v " " l i b c x x S t d e n v " " c c a c h e S t d e n v " ] ;
forAllSystems = f : nixpkgs . lib . genAttrs systems ( system : f system ) ;
forAllSystemsAndStdenvs = f : forAllSystems ( system :
nixpkgs . lib . listToAttrs
forAllSystems = lib . genAttrs systems ;
forAllCrossSystems = lib . genAttrs crossSystems ;
forAllStdenvs = f :
lib . listToAttrs
( map
( n :
nixpkgs . lib . nameValuePair " ${ n } P a c k a g e s " (
f system n
) ) stdenvs
)
) ;
( stdenvName : {
name = " ${ stdenvName } P a c k a g e s " ;
value = f stdenvName ;
} )
stdenvs ) ;
forAllStdenvs = f : nixpkgs . lib . genAttrs stdenvs ( stdenv : f stdenv ) ;
# Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor =
let stdenvsPackages = forAllSystemsAndStdenvs
( system : stdenv :
import nixpkgs {
inherit system ;
overlays = [
( overlayFor ( p : p . ${ stdenv } ) )
] ;
}
) ;
in
# Add the `stdenvPackages` at toplevel, both because these are the ones
# we want most of the time and for backwards compatibility
forAllSystems ( system : stdenvsPackages . ${ system } // stdenvsPackages . ${ system } . stdenvPackages ) ;
nixpkgsFor = forAllSystems
( system : let
make-pkgs = crossSystem : stdenv : import nixpkgs {
inherit system crossSystem ;
overlays = [
( overlayFor ( p : p . ${ stdenv } ) )
] ;
} ;
stdenvs = forAllStdenvs ( make-pkgs null ) ;
native = stdenvs . stdenvPackages ;
in {
inherit stdenvs native ;
static = native . pkgsStatic ;
cross = forAllCrossSystems ( crossSystem : make-pkgs crossSystem " s t d e n v " ) ;
} ) ;
commonDeps = { pkgs , isStatic ? false }: with pkgs ; rec {
# Use "busybox-sandbox-shell" if present,
@@ -144,7 +147,7 @@
} ;
installScriptFor = systems :
with nixpkgsFor . x86_64-linux ;
with nixpkgsFor . x86_64-linux . native ;
runCommand " i n s t a l l e r - s c r i p t "
{ buildInputs = [ nix ] ;
}
@@ -208,8 +211,9 @@
installCheckPhase = " m a k e i n s t a l l c h e c k - j $ N I X _ B U I L D _ C O R E S - l $ N I X _ B U I L D _ C O R E S " ;
} ;
binaryTarball = buildPackages : nix : pkgs :
binaryTarball = nix : pkgs :
let
inherit ( pkgs ) buildPackages ;
inherit ( pkgs ) cacert ;
installerClosureInfo = buildPackages . closureInfo { rootPaths = [ nix cacert ] ; } ;
in
@@ -289,7 +293,9 @@
# Forward from the previous stage as we don’ t want it to pick the lowdown override
nixUnstable = prev . nixUnstable ;
nix = with final ; with commonDeps { inherit pkgs ; } ; currentStdenv . mkDerivation {
nix = with final ; with commonDeps { inherit pkgs ; } ; let
canRunInstalled = currentStdenv . buildPlatform . canExecute currentStdenv . hostPlatform ;
in currentStdenv . mkDerivation {
name = " n i x - ${ version } " ;
inherit version ;
@@ -300,24 +306,26 @@
outputs = [ " o u t " " d e v " " d o c " ] ;
nativeBuildInputs = nativeBuildDeps ;
buildInputs = buildDeps ++ awsDeps ;
buildInputs = buildDeps
# There have been issues building these dependencies
++ lib . optionals ( currentStdenv . hostPlatform = = currentStdenv . buildPlatform ) awsDeps ;
propagatedBuildInputs = propagatedDeps ;
disallowedReferences = [ boost ] ;
preConfigure =
preConfigure = lib . optionalString ( ! currentStdenv . hostPlatform . isStatic )
''
# C o p y l i b b o o s t _ c o n t e x t s o w e d o n ' t g e t a l l o f B o o s t i n o u r c l o s u r e .
# h t t p s : / / g i t h u b . c o m / N i x O S / n i x p k g s / i s s u e s / 4 5 4 6 2
m k d i r - p $o u t / l i b
c p - p d ${ boost } / l i b / { l i b b o o s t _ c o n t e x t * , l i b b o o s t _ t h r e a d * , l i b b o o s t _ s y s t e m * } $o u t / l i b
r m - f $o u t / l i b / * . a
${ lib . optionalString currentStdenv . isLinux ''
${ lib . optionalString currentStdenv . hostPlatform . isLinux ''
c h m o d u + w $o u t / l i b / * . s o . *
p a t c h e l f - - s e t - r p a t h $o u t / l i b : ${ currentStdenv . cc . cc . lib } / l i b $o u t / l i b / l i b b o o s t _ t h r e a d . s o . *
'' }
${ lib . optionalString currentStdenv . isDarwin ''
${ lib . optionalString currentStdenv . hostPlatform . isDarwin ''
f o r L I B i n $o u t / l i b / * . d y l i b ; d o
c h m o d u + w $L I B
i n s t a l l _ n a m e _ t o o l - i d $L I B $L I B
@@ -328,7 +336,9 @@
'' ;
configureFlags = configureFlags ++
[ " - - s y s c o n f d i r = / e t c " ] ;
[ " - - s y s c o n f d i r = / e t c " ] ++
lib . optional stdenv . hostPlatform . isStatic " - - e n a b l e - e m b e d d e d - s a n d b o x - s h e l l " ++
lib . optional ( ! canRunInstalled ) " - - d i s a b l e - d o c - g e n " ;
enableParallelBuilding = true ;
@@ -356,6 +366,8 @@
strictDeps = true ;
hardeningDisable = lib . optional stdenv . hostPlatform . isStatic " p i e " ;
passthru . perl-bindings = with final ; perl . pkgs . toPerlModule ( currentStdenv . mkDerivation {
name = " n i x - p e r l - ${ version } " ;
@@ -388,7 +400,7 @@
postUnpack = " s o u r c e R o o t = $ s o u r c e R o o t / p e r l " ;
} ) ;
meta . platforms = systems ;
meta . platforms = lib . platforms . unix ;
} ;
lowdown-nix = with final ; currentStdenv . mkDerivation rec {
@@ -414,14 +426,15 @@
# https://nixos.org/manual/nixos/unstable/index.html#sec-calling-nixos-tests
runNixOSTestFor = system : test : nixos-lib . runTest {
imports = [ test ] ;
hostPkgs = nixpkgsFor . ${ system } ;
hostPkgs = nixpkgsFor . ${ system } . native ;
defaults = {
nixpkgs . pkgs = nixpkgsFor . ${ system } ;
nixpkgs . pkgs = nixpkgsFor . ${ system } . native ;
} ;
_module . args . nixpkgs = nixpkgs ;
} ;
in {
inherit nixpkgsFor ;
# A Nixpkgs overlay that overrides the 'nix' and
# 'nix.perl-bindings' packages.
@@ -430,32 +443,28 @@
hydraJobs = {
# Binary package for various platforms.
build = nixpkgs . lib . genAttrs systems ( system : self . packages . ${ system } . nix ) ;
build = forAllSystems ( system : self . packages . ${ system } . nix ) ;
buildStatic = nixpkgs . lib . genAttrs linux64BitSystems ( system : self . packages . ${ system } . nix-static ) ;
buildStatic = lib . genAttrs linux64BitSystems ( system : self . packages . ${ system } . nix-static ) ;
buildCross = nixpkgs . lib . genAttrs crossSystems ( crossSystem :
nixpkgs . lib . genAttrs [ " x 8 6 _ 6 4 - l i n u x " ] ( system : self . packages . ${ system } . " n i x - ${ crossSystem } " ) ) ;
buildCross = forAllCrossSystems ( crossSystem :
lib . genAttrs [ " x 8 6 _ 6 4 - l i n u x " ] ( system : self . packages . ${ system } . " n i x - ${ crossSystem } " ) ) ;
buildNoGc = nixpkgs . lib . genAttrs systems ( system : self . packages . ${ system } . nix . overrideAttrs ( a : { configureFlags = ( a . configureFlags or [ ] ) ++ [ " - - e n a b l e - g c = n o " ] ; } ) ) ;
buildNoGc = forAllSystems ( system : self . packages . ${ system } . nix . overrideAttrs ( a : { configureFlags = ( a . configureFlags or [ ] ) ++ [ " - - e n a b l e - g c = n o " ] ; } ) ) ;
# Perl bindings for various platforms.
perlBindings = nixpkgs . lib . genAttrs systems ( system : self . packages . ${ system } . nix . perl-bindings ) ;
perlBindings = forAllSystems ( system : nixpkgsFor . ${ system } . native . nix . perl-bindings ) ;
# Binary tarball for various platforms, containing a Nix store
# with the closure of 'nix' package, and the second half of
# the installation script.
binaryTarball = nixpkgs . lib . genAttrs systems ( system : binaryTarball nixpkgsFor . ${ system } nixpkgsFor . ${ system } . nix nixpkgsFor . ${ system } ) ;
binaryTarball = forAllSystems ( system : binaryTarball nixpkgsFor . ${ system } . native . nix nixpkgsFor . ${ system } . native ) ;
binaryTarballCross = nixpkgs . lib . genAttrs [ " x 8 6 _ 6 4 - l i n u x " ] ( system : builtins . listToAttrs ( map ( crossSystem : {
name = crossSystem ;
value = let
nixpkgsCross = import nixpkgs {
inherit system crossSystem ;
overlays = [ self . overlays . default ] ;
} ;
in binaryTarball nixpkgsFor . ${ system } self . packages . ${ system } . " n i x - ${ crossSystem } " nixpkgsCross ;
} ) crossSystems ) ) ;
binaryTarballCross = lib . genAttrs [ " x 8 6 _ 6 4 - l i n u x " ] ( system :
forAllCrossSystems ( crossSystem :
binaryTarball
self . packages . ${ system } . " n i x - ${ crossSystem } "
nixpkgsFor . ${ system } . cross . ${ crossSystem } ) ) ;
# The first half of the installation script. This is uploaded
# to https://nixos.org/nix/install. It downloads the binary
@@ -465,11 +474,11 @@
installerScriptForGHA = installScriptFor [ " x 8 6 _ 6 4 - l i n u x " " x 8 6 _ 6 4 - d a r w i n " " a r m v 6 l - l i n u x " " a r m v 7 l - l i n u x " ] ;
# docker image with Nix inside
dockerImage = nixpkgs . lib . genAttrs linux64BitSystems ( system : self . packages . ${ system } . dockerImage ) ;
dockerImage = lib . genAttrs linux64BitSystems ( system : self . packages . ${ system } . dockerImage ) ;
# Line coverage analysis.
coverage =
with nixpkgsFor . x86_64-linux ;
with nixpkgsFor . x86_64-linux . native ;
with commonDeps { inherit pkgs ; } ;
releaseTools . coverageAnalysis {
@@ -513,7 +522,7 @@
tests . containers = runNixOSTestFor " x 8 6 _ 6 4 - l i n u x " ./tests/nixos/containers/containers.nix ;
tests . setuid = nixpkgs . lib . genAttrs
tests . setuid = lib . genAttrs
[ " i 6 8 6 - l i n u x " " x 8 6 _ 6 4 - l i n u x " ]
( system : runNixOSTestFor system ./tests/nixos/setuid.nix ) ;
@@ -521,7 +530,7 @@
# Make sure that nix-env still produces the exact same result
# on a particular version of Nixpkgs.
tests . evalNixpkgs =
with nixpkgsFor . x86_64-linux ;
with nixpkgsFor . x86_64-linux . native ;
runCommand " e v a l - n i x o s " { buildInputs = [ nix ] ; }
''
t y p e - p n i x - e n v
@@ -532,18 +541,18 @@
'' ;
tests . nixpkgsLibTests =
nixpkgs . lib . genAttrs systems ( system :
forAllSystems ( system :
import ( nixpkgs + " / l i b / t e s t s / r e l e a s e . n i x " )
{ pkgs = nixpkgsFor . ${ system } ; }
{ pkgs = nixpkgsFor . ${ system } . native ; }
) ;
metrics . nixpkgs = import " ${ nixpkgs-regression } / p k g s / t o p - l e v e l / m e t r i c s . n i x " {
pkgs = nixpkgsFor . x86_64-linux ;
pkgs = nixpkgsFor . x86_64-linux . native ;
nixpkgs = nixpkgs-regression ;
} ;
installTests = forAllSystems ( system :
let pkgs = nixpkgsFor . ${ system } ; in
let pkgs = nixpkgsFor . ${ system } . native ; in
pkgs . runCommand " i n s t a l l - t e s t s " {
againstSelf = testNixVersions pkgs pkgs . nix pkgs . pkgs . nix ;
againstCurrentUnstable =
@@ -568,67 +577,18 @@
perlBindings = self . hydraJobs . perlBindings . ${ system } ;
installTests = self . hydraJobs . installTests . ${ system } ;
nixpkgsLibTests = self . hydraJobs . tests . nixpkgsLibTests . ${ system } ;
} // ( nixpkgs . lib . optionalAttrs ( builtins . elem system linux64BitSystems ) ) {
} // ( lib . optionalAttrs ( builtins . elem system linux64BitSystems ) ) {
dockerImage = self . hydraJobs . dockerImage . ${ system } ;
} ) ;
packages = forAllSystems ( system : rec {
inherit ( nixpkgsFor . ${ system } ) nix ;
inherit ( nixpkgsFor . ${ system } . native ) nix ;
default = nix ;
} // ( nixpkgs . lib . optionalAttrs ( builtins . elem system linux64BitSystems ) {
nix-static = let
nixpkgs = nixpkgsFor . ${ system } . pkgsStatic ;
in with commonDeps { pkgs = nixpkgs ; isStatic = true ; } ; nixpkgs . stdenv . mkDerivation {
name = " n i x - ${ version } " ;
src = self ;
VERSION_SUFFIX = versionSuffix ;
outputs = [ " o u t " " d e v " " d o c " ] ;
nativeBuildInputs = nativeBuildDeps ;
buildInputs = buildDeps ++ propagatedDeps ;
# Work around pkgsStatic disabling all tests.
# Remove in NixOS 22.11, see https://github.com/NixOS/nixpkgs/pull/140271.
preHook =
''
d o C h e c k = 1
d o I n s t a l l C h e c k = 1
'' ;
configureFlags =
configureFlags ++
[ " - - s y s c o n f d i r = / e t c "
" - - e n a b l e - e m b e d d e d - s a n d b o x - s h e l l "
] ;
enableParallelBuilding = true ;
makeFlags = " p r o f i l e d i r = $ ( o u t ) / e t c / p r o f i l e . d " ;
installFlags = " s y s c o n f d i r = $ ( o u t ) / e t c " ;
postInstall = ''
m k d i r - p $d o c / n i x - s u p p o r t
e c h o " d o c m a n u a l $d o c / s h a r e / d o c / n i x / m a n u a l " > > $d o c / n i x - s u p p o r t / h y d r a - b u i l d - p r o d u c t s
m k d i r - p $o u t / n i x - s u p p o r t
e c h o " f i l e b i n a r y - d i s t $o u t / b i n / n i x " > > $o u t / n i x - s u p p o r t / h y d r a - b u i l d - p r o d u c t s
'' ;
installCheckFlags = " s y s c o n f d i r = $ ( o u t ) / e t c " ;
stripAllList = [ " b i n " ] ;
strictDeps = true ;
hardeningDisable = [ " p i e " ] ;
} ;
} // ( lib . optionalAttrs ( builtins . elem system linux64BitSystems ) {
nix-static = nixpkgsFor . ${ system } . static . nix ;
dockerImage =
let
pkgs = nixpkgsFor . ${ system } ;
pkgs = nixpkgsFor . ${ system } . native ;
image = import ./docker.nix { inherit pkgs ; tag = version ; } ;
in
pkgs . runCommand
@@ -640,73 +600,30 @@
l n - s ${ image } $i m a g e
e c h o " f i l e b i n a r y - d i s t $i m a g e " > > $o u t / n i x - s u p p o r t / h y d r a - b u i l d - p r o d u c t s
'' ;
}
} // builtins . listToAttrs ( map
( crossSystem : {
name = " n i x - ${ crossSystem } " ;
value = nixpkgsFor . ${ system } . cross . ${ crossSystem } . nix ;
} )
crossSystems )
// builtins . listToAttrs ( map
( stdenvName : {
name = " n i x - ${ stdenvName } " ;
value = nixpkgsFor . ${ system } . stdenvs . " ${ stdenvName } P a c k a g e s " . nix ;
} )
stdenvs ) ) ) ;
// builtins . listToAttrs ( map ( crossSystem : {
name = " n i x - ${ crossSystem } " ;
value = let
nixpkgsCross = import nixpkgs {
inherit system crossSystem ;
overlays = [ self . overlays . default ] ;
} ;
inherit ( nixpkgsCross ) lib ;
in with commonDeps { pkgs = nixpkgsCross ; } ; nixpkgsCross . stdenv . mkDerivation {
name = " n i x - ${ version } " ;
src = self ;
VERSION_SUFFIX = versionSuffix ;
outputs = [ " o u t " " d e v " " d o c " ] ;
nativeBuildInputs = nativeBuildDeps ;
buildInputs = buildDeps ++ propagatedDeps ;
configureFlags = [
" C X X F L A G S = - I ${ lib . getDev nixpkgsCross . rapidcheck } / e x t r a s / g t e s t / i n c l u d e "
" - - s y s c o n f d i r = / e t c "
" - - d i s a b l e - d o c - g e n "
] ;
enableParallelBuilding = true ;
makeFlags = " p r o f i l e d i r = $ ( o u t ) / e t c / p r o f i l e . d " ;
doCheck = true ;
installFlags = " s y s c o n f d i r = $ ( o u t ) / e t c " ;
postInstall = ''
m k d i r - p $d o c / n i x - s u p p o r t
e c h o " d o c m a n u a l $d o c / s h a r e / d o c / n i x / m a n u a l " > > $d o c / n i x - s u p p o r t / h y d r a - b u i l d - p r o d u c t s
m k d i r - p $o u t / n i x - s u p p o r t
e c h o " f i l e b i n a r y - d i s t $o u t / b i n / n i x " > > $o u t / n i x - s u p p o r t / h y d r a - b u i l d - p r o d u c t s
'' ;
doInstallCheck = true ;
installCheckFlags = " s y s c o n f d i r = $ ( o u t ) / e t c " ;
} ;
} ) ( if system = = " x 8 6 _ 6 4 - l i n u x " then crossSystems else [ ] ) ) )
// ( builtins . listToAttrs ( map ( stdenvName :
nixpkgsFor . ${ system } . lib . nameValuePair
" n i x - ${ stdenvName } "
nixpkgsFor . ${ system } . " ${ stdenvName } P a c k a g e s " . nix
) stdenvs ) ) ) ;
devShells = forAllSystems ( system :
forAllStdenvs ( stdenv :
with nixpkgsFor . ${ system } ;
devShells = let
makeShell = pkgs : stdenv :
with commonDeps { inherit pkgs ; } ;
nixpkgsFor . ${ system } . ${ stdenv } . mkDerivation {
stdenv . mkDerivation {
name = " n i x " ;
outputs = [ " o u t " " d e v " " d o c " ] ;
nativeBuildInputs = nativeBuildDeps
++ ( lib . optionals
nixpkgsFor . ${ system } . ${ stdenv } . cc . isClang
[ bear clang-tools ] ) ;
++ ( lib . optionals stdenv . cc . isClang [ pkgs . bear pkgs . clang-tools ] ) ;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps ;
inherit configureFlags ;
@@ -724,10 +641,21 @@
# M a k e b a s h c o m p l e t i o n w o r k .
X D G _ D A T A _ D I R S + = : $o u t / s h a r e
'' ;
}
)
// { default = self . devShells . ${ system } . stdenv ; }
) ;
} ;
in
forAllSystems ( system :
let
makeShells = prefix : pkgs :
lib . mapAttrs'
( k : v : lib . nameValuePair " ${ prefix } - ${ k } " v )
( forAllStdenvs ( stdenvName : makeShell pkgs pkgs . ${ stdenvName } ) ) ;
in
( makeShells " n a t i v e " nixpkgsFor . ${ system } . native ) //
( makeShells " s t a t i c " nixpkgsFor . ${ system } . static ) //
( forAllCrossSystems ( crossSystem : let pkgs = nixpkgsFor . ${ system } . cross . ${ crossSystem } ; in makeShell pkgs pkgs . stdenv ) ) //
{
default = self . devShells . ${ system } . native-stdenvPackages ;
}
) ;
} ;
}