Compare commits

...

58 Commits

Author SHA1 Message Date
411a276d34 modules.system.grub: wait indefinitely on desktops 2026-01-06 12:31:34 +08:00
3b2ed6d850 modules.system.systemd: handle lid switch 2026-01-06 12:31:34 +08:00
e580d7faa2 flake: add ufo as submodule 2026-01-06 12:31:34 +08:00
c480e681c1 modules.services.gitea: remove anubis, use simple js 2026-01-06 09:48:54 +08:00
4adc1be9a2 flake: use nixpkgs from git submodule 2026-01-05 23:11:44 +08:00
93b1e4f146 modules.system.gui: set niri keybindings 2026-01-05 16:46:45 +08:00
b71484eca4 devices.wlin: chn-bsub us non-static package 2026-01-05 16:19:56 +08:00
3c37a9288c devices.wlin: use static chn-bsub 2026-01-05 16:11:09 +08:00
2532d3cf70 packages.biu: fix static build 2026-01-05 16:06:45 +08:00
1e65495897 packages.biu: cleanup unnecessary stdenv override 2026-01-05 15:26:06 +08:00
f2a9d285f3 packages.biu: simplify backtrace 2026-01-05 15:10:10 +08:00
ef8f516ab3 packages.biu: remove unused Logger::Exception class 2026-01-05 13:56:23 +08:00
d8b96a32e8 devices.wlin: fix env 2026-01-05 13:44:16 +08:00
085fde23ba modules.system.gui: allow to turn off monitors 2026-01-04 23:57:53 +08:00
5de71b4f6d modules.system.fileSystems.nfs: fix read-only NFS unmounting 2026-01-04 21:26:45 +08:00
682fb5d0a4 flake: update cachyos 2026-01-04 20:47:45 +08:00
a4ebf16124 modules.hardware.asus: do not apply kernel patch 2026-01-04 20:24:45 +08:00
03e89c43d2 Revert "devices.pc: switch to xanmod kernel"
This reverts commit 3e3e62838b.
2026-01-04 20:24:22 +08:00
e8786d4ace update asusctl 2026-01-04 19:23:57 +08:00
7b479a158b modules.system.kernel: Sort ASUS kernel patches 2026-01-04 00:30:27 +08:00
3e3e62838b devices.pc: switch to xanmod kernel 2026-01-03 23:04:29 +08:00
0ac3e0f4bc update xanmod 2026-01-03 23:03:56 +08:00
ef99027542 Revert "flake: remove linux-asus patch"
This reverts commit 1e3f630aa9.
2026-01-03 22:58:52 +08:00
c86ebb17f4 modules.packages.zsh: fix gitstatusd run on remote 2026-01-03 21:15:00 +08:00
6eb1609f3e modules.system.gui: fix niri scroll 2026-01-03 20:24:54 +08:00
b6dd4555a6 devices.wlin: add prrte.dev 2026-01-03 18:32:11 +08:00
93dc607cb5 Revert "localPackages: remove custom stdenv"
This reverts commit f653471c23.
2026-01-03 17:49:32 +08:00
f653471c23 localPackages: remove custom stdenv 2026-01-03 17:15:53 +08:00
0416427642 Revert "packages.chn-bsub: use fixed bash"
This reverts commit 9595bed7c0.
2026-01-03 16:58:50 +08:00
9595bed7c0 packages.chn-bsub: use fixed bash 2026-01-03 16:56:19 +08:00
e2556f3a04 devices.wlin: fix chn-bsub override usage 2026-01-03 16:20:21 +08:00
f5e70e16b2 packages.chn-bsub: fix config format 2026-01-03 16:05:01 +08:00
ebc05b9911 flake.lib.buildNixpkgsConfig: enable lsf support for openmpi 2026-01-03 15:57:18 +08:00
6efc29a7a4 devices.pc: Improve power management settings 2026-01-03 15:05:11 +08:00
c0c8bc3704 modules.system.systemd: disable lid switch causing suspend 2026-01-03 15:05:11 +08:00
73a1490fed modules.system.gui: fix niri 2026-01-03 15:05:11 +08:00
1bb6e550d8 modules.user.chn.ssh: Set TERM for wlin host 2026-01-03 14:18:55 +08:00
c9bd7b48d7 devices.wlin: add lsd 2026-01-03 14:17:25 +08:00
d1d27ce194 packages.chn-bsub: fix, install on wlin 2026-01-03 12:19:05 +08:00
3f46eb23de devices.wlin: adjust path 2026-01-02 18:08:02 +08:00
4cb983ce32 modules.packages.ssh: fix wlin 2026-01-02 18:06:20 +08:00
87c6d0fab4 devices.wlin: install 2026-01-02 18:05:24 +08:00
e5f7e1650e devices.wlin: add phonopy and vasp 2026-01-02 13:52:42 +08:00
d92b202b8e modules.packages.minimal: add cryptsetup 2026-01-02 12:59:45 +08:00
4c3cb5fe5f flake.dns: add tailscale DNS config 2026-01-02 12:46:56 +08:00
2147ba2f2d devices.srv2: remove NFS mount for NAS 2026-01-02 12:24:27 +08:00
58b1c596db flake.nixos: temporarily remove r2s 2026-01-02 11:38:50 +08:00
2e278b2dba flake: update btop 2026-01-01 07:56:27 +08:00
72067d23c5 flake.packages: allow to build separate archive 2025-12-31 20:21:26 +08:00
94670e9cbe devices.srv2: fix nfs mount 2025-12-31 17:31:19 +08:00
3ab4ecb5d2 modules.system.gui: Enable GTK icon cache 2025-12-31 17:03:45 +08:00
63c647ceba Merge branch 'next' into production 2025-12-31 14:11:59 +08:00
fb7e9156d0 packages.missgram: fix 2025-12-31 08:29:00 +08:00
f2e2f34cbf devices.pc: add NFS mount for nas.ts.chn.moe 2025-12-30 14:56:07 +08:00
7d09abee57 modules.system.fileSystems.nfs: add readOnly option 2025-12-30 14:55:12 +08:00
e2921059f8 modules.packages.desktop: update libreoffice 2025-12-30 11:36:40 +08:00
acd2845377 update readme 2025-12-30 10:52:00 +08:00
b1546505a5 fix distutils 2025-12-30 08:20:28 +08:00
47 changed files with 623 additions and 496 deletions

