Compare commits

...

107 Commits

Author SHA1 Message Date
1e2114aaa3 packages.biu: fix log trace 2026-01-11 15:39:58 +08:00
fe9bda0e7b update ufo 2026-01-11 14:54:13 +08:00
16c84c3dca modules.packages.vscode: Disable terminal suggestions 2026-01-11 14:14:34 +08:00
3336eeca78 modules.packages.minimal: switch yq to yq-go 2026-01-10 19:52:11 +08:00
d22da25c2b modified.packages.vscode: add ms-vscode.cpptools 2026-01-10 18:45:02 +08:00
40aa569024 devices.hwang: init 2026-01-09 15:16:48 +08:00
5f36b073a7 modified.packages.desktop: remove some packages 2026-01-09 14:53:38 +08:00
c707d8e168 packages.missgram: Update parse mode to Markdown 2026-01-09 14:43:58 +08:00
758d86262c packages.missgram: enable notification 2026-01-08 22:33:13 +08:00
08e3440742 Merge branch 'missgram' into production 2026-01-08 19:15:14 +08:00
5e1c07931e packages.missgram: fix 2026-01-08 19:15:00 +08:00
f1b762c959 packages.biu: fix inline 2026-01-08 19:11:45 +08:00
2079a35e67 fix ufo 2026-01-08 12:37:22 +08:00
438c569c2f modules.system.gui: add more keybindings for niri 2026-01-08 10:30:43 +08:00
7a50f12129 devices.nas: add new device 2026-01-07 12:07:47 +08:00
0389536c9d flake: not use submodule 2026-01-06 21:17:52 +08:00
163faa0db3 modules.system.fileSystems.impermanence: add dms cache dirs to impermanence 2026-01-06 21:10:22 +08:00
6d11d3232f flake.lib.buildNixpkgsConfig: downgrade typst 2026-01-06 20:54:48 +08:00
48cd33e478 update typst 2026-01-06 17:39:29 +08:00
65bf14958b modules.packages.yazi: add compress plugin and keymap 2026-01-06 13:59:19 +08:00
26371c3076 modules.services.gitea: disable AI web crawler prevention 2026-01-06 12:44:54 +08:00
f0cc24522e modules.services.gitea: fix 2026-01-06 12:38:43 +08:00
411a276d34 modules.system.grub: wait indefinitely on desktops 2026-01-06 12:31:34 +08:00
3b2ed6d850 modules.system.systemd: handle lid switch 2026-01-06 12:31:34 +08:00
e580d7faa2 flake: add ufo as submodule 2026-01-06 12:31:34 +08:00
c480e681c1 modules.services.gitea: remove anubis, use simple js 2026-01-06 09:48:54 +08:00
4adc1be9a2 flake: use nixpkgs from git submodule 2026-01-05 23:11:44 +08:00
93b1e4f146 modules.system.gui: set niri keybindings 2026-01-05 16:46:45 +08:00
b71484eca4 devices.wlin: chn-bsub us non-static package 2026-01-05 16:19:56 +08:00
3c37a9288c devices.wlin: use static chn-bsub 2026-01-05 16:11:09 +08:00
2532d3cf70 packages.biu: fix static build 2026-01-05 16:06:45 +08:00
1e65495897 packages.biu: cleanup unnecessary stdenv override 2026-01-05 15:26:06 +08:00
f2a9d285f3 packages.biu: simplify backtrace 2026-01-05 15:10:10 +08:00
ef8f516ab3 packages.biu: remove unused Logger::Exception class 2026-01-05 13:56:23 +08:00
d8b96a32e8 devices.wlin: fix env 2026-01-05 13:44:16 +08:00
085fde23ba modules.system.gui: allow to turn off monitors 2026-01-04 23:57:53 +08:00
5de71b4f6d modules.system.fileSystems.nfs: fix read-only NFS unmounting 2026-01-04 21:26:45 +08:00
682fb5d0a4 flake: update cachyos 2026-01-04 20:47:45 +08:00
a4ebf16124 modules.hardware.asus: do not apply kernel patch 2026-01-04 20:24:45 +08:00
03e89c43d2 Revert "devices.pc: switch to xanmod kernel"
This reverts commit 3e3e62838b.
2026-01-04 20:24:22 +08:00
e8786d4ace update asusctl 2026-01-04 19:23:57 +08:00
7b479a158b modules.system.kernel: Sort ASUS kernel patches 2026-01-04 00:30:27 +08:00
3e3e62838b devices.pc: switch to xanmod kernel 2026-01-03 23:04:29 +08:00
0ac3e0f4bc update xanmod 2026-01-03 23:03:56 +08:00
ef99027542 Revert "flake: remove linux-asus patch"
This reverts commit 1e3f630aa9.
2026-01-03 22:58:52 +08:00
c86ebb17f4 modules.packages.zsh: fix gitstatusd run on remote 2026-01-03 21:15:00 +08:00
6eb1609f3e modules.system.gui: fix niri scroll 2026-01-03 20:24:54 +08:00
b6dd4555a6 devices.wlin: add prrte.dev 2026-01-03 18:32:11 +08:00
93dc607cb5 Revert "localPackages: remove custom stdenv"
This reverts commit f653471c23.
2026-01-03 17:49:32 +08:00
f653471c23 localPackages: remove custom stdenv 2026-01-03 17:15:53 +08:00
0416427642 Revert "packages.chn-bsub: use fixed bash"
This reverts commit 9595bed7c0.
2026-01-03 16:58:50 +08:00
9595bed7c0 packages.chn-bsub: use fixed bash 2026-01-03 16:56:19 +08:00
e2556f3a04 devices.wlin: fix chn-bsub override usage 2026-01-03 16:20:21 +08:00
f5e70e16b2 packages.chn-bsub: fix config format 2026-01-03 16:05:01 +08:00
ebc05b9911 flake.lib.buildNixpkgsConfig: enable lsf support for openmpi 2026-01-03 15:57:18 +08:00
6efc29a7a4 devices.pc: Improve power management settings 2026-01-03 15:05:11 +08:00
c0c8bc3704 modules.system.systemd: disable lid switch causing suspend 2026-01-03 15:05:11 +08:00
73a1490fed modules.system.gui: fix niri 2026-01-03 15:05:11 +08:00
1bb6e550d8 modules.user.chn.ssh: Set TERM for wlin host 2026-01-03 14:18:55 +08:00
c9bd7b48d7 devices.wlin: add lsd 2026-01-03 14:17:25 +08:00
d1d27ce194 packages.chn-bsub: fix, install on wlin 2026-01-03 12:19:05 +08:00
3f46eb23de devices.wlin: adjust path 2026-01-02 18:08:02 +08:00
4cb983ce32 modules.packages.ssh: fix wlin 2026-01-02 18:06:20 +08:00
87c6d0fab4 devices.wlin: install 2026-01-02 18:05:24 +08:00
e5f7e1650e devices.wlin: add phonopy and vasp 2026-01-02 13:52:42 +08:00
d92b202b8e modules.packages.minimal: add cryptsetup 2026-01-02 12:59:45 +08:00
4c3cb5fe5f flake.dns: add tailscale DNS config 2026-01-02 12:46:56 +08:00
2147ba2f2d devices.srv2: remove NFS mount for NAS 2026-01-02 12:24:27 +08:00
58b1c596db flake.nixos: temporarily remove r2s 2026-01-02 11:38:50 +08:00
2e278b2dba flake: update btop 2026-01-01 07:56:27 +08:00
72067d23c5 flake.packages: allow to build separate archive 2025-12-31 20:21:26 +08:00
94670e9cbe devices.srv2: fix nfs mount 2025-12-31 17:31:19 +08:00
3ab4ecb5d2 modules.system.gui: Enable GTK icon cache 2025-12-31 17:03:45 +08:00
63c647ceba Merge branch 'next' into production 2025-12-31 14:11:59 +08:00
fb7e9156d0 packages.missgram: fix 2025-12-31 08:29:00 +08:00
f2e2f34cbf devices.pc: add NFS mount for nas.ts.chn.moe 2025-12-30 14:56:07 +08:00
7d09abee57 modules.system.fileSystems.nfs: add readOnly option 2025-12-30 14:55:12 +08:00
e2921059f8 modules.packages.desktop: update libreoffice 2025-12-30 11:36:40 +08:00
acd2845377 update readme 2025-12-30 10:52:00 +08:00
b1546505a5 fix distutils 2025-12-30 08:20:28 +08:00
e067993a14 packages.missgram: 转发回复,并修改文案 2025-12-29 17:06:58 +08:00
ffd01db99b packages.missgram: 修改文案 2025-12-29 16:52:47 +08:00
e1879c6625 packages/missgram: fix 2025-12-29 14:06:23 +08:00
8587524732 flake.lib: allow generic module styles 2025-12-28 18:00:25 +08:00
8fba11e9a8 modules.packages.vscode: swith to nixd 2025-12-28 17:40:51 +08:00
1de9f717ab modules.services.missgram: fix 2025-12-28 17:16:00 +08:00
3a34d1e962 packages.missgram: fix 2025-12-28 15:40:25 +08:00
f7deb945ae packages/missgram: save info to db 2025-12-28 10:46:52 +08:00
c3e1d2bfb7 devices.pc: enable postgresql 2025-12-27 16:23:42 +08:00
8166c7ecee packages/missgram: init sql depencency 2025-12-27 16:02:40 +08:00
157dd0e844 packages/reflectcpp,sqlgen: init 2025-12-27 15:46:15 +08:00
0c80dde1d1 packages/missgram: rename 2025-12-27 11:40:10 +08:00
4d1f6eb6b5 packages.misskey-forwarder: fix 2025-12-26 13:35:01 +08:00
bf922747d5 packages/misskey-forwarder: fix renote link 2025-12-26 12:38:29 +08:00
a1b4aa7803 flake.dns: fix 2025-12-26 07:01:12 +08:00
3eb2495ebb flake.lib.buildNixpkgsConfig: remove valkey workaround 2025-12-25 23:12:53 +08:00
c36e0c52d6 packages/misskey-forwarder: init 2025-12-25 23:12:48 +08:00
222b0829c8 modules.packages.vscode: remove tab default keybinding 2025-12-25 17:53:45 +08:00
3b7e22fc52 Merge branch 'next' into production 2025-12-25 09:13:40 +08:00
5aebb72185 packages.ghostty/zellij: increase scrollback buffer size 2025-12-24 21:06:20 +08:00
08023306d6 modules.services.sshd: enable GatewayPorts 2025-12-24 14:28:28 +08:00
ea91a75380 Revert "modules.services.huggin: drop"
This reverts commit 7a7b645e9e.
2025-12-24 14:01:49 +08:00
94a0b81122 modules.user: add stq 2025-12-22 18:05:20 +08:00
4d10cb5301 modules.system.gui: add more startup apps 2025-12-22 12:58:10 +08:00
1d6a352978 modules.packages.zsh: enable fzf 2025-12-21 09:29:11 +08:00
58ea730d48 Revert "devices.pc: adjust cpu voltage and power settings"
This reverts commit 298b0e05f5.
2025-12-21 08:58:00 +08:00
298b0e05f5 devices.pc: adjust cpu voltage and power settings 2025-12-20 22:00:12 +08:00
77 changed files with 1303 additions and 554 deletions

View File

@@ -24,3 +24,9 @@ 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

@@ -7,6 +7,7 @@ let devices =
"/dev/disk/by-partlabel/nas-root2".mapper = "root2";
"/dev/disk/by-partlabel/nas-root3" = { mapper = "root3"; ssd = true; };
"/dev/disk/by-partlabel/nas-root4" = { mapper = "root4"; ssd = true; };
"/dev/disk/by-partlabel/nas-root5".mapper = "root5";
"/dev/disk/by-partlabel/nas-swap" = { mapper = "swap"; ssd = true; };
"/dev/disk/by-partlabel/nas-ssd1" = { mapper = "ssd1"; ssd = true; };
"/dev/disk/by-partlabel/nas-ssd2" = { mapper = "ssd2"; ssd = true; };

18
devices/hwang/default.nix Normal file
View File

@@ -0,0 +1,18 @@
# sudo nix build --store 'local?store=/data/gpfs01/hwang/.nix/store&state=/data/gpfs01/hwang/.nix/state&log=/data/gpfs01/hwang/.nix/log' .#hwang
# sudo nix-store --store 'local?store=/data/gpfs01/hwang/.nix/store&state=/data/gpfs01/hwang/.nix/state&log=/data/gpfs01/hwang/.nix/log' -qR ./result | grep -Fxv -f <(ssh hwang find .nix/store -maxdepth 1 -exec realpath '{}' '\;') | sudo xargs nix-store --store 'local?store=/data/gpfs01/hwang/.nix/store&state=/data/gpfs01/hwang/.nix/state&log=/data/gpfs01/hwang/.nix/log' --export | pv > hwang.nar
# cat hwang.nar | nix-store --import
{ inputs, localLib }:
let
pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig
{
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/hwang/.nix"; nixos = false; };
});
hwang = pkgs.symlinkJoin
{
name = "hwang";
paths = with pkgs; [ pv localPackages.vasp.intel glibc ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; archive = pkgs.closureInfo { rootPaths = [ hwang.drvPath ]; }; };
};
in hwang

View File

@@ -12,6 +12,7 @@ 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

