NixOS: Use runCommand instead of mkDerivation in a few places

This commit is contained in:
Eelco Dolstra 2016-09-27 15:26:37 +02:00
parent 750195db7f
commit 75a1ec8a65
11 changed files with 89 additions and 140 deletions

View File

@ -94,14 +94,11 @@ let
"--stringparam chunk.toc ${toc}"
];
olinkDB = stdenv.mkDerivation {
name = "manual-olinkdb";
inherit sources;
buildInputs = [ libxml2 libxslt ];
buildCommand = ''
olinkDB = runCommand "manual-olinkdb"
{ inherit sources;
buildInputs = [ libxml2 libxslt ];
}
''
${copySources}
xsltproc \
@ -133,15 +130,14 @@ let
</targetset>
EOF
'';
};
in rec {
# The NixOS options in JSON format.
optionsJSON = stdenv.mkDerivation {
name = "options-json";
buildCommand = ''
optionsJSON = runCommand "options-json"
{ meta.description = "List of NixOS options in JSON format";
}
''
# Export list of options in different format.
dst=$out/share/doc/nixos
mkdir -p $dst
@ -154,18 +150,14 @@ in rec {
echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products
''; # */
meta.description = "List of NixOS options in JSON format";
};
# Generate the NixOS manual.
manual = stdenv.mkDerivation {
name = "nixos-manual";
inherit sources;
buildInputs = [ libxml2 libxslt ];
buildCommand = ''
manual = runCommand "nixos-manual"
{ inherit sources;
buildInputs = [ libxml2 libxslt ];
meta.description = "The NixOS manual in HTML format";
allowedReferences = ["out"];
}
''
${copySources}
# Check the validity of the manual sources.
@ -192,20 +184,12 @@ in rec {
echo "doc manual $dst" >> $out/nix-support/hydra-build-products
''; # */
meta.description = "The NixOS manual in HTML format";
allowedReferences = ["out"];
};
manualEpub = stdenv.mkDerivation {
name = "nixos-manual-epub";
inherit sources;
buildInputs = [ libxml2 libxslt zip ];
buildCommand = ''
manualEpub = runCommand "nixos-manual-epub"
{ inherit sources;
buildInputs = [ libxml2 libxslt zip ];
}
''
${copySources}
# Check the validity of the manual sources.
@ -234,17 +218,15 @@ in rec {
mkdir -p $out/nix-support
echo "doc-epub manual $manual" >> $out/nix-support/hydra-build-products
'';
};
# Generate the NixOS manpages.
manpages = stdenv.mkDerivation {
name = "nixos-manpages";
inherit sources;
buildInputs = [ libxml2 libxslt ];
buildCommand = ''
manpages = runCommand "nixos-manpages"
{ inherit sources;
buildInputs = [ libxml2 libxslt ];
allowedReferences = ["out"];
}
''
${copySources}
# Check the validity of the man pages sources.
@ -264,7 +246,4 @@ in rec {
./man-pages.xml
'';
allowedReferences = ["out"];
};
}

View File

@ -3,26 +3,27 @@
with lib;
let
cfg = config.i18n.inputMethod;
gtk2_cache = pkgs.stdenv.mkDerivation {
preferLocalBuild = true;
allowSubstitutes = false;
name = "gtk2-immodule.cache";
buildInputs = [ pkgs.gtk2 cfg.package ];
buildCommand = ''
gtk2_cache = pkgs.runCommand "gtk2-immodule.cache"
{ preferLocalBuild = true;
allowSubstitutes = false;
buildInputs = [ pkgs.gtk2 cfg.package ];
}
''
mkdir -p $out/etc/gtk-2.0/
GTK_PATH=${cfg.package}/lib/gtk-2.0/ gtk-query-immodules-2.0 > $out/etc/gtk-2.0/immodules.cache
'';
};
gtk3_cache = pkgs.stdenv.mkDerivation {
preferLocalBuild = true;
allowSubstitutes = false;
name = "gtk3-immodule.cache";
buildInputs = [ pkgs.gtk3 cfg.package ];
buildCommand = ''
gtk3_cache = pkgs.runCommand "gtk3-immodule.cache"
{ preferLocalBuild = true;
allowSubstitutes = false;
buildInputs = [ pkgs.gtk3 cfg.package ];
}
''
mkdir -p $out/etc/gtk-3.0/
GTK_PATH=${cfg.package}/lib/gtk-3.0/ gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache
'';
};
in
{
options.i18n = {

View File

@ -96,15 +96,13 @@ with lib;
'';
in
pkgs.stdenv.mkDerivation {
inherit (pkg) name meta;
buildCommand = ''
pkgs.runCommand pkg.name
{ inherit (pkg) meta; }
''
mkdir -p $out
cp -prf ${pkg}/* $out/
chmod a+w $out/share/apps/plasma-desktop/init
cp -f ${plasmaInit} $out/share/apps/plasma-desktop/init/00-defaultLayout.js
'';
};
}

View File

@ -32,13 +32,11 @@ let
'';
# Perform substitutions in all udev rules files.
udevRules = stdenv.mkDerivation {
name = "udev-rules";
preferLocalBuild = true;
allowSubstitutes = false;
buildCommand = ''
udevRules = pkgs.runCommand "udev-rules"
{ preferLocalBuild = true;
allowSubstitutes = false;
}
''
mkdir -p $out
shopt -s nullglob
set +o pipefail
@ -130,15 +128,12 @@ let
ln -s /dev/null $out/80-drivers.rules
''}
''; # */
};
hwdbBin = stdenv.mkDerivation {
name = "hwdb.bin";
preferLocalBuild = true;
allowSubstitutes = false;
buildCommand = ''
hwdbBin = pkgs.runCommand "hwdb.bin"
{ preferLocalBuild = true;
allowSubstitutes = false;
}
''
mkdir -p etc/udev/hwdb.d
for i in ${toString ([udev] ++ cfg.packages)}; do
echo "Adding hwdb files for package $i"
@ -151,7 +146,6 @@ let
${udev}/bin/udevadm hwdb --update --root=$(pwd)
mv etc/udev/hwdb.bin $out
'';
};
# Udev has a 512-character limit for ENV{PATH}, so create a symlink
# tree to work around this.

View File

@ -20,13 +20,11 @@ let
"<includedir>${d}/etc/dbus-1/session.d</includedir>"
]));
configDir = pkgs.stdenv.mkDerivation {
name = "dbus-conf";
preferLocalBuild = true;
allowSubstitutes = false;
buildCommand = ''
configDir = pkgs.runCommand "dbus-conf"
{ preferLocalBuild = true;
allowSubstitutes = false;
}
''
mkdir -p $out
sed '${./dbus-system-local.conf.in}' \
@ -38,7 +36,6 @@ let
-e 's,@extra@,${sessionExtraxml},' \
> "$out/session-local.conf"
'';
};
in

View File

@ -25,9 +25,8 @@ let
'';
};
nixos-gsettings-desktop-schemas = pkgs.stdenv.mkDerivation {
name = "nixos-gsettings-desktop-schemas";
buildCommand = ''
nixos-gsettings-desktop-schemas = pkgs.runCommand "nixos-gsettings-desktop-schemas" {}
''
mkdir -p $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
cp -rf ${gnome3.gsettings_desktop_schemas}/share/gsettings-schemas/gsettings-desktop-schemas*/glib-2.0/schemas/*.xml $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas
@ -46,7 +45,6 @@ let
${pkgs.glib.dev}/bin/glib-compile-schemas $out/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas/
'';
};
in {

View File

@ -54,19 +54,17 @@ let
''}
'';
kdmrc = pkgs.stdenv.mkDerivation {
name = "kdmrc";
config = defaultConfig + cfg.extraConfig;
preferLocalBuild = true;
buildCommand =
''
echo "$config" > $out
kdmrc = pkgs.runCommand "kdmrc"
{ config = defaultConfig + cfg.extraConfig;
preferLocalBuild = true;
}
''
echo "$config" > $out
# The default kdmrc would add "-nolisten tcp", and we already
# have that managed by nixos. Hence the grep.
cat ${kdebase_workspace}/share/config/kdm/kdmrc | grep -v nolisten >> $out
'';
};
# The default kdmrc would add "-nolisten tcp", and we already
# have that managed by nixos. Hence the grep.
cat ${kdebase_workspace}/share/config/kdm/kdmrc | grep -v nolisten >> $out
'';
in

View File

@ -16,11 +16,9 @@ let
# The default greeter provided with this expression is the GTK greeter.
# Again, we need a few things in the environment for the greeter to run with
# fonts/icons.
wrappedGtkGreeter = stdenv.mkDerivation {
name = "lightdm-gtk-greeter";
buildInputs = [ pkgs.makeWrapper ];
buildCommand = ''
wrappedGtkGreeter = pkgs.runCommand "lightdm-gtk-greeter"
{ buildInputs = [ pkgs.makeWrapper ]; }
''
# This wrapper ensures that we actually get themes
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
$out/greeter \
@ -40,7 +38,6 @@ let
Type=Application
EOF
'';
};
gtkGreeterConf = writeText "lightdm-gtk-greeter.conf"
''

View File

@ -26,15 +26,13 @@ let
# Unpack the SLiM theme, or use the default.
slimThemesDir =
let
unpackedTheme = pkgs.stdenv.mkDerivation {
name = "slim-theme";
buildCommand = ''
unpackedTheme = pkgs.runCommand "slim-theme" {}
''
mkdir -p $out
cd $out
unpackFile ${cfg.theme}
ln -s * default
'';
};
in if cfg.theme == null then "${pkgs.slim}/share/slim/themes" else unpackedTheme;
in

View File

@ -71,15 +71,11 @@ let
monitors = reverseList (foldl mkMonitor [] xrandrHeads);
in concatMapStrings (getAttr "value") monitors;
configFile = pkgs.stdenv.mkDerivation {
name = "xserver.conf";
xfs = optionalString (cfg.useXFS != false)
''FontPath "${toString cfg.useXFS}"'';
inherit (cfg) config;
buildCommand =
configFile = pkgs.runCommand "xserver.conf"
{ xfs = optionalString (cfg.useXFS != false)
''FontPath "${toString cfg.useXFS}"'';
inherit (cfg) config;
}
''
echo 'Section "Files"' >> $out
echo $xfs >> $out
@ -102,7 +98,6 @@ let
echo "$config" >> $out
''; # */
};
in

View File

@ -134,10 +134,9 @@ let
''; # */
udevRules = pkgs.stdenv.mkDerivation {
name = "udev-rules";
allowedReferences = [ extraUtils ];
buildCommand = ''
udevRules = pkgs.runCommand "udev-rules"
{ allowedReferences = [ extraUtils ]; }
''
mkdir -p $out
echo 'ENV{LD_LIBRARY_PATH}="${extraUtils}/lib"' > $out/00-env.rules
@ -176,7 +175,6 @@ let
substituteInPlace $out/60-persistent-storage.rules \
--replace ID_CDROM_MEDIA_TRACK_COUNT_DATA ID_CDROM_MEDIA
''; # */
};
# The init script of boot stage 1 (loading kernel modules for
@ -230,16 +228,12 @@ let
{ object = pkgs.writeText "mdadm.conf" config.boot.initrd.mdadmConf;
symlink = "/etc/mdadm.conf";
}
{ object = pkgs.stdenv.mkDerivation {
name = "initrd-kmod-blacklist-ubuntu";
builder = pkgs.writeText "builder.sh" ''
source $stdenv/setup
{ object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu"
{ src = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf"; }
''
target=$out
${pkgs.perl}/bin/perl -0pe 's/## file: iwlwifi.conf(.+?)##/##/s;' $src > $out
'';
src = "${pkgs.kmod-blacklist-ubuntu}/modprobe.conf";
};
symlink = "/etc/modprobe.d/ubuntu.conf";
}
{ object = pkgs.kmod-debian-aliases;