mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
install: reset mirror configuration if not in china
This commit is contained in:
1 parent
3f14d7a63e
commit
d1a652d364
2 files changed
+15
-5
No files matched your search
+14
-4
@@ -183,6 +183,17 @@ const Steps = () => [
|
||||
{
|
||||
init: 'install.preparing',
|
||||
operations: [
|
||||
() => {
|
||||
if (CN) return;
|
||||
// rollback mirrors
|
||||
writeFileSync('/etc/nix/nix.conf', `substituters = https://cache.nixos.org/ https://nix.hydro.ac/cache
|
||||
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydro.ac:EytfvyReWHFwhY9MCGimCIn46KQNfmv9y8E2NqlNfxQ=
|
||||
connect-timeout = 10`);
|
||||
exec('nix-channel --del nixpkgs', { stdio: 'inherit' });
|
||||
exec('nix-channel --add nixpkgs https://nixos.org/channels/nixpkgs-unstable', { stdio: 'inherit' });
|
||||
exec('nix-channel --update', { stdio: 'inherit' });
|
||||
},
|
||||
'nix-env -iA nixpkgs.pm2 nixpkgs.yarn nixpkgs.esbuild nixpkgs.bash nixpkgs.unzip nixpkgs.zip nixpkgs.diffutils',
|
||||
() => {
|
||||
// Not implemented yet
|
||||
// if (fs.existsSync('/home/judge/src')) {
|
||||
@@ -234,12 +245,12 @@ const Steps = () => [
|
||||
() => {
|
||||
if (!CN) return;
|
||||
try {
|
||||
exec('yarn config set registry https://registry.npmmirror.com/');
|
||||
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge');
|
||||
exec('yarn config set registry https://registry.npmmirror.com/', { stdio: 'inherit' });
|
||||
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { stdio: 'inherit' });
|
||||
} catch (e) {
|
||||
console.log('Failed to install from npmmirror, fallback to yarnpkg');
|
||||
} finally {
|
||||
exec('yarn config set registry https://registry.yarnpkg.com');
|
||||
exec('yarn config set registry https://registry.yarnpkg.com', { stdio: 'inherit' });
|
||||
}
|
||||
try {
|
||||
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge');
|
||||
@@ -353,7 +364,6 @@ async function main() {
|
||||
console.error(e);
|
||||
console.log('Cannot find the best mirror. Fallback to default.');
|
||||
}
|
||||
return;
|
||||
const steps = Steps();
|
||||
for (let i = 0; i < steps.length; i++) {
|
||||
const step = steps[i];
|
||||
|
||||
Reference in new issue
Block a user