6
.gitmodules vendored Normal file
View File

@@ -0,0 +1,6 @@
[submodule "nixpkgs"]
path = nixpkgs
url = https://github.com/CHN-beta/nixpkgs.git
[submodule "packages/ufo"]
path = packages/ufo
url = https://git.chn.moe/chn/ufo.git

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

@@ -23,6 +23,7 @@ inputs:
"/nix/remote/wlin" = "/data/gpfs01/wlin/.nix"; "/nix/remote/wlin" = "/data/gpfs01/wlin/.nix";
}; };
}; };
nfs."nas.ts.chn.moe:/" = { mountPoint = "/nix/remote/nas"; mountBeforeSwitch = false; };
}; };
luks.auto = luks.auto =
{ {
@@ -114,10 +115,17 @@ inputs:
services.colord.enable = true; services.colord.enable = true;
services.udev.extraRules = services.udev.extraRules =
'' ''
#
ACTION=="add", ATTR{power/wakeup}="disabled"
# CPU # CPU
SUBSYSTEM=="power_supply", KERNEL=="BAT0", ACTION=="*", RUN+="${inputs.pkgs.ryzenadj}/bin/ryzenadj --set-coall=0x0fff40" SUBSYSTEM=="power_supply", KERNEL=="BAT0", ACTION=="*", RUN+="${inputs.pkgs.ryzenadj}/bin/ryzenadj --set-coall=0x0fff40"
''; '';
# 解决有时蓝牙不能使用的问题 boot.kernelParams =
boot.kernelParams = [ "mt7925e.disable_aspm=1" ]; [
# 解决有时蓝牙不能使用的问题
"mt7925e.disable_aspm=1"
# 插拔电源和扩展坞不要唤醒电脑
"acpi.ec_no_wakeup=1"
];
}; };
} }

View File

@@ -12,7 +12,6 @@ inputs:
vfat."/dev/disk/by-partlabel/${clusterName}-${nodeName}-boot" = "/boot"; vfat."/dev/disk/by-partlabel/${clusterName}-${nodeName}-boot" = "/boot";
btrfs."/dev/disk/by-partlabel/${clusterName}-${nodeName}-root1" = btrfs."/dev/disk/by-partlabel/${clusterName}-${nodeName}-root1" =
{ "/nix" = "/nix"; "/nix/rootfs/current" = "/"; }; { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
nfs."nas.ts.chn.moe:/" = { mountPoint = "/nix/remote/nas"; neededForBoot = false; };
}; };
nixpkgs.cuda.capabilities = nixpkgs.cuda.capabilities =
[ [

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 }: { inputs, localLib }:
let let
pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig pkgs = import inputs.nixpkgs (localLib.buildNixpkgsConfig
@@ -5,11 +8,18 @@ let
inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; }; inputs = { inherit (inputs.nixpkgs) lib; topInputs = inputs; };
nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/wlin/.nix"; nixos = false; }; nixpkgs = { march = "haswell"; nixRoot = "/data/gpfs01/wlin/.nix"; nixos = false; };
}); });
python = pkgs.python3.withPackages (ps: with ps; [ phonopy ]);
chn-bsub = pkgs.localPackages.chn-bsub.override
(prev: { bsubConfig = builtins.toFile "bsub.yaml" (builtins.toJSON (import ./bsub.nix)); });
wlin = pkgs.symlinkJoin wlin = pkgs.symlinkJoin
{ {
name = "wlin"; name = "wlin";
paths = with pkgs; [ gnuplot localPackages.vaspkit pv ]; paths = with pkgs;
[
gnuplot localPackages.vaspkit pv python localPackages.vasp.intel chn-bsub hwloc
lsd glibc glibc.bin
];
postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version"; postBuild = "echo ${inputs.self.rev or "dirty"} > $out/.version";
passthru = { inherit pkgs; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; }; passthru = { inherit pkgs chn-bsub; archive = pkgs.closureInfo { rootPaths = [ wlin.drvPath ]; }; };
}; };
in wlin in wlin

View File

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

View File

@@ -1,43 +1,10 @@
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then if [ -f /etc/bashrc ]; then
. /etc/bashrc . /etc/bashrc
fi fi
export PATH=$PATH:/data/gpfs01/wlin/bin if [ -z "${BASHRC_SOURCED-}" ]; then
export PATH=$HOME/.nix/state/gcroots/current/bin:$HOME/bin:$PATH
# User specific aliases and functions ulimit -s unlimited
export PATH=/data/gpfs01/wlin/bin/vaspkit.1.4.1/bin:${PATH} export HISTFILESIZE=1000000
#export PATH=~/bin:/data/gpfs01/wlin/opt/mpich_ifort/bin:$PATH export BASHRC_SOURCED=1
#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 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

78
flake.lock generated
View File

