Skip to content

Commit

Permalink
nixos: add preferLocalBuild=true; on derivations for config files
Browse files Browse the repository at this point in the history
  • Loading branch information
symphorien authored and nix-review committed Feb 22, 2019
1 parent 2a81ece commit a915b33
Show file tree
Hide file tree
Showing 56 changed files with 99 additions and 60 deletions.
4 changes: 3 additions & 1 deletion nixos/modules/config/fonts/fontconfig-penultimate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ let
localConf = pkgs.writeText "fc-local.conf" cfg.localConf;

# The configuration to be included in /etc/font/
penultimateConf = pkgs.runCommand "font-penultimate-conf" {} ''
penultimateConf = pkgs.runCommand "font-penultimate-conf" {
preferLocalBuild = true;
} ''
support_folder=$out/etc/fonts/conf.d
latest_folder=$out/etc/fonts/${latestVersion}/conf.d
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/fonts/fontconfig-ultimate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let cfg = config.fonts.fontconfig.ultimate;
latestVersion = pkgs.fontconfig.configVersion;

# The configuration to be included in /etc/font/
confPkg = pkgs.runCommand "font-ultimate-conf" {} ''
confPkg = pkgs.runCommand "font-ultimate-conf" { preferLocalBuild = true; } ''
support_folder=$out/etc/fonts/conf.d
latest_folder=$out/etc/fonts/${latestVersion}/conf.d
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/fonts/fontconfig.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ let cfg = config.fonts.fontconfig;
'';

# fontconfig configuration package
confPkg = pkgs.runCommand "fontconfig-conf" {} ''
confPkg = pkgs.runCommand "fontconfig-conf" { preferLocalBuild = true; } ''
support_folder=$out/etc/fonts
latest_folder=$out/etc/fonts/${latestVersion}
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/fonts/fontdir.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ with lib;

let

x11Fonts = pkgs.runCommand "X11-fonts" { } ''
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
mkdir -p "$out/share/X11-fonts"
find ${toString config.fonts.fonts} \
\( -name fonts.dir -o -name '*.ttf' -o -name '*.otf' \) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ runCommand "uvcdynctrl-udev-rules-${version}"
];
dontPatchELF = true;
dontStrip = true;
preferLocalBuild = true;
}
''
mkdir -p "$out/lib/udev"
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/installer/cd-dvd/channel.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let
# user, as expected by nixos-rebuild/nixos-install. FIXME: merge
# with make-channel.nix.
channelSources = pkgs.runCommand "nixos-${config.system.nixos.version}"
{ }
{ preferLocalBuild = true; }
''
mkdir -p $out
cp -prd ${nixpkgs.outPath} $out/nixos
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/programs/less.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let
'';

lessKey = pkgs.runCommand "lesskey"
{ src = pkgs.writeText "lessconfig" configText; }
{ src = pkgs.writeText "lessconfig" configText; preferLocalBuild = true; }
"${pkgs.less}/bin/lesskey -o $out $src";