@@ -21,7 +21,10 @@ inputs:
swap = [ "/dev/mapper/swap" ];
# TODO: snapshot should take place just before switching root
rollingRootfs.waitDevices =
[ "/dev/mapper/root2" "/dev/mapper/root3" "/dev/mapper/root4" "/dev/mapper/ssd1" "/dev/mapper/ssd2" ];
[
"/dev/mapper/root2" "/dev/mapper/root3" "/dev/mapper/root4" "/dev/mapper/root5"
"/dev/mapper/ssd1" "/dev/mapper/ssd2"
];
};
initrd.sshd = {};
nixpkgs.march = "alderlake";
@@ -55,6 +58,7 @@ inputs:
nextcloud = {};
freshrss = {};
send = {};
huginn = {};
httpapi = {};
gitea = {};
grafana = {};

View File

@@ -54,10 +54,13 @@ vaultwarden:
admin_token: ENC[AES256_GCM,data:TrgqQwXBoCdsLeWQYkur4zS+Z4nCoDDoePnN5vm+AIcgYXVwjxcf/0AwXQIxVNEypYysPpoHKOigwhkf5kLazAMiBZ0goAflJT/S4nOLo90s+9kDCADXWnCeHNhBUg8fUulNPBbpqdfFKCJgJCD2WTI+V5yFLQ==,iv:maKU6pcxis7Cyrx9x26cUTBzA6ZKcKJWSP23w+MDehw=,tag:GYpPHp2slC6V8aKA1FHFAg==,type:str]
mariadb:
freshrss: ENC[AES256_GCM,data:Qjg5GIX13ccZi/DuqtWK0qzr2GK0GzzUdEZWXDhUhGxFWzgosADxDCc8wfOchItaJFefnVrpPxdAPvT+4TEH0g==,iv:oGii3o6sJYVc11kdQMh0Pa3GUbWqttFgjvSVEbTycZc=,tag:8GWWwuJjQBwDFl9pJvg90g==,type:str]
huginn: ENC[AES256_GCM,data:/hFQdG/RGrX75qd0+WgwhnwR7p/CEVx1vPksRSudxmc1m4VO/AVzgMCWAz4310ctTEnn4GZinvD6QGFta5IOSA==,iv:mrPDZA6Bnw+SPVDDe64tivvvQtHWvCsPJbEnPqm12g4=,tag:ihXbIJwwtQ0RfaNfcaop4Q==,type:str]
nextcloud:
admin: ENC[AES256_GCM,data:DJK+u19VP9cFvq4/P0+f7erXxZkRWI4NRrX9HdHO96xy9wZMtB+hEDN3zLQnkTTtmd2ZLs9+c9BsUNXZperGDQ==,iv:zX8Nxt5+O/mGVt5l1j8IojBkgxg5oDae6KWTXYz0hRE=,tag:MRyMx0OXYTCmtaySP/umNw==,type:str]
freshrss:
chn: ENC[AES256_GCM,data:wwHntnMeiGZ5v8CE7CGV,iv:snIdYdFpvv5HvcR5qucD2pZXXef3dhSU+2wK5SPrDjw=,tag:2RnujKKkQSoxvSNZPLS9Pg==,type:str]
huginn:
invitationCode: ENC[AES256_GCM,data:E8rEdAfUQX9oJEnvxVF5PmYFMd9PN8+K,iv:gZtUf+AkICLHD4h2beHbEfyoL4bcoOv0sivDFDB3vVY=,tag:4tlsPuED6jCXNE0iOayXsg==,type:str]
grafana:
secret: ENC[AES256_GCM,data:O2L0+R9QvOMJLKa941nxn+FeuZ5nOAm1iDlKW2vvk5Dyod0XLdGL1seWuYzpx+NL16qmC1u8jydDcBfUT+PAeA==,iv:Pqsr+POPAr8djdVMK5U4PiS1zUnZXLH3q588D/jOMys=,tag:QziP0kKT5oyI/RHaYHr2mw==,type:str]
chn: ENC[AES256_GCM,data:xMwWBYChRIxw5KDjgCYBJWkbRRo5FUtyhZ0+SVRIgjQ=,iv:EIjECQHx3/2t+oMC16B1Xfwa8guiST2pdIKM1hNcuFA=,tag:BP8ElnMevqF6urDgBP/UAg==,type:str]
@@ -87,7 +90,7 @@ sops:
by9Rd0U0bzNiK21BQTNxN1RuQ09DQVkKJmSlzV5ppEkZFljsS17ZWmoI++fz4tJh
kTdoAStG1zsKASHyZTsmdm3RBDO3qV1KhQC2gC7d4EiwNZngxOOZJg==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2025-12-19T03:10:32Z"
mac: ENC[AES256_GCM,data:xPqumB7DAGPi9HGSCnxnmr8zgOT+7smCREs4qSEKQ5ZikxIVuWQPqQaThIuAAFB/dQu0Gm92I4Lj+F+w4+9NlVTnku0HY8CWD5PlNcun+0CEAX9byuVrfEH8zwqOX+SRrHIEU0h3TWI492EiJm7lgchWe/o50seS7RT6d0q8IfQ=,iv:5PYqHhzvLYhIu8PT+TAyoDmtj7+AB3iCVZMX8PfKQQc=,tag:9+6VGz8bDmLqVWCdysXk1g==,type:str]
lastmodified: "2025-12-04T17:33:50Z"
mac: ENC[AES256_GCM,data:MjCnibcdkR927418wAlPUj5IXfbCQMS4QQOKvWRHdqqZHBQFw886Nx8YOXvH2PTgAhDWjzhuhnkF3InaY63zYqamJcKKwp/aIjZ97UXNKsZPKaVo48S9rBuHPFI/NceDSoMPZvgrMhgNguegdc6B8D2fwJPdtdSa6pJez1WQ9r8=,iv:kZnVRglmmWkR7f80bCX9Y5Th3dNI8TtUxx6P40d7E1o=,tag:5L0bfCYJq/EpvaT8BJA2QQ==,type:str]
unencrypted_suffix: _unencrypted
version: 3.11.0

View File

@@ -18,11 +18,13 @@ inputs:
"/dev/mapper/tf1" =
{
"/" = "/nix/tf";
"/nix/remote/jykang" = "/data/gpfs01/jykang/.nix";
"/nix/remote/xmuhk" = "/public/home/xmuhk/.nix";
"/nix/remote/jykang" = "/data/gpfs01/jykang/.nix";
"/nix/remote/wlin" = "/data/gpfs01/wlin/.nix";
"/nix/remote/hwang" = "/data/gpfs01/hwang/.nix";
};
};
nfs."nas.ts.chn.moe:/" = { mountPoint = "/nix/remote/nas"; mountBeforeSwitch = false; };
};
luks.auto =
{
@@ -103,6 +105,7 @@ inputs:
mariadb.mountFrom = "nodatacow";
open-webui.ollamaHost = "127.0.0.1";
howdy = {};
postgresql.enable = true;
};
bugs = [ "amdpstate" ];
packages = { mathematica = {}; vasp = {}; };
@@ -113,10 +116,17 @@ inputs:
services.colord.enable = true;
services.udev.extraRules =
''
#
ACTION=="add", ATTR{power/wakeup}="disabled"
# CPU
SUBSYSTEM=="power_supply", KERNEL=="BAT0", ACTION=="*", RUN+="${inputs.pkgs.ryzenadj}/bin/ryzenadj --set-coall=0x0fff40"
'';
# 解决有时蓝牙不能使用的问题
boot.kernelParams = [ "mt7925e.disable_aspm=1" ];
boot.kernelParams =
[
# 解决有时蓝牙不能使用的问题
"mt7925e.disable_aspm=1"
# 插拔电源和扩展坞不要唤醒电脑
"acpi.ec_no_wakeup=1"
];
};
}

View File

@@ -12,7 +12,6 @@ inputs:
vfat."/dev/disk/by-partlabel/${clusterName}-${nodeName}-boot" = "/boot";
btrfs."/dev/disk/by-partlabel/${clusterName}-${nodeName}-root1" =
{ "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
nfs."nas.ts.chn.moe:/" = { mountPoint = "/nix/remote/nas"; neededForBoot = false; };
};
nixpkgs.cuda.capabilities =
[
@@ -102,6 +101,7 @@ inputs:
"ccy" # 陈超业
"twr" # 唐文睿,吴猛的学生
"lsp" # 李书平的不知道哪个学生要用
"stq" # 孙天骐
];
};
};

View File

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

View File

@@ -5,6 +5,10 @@ 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
@@ -25,7 +29,7 @@ sops:
ZXFTU3ZCaW1pTVh0RUJzdDdGdHlPYTgK2mlgcX2kEc8+2UDdBnhUm6IIuh8V6agW
ooxH9OEPXUVI/4JcDo4v8ZUhAyU1ehLH0Ef7PJCChOZe2KZmWSNbhA==
-----END AGE ENCRYPTED FILE-----
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]
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]
unencrypted_suffix: _unencrypted
version: 3.11.0

View File

@@ -31,7 +31,7 @@ inputs:
(site: { name = "${site}.chn.moe"; value.upstream.address = "tinc0.nas.chn.moe"; })
[
"xn--s8w913fdga" "matrix" "send" "git" "grafana" "peertube" "rsshub" "misskey" "synapse" "vaultwarden"
"nextcloud" "freshrss" "api" "webdav"
"nextcloud" "freshrss" "huginn" "api" "webdav"
]);
};
};

9
devices/wlin/bsub.nix Normal file
View File

@@ -0,0 +1,9 @@
{
normal = [ 4 4 20 ];
normal_1day = [ 4 7 28 ];
normal_1week = [ 4 7 28 ];
normal_2week = [ 6 8 48 ];
normal_1day_new = [ 4 6 24 ];
ocean_530_1day = [ 4 6 24 ];
ocean6226R_1day = [ 4 8 32 ];
}

View File

@@ -1,3 +1,6 @@
# sudo nix build --store 'local?store=/data/gpfs01/wlin/.nix/store&state=/data/gpfs01/wlin/.nix/state&log=/data/gpfs01/wlin/.nix/log' .#wlin
# sudo nix-store --store 'local?store=/data/gpfs01/wlin/.nix/store&state=/data/gpfs01/wlin/.nix/state&log=/data/gpfs01/wlin/.nix/log' -qR ./result | grep -Fxv -f <(ssh wlin find .nix/store -maxdepth 1 -exec realpath '{}' '\;') | sudo xargs nix-store --store 'local?store=/data/gpfs01/wlin/.nix/store&state=/data/gpfs01/wlin/.nix/state&log=/data/gpfs01/wlin/.nix/log' --export | pv > wlin.nar
# cat wlin.nar | nix-store --import
{ inputs, localLib }:
let
pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig
@@ -5,11 +8,18 @@ let
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/wlin/.nix"; nixos = false; };
});
python = pkgs.python3.withPackages (ps: with ps; [ phonopy ]);
chn-bsub = pkgs.localPackages.chn-bsub.override
(prev: { bsubConfig = builtins.toFile "bsub.yaml" (builtins.toJSON (import ./bsub.nix)); });
wlin = pkgs.symlinkJoin
{
name = "wlin";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv ];
paths = with pkgs;
[
gnuplot localPackages.vaspkit pv python localPackages.vasp.intel chn-bsub hwloc
lsd glibc glibc.bin
];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; };
passthru = { inherit pkgs chn-bsub; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; };
};
in wlin

View File

@@ -1,12 +1,3 @@
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH

View File