@@ -100,11 +100,11 @@
"cachyos-kernel": { "cachyos-kernel": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1766083376, "lastModified": 1767371066,
"narHash": "sha256-eh914fO4gYD8aCuUrMlPBRsxwwa2+qc9HCuAhrG6G9c=", "narHash": "sha256-ztxcryN0uX2WhFYoOZLXClqaFwfC8EAVCKaA2M++ROU=",
"owner": "CachyOS", "owner": "CachyOS",
"repo": "linux-cachyos", "repo": "linux-cachyos",
"rev": "9d369789361623b8a3b842a71adccb19b24ba16f", "rev": "f280ea9c30ca7a39cf8f6995efb553ff9b8cb384",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -116,11 +116,11 @@
"cachyos-kernel-patches": { "cachyos-kernel-patches": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1766080842, "lastModified": 1767369270,
"narHash": "sha256-LezfhAfTdfhvjiHSWe258SMUIs+cP8SHT8BiPou0A4w=", "narHash": "sha256-Jne9XlgFlyuJIf9F6QoAObLo2/AXYbaGqNFqCdRdDmY=",
"owner": "CachyOS", "owner": "CachyOS",
"repo": "kernel-patches", "repo": "kernel-patches",
"rev": "e266fbc7f36273ebbc62a9bffda02e3882eb8f6c", "rev": "15a034b093aee9b935f7c6c08ea5312e187c9ac7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -364,11 +364,11 @@
"flake-compat_2": { "flake-compat_2": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1765121682, "lastModified": 1767039857,
"narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=", "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "NixOS", "owner": "NixOS",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3", "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -665,6 +665,23 @@
"type": "github" "type": "github"
} }
}, },
"linux-asus": {
"flake": false,
"locked": {
"lastModified": 1767457777,
"narHash": "sha256-DCKTOfkJ0d1IkSwcSq0r/j45BvkBDcqXVmJAVYRFHSU=",
"owner": "CHN-beta",
"repo": "linux-g14",
"rev": "c02087ae1c3f9d24bdcf2b4b277ce0b4c9fd767c",
"type": "github"
},
"original": {
"owner": "CHN-beta",
"ref": "6.18",
"repo": "linux-g14",
"type": "github"
}
},
"mac-style": { "mac-style": {
"flake": false, "flake": false,
"locked": { "locked": {
@@ -865,11 +882,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1766317927, "lastModified": 1767529782,
"narHash": "sha256-8bpmKA1+G8r8uB8YesjmvSS8w+0dhB+SYdmpGWYlXAE=", "narHash": "sha256-Wz8j5qfkxX+QQa/arHqWGYZuBfLTq/cJVDCEIBzEV9o=",
"owner": "CHN-beta", "owner": "CHN-beta",
"repo": "nix-cachyos-kernel", "repo": "nix-cachyos-kernel",
"rev": "ae6243bbaac9c0eff212bfb45eff5620dfe383a5", "rev": "7d65b67594d1422ecd2a9f4cbfcce8fca67067f4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -1144,19 +1161,14 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1766317807, "path": "nixpkgs",
"narHash": "sha256-HQeHsIrRFllgpmUlhMH+F8cxp/zeODTziEHai2Ryebw=", "type": "path"
"owner": "CHN-beta",
"repo": "nixpkgs",
"rev": "201f7c1ac0c7c455ad0a6660c037f49821160c3b",
"type": "github"
}, },
"original": { "original": {
"owner": "CHN-beta", "path": "nixpkgs",
"ref": "nixos-25.11", "type": "path"
"repo": "nixpkgs", },
"type": "github" "parent": []
}
}, },
"nixvirt": { "nixvirt": {
"inputs": { "inputs": {
@@ -1442,6 +1454,7 @@
"home-manager": "home-manager", "home-manager": "home-manager",
"impermanence": "impermanence", "impermanence": "impermanence",
"lepton": "lepton", "lepton": "lepton",
"linux-asus": "linux-asus",
"mac-style": "mac-style", "mac-style": "mac-style",
"matplotplusplus": "matplotplusplus", "matplotplusplus": "matplotplusplus",
"mirism-old": "mirism-old", "mirism-old": "mirism-old",
@@ -1478,7 +1491,6 @@
"sticker": "sticker", "sticker": "sticker",
"stickerpicker": "stickerpicker", "stickerpicker": "stickerpicker",
"tgbot-cpp": "tgbot-cpp", "tgbot-cpp": "tgbot-cpp",
"ufo": "ufo",
"v-sim": "v-sim", "v-sim": "v-sim",
"vaspberry": "vaspberry", "vaspberry": "vaspberry",
"winapps": "winapps", "winapps": "winapps",
@@ -1764,24 +1776,6 @@
"type": "github" "type": "github"
} }
}, },
"ufo": {
"flake": false,
"locked": {
"lastModified": 1762315512,
"lfs": true,
"narHash": "sha256-tTVQrXhnfFdrRwYJ60mpGdlbvUOE6egAxtqD0d80Crw=",
"ref": "refs/heads/main",
"rev": "dc6b431bf92db5ba22aac745a90e058528d9b5e3",
"revCount": 85,
"type": "git",
"url": "https://git.chn.moe/chn/ufo.git"
},
"original": {
"lfs": true,
"type": "git",
"url": "https://git.chn.moe/chn/ufo.git"
}
},
"v-sim": { "v-sim": {
"flake": false, "flake": false,
"locked": { "locked": {

View File

@@ -3,7 +3,8 @@
inputs = inputs =
{ {
nixpkgs.url = "github:CHN-beta/nixpkgs/nixos-25.11"; self = { submodules = true; lfs = true; };
nixpkgs.url = ./nixpkgs;
nixpkgs-2505.url = "github:CHN-beta/nixpkgs/nixos-25.05"; nixpkgs-2505.url = "github:CHN-beta/nixpkgs/nixos-25.05";
nixpkgs-2411.url = "github:CHN-beta/nixpkgs/nixos-24.11"; nixpkgs-2411.url = "github:CHN-beta/nixpkgs/nixos-24.11";
nixpkgs-2311.url = "github:CHN-beta/nixpkgs/nixos-23.11"; nixpkgs-2311.url = "github:CHN-beta/nixpkgs/nixos-23.11";
@@ -53,7 +54,6 @@
pocketfft = { url = "github:mreineck/pocketfft"; flake = false; }; pocketfft = { url = "github:mreineck/pocketfft"; flake = false; };
blog = { url = "git+https://git.chn.moe/chn/blog-public.git?lfs=1"; flake = false; }; blog = { url = "git+https://git.chn.moe/chn/blog-public.git?lfs=1"; flake = false; };
vaspberry = { url = "github:Infant83/VASPBERRY"; 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; }; stickerpicker = { url = "github:maunium/stickerpicker"; flake = false; };
fancy-motd = { url = "github:CHN-beta/fancy-motd"; flake = false; }; fancy-motd = { url = "github:CHN-beta/fancy-motd"; flake = false; };
mac-style = { url = "github:SergioRibera/s4rchiso-plymouth-theme?lfs=1"; flake = false; }; mac-style = { url = "github:SergioRibera/s4rchiso-plymouth-theme?lfs=1"; flake = false; };
@@ -65,6 +65,7 @@
mirism-old = { url = "github:CHN-beta/mirism-old-public"; 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; }; 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; }; 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 outputs = inputs: let localLib = import ./flake/lib inputs.nixpkgs.lib; in

View File

@@ -1,64 +1,64 @@
{ inputs }: let inherit (inputs.self.nixosConfigurations.pc) pkgs; in { inputs }: let inherit (inputs.self.nixosConfigurations.pc) pkgs; in
{ {
biu = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } biu = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.biu ]; inputsFrom = [ pkgs.localPackages.biu ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
hpcstat = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; } hpcstat = pkgs.mkShell
{ {
inputsFrom = [ (pkgs.localPackages.hpcstat.override { version = null; }) ]; inputsFrom = [ (pkgs.localPackages.hpcstat.override { version = null; }) ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
sbatch-tui = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } sbatch-tui = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.sbatch-tui ]; inputsFrom = [ pkgs.localPackages.sbatch-tui ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
ufo = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } ufo = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.ufo ]; inputsFrom = [ pkgs.localPackages.ufo ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
chn-bsub = pkgs.mkShell chn-bsub = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.chn-bsub ]; inputsFrom = [ pkgs.localPackages.chn-bsub ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
}; };
info = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } info = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.info ]; inputsFrom = [ pkgs.localPackages.info ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
vm = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } vm = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.vm ]; inputsFrom = [ pkgs.localPackages.vm ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
xinli = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } xinli = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.xinli ]; inputsFrom = [ pkgs.localPackages.xinli ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };
missgram = pkgs.mkShell.override { stdenv = pkgs.clang18Stdenv; } missgram = pkgs.mkShell
{ {
inputsFrom = [ pkgs.localPackages.missgram ]; inputsFrom = [ pkgs.localPackages.missgram ];
packages = [ pkgs.llvmPackages_18.clang-tools ]; packages = [ pkgs.llvmPackages.clang-tools ];
CMAKE_EXPORT_COMPILE_COMMANDS = "1"; CMAKE_EXPORT_COMPILE_COMMANDS = "1";
hardeningDisable = [ "all" ]; hardeningDisable = [ "all" ];
}; };