in
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/security/ca.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let
{ files =
cfg.certificateFiles ++
[ (builtins.toFile "extra.crt" (concatStringsSep "\n" cfg.certificates)) ];
preferLocalBuild = true;
}
''
cat $files > $out
Expand Down
5 changes: 4 additions & 1 deletion nixos/modules/security/sudo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ in
environment.etc = singleton
{ source =
pkgs.runCommand "sudoers"
{ src = pkgs.writeText "sudoers-in" cfg.configFile; }
{
src = pkgs.writeText "sudoers-in" cfg.configFile;
preferLocalBuild = true;
}
# Make sure that the sudoers file is syntactically valid.
# (currently disabled - NIXOS-66)
"${pkgs.buildPackages.sudo}/sbin/visudo -f $src -c && cp $src $out";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let
EOF
chmod 755 $out/${name}
'';
in pkgs.runCommand "buildkite-agent-hooks" {} ''
in pkgs.runCommand "buildkite-agent-hooks" { preferLocalBuild = true; } ''
mkdir $out
${concatStringsSep "\n" (mapAttrsToList mkHookEntry (filterAttrs (n: v: v != null) cfg.hooks))}
'';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let
if (cfg.configFile == null) then
(pkgs.runCommand "config.toml" {
buildInputs = [ pkgs.remarshal ];
preferLocalBuild = true;
} ''
remarshal -if json -of toml \
< ${pkgs.writeText "config.json" (builtins.toJSON cfg.configOptions)} \
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/databases/hbase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let
</configuration>
'';

configDir = pkgs.runCommand "hbase-config-dir" {} ''
configDir = pkgs.runCommand "hbase-config-dir" { preferLocalBuild = true; } ''
mkdir -p $out
cp ${cfg.package}/conf/* $out/
rm $out/hbase-site.xml
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/databases/influxdb.nix
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let

configFile = pkgs.runCommand "config.toml" {
buildInputs = [ pkgs.remarshal ];
preferLocalBuild = true;
} ''
remarshal -if json -of toml \
< ${pkgs.writeText "config.json" (builtins.toJSON configOptions)} \
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/hardware/acpid.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let
};
};

acpiConfDir = pkgs.runCommand "acpi-events" {}
acpiConfDir = pkgs.runCommand "acpi-events" { preferLocalBuild = true; }
''
mkdir -p $out
${
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/hardware/tlp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tlp = pkgs.tlp.override {
confFile = pkgs.runCommand "tlp"
{ config = cfg.extraConfig;
passAsFile = [ "config" ];
preferLocalBuild = true;
}
''
cat ${tlp}/etc/default/tlp > $out
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/logging/logcheck.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
let
cfg = config.services.logcheck;

defaultRules = pkgs.runCommand "logcheck-default-rules" {} ''
defaultRules = pkgs.runCommand "logcheck-default-rules" { preferLocalBuild = true; } ''
cp -prd ${pkgs.logcheck}/etc/logcheck $out
chmod u+w $out
rm -r $out/logcheck.*
Expand Down
5 changes: 4 additions & 1 deletion nixos/modules/services/logging/logstash.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ let

logstashSettingsYml = pkgs.writeText "logstash.yml" cfg.extraSettings;

logstashSettingsDir = pkgs.runCommand "logstash-settings" {inherit logstashSettingsYml;} ''
logstashSettingsDir = pkgs.runCommand "logstash-settings" {
inherit logstashSettingsYml;
preferLocalBuild = true;
} ''
mkdir -p $out
ln -s $logstashSettingsYml $out/logstash.yml
'';
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/mail/opensmtpd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let
conf = pkgs.writeText "smtpd.conf" cfg.serverConfiguration;
args = concatStringsSep " " cfg.extraServerArgs;

sendmail = pkgs.runCommand "opensmtpd-sendmail" {} ''
sendmail = pkgs.runCommand "opensmtpd-sendmail" { preferLocalBuild = true; } ''
mkdir -p $out/bin
ln -s ${cfg.package}/sbin/smtpctl $out/bin/sendmail
'';
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/misc/gitolite.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ in
config = mkIf cfg.enable (
let
manageGitoliteRc = cfg.extraGitoliteRc != "";
rcDir = pkgs.runCommand "gitolite-rc" { } rcDirScript;
rcDir = pkgs.runCommand "gitolite-rc" { preferLocalBuild = true; } rcDirScript;
rcDirScript =
''
mkdir "$out"
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/misc/nix-daemon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let
sh = pkgs.runtimeShell;
binshDeps = pkgs.writeReferencesToFile sh;
in
pkgs.runCommand "nix.conf" { extraOptions = cfg.extraOptions; } (''
pkgs.runCommand "nix.conf" { preferLocalBuild = true; extraOptions = cfg.extraOptions; } (''
${optionalString (!isNix20) ''
extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
''}
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/misc/taskserver/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ let
nixos-taskserver = pkgs.pythonPackages.buildPythonApplication {
name = "nixos-taskserver";

src = pkgs.runCommand "nixos-taskserver-src" {} ''
src = pkgs.runCommand "nixos-taskserver-src" { preferLocalBuild = true; } ''
mkdir -p "$out"
cat "${pkgs.substituteAll {
src = ./helper-tool.py;
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/monitoring/apcupsd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let

eventToShellCmds = event: if builtins.hasAttr event cfg.hooks then (shellCmdsForEventScript event (builtins.getAttr event cfg.hooks)) else "";

scriptDir = pkgs.runCommand "apcupsd-scriptdir" {} (''
scriptDir = pkgs.runCommand "apcupsd-scriptdir" { preferLocalBuild = true; } (''
mkdir "$out"
# Copy SCRIPTDIR from apcupsd package
cp -r ${pkgs.apcupsd}/etc/apcupsd/* "$out"/
Expand Down
6 changes: 4 additions & 2 deletions nixos/modules/services/monitoring/graphite.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ let
dataDir = cfg.dataDir;
staticDir = cfg.dataDir + "/static";

graphiteLocalSettingsDir = pkgs.runCommand "graphite_local_settings"
{inherit graphiteLocalSettings;} ''
graphiteLocalSettingsDir = pkgs.runCommand "graphite_local_settings" {
inherit graphiteLocalSettings;
preferLocalBuild = true;
} ''
mkdir -p $out
ln -s $graphiteLocalSettings $out/graphite_local_settings.py
'';
Expand Down
6 changes: 4 additions & 2 deletions nixos/modules/services/monitoring/nagios.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ let

nagiosObjectDefs = cfg.objectDefs;

nagiosObjectDefsDir = pkgs.runCommand "nagios-objects" {inherit nagiosObjectDefs;}
"mkdir -p $out; ln -s $nagiosObjectDefs $out/";
nagiosObjectDefsDir = pkgs.runCommand "nagios-objects" {
inherit nagiosObjectDefs;
preferLocalBuild = true;
} "mkdir -p $out; ln -s $nagiosObjectDefs $out/";

nagiosCfgFile = pkgs.writeText "nagios.cfg"
''
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/monitoring/netdata.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
let
cfg = config.services.netdata;

wrappedPlugins = pkgs.runCommand "wrapped-plugins" {} ''
wrappedPlugins = pkgs.runCommand "wrapped-plugins" { preferLocalBuild = true; } ''
mkdir -p $out/libexec/netdata/plugins.d
ln -s /run/wrappers/bin/apps.plugin $out/libexec/netdata/plugins.d/apps.plugin
'';
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/monitoring/prometheus/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let

# Pretty-print JSON to a file
writePrettyJSON = name: x:
pkgs.runCommand name { } ''
pkgs.runCommand name { preferLocalBuild = true; } ''
echo '${builtins.toJSON x}' | ${pkgs.jq}/bin/jq . > $out
'';

Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/monitoring/scollector.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
let
cfg = config.services.scollector;

collectors = pkgs.runCommand "collectors" {}
collectors = pkgs.runCommand "collectors" { preferLocalBuild = true; }
''
mkdir -p $out
${lib.concatStringsSep
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/monitoring/telegraf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let

configFile = pkgs.runCommand "config.toml" {
buildInputs = [ pkgs.remarshal ];
preferLocalBuild = true;
} ''
remarshal -if json -of toml \
< ${pkgs.writeText "config.json" (builtins.toJSON cfg.extraConfig)} \
Expand Down
3 changes: 2 additions & 1 deletion nixos/modules/services/monitoring/uptime.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ let

cfg = config.services.uptime;

configDir = pkgs.runCommand "config" {} (if cfg.configFile != null then ''
configDir = pkgs.runCommand "config" { preferLocalBuild = true; }
(if cfg.configFile != null then ''
mkdir $out
ext=`echo ${cfg.configFile} | grep -o \\..*`
ln -sv ${cfg.configFile} $out/default$ext
Expand Down
5 changes: 4 additions & 1 deletion nixos/modules/services/network-filesystems/beegfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ let

# wrappers to beegfs tools. Avoid typing path of config files
utilWrappers = mapAttrsToList ( name: cfg:
( pkgs.runCommand "beegfs-utils-${name}" { nativeBuildInputs = [ pkgs.makeWrapper ]; } ''
( pkgs.runCommand "beegfs-utils-${name}" {
nativeBuildInputs = [ pkgs.makeWrapper ];
preferLocalBuild = true;
} ''
mkdir -p $out/bin
makeWrapper ${pkgs.beegfs}/bin/beegfs-check-servers \
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/network-filesystems/ipfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let
"/var/lib/ipfs/.ipfs";

# Wrapping the ipfs binary with the environment variable IPFS_PATH set to dataDir because we can't set it in the user environment
wrapped = runCommand "ipfs" { buildInputs = [ makeWrapper ]; } ''
wrapped = runCommand "ipfs" { buildInputs = [ makeWrapper ]; preferLocalBuild = true; } ''
mkdir -p "$out/bin"
makeWrapper "${ipfs}/bin/ipfs" "$out/bin/ipfs" \
--set IPFS_PATH ${cfg.dataDir} \
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/network-filesystems/openafs/client.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let

clientServDB = pkgs.writeText "client-cellServDB-${cfg.cellName}" (mkCellServDB cfg.cellName cfg.cellServDB);

afsConfig = pkgs.runCommand "afsconfig" {} ''
afsConfig = pkgs.runCommand "afsconfig" { preferLocalBuild = true; } ''
mkdir -p $out
echo ${cfg.cellName} > $out/ThisCell
cat ${cellServDB} ${clientServDB} > $out/CellServDB
Expand Down Expand Up @@ -198,7 +198,7 @@ in

environment.etc = {
clientCellServDB = {
source = pkgs.runCommand "CellServDB" {} ''
source = pkgs.runCommand "CellServDB" { preferLocalBuild = true; } ''
cat ${cellServDB} ${clientServDB} > $out
'';
target = "openafs/CellServDB";
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/dnscache.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
let
cfg = config.services.dnscache;

dnscache-root = pkgs.runCommand "dnscache-root" {} ''
dnscache-root = pkgs.runCommand "dnscache-root" { preferLocalBuild = true; } ''
mkdir -p $out/{servers,ip}
${concatMapStrings (ip: ''
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/hylafax/systemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let
"$out/config.${name}"
'';
in
pkgs.runCommand "hylafax-config-modems" {}
pkgs.runCommand "hylafax-config-modems" { preferLocalBuild = true; }
''mkdir --parents "$out/" ${concatStringsSep "\n" (mapModems mkLine)}'';

setupSpoolScript = pkgs.substituteAll {
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/prayer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let
${cfg.extraConfig}
'';

prayerCfg = pkgs.runCommand "prayer.cf" { } ''
prayerCfg = pkgs.runCommand "prayer.cf" { preferLocalBuild = true; } ''
# We have to remove the http_port 80, or it will start a server there
cat ${prayer}/etc/prayer.cf | grep -v http_port > $out
cat ${prayerExtraCfg} >> $out
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/shout.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let
cfg = config.services.shout;
shoutHome = "/var/lib/shout";

defaultConfig = pkgs.runCommand "config.js" {} ''
defaultConfig = pkgs.runCommand "config.js" { preferLocalBuild = true; } ''
EDITOR=true ${pkgs.shout}/bin/shout config --home $PWD
mv config.js $out
'';
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/xrdp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ with lib;

let
cfg = config.services.xrdp;
confDir = pkgs.runCommand "xrdp.conf" { } ''
confDir = pkgs.runCommand "xrdp.conf" { preferLocalBuild = true; } ''
mkdir $out
cp ${cfg.package}/etc/xrdp/{km-*,xrdp,sesman,xrdp_keyboard}.ini $out
Expand Down
5 changes: 3 additions & 2 deletions nixos/modules/services/printing/cupsd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ let
avahiEnabled = config.services.avahi.enable;
polkitEnabled = config.security.polkit.enable;

additionalBackends = pkgs.runCommand "additional-cups-backends" { }
''
additionalBackends = pkgs.runCommand "additional-cups-backends" {
preferLocalBuild = true;
} ''
mkdir -p $out
if [ ! -e ${cups.out}/lib/cups/backend/smb ]; then
mkdir -p $out/lib/cups/backend
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/ttys/kmscon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ in {
X-RestartIfChanged=false
'';

systemd.units."[email protected]".unit = pkgs.runCommand "unit" { }
systemd.units."[email protected]".unit = pkgs.runCommand "unit" { preferLocalBuild = true; }
''
mkdir -p $out
ln -s ${config.systemd.units."[email protected]".unit}/[email protected] $out/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/web-apps/codimd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let
cfg = config.services.codimd;

prettyJSON = conf:
pkgs.runCommand "codimd-config.json" { } ''
pkgs.runCommand "codimd-config.json" { preferLocalBuild = true; } ''
echo '${builtins.toJSON conf}' | ${pkgs.jq}/bin/jq \
'{production:del(.[]|nulls)|del(.[][]?|nulls)}' > $out
'';
Expand Down
Loading

0 comments on commit a915b33

Please sign in to comment.