Compare commits

...

153 Commits

Author SHA1 Message Date
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
0211a71cfa devices.xmuhk: add archive 2025-12-22 19:03:41 +08:00
37a5069c3a devices.wlin: add archive 2025-12-22 19:02:33 +08:00
da9e67c25e devices.jykang: add archive 2025-12-22 18:53:11 +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
a097f7b85e flake: remname dank-material-shell 2025-12-22 10:26:03 +08:00
cd96c1a4ee flake: revert nix4vscode version 2025-12-22 10:25:46 +08:00
a1c9487e79 update everything 2025-12-21 19:57:48 +08:00
721c0af938 modules.services.slurm: update flag syntax 2025-12-21 10:39:02 +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
373e8c57ce fix bootstrap with nix store path containing /. 2025-12-20 18:20:43 +08:00
019aa5850a devices.wlin: rename 2025-12-19 17:43:18 +08:00
32babff9d5 devices.pc: mount hpc build dir 2025-12-19 17:08:42 +08:00
5f509a036e fix slurm 2025-12-19 13:11:44 +08:00
5c57f5232a downgrade slurm 2025-12-19 12:39:42 +08:00
7a7b645e9e modules.services.huggin: drop 2025-12-19 11:10:34 +08:00
3ff1802ded flake: update nixpkgs, to fix slurm 2025-12-18 21:43:28 +08:00
f7f473dac8 modules.services.peerBanHelper: drop 2025-12-18 21:34:23 +08:00
969aa0dae5 modules.services.groupshare: drop 2025-12-18 21:33:45 +08:00
ebc6307ca7 modules.services.searx: drop 2025-12-18 21:32:16 +08:00
403f4bf27f modules.services.slurm: fix 2025-12-18 19:52:15 +08:00
9188ffce9d flake: update nixpkgs 2025-12-18 19:32:02 +08:00
972155935d modules.system.gui: Start Telegram in tray on startup 2025-12-18 18:49:04 +08:00
e7d931d5c1 flake: update nixpkgs 2025-12-18 10:23:25 +08:00
43f782c44f modules.system.security: increase nofile limit 2025-12-18 09:55:51 +08:00
dd850c5984 modules.packages.desktop: add lutris 2025-12-18 09:39:38 +08:00
058aa6996d modules.services.nextcloud: upgrade to 32 2025-12-17 16:06:21 +08:00
a315cb4ef8 modules.services.gitea: fix anubis warning 2025-12-17 16:05:46 +08:00
87c0bd2e74 flake.lib.buildNixpkgsConfig: fix postgresql on cascadelake 2025-12-17 15:58:45 +08:00
c507e8d69d Revert "modules.services.postgresql: enable jit"
This reverts commit 9e66c845c1.
2025-12-17 15:56:22 +08:00
5305c9ee08 modules.packages.minimal: only enable direnv on x86_64 2025-12-17 15:40:44 +08:00
ab15e27a41 modules.packages: adjust python packages for desktop and server 2025-12-17 13:31:11 +08:00
9afb725ed1 modules.packages.minimal: disable kitty on aarch64 2025-12-17 13:28:04 +08:00
2ecad08f6e flake: update btrfs patch 2025-12-17 13:21:44 +08:00
c2c85b06f3 Revert "modules.hardware: re-enable joystick drivers"
This reverts commit 9c88a9d573.
2025-12-17 12:06:08 +08:00
9c88a9d573 modules.hardware: re-enable joystick drivers 2025-12-17 11:37:04 +08:00
06eaf9a1eb flake: update nix-cachyos-kernel 2025-12-17 11:15:58 +08:00
bbaca57ed0 flake.src: update btrfs patch 2025-12-17 11:12:39 +08:00
e92d791bc3 modules.packages.ghostty: init 2025-12-16 23:05:05 +08:00
0a5bbb14fe modules.services.tailscale: disable tailscale on aarch64 2025-12-16 17:56:59 +08:00
07c0fc44d0 flake: downgrade misskey 2025-12-16 17:14:57 +08:00
57f57e8b18 Revert "modules.services.misskey: fix"
This reverts commit 864e8c0ca6.
2025-12-16 17:13:06 +08:00
864e8c0ca6 modules.services.misskey: fix 2025-12-16 17:00:08 +08:00
838853bccf devices.nas: enable binfmt 2025-12-16 15:13:23 +08:00
4576d11bb9 flake.lib.buildNixpkgsConfig: use upstream svp 2025-12-16 14:45:32 +08:00
d5e0282abc flake: update nix-cachyos-kernel 2025-12-16 11:14:12 +08:00
9e66c845c1 modules.services.postgresql: enable jit 2025-12-16 11:13:20 +08:00
d507fcce11 flake: update misskey 2025-12-16 10:59:45 +08:00
4c8c0c8dce devices.pc: add partition 2025-12-16 10:46:50 +08:00
4e6c8562a0 flake.src: rename 2025-12-16 10:06:21 +08:00
aba0881a16 modules.services.slurm: disable X11 2025-12-15 21:33:19 +08:00
aee7d98f3c modules.packages.vscode: add nushell extension 2025-12-15 20:13:47 +08:00
65931dd1c1 flake.src: update netboot.xyz ISO sha256 2025-12-15 18:33:15 +08:00
e43c516841 flake.src: remove guix 2025-12-15 18:32:40 +08:00
cae87abde3 modules.packages.desktop: add missing desktop applications 2025-12-15 15:36:03 +08:00
7c774115f8 modules.system.gui: set niri window layout 2025-12-15 14:35:18 +08:00
09dfc1e55c modules.system.gui: add screenshot keybinding 2025-12-15 14:04:59 +08:00
ee8e980a61 Revert "modules.services.acme: fix"
This reverts commit 5a6a49ab5b.
2025-12-15 13:50:17 +08:00
db5bf6bb6a modules.services.coredns: fix 2025-12-15 13:41:14 +08:00
5a6a49ab5b modules.services.acme: fix 2025-12-15 10:38:55 +08:00
57efd0fb94 Revert "modules.services.acme: use google dns"
This reverts commit 397d8bb767.
2025-12-15 10:10:11 +08:00
397d8bb767 modules.services.acme: use google dns 2025-12-15 09:36:41 +08:00
a5fc71da87 module.system.gui: remove gtk settings 2025-12-14 23:32:25 +08:00
6c9d2555b9 flake: update nixpkgs 2025-12-14 23:22:50 +08:00
36c5799364 modules.system.kernel: fix mount fat32 2025-12-14 23:07:32 +08:00
705c24347a modules.system.gui: fix qt 2025-12-14 23:06:00 +08:00
c3670d2597 flake: set xddxdd overlay to use final 2025-12-14 20:29:31 +08:00
9d6f16ddcc devices.pc: set swap resume offset 2025-12-14 17:24:11 +08:00
e9295fea05 flake.lib.buildNixpkgsConfig: clenaup 2025-12-14 14:20:46 +08:00
592b40e73d flake.lib.buildNixpkgsConfig: remove ctranslate2 fix 2025-12-14 14:18:05 +08:00
db31934f46 flake: rewirte archive 2025-12-14 13:13:51 +08:00
73c061a350 devices.pc: add btrfs patch 2025-12-14 12:59:04 +08:00
a0cf0045df modules.system.kernel: remove unused kernel 2025-12-14 12:59:04 +08:00
a3be46d70c flake: replace chaotic with nix-cachyos-kernel 2025-12-14 12:59:04 +08:00
b973738722 flake.lib.buildNixpkgsConfig: import xddxdd overlay 2025-12-14 12:59:03 +08:00
e6d17c8ca6 modules.system.kernel: add 6.18 btrfs patch 2025-12-14 12:59:03 +08:00
f317e2db15 flake: update 2025-12-14 11:07:55 +08:00
3569aa1b9a devices.pc: disable waydroid 2025-12-14 10:12:30 +08:00
bafe32ad98 devices.pc: set cpu voltage 2025-12-13 11:52:13 +08:00
chn
959722a509 modules.user.chn: set git user name 2025-12-13 10:35:07 +08:00
chn
2a39ec4c7f devices.pc: fix coredns bind 2025-12-12 20:55:07 +08:00
chn
0c37f4c330 modules.services.xray.client: use coredns instead of dnsmasq 2025-12-12 20:33:42 +08:00
chn
d32d4398bb flake.packages: archive flake inputs 2025-12-12 20:08:19 +08:00
chn
d037f954a2 packages.sbatch-tui: cleanup unused options 2025-12-12 20:06:31 +08:00
chn
58d7b36ee3 modules.services.xray: use tailscale to visit gitea 2025-12-12 20:01:53 +08:00
chn
9de070e6be flake.dev: fix 2025-12-12 20:01:20 +08:00
90 changed files with 1575 additions and 1193 deletions