View File

@@ -45,6 +45,7 @@ let
"409test" = "192.168.1.5"; "409test" = "192.168.1.5";
}; };
tinc = import ./tinc.nix; tinc = import ./tinc.nix;
tailscale = import ./tailscale.nix;
in in
{ {
"" = "" =
@@ -82,3 +83,6 @@ in
// lib.mapAttrs' // lib.mapAttrs'
(n: v: lib.nameValuePair "tinc0.${n}" { type = "A"; value = "192.168.85.${builtins.toString v}"; }) (n: v: lib.nameValuePair "tinc0.${n}" { type = "A"; value = "192.168.85.${builtins.toString v}"; })
tinc tinc
// lib.mapAttrs'
(n: v: lib.nameValuePair "${n}.ts" { type = "A"; value = "100.97.101.${builtins.toString v}"; })
tailscale

View File

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

View File

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

View File

@@ -72,6 +72,13 @@ in platformConfig //
google-chrome = prev.google-chrome.override (prev: google-chrome = prev.google-chrome.override (prev:
{ commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; }); { commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; });
xray = prev.xray.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xray.patch ]; }); xray = prev.xray.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xray.patch ]; });
btop = prev.btop.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./btop.patch ]; });
prrte = prev.prrte.overrideAttrs (prev:
{
configureFlags = prev.configureFlags or [] ++ [ "--with-lsf" ];
buildInputs = prev.buildInputs or [] ++ [ final.localPackages.lsf final.libnsl ];
});
cpptrace = prev.cpptrace.overrideAttrs (prev: { doCheck = !final.stdenv.hostPlatform.isStatic; });
} }
// ( // (
let let
@@ -136,7 +143,7 @@ in platformConfig //
assimp = prev.assimp.override { stdenv = final.genericPackages.stdenv; }; assimp = prev.assimp.override { stdenv = final.genericPackages.stdenv; };
xen = prev.xen.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xen.patch ]; }); xen = prev.xen.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xen.patch ]; });
lib2geom = prev.lib2geom.overrideAttrs (prev: { doCheck = false; }); 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 "" + { unwrapped = prev.unwrapped.overrideAttrs (prev: { postPatch = prev.postPatch or "" +
'' ''
sed -i '/CPPUNIT_TEST.testDubiousArrayFormulasFODS/d' sc/qa/unit/functions_array.cxx sed -i '/CPPUNIT_TEST.testDubiousArrayFormulasFODS/d' sc/qa/unit/functions_array.cxx

View File

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

View File

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

View File

@@ -211,4 +211,13 @@
structuredExtraConfig = { BTRFS_ALLOCATOR_HINTS = lib.kernel.yes; BTRFS_READ_POLICIES = lib.kernel.yes; }; structuredExtraConfig = { BTRFS_ALLOCATOR_HINTS = lib.kernel.yes; BTRFS_READ_POLICIES = lib.kernel.yes; };
}; };
}; };
# download include from /opt/ibm/lsfsuite/lsf/10.1/include into lsf/include
# download lib from /opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/lib into lsf/lib and only preserve .so
lsf = pkgs.requireFile
{
name = "lsf";
sha256 = "0rij4xx705yj1vr5jd31hb8izmb35vkrdql0850qc5cn30jnkf4l";
hashMode = "recursive";
message = "lsf not found.";
};
} }

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

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

