2011-10-10 21:11:08 +00:00
|
|
|
package Nix::Config;
|
|
|
|
|
2013-11-25 16:38:33 +00:00
|
|
|
$version = "@PACKAGE_VERSION@";
|
2012-07-11 22:05:30 +00:00
|
|
|
|
2011-10-10 21:11:08 +00:00
|
|
|
$binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@";
|
|
|
|
$libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@libexecdir@";
|
2012-01-03 01:51:38 +00:00
|
|
|
$stateDir = $ENV{"NIX_STATE_DIR"} || "@localstatedir@/nix";
|
2011-10-10 21:11:08 +00:00
|
|
|
$manifestDir = $ENV{"NIX_MANIFESTS_DIR"} || "@localstatedir@/nix/manifests";
|
|
|
|
$logDir = $ENV{"NIX_LOG_DIR"} || "@localstatedir@/log/nix";
|
2011-11-23 12:21:35 +00:00
|
|
|
$confDir = $ENV{"NIX_CONF_DIR"} || "@sysconfdir@/nix";
|
2012-06-29 22:28:52 +00:00
|
|
|
$storeDir = $ENV{"NIX_STORE_DIR"} || "@storedir@";
|
2011-10-10 21:11:08 +00:00
|
|
|
|
2012-06-29 18:26:31 +00:00
|
|
|
$bzip2 = "@bzip2@";
|
|
|
|
$xz = "@xz@";
|
2011-10-10 21:11:08 +00:00
|
|
|
$curl = "@curl@";
|
2006-05-31 09:24:54 +00:00
|
|
|
|
2012-05-10 23:03:23 +00:00
|
|
|
$useBindings = "@perlbindings@" eq "yes";
|
|
|
|
|
2012-07-09 14:57:28 +00:00
|
|
|
%config = ();
|
|
|
|
|
2006-05-31 09:24:54 +00:00
|
|
|
sub readConfig {
|
2012-07-30 20:09:54 +00:00
|
|
|
if (defined $ENV{'_NIX_OPTIONS'}) {
|
|
|
|
foreach my $s (split '\n', $ENV{'_NIX_OPTIONS'}) {
|
|
|
|
my ($n, $v) = split '=', $s, 2;
|
|
|
|
$config{$n} = $v;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-09 14:57:28 +00:00
|
|
|
my $config = "$confDir/nix.conf";
|
2006-05-31 09:24:54 +00:00
|
|
|
return unless -f $config;
|
2012-07-30 20:09:54 +00:00
|
|
|
|
2006-05-31 09:24:54 +00:00
|
|
|
open CONFIG, "<$config" or die "cannot open `$config'";
|
|
|
|
while (<CONFIG>) {
|
|
|
|
/^\s*([\w|-]+)\s*=\s*(.*)$/ or next;
|
|
|
|
$config{$1} = $2;
|
|
|
|
}
|
|
|
|
close CONFIG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|