Compare commits

..

10 Commits

Author SHA1 Message Date
chn
e01d505a52 Merge branch 'production' into archive 2025-12-12 09:05:57 +08:00
chn
93cd518084 Merge branch 'production' into archive 2025-12-06 19:47:15 +08:00
chn
0a65102ac5 Merge branch 'production' into archive 2025-12-05 21:25:17 +08:00
chn
304eb91f2b Merge branch 'production' into archive 2025-11-22 11:39:04 +08:00
chn
ba02e8a75c Merge branch 'production' into archive 2025-11-21 22:28:46 +08:00
chn
15eda313bb Merge branch 'production' into archive 2025-11-21 17:36:55 +08:00
chn
a4d828a0ff Merge branch 'production' into archive 2025-11-17 13:10:20 +08:00
chn
5a80f27e3d Merge branch 'production' into archive 2025-11-16 22:45:15 +08:00
chn
90d1b8d63a Merge branch 'edge' into archive-edge 2025-11-15 15:16:44 +08:00
chn
ecdb2d2c0a set branch 2025-11-02 19:22:37 +08:00
71 changed files with 912 additions and 1112 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
flake/branch.nix merge=ours

View File

@@ -24,9 +24,3 @@ An overlay is provided through `outputs.overlays.default`, you could use it in y
}
```
## TODO
* Write this readme file. Something have been outdate.
* Servers in XMU should use vps9 to run proxy.
* Allow to specify oneapiArch and nvhpcArch per package.
* Update document. Something is outdate.

View File

@@ -15,11 +15,10 @@ let
mkdir -p $out/bin
ln -s ${python}/bin/python3 $out/bin/python-lyj
'';
jykang = pkgs.symlinkJoin
{
name = "jykang";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv python-lyj sqlite ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; archive = pkgs.closureInfo { rootPaths = [ jykang.drvPath ]; }; };
};
in jykang
in pkgs.symlinkJoin
{
name = "jykang";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv python-lyj sqlite ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; };
}

View File

@@ -12,7 +12,6 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBoDGk9HYphkngx2Ix/vef2ZntdVNK1kbS9pY8+TzI41
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJi6O1Sf1BBV1dYyH1jcHiws+ntwVfV29+6Paq1CQaET hss
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFlBxisj3sU9QC8UC5gX6sakf7G03ybbkmHtD2cybuZA qmx
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAWU/OlrP8bJ5k7IqpIwUC1COuVsmrYVreW/ieEdPYdj ccy
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILvXkM8TS8fDot22LTfU2jDVOqK20LmK8Rd7xO05vYns stq
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmJoiGO5YD3lbbIOJ99Al2xxm6QS9q+dTCTtlALjYI5f9ICGZJT8PEGlV9BBNCRQdgb3i2LBzQi90Tq1oG6/PcTV3Mto2TawLz5+2+ym29eIq1QIhVTLmZskK815FpawWqxY6+xpGU3vP1WjrFBbhGtl+CCaN+P2TWNkrR8FjG2144hdAlFfEEqfQC+TXbsyJCYoExuxGDJo8ae0JGbz9w1A1UbjnHwKnoxvirTFEbw9IHJIcTdUwuQKOrwydboCOqeaHt74+BnnCOZhpYqMDacrknHITN4GfFFzbs6FsE8NAwFk6yvkNXXzoe60iveNXtCIYuWjG517LQgHAC5BdaPgqzYNg+eqSul72e+jjRs+KDioNqvprw+TcBBO1lXZ2VQFyWyAdV2Foyaz3Wk5qYlOpX/9JLEp6H3cU0XCFR25FdXmjQ4oXN1QEe+2akV8MQ9cWhFhDcbY8Q1EiMWpBVC1xbt4FwE8VCTByZOZsQ0wPVe/vkjANOo+brS3tsR18= 00@xmuhpc
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCxcIWDQxVyIRqCGR4uWtrh4tLc025+q6du2GVsox8IzmBFkjNY8Au5GIMP5BKRstxFdg3f/wam8krckUN9rv5+OHB9U8HGz77Xs0FktqRVNMaDPdptePZQJ9A9eW3kkFDfQnORJtiVcEWfUBS3pi0QFOHylnG27YyC/Vjx9tjvtJWKsQEVTFJbFHPdi+G7lHTpqIGx+/a2JN9O6uVujXXYvjSVXsd+CWB9VMZMvYCIz2Ecb6RqR3brj4FhRRl8zyCj+J4ACYFdGWL98fTab2uPHbpVeKrefFFA43JOD/4zwBx/uw7MAQAq0GunTV3FpBfIAQHWgftf2fSlbz20oPjCwdYn9ZuGJOBUroryex7AKZmnSYM3biLHcctQfZtxqVPEU3W/62MUsI/kZb9RcF24JRksMoS2XWTiv2HFf5ijQGLXXOjqiTlGncwiKf65DwkDBsSxzgbXk5Uo86viq6UITFXPx/RytU+SUiN4Wb7wcBTjt/+tyQd1uqc7+3DCDXk= 01@xmuhpc

View File

@@ -29,7 +29,6 @@ inputs:
network.settings.static.enp3s0 =
{ ip = "192.168.1.2"; mask = 24; gateway = "192.168.1.1"; dns = "192.168.1.1"; };
kernel.patches = [ "btrfs" ];
binfmt = {};
};
hardware.gpu.type = "intel";
services =
@@ -38,7 +37,7 @@ inputs:
xray.client =
{
xray.serverName = "xserver2.vps9.chn.moe";
coredns = { extraInterfaces = [ "enp3s0" ]; hosts."git.chn.moe" = "127.0.0.1"; };
dnsmasq = { extraInterfaces = [ "enp3s0" ]; hosts."git.chn.moe" = "127.0.0.1"; };
};
beesd."/".hashTableSizeMB = 10 * 128;
postgresql.mountFrom = "ssd";

View File

@@ -15,24 +15,16 @@ inputs:
btrfs =
{
"/dev/mapper/root1" = { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
"/dev/mapper/tf1" =
{
"/" = "/nix/tf";
"/nix/remote/jykang" = "/data/gpfs01/jykang/.nix";
"/nix/remote/xmuhk" = "/public/home/xmuhk/.nix";
"/nix/remote/wlin" = "/data/gpfs01/wlin/.nix";
};
"/dev/mapper/tf1"."/" = "/nix/tf";
};
nfs."nas.ts.chn.moe:/" = { mountPoint = "/nix/remote/nas"; mountBeforeSwitch = false; };
};
luks.auto =
{
"/dev/disk/by-partlabel/pc-root1" = { mapper = "root1"; ssd = true; };
"/dev/disk/by-partlabel/pc-tf1".mapper = "tf1";
"/dev/disk/by-partlabel/pc-tf2" = { mapper = "tf2"; ssd = true; };
};
swap = [ "/nix/swap/swap" ];
resume = { device = "/dev/mapper/root1"; offset = 156901642; };
resume = { device = "/dev/mapper/root1"; offset = 228199020; };
};
grub.windowsEntries."08D3-10DE" = "Windows";
nix.marches =
@@ -50,7 +42,7 @@ inputs:
];
nixpkgs = { march = "znver5"; rocm = true; };
sysctl.laptop-mode = 5;
kernel = { variant = "cachyos"; patches = [ "btrfs" ]; };
kernel.variant = "cachyos";
};
hardware = { gpu.type = "amd"; asus = {};};
services =
@@ -67,7 +59,7 @@ inputs:
};
};
sshd = {};
xray.client.coredns =
xray.client.dnsmasq =
{
hosts = builtins.listToAttrs
(
@@ -75,7 +67,7 @@ inputs:
(name: { inherit name; value = "144.34.225.59"; })
[ "mirism.one" "beta.mirism.one" "ng01.mirism.one" "initrd.vps6.chn.moe" ])
);
extraInterfaces = [ "wlp194s0" ];
extraInterfaces = [ "wlo1" ];
};
harmonia.store = "/nix/tf";
beesd =
@@ -104,7 +96,7 @@ inputs:
mariadb.mountFrom = "nodatacow";
open-webui.ollamaHost = "127.0.0.1";
howdy = {};
postgresql.enable = true;
waydroid = {};
};
bugs = [ "amdpstate" ];
packages = { mathematica = {}; vasp = {}; };
@@ -116,7 +108,7 @@ inputs:
services.udev.extraRules =
''
# CPU
SUBSYSTEM=="power_supply", KERNEL=="BAT0", ACTION=="*", RUN+="${inputs.pkgs.ryzenadj}/bin/ryzenadj --set-coall=0x0fff40"
SUBSYSTEM=="power_supply", KERNEL=="BAT0", ACTION=="*", RUN+="${inputs.pkgs.ryzenadj}/bin/ryzenadj --set-coall=0x0fff20"
'';
# 解决有时蓝牙不能使用的问题
boot.kernelParams = [ "mt7925e.disable_aspm=1" ];

View File

@@ -10,6 +10,8 @@ mariadb:
slurm: ENC[AES256_GCM,data:fGvNMmqk7Cee28VJ1QoBVrBbgIUbj/F1W0SRjdP8N4K/M8Wx4AVm1kAr0IAhPWyDLXlIjM1NUvuEV5BpYDBdjg==,iv:rFTMJ4x2kgENQUA8ftSaLjdOc25i5mWR3UYbdq54vjs=,tag:6feD0eCSv7bcHWBveLNJwg==,type:str]
nix:
remote: ENC[AES256_GCM,data:uosYkxTCB0wiY+Uufk//OcBZFN3EzbZoQGZ95M9eZMjQ5AobAZqosi4laE+EMcZL1CqYqlWXaSoEUOB8biUaZPseo+1AX1TlmUgZ7QpkfOX0VKZu01C6C+lVyqVqMFq6z1BFyX/oeITMIfnd4a/2KwJCHLAZ4hMkJ5p+aJwByKGa3N/2m41HH/1S3z7pYQWj7YJxunTPPG6WNSiRncQki11rvmddwnXmsBF89+jW1Phge8U295haC57T5oIGPxR645IeTK4ZUlL8eVuZ+BhsnwbkYcaxvjSwe+DOIVPupR8GW+gis7KxwE89kqvnQhinamexcPUz4lGHlqO/Xn6jrJx6T/wXF+19epAzeHapYte3dTWNsdPwPLPJihT16YT5fwrLnH3zq8kexWz1crmnCGUoaBs4S2tHWHLgv2lTv0IHLx5F6ijpDBj/Avg9YILIURzdeea+rBxdycHasUDTVlJtYKRH5J+WbAKWI+oJ5qmXjIRUYL+O9xIUfOGO+1b3xs8MYxRWuvDV2P88N8vN,iv:yQQp5wjbSVn1oia5yL7d6GF9Vo704G0iOQRGMbzQHzg=,tag:bpBag5y5n+7ojOa8QOcDvA==,type:str]
searx:
secret-key: ENC[AES256_GCM,data:KhIP+Rz3rMfNgPEGTlKGvm6gl1/ZuPI=,iv:GcaLEJHKJO3n6IaeiFr9PaJ6eNx04/VjX3UgmBF429g=,tag:HkplyH9hTHUaEZ709TyitA==,type:str]
tinc: ENC[AES256_GCM,data:qI2KAyJiC9m+IOzTQ7SFjWnjzzkxvNe6R2yxyK+C/YnEK4JdYqEETIMuqAUQxaSyHjKk9x6kDs3YPC2AyNKf+lc22YoB35Eo5ym+3+GDDPTL4wL4aI4xnGHVLH3JrSFHDyIbvu8R2NLnSy2j4O5Uj+jJmOz/b1xV8zeLbdoFwLgZCbcxvqkIwMlJdDGjAtjEb8eDkjtVzSRSPXohgYgmhxKZyA5/7c41e+/X6RIsHHeOD+Ppz5jlYAkRrsvAxGTfrMN2xTZopxc=,iv:E/8ys6ucmmaKawqrgumJdjTsC17F7Y0RgnHYfu3RIPQ=,tag:OZM/HG88gyF9TZXwHcd3nA==,type:str]
open-webui:
openai: ENC[AES256_GCM,data:8CQLvoDuGtQ7PN+1SOmXF48dV/G6fDOiu6olkhSbWEjYcNO4VVmxtHw=,iv:rKBxOTB7/LXfXWVrBFBJeyn43R82oBYCxup8OzWvzKk=,tag:ByoyMizWc9Lpnt+ciYcszg==,type:str]
@@ -34,7 +36,7 @@ sops:
OUlxNjdQaXdXMkZ6bnV1ek4yZ2dpbkEKpKGOAxo5Eef2jtGrg4iSzmGCeg+vTgvu
+K8b+O19MIkGMDBm6UbYUPtc/7eqoEZRiTUzNMTmfkLVS4ul5zou9A==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2025-12-18T13:32:13Z"
mac: ENC[AES256_GCM,data:iGNeV1hyiuhmLApu9o0IA75+oNJPp5I9ehTEdcVIyNQfKLeUbzcxz3tiKQNxxDy15vjtpBb/SicgSF60i6k54Y7KRRFadlRQ6erqZRj/6XlLqGwW0EKxN1EEEG9QNqMt6smA0WsdaoInmWWalaC14P55toU6LKbL05hSfSwtbXo=,iv:WEMF3u/8LwlIG5tAf25mM5IX7KHHXNpuhDxVzIAmZmU=,tag:PJc4r6b8ppQg/rcXsoDDpA==,type:str]
lastmodified: "2025-12-04T12:34:21Z"
mac: ENC[AES256_GCM,data:S2ijc6yqf12ETehYD5Qbjf5CqEv9JiPOiP1cp2O/WiVPM/fUYBgae/jCC22KEoo4EbSgefV0IvTNM+1Xw2ROmIE19I6vLvKcc1B+qI2kUtXurL1XcpYWNiZg+dlLFFYq8NloktwC9TWQuOC4c6kI2UaWYvzOx9ZBDZ8NLJCHbWo=,iv:/fGS/lgnVFlTdIS+IpKTfyKinfGSUbb1tbLM0jPZxvE=,tag:oVs/jCBRoRBCBbTBOuRjSA==,type:str]
unencrypted_suffix: _unencrypted
version: 3.11.0

View File

@@ -102,7 +102,6 @@ inputs:
"ccy" # 陈超业
"twr" # 唐文睿,吴猛的学生
"lsp" # 李书平的不知道哪个学生要用
"stq" # 孙天骐
];
};
};

View File

@@ -9,7 +9,16 @@ inputs:
nixpkgs.march = "icelake-server";
network.settings =
{ static.eno8303 = { ip = "192.168.178.3"; mask = 24; gateway = "192.168.178.1"; }; trust = [ "eno8303" ]; };
fileSystems.swap = [ "/nix/swap/swap" ];
fileSystems =
{
swap = [ "/nix/swap/swap" ];
mount.btrfs."/dev/disk/by-partlabel/srv2-node2-root1" =
{
"/nix/remote/jykang.xmuhpc" = "/data/gpfs01/jykang/.nix";
"/nix/remote/xmuhk" = "/public/home/xmuhk/.nix";
"/nix/remote/wlin" = "/data/gpfs01/wlin/.nix";
};
};
};
services =
{

View File

@@ -61,7 +61,6 @@ inputs:
beesd."/" = {};
coredns.interface = "ens18";
headscale = {};
missgram = {};
};
};
networking.nftables.tables.forward =

View File

@@ -5,10 +5,6 @@ coturn:
tinc: ENC[AES256_GCM,data:E3OrPA67R48x5FJUW0ZbERlclz8Z/XokAaGTeBQLPEHSeqEArHYSZkdJRZejFrBruJPlGZMPNBQzlIBXOfXKwMnlBDaGJIIJHIzPDGG9W7QF4IIRK/BjVZHFwfKvZtbUDGsqLcCSe5+ttmyucBaFGquXhnD/Tu09uyWtRvS10KAJLY0Z2/16CFB1+8egJIcYw2TFXObo+KR92Va0qwiDSepKaJtYLimDGRKk04QGj+BYa5y8PjIG6bz8UG82mmCiV7XM3EPlSMA=,iv:kawsklNGFbRhxKuUwvNL2WyBxuYu2T/uks1cJ4i8NhA=,tag:V+jAaxQX7JCiR5+wIVW4Nw==,type:str]
postgresql:
headscale: ENC[AES256_GCM,data:z2cyyT1TcIhNJCBeGn072aFI2nAioWZQvpyzoky4tWtMymKlw4ilOtSYAsp+kaNOoqvWSmoAQNJLNzeDk1iTCQ==,iv:hZdS/CAVBO0k/AmX3qw3YwTYgK49Aeu5QI3YCAduiZ0=,tag:2l4GPV/T2GHjAAUDX3LaEA==,type:str]
missgram: ENC[AES256_GCM,data:zUY6397ThfeHDD8/Msy3mWnTjXCkEhpgsUwcjXnhIiNET1J14hIojCbwUpdCtGTFF+RQOtaS9aGSp8ctQeWIwg==,iv:0+WeCoMFQFhnzjSfvz0ZnqK6FIn1QBHr9fB+tjBNSDk=,tag:Bf5krX2hxIPlkdiAXppSqA==,type:str]
missgram:
secret: ENC[AES256_GCM,data:qsxJue8mGAJejSxOoPd4MXD06upnk0fxUM5EKPBs/WI=,iv:HaHj/vJkIERUQ0Lr93s9kaApNWPjDcpLu2897qmCjqA=,tag:u73jUDd6pGKk1yir/oF4hQ==,type:str]
telegramBotToken: ENC[AES256_GCM,data:kNGhj1SjyK1H8NJmJLi90cpGtWmmGpFEFFT/JkDX4QqxbOC6BfFIMgzVsZ5GVQ==,iv:sccRmCs8HBAvi9mDAaz8OjxqXLAVXepJHaj7RrUt6kI=,tag:RuK3EdRMVhS9pVDw50lW6A==,type:str]
sops:
age:
- recipient: age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
@@ -29,7 +25,7 @@ sops:
ZXFTU3ZCaW1pTVh0RUJzdDdGdHlPYTgK2mlgcX2kEc8+2UDdBnhUm6IIuh8V6agW
ooxH9OEPXUVI/4JcDo4v8ZUhAyU1ehLH0Ef7PJCChOZe2KZmWSNbhA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2025-12-28T09:13:01Z"
mac: ENC[AES256_GCM,data:rVjqBfoA/DUgb1Yqc3FzeMBPWJniAYKYcbLauh5flpKYfcTp01lr/pTbyB5BLEHZLOYwMf2PNjfG8zPDKv2z1cjYwoYEj9bur4N6pagR/NFuAoEvgOjm0YlrTVkskRmLxaqxYB749y4wWS04MvJhfPON4hWMdoYguPBmCpZMKqc=,iv:4ZVGsLKQNxqKmpaDcIpA21rAe51TKVR8diN5/d7SOQg=,tag:pIw/tqw+211V/0xK9M3hvg==,type:str]
lastmodified: "2025-12-04T12:35:00Z"
mac: ENC[AES256_GCM,data:hiEzLAEtU82Be/+nuMv10/ex/ZacXkNR9LkxdBn/x3kY/0uwHSDI9LGjn0b0/KWIg5zLoxV+zPZEBJQhN4QcRzDT6538zwc0yTv9fkFS0NUF5GchHi8Is6EjjHANbSLe3MEwFumKjx3Lm8AyMjcOXiCckzo4aXV98SHZW9EMVbQ=,iv:Nzzlfsm2aMSVa6NNh4ar67J5dzheWRIVLHSUu5ndjvE=,tag:jO8x2LUpP75g7cXyIYDfQw==,type:str]
unencrypted_suffix: _unencrypted
version: 3.11.0

View File

@@ -5,11 +5,10 @@ let
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/wlin/.nix"; nixos = false; };
});
wlin = pkgs.symlinkJoin
{
name = "wlin";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; };
};
in wlin
in pkgs.symlinkJoin
{
name = "jykang";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; };
}

View File

@@ -59,12 +59,11 @@ let
trap cleanup SIGINT SIGTERM SIGHUP EXIT
tail -f /dev/null
'';
xmuhk = pkgs.symlinkJoin
{
name = "xmuhk";
paths = (with pkgs; [ hello btop htop iotop pv localPackages.lumerical.lumerical.cmd ])
++ [ lumericalLicenseManager ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; archive = pkgs.closureInfo { rootPaths = [ xmuhk.drvPath ]; }; };
};
in xmuhk
in pkgs.symlinkJoin
{
name = "xmuhk";
paths = (with pkgs; [ hello btop htop iotop pv localPackages.lumerical.lumerical.cmd ])
++ [ lumericalLicenseManager ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; };
}

598
flake.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,10 +11,15 @@
home-manager = { url = "github:nix-community/home-manager/release-25.11"; inputs.nixpkgs.follows = "nixpkgs"; };
sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; };
nix-index-database = { url = "github:Mic92/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; };
nur-xddxdd = { url = "github:CHN-beta/nur-xddxdd"; inputs.nixpkgs.follows = "nixpkgs"; };
nur-xddxdd = { url = "github:xddxdd/nur-packages"; inputs.nixpkgs.follows = "nixpkgs"; };
impermanence.url = "github:CHN-beta/impermanence";
nur-linyinfeng = { url = "github:linyinfeng/nur-packages"; inputs.nixpkgs.follows = "nixpkgs"; };
nix-flatpak.url = "github:gmodena/nix-flatpak";
chaotic =
{
url = "github:chaotic-cx/nyx";
inputs = { nixpkgs.follows = "nixpkgs"; home-manager.follows = "home-manager"; };
};
catppuccin = { url = "github:catppuccin/nix"; inputs.nixpkgs.follows = "nixpkgs"; };
bscpkgs = { url = "github:CHN-beta/bscpkgs"; inputs.nixpkgs.follows = "nixpkgs"; };
aagl = { url = "github:ezKEa/aagl-gtk-on-nix/release-25.11"; inputs.nixpkgs.follows = "nixpkgs"; };
@@ -22,16 +27,11 @@
nixvirt = { url = "github:CHN-beta/NixVirt"; inputs.nixpkgs.follows = "nixpkgs"; };
buildproxy = { url = "github:polygon/nix-buildproxy"; inputs.nixpkgs.follows = "nixpkgs"; };
niri = { url = "github:sodiboo/niri-flake"; inputs.nixpkgs.follows = "nixpkgs"; };
nix4vscode =
{
url = "github:nix-community/nix4vscode?rev=6c603c201b11dafda616940bac1f295144ac1c41";
inputs.nixpkgs.follows = "nixpkgs";
};
nix4vscode = { url = "github:nix-community/nix4vscode"; inputs.nixpkgs.follows = "nixpkgs"; };
dankmaterialshell = { url = "github:AvengeMedia/DankMaterialShell"; inputs.nixpkgs.follows = "nixpkgs"; };
harmonia.url = "github:nix-community/harmonia";
nix-cachyos-kernel = { url = "github:CHN-beta/nix-cachyos-kernel"; inputs.nixpkgs.follows = "nixpkgs"; };
misskey = { url = "git+https://github.com/CHN-beta/misskey?submodules=1&rev=4c0425d6a229d3a75f2ff01cc30cf90434381cec"; flake = false; };
misskey = { url = "git+https://github.com/CHN-beta/misskey?submodules=1"; flake = false; };
rsshub = { url = "github:DIYgod/RSSHub"; flake = false; };
zpp-bits = { url = "github:eyalz800/zpp_bits"; flake = false; };
concurrencpp = { url = "github:David-Haim/concurrencpp"; flake = false; };
@@ -52,6 +52,7 @@
py4vasp = { url = "github:vasp-dev/py4vasp?ref=v0.10.2"; flake = false; };
pocketfft = { url = "github:mreineck/pocketfft"; flake = false; };
blog = { url = "git+https://git.chn.moe/chn/blog-public.git?lfs=1"; flake = false; };
nixos-wallpaper = { url = "git+https://git.chn.moe/chn/nixos-wallpaper.git?lfs=1"; flake = false; };
vaspberry = { url = "github:Infant83/VASPBERRY"; flake = false; };
ufo = { url = "git+https://git.chn.moe/chn/ufo.git?lfs=1"; flake = false; };
stickerpicker = { url = "github:maunium/stickerpicker"; flake = false; };
@@ -63,8 +64,6 @@
pybinding = { url = "git+https://github.com/dean0x7d/pybinding?submodules=1"; flake = false; };
brokenaxes = { url = "github:bendichter/brokenaxes"; flake = false; };
mirism-old = { url = "github:CHN-beta/mirism-old-public"; flake = false; };
sqlgen = { url = "git+https://github.com/getml/sqlgen?submodules=1"; flake = false; };
reflectcpp = { url = "git+https://github.com/getml/reflect-cpp?submodules=1"; flake = false; };
};
outputs = inputs: let localLib = import ./flake/lib inputs.nixpkgs.lib; in
@@ -73,7 +72,11 @@
nixosConfigurations = import ./flake/nixos.nix { inherit inputs localLib; };
overlays.default = final: prev:
{ localPackages = (import ./packages { inherit localLib; pkgs = final; topInputs = inputs; }); };
config.dns = inputs.self.packages.x86_64-linux.dns-push.meta.config;
config =
{
branch = import ./flake/branch.nix;
dns = inputs.self.packages.x86_64-linux.dns-push.meta.config;
};
devShells.x86_64-linux = import ./flake/dev.nix { inherit inputs; };
src = import ./flake/src.nix { inherit inputs; };
apps.x86_64-linux.dns-push = { type = "app"; program = "${inputs.self.packages.x86_64-linux.dns-push}"; };

1
flake/branch.nix Normal file
View File

@@ -0,0 +1 @@
"archive"

View File

@@ -3,62 +3,55 @@
biu = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.biu ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
hpcstat = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
{
inputsFrom = [ (pkgs.localPackages.hpcstat.override { version = null; }) ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
sbatch-tui = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.sbatch-tui ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
ufo = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.ufo ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
chn-bsub = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.chn-bsub ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
info = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.info ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
vm = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.vm ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
xinli = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.xinli ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
missgram = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
{
inputsFrom = [ pkgs.localPackages.missgram ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.clang-tools_18 ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};

View File

@@ -8,7 +8,7 @@ let
vps6 =
[
"blog" "catalog" "coturn" "element" "initrd.vps6" "sticker" "synapse-admin" "tgapi" "ua" "xserver2"
"xserver2.vps6" "s" "headscale" "missgram"
"xserver2.vps6" "s" "headscale"
# to pc
""
];

View File

@@ -38,11 +38,12 @@ in platformConfig //
overlays =
[
inputs.topInputs.aagl.overlays.default
inputs.topInputs.nur-xddxdd.overlays.inSubTree
# xddxdd overlay use prev instead of final, we import it manually
(final: prev: { svp = final.callPackage "${inputs.topInputs.nur-xddxdd}/pkgs/uncategorized/svp"
{ sources = final.callPackage "${inputs.topInputs.nur-xddxdd}/_sources/generated.nix" {}; }; })
inputs.topInputs.buildproxy.overlays.default
inputs.topInputs.nix4vscode.overlays.default
inputs.topInputs.bscpkgs.overlays.default
inputs.topInputs.nix-cachyos-kernel.overlay
(final: prev:
{
nur-linyinfeng = (inputs.topInputs.nur-linyinfeng.overlays.default final prev).linyinfeng;
@@ -72,6 +73,10 @@ in platformConfig //
google-chrome = prev.google-chrome.override (prev:
{ commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; });
xray = prev.xray.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xray.patch ]; });
linux-firmware = prev.linux-firmware.overrideAttrs (prev: { patchPhase = prev.patchPhase or "" +
''
cp ${./gc_11_5_1_mes_2.bin} amdgpu/gc_11_5_1_mes_2.bin
''; });
}
// (
let
@@ -97,6 +102,19 @@ in platformConfig //
})
];
};
# pkgs-unstable =
# {
# source = "nixpkgs-unstable";
# overlays =
# [
# inputs.topInputs.self.overlays.default
# (_: _:
# {
# genericPackages = import inputs.topInputs.nixpkgs-unstable
# { inherit system; config = { allowUnfree = true; inherit allowInsecurePredicate; }; };
# })
# ];
# };
};
packages = name:
let flakeSource = inputs.topInputs.${source.${name}.source or source.${name}};
@@ -118,11 +136,10 @@ in platformConfig //
// (inputs.lib.optionalAttrs (prev.stdenv.hostPlatform.sse4_1Support)
{
frei0r = final.genericPackages.frei0r;
valkey = final.genericPackages.valkey;
})
// (inputs.lib.optionalAttrs (nixpkgs.march == "alderlake")
{ redis = prev.redis.overrideAttrs (prev: { doCheck = false; }); })
// (inputs.lib.optionalAttrs (nixpkgs.march == "cascadelake")
{ postgresql_17 = prev.postgresql_17.override { jitSupport = false; }; })
// (inputs.lib.optionalAttrs (nixpkgs.march != null)
{
ffmpeg_8 = prev.ffmpeg_8.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./ffmpeg.patch ]; });
@@ -134,9 +151,11 @@ in platformConfig //
ffmpeg-headless = final.ffmpeg_8-headless;
ffmpeg-full = final.ffmpeg_8-full;
assimp = prev.assimp.override { stdenv = final.genericPackages.stdenv; };
# redis = prev.redis.overrideAttrs (prev: { doCheck = false; });
# wannier90 = prev.wannier90.overrideAttrs { buildFlags = [ "dynlib" ]; };
xen = prev.xen.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xen.patch ]; });
lib2geom = prev.lib2geom.overrideAttrs (prev: { doCheck = false; });
libreoffice-fresh = prev.libreoffice-fresh.override (prev:
libreoffice-qt6-still = prev.libreoffice-qt6-still.override (prev:
{ unwrapped = prev.unwrapped.overrideAttrs (prev: { postPatch = prev.postPatch or "" +
''
sed -i '/CPPUNIT_TEST.testDubiousArrayFormulasFODS/d' sc/qa/unit/functions_array.cxx
@@ -148,7 +167,15 @@ in platformConfig //
pythonPackagesExtensions = prev.pythonPackagesExtensions or [] ++ [(final: prev:
{
picosvg = prev.picosvg.overridePythonAttrs { doCheck = false; };
# aiocache = prev.aiocache.overridePythonAttrs { doCheck = false; };
# numpy =
# if inputs.lib.hasInfix "bar" prev.numpy.outPath then prev.numpy.overridePythonAttrs
# (prev:{ disabledTests = prev.disabledTests or [] ++ [ "test_nowrap_private_proceedures" ]; })
# else prev.numpy;
})];
ctranslate2 = prev.ctranslate2.overrideAttrs (prev:
{ cmakeFlags = prev.cmakeFlags or [] ++ [ "-DENABLE_CPU_DISPATCH=OFF" ]; });
# # valkey = final.redis;
})
)];
}

Binary file not shown.

View File

@@ -14,8 +14,7 @@ lib: rec
(
let handle = module: let type = builtins.typeOf module; in
if type == "path" || type == "string" then (handle (import module))
else if type == "lambda" && builtins.functionArgs module == {}
then ({ pkgs, utils, ... }@inputs: (module inputs))
else if type == "lambda" then ({ pkgs, utils, ... }@inputs: (module inputs))
else module;
in handle
)

View File

@@ -46,12 +46,8 @@
};
archive = pkgs.writeText "archive" (builtins.concatStringsSep "\n" (builtins.concatLists
[
(inputs.nixpkgs.lib.mapAttrsToList
(_: v: (v.extendModules { modules = [{ config.system.includeBuildDependencies = true; }]; })
.config.system.build.toplevel)
inputs.self.outputs.nixosConfigurations)
(inputs.nixpkgs.lib.mapAttrsToList (_: v: v.config.system.build.toplevel) inputs.self.outputs.nixosConfigurations)
[ src ]
(builtins.attrValues inputs)
]));
}
// (builtins.mapAttrs (_: v: v.config.system.build.toplevel) inputs.self.outputs.nixosConfigurations)

View File

@@ -1,4 +1,4 @@
{ inputs }: let inherit (inputs.self.packages.x86_64-linux) pkgs; inherit (inputs.nixpkgs) lib; in
{ inputs }: let inherit (inputs.self.packages.x86_64-linux) pkgs; in
{
nvhpc =
{
@@ -29,7 +29,7 @@
netboot = pkgs.fetchurl
{
url = "https://boot.netboot.xyz/ipxe/netboot.xyz.iso";
sha256 = "0h7shj8gm3kzh7d7bcwygkp3fz5mac957accqhr9dhpjaj9dsmlr";
sha256 = "6GeOcugqElGPoPXeaWVpjcV5bCFxNLShGgN/sjsVzuI=";
};
};
vasp =
@@ -84,7 +84,7 @@
};
src = pkgs.requireFile
{
name = "licenseManager";
name = "src";
sha256 = "1h93r0bb37279dzghi3k2axf0b8g0mgacw0lcww5j3sx0sqjbg4l";
hashMode = "recursive";
message = "Source file not found.";
@@ -190,25 +190,22 @@
url = "mirror://sourceforge/atomkit/Binaries/atomkit.0.9.0.linux.x64.tar.gz";
sha256 = "0y9z7wva7zikh83w9q431lgn3bqkh1v5w6iz90dwc75wqwk0w5jr";
};
btrfs =
guix = pkgs.fetchurl
{
"6.12" =
url = "https://ci.guix.gnu.org/download/2857";
name = "guix.iso";
sha256 = "0xqabnay8wwqc1a96db8ix1a6bhvgm84s5is1q67rr432q7gqgd4";
};
peerBanHelper =
{
image = "ghostchu/peerbanhelper:v8.0.12";
imageFile = pkgs.dockerTools.pullImage
{
patch = pkgs.fetchurl
{
url = "https://github.com/kakra/linux/pull/36.patch";
sha256 = "0wimihsvrxib6g23jcqdbvqlkqk6nbqjswfx9bzmpm1vlvzxj8m0";
};
structuredExtraConfig.BTRFS_EXPERIMENTAL = lib.kernel.yes;
};
"6.18" =
{
patch = pkgs.fetchurl
{
url = "https://github.com/kakra/linux/pull/40.patch";
sha256 = "02q3x64rdyj6nx7jdknlg7x69v10xxbm0ry2xbgr069dfdm2w1ya";
};
structuredExtraConfig = { BTRFS_ALLOCATOR_HINTS = lib.kernel.yes; BTRFS_READ_POLICIES = lib.kernel.yes; };
imageName = "ghostchu/peerbanhelper";
imageDigest = "sha256:fce7047795fe1e6d730ea2583b390ccc336e79eb2d8dae8114f4f63f00208879";
hash = "sha256-7Z2ewDpGFXyvCze9HZ7KwFwn9o9R6Y4pjJDcr5Wmy1g=";
finalImageName = "ghostchu/peerbanhelper";
finalImageTag = "v8.0.12";
};
};
}

View File

@@ -7,6 +7,8 @@ inputs: let inherit (inputs) topInputs; in
topInputs.nix-index-database.nixosModules.nix-index
topInputs.impermanence.nixosModules.impermanence
topInputs.nix-flatpak.nixosModules.nix-flatpak
topInputs.chaotic.nixosModules.default
{ config.chaotic.nyx.overlay.onTopOf = "user-pkgs"; }
topInputs.catppuccin.nixosModules.catppuccin
topInputs.aagl.nixosModules.default
topInputs.nixvirt.nixosModules.default
@@ -16,8 +18,8 @@ inputs: let inherit (inputs) topInputs; in
{ config.home-manager.sharedModules =
[
topInputs.catppuccin.homeModules.catppuccin
topInputs.dankmaterialshell.homeModules.dank-material-shell
topInputs.dankmaterialshell.homeModules.niri
topInputs.dankmaterialshell.homeModules.dankMaterialShell.default
topInputs.dankmaterialshell.homeModules.dankMaterialShell.niri
];}
] ++ (inputs.localLib.findModules ./.);
}

View File

@@ -53,8 +53,8 @@ inputs:
# browser
google-chrome tor-browser
# office
crow-translate zotero pandoc texliveFull poppler-utils pdftk pdfchain kdePackages.kruler kdePackages.okular
ydict texstudio panoply pspp libreoffice-fresh ocrmypdf typst # paperwork
crow-translate zotero pandoc texliveFull poppler-utils pdftk pdfchain
ydict texstudio panoply pspp libreoffice-qt6-still ocrmypdf typst # paperwork
# required by ltex-plus.vscode-ltex-plus
ltex-ls ltex-ls-plus
# matplot++ needs old gnuplot
@@ -66,22 +66,14 @@ inputs:
# virtualization
virt-viewer bottles wineWowPackages.stagingFull genymotion playonlinux
# media
nur-xddxdd.svp
svp
# for kdenlive auto subtitle
openai-whisper
# daily management
activitywatch super-productivity
# game
lutris
];
_pythonPackages = [(pythonPackages: with pythonPackages;
[
scipy scikit-learn jupyterlab autograd inputs.pkgs.localPackages.phono3py numpy
openai python-telegram-bot fastapi-cli pypdf2 pandas matplotlib plotly gunicorn redis jinja2 certifi
charset-normalizer idna orjson psycopg2 inquirerpy requests tqdm pydbus inputs.pkgs.localPackages.brokenaxes
# allow pandas read odf
odfpy
])];
[ phonopy scipy scikit-learn jupyterlab autograd inputs.pkgs.localPackages.phono3py numpy ])];
};
user.sharedModules =
[{

View File

@@ -1,15 +0,0 @@
inputs:
{
options.nixos.packages.direnv = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule {});
default =
if (inputs.config.nixos.model.type == "desktop") && (inputs.config.nixos.model.arch == "x86_64") then {}
else null;
};
config = let inherit (inputs.config.nixos.packages) direnv; in inputs.lib.mkIf (direnv != null)
{
programs.direnv = { enable = true; nix-direnv.enable = true; };
nixos.user.sharedModules = [{ config.programs.direnv.enable = true; }];
};
}

View File

@@ -1,20 +0,0 @@
inputs:
{
options.nixos.packages.ghostty = let inherit (inputs.lib) mkOption types; in mkOption
{ type = types.nullOr (types.submodule {}); default = {}; };
config = let inherit (inputs.config.nixos.packages) ghostty; in inputs.lib.mkIf (ghostty != null)
{
nixos =
{
user.sharedModules =
[{
config.programs.ghostty =
{
enable = true;
settings = { scrollback-limit = 100000000; keybind = "ctrl+shift+r=reset"; };
};
}];
packages.packages._packages = [ inputs.pkgs.ghostty ];
};
};
}

View File

@@ -44,8 +44,7 @@ inputs:
# stupid things
toilet lolcat localPackages.stickerpicker graph-easy
# shell
# somehow fish does not compile on aarch64
(if inputs.config.nixos.model.arch == "x86_64" then kitty else emptyDirectory)
kitty ghostty
]
++ (with inputs.config.boot.kernelPackages; [ cpupower usbip ]);
};
@@ -55,6 +54,7 @@ inputs:
nix-index.enable = true;
command-not-found.enable = false;
autojump.enable = true;
direnv = { enable = true; nix-direnv.enable = true; };
mosh.enable = true;
};
services =

View File

@@ -40,6 +40,7 @@ inputs:
"${inputs.pkgs.oh-my-posh}/share/oh-my-posh/themes/atomic.omp.json"));
};
zoxide.enable = true;
direnv.enable = true;
};
}];
};

View File

@@ -27,7 +27,10 @@ inputs:
];
_pythonPackages = [(pythonPackages: with pythonPackages;
[
phonopy
openai python-telegram-bot fastapi-cli pypdf2 pandas matplotlib plotly gunicorn redis jinja2 certifi
charset-normalizer idna orjson psycopg2 inquirerpy requests tqdm pydbus inputs.pkgs.localPackages.brokenaxes
# allow pandas read odf
odfpy
# for vasp plot-workfunc.py
ase
])];

View File

@@ -63,8 +63,6 @@ inputs:
"ms-toolsai.jupyter" "ms-toolsai.jupyter-keymap" "ms-toolsai.jupyter-renderers"
"ms-toolsai.vscode-jupyter-cell-tags" "ms-toolsai.vscode-jupyter-slideshow"
"ms-toolsai.datawrangler"
# nushell
"TheNuProjectContributors.vscode-nushell-lang"
];
keybindings =
[
@@ -78,14 +76,6 @@ inputs:
key = "tab";
command = "-editor.action.inlineSuggest.commit";
}
{
key = "tab";
command = "-editor.action.inlineSuggest.jump";
}
{
key = "tab";
command = "-editor.emmet.action.expandAbbreviation";
}
{
key = "ctrl+enter";
command = "-editor.action.inlineSuggest.commit";
@@ -181,8 +171,13 @@ inputs:
"update.mode" = "none";
"editor.tabSize" = 2;
"nix.enableLanguageServer" = true;
"nix.serverPath" = "nixd";
"nix.serverPath" = "nil";
"nix.formatterPath" = "nixpkgs-fmt";
"nix.serverSettings"."nil" =
{
"diagnostics"."ignored" = [ "unused_binding" "unused_with" ];
"formatting"."command" = [ "nixpkgs-fmt" ];
};
"xmake.envBehaviour" = "erase";
"git.openRepositoryInParentFolders" = "never";
"todo-tree.regex.regex" = "(//|#|<!--|;|/\\*|^|%|^[ \\t]*(-|\\d+.))\\s*($TAGS)";

View File

@@ -10,10 +10,7 @@ inputs:
user.sharedModules =
[{
config.programs.zellij =
{
enable = true;
settings = { scroll_buffer_size = 100000000; show_startup_tips = false; show_release_notes = false; };
};
{ enable = true; settings = { show_startup_tips = false; show_release_notes = false; }; };
}];
};
};

View File

@@ -34,45 +34,38 @@ inputs:
home.shell.enableZshIntegration = true;
}
{
programs =
let optional =
inputs.lib.mkIf (builtins.elem home-inputs.config.home.username
[ "chn" "root" "aleksana" "alikia" "hjp" "lilydjwg" ]);
in
programs.zsh = inputs.lib.mkIf
(builtins.elem home-inputs.config.home.username [ "chn" "root" "aleksana" "alikia" "hjp" "lilydjwg" ])
{
zsh = optional
{
plugins =
[
plugins =
[
{
file = "powerlevel10k.zsh-theme";
name = "powerlevel10k";
src = "${inputs.pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k";
}
{ file = "p10k.zsh"; name = "powerlevel10k-config"; src = ./p10k-config; }
{
name = "zsh-lsd";
src = inputs.pkgs.fetchFromGitHub
{
file = "powerlevel10k.zsh-theme";
name = "powerlevel10k";
src = "${inputs.pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k";
}
{ file = "p10k.zsh"; name = "powerlevel10k-config"; src = ./p10k-config; }
{
name = "zsh-lsd";
src = inputs.pkgs.fetchFromGitHub
{
owner = "z-shell";
repo = "zsh-lsd";
rev = "65bb5ac49190beda263aae552a9369127961632d";
hash = "sha256-JSNsfpgiqWhtmGQkC3B0R1Y1QnDKp9n0Zaqzjhwt7Xk=";
};
}
];
initContent = inputs.lib.mkOrder 550
''
# p10k instant prompt
P10K_INSTANT_PROMPT="$XDG_CACHE_HOME/p10k-instant-prompt-''${(%):-%n}.zsh"
[[ ! -r "$P10K_INSTANT_PROMPT" ]] || source "$P10K_INSTANT_PROMPT"
HYPHEN_INSENSITIVE="true"
export PATH=~/bin:$PATH
zstyle ':vcs_info:*' disable-patterns "/nix/remote/*"
'';
oh-my-zsh.theme = "";
};
fzf = optional { enable = true; };
owner = "z-shell";
repo = "zsh-lsd";
rev = "65bb5ac49190beda263aae552a9369127961632d";
hash = "sha256-JSNsfpgiqWhtmGQkC3B0R1Y1QnDKp9n0Zaqzjhwt7Xk=";
};
}
];
initContent = inputs.lib.mkOrder 550
''
# p10k instant prompt
P10K_INSTANT_PROMPT="$XDG_CACHE_HOME/p10k-instant-prompt-''${(%):-%n}.zsh"
[[ ! -r "$P10K_INSTANT_PROMPT" ]] || source "$P10K_INSTANT_PROMPT"
HYPHEN_INSENSITIVE="true"
export PATH=~/bin:$PATH
zstyle ':vcs_info:*' disable-patterns "/nix/remote/*"
'';
oh-my-zsh.theme = "";
};
}
];

View File

@@ -59,10 +59,6 @@ inputs:
ts.chn.moe {
bind ${coredns.interface}
template IN SOA ts.chn.moe {
match ".*"
answer "{{ .Name }} 60 IN SOA vps6.chn.moe. chn.chn.moe. 2023010100 7200 3600 1209600 3600"
}
forward . 100.100.100.100
header {
response set aa

View File

@@ -65,7 +65,6 @@ inputs:
BIND = "127.0.0.1:3003";
WEBMASTER_EMAIL = "chn@chn.moe";
SERVE_ROBOTS_TXT = true;
METRICS_BIND = "/run/anubis/anubis-gitea/anubis-metrics.sock";
};
};
nixos =

View File

@@ -0,0 +1,52 @@
inputs:
{
options.nixos.services.groupshare = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
users = mkOption
{
type = types.listOf types.nonEmptyStr;
default = [ "chn" "gb" "xll" "yjq" "zem" "gb" "wp" "hjp" ];
};
};});
default = null;
};
config =
let
inherit (inputs.config.nixos.services) groupshare;
users = inputs.lib.intersectLists groupshare.users inputs.config.nixos.user.users;
in inputs.lib.mkIf (groupshare != null)
{
users =
{
users = builtins.listToAttrs (map (user: { name = user; value.extraGroups = [ "groupshare" ]; }) users);
groups.groupshare.gid = inputs.config.nixos.user.gid.groupshare;
};
systemd.tmpfiles.rules = [ "d /var/lib/groupshare" ]
++ (builtins.concatLists (map
(user:
[
"d /var/lib/groupshare/${user} 2750 ${user} groupshare"
"Z /var/lib/groupshare/${user} - ${user} groupshare"
("A /var/lib/groupshare/${user} - - - - "
# d 指 default, 即目录下新创建的文件和目录的权限
# 大写 X 指仅给目录执行权限
# m 指 mask, 即对于所有者以外的用户, 该用户的权限最大为 m 指定的权限
+ (builtins.concatStringsSep "," (builtins.concatLists (map
(perm: [ "d:${perm}" perm ])
[ "u:${user}:rwX" "g:groupshare:r-X" "o::---" "m::r-x" ]))))
])
users));
home-manager.users = builtins.listToAttrs (map
(user:
{
name = user;
value = homeInputs:
{
config.home.file.groupshare.source = homeInputs.config.lib.file.mkOutOfStoreSymlink "/var/lib/groupshare";
};
})
users);
};
}

View File

@@ -1,57 +0,0 @@
inputs:
{
options.nixos.services.missgram = let inherit (inputs.lib) mkOption types; in mkOption
{ type = types.nullOr (types.submodule {}); default = null; };
config = let inherit (inputs.config.nixos.services) missgram; in inputs.lib.mkIf (missgram != null)
{
users =
{
users.missgram =
{ uid = inputs.config.nixos.user.uid.missgram; group = "missgram"; isSystemUser = true; };
groups.missgram.gid = inputs.config.nixos.user.gid.missgram;
};
systemd =
{
services.missgram =
{
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig =
{
User = inputs.config.users.users.missgram.name;
Group = inputs.config.users.users.missgram.group;
ExecStart =
let forwarder = inputs.pkgs.localPackages.missgram.override
{ configFile = inputs.config.nixos.system.sops.templates."missgram/config.yml".path; };
in "${forwarder}/bin/missgram";
};
};
};
nixos =
{
services =
{
nginx.https."missgram.chn.moe".location."/".proxy.upstream = "http://127.0.0.1:9173";
postgresql.instances.missgram = {};
};
system.sops =
{
templates."missgram/config.yml" =
{
owner = "missgram";
content =
let inherit (inputs.config.nixos.system.sops) placeholder;
in builtins.toJSON
{
Secret = placeholder."missgram/secret";
TelegramBotToken = placeholder."missgram/telegramBotToken";
TelegramChatId = -1003641252872;
ServerPort = 9173;
dbPassword = placeholder."postgresql/missgram";
};
};
secrets = { "missgram/secret" = {}; "missgram/telegramBotToken" = {}; };
};
};
};
}

View File

@@ -16,7 +16,7 @@ inputs:
hostName = nextcloud.hostname;
appstoreEnable = false;
https = true;
package = inputs.pkgs.nextcloud32;
package = inputs.pkgs.nextcloud31;
maxUploadSize = "10G";
config =
{

View File

@@ -0,0 +1,16 @@
inputs:
{
options.nixos.services.peerBanHelper = let inherit (inputs.lib) mkOption types; in mkOption
{ type = types.nullOr (types.submodule {}); default = null; };
config = let inherit (inputs.config.nixos.services) peerBanHelper; in inputs.lib.mkIf (peerBanHelper != null)
{
virtualisation.oci-containers.containers.peerBanHelper =
{
inherit (inputs.topInputs.self.src.peerBanHelper) image imageFile;
volumes = [ "peerBanHelper:/app/data" ];
ports = [ "9898:9898/tcp" ];
environment = { PUID = "0"; PGID = "0"; TZ = "UTC"; };
};
nixos.services.podman = {};
};
}

View File

@@ -0,0 +1,32 @@
inputs:
{
options.nixos.services.searx = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
hostname = mkOption { type = types.nonEmptyStr; default = "search.chn.moe"; };
};});
default = null;
};
config = let inherit (inputs.config.nixos.services) searx; in inputs.lib.mkIf (searx != null)
{
services.searx =
{
enable = true;
settings.server = { port = 8081; bind_address = "127.0.0.1"; secret_key = "@SEARX_SECRET_KEY@"; };
environmentFile = inputs.config.nixos.system.sops.templates."searx.env".path;
};
nixos =
{
system.sops =
{
templates."searx.env".content = let inherit (inputs.config.nixos.system.sops) placeholder; in
''
SEARX_SECRET_KEY=${placeholder."searx/secret-key"}
'';
secrets."searx/secret-key" = {};
};
services.nginx.https.${searx.hostname}.location."/".proxy.upstream = "http://127.0.0.1:8081";
};
};
}

View File

@@ -54,7 +54,7 @@ inputs:
{
slurm =
{
package = (inputs.pkgs.slurm.override { enableX11 = false; }).overrideAttrs (prev:
package = inputs.pkgs.slurm.overrideAttrs (prev:
{
postInstall =
''
@@ -196,7 +196,7 @@ inputs:
{
services.slurm =
{
server = { enable = true; flag.i = true; };
server.enable = true;
dbdserver =
{
enable = true;

View File

@@ -23,7 +23,6 @@ inputs:
PasswordAuthentication = sshd.passwordAuthentication;
KbdInteractiveAuthentication = false;
UsePAM = true;
GatewayPorts = "yes";
};
};
}

View File

@@ -1,10 +1,7 @@
inputs:
{
options.nixos.services.tailscale = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule {});
default = if inputs.config.nixos.model.arch == "x86_64" then {} else null;
};
{ type = types.nullOr (types.submodule {}); default = {}; };
config = let inherit (inputs.config.nixos.services) tailscale; in inputs.lib.mkIf (tailscale != null)
{
services.tailscale =

View File

@@ -14,7 +14,7 @@ inputs:
(inputs.lib.removeSuffix ".chn.moe" submoduleInputs.config.xray.serverName);
};
};
coredns =
dnsmasq =
{
extraInterfaces = mkOption { type = types.listOf types.nonEmptyStr; default = []; };
hosts = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
@@ -27,26 +27,19 @@ inputs:
{
services =
{
coredns =
dnsmasq =
{
enable = true;
config =
let
hosts = inputs.pkgs.writeText "coredns.hosts" (builtins.concatStringsSep "\n"
(inputs.lib.mapAttrsToList (n: v: "${v} ${n}") client.coredns.hosts));
in
''
. {
log
errors
bind lo ${builtins.concatStringsSep " " client.coredns.extraInterfaces}
hosts ${hosts} {
fallthrough
}
rewrite name exact git.chn.moe nas.ts.chn.moe
forward . 127.0.0.1:10853
}
'';
settings =
{
no-poll = true;
log-queries = true;
server = [ "127.0.0.1#10853" ];
interface = client.dnsmasq.extraInterfaces ++ [ "lo" ];
bind-dynamic = true;
address = builtins.map (host: "/${host.name}/${host.value}")
(inputs.localLib.attrsToList client.dnsmasq.hosts);
};
};
resolved.enable = false;
};

View File

@@ -62,8 +62,13 @@ inputs:
{
versionSuffix = inputs.lib.mkForce "";
tags = let inherit (inputs.topInputs) self; in
[ (builtins.substring 2 6 self.lastModifiedDate) (builtins.substring 0 6 self.rev or "dirty") ];
[
self.config.branch
(builtins.substring 2 6 self.lastModifiedDate)
(builtins.substring 0 6 self.rev or "dirty")
];
};
};
chaotic.nyx.cache.enable = false;
};
}

View File

@@ -1,6 +1,6 @@
{ lib, config, pkgs, ... }:
inputs:
{
options.nixos.system.fileSystems.mount.nfs = let inherit (lib) mkOption types; in mkOption
options.nixos.system.fileSystems.mount.nfs = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.attrsOf (types.oneOf
[
@@ -8,45 +8,50 @@
(types.submodule (submoduleInputs: { options =
{
mountPoint = mkOption { type = types.nonEmptyStr; };
mountBeforeSwitch = mkOption { type = types.bool; default = true; };
readOnly = mkOption { type = types.bool; default = !submoduleInputs.config.mountBeforeSwitch; };
neededForBoot = mkOption { type = types.bool; default = true; };
};}))
]);
default = {};
};
config = let inherit (config.nixos.system.fileSystems.mount) nfs; in lib.mkIf (nfs != {}) (lib.mkMerge
config =
let inherit (inputs.config.nixos.system.fileSystems.mount) nfs;
in inputs.lib.mkIf (nfs != {}) (inputs.lib.mkMerge
[
{
fileSystems = lib.mapAttrs'
(n: v: lib.nameValuePair (v.mountPoint or v)
fileSystems = builtins.listToAttrs (builtins.map
(device:
{
device = n;
fsType = "nfs4";
neededForBoot = v.mountBeforeSwitch or true;
options = builtins.concatLists
[
name = device.value.mountPoint or device.value;
value =
{
device = device.name;
fsType = "nfs4";
neededForBoot = device.value.neededForBoot or true;
options = builtins.concatLists
[
"actimeo=1" # sync every seconds
"noatime"
"x-gvfs-hide" # hide in file managers (e.g. dolphin)
]
# when try to mount at startup, wait 15 minutes before giving up
(lib.optionals (v.mountBeforeSwitch or true) [ "retry=15" "x-systemd.device-timeout=15min" ])
(lib.optionals (!(v.mountBeforeSwitch or true))
[ "bg" "x-systemd.requires=network-online.target" "x-systemd.after=network-online.target" ])
(lib.optionals (v.readOnly or false) [ "ro" ])
];
[
"actimeo=1" # sync every seconds
"noatime"
"x-gvfs-hide" # hide in file managers (e.g. dolphin)
]
# when try to mount at startup, wait 15 minutes before giving up
(inputs.lib.optionals (device.value.neededForBoot or true)
[ "retry=15" "x-systemd.device-timeout=15min" ])
(inputs.lib.optionals (!(device.value.neededForBoot or true))
[ "bg" "x-systemd.requires=network-online.target" "x-systemd.after=network-online.target" ])
];
};
})
nfs;
(inputs.localLib.attrsToList nfs));
services.rpcbind.enable = true;
}
(lib.mkIf (builtins.any (mount: mount.mountBeforeSwitch or true) (builtins.attrValues nfs))
(inputs.lib.mkIf (builtins.any (mount: mount.neededForBoot or true) (builtins.attrValues nfs))
{
boot.initrd.systemd.extraBin =
{
"ifconfig" = "${pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${pkgs.nfs-utils}/bin/mount.nfs4";
"ifconfig" = "${inputs.pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs4";
};
nixos.system.initrd.network = {};
})

View File

@@ -38,7 +38,6 @@ inputs:
];
};
xdg.portal.extraPortals = (builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" "gnome" ]);
qt = { enable = true; platformTheme = "qt5ct"; };
i18n.inputMethod =
{
enable = true;
@@ -49,61 +48,61 @@ inputs:
programs = { dconf.enable = true; niri.enable = true; };
nixos.user.sharedModules = [(hmInputs:
{
config.programs =
config =
{
dank-material-shell =
gtk =
{
enable = true;
niri.enableKeybinds = true;
systemd = { enable = true; restartIfChanged = true; };
theme.name = "Breeze";
gtk2 =
{
extraConfig = ''gtk-im-module="fcitx"'';
configLocation = "${hmInputs.config.xdg.configHome}/gtk-2.0/gtkrc";
force = true;
};
gtk3.extraConfig.gtk-im-module = "fcitx";
gtk4.extraConfig.gtk-im-module = "fcitx";
};
niri.settings =
programs =
{
binds =
let
xsel = "${inputs.pkgs.xsel}/bin/xsel";
wl-copy = "${inputs.pkgs.wl-clipboard}/bin/wl-copy";
wl-paste = "${inputs.pkgs.wl-clipboard}/bin/wl-paste";
in
{
"Mod+WheelScrollDown" = { action.focus-column-right = {}; cooldown-ms = 50; };
"Mod+WheelScrollUp" = { action.focus-column-left = {}; cooldown-ms = 50; };
"Mod+Left".action.focus-column-left = {};
"Mod+Right".action.focus-column-right = {};
"Mod+MouseMiddle".action.close-window = {};
"Mod+L".action.spawn = [ "dms" "ipc" "lock" "lock" ];
"Mod+W".action.move-workspace-to-monitor-next = {};
"Mod+Ctrl+C".action.spawn = [ "sh" "-c" "${xsel} -ob | ${wl-copy}" ];
"Mod+Ctrl+V".action.spawn = [ "sh" "-c" "${wl-paste} -n | ${xsel} -ib" ];
"Mod+S".action.screenshot = {};
"Mod+F".action.set-column-width= "100%";
"Mod+R".action.switch-preset-column-width = {};
"Mod+T".action.expand-column-to-available-width = {};
};
outputs =
dankMaterialShell =
{
"Tianma Microelectronics Ltd. TL134ADXP03 Unknown" =
{ scale = 1; position = { x = 0; y = 0; }; mode = { width = 2560; height = 1600; refresh = 180.; }; };
"Xiaomi Corporation Mi Monitor 0x00000001" =
{
scale = 1;
position = { x = 0; y = -2160; };
mode = { width = 3840; height = 2160; refresh = 160.; };
};
enable = true;
niri.enableKeybinds = true;
systemd = { enable = true; restartIfChanged = true; };
};
input = { touchpad.dwt = true; keyboard.numlock = true; };
layout =
niri.settings =
{
default-column-width.proportion = 0.5;
preset-column-widths = [ { proportion = 0.33333; } { proportion = 0.5; } { proportion = 0.66667; } ];
binds =
let
xsel = "${inputs.pkgs.xsel}/bin/xsel";
wl-copy = "${inputs.pkgs.wl-clipboard}/bin/wl-copy";
wl-paste = "${inputs.pkgs.wl-clipboard}/bin/wl-paste";
in
{
"Mod+WheelScrollDown" = { action.focus-column-right = {}; cooldown-ms = 50; };
"Mod+WheelScrollUp" = { action.focus-column-left = {}; cooldown-ms = 50; };
"Mod+Left".action.focus-column-left = {};
"Mod+Right".action.focus-column-right = {};
"Mod+MouseMiddle".action.close-window = {};
"Mod+L".action.spawn = [ "dms" "ipc" "lock" "lock" ];
"Mod+W".action.move-workspace-to-monitor-next = {};
"Mod+Ctrl+C".action.spawn = [ "sh" "-c" "${xsel} -ob | ${wl-copy}" ];
"Mod+Ctrl+V".action.spawn = [ "sh" "-c" "${wl-paste} -n | ${xsel} -ib" ];
};
outputs =
{
"Tianma Microelectronics Ltd. TL134ADXP03 Unknown" =
{ scale = 1; position = { x = 0; y = 0; }; mode = { width = 2560; height = 1600; refresh = 180.; }; };
"Xiaomi Corporation Mi Monitor 0x00000001" =
{
scale = 1;
position = { x = 0; y = -2160; };
mode = { width = 3840; height = 2160; refresh = 160.; };
};
};
input = { touchpad.dwt = true; keyboard.numlock = true; };
};
spawn-at-startup =
[
{ argv = [ "Telegram" "-startintray" ]; }
{ argv = [ "steam" "-silent" ]; }
{ argv = [ "element-desktop" "--hidden" ]; }
{ argv = [ "discord" "--start-minimized" "--no-startup-id" ]; }
];
};
};
})];

View File

@@ -42,8 +42,6 @@ inputs:
"ahci" "nvme" "igc"
# tf card for pc
"sdhci_pci"
# to mount some fat32 disk
"nls_ascii"
]
# touchscreen for one
++ (inputs.lib.optionals (inputs.config.nixos.model.arch == "x86_64") [ "pinctrl-tigerlake" ]);
@@ -59,15 +57,24 @@ inputs:
nixos = inputs.pkgs.linuxPackages;
xanmod-lts = inputs.pkgs.linuxPackages_xanmod;
xanmod-latest = inputs.pkgs.linuxPackages_xanmod_latest;
cachyos = inputs.pkgs.cachyosKernels.linuxPackages-cachyos-latest;
xanmod-unstable = inputs.pkgs.pkgs-unstable.linuxPackages_xanmod_latest;
cachyos = inputs.pkgs.linuxPackages_cachyos-gcc;
cachyos-rc = inputs.pkgs.linuxPackages_cachyos-rc;
}.${kernel.variant};
kernelPatches =
let
version = inputs.lib.versions.majorMinor inputs.config.boot.kernelPackages.kernel.version;
patches =
{
btrfs = [(inputs.topInputs.self.src.btrfs.${version} // { name = "btrfs"; })];
};
let patches =
{
btrfs =
[{
name = "btrfs";
patch = inputs.pkgs.fetchurl
{
url = "https://github.com/kakra/linux/pull/36.patch";
sha256 = "0wimihsvrxib6g23jcqdbvqlkqk6nbqjswfx9bzmpm1vlvzxj8m0";
};
structuredExtraConfig.BTRFS_EXPERIMENTAL = inputs.lib.kernel.yes;
}];
};
in builtins.concatLists (builtins.map (name: patches.${name}) kernel.patches);
};
};

View File

@@ -69,6 +69,8 @@ inputs:
}
# marches
{ nix.settings.system-features = builtins.map (march: "gccarch-${march}") nix.marches; }
# includeBuildDependencies
{ system.includeBuildDependencies = inputs.topInputs.self.config.branch == "archive"; }
# remote.slave
(inputs.lib.mkIf (nix.remote.slave != null)
{

View File

@@ -41,13 +41,13 @@ inputs:
};
loginLimits =
[
{ domain = "@users"; item = "nofile"; value = 524288; }
{ domain = "@users"; item = "nofile"; value = 65536; }
{ domain = "@users"; item = "stack"; value = "unlimited"; }
];
};
sudo.extraConfig = "Defaults pwfeedback";
};
systemd.user.extraConfig = "DefaultLimitNOFILE=524288:524288";
systemd.user.extraConfig = "DefaultLimitNOFILE=65536:524288";
# needed by xray tproxy if we want to forward traffic from other machine
networking.firewall.checkReversePath = false;
};

View File

@@ -22,36 +22,41 @@ inputs:
ssd = inputs.lib.mkOption { type = inputs.lib.types.bool; default = false; };
};}));
};
config.home =
config =
{
packages =
[
(
let
servers = inputs.localLib.attrsToList hmInputs.config.nixos.decrypt;
cat = "${inputs.pkgs.coreutils}/bin/cat";
gpg = "${inputs.pkgs.gnupg}/bin/gpg";
ssh = "${inputs.pkgs.openssh}/bin/ssh";
# generate using echo -n key | gpg --encrypt --recipient chn > xxx.key
in inputs.pkgs.writeShellScriptBin "remote-decrypt" (builtins.concatStringsSep "\n"
(
(builtins.map (system: builtins.concatStringsSep "\n"
[
"decrypt-${system.name}() {"
" key=$(${cat} ${inputs.topInputs.self}/devices/cross/luks-manual/${system.name}.key \\"
" | ${gpg} --decrypt)"
(builtins.concatStringsSep "\n" (builtins.map
(device: " echo $key | ${ssh} root@initrd.${system.name}.chn.moe cryptsetup luksOpen "
+ (if device.value.ssd then "--allow-discards " else "")
+ "${device.name} ${device.value.mapper} -")
(inputs.localLib.attrsToList system.value)))
"}"
])
servers)
++ [ "decrypt-$1" ]
))
)
];
programs.git.settings.user = { name = "chn"; email = "chn@chn.moe"; };
home =
{
file.groupshare.enable = false;
packages =
[
(
let
servers = inputs.localLib.attrsToList hmInputs.config.nixos.decrypt;
cat = "${inputs.pkgs.coreutils}/bin/cat";
gpg = "${inputs.pkgs.gnupg}/bin/gpg";
ssh = "${inputs.pkgs.openssh}/bin/ssh";
# generate using echo -n key | gpg --encrypt --recipient chn > xxx.key
in inputs.pkgs.writeShellScriptBin "remote-decrypt" (builtins.concatStringsSep "\n"
(
(builtins.map (system: builtins.concatStringsSep "\n"
[
"decrypt-${system.name}() {"
" key=$(${cat} ${inputs.topInputs.self}/devices/cross/luks-manual/${system.name}.key \\"
" | ${gpg} --decrypt)"
(builtins.concatStringsSep "\n" (builtins.map
(device: " echo $key | ${ssh} root@initrd.${system.name}.chn.moe cryptsetup luksOpen "
+ (if device.value.ssd then "--allow-discards " else "")
+ "${device.name} ${device.value.mapper} -")
(inputs.localLib.attrsToList system.value)))
"}"
])
servers)
++ [ "decrypt-$1" ]
))
)
];
};
};
};
};

View File

@@ -23,7 +23,6 @@ inputs:
tlstimeout = 3600;
transfer.maxretries = 1;
};
user = { name = "Haonan Chen"; email = "chn@chn.moe"; };
};
};
delta =

View File

@@ -41,7 +41,6 @@ inputs:
twr = 1027;
lsp = 1028;
lilydjwg = 1029;
stq = 1030;
misskey-misskey = 2000;
misskey-misskey-old = 2001;
frp = 2002;
@@ -56,7 +55,6 @@ inputs:
hpcstat = 2011;
speedtest = 2012;
tailscale = 2013;
missgram = 2014;
};
};
gid = mkOption
@@ -134,7 +132,7 @@ inputs:
{
programs.git.settings =
{
user = { name = "Haonan Chen"; email = "chn@chn.moe"; };
user = { name = "chn"; email = "chn@chn.moe"; };
# allow root operate on git repositories owned by others
safe.directory = "*";
};

View File

@@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILvXkM8TS8fDot22LTfU2jDVOqK20LmK8Rd7xO05vYns stq

View File

@@ -144,9 +144,6 @@ inputs: rec
buildProxy = inputs.pkgs.lib.mkBuildproxy ./pybinding/proxy.nix;
};
brokenaxes = inputs.pkgs.python3Packages.callPackage ./brokenaxes.nix { src = inputs.topInputs.brokenaxes; };
missgram = inputs.pkgs.callPackage ./missgram { inherit biu sqlgen; stdenv = inputs.pkgs.clang18Stdenv; };
sqlgen = inputs.pkgs.callPackage ./sqlgen.nix { src = inputs.topInputs.sqlgen; inherit reflectcpp; };
reflectcpp = inputs.pkgs.callPackage ./reflectcpp.nix { src = inputs.topInputs.reflectcpp; };
fromYaml = content: builtins.fromJSON (builtins.readFile
(inputs.pkgs.runCommand "toJSON" {}

View File

@@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILvXkM8TS8fDot22LTfU2jDVOqK20LmK8Rd7xO05vYns stq

View File

@@ -18,7 +18,6 @@ namespace hpcstat
{ "8jCEhKYtIVn4H69+fotWDFUYWHyiRN1+JCGeiDHaf5E", { "hss", "Shanshan He" } },
{ "SUoYlxc2OVSH5YJqptKhl5o1Q2TW+PG+bBvpXfHNITI", { "qmx", "Mingxuan Qiu" } },
{ "gtibfPaDxwsV1q6kZbsNsy5TKL5rfLlK3fSM/fVQTAY", { "ccy", "Chaoye Chen" } },
{ "XWP5goo/Xj6FxvrG7lKSJ4otEBKUsSOF7V2brwpBcik", { "stq", "Tianqi Sun" } },
{ "7bmG24muNsaAZkCy7mQ9Nf2HuNafmvUO+Hf1bId9zts", { "00", "Yaping Wu" } },
{ "dtx0QxdgFrXn2SYxtIRz43jIAH6rLgJidSdTvuTuews", { "01", "Jing Li" } },
{ "8crUO9u4JiVqw3COyjXfzZe87s6XZFhvi0LaY0Mv6bg", { "02", "Huahan Zhan" } },

View File

@@ -1 +0,0 @@
use flake .#missgram

View File

@@ -1 +0,0 @@
config.yaml

View File

@@ -1,29 +0,0 @@
cmake_minimum_required(VERSION 3.14)
project(missgram VERSION 0.0.0 LANGUAGES CXX)
enable_testing()
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
find_package(biu REQUIRED)
find_package(httplib REQUIRED)
find_package(sqlgen REQUIRED)
add_executable(missgram src/main.cpp src/db.cpp src/tg.cpp)
target_include_directories(missgram PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(missgram PRIVATE biu::biu httplib::httplib sqlgen::sqlgen)
target_compile_features(missgram PRIVATE cxx_std_23)
if(DEFINED MISSGRAM_CONFIG_FILE)
target_compile_definitions(missgram PRIVATE MISSGRAM_CONFIG_FILE="${MISSGRAM_CONFIG_FILE}")
endif()
target_compile_definitions(missgram PRIVATE BIU_LOGGER_SOURCE_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
install(TARGETS missgram RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
message("Imported targets: ${ImportedTargets}")
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
message("CMake build type: ${CMAKE_BUILD_TYPE}")

View File

@@ -1,8 +0,0 @@
{ lib, stdenv, cmake, pkg-config, biu, configFile ? null, httplib, sqlgen }: stdenv.mkDerivation
{
name = "missgram";
src = ./.;
buildInputs = [ biu httplib sqlgen ];
nativeBuildInputs = [ cmake pkg-config ];
cmakeFlags = lib.optional (configFile != null) [ "-DMISSGRAM_CONFIG_FILE=${configFile}" ];
}

View File

@@ -1,19 +0,0 @@
# include <biu.hpp>
namespace missgram
{
struct Config
{
std::string Secret;
std::string TelegramBotToken;
std::int64_t TelegramChatId;
std::int16_t ServerPort;
std::string dbPassword;
} inline config;
struct File { std::string url; bool is_photo; bool should_hidden; };
void db_write(std::string misskey_note, std::int32_t telegram_message_id);
std::optional<std::int32_t> db_read(std::string misskey_note);
std::optional<std::int32_t> tg_send(std::string text, std::optional<std::int32_t> replyId, std::vector<File> files);
}

View File

@@ -1,23 +0,0 @@
# include <missgram.hpp>
# include <sqlgen/postgres.hpp>
struct Record { std::string misskey_note; std::int32_t telegram_message_id; };
void missgram::db_write(std::string misskey_note, std::int32_t telegram_message_id)
{
auto&& conn = sqlgen::postgres::connect
({.user = "missgram", .password = config.dbPassword, .host = "127.0.0.1", .dbname = "missgram"});
sqlgen::write(conn, Record{misskey_note, telegram_message_id});
}
std::optional<std::int32_t> missgram::db_read(std::string misskey_note)
{
using namespace sqlgen::literals;
auto&& conn = sqlgen::postgres::connect
({.user = "missgram", .password = config.dbPassword, .host = "127.0.0.1", .dbname = "missgram"});
auto query = sqlgen::read<std::vector<Record>> |
sqlgen::where("misskey_note"_c == misskey_note) |
sqlgen::limit(1);
auto result = query(conn);
if (!result || result->empty()) return {}; else return result->front().telegram_message_id;
}

View File

@@ -1,113 +0,0 @@
# include <missgram.hpp>
# include <httplib.h>
# ifndef MISSGRAM_CONFIG_FILE
# define MISSGRAM_CONFIG_FILE "./config.yaml"
# endif
int main()
{
using namespace biu::literals;
using namespace missgram;
biu::Logger::Guard log;
config = YAML::LoadFile(MISSGRAM_CONFIG_FILE).as<Config>();
biu::Logger::try_exec([&]
{
httplib::Server svr;
svr.Post("/", [&](const httplib::Request& req, httplib::Response& res)
{
biu::Logger::try_exec([&]
{
log.debug(req.body);
log.debug("{}"_f(req.headers));
if (req.get_header_value("x-misskey-hook-secret") != config.Secret)
throw std::runtime_error("Invalid secret key.");
struct Content
{
std::string type, server;
struct Body
{
struct Note
{
std::string id, visibility;
std::optional<std::string> text, replyId;
struct Renote { std::string id; };
std::optional<Renote> renote;
bool localOnly;
struct File { bool isSensitive; std::string url; std::string type; };
std::vector<File> files;
};
std::optional<Note> note;
} body;
};
auto content = YAML::Load(req.body).as<Content>();
log();
// 只考虑公开且允许联合的帖子。
if
(
content.type != "note" // 只考虑 note 的情况这里note包括了回复、转发、引用
|| !content.body.note // 大概不会发生,但还是判断一下
|| content.body.note->visibility != "public" || content.body.note->localOnly // 只转发公开的、允许联合的帖子
) return;
// 接下来准备要转发的文字内容
std::string text;
std::optional<std::uint32_t> reply_id;
// 如果是转发,则直接写链接
if (!content.body.note->text && content.body.note->renote)
text = "转发了[帖子]({}/notes/{})"_f(content.server, content.body.note->id);
// 否则(引用或普通帖子)
else
{
text = *content.body.note->text;
// 如果有引用,则需要查找被引用的帖子是否已经被转发过,若是则直接回复被转发的消息。
// 如果没有被转发过,则在开头附上链接
if (content.body.note->renote)
{
reply_id = db_read(content.body.note->renote->id);
if (!reply_id)
text = "引用了[帖子]({}/notes/{})\n"_f(content.server, content.body.note->renote->id) + text;
}
// 检查是否是回复帖子,若是则在开头附上链接原帖链接。我一般不直接回复自己的帖子,所以这里不检查
if (content.body.note->replyId)
text = "回复了[帖子]({}/notes/{})\n"_f(content.server, *content.body.note->replyId) + text;
// 最后附上原贴地址
text += "\n[在联邦宇宙查看]({}/notes/{})"_f(content.server, content.body.note->id);
}
// 接下来整理要转发的文件
auto files = content.body.note->files | ranges::views::transform([](auto&& file) -> File
{
return File
{
.url = file.url,
.is_photo = file.type.starts_with("image/"),
.should_hidden = file.isSensitive
};
}) | ranges::to_vector;
log();
// 异步发送消息
std::thread([text, note_id = content.body.note->id, reply_id, files]
{
auto message_id = tg_send(text, reply_id, files);
if (message_id) db_write(note_id, *message_id);
}).detach();
// 完成 http 响应
res.status = 200;
res.body = "OK";
});
});
svr.listen("0.0.0.0", config.ServerPort);
return 0;
});
}

View File

@@ -1,90 +0,0 @@
# include <missgram.hpp>
# include <tgbot/tgbot.h>
std::optional<std::int32_t> missgram::tg_send
(std::string text, std::optional<std::int32_t> replyId, std::vector<File> files)
{
using namespace biu::literals;
biu::Logger::Guard log;
// 整理要发送的信息
TgBot::Bot bot(config.TelegramBotToken);
std::shared_ptr<TgBot::ReplyParameters> reply;
if (replyId) reply = std::make_shared<TgBot::ReplyParameters>(*replyId, config.TelegramChatId);
auto attachs = files
| ranges::views::transform([&](auto&& file) -> TgBot::InputMedia::Ptr
{
if (file.is_photo)
{
auto pic = std::make_shared<TgBot::InputMediaPhoto>();
pic->media = file.url;
pic->hasSpoiler = file.should_hidden;
return pic;
}
else
{
auto doc = std::make_shared<TgBot::InputMediaDocument>();
doc->media = file.url;
return doc;
}
})
| ranges::to_vector;
// 多次尝试运行函数直到成功或达到最大尝试次数5次
auto try_run = [&](auto&& func) -> std::optional<std::int32_t>
{
auto retry_delay = 1s;
int attempts = 0;
while (attempts < 5)
{
TgBot::Message::Ptr message;
biu::Logger::try_exec([&] { message = func(); });
if (message) return message->messageId;
std::this_thread::sleep_for(retry_delay);
retry_delay *= 2;
attempts++;
}
return std::nullopt;
};
// 如果没有附件,使用 sendMessage 发送文本消息
if (attachs.empty()) return try_run([&] { return bot.getApi().sendMessage
(
config.TelegramChatId, text, nullptr, reply, nullptr,
"MarkdownV2"
);});
// 如果只有一个附件并且是图片,使用 sendPhoto 发送
else if (attachs.size() == 1 && files[0].is_photo) return try_run([&]
{
return bot.getApi().sendPhoto
(
config.TelegramChatId, files[0].url, text, reply,
nullptr, "MarkdownV2", false, {}, 0, false, files[0].should_hidden
);
});
// 如果有多个附件,使用 sendMediaGroup 分两条消息发送,返回第一条的 id
else
{
auto message = try_run([&] { return bot.getApi().sendMessage
(
config.TelegramChatId, text, nullptr, reply, nullptr,
"MarkdownV2"
);});
if (message)
{
auto message2 = try_run([&] -> TgBot::Message::Ptr
{
auto msg = bot.getApi().sendMediaGroup
(
config.TelegramChatId, attachs, false,
std::make_shared<TgBot::ReplyParameters>(*message, config.TelegramChatId)
);
if (msg.empty() || !ranges::all_of(msg, [](auto&& m) { return bool(m); }))
return nullptr;
else return msg[0];
});
if (!message2) return {};
}
return message;
}
}

View File

@@ -1,7 +0,0 @@
{ stdenv, src, cmake, pkg-config }: stdenv.mkDerivation
{
name = "reflectcpp";
inherit src;
nativeBuildInputs = [ cmake pkg-config ];
cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ];
}

View File

@@ -5,7 +5,18 @@ namespace sbatch
class Fdtd : public Program
{
public: struct StateType
{ int QueueSelected = 0; std::vector<std::string> QueueEntries; std::string InputFile = "input.fsp"; };
{
int QueueSelected = 0;
std::vector<std::string> QueueEntries;
int CpuSchemeSelected = 0;
std::vector<std::string> CpuSchemeEntries = { "Default", "Custom" };
std::string Cpus = "1";
bool Nomultithread = true;
int MemorySchemeSelected = 0;
std::vector<std::string> MemorySchemeEntries = { "Default", "Custom" };
std::string Memory = "1";
std::string InputFile = "input.fsp";
};
protected: StateType State_;
protected: struct Recommended_ { int Cpus; std::optional<int> Memory; };
protected: std::vector<Recommended_> Recommendeds_;
@@ -24,6 +35,13 @@ namespace sbatch
{
auto saved_state = node.as<decltype(State_)>();
if (saved_state.QueueSelected < State_.QueueEntries.size()) State_.QueueSelected = saved_state.QueueSelected;
if (saved_state.CpuSchemeSelected < State_.CpuSchemeEntries.size())
State_.CpuSchemeSelected = saved_state.CpuSchemeSelected;
State_.Cpus = saved_state.Cpus;
State_.Nomultithread = saved_state.Nomultithread;
if (saved_state.MemorySchemeSelected < State_.MemorySchemeEntries.size())
State_.MemorySchemeSelected = saved_state.MemorySchemeSelected;
State_.Memory = saved_state.Memory;
State_.InputFile = saved_state.InputFile;
}
catch (...) {}
@@ -36,17 +54,52 @@ namespace sbatch
// 第一行
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.QueueEntries, &State_.QueueSelected) | with_title("Queue:", ftxui::Color::GrayDark)
// 队列
ftxui::Menu(&State_.QueueEntries, &State_.QueueSelected)
| with_title("Queue:", ftxui::Color::GrayDark),
// CPU 设置
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.CpuSchemeEntries, &State_.CpuSchemeSelected),
ftxui::Container::Vertical
({
input(&State_.Cpus, "CPU: "),
checkbox("Disable multithread", &State_.Nomultithread)
})
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.CpuSchemeSelected == 1; })
}) | with_title("CPU:", ftxui::Color::GrayDark) | with_separator,
// 内存
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.MemorySchemeEntries, &State_.MemorySchemeSelected),
input(&State_.Memory, "Memory (GB): ")
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.MemorySchemeSelected == 1; })
}) | with_title("Memory:", ftxui::Color::GrayDark) | with_separator
}) | with_title("Resource allocation:") | with_bottom,
// 第三行:输入文件
ftxui::Container::Vertical({input(&State_.InputFile, "Input file: ")}) | with_title("Misc:")
ftxui::Container::Vertical({input(&State_.InputFile, "Input file: ")})
| with_title("Misc:")
});
}
public: virtual std::vector<std::string> get_submit_command(std::string extra_sbatch_parameter) const override
{
auto recommended = Recommendeds_[State_.QueueSelected];
auto cpu_string = "--ntasks={} --cpus-per-task=1 --hint=nomultithread"_f(recommended.Cpus);
auto mem_string = recommended.Memory ? "--mem={}G"_f(*recommended.Memory) : "";
auto cpu_string = [&]
{
if (State_.CpuSchemeSelected == 0)
return "--ntasks={} --cpus-per-task=1 --hint=nomultithread"_f(recommended.Cpus);
else if (State_.CpuSchemeSelected == 1) return "--ntasks={} --cpus-per-task=1{}"_f
(State_.Cpus, State_.Nomultithread ? " --hint=nomultithread" : "");
else std::unreachable();
}();
auto mem_string = [&]
{
if (State_.MemorySchemeSelected == 0) return recommended.Memory ? "--mem={}G"_f(*recommended.Memory) : "";
else if (State_.MemorySchemeSelected == 1) return "--mem={}G"_f(State_.Memory);
else std::unreachable();
}();
return
{
"sbatch"s,

View File

@@ -12,6 +12,10 @@ namespace sbatch
std::vector<std::string> GpuSchemeEntries = { "Any", "Custom" };
std::vector<int> GpuSelected;
std::vector<std::vector<std::string>> GpuEntries;
bool Nomultithread = true;
int MemorySchemeSelected = 0;
std::vector<std::string> MemorySchemeEntries = { "Default", "Custom" };
std::string Memory = "1";
std::string InputFile = "input.txt";
};
protected: StateType State_;
@@ -37,6 +41,10 @@ namespace sbatch
for (size_t i = 0; i < State_.GpuSelected.size(); i++)
if (saved_state.GpuSelected[i] < State_.GpuEntries[i].size())
State_.GpuSelected[i] = saved_state.GpuSelected[i];
State_.Nomultithread = saved_state.Nomultithread;
if (saved_state.MemorySchemeSelected < State_.MemorySchemeEntries.size())
State_.MemorySchemeSelected = saved_state.MemorySchemeSelected;
State_.Memory = saved_state.Memory;
State_.InputFile = saved_state.InputFile;
}
catch (...) {}
@@ -66,6 +74,17 @@ namespace sbatch
) | with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.GpuSchemeSelected == 1; })
}) | with_title("GPU:", ftxui::Color::GrayDark) | with_separator,
// CPU 设置
checkbox("Disable multithread", &State_.Nomultithread)
| with_title("CPU:", ftxui::Color::GrayDark) | with_separator,
// 内存
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.MemorySchemeEntries, &State_.MemorySchemeSelected),
input(&State_.Memory, "Memory (GB): ")
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.MemorySchemeSelected == 1; })
}) | with_title("Memory:", ftxui::Color::GrayDark) | with_separator
}) | with_title("Resource allocation:") | with_bottom,
// 第三行:任务名和输入输出文件
ftxui::Container::Vertical({input(&State_.InputFile, "Input file: ")})
@@ -74,7 +93,8 @@ namespace sbatch
}
public: virtual std::vector<std::string> get_submit_command(std::string extra_sbatch_parameter) const override
{
auto cpu_string = "--hint=nomultithread";
auto cpu_string = [&]
{ return State_.Nomultithread ? "--hint=nomultithread" : ""; }();
auto gpu_string = [&]
{
if (State_.GpuSchemeSelected == 0) return "--gpus=1"s;
@@ -82,7 +102,12 @@ namespace sbatch
(State_.GpuEntries[State_.QueueSelected][State_.GpuSelected[State_.QueueSelected]]);
else std::unreachable();
}();
auto mem_string = "--mem=32G"s;
auto mem_string = [&]
{
if (State_.MemorySchemeSelected == 0) return "--mem=32G"s;
else if (State_.MemorySchemeSelected == 1) return "--mem={}G"_f(State_.Memory);
else std::unreachable();
}();
return
{
"sbatch"s,

View File

@@ -10,6 +10,17 @@ namespace sbatch
std::vector<std::string> VaspEntries = { "std", "gam", "ncl" };
int QueueSelected = 0;
std::vector<std::string> QueueEntries;
int CpuSchemeSelected = 0;
std::vector<std::string> CpuSchemeEntries = { "Default", "Custom" };
std::string MpiThreads = "1";
std::string OpenmpThreads = "1";
bool Nomultithread = true;
int MemorySchemeSelected = 0;
std::vector<std::string> MemorySchemeEntries = { "Default", "Custom" };
std::string Memory = "1";
bool OptcellEnable = false;
int OptcellSelected = 0;
std::vector<std::string> OptcellEntries = { "fix ab", "fix c" };
};
protected: StateType State_;
protected: struct Recommended_ { int Mpi, Openmp; std::optional<int> Memory, Cpus; };
@@ -30,6 +41,17 @@ namespace sbatch
auto saved_state = node.as<decltype(State_)>();
if (saved_state.VaspSelected < State_.VaspEntries.size()) State_.VaspSelected = saved_state.VaspSelected;
if (saved_state.QueueSelected < State_.QueueEntries.size()) State_.QueueSelected = saved_state.QueueSelected;
if (saved_state.CpuSchemeSelected < State_.CpuSchemeEntries.size())
State_.CpuSchemeSelected = saved_state.CpuSchemeSelected;
State_.OpenmpThreads = saved_state.OpenmpThreads;
State_.MpiThreads = saved_state.MpiThreads;
State_.Nomultithread = saved_state.Nomultithread;
if (saved_state.MemorySchemeSelected < State_.MemorySchemeEntries.size())
State_.MemorySchemeSelected = saved_state.MemorySchemeSelected;
State_.Memory = saved_state.Memory;
State_.OptcellEnable = saved_state.OptcellEnable;
if (saved_state.OptcellSelected < State_.OptcellEntries.size())
State_.OptcellSelected = saved_state.OptcellSelected;
}
catch (...) {}
}
@@ -47,19 +69,76 @@ namespace sbatch
// 队列
ftxui::Menu(&State_.QueueEntries, &State_.QueueSelected)
| with_title("Queue:", ftxui::Color::GrayDark),
}) | with_title("Resource allocation:") | with_bottom
// CPU 设置
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.CpuSchemeEntries, &State_.CpuSchemeSelected),
ftxui::Container::Vertical
({
input(&State_.MpiThreads, "MPI: "),
input(&State_.OpenmpThreads, "OpenMP: "),
checkbox("Disable multithread", &State_.Nomultithread)
})
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.CpuSchemeSelected == 1; })
}) | with_title("CPU:", ftxui::Color::GrayDark) | with_separator,
// 内存
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.MemorySchemeEntries, &State_.MemorySchemeSelected),
input(&State_.Memory, "Memory (GB): ")
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.MemorySchemeSelected == 1; })
}) | with_title("Memory:", ftxui::Color::GrayDark) | with_separator
}) | with_title("Resource allocation:") | with_bottom,
// 第三行:任务名和输出文件
ftxui::Container::Vertical
({
ftxui::Container::Horizontal
({
checkbox("Generate OPTCELL", &State_.OptcellEnable),
ftxui::Menu(&State_.OptcellEntries, &State_.OptcellSelected)
| with_separator | ftxui::Maybe([&]{ return State_.OptcellEnable; })
})
}) | with_title("Misc:")
});
}
public: virtual std::vector<std::string> get_submit_command(std::string extra_sbatch_parameter) const override
{
auto optcell_string = [&]
{
if (State_.OptcellEnable)
if (State_.OptcellSelected == 0) return "echo -e '000\\n000\\n001' > OPTCELL &&"s;
else if (State_.OptcellSelected == 1) return "echo -e '110\\n110\\n000' > OPTCELL &&"s;
else std::unreachable();
else return ""s;
}();
auto recommended = Recommendeds_[State_.QueueSelected];
auto cpu_string = recommended.Cpus ? "--ntasks={} --cpus-per-task=1 --hint=nomultithread"_f(*recommended.Cpus)
: "--ntasks={} --cpus-per-task={} --hint=nomultithread"_f(recommended.Mpi, recommended.Openmp);
auto mem_string = recommended.Memory ? "--mem={}G"_f(*recommended.Memory) : "";
auto srun_string =
recommended.Cpus ? " --ntasks={} --cpus-per-task={}"_f(recommended.Mpi, recommended.Openmp) : ""s;
auto cpu_string = [&]
{
if (State_.CpuSchemeSelected == 0)
if (recommended.Cpus) return "--ntasks={} --cpus-per-task=1 --hint=nomultithread"_f(*recommended.Cpus);
else return "--ntasks={} --cpus-per-task={} --hint=nomultithread"_f(recommended.Mpi, recommended.Openmp);
else if (State_.CpuSchemeSelected == 1) return "--ntasks={} --cpus-per-task={}{}"_f
(State_.MpiThreads, State_.OpenmpThreads, State_.Nomultithread ? " --hint=nomultithread" : "");
else std::unreachable();
}();
auto mem_string = [&]
{
if (State_.MemorySchemeSelected == 0) return recommended.Memory ? "--mem={}G"_f(*recommended.Memory) : "";
else if (State_.MemorySchemeSelected == 1) return "--mem={}G"_f(State_.Memory);
else std::unreachable();
}();
auto srun_string = [&]
{
if (State_.CpuSchemeSelected == 0 && recommended.Cpus)
return " --ntasks={} --cpus-per-task={}"_f(recommended.Mpi, recommended.Openmp);
else return ""s;
}();
return
{
optcell_string,
"sbatch"s,
"--partition={} --nodes=1-1"_f(State_.QueueEntries[State_.QueueSelected]),
cpu_string, mem_string,

View File

@@ -14,6 +14,16 @@ namespace sbatch
std::vector<std::string> GpuSchemeEntries = { "Any", "Custom" };
std::vector<int> GpuSelected;
std::vector<std::vector<std::string>> GpuEntries;
int CpuSchemeSelected = 0;
std::vector<std::string> CpuSchemeEntries = { "Default", "Custom" };
std::string OpenmpThreads = "1";
bool Nomultithread = true;
int MemorySchemeSelected = 0;
std::vector<std::string> MemorySchemeEntries = { "Default", "Custom" };
std::string Memory = "1";
bool OptcellEnable = false;
int OptcellSelected = 0;
std::vector<std::string> OptcellEntries = { "fix ab", "fix c" };
};
protected: StateType State_;
public: virtual std::string get_name() const override { return "VASP(GPU)"; }
@@ -39,6 +49,16 @@ namespace sbatch
for (size_t i = 0; i < State_.GpuSelected.size(); i++)
if (saved_state.GpuSelected[i] < State_.GpuEntries[i].size())
State_.GpuSelected[i] = saved_state.GpuSelected[i];
if (saved_state.CpuSchemeSelected < State_.CpuSchemeEntries.size())
State_.CpuSchemeSelected = saved_state.CpuSchemeSelected;
State_.OpenmpThreads = saved_state.OpenmpThreads;
State_.Nomultithread = saved_state.Nomultithread;
if (saved_state.MemorySchemeSelected < State_.MemorySchemeEntries.size())
State_.MemorySchemeSelected = saved_state.MemorySchemeSelected;
State_.Memory = saved_state.Memory;
State_.OptcellEnable = saved_state.OptcellEnable;
if (saved_state.OptcellSelected < State_.OptcellEntries.size())
State_.OptcellSelected = saved_state.OptcellSelected;
}
catch (...) {}
}
@@ -69,13 +89,57 @@ namespace sbatch
&State_.QueueSelected
) | with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.GpuSchemeSelected == 1; })
}) | with_title("GPU:", ftxui::Color::GrayDark) | with_separator
}) | with_title("Resource allocation:") | with_bottom
}) | with_title("GPU:", ftxui::Color::GrayDark) | with_separator,
// CPU 设置
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.CpuSchemeEntries, &State_.CpuSchemeSelected),
ftxui::Container::Vertical
({
input(&State_.OpenmpThreads, "OpenMP: "),
checkbox("Disable multithread", &State_.Nomultithread)
})
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.CpuSchemeSelected == 1; })
}) | with_title("CPU:", ftxui::Color::GrayDark) | with_separator,
// 内存
ftxui::Container::Horizontal
({
ftxui::Menu(&State_.MemorySchemeEntries, &State_.MemorySchemeSelected),
input(&State_.Memory, "Memory (GB): ")
| with_list_padding | with_separator
| ftxui::Maybe([&]{ return State_.MemorySchemeSelected == 1; })
}) | with_title("Memory:", ftxui::Color::GrayDark) | with_separator
}) | with_title("Resource allocation:") | with_bottom,
// 第三行:任务名和输出文件
ftxui::Container::Vertical
({
ftxui::Container::Horizontal
({
checkbox("Generate OPTCELL", &State_.OptcellEnable),
ftxui::Menu(&State_.OptcellEntries, &State_.OptcellSelected)
| with_separator | ftxui::Maybe([&]{ return State_.OptcellEnable; })
})
}) | with_title("Misc:")
});
}
public: virtual std::vector<std::string> get_submit_command(std::string extra_sbatch_parameter) const override
{
auto cpu_string = "--ntasks=1 --cpus-per-task=1 --hint=nomultithread"s;
auto optcell_string = [&]
{
if (State_.OptcellEnable)
if (State_.OptcellSelected == 0) return "echo -e '000\\n000\\n001' > OPTCELL && "s;
else if (State_.OptcellSelected == 1) return "echo -e '110\\n110\\n000' > OPTCELL && "s;
else std::unreachable();
else return ""s;
}();
auto cpu_string = [&]
{
if (State_.CpuSchemeSelected == 0) return "--ntasks=1 --cpus-per-task=1 --hint=nomultithread"s;
else if (State_.CpuSchemeSelected == 1) return "--ntasks=1 --cpus-per-task={}{}"_f
(State_.OpenmpThreads, State_.Nomultithread ? " --hint=nomultithread" : "");
else std::unreachable();
}();
auto gpu_string = [&]
{
if (State_.GpuSchemeSelected == 0) return "--gpus=1"s;
@@ -83,9 +147,15 @@ namespace sbatch
(State_.GpuEntries[State_.QueueSelected][State_.GpuSelected[State_.QueueSelected]]);
else std::unreachable();
}();
auto mem_string = "--mem=32G"s;
auto mem_string = [&]
{
if (State_.MemorySchemeSelected == 0) return "--mem=32G"s;
else if (State_.MemorySchemeSelected == 1) return "--mem={}G"_f(State_.Memory);
else std::unreachable();
}();
return
{
optcell_string,
"sbatch"s,
"--partition={} --nodes=1-1"_f(State_.QueueEntries[State_.QueueSelected]),
gpu_string, cpu_string, mem_string,

View File

@@ -1,8 +0,0 @@
{ stdenv, src, cmake, pkg-config, postgresql, reflectcpp }: stdenv.mkDerivation
{
name = "sqlgen";
inherit src;
nativeBuildInputs = [ cmake pkg-config ];
propagatedBuildInputs = [ postgresql reflectcpp ];
cmakeFlags = [ "-DSQLGEN_USE_VCPKG=OFF" "-DSQLGEN_SQLITE3=OFF" "-DBUILD_SHARED_LIBS=ON" ];
}