View File

@@ -54,7 +54,7 @@ inputs:
google-chrome tor-browser google-chrome tor-browser
# office # office
crow-translate zotero pandoc texliveFull poppler-utils pdftk pdfchain kdePackages.kruler kdePackages.okular crow-translate zotero pandoc texliveFull poppler-utils pdftk pdfchain kdePackages.kruler kdePackages.okular
ydict texstudio panoply pspp libreoffice-qt6-still ocrmypdf typst # paperwork ydict texstudio panoply pspp libreoffice-fresh ocrmypdf typst # paperwork
# required by ltex-plus.vscode-ltex-plus # required by ltex-plus.vscode-ltex-plus
ltex-ls ltex-ls-plus ltex-ls ltex-ls-plus
# matplot++ needs old gnuplot # matplot++ needs old gnuplot

View File

@@ -10,11 +10,11 @@ inputs:
[ [
# basic tools # basic tools
beep dos2unix gnugrep pv tmux screen parallel tldr cowsay jq yq ipfetch localPackages.pslist 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 # lsxx
pciutils usbutils lshw util-linux lsof dmidecode lm_sensors hwloc acpica-tools ethtool pciutils usbutils lshw util-linux lsof dmidecode lm_sensors hwloc acpica-tools ethtool
# top # top
iotop iftop htop btop powertop s-tui iotop iftop htop powertop s-tui
# editor # editor
nano bat nano bat
# downloader # downloader

View File

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

View File

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

View File

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

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

View File

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

View File

@@ -39,6 +39,7 @@ inputs:
}; };
xdg.portal.extraPortals = (builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" "gnome" ]); xdg.portal.extraPortals = (builtins.map (p: inputs.pkgs."xdg-desktop-portal-${p}") [ "gtk" "wlr" "gnome" ]);
qt = { enable = true; platformTheme = "qt5ct"; }; qt = { enable = true; platformTheme = "qt5ct"; };
gtk.iconCache.enable = true;
i18n.inputMethod = i18n.inputMethod =
{ {
enable = true; enable = true;
@@ -76,9 +77,10 @@ inputs:
"Mod+Ctrl+C".action.spawn = [ "sh" "-c" "${xsel} -ob | ${wl-copy}" ]; "Mod+Ctrl+C".action.spawn = [ "sh" "-c" "${xsel} -ob | ${wl-copy}" ];
"Mod+Ctrl+V".action.spawn = [ "sh" "-c" "${wl-paste} -n | ${xsel} -ib" ]; "Mod+Ctrl+V".action.spawn = [ "sh" "-c" "${wl-paste} -n | ${xsel} -ib" ];
"Mod+S".action.screenshot = {}; "Mod+S".action.screenshot = {};
"Mod+F".action.set-column-width= "100%"; "Mod+F".action.switch-preset-column-width = {};
"Mod+R".action.switch-preset-column-width = {}; "Mod+T".action.spawn = [ "ghostty" ];
"Mod+T".action.expand-column-to-available-width = {}; "Mod+B".action.spawn = [ "firefox" ];
"Mod+Escape".action.power-off-monitors = {};
}; };
outputs = outputs =
{ {
@@ -91,11 +93,17 @@ inputs:
mode = { width = 3840; height = 2160; refresh = 160.; }; 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 = layout =
{ {
default-column-width.proportion = 0.5; default-column-width.proportion = 0.5;
preset-column-widths = [ { proportion = 0.33333; } { proportion = 0.5; } { proportion = 0.66667; } ]; preset-column-widths = [ { proportion = 0.5; } { proportion = 1.; } ];
}; };
spawn-at-startup = spawn-at-startup =
[ [

View File

@@ -67,6 +67,41 @@ inputs:
patches = patches =
{ {
btrfs = [(inputs.topInputs.self.src.btrfs.${version} // { name = "btrfs"; })]; 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); in builtins.concatLists (builtins.map (name: patches.${name}) kernel.patches);
}; };

View File

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

1
nixpkgs Submodule

Submodule nixpkgs added at d8ca282fc0

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,5 @@
# pragma once # pragma once
# include <map> # include <map>
# define BOOST_STACKTRACE_USE_BACKTRACE
# include <boost/stacktrace.hpp>
# include <biu/atomic.hpp> # include <biu/atomic.hpp>
namespace biu namespace biu
@@ -53,15 +51,6 @@ namespace biu
// List of objects that is being monitored by ObjectMonitor, {address, type} // List of objects that is being monitored by ObjectMonitor, {address, type}
protected: static Atomic<std::multimap<const void*, std::string_view>> Objects_; protected: static Atomic<std::multimap<const void*, std::string_view>> Objects_;
public: template <typename FinalException> class Exception : public std::exception
{
protected: const std::string Message_;
protected: const boost::stacktrace::stacktrace Stacktrace_;
public: explicit Exception(const std::string& message);
public: const char* what() const noexcept final {return Message_.c_str();}
};
public: template <typename Function> static void try_exec(Function&& function); public: template <typename Function> static void try_exec(Function&& function);
// Monitor the start and end of a function, as well as corresponding thread. // Monitor the start and end of a function, as well as corresponding thread.
@@ -94,12 +83,6 @@ namespace biu
public: [[gnu::always_inline]] inline void error(const std::string& message) const; public: [[gnu::always_inline]] inline void error(const std::string& message) const;
public: [[gnu::always_inline]] inline void info(const std::string& message) const; public: [[gnu::always_inline]] inline void info(const std::string& message) const;
public: [[gnu::always_inline]] inline void debug(const std::string& message) const; public: [[gnu::always_inline]] inline void debug(const std::string& message) const;
public: [[gnu::always_inline]] inline void print_exception
(
std::optional<std::pair<std::string, std::string>> type_and_message,
const boost::stacktrace::stacktrace& stacktrace
) const;
}; };
friend class Guard; friend class Guard;

View File

@@ -5,6 +5,8 @@
# include <biu/common.hpp> # include <biu/common.hpp>
# include <biu/format.hpp> # include <biu/format.hpp>
# include <boost/exception/diagnostic_information.hpp> # include <boost/exception/diagnostic_information.hpp>
# include <cpptrace/cpptrace.hpp>
# include <cpptrace/from_current.hpp>
namespace biu namespace biu
{ {
@@ -63,13 +65,6 @@ namespace biu
} }
inline Atomic<std::multimap<const void*, std::string_view>> Logger::Objects_; inline Atomic<std::multimap<const void*, std::string_view>> Logger::Objects_;
template <typename FinalException> Logger::Exception<FinalException>::Exception(const std::string& message)
{
Logger::Guard log(message);
log.print_exception
(std::pair<std::string, std::string>(nameof::nameof_full_type<FinalException>(), message), Stacktrace_);
}
template <typename Function> inline void Logger::try_exec(Function&& function) template <typename Function> inline void Logger::try_exec(Function&& function)
{ {
Logger::Guard log; Logger::Guard log;
@@ -77,8 +72,12 @@ namespace biu
catch (...) catch (...)
{ {
log.error(boost::current_exception_diagnostic_information()); log.error(boost::current_exception_diagnostic_information());
log.print_exception if (auto&& lock = LoggerConfig_.lock(); lock->Level >= Logger::Level::Error)
(std::nullopt, boost::stacktrace::stacktrace::from_current_exception()); {
static_assert(std::same_as<std::size_t, std::uint64_t>);
cpptrace::from_current_exception().print(*lock->Stream);
*lock->Stream << std::flush;
}
} }
} }
@@ -124,13 +123,13 @@ namespace biu
{ {
static_assert(std::same_as<std::size_t, std::uint64_t>); static_assert(std::same_as<std::size_t, std::uint64_t>);
auto time = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()); auto time = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now());
boost::stacktrace::stacktrace stack; auto frame = cpptrace::stacktrace::current(0, 1).frames[0];
# ifdef BIU_LOGGER_SOURCE_ROOT # ifdef BIU_LOGGER_SOURCE_ROOT
auto source_root = std::string_view(BIU_LOGGER_SOURCE_ROOT "/"); auto source_root = std::string_view(BIU_LOGGER_SOURCE_ROOT "/");
auto source_file = stack[0].source_file().starts_with(source_root) ? auto source_file = frame.filename.starts_with(source_root) ?
stack[0].source_file().substr(source_root.size()) : stack[0].source_file(); frame.filename.substr(source_root.size()) : frame.filename;
# else # else
auto source_file = stack[0].source_file(); auto source_file = frame.filename;
# endif # endif
*lock->Stream << "[ {:%T} {:02x} {:02} ] {} (at {}:{} {} )\n"_f *lock->Stream << "[ {:%T} {:02x} {:02} ] {} (at {}:{} {} )\n"_f
( (
@@ -139,8 +138,8 @@ namespace biu
Indent_, Indent_,
message, message,
source_file.empty() ? "??"s : source_file, source_file.empty() ? "??"s : source_file,
stack[0].source_line() == 0 ? "??"s : "{}"_f(stack[0].source_line()), frame.line.has_value() ? "{}"_f(frame.line.value()) : "??"s,
stack[0].name() frame.symbol
) << std::flush; ) << std::flush;
} }
} }
@@ -154,26 +153,5 @@ namespace biu
return std::forward<T>(value); return std::forward<T>(value);
} }
inline void Logger::Guard::print_exception
(
std::optional<std::pair<std::string, std::string>> type_and_message,
const boost::stacktrace::stacktrace& stacktrace
) const
{
if (type_and_message) log<Level::Error>("{}: {}"_f(type_and_message->first, type_and_message->second));
if (auto&& lock = LoggerConfig_.lock(); lock->Level >= Logger::Level::Error)
{
static_assert(std::same_as<std::size_t, std::uint64_t>);
for (auto frame : stacktrace)
*lock->Stream << "\tfrom {}:{} {}\n"_f
(
frame.source_file().empty() ? "??"s : frame.source_file(),
frame.source_line() == 0 ? "??"s : "{}"_f(frame.source_line()),
frame.name()
);
*lock->Stream << std::flush;
}
}
inline Atomic<std::map<std::size_t, std::size_t>> Logger::Threads_; inline Atomic<std::map<std::size_t, std::size_t>> Logger::Threads_;
} }

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() endif()
find_package(ftxui REQUIRED) find_package(ftxui REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem iostreams)
find_package(range-v3 REQUIRED)
find_package(biu REQUIRED) find_package(biu REQUIRED)
add_executable(chn-bsub src/main.cpp) add_executable(chn-bsub src/main.cpp)
target_compile_features(chn-bsub PUBLIC cxx_std_23) 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 target_link_libraries(chn-bsub PRIVATE ftxui::screen ftxui::dom ftxui::component biu::biu)
range-v3::range-v3 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}) 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"; name = "chn-bsub";
src = ./.; src = ./.;
buildInputs = [ ftxui biu ]; buildInputs = [ ftxui biu ];
nativeBuildInputs = [ cmake pkg-config ]; nativeBuildInputs = [ cmake pkg-config ];
postInstall = "ln -s chn-bsub $out/bin/chn_bsub"; 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 <biu.hpp>
# include <filesystem>
# include <ftxui/component/component.hpp> # include <ftxui/component/component.hpp>
# include <ftxui/component/component_options.hpp> # include <ftxui/component/component_options.hpp>
# include <ftxui/component/screen_interactive.hpp> # include <ftxui/component/screen_interactive.hpp>
# include <boost/process.hpp> # include <boost/process.hpp>
# include <boost/algorithm/string.hpp> # include <boost/algorithm/string.hpp>
# include <biu.hpp>
# ifndef BSUB_CONFIG
# define BSUB_CONFIG "./bsub.yaml"
# endif
using namespace biu::literals; using namespace biu::literals;
int main() int main()
{ {
// 需要绑定到界面上的变量 biu::Logger::Guard log;
struct enum class UserCommandType { Continue, Back, Quit };
{ enum class InterfaceType { Request, Confirm };
std::array<int, 3> vasp_version_selected = {0, 0, 0}; struct
std::vector<std::string> vasp_version_entries_level1 = {"640", "631"}; {
std::map<std::string, std::vector<std::string>> vasp_version_entries_level2 = 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"}}, // /data/gpfs01/wlin/chn/lammps-SiC
{"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
std::vector<std::string> paths; std::vector<std::string> paths;
boost::split(paths, std::filesystem::current_path().string(), boost::split(paths, std::filesystem::current_path().string(), boost::is_any_of("/"));
boost::is_any_of("/")); if (paths.size() < 6) return "my-great-job"s;
if (paths.size() < 7) else return paths[4] + "_" + paths.back();
return "my-great-job"s;
else
return paths[5] + "_" + paths.back();
}(); }();
std::string bsub = ""; std::string OutputFile = "output.txt";
std::string user_command = ""; } State;
} 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) auto with_title = [](std::string title, ftxui::Color bgcolor = ftxui::Color::Blue)
{ {
return ftxui::Renderer(component, [title, component] return [=](ftxui::Element element)
{ { return ftxui::vbox(ftxui::text(title) | ftxui::bgcolor(bgcolor), element); };
return ftxui::vbox };
({ // 为组件增加下边框
ftxui::text(title) | ftxui::bgcolor(ftxui::Color::Blue), auto with_bottom = [](ftxui::Element element)
component->Render(), { return ftxui::vbox(element, ftxui::separatorLight()); };
ftxui::separator() // 为组件增加比较粗的下边框
}); 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 Screen = ftxui::ScreenInteractive::Fullscreen();
auto request_interface = [&state, &screen, &component_with_title] auto key_event_handler = [&](ftxui::Event event)
{ {
auto vasp_version_level1 = ftxui::Menu if (event == ftxui::Event::Return)
(&state.vasp_version_entries_level1, &state.vasp_version_selected[0]) { State.UserCommand = UserCommandType::Continue; Screen.ExitLoopClosure()(); return true; }
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 8); else return false;
std::vector<ftxui::Component> vasp_version_level2_children; };
for (auto& i : state.vasp_version_entries_level1) auto InterfaceRequest = ftxui::Container::Vertical
vasp_version_level2_children.push_back(ftxui::Menu ({
( ftxui::Container::Horizontal
&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
({ ({
vasp_version, queue, ncores, job_name, ftxui::Menu(&State.VaspEntries, &State.VaspSelected) | with_title("VASP variant:"),
ftxui::Container::Horizontal({continue_button, quit_button}) ftxui::Menu(&State.QueueEntries, &State.QueueSelected)
}) | ftxui::borderHeavy | with_title("Queue:") | with_separator
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 47) }) | with_bottom_heavy,
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 24); input(&State.JobName, "Job name: "),
}(); input(&State.OutputFile, "Output file: "),
auto confirm_interface = [&state, &screen, &component_with_title] // 操作按钮
{ ftxui::Container::Horizontal
ftxui::InputOption input_option;
input_option.multiline = true;
return ftxui::Container::Vertical
({ ({
component_with_title ftxui::Button("Continue (Enter)",
( [&]{ State.UserCommand = UserCommandType::Continue; Screen.ExitLoopClosure()(); }),
"Double check & modify submit command:", ftxui::Button("Quit",
ftxui::Input(&state.bsub, "", input_option) [&]{ State.UserCommand = UserCommandType::Quit; Screen.ExitLoopClosure()(); })
) }),
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 7), }) | ftxui::borderHeavy | with_padding | ftxui::CatchEvent(key_event_handler);
ftxui::Container::Horizontal auto InterfaceConfirm = ftxui::Container::Vertical
({ ({
ftxui::Button("Submit", ftxui::Input(&State.SubmitCommand, "", ftxui::InputOption{.multiline = true})
[&]{state.user_command = "submit"; screen.ExitLoopClosure()();}), | with_title("Double check & modify submit command:") | with_bottom_heavy,
ftxui::Button("Quit", ftxui::Container::Horizontal
[&]{state.user_command = "quit"; screen.ExitLoopClosure()();}), ({
ftxui::Button("Back", ftxui::Button("Submit (Enter)",
[&]{state.user_command = "back"; screen.ExitLoopClosure()();}) [&]{State.UserCommand = UserCommandType::Continue; Screen.ExitLoopClosure()();}),
}), ftxui::Button("Back",
ftxui::Renderer([]{return ftxui::vbox [&]{State.UserCommand = UserCommandType::Back; Screen.ExitLoopClosure()();}),
({ ftxui::Button("Quit",
ftxui::separator(), [&]{State.UserCommand = UserCommandType::Quit; Screen.ExitLoopClosure()();})
ftxui::text("Source code:"), })
ftxui::text("https://github.com/CHN-beta/chn_bsub.git"), }) | ftxui::borderHeavy | with_padding | ftxui::CatchEvent(key_event_handler);
ftxui::text("Star & PR are welcome!"),
});})
}) | ftxui::borderHeavy
| ftxui::size(ftxui::WIDTH, ftxui::EQUAL, 47)
| ftxui::size(ftxui::HEIGHT, ftxui::EQUAL, 14);
}();
// 实际投递任务 // 进入事件循环
auto submit = [](std::string bsub) while (true)
{ {
// replace \n with space if (State.CurrentInterface == InterfaceType::Request)
boost::replace_all(bsub, "\n", " "); {
auto process = boost::process::child State.UserCommand.reset();
( Screen.Loop(InterfaceRequest);
boost::process::search_path("sh"), "-c", bsub, if (State.UserCommand == UserCommandType::Quit) return 0;
boost::process::std_in.close(), else if (State.UserCommand == UserCommandType::Continue)
boost::process::std_out > stdout, {
boost::process::std_err > stderr State.CurrentInterface = InterfaceType::Confirm;
); State.SubmitCommand = [&]
process.wait(); {
}; auto [nproc, nthr, ncpu] = QueueConfig.at(State.QueueEntries[State.QueueSelected]);
auto args = std::vector<std::string>
// 进入事件循环 {
while (true) "bsub",
{ "-J {} -o {}"_f(escape(State.JobName), escape(State.OutputFile)),
screen.Loop(request_interface); "-q {} -n {} -R 'span[hosts=1]'"_f(escape(State.QueueEntries[State.QueueSelected]), ncpu),
if (state.user_command == "quit") "vasp-intel mpirun -n {} -x OMP_NUM_THREADS={} vasp-{}"_f
return EXIT_FAILURE; (nproc, nthr, State.VaspEntries[State.VaspSelected])
else if (state.user_command != "continue") };
throw std::runtime_error("user_command is not recognized"); return args | ranges::views::join(" \\\n ") | ranges::to<std::string>;
state.bsub = fmt::format }();
( }
"bsub -J '{}'\n-q {}\n-n {}\n-R 'span[hosts=1]'\n-o 'output.txt'\nchn_vasp.sh {}", else if (!State.UserCommand) return EXIT_FAILURE;
state.job_name, else std::unreachable();
state.queue_entries[state.queue_selected], }
state.ncores.empty() ? state.max_cores[state.queue_entries[state.queue_selected]] : else if (State.CurrentInterface == InterfaceType::Confirm)
std::stoi(state.ncores), {
[&] State.UserCommand.reset();
{ Screen.Loop(InterfaceConfirm);
auto version_level1 = state.vasp_version_entries_level1[state.vasp_version_selected[0]]; if (State.UserCommand == UserCommandType::Quit) return 0;
auto version_level2 = state.vasp_version_entries_level2[version_level1] else if (State.UserCommand == UserCommandType::Back) { State.CurrentInterface = InterfaceType::Request; }
[state.vasp_version_selected[1]]; else if (State.UserCommand == UserCommandType::Continue)
auto version_level3 = state.vasp_version_entries_level3[state.vasp_version_selected[2]]; {
return fmt::format // 提交任务
( log.debug("submit command: {}"_f(State.SubmitCommand));
"{}{}_{}", // -c 对 \\n 的处理与通常情况下不同,我们需要用 -s 然后将命令通过标准输入传入
version_level1, biu::exec<{.SearchPath = true, .Stdin = biu::IoType::String}>
version_level2 == "(default)" ? ""s : "_" + version_level2, ({.Program = "sh", .Args = { "-s"}, .Stdin = State.SubmitCommand});
version_level3 break;
); }
}() else if (!State.UserCommand) return EXIT_FAILURE;
); else std::unreachable();
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;
}
} }