1
.gitattributes vendored
View File

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

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

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

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

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

View File

@@ -15,16 +15,24 @@ inputs:
btrfs =
{
"/dev/mapper/root1" = { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
"/dev/mapper/tf1"."/" = "/nix/tf";
"/dev/mapper/tf1" =
{
"/" = "/nix/tf";
"/nix/remote/jykang" = "/data/gpfs01/jykang/.nix";
"/nix/remote/xmuhk" = "/public/home/xmuhk/.nix";
"/nix/remote/wlin" = "/data/gpfs01/wlin/.nix";
};
};
nfs."nas.ts.chn.moe:/" = { mountPoint = "/nix/remote/nas"; mountBeforeSwitch = false; };
};
luks.auto =
{
"/dev/disk/by-partlabel/pc-root1" = { mapper = "root1"; ssd = true; };
"/dev/disk/by-partlabel/pc-tf1".mapper = "tf1";
"/dev/disk/by-partlabel/pc-tf2" = { mapper = "tf2"; ssd = true; };
};
swap = [ "/nix/swap/swap" ];
resume = { device = "/dev/mapper/root1"; offset = 228199020; };
resume = { device = "/dev/mapper/root1"; offset = 156901642; };
};
grub.windowsEntries."08D3-10DE" = "Windows";
nix.marches =
@@ -42,7 +50,7 @@ inputs:
];
nixpkgs = { march = "znver5"; rocm = true; };
sysctl.laptop-mode = 5;
kernel.variant = "cachyos";
kernel = { variant = "cachyos"; patches = [ "btrfs" ]; };
};
hardware = { gpu.type = "amd"; asus = {};};
services =
@@ -59,7 +67,7 @@ inputs:
};
};
sshd = {};
xray.client.dnsmasq =
xray.client.coredns =
{
hosts = builtins.listToAttrs
(
@@ -67,7 +75,7 @@ inputs:
(name: { inherit name; value = "144.34.225.59"; })
[ "mirism.one" "beta.mirism.one" "ng01.mirism.one" "initrd.vps6.chn.moe" ])
);
extraInterfaces = [ "wlo1" ];
extraInterfaces = [ "wlp194s0" ];
};
harmonia.store = "/nix/tf";
beesd =
@@ -96,7 +104,7 @@ inputs:
mariadb.mountFrom = "nodatacow";
open-webui.ollamaHost = "127.0.0.1";
howdy = {};
waydroid = {};
postgresql.enable = true;
};
bugs = [ "amdpstate" ];
packages = { mathematica = {}; vasp = {}; };
@@ -107,10 +115,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=0x0fff20"
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

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

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

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

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

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,10 +8,18 @@ let
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/wlin/.nix"; nixos = false; };
});
in pkgs.symlinkJoin
{
name = "jykang";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv ];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; };
}
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 python localPackages.vasp.intel chn-bsub hwloc
lsd prrte.dev
];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs chn-bsub; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; };
};
in wlin