@@ -1,43 +1,10 @@
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=$PATH:/data/gpfs01/wlin/bin
# User specific aliases and functions
export PATH=/data/gpfs01/wlin/bin/vaspkit.1.4.1/bin:${PATH}
#export PATH=~/bin:/data/gpfs01/wlin/opt/mpich_ifort/bin:$PATH
#export LD_LIBRARY_PATH=/data/gpfs01/wlin/opt/mpich_ifort/lib:$LD_LIBRARY_PATH
#export PATH=~/bin:/data/gpfs01/wlin/opt/mpich/bin:$PATH
#export LD_LIBRARY_PATH=/data/gpfs01/wlin/opt/mpich/lib:$LD_LIBRARY_PATH
export P4_RSHCOMMAND=ssh
shopt -s cdspell
export HISTCONTROL=ignoredups
#shopt -s histappend
PROMPT_COMMAND='history -a'
export C3_RSH="ssh -x"
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
alias grep='grep --color'
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S `whoami`@${USER_IP}: "
export HISTFILESIZE=1000000
export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND"
shopt -s histappend
# Auto add env parameter $PROMPT_COMMAND when use non-Linux tty login by ssh.
if [ "$SSH_CONNECTION" != '' -a "$TERM" != 'linux' ]; then
declare -a HOSTIP
HOSTIP=`echo $SSH_CONNECTION |awk '{print $3}'`
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@$HOSTIP:[${HOSTNAME%%.*}]:${PWD/#$HOME/~} \007"'
if [ -z "${BASHRC_SOURCED-}" ]; then
export PATH=$HOME/.nix/state/gcroots/current/bin:$HOME/bin:$PATH
ulimit -s unlimited
export HISTFILESIZE=1000000
export BASHRC_SOURCED=1
fi
ulimit -s unlimited
export PYTHONPATH=/data/gpfs01/wlin/bin/VaspBandUnfolding-master:${PYTHONPATH}
# vsts, see https://theory.cm.utexas.edu/vtsttools/scripts.html
export PATH=$PATH:/data/gpfs01/wlin/yjj/vtstscripts-1022
export PERL5LIB=/data/gpfs01/wlin/yjj/vtstscripts-1022

View File

@@ -0,0 +1,2 @@
store = local?store=/data/gpfs01/wlin/.nix/store&state=/data/gpfs01/wlin/.nix/state&log=/data/gpfs01/wlin/.nix/log
experimental-features = flakes nix-command

94
flake.lock generated
View File

@@ -100,11 +100,11 @@
"cachyos-kernel": {
"flake": false,
"locked": {
"lastModified": 1766083376,
"narHash": "sha256-eh914fO4gYD8aCuUrMlPBRsxwwa2+qc9HCuAhrG6G9c=",
"lastModified": 1767371066,
"narHash": "sha256-ztxcryN0uX2WhFYoOZLXClqaFwfC8EAVCKaA2M++ROU=",
"owner": "CachyOS",
"repo": "linux-cachyos",
"rev": "9d369789361623b8a3b842a71adccb19b24ba16f",
"rev": "f280ea9c30ca7a39cf8f6995efb553ff9b8cb384",
"type": "github"
},
"original": {
@@ -116,11 +116,11 @@
"cachyos-kernel-patches": {
"flake": false,
"locked": {
"lastModified": 1766080842,
"narHash": "sha256-LezfhAfTdfhvjiHSWe258SMUIs+cP8SHT8BiPou0A4w=",
"lastModified": 1767369270,
"narHash": "sha256-Jne9XlgFlyuJIf9F6QoAObLo2/AXYbaGqNFqCdRdDmY=",
"owner": "CachyOS",
"repo": "kernel-patches",
"rev": "e266fbc7f36273ebbc62a9bffda02e3882eb8f6c",
"rev": "15a034b093aee9b935f7c6c08ea5312e187c9ac7",
"type": "github"
},
"original": {
@@ -364,11 +364,11 @@
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1765121682,
"narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=",
"lastModified": 1767039857,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "NixOS",
"repo": "flake-compat",
"rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
@@ -665,6 +665,23 @@
"type": "github"
}
},
"linux-asus": {
"flake": false,
"locked": {
"lastModified": 1767457777,
"narHash": "sha256-DCKTOfkJ0d1IkSwcSq0r/j45BvkBDcqXVmJAVYRFHSU=",
"owner": "CHN-beta",
"repo": "linux-g14",
"rev": "c02087ae1c3f9d24bdcf2b4b277ce0b4c9fd767c",
"type": "github"
},
"original": {
"owner": "CHN-beta",
"ref": "6.18",
"repo": "linux-g14",
"type": "github"
}
},
"mac-style": {
"flake": false,
"locked": {
@@ -865,11 +882,11 @@
]
},
"locked": {
"lastModified": 1766317927,
"narHash": "sha256-8bpmKA1+G8r8uB8YesjmvSS8w+0dhB+SYdmpGWYlXAE=",
"lastModified": 1767529782,
"narHash": "sha256-Wz8j5qfkxX+QQa/arHqWGYZuBfLTq/cJVDCEIBzEV9o=",
"owner": "CHN-beta",
"repo": "nix-cachyos-kernel",
"rev": "ae6243bbaac9c0eff212bfb45eff5620dfe383a5",
"rev": "7d65b67594d1422ecd2a9f4cbfcce8fca67067f4",
"type": "github"
},
"original": {
@@ -1144,11 +1161,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1766317807,
"narHash": "sha256-HQeHsIrRFllgpmUlhMH+F8cxp/zeODTziEHai2Ryebw=",
"lastModified": 1767694262,
"narHash": "sha256-xpFtS6JGpwaDVqXWEYDfoLb05oLEAL1VE2GF9x8smDk=",
"owner": "CHN-beta",
"repo": "nixpkgs",
"rev": "201f7c1ac0c7c455ad0a6660c037f49821160c3b",
"rev": "ae0b0157cbfee59adb0d6211ea6e47299a173cd5",
"type": "github"
},
"original": {
@@ -1406,6 +1423,24 @@
"url": "https://git.outfoxxed.me/quickshell/quickshell"
}
},
"reflectcpp": {
"flake": false,
"locked": {
"lastModified": 1766526407,
"narHash": "sha256-fUZTdojO/x5G7+MduY25nsO0WvED3LWIwf5hwsACVxA=",
"ref": "refs/heads/main",
"rev": "6fc8c9e81d24e8e9bcca0f4b01450181b1f98669",
"revCount": 748,
"submodules": true,
"type": "git",
"url": "https://github.com/getml/reflect-cpp"
},
"original": {
"submodules": true,
"type": "git",
"url": "https://github.com/getml/reflect-cpp"
}
},
"root": {
"inputs": {
"aagl": "aagl",
@@ -1424,6 +1459,7 @@
"home-manager": "home-manager",
"impermanence": "impermanence",
"lepton": "lepton",
"linux-asus": "linux-asus",
"mac-style": "mac-style",
"matplotplusplus": "matplotplusplus",
"mirism-old": "mirism-old",
@@ -1450,10 +1486,12 @@
"pocketfft": "pocketfft",
"py4vasp": "py4vasp",
"pybinding": "pybinding",
"reflectcpp": "reflectcpp",
"rsshub": "rsshub",
"rycee": "rycee",
"sops-nix": "sops-nix",
"speedtest": "speedtest",
"sqlgen": "sqlgen",
"sqlite-orm": "sqlite-orm",
"sticker": "sticker",
"stickerpicker": "stickerpicker",
@@ -1551,6 +1589,24 @@
"type": "github"
}
},
"sqlgen": {
"flake": false,
"locked": {
"lastModified": 1766749883,
"narHash": "sha256-pcEX2tWl8tHhKPxD1c1O1yeyue/ey0DleO8rCVYg5B4=",
"ref": "refs/heads/main",
"rev": "c8f4ad8d84e1e3f7adc775fa3cb7d65f1f5736b0",
"revCount": 224,
"submodules": true,
"type": "git",
"url": "https://github.com/getml/sqlgen"
},
"original": {
"submodules": true,
"type": "git",
"url": "https://github.com/getml/sqlgen"
}
},
"sqlite-orm": {
"flake": false,
"locked": {
@@ -1729,12 +1785,12 @@
"ufo": {
"flake": false,
"locked": {
"lastModified": 1762315512,
"lastModified": 1768114392,
"lfs": true,
"narHash": "sha256-tTVQrXhnfFdrRwYJ60mpGdlbvUOE6egAxtqD0d80Crw=",
"narHash": "sha256-H2vC6gA4oBBs4ZYSQAxI9VmviCcT9U9+xqNW0Q/N5Jw=",
"ref": "refs/heads/main",
"rev": "dc6b431bf92db5ba22aac745a90e058528d9b5e3",
"revCount": 85,
"rev": "b130375ff8c5e4c02febdf3821ddeb43b6cbd89c",
"revCount": 89,
"type": "git",
"url": "https://git.chn.moe/chn/ufo.git"
},

View File

@@ -53,7 +53,6 @@
pocketfft = { url = "github:mreineck/pocketfft"; flake = false; };
blog = { url = "git+https://git.chn.moe/chn/blog-public.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; };
fancy-motd = { url = "github:CHN-beta/fancy-motd"; flake = false; };
mac-style = { url = "github:SergioRibera/s4rchiso-plymouth-theme?lfs=1"; flake = false; };
@@ -63,6 +62,10 @@
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; };
linux-asus = { url = "github:CHN-beta/linux-g14/6.18"; flake = false; };
ufo = { url = "git+https://git.chn.moe/chn/ufo.git?lfs=1"; flake = false; };
};
outputs = inputs: let localLib = import ./flake/lib inputs.nixpkgs.lib; in

View File

@@ -1,57 +1,64 @@
{ inputs }: let inherit (inputs.self.nixosConfigurations.pc) pkgs; in
{
biu = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
biu = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.biu ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
hpcstat = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
hpcstat = pkgs.mkShell
{
inputsFrom = [ (pkgs.localPackages.hpcstat.override { version = null; }) ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
sbatch-tui = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
sbatch-tui = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.sbatch-tui ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
ufo = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
ufo = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.ufo ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
chn-bsub = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.chn-bsub ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
};
info = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
info = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.info ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
vm = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
vm = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.vm ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
xinli = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; }
xinli = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.xinli ];
packages = [ pkgs.llvmPackages_18.clang-tools ];
packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ];
};
missgram = pkgs.mkShell
{
inputsFrom = [ pkgs.localPackages.missgram ];
packages = [ pkgs.llvmPackages.clang-tools ];
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"
"xserver2.vps6" "s" "headscale" "missgram"
# to pc
""
];
@@ -24,7 +24,7 @@ let
[
"initrd.vps9" "xserver2.vps9"
# to nas
"git" "grafana" "peertube" "send" "vikunja" "xservernas" "freshrss" "nextcloud"
"git" "grafana" "peertube" "send" "vikunja" "xservernas" "freshrss" "huginn" "nextcloud"
"rsshub" "vaultwarden" "webdav" "synapse" "misskey" "api"
];
};
@@ -45,6 +45,7 @@ let
"409test" = "192.168.1.5";
};
tinc = import ./tinc.nix;
tailscale = import ./tailscale.nix;
in
{
"" =
@@ -82,3 +83,6 @@ in
// lib.mapAttrs'
(n: v: lib.nameValuePair "tinc0.${n}" { type = "A"; value = "192.168.85.${builtins.toString v}"; })
tinc
// lib.mapAttrs'
(n: v: lib.nameValuePair "${n}.ts" { type = "A"; value = "100.97.101.${builtins.toString v}"; })
tailscale

View File

@@ -0,0 +1,10 @@
{
vps4 = 7;
vps6 = 2;
vps9 = 6;
pc = 1;
nas = 3;
srv2-node0 = 4;
srv2-node1 = 5;
srv2-node2 = 8;
}

View File

@@ -0,0 +1,76 @@
diff --git a/src/btop_config.cpp b/src/btop_config.cpp
index eaaa577..3074a08 100644
--- a/src/btop_config.cpp
+++ b/src/btop_config.cpp
@@ -234,6 +234,7 @@ namespace Config {
{"custom_gpu_name4", "#* Custom gpu4 model name, empty string to disable."},
{"custom_gpu_name5", "#* Custom gpu5 model name, empty string to disable."},
#endif
+ {"btrfs_group_subvolumes", "#* Show only the first subvolume of a btrfs filesystem."},
};
std::unordered_map<std::string_view, string> strings = {
@@ -336,6 +337,7 @@ namespace Config {
#endif
{"terminal_sync", true},
- {"save_config_on_exit", true}
+ {"save_config_on_exit", true},
+ {"btrfs_group_subvolumes", false},
};
std::unordered_map<std::string_view, bool> boolsTmp;
diff --git a/src/btop_menu.cpp b/src/btop_menu.cpp
index 75ec31c..cfaec39 100644
--- a/src/btop_menu.cpp
+++ b/src/btop_menu.cpp
@@ -724,6 +724,15 @@ namespace Menu {
"kernel as used memory.",
"",
"True or False."},
+ {
+ "btrfs_group_subvolumes",
+ "(Linux) Show only first BTRFS subvolume.",
+ "",
+ "Set to true to only show the first BTRFS",
+ "subvolume mounted per disk.",
+ "",
+ "True or False.",
+ }
},
{
{"graph_symbol_net",
diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp
index eebaa50..37d5745 100644
--- a/src/linux/btop_collect.cpp
+++ b/src/linux/btop_collect.cpp
@@ -2117,6 +2117,7 @@ namespace Mem {
auto use_fstab = Config::getB("use_fstab");
auto only_physical = Config::getB("only_physical");
auto zfs_hide_datasets = Config::getB("zfs_hide_datasets");
+ auto btrfs_group_subvolumes = Config::getB("btrfs_group_subvolumes");
auto& disks = mem.disks;
static std::unordered_map<string, future<pair<disk_info, int>>> disks_stats_promises;
ifstream diskread;
@@ -2177,6 +2178,7 @@ namespace Mem {
vector<string> found;
found.reserve(last_found.size());
string dev, mountpoint, fstype;
+ std::unordered_set<string> found_btrfs_subvolumes;
while (not diskread.eof()) {
std::error_code ec;
diskread >> dev >> mountpoint >> fstype;
@@ -2198,6 +2200,14 @@ namespace Mem {
size_t zfs_dataset_name_start = 0;
if (fstype == "zfs" && (zfs_dataset_name_start = dev.find('/')) != std::string::npos && zfs_hide_datasets) continue;
+ //? skip BtrFS subvolumes
+ if (btrfs_group_subvolumes and fstype == "btrfs") {
+ string devname = fs::canonical(dev, ec).filename();
+ if (!found_btrfs_subvolumes.insert(devname).second) {
+ continue;
+ }
+ }
+
if ((not use_fstab and not only_physical)
or (use_fstab and v_contains(fstab, mountpoint))
or (not use_fstab and only_physical and v_contains(fstypes, fstype))) {

View File

@@ -72,6 +72,14 @@ 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 ]; });
btop = prev.btop.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./btop.patch ]; });
prrte = prev.prrte.overrideAttrs (prev:
{
configureFlags = prev.configureFlags or [] ++ [ "--with-lsf" ];
buildInputs = prev.buildInputs or [] ++ [ final.localPackages.lsf final.libnsl ];
});
cpptrace = prev.cpptrace.overrideAttrs (prev: { doCheck = !final.stdenv.hostPlatform.isStatic; });
typst = final.pkgs-2505.typst;
}
// (
let
@@ -97,6 +105,7 @@ in platformConfig //
})
];
};
pkgs-2505 = "nixpkgs-2505";
};
packages = name:
let flakeSource = inputs.topInputs.${source.${name}.source or source.${name}};
@@ -118,7 +127,6 @@ 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; }); })
@@ -137,7 +145,7 @@ in platformConfig //
assimp = prev.assimp.override { stdenv = final.genericPackages.stdenv; };
xen = prev.xen.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xen.patch ]; });
lib2geom = prev.lib2geom.overrideAttrs (prev: { doCheck = false; });
libreoffice-qt6-still = prev.libreoffice-qt6-still.override (prev:
libreoffice-fresh = prev.libreoffice-fresh.override (prev:
{ unwrapped = prev.unwrapped.overrideAttrs (prev: { postPatch = prev.postPatch or "" +
''
sed -i '/CPPUNIT_TEST.testDubiousArrayFormulasFODS/d' sc/qa/unit/functions_array.cxx

View File

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

View File

@@ -1,6 +1,6 @@
{ inputs, localLib }:
let
singles = [ "nas" "pc" "vps4" "vps6" "vps9" "r2s" ];
singles = [ "nas" "pc" "vps4" "vps6" "vps9" ];
cluster = { srv1 = 3; srv2 = 3; };
deviceModules = builtins.listToAttrs
(

View File

@@ -12,9 +12,7 @@
duc = pkgs.pkgsStatic.duc.override { enableCairo = false; cairo = null; pango = null; };
glaze = pkgs.pkgs-2411.pkgsStatic.glaze.overrideAttrs
(prev: { cmakeFlags = prev.cmakeFlags ++ [ "-Dglaze_ENABLE_FUZZING=OFF" ]; });
# pkgsStatic.clangStdenv have a bug
# https://github.com/NixOS/nixpkgs/issues/177129
biu = pkgs.pkgsStatic.localPackages.biu.override { stdenv = pkgs.pkgsStatic.gcc14Stdenv; inherit glaze; };
biu = pkgs.pkgsStatic.localPackages.biu.override { inherit glaze; };
in pkgs.pkgsStatic.localPackages.hpcstat.override
{
inherit openssh duc biu;
@@ -31,6 +29,7 @@
jykang = import ../devices/jykang { inherit inputs localLib; };
wlin = import ../devices/wlin { inherit inputs localLib; };
xmuhk = import ../devices/xmuhk { inherit inputs localLib; };
hwang = import ../devices/hwang { inherit inputs localLib; };
src =
let getDrv = x:
if pkgs.lib.isDerivation x then [ x ]
@@ -44,14 +43,17 @@
tokenPath = inputs.self.nixosConfigurations.pc.config.nixos.system.sops.secrets."acme/token".path;
octodns = pkgs.octodns.withProviders (_: with pkgs.octodns-providers; [ cloudflare ]);
};
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)
[ src ]
(builtins.attrValues inputs)
]));
archive =
let
systemWithBuildDeps = system:
(system.extendModules { modules = [{ config.system.includeBuildDependencies = true; }]; })
.config.system.build.toplevel;
systems = inputs.nixpkgs.lib.mapAttrs (_: v: systemWithBuildDeps v) inputs.self.outputs.nixosConfigurations;
inputListFile = pkgs.writeText "input-list"
(builtins.concatStringsSep "\n" (builtins.attrValues inputs));
archive = pkgs.writeText "archive" (builtins.concatStringsSep "\n"
((builtins.attrValues systems) ++ [ src inputListFile ]));
in
archive // { passthru = archive.passthru // systems // { inherit src; inputs = inputListFile; }; };
}
// (builtins.mapAttrs (_: v: v.config.system.build.toplevel) inputs.self.outputs.nixosConfigurations)

View File

@@ -55,6 +55,14 @@
};
};
};
huginn = pkgs.dockerTools.pullImage
{
imageName = "ghcr.io/huginn/huginn";
imageDigest = "sha256:68e2c7082cd51d417e5ce76fe123810e9d52f4ab2018569df5b74b913ed3bc64";
sha256 = "0jpdysdphy1lyj6zwx2b1kbgs6bfnpkkx85mf1b9ybh3is6gaz6s";
finalImageName = "ghcr.io/huginn/huginn";
finalImageTag = "latest";
};
misskey = {};
lumerical =
{
@@ -203,4 +211,13 @@
structuredExtraConfig = { BTRFS_ALLOCATOR_HINTS = lib.kernel.yes; BTRFS_READ_POLICIES = lib.kernel.yes; };
};
};
# download include from /opt/ibm/lsfsuite/lsf/10.1/include into lsf/include
# download lib from /opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/lib into lsf/lib and only preserve .so
lsf = pkgs.requireFile
{
name = "lsf";
sha256 = "0rij4xx705yj1vr5jd31hb8izmb35vkrdql0850qc5cn30jnkf4l";
hashMode = "recursive";
message = "lsf not found.";
};
}