View File

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

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
'';
}

View File

@@ -61,7 +61,7 @@ int main()
std::string text; std::string text;
std::optional<std::uint32_t> reply_id; std::optional<std::uint32_t> reply_id;
// 如果是转发,则直接写链接 // 如果是转发,则直接写链接
if (!content.body.note->text) if (!content.body.note->text && content.body.note->renote)
text = "转发了[帖子]({}/notes/{})"_f(content.server, content.body.note->id); text = "转发了[帖子]({}/notes/{})"_f(content.server, content.body.note->id);
// 否则(引用或普通帖子) // 否则(引用或普通帖子)
else else

View File

@@ -5,6 +5,7 @@ std::optional<std::int32_t> missgram::tg_send
(std::string text, std::optional<std::int32_t> replyId, std::vector<File> files) (std::string text, std::optional<std::int32_t> replyId, std::vector<File> files)
{ {
using namespace biu::literals; using namespace biu::literals;
biu::Logger::Guard log;
// 整理要发送的信息 // 整理要发送的信息
TgBot::Bot bot(config.TelegramBotToken); TgBot::Bot bot(config.TelegramBotToken);

1
packages/ufo Submodule

Submodule packages/ufo added at 19736049c9

View File

@@ -1,44 +1,46 @@
{ stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl }: { stdenv, src, writeShellScriptBin, lib, rsync, which, wannier90, hdf5, mpi, mkl, prrte }:
let vasp = stdenv.mkDerivation let
{ vasp = stdenv.mkDerivation
name = "vasp-intel"; {
src = src.vasp; name = "vasp-intel";
patches = [ ../vtst.patch ]; src = src.vasp;
configurePhase = 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 export PATH=${vasp}/bin:${mpi}/bin:${mpi.dev}/bin:${prrte}/bin:${prrte.dev}/bin''${PATH:+:$PATH}
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}
# set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set # set OMP_NUM_THREADS if SLURM_CPUS_PER_TASK is set
if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then if [ -z "$OMP_NUM_THREADS" ] && [ -n "$SLURM_CPUS_PER_TASK" ]; then
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
fi fi
# set OMP_NUM_THREADS to 1 if not set # set OMP_NUM_THREADS to 1 if not set
if [ -z "$OMP_NUM_THREADS" ]; then if [ -z "$OMP_NUM_THREADS" ]; then
export OMP_NUM_THREADS=1 export OMP_NUM_THREADS=1
fi fi
# set OMP_STACKSIZE to 512M if not set # set OMP_STACKSIZE to 512M if not set
if [ -z "$OMP_STACKSIZE" ]; then if [ -z "$OMP_STACKSIZE" ]; then
export OMP_STACKSIZE=512m export OMP_STACKSIZE=512m
fi fi
exec "$@" exec "$@"
'' '';
in wrapper // { passthru = wrapper.passthru // { inherit mpi; }; }