Split nix out

This commit is contained in:
Aoran Zeng 2024-08-16 04:18:27 +08:00
parent 8305341d62
commit e77e42fb6c
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
4 changed files with 66 additions and 57 deletions

View File

@ -166,20 +166,6 @@ wr_flathub_sources[] = {
/**
* @time 2023-09-22
* @note {
* 1.
* 2. setsrc函数中补充完整
* }
*/
wr_nix_sources[] = {
{&Upstream, NULL},
{&Bfsu, "https://mirrors.bfsu.edu.cn/nix-channels/"}
},
/**
* @time 2023-09-11
* @note
@ -228,6 +214,6 @@ def_sources_n(pl_clojure);
def_sources_n(pl_dotnet);
def_sources_n(wr_flathub);
def_sources_n(wr_nix); def_sources_n(wr_guix);
def_sources_n(wr_guix);
def_sources_n(wr_tex);
def_sources_n(wr_anaconda);

View File

@ -180,7 +180,7 @@ wr_tex_setsrc (char *option)
#include "recipe/ware/WinGet.c"
#include "recipe/ware/Homebrew.c"
#include "recipe/ware/CocoaPods.c"
#include "recipe/ware/Nix.c"
/**
* : https://mirrors.sjtug.sjtu.edu.cn/docs/guix
@ -203,46 +203,6 @@ wr_guix_setsrc (char *option)
void
wr_nix_check_cmd ()
{
chsrc_ensure_program ("nix-channel");
}
/**
* :
* 1. https://mirrors.bfsu.edu.cn/help/nix-channels/
* 2. https://gitee.com/RubyMetric/chsrc/issues/I83894
*/
void
wr_nix_setsrc (char *option)
{
wr_nix_check_cmd ();
SourceInfo source;
chsrc_yield_source (wr_nix);
chsrc_confirm_source (&source);
char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs");
chsrc_run (cmd, RunOpt_Default);
char *towrite = xy_strjoin (3, "substituters = ", source.url, "store https://cache.nixos.org/");
chsrc_append_to_file (towrite , "~/.config/nix/nix.conf");
chsrc_run ("nix-channel --update", RunOpt_Default);
chsrc_note2 ("若您使用的是NixOS请确认您的系统版本<version>如22.11),并手动运行:");
cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-<version> nixpkgs");
puts (cmd);
cmd = xy_strjoin (3, "nix.settings.substituters = [ \"", source.url, "store\" ];");
chsrc_note2 ("若您使用的是NixOS请额外添加下述内容至 configuration.nix 中");
puts (cmd);
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
}
#include "recipe/ware/docker.c"

View File

@ -93,7 +93,6 @@ static const char
def_target_noget (wr_flathub);
def_target_noget (wr_nix);
def_target_noget (wr_guix);
def_target_noget (wr_anaconda);
def_target(wr_tex);

64
src/recipe/ware/Nix.c Normal file
View File

@ -0,0 +1,64 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-26>
* Last Modified : <2024-08-15>
* ------------------------------------------------------------*/
/**
* @time 2023-09-22
* @note {
* 1.
* 2. setsrc函数中补充完整
* }
*/
static SourceInfo
wr_nix_sources[] = {
{&Upstream, NULL},
{&Bfsu, "https://mirrors.bfsu.edu.cn/nix-channels/"}
};
def_sources_n(wr_nix);
void
wr_nix_check_cmd ()
{
chsrc_ensure_program ("nix-channel");
}
/**
* :
* 1. https://mirrors.bfsu.edu.cn/help/nix-channels/
* 2. https://gitee.com/RubyMetric/chsrc/issues/I83894
*/
void
wr_nix_setsrc (char *option)
{
wr_nix_check_cmd ();
SourceInfo source;
chsrc_yield_source (wr_nix);
chsrc_confirm_source (&source);
char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs");
chsrc_run (cmd, RunOpt_Default);
char *towrite = xy_strjoin (3, "substituters = ", source.url, "store https://cache.nixos.org/");
chsrc_append_to_file (towrite , "~/.config/nix/nix.conf");
chsrc_run ("nix-channel --update", RunOpt_Default);
chsrc_note2 ("若您使用的是NixOS请确认您的系统版本<version>如22.11),并手动运行:");
cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-<version> nixpkgs");
puts (cmd);
cmd = xy_strjoin (3, "nix.settings.substituters = [ \"", source.url, "store\" ];");
chsrc_note2 ("若您使用的是NixOS请额外添加下述内容至 configuration.nix 中");
puts (cmd);
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
}
def_target_noget (wr_nix);