19
modules/packages/btop.nix Normal file
View File

@@ -0,0 +1,19 @@
{ lib, pkgs, config, ... }:
{
options.nixos.packages.btop = lib.mkOption { type = lib.types.nullOr (lib.types.submodule {}); default = {}; };
config = let inherit (config.nixos.packages) btop; in lib.mkIf (btop != null)
{
nixos =
{
packages.packages._packages = [ pkgs.btop ];
user.sharedModules =
[{
config.programs.btop =
{
enable = true;
settings.btrfs_group_subvolumes = true;
};
}];
};
};
}

View File

@@ -15,7 +15,7 @@ inputs:
[
# system management
# TODO: module should add yubikey-touch-detector into path
gparted wayland-utils clinfo mesa-demos vulkan-tools dracut yubikey-touch-detector btrfs-assistant snapper-gui
gparted wayland-utils clinfo mesa-demos vulkan-tools dracut yubikey-touch-detector btrfs-assistant
cpu-x wl-mirror geekbench xpra
(
writeShellScriptBin "xclip"
@@ -54,25 +54,21 @@ inputs:
google-chrome tor-browser
# office
crow-translate zotero pandoc texliveFull poppler-utils pdftk pdfchain kdePackages.kruler kdePackages.okular
ydict texstudio panoply pspp libreoffice-qt6-still ocrmypdf typst # paperwork
ydict texstudio panoply pspp libreoffice-fresh ocrmypdf typst # paperwork
# required by ltex-plus.vscode-ltex-plus
ltex-ls ltex-ls-plus
# matplot++ needs old gnuplot
pkgs-2311.gnuplot
# math, physics and chemistry
octaveFull ovito localPackages.vesta localPackages.v-sim jmol mpi geogebra6 localPackages.ufo
octaveFull ovito localPackages.vesta localPackages.v-sim mpi geogebra6 localPackages.ufo
(quantum-espresso.override { stdenv = gcc14Stdenv; gfortran = gfortran14; })
pkgs-2311.hdfview numbat qalculate-qt
# virtualization
virt-viewer bottles wineWowPackages.stagingFull genymotion playonlinux
pkgs-2311.hdfview
# media
nur-xddxdd.svp
# for kdenlive auto subtitle
openai-whisper
# daily management
activitywatch super-productivity
# game
lutris
super-productivity
];
_pythonPackages = [(pythonPackages: with pythonPackages;
[

View File

@@ -11,7 +11,7 @@ inputs:
config.programs.ghostty =
{
enable = true;
settings.keybind = "ctrl+shift+r=reset";
settings = { scrollback-limit = 100000000; keybind = "ctrl+shift+r=reset"; };
};
}];
packages.packages._packages = [ inputs.pkgs.ghostty ];

View File

@@ -9,12 +9,12 @@ inputs:
_packages = with inputs.pkgs;
[
# basic tools
beep dos2unix gnugrep pv tmux screen parallel tldr cowsay jq yq ipfetch localPackages.pslist
fastfetch reptyr duc ncdu progress libva-utils ksh neofetch dateutils glib
beep dos2unix gnugrep pv tmux screen parallel tldr cowsay jq yq-go ipfetch localPackages.pslist
fastfetch reptyr duc ncdu progress libva-utils ksh neofetch dateutils glib cryptsetup
# lsxx
pciutils usbutils lshw util-linux lsof dmidecode lm_sensors hwloc acpica-tools ethtool
# top
iotop iftop htop btop powertop s-tui
iotop iftop htop powertop s-tui
# editor
nano bat
# downloader

View File

@@ -47,7 +47,6 @@ inputs:
host = host;
hostname = "hpc.xmu.edu.cn";
user = host;
setEnv.TERM = "chn_unset_ls_colors:xterm-256color";
};
})
[ "wlin" "hwang" ])

View File

@@ -26,8 +26,7 @@ inputs:
[
"github.copilot" "github.copilot-chat" "github.github-vscode-theme"
"intellsmi.comment-translate"
"ms-vscode.cmake-tools" "ms-vscode.cpptools-extension-pack" "ms-vscode.hexeditor"
"ms-vscode.remote-explorer"
"ms-vscode.hexeditor" "ms-vscode.remote-explorer"
"ms-vscode-remote.remote-ssh"
"donjayamanne.githistory" "fabiospampinato.vscode-diff"
"llvm-vs-code-extensions.vscode-clangd" "ms-ceintl.vscode-language-pack-zh-hans"
@@ -65,6 +64,9 @@ inputs:
"ms-toolsai.datawrangler"
# nushell
"TheNuProjectContributors.vscode-nushell-lang"
# C/C++
"ms-vscode.cmake-tools" "ms-vscode.cpptools-extension-pack" "ms-vscode.cpptools" "coolchyni.beyond-debug"
"vadimcn.vscode-lldb"
];
keybindings =
[
@@ -78,6 +80,14 @@ 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";
@@ -173,13 +183,8 @@ inputs:
"update.mode" = "none";
"editor.tabSize" = 2;
"nix.enableLanguageServer" = true;
"nix.serverPath" = "nil";
"nix.serverPath" = "nixd";
"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)";
@@ -332,6 +337,8 @@ inputs:
"tinymist.preview.partialRendering" = false;
"tinymist.preview.refresh" = "onSave";
"workbench.secondarySideBar.defaultVisibility" = "hidden";
# disable terminal suggestions
"terminal.integrated.suggest.enabled" = false;
};
};
};

View File

@@ -1,4 +1,4 @@
inputs:
{ pkgs, ... }:
{
config =
{
@@ -8,7 +8,12 @@ inputs:
config.programs.yazi =
{
enable = true;
keymap.mgr.append_keymap = [{ on = "T"; run = "shell --orphan ghostty"; }];
keymap.mgr.append_keymap =
[
{ on = "T"; run = "shell --orphan ghostty"; }
{ on = [ "c" "a" "a" ]; run = "plugin compress"; }
];
plugins = { inherit (pkgs.yaziPlugins) compress; };
};
}];
};

View File

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

View File

@@ -34,38 +34,45 @@ inputs:
home.shell.enableZshIntegration = true;
}
{
programs.zsh = inputs.lib.mkIf
(builtins.elem home-inputs.config.home.username [ "chn" "root" "aleksana" "alikia" "hjp" "lilydjwg" ])
programs =
let optional =
inputs.lib.mkIf (builtins.elem home-inputs.config.home.username
[ "chn" "root" "aleksana" "alikia" "hjp" "lilydjwg" ]);
in
{
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
zsh = optional
{
plugins =
[
{
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 = "";
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; };
};
}
];

View File

@@ -473,7 +473,7 @@
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
# Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~|/nix/remote/*'
# Disable the default Git status formatting.
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true

View File

@@ -57,16 +57,24 @@ inputs:
"cron.gc_lfs" = { ENABLED = true; SCHEDULE = "@monthly"; NUMBER_TO_CHECK_PER_REPO = 0; };
};
};
anubis.instances.gitea.settings =
{
OG_PASSTHROUGH = true;
TARGET = "http://127.0.0.1:3002";
BIND_NETWORK = "tcp";
BIND = "127.0.0.1:3003";
WEBMASTER_EMAIL = "chn@chn.moe";
SERVE_ROBOTS_TXT = true;
METRICS_BIND = "/run/anubis/anubis-gitea/anubis-metrics.sock";
};
# prevent AI web crawlers
# https://her.esy.fun/posts/0031-how-i-protect-my-forgejo-instance-from-ai-web-crawlers/index.html
# nginx.virtualHosts."https:${gitea.hostname}".locations."/".extraConfigPre =
# ''
# if ($http_user_agent ~* "git/|git-lfs/") {
# set $bypass_cookie 1;
# }
# if ($cookie_Yogsototh_opens_the_door = "1") {
# set $bypass_cookie 1;
# }
# if ($request_method != "GET") {
# set $bypass_cookie 1;
# }
# if ($bypass_cookie != 1) {
# add_header Content-Type text/html always;
# return 418 '<script>document.cookie = "Yogsototh_opens_the_door=1; Path=/;"; window.location.reload();</script>';
# }
# '';
};
nixos =
{
@@ -78,7 +86,7 @@ inputs:
};
services =
{
nginx.https.${gitea.hostname}.location."/".proxy.upstream = "http://127.0.0.1:3003";
nginx.https.${gitea.hostname}.location."/".proxy.upstream = "http://127.0.0.1:3002";
postgresql.instances.gitea = {};
};
};

View File

@@ -0,0 +1,53 @@
inputs:
{
options.nixos.services.huginn = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
hostname = mkOption { type = types.str; default = "huginn.chn.moe"; };
};});
default = null;
};
config = let inherit (inputs.config.nixos.services) huginn; in inputs.lib.mkIf (huginn != null)
{
virtualisation.oci-containers.containers.huginn =
{
image = "ghcr.io/huginn/huginn:latest";
imageFile = inputs.topInputs.self.src.huginn;
ports = [ "127.0.0.1:3000:3000/tcp" ];
environmentFiles = [ inputs.config.nixos.system.sops.templates."huginn/env".path ];
};
nixos =
{
services =
{
nginx.https.${huginn.hostname}.location."/".proxy = { upstream = "http://127.0.0.1:3000"; websocket = true; };
mariadb.instances.huginn = {};
podman = {};
};
system.sops =
{
templates."huginn/env".content = let inherit (inputs.config.nixos.system.sops) placeholder; in
''
MYSQL_PORT_3306_TCP_ADDR=host.containers.internal
HUGINN_DATABASE_NAME=huginn
HUGINN_DATABASE_USERNAME=huginn
HUGINN_DATABASE_PASSWORD=${placeholder."mariadb/huginn"}
DOMAIN=${huginn.hostname}
RAILS_ENV=production
FORCE_SSL=true
INVITATION_CODE=${placeholder."huginn/invitationCode"}
SMTP_DOMAIN=mail.chn.moe
SMTP_USER_NAME=bot@chn.moe
SMTP_PASSWORD="${placeholder."mail/bot"}"
SMTP_SERVER=mail.chn.moe
SMTP_SSL=true
EMAIL_FROM_ADDRESS=bot@chn.moe
TIMEZONE=Beijing
DO_NOT_CREATE_DATABASE=true
'';
secrets = { "huginn/invitationCode" = {}; "mail/bot" = {}; };
};
};
};
}

