Move GC roots to /nix/var/nix/gcroots/hydra
The uid split a while back caused the web interface to create GC roots in /nix/var/nix/gcroots/per-user/hydra-www, where they wouldn't be purged by hydra-update-gc-roots. Thus restarted builds would accumulate forever. The fix is to keep the roots in a shared directory with gid=hydra.
This commit is contained in:
parent
e04fb5c8e7
commit
b081133dcc
|
@ -144,6 +144,12 @@ in
|
||||||
default = {};
|
default = {};
|
||||||
description = "Extra environment variables for Hydra.";
|
description = "Extra environment variables for Hydra.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
gcRootsDir = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
default = "/nix/var/nix/gcroots/hydra";
|
||||||
|
description = "Directory that holds Hydra garbage collector roots.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -189,6 +195,7 @@ in
|
||||||
${optionalString (cfg.logo != null) ''
|
${optionalString (cfg.logo != null) ''
|
||||||
hydra_logo ${cfg.logo}
|
hydra_logo ${cfg.logo}
|
||||||
''}
|
''}
|
||||||
|
gc_roots_dir ${cfg.gcRootsDir}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
environment.systemPackages = [ cfg.package ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
@ -230,6 +237,26 @@ in
|
||||||
touch ${baseDir}/.db-created
|
touch ${baseDir}/.db-created
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
if [ ! -e ${cfg.gcRootsDir} ]; then
|
||||||
|
|
||||||
|
# Move legacy roots directory.
|
||||||
|
if [ -e /nix/var/nix/gcroots/per-user/hydra/hydra-roots ]; then
|
||||||
|
mv /nix/var/nix/gcroots/per-user/hydra/hydra-roots ${cfg.gcRootsDir}
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p ${cfg.gcRootsDir}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Move legacy hydra-www roots.
|
||||||
|
if [ -e /nix/var/nix/gcroots/per-user/hydra-www/hydra-roots ]; then
|
||||||
|
find /nix/var/nix/gcroots/per-user/hydra-www/hydra-roots/ -type f \
|
||||||
|
| xargs -r mv -f -t ${cfg.gcRootsDir}/
|
||||||
|
rmdir /nix/var/nix/gcroots/per-user/hydra-www/hydra-roots
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown hydra.hydra ${cfg.gcRootsDir}
|
||||||
|
chmod 2775 ${cfg.gcRootsDir}
|
||||||
'';
|
'';
|
||||||
serviceConfig.ExecStart = "${cfg.package}/bin/hydra-init";
|
serviceConfig.ExecStart = "${cfg.package}/bin/hydra-init";
|
||||||
serviceConfig.PermissionsStartOnly = true;
|
serviceConfig.PermissionsStartOnly = true;
|
||||||
|
|
|
@ -32,11 +32,18 @@ sub getHydraHome {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
my $hydraConfig;
|
||||||
|
|
||||||
sub getHydraConfig {
|
sub getHydraConfig {
|
||||||
|
return $hydraConfig if defined $hydraConfig;
|
||||||
my $conf = $ENV{"HYDRA_CONFIG"} || (Hydra::Model::DB::getHydraPath . "/hydra.conf");
|
my $conf = $ENV{"HYDRA_CONFIG"} || (Hydra::Model::DB::getHydraPath . "/hydra.conf");
|
||||||
return {} unless -f $conf;
|
if (-f $conf) {
|
||||||
my %config = new Config::General($conf)->getall;
|
my %h = new Config::General($conf)->getall;
|
||||||
return \%config;
|
$hydraConfig = \%h;
|
||||||
|
} else {
|
||||||
|
$hydraConfig = {};
|
||||||
|
}
|
||||||
|
return $hydraConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,8 +75,12 @@ sub getSCMCacheDir {
|
||||||
|
|
||||||
|
|
||||||
sub getGCRootsDir {
|
sub getGCRootsDir {
|
||||||
die unless defined $ENV{LOGNAME};
|
my $config = getHydraConfig();
|
||||||
my $dir = ($ENV{NIX_STATE_DIR} || "/nix/var/nix" ) . "/gcroots/per-user/$ENV{LOGNAME}/hydra-roots";
|
my $dir = $config->{gc_roots_dir};
|
||||||
|
unless (defined $dir) {
|
||||||
|
die unless defined $ENV{LOGNAME};
|
||||||
|
$dir = ($ENV{NIX_STATE_DIR} || "/nix/var/nix" ) . "/gcroots/per-user/$ENV{LOGNAME}/hydra-roots";
|
||||||
|
}
|
||||||
mkpath $dir if !-e $dir;
|
mkpath $dir if !-e $dir;
|
||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue