Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 502513ef1c9a
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 88927d408b1e
Choose a head ref
  • 8 commits
  • 13 files changed
  • 1 contributor

Commits on Apr 5, 2020

  1. Copy the full SHA
    86e1a96 View commit details
  2. Copy the full SHA
    609ef40 View commit details
  3. Copy the full SHA
    eb26c48 View commit details
  4. nixos/etc: fix building etc with structuredAttrs

    Yay, no more should-use-XML todo!
    lheckemann committed Apr 5, 2020
    Copy the full SHA
    59d6f2a View commit details
  5. make-initrd: fix for structuredAttrs

    no more "!!! should use XML" :)
    lheckemann committed Apr 5, 2020
    Copy the full SHA
    ea9ad7e View commit details
  6. Copy the full SHA
    db02491 View commit details
  7. Copy the full SHA
    6771c1f View commit details
  8. Copy the full SHA
    88927d4 View commit details
3 changes: 1 addition & 2 deletions nixos/modules/system/etc/etc.nix
Original file line number Diff line number Diff line change
@@ -11,12 +11,11 @@ let
etc = pkgs.stdenvNoCC.mkDerivation {
name = "etc";

builder = ./make-etc.sh;
buildCommand = builtins.readFile ./make-etc.sh;

preferLocalBuild = true;
allowSubstitutes = false;

/* !!! Use toXML. */
sources = map (x: x.source) etc';
targets = map (x: x.target) etc';
modes = map (x: x.mode) etc';
41 changes: 15 additions & 26 deletions nixos/modules/system/etc/make-etc.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
source $stdenv/setup
mkdir -p "$out/etc"

mkdir -p $out/etc

set -f
sources_=($sources)
targets_=($targets)
modes_=($modes)
users_=($users)
groups_=($groups)
set +f

for ((i = 0; i < ${#targets_[@]}; i++)); do
source="${sources_[$i]}"
target="${targets_[$i]}"
for ((i = 0; i < ${#targets[@]}; i++)); do
source="${sources[$i]}"
target="${targets[$i]}"

if [[ "$source" =~ '*' ]]; then

# If the source name contains '*', perform globbing.
mkdir -p $out/etc/$target
mkdir -p "$out/etc/$target"
for fn in $source; do
ln -s "$fn" $out/etc/$target/
ln -s "$fn" "$out/etc/$target/"
done

else
mkdir -p $out/etc/$(dirname $target)
if ! [ -e $out/etc/$target ]; then
ln -s $source $out/etc/$target

mkdir -p "$out/etc/$(dirname "$target")"
if ! [ -e "$out/etc/$target" ]; then
ln -s "$source" "$out/etc/$target"
else
echo "duplicate entry $target -> $source"
if test "$(readlink $out/etc/$target)" != "$source"; then
echo "mismatched duplicate entry $(readlink $out/etc/$target) <-> $source"
exit 1
fi
fi
if test "${modes_[$i]}" != symlink; then
echo "${modes_[$i]}" > $out/etc/$target.mode
echo "${users_[$i]}" > $out/etc/$target.uid
echo "${groups_[$i]}" > $out/etc/$target.gid

if test "${modes[$i]}" != symlink; then
echo "${modes[$i]}" > "$out/etc/$target.mode"
echo "${users[$i]}" > "$out/etc/$target.uid"
echo "${groups[$i]}" > "$out/etc/$target.gid"
fi

fi
done

23 changes: 6 additions & 17 deletions pkgs/build-support/kernel/make-initrd.nix
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
# `contents = {object = ...; symlink = /init;}' is a typical
# argument.

{ stdenvNoCC, perl, cpio, contents, ubootTools
{ stdenvNoCC, closureInfo, cpio, contents, ubootTools, jq
, name ? "initrd"
, compressor ? "gzip -9n"
, prepend ? []
@@ -26,27 +26,16 @@ let
in stdenvNoCC.mkDerivation rec {
inherit name;

builder = ./make-initrd.sh;
buildCommand = builtins.readFile ./make-initrd.sh;

makeUInitrd = stdenvNoCC.hostPlatform.platform.kernelTarget == "uImage";

nativeBuildInputs = [ perl cpio ]
nativeBuildInputs = [ cpio jq ]
++ stdenvNoCC.lib.optional makeUInitrd ubootTools;

# !!! should use XML.
objects = map (x: x.object) contents;
symlinks = map (x: x.symlink) contents;
suffices = map (x: if x ? suffix then x.suffix else "none") contents;

# For obtaining the closure of `contents'.
# Note: we don't use closureInfo yet, as that won't build with nix-1.x.
# See #36268.
exportReferencesGraph =
lib.zipListsWith
(x: i: [("closure-${toValidStoreName (baseNameOf x.symlink)}-${toString i}") x.object])
contents
(lib.range 0 (lib.length contents - 1));
pathsFromGraph = ./paths-from-graph.pl;
inherit contents;

env.closure = "${closureInfo { rootPaths = map (x: x.object) contents; }}";

inherit compressor prepend;
}
22 changes: 6 additions & 16 deletions pkgs/build-support/kernel/make-initrd.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
source $stdenv/setup

set -o pipefail

objects=($objects)
symlinks=($symlinks)
suffices=($suffices)

mkdir root

# Needed for splash_helper, which gets run before init.
mkdir root/dev
mkdir root/sys
mkdir root/proc

objectCount=$(<.attrs.json jq '.contents | length')

for ((n = 0; n < ${#objects[*]}; n++)); do
object=${objects[$n]}
symlink=${symlinks[$n]}
suffix=${suffices[$n]}
for ((n = 0; n < $objectCount; n++)); do
object=$(<.attrs.json jq -r ".contents[$n].object")
symlink=$(<.attrs.json jq -r ".contents[$n].symlink")
suffix=$(<.attrs.json jq -r '.contents['"$n"'] | if has("suffix") then .suffix else "" end')
if test "$suffix" = none; then suffix=; fi

mkdir -p $(dirname root/$symlink)
ln -s $object$suffix root/$symlink
done


# Get the paths in the closure of `object'.
storePaths=$(perl $pathsFromGraph closure-*)


# Paths in cpio archives *must* be relative, otherwise the kernel
# won't unpack 'em.
(cd root && cp -prd --parents $storePaths .)
(cd root && cp -prd --parents $(cat "$closure/store-paths") .)


# Put the closure in a gzipped cpio archive.
9 changes: 7 additions & 2 deletions pkgs/build-support/kernel/modules-closure.nix
Original file line number Diff line number Diff line change
@@ -8,8 +8,13 @@

stdenvNoCC.mkDerivation {
name = kernel.name + "-shrunk";
builder = ./modules-closure.sh;
buildCommand = builtins.readFile ./modules-closure.sh;
nativeBuildInputs = [ nukeReferences kmod ];
inherit kernel firmware rootModules allowMissing;
inherit rootModules;
env = {
kernel = "${kernel}";
firmware = "${firmware}";
inherit allowMissing;
};
allowedReferences = ["out"];
}
8 changes: 3 additions & 5 deletions pkgs/build-support/kernel/modules-closure.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
source $stdenv/setup

# When no modules are built, the $out/lib/modules directory will not
# exist. Because the rest of the script assumes it does exist, we
# handle this special case first.
if ! test -d "$kernel/lib/modules"; then
if test -z "$rootModules" || test -n "$allowMissing"; then
if test -z "${rootModules[*]}" || test -n "$allowMissing"; then
mkdir -p "$out"
exit 0
else
echo "Required modules: $rootModules"
echo "Required modules: ${rootModules[*]}"
echo "Can not derive a closure of kernel modules because no modules were provided."
exit 1
fi
@@ -20,7 +18,7 @@ echo "kernel version is $version"

# Determine the dependencies of each root module.
closure=
for module in $rootModules; do
for module in "${rootModules[@]}"; do
echo "root module: $module"
deps=$(modprobe --config no-config -d $kernel --set-version "$version" --show-depends "$module" \
| sed 's/^insmod //') \
2 changes: 1 addition & 1 deletion pkgs/data/fonts/unifont/default.nix
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {

nativeBuildInputs = [ libfaketime fonttosfnt mkfontscale ];

phases = [ "buildPhase" "installPhase" ];
dontUnpack = true;

buildPhase =
''
4 changes: 1 addition & 3 deletions pkgs/development/libraries/libunistring/default.nix
Original file line number Diff line number Diff line change
@@ -13,9 +13,7 @@ stdenv.mkDerivation rec {

propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv;

configureFlags = [
"--with-libiconv-prefix=${libiconv}"
];
configureFlags = stdenv.lib.optional (!stdenv.isLinux) "--with-libiconv-prefix=${libiconv}";

doCheck = false;

Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ stdenv.mkDerivation rec {
sha256 = "cef3ce537d213e020af794cecf9de207e2882c375ceda39102eb6fa2580bad8d";
};

phases = [ "unpackPhase" "installPhase" ];
dontBuild = true;

installPhase = ''
DESTDIR="$out" ./install
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
sha256 = "0j3c35paapq1icmxq0mg7pm2xa2m69q7bkfmwgq99d682yr2cb5l";
};

phases = [ "unpackPhase" "installPhase" ];
dontBuild = true;

installPhase = ''
for i in rtl8192sfw.bin \
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ stdenv.mkDerivation {
name = "rtl8723bs-firmware-${linuxPackages.rtl8723bs.version}";
inherit (linuxPackages.rtl8723bs) src;

phases = [ "unpackPhase" "installPhase" ];
dontBuild = true;

installPhase = ''
mkdir -p "$out/lib/firmware/rtlwifi"
10 changes: 5 additions & 5 deletions pkgs/os-specific/linux/kernel/manual-config.nix
Original file line number Diff line number Diff line change
@@ -161,11 +161,11 @@ let
installFlags = [
"INSTALLKERNEL=${installkernel}"
"INSTALL_PATH=$(out)"
] ++ (optional isModular "INSTALL_MOD_PATH=$(out)")
] ++ optional isModular "INSTALL_MOD_PATH=$(out)"
++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware";

preInstall = ''
installFlagsArray+=("-j$NIX_BUILD_CORES")
installFlags+=("-j$NIX_BUILD_CORES")
'';

# Some image types need special install targets (e.g. uImage is installed with make uinstall)
@@ -184,10 +184,10 @@ let
mkdir -p $dev
cp vmlinux $dev/
if [ -z "''${dontStrip-}" ]; then
installFlagsArray+=("INSTALL_MOD_STRIP=1")
installFlags+=("INSTALL_MOD_STRIP=1")
fi
make modules_install $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}"
"''${installFlags[@]}"
unlink $out/lib/modules/${modDirVersion}/build
unlink $out/lib/modules/${modDirVersion}/source
@@ -256,7 +256,7 @@ let
sed -i Makefile -e 's|= ${buildPackages.kmod}/bin/depmod|= depmod|'
'' else optionalString installsFirmware ''
make firmware_install $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}"
"''${installFlags[@]}"
'');

requiredSystemFeatures = [ "big-parallel" ];
6 changes: 4 additions & 2 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
@@ -228,8 +228,10 @@ in rec {
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
inherit stdenv;

env =
assert lib.all (v: lib.isString v || lib.isBool v || lib.isInt v) (lib.attrValues env);
env = lib.mapAttrs
(k: v: if lib.isString v || lib.isBool v || lib.isInt v
then v
else throw "Environment variable '${k}' is a ${builtins.typeOf v} but should be a string, boolean or integer")
env;

# The `system` attribute of a derivation has special meaning to Nix.