View File

@@ -6,7 +6,5 @@ if [ -f ~/.bashrc ]; then
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH=/data/gpfs01/wlin/.nix/state/gcroots/current/bin:$HOME/bin:$PATH
ulimit -s unlimited

View File

@@ -4,40 +4,4 @@
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"'
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

View File

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

614
flake.lock generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -1 +0,0 @@
"production"

View File

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

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

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

@@ -44,10 +44,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.config.system.build.toplevel) inputs.self.outputs.nixosConfigurations)
[ src ]
]));
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

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

View File

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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

@@ -63,6 +63,8 @@ inputs:
"ms-toolsai.jupyter" "ms-toolsai.jupyter-keymap" "ms-toolsai.jupyter-renderers"
"ms-toolsai.vscode-jupyter-cell-tags" "ms-toolsai.vscode-jupyter-slideshow"
"ms-toolsai.datawrangler"
# nushell
"TheNuProjectContributors.vscode-nushell-lang"
];
keybindings =
[
@@ -76,6 +78,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";
@@ -171,13 +181,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)";

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

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

View File

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

View File

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

View File

@@ -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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
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,45 @@ 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;
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

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

View File

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

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

View File

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

View File

@@ -3,7 +3,11 @@ inputs:
config =
{
# only preserve the last 7 days of logs
services.journald.extraConfig = "MaxRetentionSec=7d";
services =
{
journald.extraConfig = "MaxRetentionSec=7d";
logind.settings.Login.HandleLidSwitch = "ignore";
};
systemd =
{
settings.Manager =

View File

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

View File

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

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
@@ -132,7 +134,7 @@ inputs:
{
programs.git.settings =
{
user = { name = "chn"; email = "chn@chn.moe"; };
user = { name = "Haonan Chen"; email = "chn@chn.moe"; };
# allow root operate on git repositories owned by others
safe.directory = "*";
};

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

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

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

@@ -144,6 +144,10 @@ inputs: rec
buildProxy = inputs.pkgs.lib.mkBuildproxy ./pybinding/proxy.nix;
};
brokenaxes = inputs.pkgs.python3Packages.callPackage ./brokenaxes.nix { src = inputs.topInputs.brokenaxes; };
missgram = inputs.pkgs.callPackage ./missgram { inherit biu sqlgen; stdenv = inputs.pkgs.clang18Stdenv; };
sqlgen = inputs.pkgs.callPackage ./sqlgen.nix { src = inputs.topInputs.sqlgen; inherit reflectcpp; };
reflectcpp = inputs.pkgs.callPackage ./reflectcpp.nix { src = inputs.topInputs.reflectcpp; };
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,29 @@
cmake_minimum_required(VERSION 3.14)
project(missgram VERSION 0.0.0 LANGUAGES CXX)
enable_testing()
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
find_package(biu REQUIRED)
find_package(httplib REQUIRED)
find_package(sqlgen REQUIRED)
add_executable(missgram src/main.cpp src/db.cpp src/tg.cpp)
target_include_directories(missgram PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_link_libraries(missgram PRIVATE biu::biu httplib::httplib sqlgen::sqlgen)
target_compile_features(missgram PRIVATE cxx_std_23)
if(DEFINED MISSGRAM_CONFIG_FILE)
target_compile_definitions(missgram PRIVATE MISSGRAM_CONFIG_FILE="${MISSGRAM_CONFIG_FILE}")
endif()
target_compile_definitions(missgram PRIVATE BIU_LOGGER_SOURCE_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
install(TARGETS missgram RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
message("Imported targets: ${ImportedTargets}")
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
message("CMake build type: ${CMAKE_BUILD_TYPE}")

View File

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

View File

@@ -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 url; bool is_photo; bool should_hidden; };
void db_write(std::string misskey_note, std::int32_t telegram_message_id);
std::optional<std::int32_t> db_read(std::string misskey_note);
std::optional<std::int32_t> tg_send(std::string text, std::optional<std::int32_t> replyId, std::vector<File> files);
}

View File

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

View File

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

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" ];
}

View File

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

View File

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

View File

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

View File

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

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 =
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''${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; }; }