View File

@@ -0,0 +1,57 @@
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

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

View File

@@ -69,6 +69,8 @@ inputs:
"bin" "Desktop" "Documents" "Downloads" "Music" "Pictures" "repo" "share" "Public" "Videos" ".config"
".local" ".ecdata" { directory = ".mozilla/firefox/default"; mode = "0700"; } ".steam" ".zotero"
"Zotero" ".thunderbird"
# dms 将剪贴板历史数据和主题的一些设置存放在这里
".cache/dms-clipboard" ".cache/DankMaterialShell"
];
})
# 对于集群的工作节点,挂载一些本来由 home-manager 生成的文件,以及一些用来存放 home-manager 生成文件的目录

View File

@@ -1,6 +1,6 @@
inputs:
{ lib, config, pkgs, ... }:
{
options.nixos.system.fileSystems.mount.nfs = let inherit (inputs.lib) mkOption types; in mkOption
options.nixos.system.fileSystems.mount.nfs = let inherit (lib) mkOption types; in mkOption
{
type = types.attrsOf (types.oneOf
[
@@ -8,50 +8,54 @@ inputs:
(types.submodule (submoduleInputs: { options =
{
mountPoint = mkOption { type = types.nonEmptyStr; };
neededForBoot = mkOption { type = types.bool; default = true; };
mountBeforeSwitch = mkOption { type = types.bool; default = true; };
readOnly = mkOption { type = types.bool; default = !submoduleInputs.config.mountBeforeSwitch; };
};}))
]);
default = {};
};
config =
let inherit (inputs.config.nixos.system.fileSystems.mount) nfs;
in inputs.lib.mkIf (nfs != {}) (inputs.lib.mkMerge
config = let inherit (config.nixos.system.fileSystems.mount) nfs; in lib.mkIf (nfs != {}) (lib.mkMerge
[
{
fileSystems = builtins.listToAttrs (builtins.map
(device:
fileSystems = lib.mapAttrs'
(n: v: lib.nameValuePair (v.mountPoint or v)
{
name = device.value.mountPoint or device.value;
value =
{
device = device.name;
fsType = "nfs4";
neededForBoot = device.value.neededForBoot or true;
options = builtins.concatLists
device = n;
fsType = "nfs4";
neededForBoot = v.mountBeforeSwitch 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
(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" ])
];
};
"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" ])
];
})
(inputs.localLib.attrsToList nfs));
nfs;
systemd.mounts = builtins.map
(mount:
{
where = mount.value.mountPoint or mount.value;
what = mount.name;
overrideStrategy = "asDropin";
mountConfig.ForceUnmount = true;
})
(builtins.filter (mount: mount.value.readOnly or false) (lib.attrsToList nfs));
services.rpcbind.enable = true;
}
(inputs.lib.mkIf (builtins.any (mount: mount.neededForBoot or true) (builtins.attrValues nfs))
(lib.mkIf (builtins.any (mount: mount.mountBeforeSwitch or true) (builtins.attrValues nfs))
{
boot.initrd.systemd.extraBin =
{
"ifconfig" = "${inputs.pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${inputs.pkgs.nfs-utils}/bin/mount.nfs4";
"ifconfig" = "${pkgs.nettools}/bin/ifconfig";
"mount.nfs" = "${pkgs.nfs-utils}/bin/mount.nfs";
"mount.nfs4" = "${pkgs.nfs-utils}/bin/mount.nfs4";
};
nixos.system.initrd.network = {};
})

View File

@@ -4,7 +4,6 @@ inputs:
{
type = types.nullOr (types.submodule { options =
{
timeout = mkOption { type = types.int; default = 15; };
windowsEntries = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
# "efi" using efi, "efiRemovable" using efi with install grub removable, or dev path like "/dev/sda" using bios
installDevice = mkOption { type = types.str; default = "efi"; };
@@ -15,9 +14,13 @@ inputs:
(inputs.lib.mkMerge
[
# general settings
{ boot.loader.grub = { enable = true; useOSProber = false; }; }
# grub timeout
{ boot.loader.timeout = grub.timeout; }
{
boot.loader =
{
grub = { enable = true; useOSProber = false; };
timeout = if inputs.config.nixos.model.type == "desktop" then null else 15;
};
}
# grub install
{
boot.loader =

View File

@@ -39,6 +39,7 @@ inputs:
};
xdg.portal.extraPortals = (builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" "gnome" ]);
qt = { enable = true; platformTheme = "qt5ct"; };
gtk.iconCache.enable = true;
i18n.inputMethod =
{
enable = true;
@@ -70,15 +71,20 @@ inputs:
"Mod+WheelScrollUp" = { action.focus-column-left = {}; cooldown-ms = 50; };
"Mod+Left".action.focus-column-left = {};
"Mod+Right".action.focus-column-right = {};
"Ctrl+Mod+Left".action.move-column-left = {};
"Ctrl+Mod+Right".action.move-column-right = {};
"Mod+Up".action.focus-workspace-up = {};
"Mod+Down".action.focus-workspace-down = {};
"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 = {};
"Mod+F".action.switch-preset-column-width = {};
"Mod+T".action.spawn = [ "ghostty" ];
"Mod+B".action.spawn = [ "firefox" ];
"Mod+Escape".action.power-off-monitors = {};
};
outputs =
{
@@ -91,13 +97,25 @@ inputs:
mode = { width = 3840; height = 2160; refresh = 160.; };
};
};
input = { touchpad.dwt = true; keyboard.numlock = true; };
input =
{
touchpad.dwt = true;
keyboard.numlock = true;
power-key-handling.enable = false;
focus-follows-mouse = { enable = true; max-scroll-amount="10%"; };
};
layout =
{
default-column-width.proportion = 0.5;
preset-column-widths = [ { proportion = 0.33333; } { proportion = 0.5; } { proportion = 0.66667; } ];
preset-column-widths = [ { proportion = 0.5; } { proportion = 1.; } ];
};
spawn-at-startup = [{ argv = [ "Telegram" "-startintray" ]; }];
spawn-at-startup =
[
{ argv = [ "Telegram" "-startintray" ]; }
{ argv = [ "steam" "-silent" ]; }
{ argv = [ "element-desktop" "--hidden" ]; }
{ argv = [ "discord" "--start-minimized" "--no-startup-id" ]; }
];
};
};
})];

View File

@@ -67,6 +67,41 @@ inputs:
patches =
{
btrfs = [(inputs.topInputs.self.src.btrfs.${version} // { name = "btrfs"; })];
asus = builtins.map
(file:
{
name = "asus-${file}";
patch = "${inputs.topInputs.linux-asus}/${file}";
})
[
# copy from PKGBUILD
"0001-platform-x86-asus-wmi-export-symbols-used-for-read-w.patch"
"0002-platform-x86-asus-armoury-move-existing-tunings-to-a.patch"
"0003-platform-x86-asus-armoury-add-panel_hd_mode-attribut.patch"
"0004-platform-x86-asus-armoury-add-apu-mem-control-suppor.patch"
"0005-platform-x86-asus-armoury-add-screen-auto-brightness.patch"
"0006-platform-x86-asus-wmi-deprecate-bios-features.patch"
"0007-platform-x86-asus-wmi-rename-ASUS_WMI_DEVID_PPT_FPPT.patch"
"0008-platform-x86-asus-armoury-add-ppt_-and-nv_-tuning-kn.patch"
"0001-platform-x86-asus-armoury-Fix-error-code-in-mini_led.patch"
"0002-platform-x86-asus-armoury-fix-mini-led-mode-show.patch"
"0003-platform-x86-asus-armoury-add-support-for-FA507UV.patch"
"0001-platform-x86-asus-armoury-fix-only-DC-tunables-being.patch"
"PATCH-v10-00-11-HID-asus-Fix-ASUS-ROG-Laptop-s-Keyboard-backlight-handling.patch"
"PATCH-v10-00-11-HID-asus-Fix-ASUS-ROG-Laptop-s-Keyboard-backlight-handling-id1-id2-pr_err.patch"
"0001-platform-x86-asus-wmi-fix-initializing-TUFs-keyboard.patch"
"0002-platform-x86-asus-armoury-add-keyboard-control-firmw.patch"
"0001-acpi-proc-idle-skip-dummy-wait.patch"
"PATCH-v5-00-11-Improvements-to-S5-power-consumption.patch"
"PATCH-asus-wmi-fixup-screenpad-brightness.patch"
"asus-patch-series.patch"
"0070-acpi-x86-s2idle-Add-ability-to-configure-wakeup-by-A.patch"
"0040-workaround_hardware_decoding_amdgpu.patch"
"0081-amdgpu-adjust_plane_init_off_by_one.patch"
"0084-enable-steam-deck-hdr.patch"
"sys-kernel_arch-sources-g14_files-0047-asus-nb-wmi-Add-tablet_mode_sw-lid-flip.patch"
"sys-kernel_arch-sources-g14_files-0048-asus-nb-wmi-fix-tablet_mode_sw_int.patch"
];
};
in builtins.concatLists (builtins.map (name: patches.${name}) kernel.patches);
};

View File

@@ -13,6 +13,7 @@ inputs:
xmuhk = { host = "xmuhk"; hostname = "10.26.14.64"; user = "xmuhk"; };
xmuhk2 = { host = "xmuhk2"; hostname = "183.233.219.132"; user = "xmuhk"; port = 62022; };
jykang.setEnv.TERM = "chn_unset_ls_colors:chn_cd:linwei/chn:xterm-256color";
wlin.setEnv.TERM = "xterm-256color";
"tinc0.jykang" = jykang;
};
extraConfig = inputs.lib.mkIf inputs.config.nixos.model.private

View File

@@ -41,6 +41,7 @@ inputs:
twr = 1027;
lsp = 1028;
lilydjwg = 1029;
stq = 1030;
misskey-misskey = 2000;
misskey-misskey-old = 2001;
frp = 2002;
@@ -55,6 +56,7 @@ inputs:
hpcstat = 2011;
speedtest = 2012;
tailscale = 2013;
missgram = 2014;
};
};
gid = mkOption

1
modules/user/keys/stq Normal file
View File

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

View File

@@ -13,8 +13,7 @@ endif()
find_package(magic_enum REQUIRED)
find_package(fmt REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process stacktrace_from_exception
stacktrace_backtrace)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process)
find_package(range-v3 REQUIRED)
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
find_package(Eigen3 REQUIRED)
@@ -22,13 +21,14 @@ set(HIGHFIVE_FIND_HDF5 Off)
find_package(HighFive REQUIRED)
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
find_package(HDF5 REQUIRED)
find_package(concurrencpp REQUIRED)
find_path(POCKETFFT_INCLUDE_DIR pocketfft.h REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(glaze REQUIRED)
find_package(cpptrace REQUIRED)
# on static build, cpptrace requires zlib
find_library(ZLIB_LIBRARY NAMES z REQUIRED)
add_library(biu src/common.cpp src/hdf5.cpp src/string.cpp)
target_include_directories(biu PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -36,7 +36,7 @@ target_include_directories(biu PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_D
${LIBBACKTRACE_INCLUDE_DIR} ${POCKETFFT_INCLUDE_DIR})
target_link_libraries(biu PUBLIC magic_enum::magic_enum fmt::fmt Boost::headers Boost::iostreams Boost::filesystem
range-v3::range-v3 Eigen3::Eigen HighFive TgBot::TgBot ${LIBBACKTRACE_LIBRARY} hdf5::hdf5 concurrencpp::concurrencpp
yaml-cpp::yaml-cpp glaze::glaze Boost::process Boost::stacktrace_from_exception Boost::stacktrace_backtrace)
yaml-cpp::yaml-cpp glaze::glaze Boost::process cpptrace::cpptrace ${ZLIB_LIBRARY})
target_compile_features(biu PUBLIC cxx_std_23)
target_compile_options(biu PUBLIC -Wno-gnu-string-literal-operator-template)
install(TARGETS biu EXPORT biuTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@@ -1,18 +1,16 @@
include("${CMAKE_CURRENT_LIST_DIR}/biuTargets.cmake")
find_package(magic_enum REQUIRED)
find_package(fmt REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process stacktrace_from_exception
stacktrace_backtrace)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system process)
find_package(range-v3 REQUIRED)
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(HighFive REQUIRED)
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
find_package(HDF5 REQUIRED)
find_package(concurrencpp REQUIRED)
find_path(POCKETFFT_INCLUDE_DIR pocketfft.h REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(glaze REQUIRED)
find_package(cpptrace REQUIRED)

View File

@@ -1,7 +1,7 @@
{
stdenv, cmake, lib,
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits, highfive, tgbot-cpp, libbacktrace, hdf5, concurrencpp,
pocketfft, yaml-cpp, glaze
pocketfft, yaml-cpp, glaze, cpptrace
}: stdenv.mkDerivation rec
{
name = "biu";
@@ -10,6 +10,7 @@
[
magic-enum fmt boost range-v3 nameof zpp-bits eigen libbacktrace hdf5
concurrencpp pocketfft yaml-cpp glaze (highfive.override { inherit boost; }) (tgbot-cpp.override { inherit boost; })
cpptrace
];
propagatedBuildInputs = buildInputs;
nativeBuildInputs = [ cmake ];

View File

@@ -19,7 +19,7 @@ namespace biu
namespace common
{
std::size_t hash(auto&&... objs);
[[gnu::always_inline]] void unused(auto&&...);
[[gnu::always_inline]] inline void unused(auto&&...);
[[noreturn]] void block_forever();
bool is_interactive();

View File

@@ -1,7 +1,5 @@
# pragma once
# include <map>
# define BOOST_STACKTRACE_USE_BACKTRACE
# include <boost/stacktrace.hpp>
# include <biu/atomic.hpp>
namespace biu
@@ -43,25 +41,16 @@ namespace biu
protected: const std::chrono::time_point<std::chrono::steady_clock> CreateTime_;
// call log<Debug>("create {type} at {address}.");
protected: [[gnu::always_inline]] ObjectMonitor();
protected: [[gnu::noinline]] inline ObjectMonitor();
// call log<Debug>("destroy {type} at {address} after {duration} ms.");
protected: [[gnu::always_inline]] virtual ~ObjectMonitor();
protected: [[gnu::noinline]] inline virtual ~ObjectMonitor();
};
template <typename T> friend class ObjectMonitor;
// List of objects that is being monitored by ObjectMonitor, {address, type}
protected: static Atomic<std::multimap<const void*, std::string_view>> Objects_;
public: template <typename FinalException> class Exception : public std::exception
{
protected: const std::string Message_;
protected: const boost::stacktrace::stacktrace Stacktrace_;
public: explicit Exception(const std::string& message);
public: const char* what() const noexcept final {return Message_.c_str();}
};
public: template <typename Function> static void try_exec(Function&& function);
// Monitor the start and end of a function, as well as corresponding thread.
@@ -76,30 +65,26 @@ namespace biu
// if sizeof...(Param) > 0, call log<Debug>("begin function with {arguments}.");
// else call log<Debug>("begin function.");
public: template <typename... Param> [[gnu::always_inline]] explicit Guard(Param&&... param);
public: template <typename... Param> explicit Guard(Param&&... param);
// call log<Debug>("end function after {duration} ms.")
public: [[gnu::always_inline]] inline virtual ~Guard();
public: [[gnu::noinline]] inline virtual ~Guard();
// call log<Debug>("reached after {duration} ms.")
public: [[gnu::always_inline]] inline void operator()() const;
public: [[gnu::noinline]] inline void operator()() const;
// call log<Debug>("return {return} after {duration} ms.")
public: template <typename T> [[gnu::always_inline]] T rtn(T&& value) const;
public: template <typename T> [[gnu::noinline]] T rtn(T&& value) const;
// print the following message if LoggerConfig_ is set and the level is higher than the level of the
// LoggerConfig_
// [ {time} {thread} {indent} {filename}:{line} {function_name} ] {message}
public: template <Level L> [[gnu::always_inline]] void log(const std::string& message) const;
public: [[gnu::always_inline]] inline void error(const std::string& message) const;
public: [[gnu::always_inline]] inline void info(const std::string& message) const;
public: [[gnu::always_inline]] inline void debug(const std::string& message) const;
public: [[gnu::always_inline]] inline void print_exception
(
std::optional<std::pair<std::string, std::string>> type_and_message,
const boost::stacktrace::stacktrace& stacktrace
) const;
// All directly called log functions should not be inlined to ensure correct stacktrace information
// all not directly called log functions should be inlined to align stacktrace depth (always 1)
protected: template <Level L> [[gnu::noinline]] void log_(const std::string& message) const;
public: [[gnu::noinline]] inline void error(const std::string& message) const;
public: [[gnu::noinline]] inline void info(const std::string& message) const;
public: [[gnu::noinline]] inline void debug(const std::string& message) const;
};
friend class Guard;

View File

@@ -5,6 +5,8 @@
# include <biu/common.hpp>
# include <biu/format.hpp>
# include <boost/exception/diagnostic_information.hpp>
# include <cpptrace/cpptrace.hpp>
# include <cpptrace/from_current.hpp>
namespace biu
{
@@ -44,12 +46,12 @@ namespace biu
{
Guard guard;
Objects_.lock()->emplace(this, nameof::nameof_full_type<T>());
guard.debug("create {} at {}."_f(nameof::nameof_full_type<T>(), fmt::ptr(this)));
guard.log_<Level::Debug>("create {} at {}."_f(nameof::nameof_full_type<T>(), fmt::ptr(this)));
}
template <typename T> Logger::ObjectMonitor<T>::~ObjectMonitor()
{
Guard guard;
guard.log<Level::Debug>("destroy {} at {} after {} ms."_f
guard.log_<Level::Debug>("destroy {} at {} after {} ms."_f
(
nameof::nameof_full_type<T>(), fmt::ptr(this),
std::chrono::duration_cast<std::chrono::milliseconds>
@@ -63,13 +65,6 @@ namespace biu
}
inline Atomic<std::multimap<const void*, std::string_view>> Logger::Objects_;
template <typename FinalException> Logger::Exception<FinalException>::Exception(const std::string& message)
{
Logger::Guard log(message);
log.print_exception
(std::pair<std::string, std::string>(nameof::nameof_full_type<FinalException>(), message), Stacktrace_);
}
template <typename Function> inline void Logger::try_exec(Function&& function)
{
Logger::Guard log;
@@ -77,8 +72,12 @@ namespace biu
catch (...)
{
log.error(boost::current_exception_diagnostic_information());
log.print_exception
(std::nullopt, boost::stacktrace::stacktrace::from_current_exception());
if (auto&& lock = LoggerConfig_.lock(); lock->Level >= Logger::Level::Error)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
cpptrace::from_current_exception().print(*lock->Stream);
*lock->Stream << std::flush;
}
}
}
@@ -103,13 +102,13 @@ namespace biu
else return "({})"_f(nameof::nameof_full_type<T>());
};
if constexpr (sizeof...(Param) > 0)
debug("begin function with {{{}}}."_f(fmt::join({try_format(std::forward<Param>(param))...}, ", ")));
else debug("begin function.");
log_<Level::Debug>("begin function with {{{}}}."_f(fmt::join({try_format(std::forward<Param>(param))...}, ", ")));
else log_<Level::Debug>("begin function.");
}
Logger::Guard::~Guard()
{
debug("end function after {} ms."_f(get_time_ms()));
log_<Level::Debug>("end function after {} ms."_f(get_time_ms()));
Indent_--;
auto&& lock = Threads_.lock();
if (auto thread_id = get_thread_id(); lock->contains(thread_id))
@@ -117,20 +116,20 @@ namespace biu
else [[unlikely]]
error("{:08x} not found in Logger::Threads."_f(thread_id % std::numeric_limits<std::uint64_t>::max()));
}
void Logger::Guard::operator()() const { debug("reached after {} ms."_f(get_time_ms())); }
template <Logger::Level L> void Logger::Guard::log(const std::string& message) const
void Logger::Guard::operator()() const { log_<Level::Debug>("reached after {} ms."_f(get_time_ms())); }
template <Logger::Level L> void Logger::Guard::log_(const std::string& message) const
{
if (auto&& lock = LoggerConfig_.lock(); lock->Level >= L)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
auto time = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
boost::stacktrace::stacktrace stack;
auto frame = cpptrace::stacktrace::current(2, 1).frames[0];
# ifdef BIU_LOGGER_SOURCE_ROOT
auto source_root = std::string_view(BIU_LOGGER_SOURCE_ROOT "/");
auto source_file = stack[0].source_file().starts_with(source_root) ?
stack[0].source_file().substr(source_root.size()) : stack[0].source_file();
auto source_file = frame.filename.starts_with(source_root) ?
frame.filename.substr(source_root.size()) : frame.filename;
# else
auto source_file = stack[0].source_file();
auto source_file = frame.filename;
# endif
*lock->Stream << "[ {:%T} {:02x} {:02} ] {} (at {}:{} {} )\n"_f
(
@@ -139,41 +138,20 @@ namespace biu
Indent_,
message,
source_file.empty() ? "??"s : source_file,
stack[0].source_line() == 0 ? "??"s : "{}"_f(stack[0].source_line()),
stack[0].name()
frame.line.has_value() ? "{}"_f(frame.line.value()) : "??"s,
frame.symbol
) << std::flush;
}
}
void Logger::Guard::error(const std::string& message) const { log<Level::Error>(message); }
void Logger::Guard::info(const std::string& message) const { log<Level::Info>(message); }
void Logger::Guard::debug(const std::string& message) const { log<Level::Debug>(message); }
void Logger::Guard::error(const std::string& message) const { log_<Level::Error>(message); }
void Logger::Guard::info(const std::string& message) const { log_<Level::Info>(message); }
void Logger::Guard::debug(const std::string& message) const { log_<Level::Debug>(message); }
template <typename T> inline T Logger::Guard::rtn(T&& value) const
template <typename T> T Logger::Guard::rtn(T&& value) const
{
debug("return {} after {} ms."_f(std::forward<T>(value), get_time_ms()));
log_<Level::Debug>("return {} after {} ms."_f(std::forward<T>(value), get_time_ms()));
return std::forward<T>(value);
}
inline void Logger::Guard::print_exception
(
std::optional<std::pair<std::string, std::string>> type_and_message,
const boost::stacktrace::stacktrace& stacktrace
) const
{
if (type_and_message) log<Level::Error>("{}: {}"_f(type_and_message->first, type_and_message->second));
if (auto&& lock = LoggerConfig_.lock(); lock->Level >= Logger::Level::Error)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
for (auto frame : stacktrace)
*lock->Stream << "\tfrom {}:{} {}\n"_f
(
frame.source_file().empty() ? "??"s : frame.source_file(),
frame.source_line() == 0 ? "??"s : "{}"_f(frame.source_line()),
frame.name()
);
*lock->Stream << std::flush;
}
}
inline Atomic<std::map<std::size_t, std::size_t>> Logger::Threads_;
}

View File

@@ -2,4 +2,6 @@
int main()
{
biu::Logger::Guard log("test", nullptr, std::ofstream());
log.info("hello world");
return 0;
}

1
packages/chn-bsub/.envrc Normal file
View File

@@ -0,0 +1 @@
use flake .#chn-bsub

View File

@@ -10,14 +10,14 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()
find_package(ftxui REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem iostreams)
find_package(range-v3 REQUIRED)
find_package(biu REQUIRED)
add_executable(chn-bsub src/main.cpp)
target_compile_features(chn-bsub PUBLIC cxx_std_23)
target_link_libraries(chn-bsub PRIVATE fmt::fmt ftxui::screen ftxui::dom ftxui::component Boost::filesystem
range-v3::range-v3 biu::biu)
target_link_libraries(chn-bsub PRIVATE ftxui::screen ftxui::dom ftxui::component biu::biu)
if(BSUB_CONFIG)
target_compile_definitions(chn-bsub PRIVATE BSUB_CONFIG="${BSUB_CONFIG}")
endif()
install(TARGETS chn-bsub RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

View File

@@ -0,0 +1,2 @@
normal: [ 4, 4, 20 ]
normal_1day: [ 4, 7, 28 ]

View File

@@ -1,8 +1,10 @@
{ stdenv, lib, cmake, pkg-config, ftxui, biu }: stdenv.mkDerivation
{ stdenv, cmake, pkg-config, ftxui, biu, bsubConfig ? null, lib }: stdenv.mkDerivation
{
name = "chn-bsub";
src = ./.;
buildInputs = [ ftxui biu ];
nativeBuildInputs = [ cmake pkg-config ];
postInstall = "ln -s chn-bsub $out/bin/chn_bsub";
cmakeFlags = lib.optional (bsubConfig != null) [ "-DBSUB_CONFIG=${bsubConfig}" ];
passthru = { inherit bsubConfig; };
}

View File

@@ -1,202 +1,177 @@
# include <map>
# include <filesystem>
# include <biu.hpp>
# include <ftxui/component/component.hpp>
# include <ftxui/component/component_options.hpp>
# include <ftxui/component/screen_interactive.hpp>
# include <boost/process.hpp>
# include <boost/algorithm/string.hpp>
# include <biu.hpp>
# ifndef BSUB_CONFIG
# define BSUB_CONFIG "./bsub.yaml"
# endif
using namespace biu::literals;
int main()
{
// 需要绑定到界面上的变量
struct
{
std::array<int, 3> vasp_version_selected = {0, 0, 0};
std::vector<std::string> vasp_version_entries_level1 = {"640", "631"};
std::map<std::string, std::vector<std::string>> vasp_version_entries_level2 =
biu::Logger::Guard log;
enum class UserCommandType { Continue, Back, Quit };
enum class InterfaceType { Request, Confirm };
struct
{
std::optional<UserCommandType> UserCommand;
std::string SubmitCommand;
InterfaceType CurrentInterface = InterfaceType::Request;
int VaspSelected = 0;
std::vector<std::string> VaspEntries = { "std", "gam", "ncl" };
int QueueSelected = 0;
std::vector<std::string> QueueEntries;
std::string JobName = []
{
{"640", {"(default)", "fixc", "optcell_vtst_wannier90", "shmem", "vtst"}},
{"631", {"shmem"}}
};
std::vector<std::string> vasp_version_entries_level3 = {"std", "gam", "ncl"};
int queue_selected = 0;
std::vector<std::string> queue_entries =
{
"normal_1day", "normal_1week", "normal",
"normal_1day_new", "ocean_530_1day", "ocean6226R_1day"
};
std::map<std::string, std::size_t> max_cores =
{
{"normal_1day", 28}, {"normal_1week", 28}, {"normal", 20},
{"normal_1day_new", 24}, {"ocean_530_1day", 24}, {"ocean6226R_1day", 32}
};
std::string ncores = "";
std::string job_name = []
{
// /data/gpfs01/jykang/linwei/chn/lammps-SiC
// /data/gpfs01/wlin/chn/lammps-SiC
std::vector<std::string> paths;
boost::split(paths, std::filesystem::current_path().string(),
boost::is_any_of("/"));
if (paths.size() < 7)
return "my-great-job"s;
else
return paths[5] + "_" + paths.back();
boost::split(paths, std::filesystem::current_path().string(), boost::is_any_of("/"));
if (paths.size() < 6) return "my-great-job"s;
else return paths[4] + "_" + paths.back();
}();
std::string bsub = "";
std::string user_command = "";
} state;
std::string OutputFile = "output.txt";
} State;
std::map<std::string, std::array<int, 3>> QueueConfig =
YAML::LoadFile(BSUB_CONFIG).as<decltype(QueueConfig)>();
State.QueueEntries = QueueConfig
| ranges::views::transform([](auto const& item) { return item.first; })
| ranges::to_vector;
// 为组件增加标题栏
auto component_with_title = [](std::string title, ftxui::Component component)
{
return ftxui::Renderer(component, [title, component]
{
return ftxui::vbox
({
ftxui::text(title) | ftxui::bgcolor(ftxui::Color::Blue),
component->Render(),
ftxui::separator()
});
});
};
// 为组件增加标题栏
auto with_title = [](std::string title, ftxui::Color bgcolor = ftxui::Color::Blue)
{
return [=](ftxui::Element element)
{ return ftxui::vbox(ftxui::text(title) | ftxui::bgcolor(bgcolor), element); };
};
// 为组件增加下边框
auto with_bottom = [](ftxui::Element element)
{ return ftxui::vbox(element, ftxui::separatorLight()); };
// 为组件增加比较粗的下边框
auto with_bottom_heavy = [](ftxui::Element element)
{ return ftxui::vbox(element, ftxui::separatorHeavy()); };
// 在组件左边增加小标题
auto with_subtitle = [](std::string title)
{ return [title](ftxui::Element element) { return ftxui::hbox(ftxui::text(title), element); }; };
// 带标题的文本输入框
auto input = [with_subtitle](std::string* content, std::string title)
{
return ftxui::Input(content) | ftxui::underlined
| ftxui::size(ftxui::WIDTH, ftxui::GREATER_THAN, 3)
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 1)
| with_subtitle(title);
};
// 在组件左边增加分割线
auto with_separator = [](ftxui::Element element)
{ return ftxui::hbox(ftxui::separatorLight(), element); };
// 为组件增加空白以填充界面
auto with_padding = [](ftxui::Element element)
{
auto empty = ftxui::emptyElement() | ftxui::flex_grow;
return ftxui::vbox(empty, ftxui::hbox(empty, element | ftxui::center, empty), empty);
};
// 转义字符
auto escape = [](std::string str)
{
return str | ranges::views::transform([](char c)
{
// only the following characters need to be escaped: $ ` \ " newline * @ space tab
if (std::set{'$', '`', '\\', '\"', '\n', '*', '@', ' ', '\t'}.contains(c))
return '\\' + std::string(1, c);
else return std::string(1, c);
}) | ranges::views::join("") | ranges::to<std::string>;
};
// 构建界面, 需要至少 25 行 47 列
auto screen = ftxui::ScreenInteractive::Fullscreen();
auto request_interface = [&state, &screen, &component_with_title]
{
auto vasp_version_level1 = ftxui::Menu
(&state.vasp_version_entries_level1, &state.vasp_version_selected[0])
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 8);
std::vector<ftxui::Component> vasp_version_level2_children;
for (auto& i : state.vasp_version_entries_level1)
vasp_version_level2_children.push_back(ftxui::Menu
(
&state.vasp_version_entries_level2[i],
&state.vasp_version_selected[1]
));
auto vasp_version_level2 = ftxui::Container::Tab
(
vasp_version_level2_children,
&state.vasp_version_selected[0]
) | ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 27);
auto vasp_version_level3 = ftxui::Menu
(&state.vasp_version_entries_level3, &state.vasp_version_selected[2])
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 8);
auto vasp_version = component_with_title("Select vasp version:",
ftxui::Container::Horizontal
({vasp_version_level1, vasp_version_level2, vasp_version_level3})
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 5));
auto queue = component_with_title("Select queue:",
ftxui::Menu(&state.queue_entries, &state.queue_selected)
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 6));
auto ncores = component_with_title("Input cores you want to use:",
ftxui::Input(&state.ncores, "(leave blank to use all cores)"))
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 3);
auto job_name = component_with_title("Job name:",
ftxui::Input(&state.job_name, ""))
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 3);
auto continue_button = ftxui::Button("Continue",
[&]{state.user_command = "continue"; screen.ExitLoopClosure()();});
auto quit_button = ftxui::Button("Quit",
[&]{state.user_command = "quit"; screen.ExitLoopClosure()();});
return ftxui::Container::Vertical
// 构建界面
auto Screen = ftxui::ScreenInteractive::Fullscreen();
auto key_event_handler = [&](ftxui::Event event)
{
if (event == ftxui::Event::Return)
{ State.UserCommand = UserCommandType::Continue; Screen.ExitLoopClosure()(); return true; }
else return false;
};
auto InterfaceRequest = ftxui::Container::Vertical
({
ftxui::Container::Horizontal
({
vasp_version, queue, ncores, job_name,
ftxui::Container::Horizontal({continue_button, quit_button})
}) | ftxui::borderHeavy
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 47)
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 24);
}();
auto confirm_interface = [&state, &screen, &component_with_title]
{
ftxui::InputOption input_option;
input_option.multiline = true;
return ftxui::Container::Vertical
ftxui::Menu(&State.VaspEntries, &State.VaspSelected) | with_title("VASP variant:"),
ftxui::Menu(&State.QueueEntries, &State.QueueSelected)
| with_title("Queue:") | with_separator
}) | with_bottom_heavy,
input(&State.JobName, "Job name: "),
input(&State.OutputFile, "Output file: "),
// 操作按钮
ftxui::Container::Horizontal
({
component_with_title
(
"Double check & modify submit command:",
ftxui::Input(&state.bsub, "", input_option)
)
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 7),
ftxui::Container::Horizontal
({
ftxui::Button("Submit",
[&]{state.user_command = "submit"; screen.ExitLoopClosure()();}),
ftxui::Button("Quit",
[&]{state.user_command = "quit"; screen.ExitLoopClosure()();}),
ftxui::Button("Back",
[&]{state.user_command = "back"; screen.ExitLoopClosure()();})
}),
ftxui::Renderer([]{return ftxui::vbox
({
ftxui::separator(),
ftxui::text("Source code:"),
ftxui::text("https://github.com/CHN-beta/chn_bsub.git"),
ftxui::text("Star & PR are welcome!"),
});})
}) | ftxui::borderHeavy
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 47)
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 14);
}();
ftxui::Button("Continue (Enter)",
[&]{ State.UserCommand = UserCommandType::Continue; Screen.ExitLoopClosure()(); }),
ftxui::Button("Quit",
[&]{ State.UserCommand = UserCommandType::Quit; Screen.ExitLoopClosure()(); })
}),
}) | ftxui::borderHeavy | with_padding | ftxui::CatchEvent(key_event_handler);
auto InterfaceConfirm = ftxui::Container::Vertical
({
ftxui::Input(&State.SubmitCommand, "", ftxui::InputOption{.multiline = true})
| with_title("Double check & modify submit command:") | with_bottom_heavy,
ftxui::Container::Horizontal
({
ftxui::Button("Submit (Enter)",
[&]{State.UserCommand = UserCommandType::Continue; Screen.ExitLoopClosure()();}),
ftxui::Button("Back",
[&]{State.UserCommand = UserCommandType::Back; Screen.ExitLoopClosure()();}),
ftxui::Button("Quit",
[&]{State.UserCommand = UserCommandType::Quit; Screen.ExitLoopClosure()();})
})
}) | ftxui::borderHeavy | with_padding | ftxui::CatchEvent(key_event_handler);
// 实际投递任务
auto submit = [](std::string bsub)
{
// replace \n with space
boost::replace_all(bsub, "\n", " ");
auto process = boost::process::child
(
boost::process::search_path("sh"), "-c", bsub,
boost::process::std_in.close(),
boost::process::std_out > stdout,
boost::process::std_err > stderr
);
process.wait();
};
// 进入事件循环
while (true)
{
screen.Loop(request_interface);
if (state.user_command == "quit")
return EXIT_FAILURE;
else if (state.user_command != "continue")
throw std::runtime_error("user_command is not recognized");
state.bsub = fmt::format
(
"bsub -J '{}'\n-q {}\n-n {}\n-R 'span[hosts=1]'\n-o 'output.txt'\nchn_vasp.sh {}",
state.job_name,
state.queue_entries[state.queue_selected],
state.ncores.empty() ? state.max_cores[state.queue_entries[state.queue_selected]] :
std::stoi(state.ncores),
[&]
{
auto version_level1 = state.vasp_version_entries_level1[state.vasp_version_selected[0]];
auto version_level2 = state.vasp_version_entries_level2[version_level1]
[state.vasp_version_selected[1]];
auto version_level3 = state.vasp_version_entries_level3[state.vasp_version_selected[2]];
return fmt::format
(
"{}{}_{}",
version_level1,
version_level2 == "(default)" ? ""s : "_" + version_level2,
version_level3
);
}()
);
screen.Loop(confirm_interface);
if (state.user_command == "quit")
return EXIT_FAILURE;
else if (state.user_command == "back")
continue;
else if (state.user_command != "submit")
throw std::runtime_error("user_command is not recognized");
submit(state.bsub);
break;
}
// 进入事件循环
while (true)
{
if (State.CurrentInterface == InterfaceType::Request)
{
State.UserCommand.reset();
Screen.Loop(InterfaceRequest);
if (State.UserCommand == UserCommandType::Quit) return 0;
else if (State.UserCommand == UserCommandType::Continue)
{
State.CurrentInterface = InterfaceType::Confirm;
State.SubmitCommand = [&]
{
auto [nproc, nthr, ncpu] = QueueConfig.at(State.QueueEntries[State.QueueSelected]);
auto args = std::vector<std::string>
{
"bsub",
"-J {} -o {}"_f(escape(State.JobName), escape(State.OutputFile)),
"-q {} -n {} -R 'span[hosts=1]'"_f(escape(State.QueueEntries[State.QueueSelected]), ncpu),
"vasp-intel mpirun -n {} -x OMP_NUM_THREADS={} vasp-{}"_f
(nproc, nthr, State.VaspEntries[State.VaspSelected])
};
return args | ranges::views::join(" \\\n ") | ranges::to<std::string>;
}();
}
else if (!State.UserCommand) return EXIT_FAILURE;
else std::unreachable();
}
else if (State.CurrentInterface == InterfaceType::Confirm)
{
State.UserCommand.reset();
Screen.Loop(InterfaceConfirm);
if (State.UserCommand == UserCommandType::Quit) return 0;
else if (State.UserCommand == UserCommandType::Back) { State.CurrentInterface = InterfaceType::Request; }
else if (State.UserCommand == UserCommandType::Continue)
{
// 提交任务
log.debug("submit command: {}"_f(State.SubmitCommand));
// -c 对 \\n 的处理与通常情况下不同,我们需要用 -s 然后将命令通过标准输入传入
biu::exec<{.SearchPath = true, .Stdin = biu::IoType::String}>
({.Program = "sh", .Args = { "-s"}, .Stdin = State.SubmitCommand});
break;
}
else if (!State.UserCommand) return EXIT_FAILURE;
else std::unreachable();
}
}
}

View File

@@ -14,11 +14,7 @@ inputs: rec
};
v-sim = inputs.pkgs.callPackage ./v-sim.nix { src = inputs.topInputs.v-sim; };
concurrencpp = inputs.pkgs.callPackage ./concurrencpp.nix { src = inputs.topInputs.concurrencpp; };
matplotplusplus = inputs.pkgs.callPackage ./matplotplusplus.nix
{
src = inputs.topInputs.matplotplusplus;
stdenv = inputs.pkgs.clang18Stdenv;
};
matplotplusplus = inputs.pkgs.callPackage ./matplotplusplus.nix { src = inputs.topInputs.matplotplusplus; };
zpp-bits = inputs.pkgs.callPackage ./zpp-bits.nix { src = inputs.topInputs.zpp-bits; };
nameof = inputs.pkgs.callPackage ./nameof.nix { src = inputs.topInputs.nameof; };
pslist = inputs.pkgs.callPackage ./pslist.nix { src = inputs.topInputs.self.src.pslist; };
@@ -67,9 +63,7 @@ inputs: rec
inherit nameof zpp-bits tgbot-cpp concurrencpp pocketfft;
# TODO: report glaze bug to upstream
inherit (inputs.pkgs.pkgs-2411) glaze;
stdenv = inputs.pkgs.clang18Stdenv;
boost = (inputs.pkgs.boost188.override { extraB2Args = [ "boost.stacktrace.backtrace=on" ]; }).overrideAttrs
(prev: { buildInputs = prev.buildInputs ++ [(inputs.pkgs.libbacktrace.override { enableStatic = true; })]; });
boost = inputs.pkgs.boost188;
fmt = inputs.pkgs.fmt_11.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./biu/fmt.patch ]; });
};
hpcstat = inputs.pkgs.callPackage ./hpcstat
@@ -77,13 +71,8 @@ inputs: rec
openxlsx = inputs.pkgs.callPackage ./openxlsx.nix { src = inputs.topInputs.openxlsx; };
sqlite-orm = inputs.pkgs.callPackage ./sqlite-orm.nix { src = inputs.topInputs.sqlite-orm; };
mkPnpmPackage = inputs.pkgs.callPackage ./mkPnpmPackage.nix {};
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
ufo = inputs.pkgs.callPackage inputs.topInputs.ufo
{
inherit biu matplotplusplus;
tbb = inputs.pkgs.tbb_2022;
stdenv = inputs.pkgs.clang18Stdenv;
};
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; };
ufo = inputs.pkgs.callPackage inputs.topInputs.ufo { inherit biu matplotplusplus; tbb = inputs.pkgs.tbb_2022; };
chn-bsub = inputs.pkgs.callPackage ./chn-bsub { inherit biu; };
py4vasp = inputs.pkgs.python3Packages.callPackage ./py4vasp.nix { src = inputs.topInputs.py4vasp; };
pocketfft = inputs.pkgs.callPackage ./pocketfft.nix { src = inputs.topInputs.pocketfft; };
@@ -112,14 +101,14 @@ inputs: rec
];
};
stickerpicker = inputs.pkgs.python3Packages.callPackage ./stickerpicker.nix { src = inputs.topInputs.stickerpicker; };
info = inputs.pkgs.callPackage ./info { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
info = inputs.pkgs.callPackage ./info { inherit biu; };
blog = inputs.pkgs.callPackage inputs.topInputs.blog
{
inherit (inputs.topInputs) hextra;
buildProxy = inputs.pkgs.lib.mkBuildproxy ./blog-buildproxy.nix;
};
phono3py = inputs.pkgs.python3Packages.callPackage ./phono3py.nix { src = inputs.topInputs.phono3py; };
vm = inputs.pkgs.callPackage ./vm { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
vm = inputs.pkgs.callPackage ./vm { inherit biu; };
oneapiPackages = inputs.pkgs.lib.makeScope inputs.pkgs.newScope (final:
{
stdenv = inputs.pkgs.callPackage ./oneapi/stdenv.nix { src = inputs.topInputs.self.src.oneapi; inherit gccFull; };
@@ -137,13 +126,17 @@ inputs: rec
speedtest = inputs.pkgs.callPackage ./speedtest.nix { src = inputs.topInputs.speedtest; };
atat = inputs.pkgs.callPackage ./atat.nix { src = inputs.topInputs.self.src.atat; };
atomkit = inputs.pkgs.callPackage ./atomkit.nix { src = inputs.topInputs.self.src.atomkit; };
xinli = inputs.pkgs.callPackage ./xinli { inherit biu; stdenv = inputs.pkgs.clang18Stdenv; };
xinli = inputs.pkgs.callPackage ./xinli { inherit biu; };
pybinding = inputs.pkgs.pkgs-2411.python310Packages.callPackage ./pybinding
{
src = inputs.topInputs.pybinding;
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; };
sqlgen = inputs.pkgs.callPackage ./sqlgen.nix { src = inputs.topInputs.sqlgen; inherit reflectcpp; };
reflectcpp = inputs.pkgs.callPackage ./reflectcpp.nix { src = inputs.topInputs.reflectcpp; };
lsf = inputs.pkgs.callPackage ./lsf.nix { src = inputs.topInputs.self.src.lsf; };
fromYaml = content: builtins.fromJSON (builtins.readFile
(inputs.pkgs.runCommand "toJSON" {}

View File

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

View File

@@ -18,6 +18,7 @@ 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" } },

18
packages/lsf.nix Normal file
View File

@@ -0,0 +1,18 @@
{ stdenv, src, autoPatchelfHook, libz }: stdenv.mkDerivation rec
{
name = "lsf";
inherit src;
dontConfigure = true;
dontBuild = true;
buildInputs = [ stdenv.cc.cc libz ];
nativeBuildInputs = [ autoPatchelfHook ];
autoPatchelfIgnoreMissingDeps = [ "libnvidia-ml.so.1" ];
installPhase =
''
runHook preInstall
mkdir -p $out
cp -r * $out
rm $out/lib/{hwloc_nvml,sec_ego_kerberos,sec_ego_gsskrb,sec_ego_pam_default}.so
runHook postInstall
'';
}

1
packages/missgram/.envrc Normal file
View File

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

1
packages/missgram/.gitignore vendored Normal file
View File

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

View File

@@ -0,0 +1,39 @@
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)
find_package(nlohmann_json 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 nlohmann_json::nlohmann_json)
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})
add_executable(tg-test EXCLUDE_FROM_ALL src/tg.cpp src/tg-test.cpp)
target_include_directories(tg-test PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(tg-test PRIVATE biu::biu httplib::httplib nlohmann_json::nlohmann_json)
target_compile_features(tg-test PRIVATE cxx_std_23)
if(DEFINED MISSGRAM_CONFIG_FILE)
target_compile_definitions(tg-test PRIVATE MISSGRAM_CONFIG_FILE="${MISSGRAM_CONFIG_FILE}")
endif()
target_compile_definitions(tg-test PRIVATE BIU_LOGGER_SOURCE_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
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

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

View File

@@ -0,0 +1,19 @@
# 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 name, url, type; bool isSensitive; };
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

@@ -0,0 +1,23 @@
# 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

@@ -0,0 +1,100 @@
# 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;
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.value_or("");
// 如果有引用,则需要查找被引用的帖子是否已经被转发过,若是则直接回复被转发的消息。
// 如果没有被转发过,则在开头附上链接
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);
}
// 异步发送消息
std::thread([text, note_id = content.body.note->id, reply_id,
files = content.body.note->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

@@ -0,0 +1,25 @@
# include <missgram.hpp>
# 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>();
// tg_send("aaaa", std::nullopt, {});
// tg_send("aaaa", std::nullopt, {{"IMG20241013173523.jpg", "https://xn--s8w913fdga.chn.moe/files/3dd41113-4df5-4f34-a825-e4137d146172", "image/jpeg", false}});
tg_send("aaaa", std::nullopt,
{
{"2026-01-07 22-02-22 1.png", "https://xn--s8w913fdga.chn.moe/files/a23d13ea-de37-4907-9d54-66417d7e0e36", "image/png", false}
});
// tg_send("aaaa", std::nullopt,
// {
// {"IMG20241013173523.jpg", "https://xn--s8w913fdga.chn.moe/files/// 3dd41113-4df5-4f34-a825-e4137d146172", "image/jpeg", true},
// {"2026-01-07 22-02-22 1.png", "https://xn--s8w913fdga.chn.moe/files/// a23d13ea-de37-4907-9d54-66417d7e0e36", "image/png", false}
// });
}

View File

@@ -0,0 +1,127 @@
# include <missgram.hpp>
# include <httplib.h>
# include <nlohmann/json.hpp>
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;
// 多次尝试运行函数直到成功或达到最大尝试次数5次
auto try_run = [&](auto&& func) -> std::optional<decltype(func())>
{
auto retry_delay = 1s;
int attempts = 0;
while (attempts < 5)
{
std::optional<decltype(func())> result;
biu::Logger::try_exec([&] { result = func(); });
if (result) return result;
std::this_thread::sleep_for(retry_delay);
retry_delay *= 2;
attempts++;
}
return {};
};
// 下载一个 https 资源到内存
auto download = [&](const std::string& url) -> std::string
{
std::regex https_regex(R"(https://([^/]+)(/.+))");
std::smatch match;
if (!std::regex_match(url, match, https_regex))
throw std::runtime_error("Only https URLs are supported");
httplib::SSLClient cli(match[1].str());
auto res = cli.Get(match[2].str());
if (res && res->status == 200) return res->body;
else throw std::runtime_error("Failed to download file from " + url);
};
// 下载要发送的文件
std::vector<std::string> file_contents;
for (const auto& file : files)
{
auto content = try_run([&] { return download(file.url); });
if (!content) throw std::runtime_error("Failed to download file from " + file.url);
file_contents.push_back(std::move(*content));
}
// 准备要发送的请求
httplib::UploadFormDataItems items;
std::string method;
if (files.empty())
{
method = "sendMessage";
items.push_back({"text", text});
items.push_back({"parse_mode", "Markdown"});
items.push_back({"link_preview_options",
[]{ nlohmann::json j; j["is_disabled"] = true; return j.dump(); }()});
}
else if (files.size() == 1)
{
auto is_photo = files[0].type.starts_with("image/");
method = is_photo ? "sendPhoto" : "sendDocument";
items.push_back
({
is_photo ? "photo" : "document",
file_contents[0], files[0].name, files[0].type
});
items.push_back({"caption", text});
items.push_back({"parse_mode", "Markdown"});
if (is_photo && files[0].isSensitive) items.push_back({"has_spoiler", "True"});
}
else
{
method = "sendMediaGroup";
auto all_photo = ranges::all_of(files,
[](auto&& file) { return file.type.starts_with("image/"); });
nlohmann::json media_group = files | ranges::views::enumerate | ranges::views::transform([&](auto&& file)
{
nlohmann::json params;
if (all_photo)
{
params["type"] = "photo";
if (file.second.isSensitive) params["has_spoiler"] = true;
}
else params["type"] = "document";
params["media"] = "attach://media-{}"_f(file.first);
log.debug("Prepared media {}: {}"_f(file.first, params.dump()));
if (file.first == 0) { params["caption"] = text; params["parse_mode"] = "Markdown"; }
return params;
}) | ranges::to_vector;
items.push_back({"media", media_group.dump()});
for (int i = 0; i < files.size(); i++) items.push_back
({"media-{}"_f(i), file_contents[i], files[i].name, files[i].type});
}
items.push_back({"chat_id", std::to_string(config.TelegramChatId)});
if (replyId) items.push_back({"reply_parameters", [&]
{
nlohmann::json j;
j["message_id"] = *replyId;
j["chat_id"] = config.TelegramChatId;
return j.dump();
}()});
httplib::Client cli("https://api.telegram.org");
auto result = cli.Post("/bot{}/{}"_f(config.TelegramBotToken, method), items);
log.debug("{} {} {}"_f(result->status, result->body, result->headers));
if (result && result->status == 200)
{
auto json = nlohmann::json::parse(result->body);
// 测试 js["result"]["message_id"] 是否存在且为整数
if (json.contains("result") && json["result"].contains("message_id")
&& json["result"]["message_id"].is_number_integer())
return json["result"]["message_id"].get<std::int32_t>();
else
{
log.error("Telegram API error: {}"_f(json.dump()));
return {};
}
}
else
{
log.error("HTTP error: {}"_f(result ? std::to_string(result->status) : "No response"));
return {};
}
}

7
packages/reflectcpp.nix Normal file
View File

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

8
packages/sqlgen.nix Normal file
View File

@@ -0,0 +1,8 @@
{ 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" ];
}

View File

@@ -1,44 +1,46 @@
{ stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl }:
let vasp = stdenv.mkDerivation
{
name = "vasp-intel";
src = src.vasp;
patches = [ ../vtst.patch ];
configurePhase =
{ stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl, prrte }:
let
vasp = stdenv.mkDerivation
{
name = "vasp-intel";
src = src.vasp;
patches = [ ../vtst.patch ];
configurePhase =
''
cp ${./makefile.include} makefile.include
chmod +w makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
cp -r ${src.vtst.patch}/vtstcode6.4.3/* src
chmod -R +w src
'';
buildInputs = [ hdf5 wannier90 mkl ];
nativeBuildInputs = [ rsync which mpi ];
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done
'';
# NIX_DEBUG = "7";
enableParallelBuilding = true;
env = { DEPS = "1"; MKLROOT = mkl; OMPI_F90 = "ifx"; };
};
wrapper = writeShellScriptBin "vasp-intel"
''
cp ${./makefile.include} makefile.include
chmod +w makefile.include
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
cp -r ${src.vtst.patch}/vtstcode6.4.3/* src
chmod -R +w src
'';
buildInputs = [ hdf5 wannier90 mkl ];
nativeBuildInputs = [ rsync which mpi ];
installPhase =
''
mkdir -p $out/bin
for i in std gam ncl; do cp bin/vasp_$i $out/bin/vasp-$i; done
'';
# NIX_DEBUG = "7";
enableParallelBuilding = true;
env = { DEPS = "1"; MKLROOT = mkl; OMPI_F90 = "ifx"; };
};
in writeShellScriptBin "vasp-intel"
''
export PATH=${vasp}/bin:${mpi}/bin''${PATH:+:$PATH}
export PATH=${vasp}/bin:${mpi}/bin:${mpi.dev}/bin:${prrte}/bin:${prrte.dev}/bin''${PATH:+:$PATH}
# set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set
if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
fi
# set OMP_NUM_THREADS to 1 if not set
if [ -z "$OMP_NUM_THREADS" ]; then
export OMP_NUM_THREADS=1
fi
# set OMP_STACKSIZE to 512M if not set
if [ -z "$OMP_STACKSIZE" ]; then
export OMP_STACKSIZE=512m
fi
# set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set
if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
fi
# set OMP_NUM_THREADS to 1 if not set
if [ -z "$OMP_NUM_THREADS" ]; then
export OMP_NUM_THREADS=1
fi
# set OMP_STACKSIZE to 512M if not set
if [ -z "$OMP_STACKSIZE" ]; then
export OMP_STACKSIZE=512m
fi
exec "$@"
''
exec "$@"
'';
in wrapper // { passthru = wrapper.passthru // { inherit mpi; }; }