mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:19:22 +08:00
Compare commits
390 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b201a19c75 | |||
| 1854e294cf | |||
| b45a9c7a62 | |||
| 858f4c68aa | |||
| 37e6d70561 | |||
| f101038f4a | |||
| 412fac9692 | |||
| 4c7d17f001 | |||
| e8d80daee2 | |||
| 8aeb290d0f | |||
| 0f37c886a4 | |||
| 5940da526d | |||
| df2ac86e1a | |||
| 8bf7e2cb30 | |||
| 96f7056d16 | |||
| 5cc40727db | |||
| c4f8e5f61c | |||
| 03be19da5a | |||
| 7657fe3d14 | |||
| 9fee2a8e2a | |||
| db1e825cd6 | |||
| 670126ba0c | |||
| 92ddf86df1 | |||
| bd12de34b7 | |||
| a7b0906488 | |||
| 0ce31201a9 | |||
| 58d927b648 | |||
| 5efee599f7 | |||
| 2c833934e7 | |||
| c5dc456c35 | |||
| 7576726fbe | |||
| 6dfd6a8bf0 | |||
| eb68d8f8b1 | |||
| 46ae9f1aac | |||
| bb5aee5545 | |||
| a8833dac7f | |||
| d1b3f84cf3 | |||
| f813ffd053 | |||
| 00c99adca9 | |||
| ef58de9a1d | |||
| b9175a211f | |||
| 0cb7791b84 | |||
| 803af74404 | |||
| c5da42debd | |||
| e16f49b3f3 | |||
| f10c385f13 | |||
| f65ec24862 | |||
| 73261c3e3f | |||
| e50ad89bc2 | |||
| 5f4a79788d | |||
| 1360a3e9fa | |||
| d692bb8baf | |||
| dbcf7093aa | |||
| 7833f37588 | |||
| 673f241490 | |||
| a5be9adb53 | |||
| d6a1da17fb | |||
| 6e0e224530 | |||
| 1a007ab57f | |||
| da76976c3d | |||
| b46f928964 | |||
| 92fdc6c67d | |||
| 2534f35c4d | |||
| f9e376920c | |||
| c335a79b19 | |||
| 2d27006978 | |||
| dd1fb05917 | |||
| 6d814881c4 | |||
| ee18e481ba | |||
| 80ef9571db | |||
| de68b75268 | |||
| 423debe893 | |||
| 076a267ba4 | |||
| 2b88a1e32c | |||
| d8672ea42e | |||
| 7bd6e1f529 | |||
| 3d9af79476 | |||
| 734eedef2a | |||
| dd767f275a | |||
| 416eac129b | |||
| 11171c048a | |||
| e070046fc4 | |||
| b6ee3723d6 | |||
| b731752700 | |||
| 8f09a18dc5 | |||
| 1949ea7d78 | |||
| fb4a9644fc | |||
| 354f7d428e | |||
| 74b6155013 | |||
| 115a7f7753 | |||
| 98eb945684 | |||
| f1c8f8f1bb | |||
| 50da5ffa0b | |||
| b5a4aee761 | |||
| 64532717da | |||
| cc303a082c | |||
| 9e81d5a64f | |||
| c2d54a2b73 | |||
| 4e8452e9e0 | |||
| 9bf65a7a11 | |||
| 861d56ac7a | |||
| d51414e341 | |||
| 61afb76cfe | |||
| 1886f7e647 | |||
| 0a2e7e04e5 | |||
| 7dad1d3ec2 | |||
| 93ad14cc26 | |||
| b39fb0b8e0 | |||
| 30c25c499c | |||
| 4e8b18b417 | |||
| 4779d5e162 | |||
| 3b018c90e6 | |||
| 1dd9a61c95 | |||
| 705a43fa41 | |||
| e01a69e039 | |||
| 682bba4af9 | |||
| b04f527ee1 | |||
| c6d67af8c7 | |||
| 6275f6a519 | |||
| 5baa1ad173 | |||
| 1166dfbbcc | |||
| 5b183a5446 | |||
| 8e3eca38d7 | |||
| f74895585f | |||
| 4a0c5eee5a | |||
| 77296face8 | |||
| eb4cac0f14 | |||
| 7f343ce440 | |||
| 1b42c688ef | |||
| a94a7d368e | |||
| 1429950370 | |||
| f8b5a79afe | |||
| 759b3f7cae | |||
| a9931623b1 | |||
| d0213f48c1 | |||
| 24e8a94e7c | |||
| 0bc485a9b1 | |||
| ba523b61e8 | |||
| c40888a9b9 | |||
| e49d7b4055 | |||
| 4cba5c0160 | |||
| 837c6ff2d5 | |||
| f95c059ece | |||
| f6b40a3f3a | |||
| 5f0ea6f428 | |||
| d90e74c8df | |||
| c3647caacc | |||
| 5a07c21eac | |||
| f31dcbc640 | |||
| 37d90d0ed2 | |||
| 9ef2be228d | |||
| 4a2c0778e3 | |||
| a4c519c882 | |||
| 212869fe29 | |||
| 7afafdaac5 | |||
| 7c6709e70c | |||
| 0e972642be | |||
| 4939db84f0 | |||
| 964028dbe5 | |||
| 307fe81b15 | |||
| 9eea7cb2dc | |||
| 6dca3f3acf | |||
| 9d083566ed | |||
| 02b4a10ceb | |||
| 9617f19292 | |||
| b4b7ebf6fe | |||
| e8a45f91c8 | |||
| 0114927adf | |||
| 5a52292a97 | |||
| 578c2c9646 | |||
| 3059b012f7 | |||
| 9c80e754b2 | |||
| e908765aa8 | |||
| aa050c681a | |||
| e65fa2dc60 | |||
| 6011a2ba9f | |||
| 7281962001 | |||
| 215dbe7669 | |||
| 9f27c9dbc9 | |||
| 37c5678862 | |||
| f414a79a01 | |||
| 6690870fd3 | |||
| be49ac36ac | |||
| 0a55220e4e | |||
| 351623206d | |||
| 8848862e55 | |||
| 9b3db9f446 | |||
| a2166f8090 | |||
| eb01b0532c | |||
| bbad8cc650 | |||
| 779de003aa | |||
| b7ffc2cbe2 | |||
| 74872ec80a | |||
| 6c286cd402 | |||
| a24b38c4a6 | |||
| afeeade925 | |||
| 4334f84710 | |||
| a0735f00e4 | |||
| d77fd05405 | |||
| e0bec05c59 | |||
| 7aeb283101 | |||
| 745525f41f | |||
| 08e99e9fe1 | |||
| 45551ba438 | |||
| 5ddf6cebaa | |||
| e2b2801a37 | |||
| e71c7ef993 | |||
| 2c5e6fb4f0 | |||
| f5f5dd5724 | |||
| cf00062fab | |||
| 0a672ca144 | |||
| 7c1fba7939 | |||
| 525147f9d4 | |||
| 5f12da16ec | |||
| 62d3c7ed4a | |||
| 9333bd01d4 | |||
| c7eb349ca2 | |||
| ddd4cd667d | |||
| f97fad608d | |||
| 8115d2a0c6 | |||
| dd01486bb4 | |||
| c30304abac | |||
| 6e736c8093 | |||
| eb97197d0d | |||
| 629980e81b | |||
| 174e893fbb | |||
| 57fdb9ff6e | |||
| f14ea18b30 | |||
| 224026ed3c | |||
| c509149fbe | |||
| dc3e9819fd | |||
| ade11c0e06 | |||
| 0844e08bc9 | |||
| 7556cd2879 | |||
| 8989e30455 | |||
| 374c1ef112 | |||
| 3945a494f2 | |||
| bb11c24eaa | |||
| 95d54a1a0f | |||
| aa635de7f2 | |||
| 4e19f686b8 | |||
| f172f3d44a | |||
| 474990323c | |||
| d00729a7bf | |||
| 39636c14c8 | |||
| 449e62b52c | |||
| 6ffabba263 | |||
| 1e4077af0c | |||
| 0743dc3255 | |||
| dbd2833bfd | |||
| 386a46e884 | |||
| e5020092da | |||
| 57d09cb3ba | |||
| c274af61a5 | |||
| 19e3acc4f4 | |||
| 965d6b01aa | |||
| 0cb75a802a | |||
| db04febfa2 | |||
| 1a35c9e742 | |||
| 47ab4876b5 | |||
| d0839dc726 | |||
| c8ed0a7a02 | |||
| b492c82b45 | |||
| 22464c272a | |||
| f58e2e3eba | |||
| 4af5512f85 | |||
| ec9d89a592 | |||
| 7785cea534 | |||
| 355ccbbcc7 | |||
| 9c678b4e0c | |||
| 5dd21a1b44 | |||
| 0ab4353016 | |||
| 01711bd339 | |||
| 8caee452ad | |||
| 4c71ca5642 | |||
| 89ad32bac6 | |||
| 731756cd38 | |||
| e4bab2b5d5 | |||
| 0bf23f71e9 | |||
| 7ed3355f62 | |||
| 18cf44e270 | |||
| 38697d89a7 | |||
| 1d7b25f2f1 | |||
| 4ec6fe4a27 | |||
| 29420a8521 | |||
| 1291cda91f | |||
| c7d2badc74 | |||
| 9b2e8dc472 | |||
| fdee36fb97 | |||
| b5753b7b05 | |||
| aaeea6a22d | |||
| 7b40f61b8a | |||
| 7197e19188 | |||
| 815dfaab7e | |||
| 4e4f32c82e | |||
| 2335a510dc | |||
| 06f2ec22d3 | |||
| 93f11a5776 | |||
| 5047ae84a0 | |||
| dbf23db014 | |||
| b5d6f29a3a | |||
| 440fe83e22 | |||
| 972f33599b | |||
| 3aa9fbc75f | |||
| 14232bf369 | |||
| a31c7e5485 | |||
| 72e14db25f | |||
| c82cc289b0 | |||
| 4c9b3cf6cb | |||
| 4e90a8aa47 | |||
| 6a5888d63e | |||
| 483df46bfa | |||
| 03c4161725 | |||
| b815650666 | |||
| d69f2911cc | |||
| 3a49f53714 | |||
| 668e5a2ea3 | |||
| 118ff59ce2 | |||
| 9941446351 | |||
| bd32f705bc | |||
| 46f109cce1 | |||
| 2bc088ce85 | |||
| a9df0cabda | |||
| f9ebd70b38 | |||
| ed8ec81674 | |||
| 10495ee0cd | |||
| 41cf7f2c63 | |||
| b28255e866 | |||
| a661584161 | |||
| 055f63f0c9 | |||
| fd120e0ca9 | |||
| 045f7ec30e | |||
| e0f992ead9 | |||
| ba2ac91a4d | |||
| 788f44f6a0 | |||
| 7d72356996 | |||
| 451da06005 | |||
| 4516bf7d69 | |||
| 10cc12788c | |||
| 6066245021 | |||
| 0dfb95d722 | |||
| bdcb968392 | |||
| e999735cd6 | |||
| c136bd2243 | |||
| 387b82d0d1 | |||
| a2d2422b92 | |||
| 4753d78ed3 | |||
| 4cb8ae548a | |||
| 008fc61887 | |||
| ecadca93b3 | |||
| ec85e19bb1 | |||
| 87a8e7eb84 | |||
| fc6a692bfc | |||
| 4f79141d1b | |||
| 9ab1997e78 | |||
| 348830084b | |||
| 3302666b76 | |||
| 3b858d88ea | |||
| 9efe69151c | |||
| f1e2be106e | |||
| 7533ef13cc | |||
| 422c1f7615 | |||
| e5fd732788 | |||
| 58786cef0e | |||
| 3ce244eb30 | |||
| ffad809c4a | |||
| 9719e19879 | |||
| 30415da2d1 | |||
| 4c5e3f696c | |||
| aff9b29c1c | |||
| 47cd032906 | |||
| 1fe31395f6 | |||
| 79926e1a7a | |||
| 5255cb2845 | |||
| 139405b891 | |||
| 1a109ff0f9 | |||
| 1d295d2cbb | |||
| 4e82ca7811 | |||
| 2d1bfb84eb | |||
| 42f84e2f6d | |||
| ff84538460 | |||
| ea9170e3d3 | |||
| dc48d30d75 | |||
| 83e54aa09d | |||
| 6920f5d845 | |||
| 405dc14ce7 | |||
| eb8ea76980 | |||
| fc41506c1f | |||
| 3e7a50df5f | |||
| 21a4afe164 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
result
|
||||
result-man
|
||||
result-*
|
||||
outputs
|
||||
.direnv
|
||||
build
|
||||
|
||||
3
devices/jykang.xmuhpc/.bash_logout
Normal file
3
devices/jykang.xmuhpc/.bash_logout
Normal file
@@ -0,0 +1,3 @@
|
||||
if [ -z "${CHN_DEBUG-}" ]; then
|
||||
hpcstat logout
|
||||
fi
|
||||
3
devices/jykang.xmuhpc/.bash_profile
Normal file
3
devices/jykang.xmuhpc/.bash_profile
Normal file
@@ -0,0 +1,3 @@
|
||||
if [ -f ~/.bashrc ]; then
|
||||
. ~/.bashrc
|
||||
fi
|
||||
42
devices/jykang.xmuhpc/.bashrc
Normal file
42
devices/jykang.xmuhpc/.bashrc
Normal file
@@ -0,0 +1,42 @@
|
||||
# This is really FOLLISH but it works
|
||||
if [ -z "${BASHRC_SOURCED-}" ]; then
|
||||
if [[ $TERM == chn_unset_ls_colors* ]]; then
|
||||
export TERM=${TERM#*:}
|
||||
export CHN_LS_USE_COLOR=1
|
||||
fi
|
||||
if [[ $TERM == chn_cd* ]]; then
|
||||
export TERM=${TERM#*:}
|
||||
cd ~/${TERM%%:*}
|
||||
export TERM=${TERM#*:}
|
||||
fi
|
||||
if [[ $TERM == hpcstat_subaccount* ]]; then
|
||||
export TERM=${TERM#*:}
|
||||
export HPCSTAT_SUBACCOUNT=${TERM%%:*}
|
||||
export TERM=${TERM#*:}
|
||||
fi
|
||||
if [[ $TERM == chn_debug* ]]; then
|
||||
export TERM=${TERM#*:}
|
||||
export CHN_DEBUG=1
|
||||
fi
|
||||
|
||||
export HPCSTAT_DATADIR=$HOME/linwei/chn/software/hpcstat/var/lib/hpcstat
|
||||
export HPCSTAT_SHAREDIR=$HOME/linwei/chn/software/hpcstat/share/hpcstat
|
||||
export HPCSTAT_SSH_BINDIR=$HOME/linwei/chn/software/hpcstat/bin
|
||||
export HPCSTAT_DUC_BINDIR=$HOME/linwei/chn/software/hpcstat/bin
|
||||
export HPCSTAT_BSUB=/opt/ibm/lsfsuite/lsf/10.1/linux2.6-glibc2.3-x86_64/bin/bsub
|
||||
${HPCSTAT_SSH_BINDIR}/hpcstat login
|
||||
if [ "$?" -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /etc/bashrc ]; then
|
||||
. /etc/bashrc
|
||||
fi
|
||||
|
||||
if [ -z "${BASHRC_SOURCED-}" ]; then
|
||||
export PATH=$HPCSTAT_SSH_BINDIR:$PATH:$HOME/bin:$HOME/linwei/chn/software/scripts
|
||||
export BASHRC_SOURCED=1
|
||||
fi
|
||||
|
||||
[ -n "$CHN_LS_USE_COLOR" ] && alias ls="ls --color=auto"
|
||||
15
devices/jykang.xmuhpc/.ssh/authorized_keys
Normal file
15
devices/jykang.xmuhpc/.ssh/authorized_keys
Normal file
@@ -0,0 +1,15 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXlhoouWG+arWJz02vBP/lxpG2tUjx8jhGBnDeNyMu0OtGcnHMAWcb3YDP0A2XJIVFBCCZMM2REwnSNbHRSCl1mTdRbelfjA+7Jqn1wnrDXkAOG3S8WYXryPGpvavu6lgW7p+dIhGiTLWwRbFH+epFTn1hZ3A1UofVIWTOPdoOnx6k7DpQtIVMWiIXLg0jIkOZiTMr3jKfzLMBAqQ1xbCV2tVwbEY02yxxyxIznbpSPReyn1RDLWyqqLRd/oqGPzzhEXNGNAZWnSoItkYq9Bxh2AvMBihiTir3FEVPDgDLtS5LUpM93PV1yTr6JyCPAod9UAxpfBYzHKse0KCQFoZH chn@chn-PC
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDWAfyfDFctbzJTiuK9IPw3yFLqt7vqd/T0/HoZfH/bzLZ8GVeod2oz6kjm3ns0IG94HO5vGMEmQfbK1ZKT2TqA7ve+3wG9seiwfh8xh7Xhl2AnaF0pjHEXnw+w8mTzxCv9qRhsgfHuuBVhH6PguHvk66GKjvNaxTJhlKAyNogOI3jLnw7ODFScldHbJlMYl1pBHV/G/Zeuq0qnA/pkeiFdvlsZUVGD0cCfuoHm8FCfEzv6pfkhVJUH0v5rof8GiT9eg7ntG49Gei1lkH5NosbY8f6fEKNSoOc0dm5g2FaI3D7LJixwQ6rMiJwmPb6A4oHmcJQKokU8uhROQorYLgV7RtrnHu2cHMRW6SiAUvpmvaPPcxn8CbfuSOGDhYRKxNJNtWRK08Urtq9tYD+Fpze4QoZXxN35uvsi3lMA55PK0AsTm/aVGslzHUUzgWtDxcI2pLAm9rFpCRPCY+UC1Xp5vjZoqZXwhJ81qZ7VXWTM2voxCrKAlu+Zg2FaQD5szOU= gb@xmupc1
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDJ/jzUQ6QuAjnAryvpWk7TReS6pnHxhEXY9RonojKkurhfYSQO/IlxDMDq23TFXcgu8iZG4cS6MADgx/KNZD/MjuN9YNCIEGvMwzWvB0oM25BC6Vf3iKDmhH06rZKH6/g5GN+HWoCN4yE/+MhIpegFO3+YMpveXwEESlyoIjPvcW+RwmlNJevrHd83ETYDQ4AybWyJo6en5tz2ngr22HaK4MtxgrqnIN/KorY+nrzTNa7VBC7BaZc1tA5FLwUeCXtuzp2ibfrxoGUAiDig4FW09ijCk3Y77y7aNVI2nw5y28nCV5rgVMh5fejtNVqIqku7p+8qgjxvY6veATG0lYgZgw2ldnDGDNbEGxcCnKKmCgZMxok8zTRsniZ91KuHkcl2L7xUo7kdQYzBRwZyQ53eW+yPoqUya4yn272rscBEUMyZzmegfr1SXMqw/8zn+MZdr1KXEvrbfjX+2QL52GY3bfYUf3KFje+Sp88k688bRH0vrxj9BCOS7ovbyfe9BEU= xll@xmupc1
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCtnVhZQsJfbs2w9hFZkx4qDhIs++7no+6r5TifP3Dq7epJYd2QYx4dI66XxTNhKxZjN6a4Xn5nFlYLtQJXOvzBLC8IBf1W5GCH0k/jqzzskS0/Ix/70HzcBwJk8ihWDkyON5Ki1BRCx34RNxth1BIxWyc5QT+lou+D92x8iAu/uOvmcAL3Ua0OlZwxw03hLp/PpS4ZnUqFjc2JVtarY7eQu/i3RwOZUaK6nT2EL8RObzk4xnieqsU5PWwA3voVjetqZaDQ+P7dimQXz/FaucroKxCNyTiy1oG4fdQpm2UDrH6ZfPvdQLYrtet6FQabXOxhV7MuR3jYtxZjs1kDVZIseIZ6IwjetaUoMxvIouRfYjOSIEo9Ek9o0+Yhku4r0uWmPDrymWugU1raMmlRxSUwdlzW+C7mQwtGbs/MG4MN4GWkM6id5DKlY2vYKUfrTzmhY1swCtzKq20fjvyX8qhJdcytgVlOrBZnPje6Qd55sI0RjdgJrBsxT2SYquez7U8= yjq@xmupc1
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDn1pfGen7kjPTHsbb8AgrUJWOeFPHK5S4M97Lcj3tvdcjZi2SXN6PwHQfh8/xGhZbTLPz/40S9O9/Dn30xkUTfnONirKt790jp7VEbOtPnjQPOd/KRNWlS3VV0BELuq5p633Mi13rP6JZtdKmU2uSkvvaUBfCppy3JaWv/B7HLJ48f8IzkdiT1px3dN1eQ4SFoHOiVG0ci5TGG6wfMdoAAnM9R1aXI4gDxnYjLYujpaNZ4hBOta/6ZK/PV0JufoXdIAZjubgk1Hv04XHXLR2Z0UhRM6x7UrZIOdM/LlnKmcVk408ZKEj/9m1xRyDsNoZ24CF++cmnwfBHrp9I5nvDI7xOTdZlOhzkiiPM3f4i6s2Qjdv4vpZ6AeE3Qt1LVQyAr67b4UMjHuYqSi2KgyCO6My2Ov2eRoS74EKcb8ejJv3O+XInmYUgDgTgDFT3CgQgK2DG45HiV6nOkaE/6iKx2JSOiYZTFc7TRcePfXF9JQD7dXFde6qm3EbIVyJIpCJ8= zem@xmupc1
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCW2fx1Sim7X2i/e/RBPEl1q/XbV7wa9pmZfnRINHIv24MCUgtNZ5GHEEW7dvzrQBeRj3I7CAyK8fbuhv/l8HuDtjxJJ1fmcBp9UG5vfpb/UTxayJxHBRrwokp2JL7HKVviI6d8FcNa/T0CMoUNYXnel6dE3B78k9Q0dDxlOGS1MzgsP3Pn66lm0ww9FRAVHe+KkhFmwyQ1VHUxHgK4QjCIt7+9+PJE7fK0aVWBsR309pui7Pbm6mgd4d6mwiBeVvxsNGnI4DsO1hz4N2GapuQy19PDiG7A4H41Z5RYQnv/3XTy4TBXOFQm77v6pyGkCmG6BGnRdvMB6C0hWPJvudbsA/BNp4ApL7/CrwTdLp1z6ToAOLvKrUQAM+hcbJimnFVMXqz7iSYg99XTnzue7ncecp19XiaDJbM47bGXcT4nTO5XaiMYi2xGAHIrij5GIuFF5ymKYSp5ejb1VucMdKlaaAmS10+wdUcuT7tzX/IuVr5aqg2dsxT5aJCRhZ1k2V0= xly@xmuhpc
|
||||
|
||||
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
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDkT/P4MnzxBh8sRi0oQ88duNpY/ejFtptGqUQJVobj23vbu7ju6x/yuXqnHFOLi/IOZgNl5oBhRlJekRL+FWMIwpPBA6MnbVNkHXvwu5kLXVTt0O9dhJfDiPPbYcNjOhw4o8aZMc0oEyz8xZgkPoIehHQda+K5vRhFnYCRgn2X92VY/dW1QqPJKEfN47Tsp00w8wyKixEvuJe8OBEoKDpiZYzbXJKuoKhCdMp0uMHMCojYuYP9rGZO6bHl7Q6cYotGx1jH2pe30Ujtm3Xbm44H1mhXr1K/lhcHfojSge8POqii+eaXSCzqRlXaWyvrL9JLaaRD7GfWDaRWSKDfN8Ha4mnUvRtObRMSLOnr2QOTLJw9QPnlDDxCd1q7yluKraccYnTQQP5JuBwkRqjuJTatd9b18Z14HffmXZNR7asT1sJXK1rWKeLTrZwqxpkuwLAnbr60PVwfMHZeZ6FVPXGZ4wQb22lFHvaZZCEJf+9QDXpDn5L59FlaBYO2Xwojj3s= 02@xmuhpc
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOF3LfnQiI8wpsXGn87bt7rbUZcgsdaOSOswk4Vf4dBautEdQZc0q+UDB2TlR2K8L7SPyywpl5z67euN5QRJLEwg8flTybiJp3EKDctYEM22sa36ONcSIJ/iHSdCkwtPXkBYreh9e+MAHfTroIKK5zM/P1QIN3NrknIXpWjLDF73ejrxE+EXRK6jbuWfo+5dnLnDoUFt1e+pYLZos5KRRB94Qt5I79D/cAg3hG+Zl2FCCOpn1hIdLo/kWJTKUPe61oUaIxriV6nCXp/pU1BHlM43hGowiHa4bVZIs8Eo4r7OI9thhSuS2BKSifibBKIicZtntSlS/I3xa5am28YLmrOiEXRsjPom7trO8qIhPfYOc/yFDg1gcpLxyNroCPooPBzPxUqrTT96Q4fDDTaqfyuVxQFxbYoFAqQs8/lw6WcGJ4fGC5JPsPiwoSdQy/B7gCfQcFjPXp1NH8Sx+xMLCmxRqdKSyeiEwoyB0tZ6ngaI73HFhCPX1/rLx3xv0zd/8= 03@xmuhpc
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC96jp6qFrWt4651Arg+Ua6AU3CjftZuounKLlZ8s268Lo9Cba+nmoOGRNzefqr+f6/7KmFKd9+jqS3ZnKFQbzRFVzzHHIT7tSlgxFRw+yb553/vgm7z6d0HGd3B7XjpIpR7DrM/unnXtiT/WuX+UIKKQ1S4kHp4fTJxZuwzYgNWDsT7O/5H7nBoRVuUSG/achCzTq5V5WfNjvrGZypCmcCw5MTH3Iab4qQ7fhRK46e/OpgSMmsY1ZuEynIwVtimW4G10MUWZdawN4LHBNsCDBmBu0H1DYBb9AUW5IuifAyFPPlTOPtuzpEganaMwotcXiAwhfPQg1c0TfbB4ZJPow612dzxcflHAJyFy2LXbiG0rF48h0GpW5gY92QkeMQcbybKOS5yVlXynNNg0nL1bx+reu7Fy4jurc0facTaqzpSiyXsBLSOva+DZrxl2MBDLEdykkQMNIY69GeeC2XIN4tbfGDYU8VVtwnXJUkmeHAge5ypI1kkPhYRDxPDspym9M= 04@xmuhpc
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9FmT0i2j9JsnyeVrEZP8gaWHnc5NnhJgb1sP8MP/pjx/GMEkms2LQvZYNw8MQvGA6HH/O2acy5NIdD69QkRlALXZlWpUQco8JDuJe7+2xkTMGPOAqB5YLMHRpFGHUmDMuSFGSg2YyLXaWXoWmib5xAvTL95xAcdNgp5xqWvO2N55edDeVOY5cTmIE2vC0nm5JSjMEMcIuqL8yJ3AweN4JkD8CVVy3po8f+krKsaYB+f21MqqSnCQ/cpKlWHuMN9k85hP/FB1E7gBXW/MuZ1uOm4IzjBhj8tYVN0UY7Mo2/9PhFqoBKGr6vs7Nx1mXBJ/A1lIKvW+ROvQ9ADpOfww6kPuHbX16gQ55JG7zneWeiP5pVaI4YZ4O1vAvARw/SaSFhRdpymPs5r+wdIDV9gGoqORrYqoPBz7Q02V71W+EV7WFAgxiJozO0vZwD9JJ2zivyIJfcVtIOMIvEhfsha7Hviut4JIOyoaEHjIZYsmvYHEeEBA4pTUHIUZlZj/St7U= 05@xmuhpc
|
||||
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJRWge2+B1Et03n/B4ALBcAnjvtWPPmcFAoIlLP8oFkB hpcstat
|
||||
165
devices/jykang.xmuhpc/.vaspkit
Normal file
165
devices/jykang.xmuhpc/.vaspkit
Normal file
@@ -0,0 +1,165 @@
|
||||
# cp how_to_set_environment_variables ~/.vaspkit and modify the ~/.vaspkit file based on the settings in your supercomputer!
|
||||
# All environment variables are case sensitive.
|
||||
VASP5 = .TRUE. # .TRUE. or .FALSE.; Set .FALSE. if you are using vasp.4.x
|
||||
LDA_PATH = /data/gpfs01/jykang/linwei/chn/software/vaspkit-1.4.1/POTCAR/PAW_LDA
|
||||
PBE_PATH = /data/gpfs01/jykang/linwei/chn/software/vaspkit-1.4.1/POTCAR/PAW_PBE
|
||||
GGA_PATH = /data/gpfs01/jykang/linwei/chn/software/vaspkit-1.4.1/POTCAR/PAW_PW91
|
||||
VASPKIT_UTILITIES_PATH = /data/gpfs01/jykang/linwei/chn/software/vaspkit-1.4.1/utilities
|
||||
PYTHON_BIN = /data/gpfs01/jykang/linwei/chn/software/scripts/chn_python3.sh
|
||||
POTCAR_TYPE = PBE # PBE, PW91 or LDA; Set PBE if you want to make PBE-POTCAR file
|
||||
GW_POTCAR = .FALSE. # .TRUE. or .FALSE.; For example, H_GW, O_GW will be chose when POTCAR_GW set to .TRUE.
|
||||
RECOMMENDED_POTCAR = .TRUE. # .TRUE. or .FALSE.; The recommended PAW potential will be chose when RECOMMENDED_POTCAR set to .TRUE.
|
||||
SET_FERMI_ENERGY_ZERO = .TRUE. # .TRUE. or .FALSE.; The Fermi Energy will be set to zero eV when SET_FERMI_ENERGY_ZERO set to .TRUE.
|
||||
SET_MINI_INCAR = .FALSE. # .TRUE. or .FALSE.; A simplified INCAR will be written when MINI_INCAR set to .TRUE.
|
||||
USER_DEFINED_INCAR = .FALSE. # .TRUE. or .FALSE.; whether to use embedded INCAR templates or user defined INCAR templates
|
||||
WRITE_SELECTIVE_DYNAMICS = .FALSE. # .TRUE. or .FALSE.; the selective dymanics set will be forced to write when SET_SELECTIVE_DYNAMICS_MODE set to .TRUE.
|
||||
GET_DOS_FROM_HYBRID_BAND = .FASLE. # .TRUE. or .FALSE.; whether to calculate DOS using optimized tetrahedron method in the hybrid band strucutre calculations
|
||||
ADVANCED_USER = .TRUE. # .TRUE. or .FALSE.; Please fill in your settings in the block 'USER_DEFINED' if you want vaspkit to integrate your own scripts in the 'UTILITIES' file.
|
||||
SET_INCAR_WRITE_MODE = OVERRIDE # OVERRIDE, APPEND, BACK-UP-OLD,BACK-UP-NEW; "Customize INCAR File" whether to override existing or appending existing INCAR/backup existing INCAR to INCAR.old && write into INCAR/write into INCAR.new
|
||||
APPLY_SCISSOR_CORRECTION = .FALSE. # .TRUE. or .FALSE.; whether to rigidly shift of the conduction band with respect to the valence band of nonmagnetic semiconductors to matches with that of the experimental, HSE or GW value (default: .FALSE)
|
||||
APPLY_PHS_CORRECTION = .FALSE. # .TRUE. or .FALSE.; whether to make PHS correction during linear optical calculations. More details are given in Comput. Mater. Sci. 172 (2020) 109315
|
||||
NORMALIZE_ORBITAL_WEIGHTS = .FALSE. # .TRUE. or .FALSE.; whether to normalize orbital-projected weights in each state (default: .FALSE.)
|
||||
REORIENTATE_LATTICE_VECTORS = .FALSE. # .TRUE. or .FALSE.; reorientate lattice vectors when build supercell or heterojunction or not (default: .FALSE.)
|
||||
GET_IRREDUCIBLE_KPOINTS = .TRUE. # .TRUE. or .FALSE.; Control whether to generate k-points in the symmetry-irreducible wedge of the Brillouin Zone (default: .TRUE.)
|
||||
FACTOR_ENCUT2NPWS = 0.262465831d0 # Adjust the final decimal place (or one beyond that) of this parameter if you encounter an error message saying that “Error: the calculated NPWS is not equal to the read NPWS”.
|
||||
SYMMETRY_TOLERANCE = 1E-5 # Tolerance in Cartesian coordinates to find crystal symmetry, compatibility with SYMPREC (default: 1E-5)
|
||||
LATTICE_TOLERANCE = 0.2 # Float lattice tolerance for the lattice vectors (default: 0.2 angstrom)
|
||||
ANGLE_TOLERANCE = 0.2 # Float angle tolerance for the lattice vectors in degrees (default: 0.2 degree)
|
||||
EMIN = -20.0 # Minimum energy for evaluation of DOS (default: -20.0 eV)
|
||||
EMAX = 20.0 # Maximum energy for evaluation of DOS (default: 20.0 eV)
|
||||
SIGMA = 0.2 # The width of the smearing to calculate DOS from eigenvalue (default: 0.2 eV)
|
||||
NEDOS = 2001 # Number of grid points in DOS (default: 2001)
|
||||
GAMMA_CENTERED = .TRUE. # .TRUE. or .FALSE. (default: .TRUE.).
|
||||
VACUUM_THICKNESS = 15.0 # The thickness of vacuum to build slab or 2D materials (default: 10 angstrom)
|
||||
CENTER_SLAB = .TRUE. # Center the slab in the z direction; (default: .TRUE.)
|
||||
|
||||
# New added in Version 1.3.0
|
||||
MAX_ATOM_NUMBER = 10000 # The maximum number of atoms to screen heterostructures (default: 10000)
|
||||
MIN_ATOM_NUMBER = 1 # The minimum number of atoms to screen heterostructures (default: 1)
|
||||
MIN_LATTICE_ANGLE = 0.0 # The minimum lattice angle to screen heterostructures (default: 0.0)
|
||||
MAX_LATTICE_ANGLE = 180.0 # The maximum lattice angle to screen heterostructures (default: 180.0)
|
||||
GET_INTERPOLATED_DATA = .FALSE. # .TRUE. or .FALSE.; Whether to interpolate the grid data of charge/spin density, potential, band structure, etc. (default: .FALSE.)
|
||||
INTERPOLATION_SPACING = 0.04 # Determines the number of interpolation grids, in unit of A in real-space or 1/A in reciprocal space (default: 0.04)
|
||||
INTERPOLATION_METHOD = 'cubic' # 'linear', 'cubic' (3rd order-spline interpolation), quartic (4th order-spline interpolation), or FFT available only for 2D and 3D grids (default method: 'cubic')
|
||||
AUTO_SUBMIT_JOB = .FALSE. # .TRUE. or .FALSE. (default: .FASLE.). Whether to auto-submit vaspkit or vasp job or not.
|
||||
SUBMIT_JOB_COMMAND = 'qsub job.sh' # The command line to submit job
|
||||
AUTO_PLOT = .TRUE. # TRUE. or .FALSE. (default: .FASLE.). Whether to auto-plot data graphs in the post-processing.
|
||||
|
||||
# New added in Version 1.4.1
|
||||
REDUCE_FERMISURFACE_FILE = .FALSE. # TRUE. or .FALSE. (default: .FASLE.). Whether to write only the bands which cross the Fermi energy.
|
||||
WEIGHT_THRESHOLD = 0.00 # Threshold value of spectra weight in the band structure unfolding.
|
||||
|
||||
# New added in Version 1.5.0
|
||||
CENTER_DEFECT_POSITION = .TRUE. # Move the position of defect to the center of the supercell; (default value: .TRUE.)
|
||||
VACUUM_THICKNES = 10 # Vacuum thickness (default value: 10 Angstrom).
|
||||
UNWRAP_TRAJECTORIES = .TRUE. # Unwrap MD trajectories or not; (default value: .TRUE.)
|
||||
|
||||
#USER_DEFINED
|
||||
#Synopsis:The first parameter is the command-id,starting with 'u'; the second is the interpreter, like 'python/bash/perl'(Please left it blank if you are using an executive binary); the third is the name of a script or an executive binary; the fourth one is a switch, if any extra argv is needed, please set if .TRUE. ; the last on is the description, MUST use '_' as delimiter.
|
||||
# id interpreter script argv description
|
||||
#Example1 'u1 python get_entropy.py .TRUE. get_entropy'
|
||||
#Example2 'u2 hello.exe .FALSE. ls '
|
||||
|
||||
u1 python get_entropy.py .TRUE. get_entropy_for_adsorbate
|
||||
u2 python bader2pqr.py .FALSE. bader2pqr
|
||||
#END_USER_DEFINED
|
||||
|
||||
#+------------------------------------------------------------------------------------------------------------------+
|
||||
#| Customize VASP job script |
|
||||
#| Must copy the block from #BEGIN_CUSTOMIZE_JOB_SCRIPT to #END_CUSTOMIZE_JOB_SCRIPT |
|
||||
#+------------------------------------------------------------------------------------------------------------------+
|
||||
#BEGIN_CUSTOMIZE_JOB_SCRIPT
|
||||
#PBS -N name
|
||||
#PBS -o out
|
||||
#PBS -e err
|
||||
#PBS -l nodes=2:ppn=4
|
||||
#PBS -r y
|
||||
cd $PBS_O_WORKDIR
|
||||
mpirun -np 8 vasp_std > vasp-out
|
||||
#END_CUSTOMIZE_JOB_SCRIPT
|
||||
#+------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
#BEGIN_CUSTOMIZE_PLOT
|
||||
#+------------------------------------------------------------------------------------------------------------------+
|
||||
#| WARNNING! The character-type values of plot variables are case sensitive and must be enclosed in single quotes. |
|
||||
#+------------------------------------------------------------------------------------------------------------------+
|
||||
# https://matplotlib.org/3.3.3/tutorials/introductory/customizing.html
|
||||
# https://matplotlib.org/tutorials/text/text_props.html
|
||||
# https://github.com/rougier/matplotlib-cheatsheet
|
||||
# Advanced Features of VASPKIT Pro version
|
||||
figure_format = 'pdf' # string type (default: 'jpg'). Options: 'png', 'pdf', 'eps', 'jpg', etc.
|
||||
figure_height = 4.0 # float type (default: 4.0). The height of the figure.
|
||||
figure_width = 5.0 # float type (default: 5.0). The width of the figure.
|
||||
dpi = 400 # integer type (default: 400). The resolution of the figure in dots-per-inch.
|
||||
set_tight_layout = .FALSE. # .TRUE. or .FALSE (default: .FALSE.). Automatically adjust the padding between and around subplots.
|
||||
|
||||
# Global settings =
|
||||
figure_style = 'default' # string type (default: 'default'). Options: 'default', 'classic', 'grayscale', 'seaborn', 'bmh', 'seaborn-notebook', etc.
|
||||
font_family = 'arial' # string type (default: 'arial'). Options: 'fantasy','arial','sans-serif', 'monospace', 'cursive', 'serif', etc.
|
||||
global_fontsize = 12.0 # float type (default: 15.0).
|
||||
label_fontsize = 12.0 # float type (default: 15.0).
|
||||
number_format = '%.3f' # string type (default: 15.0).
|
||||
|
||||
# Legend-related settings =
|
||||
show_legend = .TRUE. # .TRUE. or .FALSE (default: .TRUE.).
|
||||
legend_location = 'best' # string type (default: 'best'). Options: 'best', 'upper right', 'upper left', 'lower left', 'lower right', 'right', 'center left', 'center right', 'lower center', 'upper center', 'center', etc.
|
||||
legend_fontsize = 12.0 # float type (default: 14.0).
|
||||
=
|
||||
# Line-related settings =
|
||||
line_colors = ['b', 'g', 'r', 'm'] # string type (default: 'blue'). Options: 'red', 'green', 'cyan', '#4c005c', etc.
|
||||
line_styles = ['-', '-', '-', '-'] # string type (default: '-'). Options: '-' or solid, '--' or 'dashed', '-.' or 'dashdot', etc.
|
||||
line_widths = [1.5, 1.5, 1.5] # float type (default: 1.5).
|
||||
line_alpha = [1.0, 1.0, 1.0] # float type (default: 1.0). 0.0< alpha <=1.0, adjust the transparency of each line (by default, alpha=1.0)
|
||||
fill_areas = .FALSE. # .TRUE. or .FALSE (default: .FLASE.). Fill the area between two horizontal curves.
|
||||
|
||||
# Marker-related settings =
|
||||
#marker_colors = ['blue', 'cyan', 'red', 'magenta', 'orange', 'lawngreen', 'deeppink', 'brown', 'dodgerblue']
|
||||
marker_symbols = ['o','o','o'] # string type (default: 'o'). Options: 'o': Circle, 'x': Cross, '+': Plus sign, 'D': Filled diamond, 's': Square, '^': Triangle, etc.
|
||||
marker_colors = ['#0db14b', '#4c005c', '#d93b2b','#0075dc', '#740aff', '#993f00', '#4c005c', '#426600']
|
||||
marker_sizes = [60, 60.0, 60.0] # float type (default: 10.0).
|
||||
marker_scale = 1.0 # float type (default: 1.0). marker_sizes = marker_sizes * marker_scale
|
||||
marker_alpha = [0.8, 0.7, 0.6, 0.5, 0.4] # float type (default: 1.0). 0.0< alpha <=1.0), adjust the transparency of markers (by default, alpha=1.0)
|
||||
|
||||
# Tick-related settings =
|
||||
#x_label = 'Wave vector' # string type (No default value).
|
||||
#y_label = 'Energy (eV)' # string type (No default value).
|
||||
#z_label = 'k$_x$ ($\\mathrm{\\AA}$)' # string type (No default value).
|
||||
#x_limits = [-8.0, 8.0] # float type [xmin, xmax] (No default value).
|
||||
#y_limits = [-8.0, 8.0] # float type [ymin, ymax] (No default value).
|
||||
#z_limits = [-8.0, 8.0] # float type [zmin, zmax] (No default value).
|
||||
#x_major_locator = 2.0 # float type (No default value).
|
||||
#y_major_locator = 2.0 # float type (No default value).
|
||||
#z_major_locator = 2.0 # float type (No default value).
|
||||
#x_minor_locator = 1.0 # float type (No default value).
|
||||
#y_minor_locator = 1.0 # float type (No default value).
|
||||
#z_minor_locator = 1.0 # float type (No default value).
|
||||
|
||||
# contour-related settings
|
||||
colormap = 'RdBu' # string typ (default: 'jet'). Options: 'jet', 'hsv', 'viridis', 'gray', etc.
|
||||
contour_levels = 5 # integer type (default: 5).
|
||||
contour_limits = [0.0, 0.5] # float type (No default value).
|
||||
display_colorbar = .FLASE. # .TRUE. or .FALSE (default: .FLASE.).
|
||||
display_level_value = .FLASE. # .TRUE. or .FALSE (default: .FLASE.).
|
||||
display_contour = .FLASE. # .TRUE. or .FALSE (default: .FLASE.).
|
||||
colorbar_shrink = 0.5 # float type (default: 0.4).
|
||||
colorbar_orientation = 'vertical' # 'horizontal' or 'vertical' (default: 'horizontal')
|
||||
|
||||
# 3D-plot related settings
|
||||
elevation = 12.0 # float type (default: 12).
|
||||
azimuth = 24.0 # float type (default: 23).
|
||||
display_coordinate_axes = .TRUE. # .TRUE. or .FALSE (default: .TRUE.).
|
||||
display_brillouin_zone = .TRUE. # .TRUE. or .FALSE (default: .TRUE.).
|
||||
axis_length = [1.0, 1.0, 1.0] # Determine the length of each axis
|
||||
box_linewidth = 1.0 # Specify the transparency level for the lines of the box or Brillouin zone
|
||||
box_linealpha = 1.0 # Evaluate the line width of the box or Brillouin zone
|
||||
|
||||
# XKCD sketch-style related settings
|
||||
xkcd_style = .FALSE. # .TRUE. or .FALSE (default: .FLASE.). Turn on xkcd sketch-style drawing mode or not.
|
||||
xkcd_scale = 1 # float type (default: 1.0). The amplitude of the wiggle perpendicular to the source line (default: 1).
|
||||
xkcd_length = 100 # float type (default: 100.0). The length of the wiggle along the line (default: 100).
|
||||
xkcd_randomness = 2 # float type (default: 2.0). The scale factor by which the length is shrunken or expanded (default: 2).
|
||||
|
||||
# band structure related settings
|
||||
disconnecte_band_paths = .TRUE. # .TRUE. or .FALSE (default: .TRUE.). Turn on disconnected band paths drawing mode or not.
|
||||
|
||||
#END_CUSTOMIZE_PLOT
|
||||
2
devices/jykang.xmuhpc/linwei/chn/software/hpcstat/bin/bsub
Executable file
2
devices/jykang.xmuhpc/linwei/chn/software/hpcstat/bin/bsub
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env sh
|
||||
hpcstat submitjob "$@"
|
||||
@@ -32,12 +32,14 @@ inputs:
|
||||
{
|
||||
"/dev/disk/by-uuid/5cf1d19d-b4a5-4e67-8e10-f63f0d5bb649".mapper = "root1";
|
||||
"/dev/disk/by-uuid/aa684baf-fd8a-459c-99ba-11eb7636cb0d".mapper = "root2";
|
||||
"/dev/disk/by-uuid/a47f06e1-dc90-40a4-89ea-7c74226a5449".mapper = "root3";
|
||||
"/dev/disk/by-uuid/b3408fb5-68de-405b-9587-5e6fbd459ea2".mapper = "root4";
|
||||
"/dev/disk/by-uuid/a779198f-cce9-4c3d-a64a-9ec45f6f5495" = { mapper = "nix"; ssd = true; };
|
||||
};
|
||||
delayedMount = [ "/" "/nix" ];
|
||||
};
|
||||
swap = [ "/nix/swap/swap" ];
|
||||
rollingRootfs.waitDevices = [ "/dev/mapper/root2" ];
|
||||
rollingRootfs.waitDevices = [ "/dev/mapper/root2" "/dev/mapper/root3" "/dev/mapper/root4" ];
|
||||
};
|
||||
initrd.sshd.enable = true;
|
||||
grub.installDevice = "efi";
|
||||
@@ -49,14 +51,9 @@ inputs:
|
||||
services =
|
||||
{
|
||||
snapper.enable = true;
|
||||
samba =
|
||||
{
|
||||
enable = true;
|
||||
hostsAllowed = "192.168. 127.";
|
||||
shares = { home.path = "/home"; root.path = "/"; };
|
||||
};
|
||||
samba = { enable = true; hostsAllowed = "192.168. 127."; shares = { home.path = "/home"; root.path = "/"; }; };
|
||||
sshd = {};
|
||||
xray.client.dae.wanInterface = [ "enp3s0" ];
|
||||
xray.client = { enable = true; dnsmasq.hosts."git.nas.chn.moe" = "127.0.0.1"; };
|
||||
groupshare = {};
|
||||
smartd.enable = true;
|
||||
beesd.instances =
|
||||
@@ -72,6 +69,8 @@ inputs:
|
||||
publicKey = "xCYRbZEaGloMk7Awr00UR3JcDJy4AzVp4QvGNoyEgFY=";
|
||||
wireguardIp = "192.168.83.4";
|
||||
};
|
||||
hpcstat = {};
|
||||
gitea = { enable = true; hostname = "git.nas.chn.moe"; ssh = { hostname = "office.chn.moe"; port = 5440; }; };
|
||||
};
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" ];
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
xray-client:
|
||||
uuid: ENC[AES256_GCM,data:97aX07G5FPumdWcDxnYOs6fRgljXWuwyNXGg1d7zdbUUfNnb,iv:+wAC/DZXsg+evYFA4DMfLw5Ut3ExQl1RgZ/2AsNQDpo=,tag:ebD77muITHof+FQMydWobg==,type:str]
|
||||
acme:
|
||||
cloudflare.ini: ENC[AES256_GCM,data:/LpP1qoVS+CG+5ska6vtmagHNrhcgr5e1QRzDdbdCYGnDB8Nca/GmIogzHCXsogQY/rwGTCZoXLKKEGToYiThwk=,iv:R++I0ued2wrVsmM/vYvBVMOp9M7HyZIfDOVOlg7GALE=,tag:gYchPuh8MHk3EEnGb9g4WA==,type:str]
|
||||
token: ENC[AES256_GCM,data:OrYgBRU1VPpkpDzYMFHINfPSHsXEKABdZOcgiAiBJKcreBoaSVHUvg==,iv:XIeZPJhzmUi5ZHKBCYN5UA9HWH1K+26SvcIWVrHAYDA=,tag:3F93syLBZjcHwnRRkUEjlw==,type:str]
|
||||
users:
|
||||
xll: ENC[AES256_GCM,data:XLSsz6fZ23PPaJS1Y5C3FAOks3wzb2f+Pv8TgyKrDBfMeoLk1M37A00OGJ2wsYxkuR0JV6Uoh+hhRpTUjOQnmLfQrBxPxxP8DA==,iv:jxEZX/flxxduM1sdrYfGHfMtFMYduMg0Lr6hY1pkAPg=,tag:CYy0y1e2S2Txz1OSh+XDHA==,type:str]
|
||||
zem: ENC[AES256_GCM,data:VCVLfGO9a06XhAOBciFf1u7A5jaQikAt2wZf+dCAi1BglXpM6Hof1yAunadYOwLOBFgGlP19kX53CBBlZtaqZFL2GRDzXP0woQ==,iv:AFYtHCCkzNrllN/fjQ8GKYs2TyV3uj3BsU5n1tBQAmM=,tag:5dP7c5N4yG2NS4T+Vg0Zpg==,type:str]
|
||||
@@ -13,6 +13,15 @@ nginx:
|
||||
maxmind-license: ENC[AES256_GCM,data:JbAnFQiDcJGwvb89sG2ro77nwwOWcDnqVcA902jwb2zzZci7PpXROw==,iv:eifkWK0oN73Ekn3oWzy6XbYK2GU+4tlnLPJ+96WOWJY=,tag:35ulsshxtUfOsSQOLgAt0g==,type:str]
|
||||
wireguard:
|
||||
privateKey: ENC[AES256_GCM,data:VPlB4wSbWqSYw3rYRwfAMa39xrPcPZfz7sV2Cq3rmOhifnUPwggxnA+51do=,iv:utnyrB6Yfe5O94Oq4HDVFm/lQ9ZBoyvUT68r2G2PdwA=,tag:snm01vA+z2yKK8d2i5i2ig==,type:str]
|
||||
telegram:
|
||||
token: ENC[AES256_GCM,data:NK9Eq3jUaMVNyPyqiXEkrc4m81c2CBg3p9TjpD8TQgKRYs2uxT9lsSrLMi02Rw==,iv:N2mjY9n7QuLD2PG4gNl79c933GTCCfw35XxluiLSuOA=,tag:ZLreEQoV+O0yhHw0CM00aQ==,type:str]
|
||||
chat: ENC[AES256_GCM,data:XJi6HftAygFH,iv:ea2m41/YXp0VyxR9U84xMCHdknZBhP2QUiX6zsipaFc=,tag:+/Y2bvUwrQsLVGUZp0Imwg==,type:str]
|
||||
hpcstat:
|
||||
key: ENC[AES256_GCM,data:3bMieouWGMEw8eu6z55TX66NAGiF/O5dRtnDTjDtNC3fmR4PTn+FreMZuA9+AjTPUm2GsS9esC6tULIzh+qTflnSrxqtTdKAbfqY6o8pPPpDJ9WWm4f/g3x8PnvlsyQDYCZ0MYKYg3cc6n60moCzv1WWlVsT8QUMTXQL3yb36vVzo4ELea4Gf2UkpfYKX89gFDtJK78srh7rj8rwoDiBs1qVUUnIBABUDLxoyC3Rym5yevrCJeFD+8AlIAIaMc62Kslw0lCCKKSaXGsFpppFYFwUTedi595eISEr4tIuPXVd4EECQchsYg+tInphIXebp/5rzXQM37yQEymImNRiMcxDWGR0B8Nq9XO+I5T8VOIb6xXCtvEeY2Z8nPfmUn9UHfvYzqFv3it5TCcd9J4SeBa2LVW8+YCIO/KitznL49O5SGAJUONIkcwMUhUuXQUFe/vnc+g8+yqB5ltCZtHWCOY2pCdmQpBRaZq55fcde5FNhxt3J8zCbu++oIn+ERSHadMIGMuGgGqzG6XDQJZN,iv:cbPCnNi2gX1gZIdcQd7HR3c/JEsWj3nv+x+OQ0bDs40=,tag:olrGr6t2Si39wl/1rR81ig==,type:str]
|
||||
postgresql:
|
||||
gitea: ENC[AES256_GCM,data:qssnsnlaEKwEnLbnpX+XDs7JK/2DdK1cxD6U2NddpCPnwfOinP2cuc1HLnteWQfYZXTuYM3VOXDEXQB9CexILA==,iv:+TVoTuqmxIsTlNPngMBBWgIvP5EQD5ROHZI4u0mSJGE=,tag:6X8hewc5a6C6nbuD5WozCQ==,type:str]
|
||||
mail:
|
||||
bot: ENC[AES256_GCM,data:ugfBeRM4Ks7j+V4lLOqHrA==,iv:QwXeSrfw+TTN5N42DaaA7YgpaIJX/E+kTv9p6eWSxEk=,tag:fLUDBhsvCbOiYqhq9TCzmw==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -37,8 +46,8 @@ sops:
|
||||
by9Rd0U0bzNiK21BQTNxN1RuQ09DQVkKJmSlzV5ppEkZFljsS17ZWmoI++fz4tJh
|
||||
kTdoAStG1zsKASHyZTsmdm3RBDO3qV1KhQC2gC7d4EiwNZngxOOZJg==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-04-18T13:51:13Z"
|
||||
mac: ENC[AES256_GCM,data:mRJEowQNw1aczxkxcBt9Y0LCfv7Q10Of5Bo7nuTYES5/DVRHK8ZRILm9w2/5+jpcRdpFnkvfOZ6yMu0YPipEfa/LeLJIDMHPbp2qgafZ1XSaanT9EC+vr6Lc5tqKoPnDD00+HtX9LqpDOhWvBkuS874O2Hg9HUZd/PrfCj3oFes=,iv:wqbIVCXWtslBfkzyJ5ZLFlyT1GUuu76yk9zlw05is8E=,tag:bkyyWqIrLlfOPlhxsS+a8g==,type:str]
|
||||
lastmodified: "2024-05-10T08:52:02Z"
|
||||
mac: ENC[AES256_GCM,data:gKEZ0bxn+xCu7wPRCRpacErzqdajw4zNalUwZvldUP+Ygdq6KOMgjxvm3hy7GIBlhK2MLgps3X3sjdrUW1A7Tx5wiPtrqddVo5qiubZcuWqNO4SSoM2x/VxtHbKcZQMaNdIHXx3TUFjQ0tcsMuDBNNUZ192JJUDE/DaDyxTklq4=,iv:sZ98srsM68h59R9HHeh7gXdUBN2JtoWx+PhU1nsHgk0=,tag:N7211a4Jrp6AdPKhQCz65g==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
@@ -51,10 +51,11 @@ inputs:
|
||||
"alderlake"
|
||||
];
|
||||
remote.master = { enable = true; hosts = [ "xmupc1" "xmupc2" ]; };
|
||||
githubToken.enable = true;
|
||||
};
|
||||
nixpkgs =
|
||||
{ march = "znver4"; cuda = { enable = true; capabilities = [ "8.9" ]; forwardCompat = false; }; };
|
||||
kernel.patches = [ "cjktty" "hibernate-progress" ];
|
||||
kernel = { variant = "cachyos"; patches = [ "cjktty" "hibernate-progress" ]; };
|
||||
networking.hostname = "pc";
|
||||
sysctl.laptop-mode = 5;
|
||||
gui.enable = true;
|
||||
@@ -62,7 +63,11 @@ inputs:
|
||||
hardware =
|
||||
{
|
||||
cpus = [ "amd" ];
|
||||
gpu = { type = "amd+nvidia"; prime.busId = { amd = "8:0:0"; nvidia = "1:0:0"; }; dynamicBoost = true; };
|
||||
gpu =
|
||||
{
|
||||
type = "amd+nvidia";
|
||||
nvidia = { prime.busId = { amd = "6:0:0"; nvidia = "1:0:0"; }; dynamicBoost = true; driver = "beta"; };
|
||||
};
|
||||
legion = {};
|
||||
};
|
||||
packages.packageSet = "workstation";
|
||||
@@ -70,13 +75,12 @@ inputs:
|
||||
{
|
||||
waydroid.enable = true;
|
||||
docker.enable = true;
|
||||
kvmHost = { enable = true; gui = true; autoSuspend = [ "win10" "hardconnect" ]; };
|
||||
kvmHost = { enable = true; gui = true; };
|
||||
nspawn = [ "arch" "ubuntu-22.04" "fedora" ];
|
||||
};
|
||||
services =
|
||||
{
|
||||
snapper.enable = true;
|
||||
fontconfig.enable = true;
|
||||
samba =
|
||||
{
|
||||
enable = true;
|
||||
@@ -93,10 +97,19 @@ inputs:
|
||||
sshd = {};
|
||||
xray.client =
|
||||
{
|
||||
dnsmasq.hosts = builtins.listToAttrs (builtins.map
|
||||
(name: { inherit name; value = "74.211.99.69"; })
|
||||
[ "mirism.one" "beta.mirism.one" "ng01.mirism.one" "initrd.vps6.chn.moe" ]);
|
||||
dae.wanInterface = [ "wlp4s0" "enp5s0" ];
|
||||
enable = true;
|
||||
dnsmasq.hosts = builtins.listToAttrs
|
||||
(
|
||||
(builtins.map
|
||||
(name: { inherit name; value = "74.211.99.69"; })
|
||||
[ "mirism.one" "beta.mirism.one" "ng01.mirism.one" "initrd.vps6.chn.moe" ])
|
||||
++ (builtins.map
|
||||
(name: { inherit name; value = "0.0.0.0"; })
|
||||
[
|
||||
"log-upload.mihoyo.com" "uspider.yuanshen.com" "ys-log-upload.mihoyo.com"
|
||||
"dispatchcnglobal.yuanshen.com"
|
||||
])
|
||||
);
|
||||
};
|
||||
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
|
||||
acme.cert."debug.mirism.one" = {};
|
||||
@@ -119,18 +132,35 @@ inputs:
|
||||
wireguardIp = "192.168.83.3";
|
||||
};
|
||||
gamemode = { enable = true; drmDevice = 1; };
|
||||
slurm = { enable = true; cpu = { cores = 16; threads = 2; }; memoryMB = 90112; gpus."4060" = 1; };
|
||||
xrdp =
|
||||
slurm =
|
||||
{
|
||||
enable = true;
|
||||
hostname = [ "pc.chn.moe" ];
|
||||
cpu = { cores = 16; threads = 2; mpiThreads = 2; openmpThreads = 4; };
|
||||
memoryMB = 90112;
|
||||
gpus."4060" = 1;
|
||||
};
|
||||
xrdp = { enable = true; hostname = [ "pc.chn.moe" ]; };
|
||||
};
|
||||
bugs = [ "xmunet" "backlight" "amdpstate" "suspend-hibernate-no-platform" ];
|
||||
bugs = [ "xmunet" "backlight" "amdpstate" ];
|
||||
};
|
||||
boot.kernelParams =
|
||||
[
|
||||
"acpi_osi=!" ''acpi_osi="Windows 2015"''
|
||||
"mt7921e.disable_aspm=y" # 避免休眠恢复后无 wifi,似乎有时还是有问题
|
||||
"amdgpu.sg_display=0" # 混合模式下避免外接屏幕闪烁,和内置外接屏幕延迟
|
||||
"acpi.ec_no_wakeup" # 睡眠时避免开盖唤醒,似乎没有用
|
||||
];
|
||||
# 禁止鼠标等在睡眠时唤醒
|
||||
services.udev.extraRules = ''ACTION=="add", ATTR{power/wakeup}="disabled"'';
|
||||
networking.extraHosts = "74.211.99.69 mirism.one beta.mirism.one ng01.mirism.one";
|
||||
services.colord.enable = true;
|
||||
virtualisation.virtualbox.host = { enable = true; enableExtensionPack = true; };
|
||||
environment.persistence."/nix/archive" =
|
||||
{
|
||||
hideMounts = true;
|
||||
users.chn.directories = builtins.map
|
||||
(dir: { directory = "repo/${dir}"; user = "chn"; group = "chn"; mode = "0755"; })
|
||||
[ "lammps-SiC" "BPD-paper" "kurumi-asmr" "linwei-stuff" "BPD-paper-old" ];
|
||||
};
|
||||
specialisation =
|
||||
{
|
||||
nvidia.configuration =
|
||||
@@ -142,35 +172,10 @@ inputs:
|
||||
};
|
||||
system.nixos.tags = [ "nvidia" ];
|
||||
};
|
||||
hybrid-sync.configuration =
|
||||
xanmod.configuration =
|
||||
{
|
||||
nixos.hardware.gpu.prime.mode = "sync";
|
||||
system.nixos.tags = [ "hybrid-sync" ];
|
||||
};
|
||||
amd.configuration =
|
||||
{
|
||||
nixos.hardware.gpu = { type = inputs.lib.mkForce "amd"; dynamicBoost = inputs.lib.mkForce false; };
|
||||
boot =
|
||||
{
|
||||
extraModprobeConfig =
|
||||
''
|
||||
blacklist nouveau
|
||||
options nouveau modeset=0
|
||||
'';
|
||||
blacklistedKernelModules = [ "nvidia" "nvidia_drm" "nvidia_modeset" ];
|
||||
};
|
||||
services.udev.extraRules =
|
||||
''
|
||||
# Remove NVIDIA USB xHCI Host Controller devices, if present
|
||||
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
|
||||
# Remove NVIDIA USB Type-C UCSI devices, if present
|
||||
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
|
||||
# Remove NVIDIA Audio devices, if present
|
||||
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
|
||||
# Remove NVIDIA VGA/3D controller devices
|
||||
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
|
||||
'';
|
||||
system.nixos.tags = [ "amd" ];
|
||||
nixos.system.kernel.variant = inputs.lib.mkForce "xanmod-latest";
|
||||
system.nixos.tags = [ "xanmod" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
xray-client:
|
||||
uuid: ENC[AES256_GCM,data:XU7/GZ8cJmDwNsrQfoFHrquZT5QkjvTPZfnghX3BLyvPLlrX,iv:e/BQkZ5ydWD4P/qT9OUloB8/cXImfkG3YZnuIeNLoTc=,tag:EW3ZBzGnyIrUfcMeJqm4aA==,type:str]
|
||||
acme:
|
||||
cloudflare.ini: ENC[AES256_GCM,data:hPNpTclYvRbcbFO6aR9PNyHt3kDUmjeUgg4NPsr+c/yxKPundoiziNYBRfF7/axlw8Hu32jf/cDlcWaEmqCBQJY=,iv:bdGCD/a6AnGQhiFNyZ+fD1f/rILsEcPXC2qRDsAO4n8=,tag:MLZak9uSqsg/0Ldx2Wgb6A==,type:str]
|
||||
token: ENC[AES256_GCM,data:e+ZPOwOobbShxm5zZqmIeM4cmP4JQT8kDQ0goKsSwpIKmJAzi8WutQ==,iv:ZKOzKa98yWTM2LkC4+rzA6rTW4afm3oAG4nc/2vk7Bg=,tag:Qctw1sk1SC/a6Xv5Fju8EA==,type:str]
|
||||
frp:
|
||||
token: ENC[AES256_GCM,data:0mE8/cWqHKNquCIiqgbjcNhipKk7KEfbZ+qRYbu+iZr7AH9QjfYZQiMJNp4Aa3JWwBLYAnpf,iv:ID4cc8Tn0H9b1CimXlPamMlhlAkafhRApDHo/CCQ4BE=,tag:BUuU/BCj16R7FlKlpubawA==,type:str]
|
||||
stcp:
|
||||
@@ -20,6 +20,8 @@ mariadb:
|
||||
slurm: ENC[AES256_GCM,data:fGvNMmqk7Cee28VJ1QoBVrBbgIUbj/F1W0SRjdP8N4K/M8Wx4AVm1kAr0IAhPWyDLXlIjM1NUvuEV5BpYDBdjg==,iv:rFTMJ4x2kgENQUA8ftSaLjdOc25i5mWR3UYbdq54vjs=,tag:6feD0eCSv7bcHWBveLNJwg==,type:str]
|
||||
nix:
|
||||
remote: ENC[AES256_GCM,data:uosYkxTCB0wiY+Uufk//OcBZFN3EzbZoQGZ95M9eZMjQ5AobAZqosi4laE+EMcZL1CqYqlWXaSoEUOB8biUaZPseo+1AX1TlmUgZ7QpkfOX0VKZu01C6C+lVyqVqMFq6z1BFyX/oeITMIfnd4a/2KwJCHLAZ4hMkJ5p+aJwByKGa3N/2m41HH/1S3z7pYQWj7YJxunTPPG6WNSiRncQki11rvmddwnXmsBF89+jW1Phge8U295haC57T5oIGPxR645IeTK4ZUlL8eVuZ+BhsnwbkYcaxvjSwe+DOIVPupR8GW+gis7KxwE89kqvnQhinamexcPUz4lGHlqO/Xn6jrJx6T/wXF+19epAzeHapYte3dTWNsdPwPLPJihT16YT5fwrLnH3zq8kexWz1crmnCGUoaBs4S2tHWHLgv2lTv0IHLx5F6ijpDBj/Avg9YILIURzdeea+rBxdycHasUDTVlJtYKRH5J+WbAKWI+oJ5qmXjIRUYL+O9xIUfOGO+1b3xs8MYxRWuvDV2P88N8vN,iv:yQQp5wjbSVn1oia5yL7d6GF9Vo704G0iOQRGMbzQHzg=,tag:bpBag5y5n+7ojOa8QOcDvA==,type:str]
|
||||
github:
|
||||
token: ENC[AES256_GCM,data:59z1zSofzUyv2Qfn8oS7dZplzJDtOD/zxhPm07MLbVLHt8mE57IGcw==,iv:nZ4JmIE1h496RN6BChvqo7XWHjur76jP4HMgqGBbMJQ=,tag:pUSGsofG7hvkvJxCRwkg1Q==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -44,8 +46,8 @@ sops:
|
||||
OUlxNjdQaXdXMkZ6bnV1ek4yZ2dpbkEKpKGOAxo5Eef2jtGrg4iSzmGCeg+vTgvu
|
||||
+K8b+O19MIkGMDBm6UbYUPtc/7eqoEZRiTUzNMTmfkLVS4ul5zou9A==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-04-18T13:48:02Z"
|
||||
mac: ENC[AES256_GCM,data:upQaP/oOym+Wucwb+9o/nZSMfVrzWZvQigiGyZrWjZ4TehMxJt/v69z6bu/h63HzjHA9T5NbthQaJaPo7XmTI97AZS7Dm7kr0gS7P2K7fzdMZ0NAibZmFPIfBBjHykBh77MobVI4RkGuXfLv7yQxIK9ChxQNpLOHlGpOa59bz3w=,iv:0NN0y+7njKL3X8qHEfdCXqTDti+eXSau8FYi9JLutHw=,tag:4t1SiXjxqEUo04L9HXLVzw==,type:str]
|
||||
lastmodified: "2024-05-24T03:34:07Z"
|
||||
mac: ENC[AES256_GCM,data:+nJ/wuO5G6pEsCiBNEHOYrbiYyGXXIHu3ZUgEVwqLQ10W94EOGLUto61IGtkapk4xmaHYAVmUlq76g2hRGrndLVlUthGnEc5QoQKZoUmrxK7ux1R2ubv0s1k+l2HpRerr/I8X+hHyV0fdxT6ivkpq6OsEzHDnxgewDvYNZGQS4k=,iv:TuzO1Yo0MPms5RrG8+GbwSCOILp9BF7Jsv5JvcAPwFw=,tag:fUNc+ccQDE/jcMLuQ4thCQ==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
@@ -20,6 +20,7 @@ inputs:
|
||||
networking = { hostname = "pcarm"; networkd = {}; };
|
||||
nixpkgs.arch = "aarch64";
|
||||
kernel.variant = "nixos";
|
||||
sops.enable = false;
|
||||
};
|
||||
services.sshd = {};
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ inputs:
|
||||
{
|
||||
# snapper.enable = true;
|
||||
sshd = {};
|
||||
xray.client.dae.wanInterface = [ "enu1u1" ];
|
||||
xray.client.enable = true;
|
||||
fail2ban = {};
|
||||
wireguard =
|
||||
{
|
||||
|
||||
@@ -30,8 +30,8 @@ inputs:
|
||||
};
|
||||
nixpkgs.march = "skylake";
|
||||
grub.installDevice = "efi";
|
||||
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
kernel = { variant = "xanmod-lts"; patches = [ "cjktty" "lantian" "surface" ]; };
|
||||
nix = { substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ]; githubToken.enable = true; };
|
||||
kernel = { variant = "xanmod-lts"; patches = [ "cjktty" "lantian" "surface" "hibernate-progress" ]; };
|
||||
networking.hostname = "surface";
|
||||
gui.enable = true;
|
||||
};
|
||||
@@ -41,9 +41,8 @@ inputs:
|
||||
services =
|
||||
{
|
||||
snapper.enable = true;
|
||||
fontconfig.enable = true;
|
||||
sshd = {};
|
||||
xray.client.dae.wanInterface = [ "wlp2s0" ];
|
||||
xray.client.enable = true;
|
||||
firewall.trustedInterfaces = [ "virbr0" ];
|
||||
wireguard =
|
||||
{
|
||||
@@ -56,8 +55,12 @@ inputs:
|
||||
};
|
||||
bugs = [ "xmunet" "suspend-hibernate-no-platform" ];
|
||||
};
|
||||
boot.kernelParams = [ "intel_iommu=off" ];
|
||||
environment.systemPackages = with inputs.pkgs; [ maliit-keyboard maliit-framework ];
|
||||
powerManagement.resumeCommands = ''${inputs.pkgs.systemd}/bin/systemctl restart iptsd'';
|
||||
services.iptsd.config =
|
||||
{
|
||||
Touch = { DisableOnPalm = true; DisableOnStylus = true; Overshoot = 0.5; };
|
||||
Contacts = { Neutral = "Average"; NeutralValue = 100; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ xray-client:
|
||||
uuid: ENC[AES256_GCM,data:WEBAH3PQM5ahNpH/kvTtcjcJ2GllmmRlBR2oclG6AimGenSg,iv:TMp0WTOe9fuELSZoVGenl5XSZUFoiYUBEMWMn4NFv1g=,tag:GJTE0EELcZkrnGAKLYer1g==,type:str]
|
||||
wireguard:
|
||||
privateKey: ENC[AES256_GCM,data:P/tyZHaEAahZUBF22dJEZb6mACm/wmUunPDG0vS7SNW3sWbzxRSut0haR/g=,iv:8VMv5iotmDrYDLiszcOvJHkD8l6uE+SboPSILr6KuzU=,tag:U/FIBhvghwDTvFtUWEqr4g==,type:str]
|
||||
github:
|
||||
token: ENC[AES256_GCM,data:SyqrpFfy+y7syReWs0Bi23651ew41Us8aqjImBTzkDanOtWQgIYC6g==,iv:H3Y/TuP3VvZv6MlRAdLOY0CiNUeoqGZRNg0s58ZSkQ8=,tag:rSf4E8Whvue/LZ+VlSqDDQ==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -26,8 +28,8 @@ sops:
|
||||
a2xybTRFUFZZN20zajZJTVNwVEpGcEEKglmFMk7z1q5IlZ+lZf9M0HtknmvcYt/P
|
||||
2/z5e8wLN1Hy0Zsbv0yIL/NmqwxAOGJOdzz7ElJszk/Y4kUr9aRasg==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-02-16T14:25:17Z"
|
||||
mac: ENC[AES256_GCM,data:lpZ+Jd5LF35ESBOmOoq7pbNHze7rJiQsiq8cOgf8+cWnAqVh1bccG0cFe7R8uBhmuKIqp7TwkORDFuD+KFCZW14cbR4SP3vndSoYzKxIBdKTObR95w2ETst+prUtQ3fvFeEtlJexeljikfprWf2pGo1OzPophAyocgT31z2iMjs=,iv:Bryz+kqRvXYPj6YuxeDhQfLsgYqHXrA+lHFX18m2GGE=,tag:A7mvmguWoOir2JoIprgL4A==,type:str]
|
||||
lastmodified: "2024-05-24T03:36:38Z"
|
||||
mac: ENC[AES256_GCM,data:Dv6WO5K0GFVm4Rt+GjXeE1vwqlPkP+kmRCGU41rbSR3YBcL8mkpBRQQXJiMU99cQQMK/rCGy+k91fhGnG5xFT/FdEZF8qUjRHPZ5MdWCjPOuY/LrXWnSnwwJa2neQLFH/ToUkNaGHCk/FngnZ/e0U43Rnwt3iHRDBG3io8oDY0M=,iv:Jf5EtkTuf/MFDq6UiOo8/31ev5zBiaP9WnlgsUgK5Y4=,tag:r6ql+UbXbG5A1vtbsGXnJQ==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
@@ -24,6 +24,7 @@ inputs:
|
||||
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
initrd.sshd.enable = true;
|
||||
networking = { hostname = "vps4"; networkd = {}; };
|
||||
kernel.variant = "cachyos-server";
|
||||
};
|
||||
services =
|
||||
{
|
||||
|
||||
@@ -30,12 +30,13 @@ inputs:
|
||||
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
initrd.sshd.enable = true;
|
||||
networking = { hostname = "vps6"; networkd = {}; };
|
||||
# do not use cachyos kernel, beesd + cachyos kernel + heavy io = system freeze, not sure why
|
||||
};
|
||||
services =
|
||||
{
|
||||
snapper.enable = true;
|
||||
sshd = {};
|
||||
xray.server = { serverName = "vps6.xserver.chn.moe"; userNumber = 14; };
|
||||
xray.server = { serverName = "vps6.xserver.chn.moe"; userNumber = 20; };
|
||||
frpServer = { enable = true; serverName = "frp.chn.moe"; };
|
||||
nginx =
|
||||
{
|
||||
@@ -61,6 +62,7 @@ inputs:
|
||||
catalog.enable = true;
|
||||
blog.enable = true;
|
||||
main.enable = true;
|
||||
nekomia.enable = true;
|
||||
};
|
||||
};
|
||||
coturn = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
acme:
|
||||
cloudflare.ini: ENC[AES256_GCM,data:X1v1QuOZemIuxldd1bzIvbUsq+8HMGLh91zUB+fnrxaW40z0OQh9L1rF/0Nj3gmUmgT4KEV7nkHFYYpZBp4/Kyc=,iv:fQmbhx9wV3l+DVPaBrAyJbTCsS3q3s5F9Go1F7pZ2pQ=,tag:P4vuruX460YSOUsx6zGHXQ==,type:str]
|
||||
token: ENC[AES256_GCM,data:lJc2A1Q5vxWQsSchA5pvXSYW+DjBCkdSbWVD7+Py+lG/6nGUmEAHVw==,iv:ZcysHsiLQzD/7vMn1wTCE5lw7/IgkH3oLem5xCjnf7Q=,tag:7EC+S79HRCG/Q+bqVcGVDw==,type:str]
|
||||
frp:
|
||||
token: ENC[AES256_GCM,data:T8b1ku4HNCNSJ+33QgIt1GILFA4wTu3Qd0rDqHPVgdqsGo0R90k0u8z+dElSO7q9PapTqUbZ,iv:hwnMu6JxfYLgw4TyhujX5dI2IAytgZh+Bexhgta6ATQ=,tag:lqgwvXlS/jGPxasmk5Vh3w==,type:str]
|
||||
xray-server:
|
||||
@@ -34,9 +34,16 @@ xray-server:
|
||||
user13: ENC[AES256_GCM,data:ExbnvWDIBqga5+k2mpoT8AKBOXAvUNMjBTPXUKrmtWzz4l+L,iv:UI7CvSx2FHYGf6BEHS4e3iwHZZWkl2Zt5xg2WdKbLvY=,tag:ad0c7YW2Bxo+Dn+BoSZ0Ng==,type:str]
|
||||
#ENC[AES256_GCM,data:R8lN5T0=,iv:FXLf8Vtjg+PkwNhxXWDViMKqwn7tFMaPhio9zhnudZw=,tag:34gxRH+P9lmkUxlOPKcYMg==,type:comment]
|
||||
user14: ENC[AES256_GCM,data:dgNPPlJD5JOFPbKhlvlRHBLmUNKeDm/JAiawUVpBE7H07Box,iv:w+t9BkqYvlxVKr+x0MwtBz0/YSR/7z1OnZLIoPdW4gc=,tag:CR3GLbaO0jSQgA2HuwzRqg==,type:str]
|
||||
telegram:
|
||||
token: ENC[AES256_GCM,data:xsJoGgQ8pLeZqA2alGKkCyrvnjY6rVF5TlXn4GWDrStFBl65XXzwVY/9ZZthYQ==,iv:qTLfpRUyuIGFM668URfknhSRtx3WEHp/WTGzGUPuFd4=,tag:p8mF0tM+t02g7v2EQZN3Vg==,type:str]
|
||||
chat: ENC[AES256_GCM,data:X1JxFQw0bPCu,iv:hf+TOSH2p9RdnXDFKxTpSRzxDLdJyzNHVV8MfOQuGWY=,tag:iiWw9IFiBGOOyOSl9Jj2wQ==,type:str]
|
||||
#ENC[AES256_GCM,data:X80nhW5a/JQ1IQ==,iv:2UTsNLLDr4uBAEcPyvmep1fqH43JLUiHc/zqQWChfDk=,tag:DJEArs1nVnlcJgqM2uy17A==,type:comment]
|
||||
user15: ENC[AES256_GCM,data:6AskiMLLl0HV6tm2rYpV46XW0jePQy+wme2oi3M7He7WsgVM,iv:lGfnFn69Vnjv5J3rp5sRazD5/B+8Nk8MNG7HIyf4HKA=,tag:Vbg82tdn3noOfhKVVx0Phg==,type:str]
|
||||
#ENC[AES256_GCM,data:4jJkbMD9Psxrag==,iv:arRtRaNrqnYcT7vE3wqgl/y8/65ORaxqTdGw55AKDP8=,tag:pRpta6mXfy0XCyzMA4+cEQ==,type:comment]
|
||||
user16: ENC[AES256_GCM,data:fo6KJXlPDn7+FmxjEJQo9d79rDYemLFx6LanYZcJpKJR7Gxq,iv:yEUKPNZ9idrSqyVO9fhksP/7bjPMT/LzNK2VSq503/c=,tag:M87D44SIo9JzDB3ZyKu7fA==,type:str]
|
||||
#ENC[AES256_GCM,data:/Kec+CdtnT11EA==,iv:DnmbWfgriaE6XAnMqq2UXhHhN+Rd/3YRodKVUCJo6p4=,tag:NimqZpbslKxwzoljaZqEdw==,type:comment]
|
||||
user17: ENC[AES256_GCM,data:gQInIcNFxJuCSsMDGq4yTp5JdMMmJRy1tY3PGLoLuuIXWV0a,iv:ya4n9Z7T9/bxeHqi5QqwJprEzDMsT6X0BuEXRS67wWk=,tag:RcjQfAHv8uc3PgN5c4bySA==,type:str]
|
||||
#ENC[AES256_GCM,data:h7E4P6BiGjktYg==,iv:DhkK3NNppBqo3sXt9U7kbgfaBPYcSEX2hu6VOAesDiE=,tag:XoVbZklwCmU1EBhv0ujcSw==,type:comment]
|
||||
user18: ENC[AES256_GCM,data:dssxPEv8srXydunolaaDAYYo+BOXhp2PoqidOWH3z6NYBpyB,iv:WCLcMMwQJiHZBwreQpaOZp2saXvjBwgYUqSf7HQhMgA=,tag:5jsAVcgAgO+7JhBINz6tzQ==,type:str]
|
||||
#ENC[AES256_GCM,data:qGsMmWrUIzVdHw==,iv:DXayEA5zquwOzm+TqECYNHM98r0WSzcP3gA8zkzdPy4=,tag:OKTx12RqP9VxJQOnrBLkmw==,type:comment]
|
||||
user19: ENC[AES256_GCM,data:+Mh15DR9xvFAwks86iuHEA9FpObKWTSuVOEzUDpBUS/h0hOz,iv:zYIkic2bibvwCBpomnJ9465mda1rbm3RERBZY9twXuc=,tag:bwdL6DAGgkGYhYFI2C4A+A==,type:str]
|
||||
private-key: ENC[AES256_GCM,data:ts/LRGFAsYqvGvkvlxUI42IW1a8cGsSkpZhMDd3QVceRKvhPb1SRDaXoSw==,iv:6xX9xFIFUNlLBZ6CPBOz9JbHpvC4+QG9ZaCZcWdl12c=,tag:DYIa+QTV8vyl1l7OKKykTw==,type:str]
|
||||
nginx:
|
||||
#ENC[AES256_GCM,data:85LrqdTMIhSa,iv:mIQPYz8VPd5AxeMCQEdTGMD0Iqa5QEAa5+8JVFaj3JM=,tag:TcZd7S3WRPpEV9lHI1fzbw==,type:comment]
|
||||
@@ -53,6 +60,9 @@ coturn:
|
||||
auth-secret: ENC[AES256_GCM,data:50KqO4GQ1ERbCnK4IjYu6aywT+IPMtVlTzh/TE4MwWApU4pO9yqz25ENGUAKRLi4p+Ecug+Rn3InRl1b+q6bAQ==,iv:SgHkHvHg/+yA1Z5E9effgCnZMVXv5amGNUsVKErai54=,tag:PoYLV9Xr0IXXsA39n7wiTQ==,type:str]
|
||||
wireguard:
|
||||
privateKey: ENC[AES256_GCM,data:4DKPPqQkjb33rQzFIz863A2arDRQA9AivWFBaWTf0xXDX4hWvJFiIlJQfvE=,iv:0R2TH3CMxHgwVjojzjE2Gnp8SXonmBDLWF7hB33NiX0=,tag:vgtV8JkuCdspleN/SvgIqQ==,type:str]
|
||||
telegram:
|
||||
token: ENC[AES256_GCM,data:LskBPmXZk3hRZ2bChXZjmRzzGd2A2GKrUZMknCDXTpTzOdP/RDibRvgI75HLWg==,iv:9lJKuGLD5HuQinWvvAvwWFAvEJofUGkJsxKNpqZrGmI=,tag:pTmTOlsYIY6Uqd69AtrnBA==,type:str]
|
||||
chat: ENC[AES256_GCM,data:0ehCIvd7sBFc,iv:OwdiIoPrt/e1YgsCrYcqqMYhsJuEtKW2pSKNVxahMV4=,tag:ig2CfQxwzv2ppIutU6371w==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -77,8 +87,8 @@ sops:
|
||||
ZXFTU3ZCaW1pTVh0RUJzdDdGdHlPYTgK2mlgcX2kEc8+2UDdBnhUm6IIuh8V6agW
|
||||
ooxH9OEPXUVI/4JcDo4v8ZUhAyU1ehLH0Ef7PJCChOZe2KZmWSNbhA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-03-28T10:31:05Z"
|
||||
mac: ENC[AES256_GCM,data:6Z+ltjbvQaYhDPoiCN7ajQeWcp6vj3TIcUXUm/r/tZU4mIOvfxA7hxW971b76bYPTeVwgp7ZB9qQy9emDHV9i+aSyJpTPKQHRRz5J+T+NJhTP/IL3R3VmG89ssC6NH8FSk0S487JkPd8tNz+G6bvwFCPRxRLNj1pXX0Dp6tgwIw=,iv:xLw2iX1ODAbJCTJ8fEvG7SdZ1GnGwADIckH8DibVM2Y=,tag:TTzlHdcyIQr/92ZHmViRXQ==,type:str]
|
||||
lastmodified: "2024-06-30T10:43:57Z"
|
||||
mac: ENC[AES256_GCM,data:Mg/DZghIkaWM5KEjk5zg3S0L5qPa8/rkc2ooSjA1ewzbDhTKls2tzv7fQqLx2WQtcJiKkoVx22UkiL0AzBwJdCr3473vx93ajTVK9HNu3jqXmuzSiv2iVS21EX9tyBNiL6uWlVAtlVfMMs69PEUF+EJIYY5TkVVPaQjzEebwo5w=,iv:tFON7RVSnNNHo5U4dRuMGDhH5iPGShW9uoda+apiIjI=,tag:3nG/u7vaChFBHoDsLLb23w==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
@@ -30,6 +30,7 @@ inputs:
|
||||
nix.substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ];
|
||||
initrd.sshd.enable = true;
|
||||
networking = { hostname = "vps7"; networkd = {}; };
|
||||
kernel.variant = "cachyos-server";
|
||||
};
|
||||
services =
|
||||
{
|
||||
@@ -45,16 +46,16 @@ inputs:
|
||||
matrix = { port = 8009; redisPort = 6380; slidingSyncPort = 9001; };
|
||||
};
|
||||
vaultwarden.enable = true;
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 1024; };
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 1024; loadAverage = 4; };
|
||||
photoprism.enable = true;
|
||||
nextcloud.enable = true;
|
||||
nextcloud = {};
|
||||
freshrss.enable = true;
|
||||
send.enable = true;
|
||||
huginn.enable = true;
|
||||
fz-new-order = {};
|
||||
nginx.applications = { kkmeeting.enable = true; webdav.instances."webdav.chn.moe" = {}; };
|
||||
httpapi.enable = true;
|
||||
gitea.enable = true;
|
||||
gitea = { enable = true; ssh = {}; };
|
||||
grafana.enable = true;
|
||||
fail2ban = {};
|
||||
wireguard =
|
||||
@@ -67,6 +68,7 @@ inputs:
|
||||
};
|
||||
vikunja.enable = true;
|
||||
chatgpt = {};
|
||||
xray.server = { serverName = "xserver.vps7.chn.moe"; userNumber = 4; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
acme:
|
||||
cloudflare.ini: ENC[AES256_GCM,data:PJ3JhdSPCyxzdcRI4UFdESWgyAjIYGyuVaU9l0R3s8mJidtgavvSSMy0hC0G/2fauLB/Eqc3L3NppXFjlKVywVE=,iv:lZVlOf7P/Vs/+u/5YPKFXmdeYV9NP9kcVWd00w1OjB4=,tag:LfWZTvPQH4QPrNrYfZ/Z6Q==,type:str]
|
||||
token: ENC[AES256_GCM,data:D5D9Voteggfoc7Hj/xdhGEHmFIkG2H0Y0t2AfSY7hjRlsQhUoAzCRg==,iv:JLUjY/6DJrNsG0YZ0WD/Dmjgjsbx26VANAQvZnyj6l4=,tag:WBQv8AvPW5+XK8FAzppnNw==,type:str]
|
||||
nginx:
|
||||
detectAuth:
|
||||
chn: ENC[AES256_GCM,data:Gk0TTbnFcsvIgoDcen6B8w==,iv:kvyvygw9zDwaiTQ2vPFTHQex0EWDFg8M8U22AConQFM=,tag:ewAZ/nXxmTOhDAjW/A2OnA==,type:str]
|
||||
@@ -91,8 +91,6 @@ fz-new-order:
|
||||
username: ENC[AES256_GCM,data:xWP1cesh,iv:11KFZ/J9PScz/oW2+H5BWgw0+ETkCXlcYOMuPpgjEs0=,tag:HswEVzm6ElRjIDsZyEfZcA==,type:str]
|
||||
password: ENC[AES256_GCM,data:Da/E7ZeZ,iv:gIoheXeTErV3+CtZSEDsX7pGzRahHWlKYQ6QZ6W2eu8=,tag:0oQzQ5DJiS2hqMQfU6JRWw==,type:str]
|
||||
comment: ENC[AES256_GCM,data:etfZKwbh,iv:XqqF3D0PpCPd2Q/CCu/PAH4SrvXAOu+lIXvSht/KfKk=,tag:7jyG33foxneRK2wvI/5uBg==,type:str]
|
||||
httpapi:
|
||||
token: ENC[AES256_GCM,data:fuGJ+5sKr3yob7JbyqtwGBAxnDzxTvoC5XPWHNawOjqC7Ydz6HujpYudG2CUMxt+rA==,iv:Yhg5NqRRp+PYsxNKFUiUydAL1hmz2pr/T0f5GDKV18w=,tag:SZoy0gTzpeq39mEFBTUDLA==,type:str]
|
||||
gitlab:
|
||||
secret: ENC[AES256_GCM,data:hBax7ClSuttBacykKw42pvrvowZW8OeTry/0rkmy5BHyLM7HllNYCOw+tupIOdhVEfgJPWQeBeGuyFHt7lPRWQ==,iv:zOM+eMW04Z9QkTchkAXWYHg2eWTQmGEs/dHtUnvNVd8=,tag:RzLyecuASl9CcmQSuabN6w==,type:str]
|
||||
otp: ENC[AES256_GCM,data:Hgq5Tyq+BUTsexVsjFWf07fY0znPL50+qIm+fhuVljlauXBZouQjJKMhqTs9zhLECOktYUtp0wrNa++nO1Ys9A==,iv:Am51j8QjDtldtsZL8uCu0I3pr/SQ6R8KUQinznZjClg=,tag:hbtrlG0MGNL3VcbQUG/irQ==,type:str]
|
||||
@@ -107,6 +105,20 @@ vikunja:
|
||||
jwtsecret: ENC[AES256_GCM,data:p6e22qPJzTGB21oWhSr8AA4bfrele9ZOHVtZ8BHgX21IhoKdm58coGtSX1CGXR7J6+1/74RdLY9K88nGrM1F1w==,iv:DGUO8rhf7Lg9dTqSmzlR/Jd2K4oUjO8w9E5bihwsykI=,tag:SpX6UI0QIju/tC1fIL9CCg==,type:str]
|
||||
chatgpt:
|
||||
key: ENC[AES256_GCM,data:bkLxKUqkjwpUeqeAZCaAgKiOse8QtZ0zOn9TQNA84+B3rxNiTFPisI8=,iv:Zd5dO5Sdt4HCvNZgS2K0FjJAzti6oE22vahYQl99TrI=,tag:E3o+X84tRsIEGU9Jfb85JQ==,type:str]
|
||||
telegram:
|
||||
token: ENC[AES256_GCM,data:Mr6KrAzYoDXA+dPT3oXqK2wm9ahTjZ5GVE/iRPsmcM+S2MABT+8ramyHz9oIFw==,iv:nIZ8rpSxz2GwMbDQFfG3xauMQjiriZ1oxFMrEQeH7sQ=,tag:y5U1T1vV/mmdE/CeaeTR8g==,type:str]
|
||||
chat: ENC[AES256_GCM,data:8w/0EI64a1dC,iv:dHu9JHcUY7QPd9YBKXnrRXQB2K6jpnLrSFs+1IJmkio=,tag:3ucN3uNnBxxRF+cbLsa1nQ==,type:str]
|
||||
xray-server:
|
||||
clients:
|
||||
#ENC[AES256_GCM,data:aAZS,iv:Z+iJG7yC6HJeNdKCCpsZSc9Ny7kAt6GYfXUtZozMb4A=,tag:iMfwjqqmLvu5a8YpF7a0zQ==,type:comment]
|
||||
user0: ENC[AES256_GCM,data:Q8MFrN/3SRgzSlwTx2GmpP/gvG1vpYiVgjsESzUoomsJaigP,iv:oLsf7AX3FE0tFOkJAbqrZVrCa6UxKjp450Sl1rs2Vs0=,tag:5w+AX0p4Or1GAQsEU3NxOQ==,type:str]
|
||||
#ENC[AES256_GCM,data:j3zVwqHmag==,iv:8+ol60wNlbV2RzMBe47VxIrZuec8aXDUNcQvHcxKuiA=,tag:1AgCMfZf9vzWiWDS6hkw2Q==,type:comment]
|
||||
user1: ENC[AES256_GCM,data:ucCiL7uoSafFUP9IiwKOjJqgwNxNLmuHxYXsLYl0fBgbCT3F,iv:RbNPwvSWibODQqySRc+YW65nUvRwaeXT0eDh02sfrwM=,tag:iE7GGrkBxljBT9HdPzDOfA==,type:str]
|
||||
#ENC[AES256_GCM,data:x7dwVDe22M8=,iv:+fT7VUxZGd8SgS0PnEBqHLPLDuywu4s01iWB6TA/BKQ=,tag:CxfP7xSd4L9RBulSfViHaQ==,type:comment]
|
||||
user2: ENC[AES256_GCM,data:e6PbRg30dzOJSXNmU6TML4AaFsSWEvZwN7MHAEX6fEW2p3hW,iv:Y+YYAO6hY9e/T8LSCr34M7riGmSzFIocmWwAwWjnZQs=,tag:LTkdGcRyrx7HqvbSYSsv4A==,type:str]
|
||||
#ENC[AES256_GCM,data:j83rYg==,iv:3oEdAoVz7aMcezcy2chTO0LQTtKpTrJJoQZx3PC03BU=,tag:ABteEIyr2Y6MbGQhmrQySQ==,type:comment]
|
||||
user3: ENC[AES256_GCM,data:Uk0Ax9FVzmmYs+ggWy7z6FEkuj2tppGlvnQdoW6PDI1VA9oI,iv:wSxigXleRUalQR1/TzKfdUVrdyEUuq+Wg42gSv1QMAI=,tag:qn6nBWv6MlGhMarCfI13BA==,type:str]
|
||||
private-key: ENC[AES256_GCM,data:TarrinCFzWkB5zCc7i7f3B3tFfxrF+cGnrg4bw9CAGKWBazSJHCviY8Imw==,iv:azHdrc6AlgS9RPwGVsYRb8bBeC/askCdut1rnv9TA3I=,tag:AT2lLraKVgbp9GmlLJiI+w==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -131,8 +143,8 @@ sops:
|
||||
SnFHS1Z0SXUzTFdEd29KTy9DU3Y3R0UKfhh+rUmWDrf+UGjclP57dHipPLFoXSqy
|
||||
HdelmfV6q4/c7ppx2E+oZw3VNgoZCsrxxzYZfwxHJiZb+5vkE0D8iA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-04-18T13:48:22Z"
|
||||
mac: ENC[AES256_GCM,data:LjUMKJBWlNb/7s2VfFQATmRNPpmP0w7wZ+/7R2rpeH/1rTUH7ee3f3tutHijF1MnFjx1Z22iGC0jW/P9VBedKSETJBhQQ9lHZDqr7dzr+InbnYQ1sCt2LnLBu1m7bACgOxh9xr9v8pGIj9UdW+9gMhpSIB5r8h6/cIuBiO/7eqs=,iv:d0qj6vZSHoeuZNsLCzAJ6Ono4Mqf01SWkygItkP5Vco=,tag:CAQ2O6/86Smc77qrfcU7Xg==,type:str]
|
||||
lastmodified: "2024-06-08T09:15:52Z"
|
||||
mac: ENC[AES256_GCM,data:EY6sFc4EcTuxPgIZQ51HFZZZf+khb7mkNEvb6U12kCtoJAEo+i83uszwBZCo/QWw6VCCt9c//9y0mNH4FjZPJAxweJHcRtanyTXa5jdyv12qINUceYe7Uhcb7JuiiEns9DEbrr3UeAKfbPC+N5mD/2trzht0E8hqnFlWU/fysz8=,iv:saymdP4nFveEWx0JrBR2bW8SUl6xCJKhYqw+CsrfRG8=,tag:CHGvJAO8hpSMNdU2YE2OGw==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
12
devices/wlin.xmuhpc/.bash_profile
Normal file
12
devices/wlin.xmuhpc/.bash_profile
Normal file
@@ -0,0 +1,12 @@
|
||||
# .bash_profile
|
||||
|
||||
# Get the aliases and functions
|
||||
if [ -f ~/.bashrc ]; then
|
||||
. ~/.bashrc
|
||||
fi
|
||||
|
||||
# User specific environment and startup programs
|
||||
|
||||
PATH=$PATH:$HOME/bin
|
||||
|
||||
export PATH
|
||||
43
devices/wlin.xmuhpc/.bashrc
Normal file
43
devices/wlin.xmuhpc/.bashrc
Normal file
@@ -0,0 +1,43 @@
|
||||
# .bashrc
|
||||
|
||||
# Source global definitions
|
||||
if [ -f /etc/bashrc ]; then
|
||||
. /etc/bashrc
|
||||
fi
|
||||
|
||||
export PATH=$PATH:/data/gpfs01/wlin/bin
|
||||
|
||||
# User specific aliases and functions
|
||||
export PATH=/data/gpfs01/wlin/bin/vaspkit.1.4.1/bin:${PATH}
|
||||
#export PATH=~/bin:/data/gpfs01/wlin/opt/mpich_ifort/bin:$PATH
|
||||
#export LD_LIBRARY_PATH=/data/gpfs01/wlin/opt/mpich_ifort/lib:$LD_LIBRARY_PATH
|
||||
#export PATH=~/bin:/data/gpfs01/wlin/opt/mpich/bin:$PATH
|
||||
#export LD_LIBRARY_PATH=/data/gpfs01/wlin/opt/mpich/lib:$LD_LIBRARY_PATH
|
||||
export P4_RSHCOMMAND=ssh
|
||||
shopt -s cdspell
|
||||
export HISTCONTROL=ignoredups
|
||||
#shopt -s histappend
|
||||
PROMPT_COMMAND='history -a'
|
||||
export C3_RSH="ssh -x"
|
||||
export OMP_NUM_THREADS=1
|
||||
export MKL_NUM_THREADS=1
|
||||
alias grep='grep --color'
|
||||
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
|
||||
|
||||
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S `whoami`@${USER_IP}: "
|
||||
export HISTFILESIZE=1000000
|
||||
export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND"
|
||||
shopt -s histappend
|
||||
# Auto add env parameter $PROMPT_COMMAND when use non-Linux tty login by ssh.
|
||||
if [ "$SSH_CONNECTION" != '' -a "$TERM" != 'linux' ]; then
|
||||
declare -a HOSTIP
|
||||
HOSTIP=`echo $SSH_CONNECTION |awk '{print $3}'`
|
||||
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@$HOSTIP:[${HOSTNAME%%.*}]:${PWD/#$HOME/~} \007"'
|
||||
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
|
||||
|
||||
@@ -16,10 +16,25 @@ SLURM 是一个用来对任务排队的系统,轮到某个任务时,再调
|
||||
|
||||
## 常用命令
|
||||
|
||||
我做了一个 TUI 界面,用起来比较简单,大多情况下可以满足需求。命令为:
|
||||
|
||||
```bash
|
||||
sbatch-tui
|
||||
```
|
||||
|
||||
或
|
||||
|
||||
```bash
|
||||
sbatch
|
||||
```
|
||||
|
||||
如果需要在提交任务时指定更详细的细节,或者要编写脚本批量提交任务,则在 `sbatch` 后面加上参数,这时是直接调用来自 SLURM 的 `sbatch` 命令。
|
||||
常用的参数见下文。更详细的内容见 SLURM 的官方文档。
|
||||
|
||||
提交一个 VASP GPU 任务的例子:
|
||||
|
||||
```bash
|
||||
sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" vasp-nvidia-640
|
||||
sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" vasp-nvidia
|
||||
```
|
||||
|
||||
* `--gpus` 指定使用GPU 的情况:
|
||||
@@ -30,12 +45,12 @@ sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" vasp-nvidia-640
|
||||
* `--ntasks-per-gpu=1` 对于 VASP 来说一定要写。
|
||||
* `--job-name=xxx` 指定任务的名字。可以简写为 `-J`。也可以不指定。
|
||||
* 默认情况下,一个 task 会搭配分配一个 CPU 核(一个线程),一般已经够用。如果一定要修改,用 `--cpus-per-task`。
|
||||
* `vasp-nvidia-640` 指调用 std 版本,要使用 gam 或 ncl 版本时,写为例如 `vasp-nvidia-640-gam`。
|
||||
* `vasp-nvidia` 指调用 std 版本,要使用 gam 或 ncl 版本时,写为例如 `vasp-nvidia-gam`。
|
||||
|
||||
提交一个 VASP CPU 任务的例子:
|
||||
|
||||
```bash
|
||||
sbatch --ntasks=4 --cpus-per-task=4 --hint=nomultithread --job-name="my great job" vasp-intel-640
|
||||
sbatch --ntasks=4 --cpus-per-task=4 --hint=nomultithread --job-name="my great job" vasp-intel
|
||||
```
|
||||
|
||||
* `--ntasks=4 --cpus-per-task=4` 指定使用占用多少核。
|
||||
@@ -45,7 +60,7 @@ sbatch --ntasks=4 --cpus-per-task=4 --hint=nomultithread --job-name="my great jo
|
||||
* 对于 xmupc2:`--ntasks=4 --cpus-per-task=10`。
|
||||
* `--hint=nomultithread` 记得写。
|
||||
* `--job-name=xxx` 指定任务的名字。可以简写为 `-J`。也可以不指定。
|
||||
* `vasp-intel-640` 指调用 std 版本,要使用 gam 或 ncl 版本时,写为例如 `vasp-intel-640-gam`。
|
||||
* `vasp-intel` 指调用 std 版本,要使用 gam 或 ncl 版本时,写为例如 `vasp-intel-gam`。
|
||||
|
||||
要把其它程序提交到队列里,也是类似的写法。请自行举一反三。
|
||||
|
||||
@@ -186,7 +201,6 @@ samba 就是 windows 共享文件夹的那个协议。
|
||||
|
||||
VASP 有很多很多个版本,具体来说:
|
||||
|
||||
* VASP 多个版本可以共存,但为了简单只安装了 6.4.0 版本。
|
||||
* VASP 可以用不同的编译器编译。目前安装的有:nvidia、intel。nvidia 使用 GPU 计算,intel 能用 CPU 计算。其它版本性能不佳,没有安装。
|
||||
* VASP 的 std/gam/ncl 版本有一点区别,一般用 std,只有一个 gamma 点的时候用 gam 会快一点,系统中存在方向不平行的磁矩时必须用 ncl。
|
||||
* 无论哪个版本,都集成了下面这些补丁:
|
||||
@@ -199,14 +213,14 @@ VASP 有很多很多个版本,具体来说:
|
||||
如何提交 VASP 到队列系统已经在上面介绍过了。下面的例子是,如果要直接运行一个任务的写法:
|
||||
|
||||
```bash
|
||||
vasp-nvidia-640-env mpirun -np 1 -x CUDA_DEVICE_ORDER=PCI_BUS_ID -x CUDA_VISIBLE_DEVICES=0 -x OMP_NUM_THREADS=4 vasp-std
|
||||
vasp-intel-640-env mpirun -n 2 -genv OMP_NUM_THREADS=4 vasp-std
|
||||
vasp-nvidia-env mpirun -np 1 -x CUDA_DEVICE_ORDER=PCI_BUS_ID -x CUDA_VISIBLE_DEVICES=0 -x OMP_NUM_THREADS=4 vasp-std
|
||||
vasp-intel-env mpirun -n 2 -genv OMP_NUM_THREADS=4 vasp-std
|
||||
```
|
||||
|
||||
其中 `CUDA_VISIBLE_DEVICES` 用于指定用哪几个显卡计算(多个显卡用逗号分隔)。
|
||||
要查看显卡的编号,可以用 `CUDA_DEVICE_ORDER=PCI_BUS_ID vasp-nvidia-640-env nvaccelinfo` 命令。
|
||||
要查看显卡的编号,可以用 `CUDA_DEVICE_ORDER=PCI_BUS_ID vasp-nvidia-env nvaccelinfo` 命令。
|
||||
|
||||
这里 `vasp-xxx-6.4.0` 命令的作用是,进入一个安装了对应版本的 VASP 的环境,实际上和 VASP 关系不大;
|
||||
这里 `vasp-xxx-env` 命令的作用是,进入一个安装了对应版本的 VASP 的环境,实际上和 VASP 关系不大;
|
||||
后面的 `mpirun xxx` 才是真的调用 VASP。
|
||||
所以实际上你也可以在这个环境里做别的事情,例如执行上面的 `nvaccelinfo` 命令。
|
||||
|
||||
|
||||
@@ -57,9 +57,8 @@ inputs:
|
||||
services =
|
||||
{
|
||||
snapper.enable = true;
|
||||
fontconfig.enable = true;
|
||||
sshd = { passwordAuthentication = true; groupBanner = true; };
|
||||
xray.client.dae.wanInterface = [ "wlp57s0" ];
|
||||
xray.client.enable = true;
|
||||
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
|
||||
smartd.enable = true;
|
||||
beesd.instances =
|
||||
@@ -77,7 +76,7 @@ inputs:
|
||||
slurm =
|
||||
{
|
||||
enable = true;
|
||||
cpu = { cores = 16; threads = 2; };
|
||||
cpu = { cores = 16; threads = 2; mpiThreads = 3; openmpThreads = 4; };
|
||||
memoryMB = 94208;
|
||||
gpus = { "2080_ti" = 1; "3090" = 1; "4090" = 1; };
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
acme:
|
||||
cloudflare.ini: ENC[AES256_GCM,data:PjCyozvFTXxA///enYYbaMZ8ISfFjJviLVKfdOcMSi5G3CEjEsp1Ez4krbgy4/eJo4v9HfTN0bMmUnl2OHOyzTg=,iv:e1iQZ5JUHkzfnfP956Lzl3FWs11xdULctA5MZsALtU0=,tag:8X2Q/Hixxn/ci4XRSUDidg==,type:str]
|
||||
token: ENC[AES256_GCM,data:KKMdZgzciiM+n0Hdsb8vivjmCw6SiqJMbEAmvFwFQgvS9zpCNSyh+g==,iv:GbNJrVLmFudVzgoLdf+j8JsEPRvrQhBu3+2585grReQ=,tag:3tNL+2hoz2R9aOz0TUTjVQ==,type:str]
|
||||
nginx:
|
||||
maxmind-license: ENC[AES256_GCM,data:/7R7w+fiMw54Cmd7y/wT/s8RMqFMf3Fc0Mph0ZhURmCzowkmLEhtmw==,iv:i+Z+2NbssI864Edwf73SQfaeFuWoqr+U8eQ/8R23FOk=,tag:8ITlkS97vlsmHM1HDk6/3A==,type:str]
|
||||
xray-client:
|
||||
@@ -41,8 +41,8 @@ sops:
|
||||
ZDNHUjE2QVlCV3p0NHdKYW5IMHVBZzQKkZtfyvfroOntg3yRjMw4jQHiQj8eaB2h
|
||||
IeIHfW4y01mmVT2ofbtB0xYpjcl4gtUlQ8X3tn5iJ9P8gcVo0G598A==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-03-10T13:47:17Z"
|
||||
mac: ENC[AES256_GCM,data:19w2Q1SRhKIyxibGgKa+CkEhiizFJ27FePOlMll+8tJVJRzfIl8KrutlRi0hMhEYFlML0bWunbINUEIg7yJbIwFCSjxFDnqKsCT3iClT3kaktxr5+0R+ECoQTGGV67VkT5WY/LT3V1zdLYI38MVaBQObGKCpBs23nIK2QXrg39Q=,iv:q1ezSmo14vsmEE8owxnsonWMq2uj6mrVjKNh+RuK+cE=,tag:QBc99UEaEPiEgZH+Z3Z8tA==,type:str]
|
||||
lastmodified: "2024-05-10T08:53:57Z"
|
||||
mac: ENC[AES256_GCM,data:ImxIE0d7cEpudUKGs9zHCMFKlHYwFfztLWe5ZMWOrQxr7/uRxfCsiIvuU1nRri0jx2x8J6EFAG1BdrF4KRSeW5sIB9Tlk7X1TJ69zSdLhhnIuPl+rSyovoIkMQAJ0Wvyvlgimh1VQyaBkPsjnGk/dga1N0+gIlmiwFKY5uTpaaA=,iv:fo6S9fIDxnp7VWYYWH613U6bxIlDBZaNObkRR3AdgEc=,tag:ZRIMHkWRsf75K3Tg3Xv5xw==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
@@ -51,9 +51,8 @@ inputs:
|
||||
services =
|
||||
{
|
||||
snapper.enable = true;
|
||||
fontconfig.enable = true;
|
||||
sshd = { passwordAuthentication = true; groupBanner = true; };
|
||||
xray.client.dae.wanInterface = [ "wlp4s0" ];
|
||||
xray.client.enable = true;
|
||||
firewall.trustedInterfaces = [ "virbr0" "waydroid0" ];
|
||||
smartd.enable = true;
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 16384; threads = 4; };
|
||||
@@ -67,7 +66,7 @@ inputs:
|
||||
slurm =
|
||||
{
|
||||
enable = true;
|
||||
cpu = { sockets = 2; cores = 22; threads = 2; };
|
||||
cpu = { sockets = 2; cores = 22; threads = 2; mpiThreads = 4; openmpThreads = 10; };
|
||||
memoryMB = 253952;
|
||||
gpus = { "4090" = 1; "p5000" = 1; };
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
acme:
|
||||
cloudflare.ini: ENC[AES256_GCM,data:/y070fzfZFI/Jb9xS8UO7iRnjHJ3uItqsHqjyHPAqsTN4tSEyMpaE3KtNpecgWxk2PvLRfqdmdwu/bnGlIp7adU=,iv:fv4dbeK1F/cn5nhnSC1lTUqxeFPG/0lNqEvPWMH6Mzw=,tag:dE4clxPGraAXXsJM6NS8XQ==,type:str]
|
||||
token: ENC[AES256_GCM,data:Wb7Gons3HCMK5WGIZpG4XrrqZ5G6bymjuKMW6IUjLiK0CIXFz/ARNg==,iv:zc4BgHcc+O7SHQbJkff11fBwgsd+TFtvSEGJ/qrzVo4=,tag:K+Nu9kenTtTnin4+hDCdWA==,type:str]
|
||||
nginx:
|
||||
maxmind-license: ENC[AES256_GCM,data:FPVSD8otQMNpbESNEHXCfQjB/zi3OVwZoyLijUtnHQlQzec7KVSiGw==,iv:DkkwCqvRmcFHQIXseh2fycCxZboJMYhHPu67GddenY4=,tag:iHEC8r5GcuB1QcZ5Uf8Skw==,type:str]
|
||||
xray-client:
|
||||
@@ -41,8 +41,8 @@ sops:
|
||||
M0xoL1dQR0kvMWpzN0RMNWVCTFQxNFUKj9LPjBo5NGOrGYNvu8qZ13PLYjLEWllU
|
||||
LARzEn4XgkeHckouwvxZYMCx7WxmAruRWaOvnxTIczzSNP7wIrqnkA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-03-10T13:46:59Z"
|
||||
mac: ENC[AES256_GCM,data:j+bdp0emAtTNNI7aZsKTJ+uARsuyLb9GRV0CeIb2EoZaOmj5cJpUzYtcAWIdCYplt1ZScCcR7iQPUlCzUb0+pXth7QDibtGJcj0dqw87DoaY3cqm7jNkKteiIYxXOCmbMBgED9eMxQVdcGZTDSuTQ0KjFYoXkcUSriMsJltDUDc=,iv:+eLNmlxeqB/Q7Rmz5B/wZSajiesV+/ED3ROJuuShpfo=,tag:95xKRRuqRZkUFUjHbPrDNw==,type:str]
|
||||
lastmodified: "2024-05-10T08:54:10Z"
|
||||
mac: ENC[AES256_GCM,data:4n7bAGzORwd6vHl/Cs5YT8VZaSdfvxUm6e+fw7PYC2ov8XoRlJKU/Bci8Sbwcy2H6OjbkdRYA61cB2wAjtEY1x9N/c6qvUAOjTvOtcXoQQex8d+aMnJsFfJQ70GHCZE+KRTmy1SAMn+N00Oy0FDisdQe/jIZuWyav5j62CKqLqc=,iv:YEhiXU2IgXy4A0ZLsNY7kFqXJM5RBHE4IZwlRoF8XMA=,tag:aVc0r2g1QkY42NP59p4m2w==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
1208
flake.lock
generated
1208
flake.lock
generated
File diff suppressed because it is too large
Load Diff
158
flake.nix
158
flake.nix
@@ -3,35 +3,25 @@
|
||||
|
||||
inputs =
|
||||
{
|
||||
# TODO: add color scheme
|
||||
nixpkgs.url = "github:CHN-beta/nixpkgs/nixos-23.11";
|
||||
nixpkgs.url = "github:CHN-beta/nixpkgs/nixos-24.05";
|
||||
nixpkgs-unstable.url = "github:CHN-beta/nixpkgs/nixos-unstable";
|
||||
"nixpkgs-23.11".url = "github:CHN-beta/nixpkgs/nixos-23.11";
|
||||
"nixpkgs-23.05".url = "github:CHN-beta/nixpkgs/nixos-23.05";
|
||||
"nixpkgs-22.11".url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
"nixpkgs-22.05".url = "github:NixOS/nixpkgs/nixos-22.05";
|
||||
home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
home-manager = { url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
sops-nix =
|
||||
{
|
||||
url = "github:Mic92/sops-nix";
|
||||
inputs = { nixpkgs.follows = "nixpkgs"; nixpkgs-stable.follows = "nixpkgs"; };
|
||||
};
|
||||
aagl = { url = "github:ezKEa/aagl-gtk-on-nix"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
aagl = { url = "github:ezKEa/aagl-gtk-on-nix/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
nix-index-database = { url = "github:Mic92/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs-unstable"; };
|
||||
nur.url = "github:nix-community/NUR";
|
||||
nixos-cn = { url = "github:nixos-cn/flakes"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
nur-xddxdd =
|
||||
{
|
||||
url = "github:xddxdd/nur-packages?rev=404bc382a29f3d78b03871b96016579d6a0aa305";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nur-xddxdd = { url = "github:xddxdd/nur-packages"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
nix-vscode-extensions = { url = "github:nix-community/nix-vscode-extensions"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
impermanence.url = "github:nix-community/impermanence";
|
||||
qchem = { url = "github:Nix-QChem/NixOS-QChem/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
nixd = { url = "github:nix-community/nixd"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
napalm = { url = "github:nix-community/napalm"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
nixpak = { url = "github:nixpak/nixpak"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
qchem = { url = "github:Nix-QChem/NixOS-QChem/master"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
deploy-rs = { url = "github:serokell/deploy-rs"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
pnpm2nix-nzbr = { url = "github:CHN-beta/pnpm2nix-nzbr"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
plasma-manager =
|
||||
{
|
||||
url = "github:pjones/plasma-manager";
|
||||
@@ -48,15 +38,13 @@
|
||||
url = "github:chaotic-cx/nyx";
|
||||
inputs = { nixpkgs.follows = "nixpkgs"; home-manager.follows = "home-manager"; };
|
||||
};
|
||||
# TODO: pick it from nixpkgs
|
||||
nix-inspect.url = "github:bluskript/nix-inspect";
|
||||
gricad = { url = "github:Gricad/nur-packages"; flake = false; };
|
||||
catppuccin.url = "github:catppuccin/nix";
|
||||
bscpkgs = { url = "git+https://pm.bsc.es/gitlab/rarias/bscpkgs.git"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
|
||||
misskey = { url = "git+https://github.com/CHN-beta/misskey?submodules=1"; flake = false; };
|
||||
rsshub = { url = "github:DIYgod/RSSHub"; flake = false; };
|
||||
zpp-bits = { url = "github:eyalz800/zpp_bits"; flake = false; };
|
||||
citation-style-language = { url = "git+https://github.com/zepinglee/citeproc-lua?submodules=1"; flake = false; };
|
||||
concurrencpp = { url = "github:David-Haim/concurrencpp"; flake = false; };
|
||||
cppcoro = { url = "github:Garcia6l20/cppcoro"; flake = false; };
|
||||
date = { url = "github:HowardHinnant/date"; flake = false; };
|
||||
@@ -69,42 +57,62 @@
|
||||
win11os-kde = { url = "github:yeyushengfan258/Win11OS-kde"; flake = false; };
|
||||
fluent-kde = { url = "github:vinceliuice/Fluent-kde"; flake = false; };
|
||||
rycee = { url = "gitlab:rycee/nur-expressions"; flake = false; };
|
||||
blurred-wallpaper =
|
||||
{ url = "github:bouteillerAlan/blurredwallpaper?rev=aecc88d43e458a0962a0091dcdb7baac34e263be"; flake = false; };
|
||||
blurred-wallpaper = { url = "github:bouteillerAlan/blurredwallpaper"; flake = false; };
|
||||
slate = { url = "github:TheBigWazz/Slate"; flake = false; };
|
||||
linux-surface = { url = "github:linux-surface/linux-surface"; flake = false; };
|
||||
lepton = { url = "github:black7375/Firefox-UI-Fix"; flake = false; };
|
||||
lmod = { url = "github:TACC/Lmod"; flake = false; };
|
||||
mumax = { url = "github:CHN-beta/mumax"; flake = false; };
|
||||
kylin-virtual-keyboard = { url = "git+https://gitee.com/openkylin/kylin-virtual-keyboard.git"; flake = false; };
|
||||
cjktty = { url = "github:zhmars/cjktty-patches"; flake = false; };
|
||||
cjktty = { url = "github:CHN-beta/cjktty-patches"; flake = false; };
|
||||
zxorm = { url = "github:CHN-beta/zxorm"; flake = false; };
|
||||
openxlsx = { url = "github:troldal/OpenXLSX"; flake = false; };
|
||||
sqlite-orm = { url = "github:fnc12/sqlite_orm"; flake = false; };
|
||||
|
||||
# does not support lfs yet
|
||||
# nixos-wallpaper = { url = "git+https://git.chn.moe/chn/nixos-wallpaper.git"; flake = false; };
|
||||
};
|
||||
|
||||
outputs = inputs:
|
||||
let
|
||||
localLib = import ./local/lib inputs.nixpkgs.lib;
|
||||
devices = builtins.attrNames (builtins.readDir ./devices);
|
||||
devices = builtins.filter (dir: (builtins.readDir ./devices/${dir})."default.nix" or null == "regular" )
|
||||
(builtins.attrNames (builtins.readDir ./devices));
|
||||
in
|
||||
{
|
||||
packages.x86_64-linux =
|
||||
{
|
||||
default = inputs.nixpkgs.legacyPackages.x86_64-linux.writeText "systems"
|
||||
(builtins.concatStringsSep "\n" (builtins.map
|
||||
(system: builtins.toString inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel)
|
||||
devices));
|
||||
}
|
||||
// (
|
||||
builtins.listToAttrs (builtins.map
|
||||
(system:
|
||||
{
|
||||
name = system;
|
||||
value = inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel;
|
||||
})
|
||||
devices)
|
||||
);
|
||||
# ssh-keygen -t rsa -C root@pe -f /mnt/nix/persistent/etc/ssh/ssh_host_rsa_key
|
||||
# ssh-keygen -t ed25519 -C root@pe -f /mnt/nix/persistent/etc/ssh/ssh_host_ed25519_key
|
||||
# systemd-machine-id-setup --root=/mnt/nix/persistent
|
||||
let pkgs = (import inputs.nixpkgs
|
||||
{
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
overlays = [ inputs.self.overlays.default ];
|
||||
});
|
||||
in
|
||||
{
|
||||
default = inputs.nixpkgs.legacyPackages.x86_64-linux.writeText "systems"
|
||||
(builtins.concatStringsSep "\n" (builtins.map
|
||||
(system: builtins.toString inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel)
|
||||
devices));
|
||||
hpcstat =
|
||||
let
|
||||
openssh = (pkgs.pkgsStatic.openssh.override { withLdns = false; etcDir = null; }).overrideAttrs
|
||||
(prev: { doCheck = false; patches = prev.patches ++ [ ./local/pkgs/hpcstat/openssh.patch ];});
|
||||
duc = pkgs.pkgsStatic.duc.override { enableCairo = false; cairo = null; pango = null; };
|
||||
in pkgs.pkgsStatic.localPackages.hpcstat.override
|
||||
{ inherit openssh duc; standalone = true; version = inputs.self.rev or "dirty"; };
|
||||
ufo = pkgs.pkgsStatic.localPackages.ufo.override { version = inputs.self.rev or "dirty"; };
|
||||
chn-bsub = pkgs.pkgsStatic.localPackages.chn-bsub;
|
||||
nixpkgs = pkgs;
|
||||
}
|
||||
// (
|
||||
builtins.listToAttrs (builtins.map
|
||||
(system:
|
||||
{
|
||||
name = system;
|
||||
value = inputs.self.outputs.nixosConfigurations.${system}.config.system.build.toplevel;
|
||||
})
|
||||
devices)
|
||||
);
|
||||
nixosConfigurations =
|
||||
(
|
||||
(builtins.listToAttrs (builtins.map
|
||||
@@ -142,23 +150,6 @@
|
||||
};
|
||||
}
|
||||
);
|
||||
# sudo HTTPS_PROXY=socks5://127.0.0.1:10884 nixos-install --flake .#bootstrap --option substituters http://127.0.0.1:5000 --option require-sigs false --option system-features gccarch-silvermont
|
||||
# nix-serve -p 5000
|
||||
# nix copy --substitute-on-destination --to ssh://server /run/current-system
|
||||
# nix copy --to ssh://nixos@192.168.122.56 ./result
|
||||
# sudo nixos-install --flake .#bootstrap
|
||||
# --option substituters http://192.168.122.1:5000 --option require-sigs false
|
||||
# sudo chattr -i var/empty
|
||||
# nix-shell -p ssh-to-age --run 'cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age'
|
||||
# sudo nixos-rebuild switch --flake .#vps6 --log-format internal-json -v |& nom --json
|
||||
# boot.shell_on_fail systemd.setenv=SYSTEMD_SULOGIN_FORCE=1
|
||||
# sudo usbipd
|
||||
# ssh -R 3240:127.0.0.1:3240 root@192.168.122.57
|
||||
# modprobe vhci-hcd
|
||||
# sudo usbip bind -b 3-6
|
||||
# usbip attach -r 127.0.0.1 -b 3-6
|
||||
# systemd-cryptenroll --fido2-device=auto /dev/vda2
|
||||
# systemd-cryptsetup attach root /dev/vda2
|
||||
deploy =
|
||||
{
|
||||
sshUser = "root";
|
||||
@@ -183,15 +174,46 @@
|
||||
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks inputs.self.deploy) inputs.deploy-rs.lib;
|
||||
overlays.default = final: prev:
|
||||
{ localPackages = (import ./local/pkgs { inherit (inputs) lib; pkgs = final; topInputs = inputs; }); };
|
||||
config.archive = false;
|
||||
devShell.x86_64-linux = let inherit (inputs.self.nixosConfigurations.pc) pkgs; in pkgs.mkShell
|
||||
{
|
||||
packages = with pkgs; [ pkg-config cmake ninja clang-tools_17 ];
|
||||
buildInputs =
|
||||
(with pkgs; [ fmt boost magic-enum libbacktrace eigen range-v3 ])
|
||||
++ (with pkgs.localPackages; [ concurrencpp tgbot-cpp nameof ]);
|
||||
# hardeningDisable = [ "all" ];
|
||||
# NIX_DEBUG = "1";
|
||||
};
|
||||
config = { archive = false; branch = "production"; };
|
||||
devShells.x86_64-linux =
|
||||
let pkgs = (import inputs.nixpkgs
|
||||
{
|
||||
system = "x86_64-linux";
|
||||
config.allowUnfree = true;
|
||||
overlays = [ inputs.self.overlays.default ];
|
||||
});
|
||||
in
|
||||
{
|
||||
biu = pkgs.mkShell
|
||||
{
|
||||
inputsFrom = with pkgs.localPackages; [ biu ];
|
||||
buildInputs = [ pkgs.clang-tools_18 ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
hpcstat = pkgs.mkShell
|
||||
{
|
||||
inputsFrom = [ (inputs.self.packages.x86_64-linux.hpcstat.override { version = null; }) ];
|
||||
packages = [ pkgs.clang-tools_18 ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
sbatch-tui = pkgs.mkShell
|
||||
{
|
||||
inputsFrom = with pkgs.localPackages; [ sbatch-tui ];
|
||||
buildInputs = [ pkgs.clang-tools_18 ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
ufo = pkgs.mkShell
|
||||
{
|
||||
inputsFrom = [ (inputs.self.packages.x86_64-linux.ufo.override { version = null; }) ];
|
||||
packages = [ pkgs.clang-tools_18 ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
chn-bsub = pkgs.mkShell
|
||||
{
|
||||
inputsFrom = with pkgs.localPackages; [ chn-bsub ];
|
||||
buildInputs = [ pkgs.clang-tools_18 ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{ version ? "4.2.0", stdenv, fetchurl, lib }:
|
||||
let versions =
|
||||
{
|
||||
"4.1.0" = "1k9anln9hmdjflrkq4iacrmhma7gfrfj6d0b8ywxys0wfpdvy12v";
|
||||
"4.2.0" = "1aycw6ygzr1db6xf3z7v5lpznhs8j7gcpkawd304vcj5qw75cnpd";
|
||||
};
|
||||
in stdenv.mkDerivation
|
||||
{
|
||||
pname = "aocc";
|
||||
inherit version;
|
||||
src = fetchurl
|
||||
{
|
||||
url = "https://download.amd.com/developer/eula/aocc/aocc-"
|
||||
+ builtins.concatStringsSep "-" (lib.lists.take 2 (builtins.splitVersion version))
|
||||
+ "/aocc-compiler-${version}.tar";
|
||||
sha256 = versions.${version};
|
||||
};
|
||||
dontBuild = true;
|
||||
installPhase =
|
||||
''
|
||||
mkdir -p $out
|
||||
cp -r bin include lib lib32 libexec share $out
|
||||
'';
|
||||
dontFixup = true;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{ version ? "4.2.0", stdenv, fetchurl, lib }:
|
||||
let versions =
|
||||
{
|
||||
"4.1.0" = "04780c2zks0g76c4n4a2cbbhs1qz4lza4ffiw1fj0md3f1lxihr5";
|
||||
"4.2.0" = "0p4x0zza6y18hjjs1971gyc5kjd2f8nzzynp2jabhl2vxiys2nnj";
|
||||
};
|
||||
in stdenv.mkDerivation
|
||||
{
|
||||
pname = "aocl";
|
||||
inherit version;
|
||||
src = fetchurl
|
||||
{
|
||||
url = "https://download.amd.com/developer/eula/aocl/aocl-"
|
||||
+ builtins.concatStringsSep "-" (lib.lists.take 2 (builtins.splitVersion version))
|
||||
+ "/aocl-linux-aocc-${version}.tar.gz";
|
||||
sha256 = versions.${version};
|
||||
};
|
||||
dontBuild = true;
|
||||
installPhase =
|
||||
''
|
||||
installDir=$(mktemp -d)
|
||||
bash ./install.sh -t $installDir
|
||||
mkdir -p $out
|
||||
cp -r $installDir/${version}/aocc/lib_LP64 $out/lib
|
||||
cp -r $installDir/${version}/aocc/include_LP64 $out/include
|
||||
'';
|
||||
dontFixup = true;
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
CompileFlags:
|
||||
Add: [ -Wall, -Wextra, -std=c++23 ]
|
||||
Compiler: gcc
|
||||
Compiler: g++
|
||||
1
local/pkgs/biu/.envrc
Normal file
1
local/pkgs/biu/.envrc
Normal file
@@ -0,0 +1 @@
|
||||
use flake .#biu
|
||||
@@ -3,6 +3,8 @@ project(biu LANGUAGES CXX)
|
||||
enable_testing()
|
||||
include(GNUInstallDirs)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
|
||||
|
||||
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)
|
||||
@@ -12,33 +14,23 @@ endif()
|
||||
find_package(magic_enum REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS headers iostreams)
|
||||
# find_package(concurrencpp REQUIRED)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
find_package(range-v3 REQUIRED)
|
||||
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
|
||||
# find_path(TGBOTCPP_INCLUDE_DIR tgbot/tgbot.h REQUIRED)
|
||||
# find_library(TGBOTCPP_LIB libTgBot.a REQUIRED)
|
||||
# find_path(BACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
|
||||
# find_library(BACKTRACE_LIB backtrace REQUIRED)
|
||||
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
|
||||
|
||||
# add_library(biu SHARED src/common.cpp src/logger.cpp src/string.cpp)
|
||||
add_library(biu SHARED src/common.cpp)
|
||||
target_include_directories(biu PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
${NAMEOF_INCLUDE_DIR} ${TGBOTCPP_INCLUDE_DIR})
|
||||
target_link_libraries(biu PUBLIC
|
||||
magic_enum::magic_enum
|
||||
fmt::fmt
|
||||
Boost::headers Boost::iostreams
|
||||
# concurrencpp::concurrencpp
|
||||
Eigen3::Eigen
|
||||
add_library(biu src/common.cpp)
|
||||
target_include_directories(biu PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ${NAMEOF_INCLUDE_DIR} ${ZPP_BITS_INCLUDE_DIR})
|
||||
target_link_libraries(biu PUBLIC magic_enum::magic_enum fmt::fmt Boost::headers Boost::iostreams Eigen3::Eigen
|
||||
range-v3::range-v3)
|
||||
# ${TGBOTCPP_LIB} ${BACKTRACE_LIB})
|
||||
set_property(TARGET biu PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
|
||||
install(TARGETS biu EXPORT biuConfig)
|
||||
install(EXPORT biuConfig NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/biu)
|
||||
install(TARGETS biu EXPORT biuTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(EXPORT biuTargets FILE biuTargets.cmake NAMESPACE biu:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/biu)
|
||||
install(FILES biuConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/biu)
|
||||
|
||||
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
|
||||
message("Imported targets: ${ImportedTargets}")
|
||||
|
||||
49
local/pkgs/biu/README.md
Normal file
49
local/pkgs/biu/README.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# `common`:
|
||||
|
||||
```c++
|
||||
// get hash of any object
|
||||
std::size_t hash(auto&&... objs);
|
||||
// suppress unused variable warning
|
||||
void unused(auto&&...);
|
||||
// block forever
|
||||
void block_forever();
|
||||
detail_::ExecResult exec
|
||||
(
|
||||
std::filesystem::path program, std::vector<std::string> args, std::optional<std::string> stdin,
|
||||
std::map<std::string, std::string> extra_env
|
||||
);
|
||||
|
||||
using int128_t = ...;
|
||||
using uint128_t = ...;
|
||||
|
||||
struct CaseInsensitiveStringLessComparator {...};
|
||||
|
||||
// remove Class::*
|
||||
template <typename MemberPointer> using RemoveMemberPointer = ...;
|
||||
// move qualifiers (cvref) from From to To
|
||||
template <typename From, typename To> using MoveQualifiers = ...;
|
||||
// get T::type or T::Type if exists, otherwise Fallback
|
||||
template <typename T, typename Fallback = void> using FallbackIfNoTypeDeclared
|
||||
```
|
||||
|
||||
# `inline literals`
|
||||
|
||||
```c++
|
||||
using namespace std::literals;
|
||||
using namespace fmt::literals;
|
||||
std::regex operator""_re(const char* str, std::size_t len);
|
||||
```
|
||||
|
||||
# `inline stream_operators`:
|
||||
|
||||
```c++
|
||||
inline namespace stream_operators { using namespace magic_enum::iostream_operators; }
|
||||
```
|
||||
|
||||
# `env`
|
||||
|
||||
```c++
|
||||
bool is_interactive();
|
||||
std::optional<std::string> env(std::string name);
|
||||
std::map<std::string, std::string> env();
|
||||
```
|
||||
7
local/pkgs/biu/biuConfig.cmake
Normal file
7
local/pkgs/biu/biuConfig.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/biuTargets.cmake")
|
||||
find_package(magic_enum REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS headers iostreams)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
find_package(range-v3 REQUIRED)
|
||||
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
|
||||
@@ -1,10 +1,11 @@
|
||||
{
|
||||
stdenv, cmake,
|
||||
magic-enum, fmt, boost, eigen, range-v3, nameof
|
||||
}: stdenv.mkDerivation
|
||||
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits
|
||||
}: stdenv.mkDerivation rec
|
||||
{
|
||||
name = "biu";
|
||||
src = ./.;
|
||||
buildInputs = [ magic-enum fmt boost eigen range-v3 nameof ];
|
||||
buildInputs = [ magic-enum fmt boost eigen range-v3 nameof zpp-bits ];
|
||||
propagatedBuildInputs = buildInputs;
|
||||
nativeBuildInputs = [ cmake ];
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
// # include <biu/atomic/atomic.tpp>
|
||||
// # include <biu/called_by.hpp>
|
||||
# include <biu/common.tpp>
|
||||
// # include <biu/concepts.tpp>
|
||||
// # include <biu/format.tpp>
|
||||
# include <biu/concepts.tpp>
|
||||
# include <biu/string.tpp>
|
||||
# include <biu/format.tpp>
|
||||
// # include <biu/logger.tpp>
|
||||
// # include <biu/smartref.tpp>
|
||||
// # include <biu/string.tpp>
|
||||
# include <biu/eigen.hpp>
|
||||
|
||||
// # include <biu/eigen.hpp>
|
||||
|
||||
@@ -1,66 +1,108 @@
|
||||
# pragma once
|
||||
# include <regex>
|
||||
# include <optional>
|
||||
# include <filesystem>
|
||||
# include <fmt/format.h>
|
||||
# include <magic_enum.hpp>
|
||||
# include <magic_enum_all.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
std::size_t hash(auto&&... objs);
|
||||
[[gnu::always_inline]] void unused(auto&&...);
|
||||
inline namespace literals
|
||||
{
|
||||
using namespace std::literals;
|
||||
using namespace fmt::literals;
|
||||
std::regex operator""_re(const char* str, std::size_t len);
|
||||
}
|
||||
inline namespace stream_operators { using namespace magic_enum::iostream_operators; }
|
||||
namespace common
|
||||
{
|
||||
std::size_t hash(auto&&... objs);
|
||||
[[gnu::always_inline]] void unused(auto&&...);
|
||||
[[noreturn]] void block_forever();
|
||||
|
||||
using uint128_t = __uint128_t;
|
||||
bool is_interactive();
|
||||
std::optional<std::string> env(std::string name);
|
||||
|
||||
inline namespace literals
|
||||
{
|
||||
using namespace std::literals;
|
||||
using namespace fmt::literals;
|
||||
std::regex operator""_re(const char* str, std::size_t len);
|
||||
}
|
||||
using int128_t = __int128_t;
|
||||
using uint128_t = __uint128_t;
|
||||
|
||||
inline namespace stream_operators { using namespace magic_enum::iostream_operators; }
|
||||
struct Empty {};
|
||||
|
||||
struct CaseInsensitiveStringLessComparator
|
||||
{
|
||||
template <typename String> constexpr bool operator()(const String& s1, const String& s2) const;
|
||||
};
|
||||
struct CaseInsensitiveStringLessComparator
|
||||
{
|
||||
template <typename String> constexpr bool operator()(const String& s1, const String& s2) const;
|
||||
};
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T> struct RemoveMemberPointerHelper { using Type = T; };
|
||||
template <typename Class, typename Member> struct RemoveMemberPointerHelper<Member Class::*>
|
||||
{ using Type = Member; };
|
||||
}
|
||||
template <typename MemberPointer> using RemoveMemberPointer
|
||||
= typename detail_::RemoveMemberPointerHelper<MemberPointer>::Type;
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T> struct RemoveMemberPointerHelper { using Type = T; };
|
||||
template <typename Class, typename Member> struct RemoveMemberPointerHelper<Member Class::*>
|
||||
{ using Type = Member; };
|
||||
}
|
||||
template <typename MemberPointer> using RemoveMemberPointer
|
||||
= typename detail_::RemoveMemberPointerHelper<MemberPointer>::Type;
|
||||
namespace detail_
|
||||
{
|
||||
template <typename From, typename To> struct MoveQualifiersHelper
|
||||
{
|
||||
protected: static constexpr bool Const_ = std::is_const_v<From>;
|
||||
protected: static constexpr bool Volatile_ = std::is_volatile_v<From>;
|
||||
protected: static constexpr bool Reference_ = std::is_reference_v<From>;
|
||||
protected: static constexpr bool Lvalue_ = std::is_lvalue_reference_v<From>;
|
||||
protected: using NoCvrefType_ = std::remove_cvref_t<To>;
|
||||
protected: using NoCvType_
|
||||
= std::conditional_t<Reference_, std::conditional_t<Lvalue_, NoCvrefType_&, NoCvrefType_&&>, NoCvrefType_>;
|
||||
protected: using NoConstType_ = std::conditional_t<Volatile_, volatile NoCvType_, NoCvType_>;
|
||||
public: using Type = std::conditional_t<Const_, const NoConstType_, NoConstType_>;
|
||||
};
|
||||
}
|
||||
template <typename From, typename To> using MoveQualifiers
|
||||
= typename detail_::MoveQualifiersHelper<From, To>::Type;
|
||||
|
||||
[[noreturn]] void block_forever();
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T, typename Fallback = void> struct FallbackIfNoTypeDeclaredHelper { using Type = Fallback; };
|
||||
template <typename T, typename Fallback> requires requires { typename T::Type; }
|
||||
struct FallbackIfNoTypeDeclaredHelper<T, Fallback> { using Type = typename T::Type; };
|
||||
template <typename T, typename Fallback> requires requires {typename T::type;}
|
||||
struct FallbackIfNoTypeDeclaredHelper<T, Fallback> { using Type = typename T::type; };
|
||||
}
|
||||
template <typename T, typename Fallback = void> using FallbackIfNoTypeDeclared
|
||||
= typename detail_::FallbackIfNoTypeDeclaredHelper<T, Fallback>::Type;
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename From, typename To> struct MoveQualifiersHelper
|
||||
{
|
||||
protected: static constexpr bool Const_ = std::is_const_v<From>;
|
||||
protected: static constexpr bool Volatile_ = std::is_volatile_v<From>;
|
||||
protected: static constexpr bool Reference_ = std::is_reference_v<From>;
|
||||
protected: static constexpr bool Lvalue_ = std::is_lvalue_reference_v<From>;
|
||||
protected: using NoCvrefType_ = std::remove_cvref_t<To>;
|
||||
protected: using NoCvType_
|
||||
= std::conditional_t<Reference_, std::conditional_t<Lvalue_, NoCvrefType_&, NoCvrefType_&&>, NoCvrefType_>;
|
||||
protected: using NoConstType_ = std::conditional_t<Volatile_, volatile NoCvType_, NoCvType_>;
|
||||
public: using Type = std::conditional_t<Const_, const NoConstType_, NoConstType_>;
|
||||
};
|
||||
}
|
||||
template <typename From, typename To> using MoveQualifiers
|
||||
= typename detail_::MoveQualifiersHelper<From, To>::Type;
|
||||
namespace detail_
|
||||
{
|
||||
template <bool DirectStdout, bool DirectStderr> struct ExecResult
|
||||
{
|
||||
int ExitCode;
|
||||
std::conditional_t<DirectStdout, Empty, std::string> Stdout;
|
||||
std::conditional_t<DirectStderr, Empty, std::string> Stderr;
|
||||
operator bool() const;
|
||||
};
|
||||
struct ExecInput { bool DirectStdin = false, DirectStdout = false, DirectStderr = false, SearchPath = false; };
|
||||
}
|
||||
template <detail_::ExecInput Input = {}> requires (!Input.DirectStdin)
|
||||
detail_::ExecResult<Input.DirectStdout, Input.DirectStderr> exec
|
||||
(
|
||||
std::conditional_t<Input.SearchPath, std::string, std::filesystem::path> program, std::vector<std::string> args,
|
||||
std::optional<std::string> stdin_string = {}, std::map<std::string, std::string> extra_env = {}
|
||||
);
|
||||
template <detail_::ExecInput Input = {}> requires (Input.DirectStdin)
|
||||
detail_::ExecResult<Input.DirectStdout, Input.DirectStderr> exec
|
||||
(
|
||||
std::conditional_t<Input.SearchPath, std::string, std::filesystem::path> program, std::vector<std::string> args,
|
||||
std::map<std::string, std::string> extra_env = {}
|
||||
);
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T, typename Fallback = void> struct FallbackIfNoTypeDeclaredHelper { using Type = Fallback; };
|
||||
template <typename T, typename Fallback> requires requires { typename T::Type; }
|
||||
struct FallbackIfNoTypeDeclaredHelper<T, Fallback> { using Type = typename T::Type; };
|
||||
template <typename T, typename Fallback> requires requires {typename T::type;}
|
||||
struct FallbackIfNoTypeDeclaredHelper<T, Fallback> { using Type = typename T::type; };
|
||||
}
|
||||
template <typename T, typename Fallback = void> using FallbackIfNoTypeDeclared
|
||||
= typename detail_::FallbackIfNoTypeDeclaredHelper<T, Fallback>::Type;
|
||||
static_assert(sizeof(char) == sizeof(std::byte));
|
||||
template <typename Char = std::byte, typename T> requires (std::same_as<Char, std::byte>)
|
||||
std::vector<std::byte> serialize(const T& data);
|
||||
template <typename Char = std::byte, typename T> requires (std::same_as<Char, char>)
|
||||
std::string serialize(const T& data);
|
||||
template <typename T> T deserialize(const std::string& serialized_data);
|
||||
template <typename T> T deserialize(const std::vector<std::byte>& serialized_data);
|
||||
}
|
||||
using common::hash, common::unused, common::block_forever, common::is_interactive, common::env, common::int128_t,
|
||||
common::uint128_t, common::Empty, common::CaseInsensitiveStringLessComparator, common::RemoveMemberPointer,
|
||||
common::MoveQualifiers, common::FallbackIfNoTypeDeclared, common::exec, common::serialize, common::deserialize;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,50 @@
|
||||
# pragma once
|
||||
# include <boost/functional/hash.hpp>
|
||||
# include <zpp_bits.h>
|
||||
# include <biu/common.hpp>
|
||||
|
||||
namespace biu
|
||||
namespace biu::common
|
||||
{
|
||||
inline void unused(auto&&...) {}
|
||||
inline std::size_t hash(auto&&... objs)
|
||||
{
|
||||
std::size_t result = 0;
|
||||
(boost::hash_combine(result, objs), ...);
|
||||
return result;
|
||||
}
|
||||
void unused(auto&&...) {}
|
||||
std::size_t hash(auto&&... objs)
|
||||
{
|
||||
std::size_t result = 0;
|
||||
(boost::hash_combine(result, objs), ...);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename String> inline constexpr bool CaseInsensitiveStringLessComparator::operator()
|
||||
(const String& s1, const String& s2) const
|
||||
{
|
||||
return std::lexicographical_compare
|
||||
(
|
||||
s1.begin(), s1.end(), s2.begin(), s2.end(),
|
||||
[](char c1, char c2){return std::tolower(c1) < std::tolower(c2);}
|
||||
);
|
||||
}
|
||||
}
|
||||
template <typename String> constexpr bool CaseInsensitiveStringLessComparator::operator()
|
||||
(const String& s1, const String& s2) const
|
||||
{
|
||||
return std::lexicographical_compare
|
||||
(
|
||||
s1.begin(), s1.end(), s2.begin(), s2.end(),
|
||||
[](char c1, char c2){return std::tolower(c1) < std::tolower(c2);}
|
||||
);
|
||||
}
|
||||
|
||||
template <typename Char, typename T> requires (std::same_as<Char, std::byte>)
|
||||
std::vector<std::byte> serialize(const T& data)
|
||||
{
|
||||
auto [serialized_data, out] = zpp::bits::data_out();
|
||||
out(data).or_throw();
|
||||
return serialized_data;
|
||||
}
|
||||
template <typename Char, typename T> requires (std::same_as<Char, char>) std::string serialize(const T& data)
|
||||
{
|
||||
auto serialized_data = serialize<std::byte>(data);
|
||||
return {reinterpret_cast<const char*>(serialized_data.data()), serialized_data.size()};
|
||||
}
|
||||
template <typename T> T deserialize(const std::vector<std::byte>& serialized_data)
|
||||
{
|
||||
auto in = zpp::bits::in(serialized_data);
|
||||
T data;
|
||||
in(data).or_throw();
|
||||
return data;
|
||||
}
|
||||
template <typename T> T deserialize(const std::string& serialized_data)
|
||||
{
|
||||
auto begin = reinterpret_cast<const std::byte*>(serialized_data.data()), end = begin + serialized_data.size();
|
||||
return deserialize<T>(std::vector<std::byte>{begin, end});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,42 +6,49 @@
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <typename T> concept DecayedType = std::same_as<std::decay_t<T>, T>;
|
||||
namespace concepts
|
||||
{
|
||||
template <typename T> concept DecayedType = std::same_as<std::decay_t<T>, T>;
|
||||
|
||||
namespace detail_::specialization_of_detail_
|
||||
{
|
||||
template <typename Tuple> struct DropFirstMemberOfTupleHelper;
|
||||
template <typename First, typename... Others> struct DropFirstMemberOfTupleHelper<std::tuple<First, Others...>>
|
||||
{using Type = std::tuple<Others...>;};
|
||||
template <typename ProvidedArgs, typename ActualArgs> consteval bool check_provided_args();
|
||||
template <typename Class, template <typename...> typename Template> struct SpecializationOfHelper
|
||||
{template <typename... ProvidedArgs> consteval static bool check_provided_args();};
|
||||
template <template <typename...> typename Template, typename... ActualArgs>
|
||||
struct SpecializationOfHelper<Template<ActualArgs...>, Template>
|
||||
{template <typename... ProvidedArgs> consteval static bool check_provided_args();};
|
||||
}
|
||||
template <typename Class, template <typename...> typename Template, typename... ProvidedArgs>
|
||||
concept SpecializationOf
|
||||
= detail_::specialization_of_detail_::SpecializationOfHelper<std::decay_t<Class>, Template>
|
||||
::template check_provided_args<ProvidedArgs...>();
|
||||
namespace detail_::specialization_of_detail_
|
||||
{
|
||||
template <typename Tuple> struct DropFirstMemberOfTupleHelper;
|
||||
template <typename First, typename... Others> struct DropFirstMemberOfTupleHelper<std::tuple<First, Others...>>
|
||||
{using Type = std::tuple<Others...>;};
|
||||
template <typename ProvidedArgs, typename ActualArgs> consteval bool check_provided_args();
|
||||
template <typename Class, template <typename...> typename Template> struct SpecializationOfHelper
|
||||
{template <typename... ProvidedArgs> consteval static bool check_provided_args();};
|
||||
template <template <typename...> typename Template, typename... ActualArgs>
|
||||
struct SpecializationOfHelper<Template<ActualArgs...>, Template>
|
||||
{template <typename... ProvidedArgs> consteval static bool check_provided_args();};
|
||||
}
|
||||
template <typename Class, template <typename...> typename Template, typename... ProvidedArgs>
|
||||
concept SpecializationOf
|
||||
= detail_::specialization_of_detail_::SpecializationOfHelper<std::decay_t<Class>, Template>
|
||||
::template check_provided_args<ProvidedArgs...>();
|
||||
|
||||
template <typename T> concept CompletedType = sizeof(T) == sizeof(T);
|
||||
template <typename T> concept CompletedType = sizeof(T) == sizeof(T);
|
||||
|
||||
template <typename From, typename To> concept ImplicitlyConvertibleTo = std::is_convertible<From, To>::value;
|
||||
template <typename To, typename From> concept ImplicitlyConvertibleFrom = std::is_convertible<From, To>::value;
|
||||
template <typename From, typename To> concept ExplicitlyConvertibleTo = std::is_constructible<To, From>::value;
|
||||
template <typename To, typename From> concept ExplicitlyConvertibleFrom = std::is_constructible<To, From>::value;
|
||||
template <typename From, typename To> concept ConvertibleTo
|
||||
= ImplicitlyConvertibleTo<From, To> || ExplicitlyConvertibleTo<From, To>;
|
||||
template <typename From, typename To> concept ConvertibleFrom = ConvertibleTo<From, To>;
|
||||
template <typename From, typename To> concept ImplicitlyConvertibleTo = std::is_convertible<From, To>::value;
|
||||
template <typename To, typename From> concept ImplicitlyConvertibleFrom = std::is_convertible<From, To>::value;
|
||||
template <typename From, typename To> concept ExplicitlyConvertibleTo = std::is_constructible<To, From>::value;
|
||||
template <typename To, typename From> concept ExplicitlyConvertibleFrom = std::is_constructible<To, From>::value;
|
||||
template <typename From, typename To> concept ConvertibleTo
|
||||
= ImplicitlyConvertibleTo<From, To> || ExplicitlyConvertibleTo<From, To>;
|
||||
template <typename From, typename To> concept ConvertibleFrom = ConvertibleTo<From, To>;
|
||||
|
||||
template <typename Function, auto... Args> concept ConstevalInvokable
|
||||
= requires() {typename std::type_identity_t<int[(Function()(Args...), 1)]>;};
|
||||
template <typename Function, auto... Args> concept ConstevalInvokable
|
||||
= requires() {typename std::type_identity_t<int[(Function()(Args...), 1)]>;};
|
||||
|
||||
template <typename T> concept Enumerable = std::is_enum_v<T>;
|
||||
template <typename T> concept Enumerable = std::is_enum_v<T>;
|
||||
|
||||
template <typename Function, typename Result, typename... Args> concept InvocableWithResult
|
||||
= std::is_invocable_r_v<Result, Function, Args...>;
|
||||
|
||||
template <typename T> concept Arithmetic = std::is_arithmetic<T>::value || SpecializationOf<T, std::complex>;
|
||||
template <typename Function, typename Result, typename... Args> concept InvocableWithResult
|
||||
= std::is_invocable_r_v<Result, Function, Args...>;
|
||||
|
||||
template <typename T> concept Arithmetic = std::is_arithmetic<T>::value || SpecializationOf<T, std::complex>;
|
||||
}
|
||||
using concepts::DecayedType, concepts::SpecializationOf, concepts::CompletedType, concepts::ImplicitlyConvertibleTo,
|
||||
concepts::ImplicitlyConvertibleFrom, concepts::ExplicitlyConvertibleTo, concepts::ExplicitlyConvertibleFrom,
|
||||
concepts::ConvertibleTo, concepts::ConvertibleFrom, concepts::ConstevalInvokable, concepts::Enumerable,
|
||||
concepts::InvocableWithResult, concepts::Arithmetic;
|
||||
}
|
||||
|
||||
@@ -2,33 +2,33 @@
|
||||
# include <tuple>
|
||||
# include <biu/concepts.hpp>
|
||||
|
||||
namespace biu
|
||||
namespace biu::concepts
|
||||
{
|
||||
template <typename ProvidedArgs, typename ActualArgs> consteval bool
|
||||
detail_::specialization_of_detail_::check_provided_args()
|
||||
{
|
||||
if constexpr (std::tuple_size_v<ProvidedArgs> == 0)
|
||||
return true;
|
||||
else if constexpr (std::tuple_size_v<ActualArgs> == 0)
|
||||
return false;
|
||||
else if constexpr
|
||||
(std::same_as<std::tuple_element_t<0, ProvidedArgs>, std::tuple_element_t<0, ActualArgs>>)
|
||||
return check_provided_args
|
||||
<
|
||||
typename DropFirstMemberOfTupleHelper<ProvidedArgs>::Type,
|
||||
typename DropFirstMemberOfTupleHelper<ActualArgs>::Type
|
||||
>();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
template <typename Class, template <typename...> typename Template> template <typename... ProvidedArgs> consteval
|
||||
bool detail_::specialization_of_detail_::SpecializationOfHelper<Class, Template>::check_provided_args()
|
||||
{ return false; }
|
||||
template <template <typename...> typename Template, typename... ActualArgs> template <typename... ProvidedArgs>
|
||||
consteval bool detail_::specialization_of_detail_::SpecializationOfHelper
|
||||
<Template<ActualArgs...>, Template>::check_provided_args()
|
||||
{
|
||||
return specialization_of_detail_::check_provided_args
|
||||
<std::tuple<ProvidedArgs...>, std::tuple<ActualArgs...>>();
|
||||
}
|
||||
template <typename ProvidedArgs, typename ActualArgs> consteval bool
|
||||
detail_::specialization_of_detail_::check_provided_args()
|
||||
{
|
||||
if constexpr (std::tuple_size_v<ProvidedArgs> == 0)
|
||||
return true;
|
||||
else if constexpr (std::tuple_size_v<ActualArgs> == 0)
|
||||
return false;
|
||||
else if constexpr
|
||||
(std::same_as<std::tuple_element_t<0, ProvidedArgs>, std::tuple_element_t<0, ActualArgs>>)
|
||||
return check_provided_args
|
||||
<
|
||||
typename DropFirstMemberOfTupleHelper<ProvidedArgs>::Type,
|
||||
typename DropFirstMemberOfTupleHelper<ActualArgs>::Type
|
||||
>();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
template <typename Class, template <typename...> typename Template> template <typename... ProvidedArgs> consteval
|
||||
bool detail_::specialization_of_detail_::SpecializationOfHelper<Class, Template>::check_provided_args()
|
||||
{ return false; }
|
||||
template <template <typename...> typename Template, typename... ActualArgs> template <typename... ProvidedArgs>
|
||||
consteval bool detail_::specialization_of_detail_::SpecializationOfHelper
|
||||
<Template<ActualArgs...>, Template>::check_provided_args()
|
||||
{
|
||||
return specialization_of_detail_::check_provided_args
|
||||
<std::tuple<ProvidedArgs...>, std::tuple<ActualArgs...>>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,66 +7,65 @@
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <typename T, typename Char = char> concept Formattable = fmt::is_formattable<T, Char>::value;
|
||||
namespace concepts
|
||||
{ template <typename T, typename Char = char> concept Formattable = fmt::is_formattable<T, Char>::value; }
|
||||
using concepts::Formattable;
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename Char, Char... c> struct FormatLiteralHelper : protected BasicStaticString<Char, c...>
|
||||
{template <typename... Param> std::basic_string<Char> operator()(Param&&... param) const;};
|
||||
}
|
||||
namespace literals
|
||||
{template <typename Char, Char... c> consteval detail_::FormatLiteralHelper<Char, c...> operator""_f();}
|
||||
namespace detail_
|
||||
{
|
||||
template <typename Char, Char... c> struct FormatLiteralHelper : protected BasicStaticString<Char, c...>
|
||||
{template <typename... Param> std::basic_string<Char> operator()(Param&&... param) const;};
|
||||
}
|
||||
inline namespace literals
|
||||
{ template <typename Char, Char... c> consteval detail_::FormatLiteralHelper<Char, c...> operator""_f(); }
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T> concept OptionalWrap
|
||||
= SpecializationOf<T, std::optional> || SpecializationOf<T, std::shared_ptr>
|
||||
|| SpecializationOf<T, std::weak_ptr> || SpecializationOf<T, std::unique_ptr>
|
||||
|| SpecializationOf<T, std::experimental::observer_ptr>;
|
||||
template <typename Wrap> struct UnderlyingTypeOfOptionalWrap;
|
||||
template <typename Wrap> requires requires() {typename Wrap::value_type;}
|
||||
struct UnderlyingTypeOfOptionalWrap<Wrap>
|
||||
{using Type = std::remove_cvref_t<typename Wrap::value_type>;};
|
||||
template <typename Wrap> requires requires() {typename Wrap::element_type;}
|
||||
struct UnderlyingTypeOfOptionalWrap<Wrap>
|
||||
{using Type = std::remove_cvref_t<typename Wrap::element_type>;};
|
||||
template <typename T> struct FormatterReuseProxy
|
||||
{
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
};
|
||||
template <typename T>
|
||||
requires (!SpecializationOf<T, std::weak_ptr> && std::default_initializable<fmt::formatter<T>>)
|
||||
struct FormatterReuseProxy<T> : fmt::formatter<T> {};
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename Char, typename... Ts> requires (sizeof...(Ts) > 0) basic_ostream<Char>& operator<<
|
||||
(basic_ostream<Char>& os, const variant<Ts...>& value);
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T> concept OptionalWrap
|
||||
= SpecializationOf<T, std::optional> || SpecializationOf<T, std::shared_ptr>
|
||||
|| SpecializationOf<T, std::weak_ptr> || SpecializationOf<T, std::unique_ptr>
|
||||
|| SpecializationOf<T, std::experimental::observer_ptr>;
|
||||
template <typename Wrap> struct UnderlyingTypeOfOptionalWrap;
|
||||
template <typename Wrap> requires requires() {typename Wrap::value_type;}
|
||||
struct UnderlyingTypeOfOptionalWrap<Wrap>
|
||||
{using Type = std::remove_cvref_t<typename Wrap::value_type>;};
|
||||
template <typename Wrap> requires requires() {typename Wrap::element_type;}
|
||||
struct UnderlyingTypeOfOptionalWrap<Wrap>
|
||||
{using Type = std::remove_cvref_t<typename Wrap::element_type>;};
|
||||
template <typename T> struct FormatterReuseProxy
|
||||
{
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
};
|
||||
template <typename T>
|
||||
requires (!SpecializationOf<T, std::weak_ptr> && std::default_initializable<fmt::formatter<T>>)
|
||||
struct FormatterReuseProxy<T> : fmt::formatter<T> {};
|
||||
}
|
||||
inline namespace stream_operators
|
||||
{
|
||||
template <typename Char, typename... Ts> requires (sizeof...(Ts) > 0) std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const std::variant<Ts...>& value);
|
||||
}
|
||||
}
|
||||
|
||||
namespace fmt
|
||||
{
|
||||
using namespace biu::stream_operators;
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> struct formatter<Wrap, Char>
|
||||
: biu::detail_::FormatterReuseProxy<typename biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type>
|
||||
{
|
||||
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
};
|
||||
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> struct formatter<Wrap, Char>
|
||||
: biu::detail_::FormatterReuseProxy<typename biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type>
|
||||
{
|
||||
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
};
|
||||
template <typename Char, biu::Enumerable T> struct formatter<T, Char>
|
||||
{
|
||||
bool full = false;
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
template <typename FormatContext> auto format(const T& value, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
};
|
||||
|
||||
template <typename Char, biu::Enumerable T> struct formatter<T, Char>
|
||||
{
|
||||
bool full = false;
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
template <typename FormatContext> auto format(const T& value, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
};
|
||||
|
||||
template <typename Char, typename... Ts> struct formatter<std::variant<Ts...>, Char>
|
||||
: basic_ostream_formatter<Char> {};
|
||||
template <typename Char, typename... Ts> struct formatter<std::variant<Ts...>, Char>
|
||||
: basic_ostream_formatter<Char> {};
|
||||
}
|
||||
|
||||
@@ -1,122 +1,92 @@
|
||||
# pragma once
|
||||
# include <nameof.hpp>
|
||||
# include <biu/format.hpp>
|
||||
# include <fmt/core.h>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <typename Char, Char... c> template <typename... Param>
|
||||
std::basic_string<Char> detail_::FormatLiteralHelper<Char, c...>::operator() (Param&&... param) const
|
||||
{return fmt::format(BasicStaticString<Char, c...>::StringView, std::forward<Param>(param)...);}
|
||||
template <typename Char, Char... c> consteval
|
||||
detail_::FormatLiteralHelper<Char, c...> literals::operator""_f()
|
||||
{return {};}
|
||||
template <typename Char, Char... c> template <typename... Param>
|
||||
std::basic_string<Char> detail_::FormatLiteralHelper<Char, c...>::operator() (Param&&... param) const
|
||||
{ return fmt::format(BasicStaticString<Char, c...>::StringView, std::forward<Param>(param)...); }
|
||||
template <typename Char, Char... c> consteval
|
||||
detail_::FormatLiteralHelper<Char, c...> literals::operator""_f()
|
||||
{ return {}; }
|
||||
|
||||
template <typename T> constexpr
|
||||
auto detail_::FormatterReuseProxy<T>::parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>
|
||||
{
|
||||
if (ctx.begin() != ctx.end() && *ctx.begin() != '}')
|
||||
throw fmt::format_error
|
||||
(
|
||||
"{} do not support to be format, so the wrapper should not have any format syntax."_f
|
||||
(nameof::nameof_full_type<T>())
|
||||
);
|
||||
return ctx.begin();
|
||||
}
|
||||
}
|
||||
template <typename T> constexpr
|
||||
auto detail_::FormatterReuseProxy<T>::parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>
|
||||
{
|
||||
if (ctx.begin() != ctx.end() && *ctx.begin() != '}')
|
||||
throw fmt::format_error
|
||||
(
|
||||
"{} do not support to be format, so the wrapper should not have any format syntax."_f
|
||||
(nameof::nameof_full_type<T>())
|
||||
);
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename Char, typename... Ts> requires (sizeof...(Ts) > 0)
|
||||
basic_ostream<Char>& operator<<(basic_ostream<Char>& os, const variant<Ts...>& value)
|
||||
{
|
||||
using namespace biu::literals;
|
||||
auto try_print = [&]<typename T>
|
||||
{
|
||||
if (holds_alternative<T>(value))
|
||||
{
|
||||
if constexpr (biu::Formattable<T, Char>)
|
||||
os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
|
||||
else
|
||||
os << "({}: {})"_f(nameof::nameof_full_type<T>(), "non-null unformattable value");
|
||||
}
|
||||
};
|
||||
(try_print.template operator()<Ts>(), ...);
|
||||
return os;
|
||||
}
|
||||
template <typename Char, typename... Ts> requires (sizeof...(Ts) > 0) std::basic_ostream<Char>&
|
||||
stream_operators::operator<<(std::basic_ostream<Char>& os, const std::variant<Ts...>& value)
|
||||
{
|
||||
using namespace biu::literals;
|
||||
auto try_print = [&]<typename T>
|
||||
{
|
||||
if (holds_alternative<T>(value))
|
||||
{
|
||||
if constexpr (biu::Formattable<T, Char>) os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
|
||||
else os << "({}: {})"_f(nameof::nameof_full_type<T>(), "non-null unformattable value");
|
||||
}
|
||||
};
|
||||
(try_print.template operator()<Ts>(), ...);
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
namespace fmt
|
||||
{
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> template <typename FormatContext>
|
||||
auto formatter<Wrap, Char>::format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
|
||||
{
|
||||
using namespace biu::literals;
|
||||
using namespace biu::stream_operators;
|
||||
using value_t = biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type;
|
||||
auto format_value_type = [&, this](const value_t& value)
|
||||
{
|
||||
if constexpr (!biu::Formattable<value_t, Char>)
|
||||
return format_to(ctx.out(), "non-null unformattable value");
|
||||
else if constexpr (std::default_initializable<formatter<value_t>>)
|
||||
biu::detail_::FormatterReuseProxy<value_t>::format(value, ctx);
|
||||
else
|
||||
format_to(ctx.out(), "{}", value);
|
||||
};
|
||||
format_to(ctx.out(), "(");
|
||||
if constexpr (biu::SpecializationOf<Wrap, std::optional>)
|
||||
{
|
||||
if (wrap)
|
||||
format_value_type(*wrap);
|
||||
else
|
||||
format_to(ctx.out(), "null");
|
||||
}
|
||||
else if constexpr (biu::SpecializationOf<Wrap, std::weak_ptr>)
|
||||
{
|
||||
if (auto shared = wrap.lock())
|
||||
{
|
||||
format_to(ctx.out(), "{} ", ptr(shared.get()));
|
||||
format_value_type(*shared);
|
||||
}
|
||||
else
|
||||
format_to(ctx.out(), "null");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wrap)
|
||||
{
|
||||
format_to(ctx.out(), "{} ", ptr(wrap.get()));
|
||||
format_value_type(*wrap);
|
||||
}
|
||||
else
|
||||
format_to(ctx.out(), "null");
|
||||
}
|
||||
return format_to(ctx.out(), ")");
|
||||
}
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> template <typename FormatContext>
|
||||
auto formatter<Wrap, Char>::format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
|
||||
{
|
||||
using value_t = biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type;
|
||||
auto format_value_type = [&, this](const value_t& value)
|
||||
{
|
||||
if constexpr (!biu::Formattable<value_t, Char>) return fmt::format_to(ctx.out(), "non-null unformattable value");
|
||||
else if constexpr (std::default_initializable<formatter<value_t>>)
|
||||
biu::detail_::FormatterReuseProxy<value_t>::format(value, ctx);
|
||||
else fmt::format_to(ctx.out(), "{}", value);
|
||||
};
|
||||
fmt::format_to(ctx.out(), "(");
|
||||
if constexpr (biu::SpecializationOf<Wrap, std::optional>)
|
||||
{ if (wrap) format_value_type(*wrap); else fmt::format_to(ctx.out(), "null"); }
|
||||
else if constexpr (biu::SpecializationOf<Wrap, std::weak_ptr>)
|
||||
{
|
||||
if (auto shared = wrap.lock())
|
||||
{ fmt::format_to(ctx.out(), "{} ", ptr(shared.get())); format_value_type(*shared); }
|
||||
else fmt::format_to(ctx.out(), "null");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wrap) { fmt::format_to(ctx.out(), "{} ", ptr(wrap.get())); format_value_type(*wrap); }
|
||||
else fmt::format_to(ctx.out(), "null");
|
||||
}
|
||||
return fmt::format_to(ctx.out(), ")");
|
||||
}
|
||||
|
||||
template <typename Char, biu::Enumerable T> constexpr
|
||||
auto formatter<T, Char>::parse(format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&format_parse_context::begin), format_parse_context>
|
||||
{
|
||||
auto it = ctx.begin();
|
||||
if (it != ctx.end() && *it == 'f')
|
||||
{
|
||||
full = true;
|
||||
it++;
|
||||
}
|
||||
if (it != ctx.end() && *it != '}')
|
||||
throw format_error{"syntax error."};
|
||||
return it;
|
||||
}
|
||||
template <typename Char, biu::Enumerable T> constexpr auto formatter<T, Char>::parse(format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&format_parse_context::begin), format_parse_context>
|
||||
{
|
||||
auto it = ctx.begin();
|
||||
if (it != ctx.end() && *it == 'f') { full = true; it++; }
|
||||
if (it != ctx.end() && *it != '}') throw format_error{"syntax error."};
|
||||
return it;
|
||||
}
|
||||
|
||||
template <typename Char, biu::Enumerable T> template <typename FormatContext>
|
||||
auto formatter<T, Char>::format(const T& value, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
|
||||
{
|
||||
if (full)
|
||||
return format_to(ctx.out(), "{}::{}", nameof::nameof_type<T>(), nameof::nameof_enum(value));
|
||||
else
|
||||
return format_to(ctx.out(), "{}", nameof::nameof_enum(value));
|
||||
}
|
||||
template <typename Char, biu::Enumerable T> template <typename FormatContext>
|
||||
auto formatter<T, Char>::format(const T& value, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>
|
||||
{
|
||||
if (full) return fmt::format_to(ctx.out(), "{}::{}", nameof::nameof_type<T>(), nameof::nameof_enum(value));
|
||||
else return fmt::format_to(ctx.out(), "{}", nameof::nameof_enum(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,108 +4,114 @@
|
||||
# include <string>
|
||||
# include <string_view>
|
||||
# include <iostream>
|
||||
# include <concurrencpp/concurrencpp.h>
|
||||
# include <biu/concepts.hpp>
|
||||
# include <biu/smartref.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
// Store a string in a static member of a class; or, use a class to represent a string.
|
||||
template <DecayedType Char, Char... c> struct BasicStaticString
|
||||
{
|
||||
static constexpr std::array<Char, sizeof...(c)> Array{c...};
|
||||
static constexpr std::basic_string_view<Char> StringView{Array.data(), sizeof...(c)};
|
||||
};
|
||||
template <char... c> using StaticString = BasicStaticString<char, c...>;
|
||||
inline namespace stream_operators
|
||||
{
|
||||
template <typename Char, Char... c>
|
||||
std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& os, BasicStaticString<Char, c...>);
|
||||
}
|
||||
inline namespace literals
|
||||
{ template <typename Char, Char... c> consteval BasicStaticString<Char, c...> operator""_ss(); }
|
||||
namespace detail_
|
||||
{
|
||||
template <typename C, typename T> struct SpecializationOfBasicStaticStringHelper : std::false_type {};
|
||||
template <typename C, C... c>
|
||||
struct SpecializationOfBasicStaticStringHelper<C, BasicStaticString<C, c...>> : std::true_type {};
|
||||
template <typename C, C... c>
|
||||
struct SpecializationOfBasicStaticStringHelper<void, BasicStaticString<C, c...>> : std::true_type {};
|
||||
template <typename T, typename C> concept SpecializationOfBasicStaticString
|
||||
= SpecializationOfBasicStaticStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
|
||||
}
|
||||
template <typename T, typename C = void> concept SpecializationOfBasicStaticString
|
||||
= detail_::SpecializationOfBasicStaticString<T, C>
|
||||
&& detail_::SpecializationOfBasicStaticString<T, void>;
|
||||
template <typename T> concept SpecializationOfStaticString = SpecializationOfBasicStaticString<T, char>;
|
||||
namespace string
|
||||
{
|
||||
// Store a string in a static member of a class; or, use a class to represent a string.
|
||||
template <DecayedType Char, Char... c> struct BasicStaticString
|
||||
{
|
||||
static constexpr std::array<Char, sizeof...(c)> Array{c...};
|
||||
static constexpr std::basic_string_view<Char> StringView{Array.data(), sizeof...(c)};
|
||||
};
|
||||
template <char... c> using StaticString = BasicStaticString<char, c...>;
|
||||
|
||||
// Store a string in a fixed-size array
|
||||
template <DecayedType Char, std::size_t N> struct BasicFixedString
|
||||
{
|
||||
Char Data[N];
|
||||
constexpr static const std::size_t Size = N - 1;
|
||||
constexpr BasicFixedString(const Char (&str)[N]);
|
||||
};
|
||||
template <std::size_t N> using FixedString = BasicFixedString<char, N>;
|
||||
inline namespace stream_operators
|
||||
{
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicFixedString<Char, N>& str);
|
||||
}
|
||||
inline namespace literals { template <BasicFixedString FS> constexpr decltype(FS) operator""_fs(); }
|
||||
namespace detail_
|
||||
{
|
||||
template <typename C, typename T> struct SpecializationOfBasicFixedStringHelper : std::false_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicFixedStringHelper<C, BasicFixedString<C, N>> : std::true_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicFixedStringHelper<void, BasicFixedString<C, N>> : std::true_type {};
|
||||
template <typename T, typename C> concept SpecializationOfBasicFixedString
|
||||
= SpecializationOfBasicFixedStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
|
||||
}
|
||||
template <typename T, typename C = void> concept SpecializationOfBasicFixedString
|
||||
= detail_::SpecializationOfBasicFixedString<T, C>
|
||||
&& detail_::SpecializationOfBasicFixedString<T, void>;
|
||||
template <typename T> concept SpecializationOfFixedString = SpecializationOfBasicFixedString<T, char>;
|
||||
// Store a string in a fixed-size array
|
||||
template <DecayedType Char, std::size_t N> struct BasicFixedString
|
||||
{
|
||||
Char Data[N];
|
||||
constexpr static const std::size_t Size = N - 1;
|
||||
constexpr BasicFixedString(const Char (&str)[N]);
|
||||
};
|
||||
template <std::size_t N> using FixedString = BasicFixedString<char, N>;
|
||||
|
||||
// Store a string with at most N characters
|
||||
template <DecayedType Char, std::size_t N> struct BasicVariableString
|
||||
{
|
||||
Char Data[N];
|
||||
std::size_t Size;
|
||||
constexpr static const std::size_t MaxSize = N - 1;
|
||||
template <std::size_t M> requires (M<=N) constexpr BasicVariableString(const Char (&str)[M]);
|
||||
};
|
||||
template <std::size_t N> using VariableString = BasicVariableString<char, N>;
|
||||
inline namespace stream_operators
|
||||
{
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicVariableString<Char, N>& str);
|
||||
}
|
||||
// Store a string with at most N characters
|
||||
template <DecayedType Char, std::size_t N> struct BasicVariableString
|
||||
{
|
||||
Char Data[N];
|
||||
std::size_t Size;
|
||||
constexpr static const std::size_t MaxSize = N - 1;
|
||||
template <std::size_t M> requires (M<=N) constexpr BasicVariableString(const Char (&str)[M]);
|
||||
};
|
||||
template <std::size_t N> using VariableString = BasicVariableString<char, N>;
|
||||
}
|
||||
using string::BasicStaticString, string::StaticString, string::BasicFixedString, string::FixedString,
|
||||
string::BasicVariableString, string::VariableString;
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename C, typename T> struct SpecializationOfBasicVariableStringHelper : std::false_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicVariableStringHelper<C, BasicVariableString<C, N>> : std::true_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicVariableStringHelper<void, BasicVariableString<C, N>> : std::true_type {};
|
||||
template <typename T, typename C> concept SpecializationOfBasicVariableString
|
||||
= SpecializationOfBasicVariableStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
|
||||
}
|
||||
template <typename T, typename C = void> concept SpecializationOfBasicVariableString
|
||||
= detail_::SpecializationOfBasicVariableString<T, C>
|
||||
&& detail_::SpecializationOfBasicVariableString<T, void>;
|
||||
template <typename T> concept SpecializationOfVariableString = SpecializationOfBasicVariableString<T, char>;
|
||||
inline namespace stream_operators
|
||||
{
|
||||
template <typename Char, Char... c>
|
||||
std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& os, BasicStaticString<Char, c...>);
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicFixedString<Char, N>& str);
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicVariableString<Char, N>& str);
|
||||
}
|
||||
inline namespace literals
|
||||
{
|
||||
template <typename Char, Char... c> consteval BasicStaticString<Char, c...> operator""_ss();
|
||||
template <BasicFixedString FS> constexpr decltype(FS) operator""_fs();
|
||||
}
|
||||
namespace concepts
|
||||
{
|
||||
namespace detail_
|
||||
{
|
||||
template <typename C, typename T> struct SpecializationOfBasicStaticStringHelper : std::false_type {};
|
||||
template <typename C, C... c>
|
||||
struct SpecializationOfBasicStaticStringHelper<C, BasicStaticString<C, c...>> : std::true_type {};
|
||||
template <typename C, C... c>
|
||||
struct SpecializationOfBasicStaticStringHelper<void, BasicStaticString<C, c...>> : std::true_type {};
|
||||
template <typename T, typename C> concept SpecializationOfBasicStaticString
|
||||
= SpecializationOfBasicStaticStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
|
||||
}
|
||||
template <typename T, typename C = void> concept SpecializationOfBasicStaticString
|
||||
= detail_::SpecializationOfBasicStaticString<T, C>
|
||||
&& detail_::SpecializationOfBasicStaticString<T, void>;
|
||||
template <typename T> concept SpecializationOfStaticString = SpecializationOfBasicStaticString<T, char>;
|
||||
|
||||
namespace string
|
||||
{
|
||||
// Find specific content in a string. Return unmatched content before the match and the match result every
|
||||
// time. If match reached the end, the second returned value will be std::sregex_iterator().
|
||||
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> find
|
||||
(SmartRef<const std::string> data, SmartRef<const std::regex> regex);
|
||||
// Use a regex to find all matches and replace them with a callback function
|
||||
std::string replace
|
||||
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function);
|
||||
}
|
||||
namespace detail_
|
||||
{
|
||||
template <typename C, typename T> struct SpecializationOfBasicFixedStringHelper : std::false_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicFixedStringHelper<C, BasicFixedString<C, N>> : std::true_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicFixedStringHelper<void, BasicFixedString<C, N>> : std::true_type {};
|
||||
template <typename T, typename C> concept SpecializationOfBasicFixedString
|
||||
= SpecializationOfBasicFixedStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
|
||||
}
|
||||
template <typename T, typename C = void> concept SpecializationOfBasicFixedString
|
||||
= detail_::SpecializationOfBasicFixedString<T, C>
|
||||
&& detail_::SpecializationOfBasicFixedString<T, void>;
|
||||
template <typename T> concept SpecializationOfFixedString = SpecializationOfBasicFixedString<T, char>;
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename C, typename T> struct SpecializationOfBasicVariableStringHelper : std::false_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicVariableStringHelper<C, BasicVariableString<C, N>> : std::true_type {};
|
||||
template <typename C, std::size_t N>
|
||||
struct SpecializationOfBasicVariableStringHelper<void, BasicVariableString<C, N>> : std::true_type {};
|
||||
template <typename T, typename C> concept SpecializationOfBasicVariableString
|
||||
= SpecializationOfBasicVariableStringHelper<std::decay_t<C>, std::decay_t<T>>::value;
|
||||
}
|
||||
template <typename T, typename C = void> concept SpecializationOfBasicVariableString
|
||||
= detail_::SpecializationOfBasicVariableString<T, C>
|
||||
&& detail_::SpecializationOfBasicVariableString<T, void>;
|
||||
template <typename T> concept SpecializationOfVariableString = SpecializationOfBasicVariableString<T, char>;
|
||||
}
|
||||
using concepts::SpecializationOfBasicStaticString, concepts::SpecializationOfStaticString,
|
||||
concepts::SpecializationOfBasicFixedString, concepts::SpecializationOfFixedString,
|
||||
concepts::SpecializationOfBasicVariableString, concepts::SpecializationOfVariableString;
|
||||
}
|
||||
// namespace string
|
||||
// {
|
||||
// // Find specific content in a string. Return unmatched content before the match and the match result every
|
||||
// // time. If match reached the end, the second returned value will be std::sregex_iterator().
|
||||
// concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> find
|
||||
// (SmartRef<const std::string> data, SmartRef<const std::regex> regex);
|
||||
// // Use a regex to find all matches and replace them with a callback function
|
||||
// std::string replace
|
||||
// (const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function);
|
||||
// }
|
||||
|
||||
@@ -3,28 +3,37 @@
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <typename Char, Char... c> inline std::basic_ostream<Char>& stream_operators::operator<<
|
||||
(std::basic_ostream<Char>& os, BasicStaticString<Char, c...>)
|
||||
{ return os << std::basic_string_view{c...}; }
|
||||
template <typename Char, Char... c> consteval BasicStaticString<Char, c...> literals::operator""_ss()
|
||||
{ return {}; }
|
||||
namespace string
|
||||
{
|
||||
template <DecayedType Char, std::size_t N> constexpr
|
||||
BasicFixedString<Char, N>::BasicFixedString(const Char (&str)[N])
|
||||
{ std::copy_n(str, N, Data); }
|
||||
template <DecayedType Char, std::size_t N> template <std::size_t M> requires (M<=N) constexpr
|
||||
BasicVariableString<Char, N>::BasicVariableString(const Char (&str)[M]) : Size(M)
|
||||
{
|
||||
std::fill(Data, Data + N, '\0');
|
||||
std::copy_n(str, M, Data);
|
||||
}
|
||||
}
|
||||
|
||||
template <DecayedType Char, std::size_t N> constexpr
|
||||
BasicFixedString<Char, N>::BasicFixedString(const Char (&str)[N])
|
||||
{ std::copy_n(str, N, Data); }
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& stream_operators::operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicFixedString<Char, N>& str)
|
||||
{ return os << std::basic_string_view<Char>(str.Data, str.Size); }
|
||||
template <BasicFixedString FS> constexpr decltype(FS) literals::operator""_fs()
|
||||
{ return FS; }
|
||||
inline namespace stream_operators
|
||||
{
|
||||
template <typename Char, Char... c> inline std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, BasicStaticString<Char, c...>)
|
||||
{ return os << std::basic_string_view{c...}; }
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicFixedString<Char, N>& str)
|
||||
{ return os << std::basic_string_view<Char>(str.Data, str.Size); }
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicVariableString<Char, N>& str)
|
||||
{ return os << std::basic_string_view<Char>(str.Data, str.Size); }
|
||||
}
|
||||
|
||||
template <DecayedType Char, std::size_t N> template <std::size_t M> requires (M<=N) constexpr
|
||||
BasicVariableString<Char, N>::BasicVariableString(const Char (&str)[M]) : Size(M)
|
||||
{
|
||||
std::fill(Data, Data + N, '\0');
|
||||
std::copy_n(str, M, Data);
|
||||
}
|
||||
template <typename Char, std::size_t N> std::basic_ostream<Char>& stream_operators::operator<<
|
||||
(std::basic_ostream<Char>& os, const BasicVariableString<Char, N>& str)
|
||||
{ return os << std::basic_string_view<Char>(str.Data, str.Size); }
|
||||
inline namespace literals
|
||||
{
|
||||
template <typename Char, Char... c> consteval BasicStaticString<Char, c...> operator""_ss()
|
||||
{ return {}; }
|
||||
template <BasicFixedString FS> constexpr decltype(FS) operator""_fs()
|
||||
{ return FS; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,104 @@
|
||||
# include <future>
|
||||
# include <utility>
|
||||
# include <cstdio>
|
||||
# include <biu.hpp>
|
||||
# include <boost/process.hpp>
|
||||
# include <boost/preprocessor.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
std::regex literals::operator""_re(const char* str, std::size_t len)
|
||||
{ return std::regex{str, len}; }
|
||||
void block_forever()
|
||||
{
|
||||
std::promise<void>().get_future().wait();
|
||||
std::unreachable();
|
||||
}
|
||||
std::regex literals::operator""_re(const char* str, std::size_t len) { return std::regex{str, len}; }
|
||||
namespace common
|
||||
{
|
||||
void block_forever() { std::promise<void>().get_future().wait(); std::unreachable(); }
|
||||
bool is_interactive() { return isatty(fileno(stdin)); }
|
||||
std::optional<std::string> env(std::string name)
|
||||
{
|
||||
if (auto value = std::getenv(name.c_str()); !value) return std::nullopt;
|
||||
else return value;
|
||||
}
|
||||
|
||||
template <bool DirectStdout, bool DirectStderr>
|
||||
detail_::ExecResult<DirectStdout, DirectStderr>::operator bool() const
|
||||
{ return ExitCode == 0; }
|
||||
# define BIU_EXECRESULT_PRED(r, state) BOOST_PP_NOT_EQUAL(state, 4)
|
||||
# define BIU_EXECRESULT_OP(r, state) BOOST_PP_INC(state)
|
||||
# define BIU_EXECRESULT_MACRO(r, state) \
|
||||
template detail_::ExecResult<(state & 1) != 0, (state & 2) != 0>::operator bool() const;
|
||||
BOOST_PP_FOR(0, BIU_EXECRESULT_PRED, BIU_EXECRESULT_OP, BIU_EXECRESULT_MACRO)
|
||||
namespace detail_
|
||||
{
|
||||
template <ExecInput Input>
|
||||
detail_::ExecResult<Input.DirectStdout, Input.DirectStderr> exec
|
||||
(
|
||||
std::conditional_t<Input.SearchPath, std::string, std::filesystem::path> program, std::vector<std::string> args,
|
||||
std::optional<std::string> stdin_string, std::map<std::string, std::string> extra_env
|
||||
)
|
||||
{
|
||||
namespace bp = boost::process;
|
||||
bp::ipstream stdout_stream, stderr_stream;
|
||||
bp::opstream input_stream;
|
||||
auto&& stdout_format = [&]
|
||||
{ if constexpr (Input.DirectStdout) return bp::std_out > stdout; else return bp::std_out > stdout_stream; }();
|
||||
auto&& stderr_format = [&]
|
||||
{ if constexpr (Input.DirectStderr) return bp::std_err > stderr; else return bp::std_err > stderr_stream; }();
|
||||
auto&& actual_program =
|
||||
[&]{ if constexpr (Input.SearchPath) return bp::search_path(program); else return program.string(); }();
|
||||
std::unique_ptr<bp::child> process;
|
||||
bp::environment env = boost::this_process::environment();
|
||||
for (const auto& [key, value] : extra_env) env[key] = value;
|
||||
process = [&]
|
||||
{
|
||||
if constexpr (Input.DirectStdin) return std::make_unique<bp::child>
|
||||
(actual_program, bp::args(args), stdout_format, stderr_format, bp::std_in < stdin, env);
|
||||
else if (stdin_string) return std::make_unique<bp::child>
|
||||
(actual_program, bp::args(args), stdout_format, stderr_format, bp::std_in < input_stream, env);
|
||||
else return std::make_unique<bp::child>
|
||||
(actual_program, bp::args(args), stdout_format, stderr_format, bp::std_in < bp::null, env);
|
||||
}();
|
||||
if (stdin_string) { input_stream << *stdin_string; input_stream.pipe().close(); }
|
||||
process->wait();
|
||||
return
|
||||
{
|
||||
.ExitCode = process->exit_code(),
|
||||
.Stdout = [&]
|
||||
{
|
||||
if constexpr (Input.DirectStdout) return Empty{};
|
||||
else return std::string{std::istreambuf_iterator<char>{stdout_stream.rdbuf()}, {}};
|
||||
}(),
|
||||
.Stderr = [&]
|
||||
{
|
||||
if constexpr (Input.DirectStderr) return Empty{};
|
||||
else return std::string{std::istreambuf_iterator<char>{stderr_stream.rdbuf()}, {}};
|
||||
}()
|
||||
};
|
||||
}
|
||||
}
|
||||
template <detail_::ExecInput Input> requires (!Input.DirectStdin)
|
||||
detail_::ExecResult<Input.DirectStdout, Input.DirectStderr> exec
|
||||
(
|
||||
std::conditional_t<Input.SearchPath, std::string, std::filesystem::path> program, std::vector<std::string> args,
|
||||
std::optional<std::string> stdin_string, std::map<std::string, std::string> extra_env
|
||||
)
|
||||
{ return detail_::exec<Input>(program, args, stdin_string, extra_env); }
|
||||
template <detail_::ExecInput Input> requires (Input.DirectStdin)
|
||||
detail_::ExecResult<Input.DirectStdout, Input.DirectStderr> exec
|
||||
(
|
||||
std::conditional_t<Input.SearchPath, std::string, std::filesystem::path> program, std::vector<std::string> args,
|
||||
std::map<std::string, std::string> extra_env
|
||||
)
|
||||
{ return detail_::exec<Input>(program, args, {}, extra_env); }
|
||||
# define BIU_EXEC_PRED(r, state) BOOST_PP_NOT_EQUAL(state, 8)
|
||||
# define BIU_EXEC_OP(r, state) BOOST_PP_INC(state)
|
||||
# define BIU_EXEC_MACRO(r, state) \
|
||||
template detail_::ExecResult<(state & 1) != 0, (state & 2) != 0> \
|
||||
exec<{false, (state & 1) != 0, (state & 2) != 0, (state & 4) != 0}> \
|
||||
(std::conditional_t<(state & 4) != 0, std::string, std::filesystem::path>, std::vector<std::string>, \
|
||||
std::optional<std::string>, std::map<std::string, std::string>); \
|
||||
template detail_::ExecResult<(state & 1) != 0, (state & 2) != 0> \
|
||||
exec<{true, (state & 1) != 0, (state & 2) != 0, (state & 4) != 0}> \
|
||||
(std::conditional_t<(state & 4) != 0, std::string, std::filesystem::path>, std::vector<std::string>, \
|
||||
std::map<std::string, std::string>);
|
||||
BOOST_PP_FOR(0, BIU_EXEC_PRED, BIU_EXEC_OP, BIU_EXEC_MACRO)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,51 +3,51 @@
|
||||
|
||||
namespace biu
|
||||
{
|
||||
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
|
||||
(SmartRef<const std::string> data, SmartRef<const std::regex> regex)
|
||||
{
|
||||
Logger::Guard log;
|
||||
std::string::const_iterator unmatched_prefix_begin = data->cbegin(), unmatched_prefix_end;
|
||||
std::sregex_iterator regit;
|
||||
while (true)
|
||||
{
|
||||
if (regit == std::sregex_iterator{})
|
||||
regit = std::sregex_iterator{data->begin(), data->end(), *regex};
|
||||
else
|
||||
regit++;
|
||||
if (regit == std::sregex_iterator{})
|
||||
{
|
||||
unmatched_prefix_end = data->cend();
|
||||
log.log<Logger::Level::Debug>("distance: {}"_f(std::distance(unmatched_prefix_begin, unmatched_prefix_end)));
|
||||
}
|
||||
else
|
||||
unmatched_prefix_end = (*regit)[0].first;
|
||||
co_yield
|
||||
{
|
||||
std::string_view
|
||||
{
|
||||
&*unmatched_prefix_begin,
|
||||
static_cast<std::size_t>(std::distance(unmatched_prefix_begin, unmatched_prefix_end))
|
||||
},
|
||||
regit
|
||||
};
|
||||
if (regit == std::sregex_iterator{})
|
||||
break;
|
||||
unmatched_prefix_begin = (*regit)[0].second;
|
||||
}
|
||||
}
|
||||
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
|
||||
(SmartRef<const std::string> data, SmartRef<const std::regex> regex)
|
||||
{
|
||||
Logger::Guard log;
|
||||
std::string::const_iterator unmatched_prefix_begin = data->cbegin(), unmatched_prefix_end;
|
||||
std::sregex_iterator regit;
|
||||
while (true)
|
||||
{
|
||||
if (regit == std::sregex_iterator{})
|
||||
regit = std::sregex_iterator{data->begin(), data->end(), *regex};
|
||||
else
|
||||
regit++;
|
||||
if (regit == std::sregex_iterator{})
|
||||
{
|
||||
unmatched_prefix_end = data->cend();
|
||||
log.log<Logger::Level::Debug>("distance: {}"_f(std::distance(unmatched_prefix_begin, unmatched_prefix_end)));
|
||||
}
|
||||
else
|
||||
unmatched_prefix_end = (*regit)[0].first;
|
||||
co_yield
|
||||
{
|
||||
std::string_view
|
||||
{
|
||||
&*unmatched_prefix_begin,
|
||||
static_cast<std::size_t>(std::distance(unmatched_prefix_begin, unmatched_prefix_end))
|
||||
},
|
||||
regit
|
||||
};
|
||||
if (regit == std::sregex_iterator{})
|
||||
break;
|
||||
unmatched_prefix_begin = (*regit)[0].second;
|
||||
}
|
||||
}
|
||||
|
||||
std::string string::replace
|
||||
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function)
|
||||
{
|
||||
Logger::Guard log;
|
||||
std::string result;
|
||||
for (auto matched : find(data, regex))
|
||||
{
|
||||
result.append(matched.first);
|
||||
if (matched.second != std::sregex_iterator{})
|
||||
result.append(function(*matched.second));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
std::string string::replace
|
||||
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function)
|
||||
{
|
||||
Logger::Guard log;
|
||||
std::string result;
|
||||
for (auto matched : find(data, regex))
|
||||
{
|
||||
result.append(matched.first);
|
||||
if (matched.second != std::sregex_iterator{})
|
||||
result.append(function(*matched.second));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
phases = [ "installPhase" ];
|
||||
installPhase =
|
||||
''
|
||||
mkdir -p $out/share/plasma/wallpapers/a2n.blur
|
||||
cp -r $src/* $out/share/plasma/wallpapers/a2n.blur
|
||||
mkdir -p $out/share/plasma/wallpapers
|
||||
cp -r $src/a2n.blur $out/share/plasma/wallpapers
|
||||
'';
|
||||
}
|
||||
26
local/pkgs/chn-bsub/CMakeLists.txt
Normal file
26
local/pkgs/chn-bsub/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(chn-bsub 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(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)
|
||||
|
||||
install(TARGETS chn-bsub 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}")
|
||||
12
local/pkgs/chn-bsub/default.nix
Normal file
12
local/pkgs/chn-bsub/default.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
stdenv, lib, sbatchConfig ? null, substituteAll, runCommand,
|
||||
cmake, pkg-config, ftxui, biu
|
||||
}:
|
||||
stdenv.mkDerivation
|
||||
{
|
||||
name = "chn-bsub";
|
||||
src = ./.;
|
||||
buildInputs = [ ftxui biu ];
|
||||
nativeBuildInputs = [ cmake pkg-config ];
|
||||
postInstall = "ln -s chn-bsub $out/bin/chn_bsub";
|
||||
}
|
||||
202
local/pkgs/chn-bsub/src/main.cpp
Normal file
202
local/pkgs/chn-bsub/src/main.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
# include <map>
|
||||
# include <filesystem>
|
||||
# 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>
|
||||
|
||||
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 =
|
||||
{
|
||||
{"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
|
||||
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();
|
||||
}();
|
||||
std::string bsub = "";
|
||||
std::string user_command = "";
|
||||
} state;
|
||||
|
||||
// 为组件增加标题栏
|
||||
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()
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 构建界面, 需要至少 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
|
||||
({
|
||||
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
|
||||
({
|
||||
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);
|
||||
}();
|
||||
|
||||
// 实际投递任务
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{ stdenvNoCC, texlive, src }: stdenvNoCC.mkDerivation (finalAttrs:
|
||||
{
|
||||
name = "citation-style-language";
|
||||
inherit src;
|
||||
passthru =
|
||||
{
|
||||
pkgs = [ finalAttrs.finalPackage ];
|
||||
tlDeps = with texlive; [ latex ];
|
||||
tlType = "run";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ texlive.combined.scheme-full ];
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
installPhase =
|
||||
''
|
||||
runHook preInstall
|
||||
export TEXMFHOME=$out
|
||||
l3build install
|
||||
runHook postInstall
|
||||
'';
|
||||
})
|
||||
@@ -1,13 +1,7 @@
|
||||
{ stdenv, src }: stdenv.mkDerivation
|
||||
{ stdenv, src, cmake, pkg-config }: stdenv.mkDerivation
|
||||
{
|
||||
name = "date";
|
||||
inherit src;
|
||||
phases = [ "installPhase" ];
|
||||
installPhase =
|
||||
''
|
||||
runHook preInstall
|
||||
mkdir -p $out
|
||||
cp -r $src/{include,src} $out
|
||||
runHook postInstall
|
||||
'';
|
||||
nativeBuildInputs = [ cmake pkg-config ];
|
||||
cmakeFlags = [ "-DBUILD_TZ_LIB=ON" "-DUSE_SYSTEM_TZ_DB=ON" ];
|
||||
}
|
||||
|
||||
@@ -2,8 +2,14 @@ inputs: rec
|
||||
{
|
||||
typora = inputs.pkgs.callPackage ./typora {};
|
||||
vesta = inputs.pkgs.callPackage ./vesta {};
|
||||
rsshub = inputs.pkgs.callPackage ./rsshub { src = inputs.topInputs.rsshub; };
|
||||
misskey = inputs.pkgs.callPackage ./misskey { nodejs = inputs.pkgs.nodejs_21; src = inputs.topInputs.misskey; };
|
||||
rsshub = inputs.pkgs.callPackage ./rsshub.nix
|
||||
{
|
||||
inherit mkPnpmPackage;
|
||||
src = inputs.topInputs.rsshub;
|
||||
nodejs = nodejs-with-pnpm9.override { nodejs = inputs.pkgs.nodejs_22; };
|
||||
};
|
||||
misskey = inputs.pkgs.callPackage ./misskey.nix
|
||||
{ inherit mkPnpmPackage; src = inputs.topInputs.misskey; nodejs = nodejs-with-pnpm9; };
|
||||
mk-meili-mgn = inputs.pkgs.callPackage ./mk-meili-mgn {};
|
||||
vaspkit = inputs.pkgs.callPackage ./vaspkit { inherit (inputs.localLib) attrsToList; };
|
||||
v-sim = inputs.pkgs.callPackage ./v-sim { src = inputs.topInputs.v-sim; };
|
||||
@@ -20,13 +26,12 @@ inputs: rec
|
||||
chromiumos-touch-keyboard = inputs.pkgs.callPackage ./chromiumos-touch-keyboard {};
|
||||
yoga-support = inputs.pkgs.callPackage ./yoga-support {};
|
||||
tgbot-cpp = inputs.pkgs.callPackage ./tgbot-cpp { src = inputs.topInputs.tgbot-cpp; };
|
||||
citation-style-language = inputs.pkgs.callPackage ./citation-style-language
|
||||
{ src = inputs.topInputs.citation-style-language; };
|
||||
mirism = inputs.pkgs.callPackage ./mirism
|
||||
{
|
||||
inherit cppcoro nameof tgbot-cpp date;
|
||||
nghttp2 = inputs.pkgs.callPackage "${inputs.topInputs."nixpkgs-23.05"}/pkgs/development/libraries/nghttp2"
|
||||
{ enableAsioLib = true; };
|
||||
{ enableAsioLib = true; stdenv = inputs.pkgs.gcc12Stdenv; };
|
||||
stdenv = inputs.pkgs.gcc12Stdenv;
|
||||
};
|
||||
cppcoro = inputs.pkgs.callPackage ./cppcoro { src = inputs.topInputs.cppcoro; };
|
||||
date = inputs.pkgs.callPackage ./date { src = inputs.topInputs.date; };
|
||||
@@ -37,53 +42,46 @@ inputs: rec
|
||||
torchtext = inputs.pkgs.python3Packages.callPackage ./torchtext { inherit torchdata; };
|
||||
win11os-kde = inputs.pkgs.callPackage ./win11os-kde { src = inputs.topInputs.win11os-kde; };
|
||||
fluent-kde = inputs.pkgs.callPackage ./fluent-kde { src = inputs.topInputs.fluent-kde; };
|
||||
blurred-wallpaper = inputs.pkgs.callPackage ./blurred-wallpaper { src = inputs.topInputs.blurred-wallpaper; };
|
||||
blurred-wallpaper = inputs.pkgs.callPackage ./blurred-wallpaper.nix { src = inputs.topInputs.blurred-wallpaper; };
|
||||
slate = inputs.pkgs.callPackage ./slate { src = inputs.topInputs.slate; };
|
||||
nvhpc = inputs.pkgs.callPackage ./nvhpc {};
|
||||
lmod = inputs.pkgs.callPackage ./lmod { src = inputs.topInputs.lmod; };
|
||||
vasp = rec
|
||||
{
|
||||
source = inputs.pkgs.callPackage ./vasp/source.nix {};
|
||||
src = inputs.pkgs.callPackage ./vasp/source.nix {};
|
||||
gnu = inputs.pkgs.callPackage ./vasp/gnu
|
||||
{
|
||||
inherit (inputs.pkgs.llvmPackages) openmp;
|
||||
inherit wannier90 additionalCommands;
|
||||
hdf5 = inputs.pkgs.hdf5.override { mpiSupport = true; fortranSupport = true; };
|
||||
};
|
||||
gnu-mkl = inputs.pkgs.callPackage ./vasp/gnu-mkl
|
||||
{
|
||||
inherit (inputs.pkgs.llvmPackages) openmp;
|
||||
inherit wannier90 additionalCommands;
|
||||
hdf5 = inputs.pkgs.hdf5.override { mpiSupport = true; fortranSupport = true; };
|
||||
inherit wannier90 src;
|
||||
hdf5 = inputs.pkgs.hdf5.override { mpiSupport = true; fortranSupport = true; cppSupport = false; };
|
||||
};
|
||||
nvidia = inputs.pkgs.callPackage ./vasp/nvidia
|
||||
{ inherit lmod nvhpc wannier90 additionalCommands vtst; hdf5 = hdf5-nvhpc; };
|
||||
{ inherit lmod nvhpc wannier90 vtst src; hdf5 = hdf5-nvhpc; };
|
||||
intel = inputs.pkgs.callPackage ./vasp/intel
|
||||
{ inherit lmod oneapi wannier90 additionalCommands vtst; hdf5 = hdf5-oneapi; };
|
||||
amd = inputs.pkgs.callPackage ./vasp/amd
|
||||
{ inherit aocc aocl wannier90 additionalCommands; hdf5 = hdf5-aocc; openmpi = openmpi-aocc; gcc = gcc-pie; };
|
||||
{ inherit lmod oneapi wannier90 vtst src; hdf5 = hdf5-oneapi; };
|
||||
wannier90 = inputs.pkgs.callPackage
|
||||
"${inputs.topInputs.nixpkgs-unstable}/pkgs/by-name/wa/wannier90/package.nix" {};
|
||||
hdf5-nvhpc = inputs.pkgs.callPackage ./vasp/hdf5-nvhpc { inherit lmod nvhpc; inherit (inputs.pkgs.hdf5) src; };
|
||||
hdf5-oneapi = inputs.pkgs.callPackage ./vasp/hdf5-oneapi { inherit lmod oneapi; inherit (inputs.pkgs.hdf5) src; };
|
||||
hdf5-aocc = inputs.pkgs.callPackage ./vasp/hdf5-aocc
|
||||
{ inherit (inputs.pkgs.hdf5) src; inherit aocc; openmpi = openmpi-aocc; gcc = gcc-pie; };
|
||||
openmpi-aocc = inputs.pkgs.callPackage ./vasp/openmpi-aocc { inherit aocc; gcc = gcc-pie; };
|
||||
gcc-pie = inputs.pkgs.wrapCC (inputs.pkgs.gcc.cc.overrideAttrs (prev:
|
||||
{ configureFlags = prev.configureFlags ++ [ "--enable-default-pie" ];}));
|
||||
additionalCommands = let uid = inputs.config.nixos.user.uid.gb; in
|
||||
''[ "$(${inputs.pkgs.coreutils}/bin/id -u)" -eq ${builtins.toString uid} ] && exit 1'';
|
||||
vtst = (inputs.pkgs.callPackage ./vasp/vtst.nix {});
|
||||
vtstscripts = inputs.pkgs.callPackage ./vasp/vtstscripts.nix {};
|
||||
};
|
||||
# TODO: use other people packaged hpc version
|
||||
oneapi = inputs.pkgs.callPackage ./oneapi {};
|
||||
mumax = inputs.pkgs.callPackage ./mumax { src = inputs.topInputs.mumax; };
|
||||
aocc = inputs.pkgs.callPackage ./aocc {};
|
||||
aocl = inputs.pkgs.callPackage ./aocl {};
|
||||
kylin-virtual-keyboard = inputs.pkgs.libsForQt5.callPackage ./kylin-virtual-keyboard
|
||||
{ src = inputs.topInputs.kylin-virtual-keyboard; };
|
||||
biu = inputs.pkgs.callPackage ./biu { inherit nameof; };
|
||||
biu = inputs.pkgs.callPackage ./biu { inherit nameof zpp-bits; };
|
||||
zxorm = inputs.pkgs.callPackage ./zxorm { src = inputs.topInputs.zxorm; };
|
||||
hpcstat = inputs.pkgs.callPackage ./hpcstat { inherit nameof sqlite-orm zpp-bits date biu; };
|
||||
openxlsx = inputs.pkgs.callPackage ./openxlsx { src = inputs.topInputs.openxlsx; };
|
||||
sqlite-orm = inputs.pkgs.callPackage ./sqlite-orm { src = inputs.topInputs.sqlite-orm; };
|
||||
mkPnpmPackage = inputs.pkgs.callPackage ./mkPnpmPackage.nix {};
|
||||
nodejs-with-pnpm9 = inputs.pkgs.callPackage ./nodejs-with-pnpm9.nix {};
|
||||
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; };
|
||||
ufo = inputs.pkgs.callPackage ./ufo
|
||||
{ inherit concurrencpp biu glad matplotplusplus zpp-bits; tbb = inputs.pkgs.tbb_2021_11; };
|
||||
chn-bsub = inputs.pkgs.callPackage ./chn-bsub { inherit biu; };
|
||||
|
||||
fromYaml = content: builtins.fromJSON (builtins.readFile
|
||||
(inputs.pkgs.runCommand "toJSON" {}
|
||||
|
||||
3
local/pkgs/hpcstat/.clangd
Normal file
3
local/pkgs/hpcstat/.clangd
Normal file
@@ -0,0 +1,3 @@
|
||||
CompileFlags:
|
||||
Add: [ -Wall, -Wextra, -std=c++23 ]
|
||||
Compiler: g++
|
||||
1
local/pkgs/hpcstat/.envrc
Normal file
1
local/pkgs/hpcstat/.envrc
Normal file
@@ -0,0 +1 @@
|
||||
use flake .#hpcstat
|
||||
39
local/pkgs/hpcstat/CMakeLists.txt
Normal file
39
local/pkgs/hpcstat/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(hpcstat 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()
|
||||
|
||||
set(HPCSTAT_VERSION "unknown" CACHE STRING "Version of the hpcstat")
|
||||
|
||||
find_package(Boost REQUIRED COMPONENTS headers filesystem)
|
||||
find_package(SqliteOrm REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
|
||||
find_package(range-v3 REQUIRED)
|
||||
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
|
||||
find_package(date REQUIRED)
|
||||
find_package(httplib REQUIRED)
|
||||
find_package(termcolor REQUIRED)
|
||||
find_package(biu REQUIRED)
|
||||
|
||||
add_executable(hpcstat src/main.cpp src/env.cpp src/keys.cpp src/ssh.cpp src/sql.cpp src/lfs.cpp src/common.cpp
|
||||
src/push.cpp src/disk.cpp)
|
||||
target_compile_features(hpcstat PRIVATE cxx_std_23)
|
||||
target_include_directories(hpcstat PRIVATE ${PROJECT_SOURCE_DIR}/include ${ZPP_BITS_INCLUDE_DIR})
|
||||
target_link_libraries(hpcstat PRIVATE Boost::headers Boost::filesystem sqlite_orm::sqlite_orm
|
||||
nlohmann_json::nlohmann_json range-v3::range-v3 date::date date::date-tz httplib::httplib
|
||||
termcolor::termcolor biu::biu)
|
||||
target_compile_definitions(hpcstat PRIVATE HPCSTAT_VERSION="${HPCSTAT_VERSION}")
|
||||
|
||||
install(TARGETS hpcstat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(DIRECTORY share/ DESTINATION ${CMAKE_INSTALL_DATADIR}/hpcstat)
|
||||
|
||||
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
|
||||
message("Imported targets: ${ImportedTargets}")
|
||||
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
|
||||
21
local/pkgs/hpcstat/default.nix
Normal file
21
local/pkgs/hpcstat/default.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
stdenv, cmake, pkg-config, standalone ? false, version ? null, makeWrapper, lib,
|
||||
boost, fmt, sqlite-orm, nlohmann_json, zpp-bits, range-v3, nameof, openssh, sqlite, date, httplib, openssl,
|
||||
termcolor, duc, biu
|
||||
}: stdenv.mkDerivation
|
||||
{
|
||||
name = "hpcstat";
|
||||
src = ./.;
|
||||
buildInputs =
|
||||
[ boost fmt sqlite-orm nlohmann_json zpp-bits range-v3 nameof sqlite date httplib termcolor openssl biu ];
|
||||
nativeBuildInputs = [ cmake pkg-config makeWrapper ];
|
||||
cmakeFlags = lib.optionals (version != null) [ "-DHPCSTAT_VERSION=${version}" ];
|
||||
postInstall =
|
||||
if standalone then "cp ${openssh}/bin/{ssh-add,ssh-keygen} ${duc}/bin/duc $out/bin"
|
||||
else
|
||||
''
|
||||
wrapProgram $out/bin/hpcstat --set HPCSTAT_SHAREDIR $out/share/hpcstat \
|
||||
--set HPCSTAT_DATADIR /var/lib/hpcstat --set HPCSTAT_SSH_BINDIR ${openssh}/bin \
|
||||
--set HPCSTAT_DUC_BINDIR ${duc}/bin
|
||||
'';
|
||||
}
|
||||
BIN
local/pkgs/hpcstat/doc/pageant1.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/pageant1.png
LFS
Normal file
Binary file not shown.
BIN
local/pkgs/hpcstat/doc/pageant2.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/pageant2.png
LFS
Normal file
Binary file not shown.
BIN
local/pkgs/hpcstat/doc/putty1.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/putty1.png
LFS
Normal file
Binary file not shown.
BIN
local/pkgs/hpcstat/doc/putty2.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/putty2.png
LFS
Normal file
Binary file not shown.
BIN
local/pkgs/hpcstat/doc/putty3.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/putty3.png
LFS
Normal file
Binary file not shown.
214
local/pkgs/hpcstat/doc/setup.md
Normal file
214
local/pkgs/hpcstat/doc/setup.md
Normal file
@@ -0,0 +1,214 @@
|
||||
# 设置 SSH agent forwarding
|
||||
|
||||
为了区分登陆 jykang@hpc.xmu.edu.cn 时使用的密钥,并分密钥统计使用情况,需要启用一项名为“SSH agent forwarding”的功能。
|
||||
接下来的内容将带领您在 Windows 系统上配置 SSH agent forwarding。
|
||||
|
||||
> [!NOTE]
|
||||
> 在 Linux 上的配置方法放在了文章末尾。大多数用户不需要阅读。
|
||||
|
||||
要启用“SSH agent forwarding”,需要下面三个步骤:
|
||||
1. 启动 Pageant 并添加密钥。 **这一步骤每次登陆前都需要执行。**
|
||||
2. 配置 PuTTY,使 PuTTY 在每次登陆时不直接使用密钥,而是利用 Pageant 完成认证。这一步骤只需要执行一次。
|
||||
3. 配置 WinSCP,使 WinSCP 在每次登陆时不直接使用密钥,而是利用 Pageant 完成认证。这一步骤只需要执行一次。
|
||||
|
||||
接下来将分别说明这三个步骤。
|
||||
|
||||
## Pageant:
|
||||
|
||||
1. 找到 Pageant 程序。Pageant 会随着 PuTTY 一起安装,一般来说您可以直接在开始菜单中搜索 “pageant” 找到它,也可以在 PuTTY 的安装目录中找到它。
|
||||
2. 启动 Pageant。启动后可能没有任何反应,也可能有一个黑框闪过,这是正常的。只要右下角的系统托盘中出现了 pageant 的图标就可以了。
|
||||
|
||||

|
||||
|
||||
3. 双击 Pageant 图标,打开 Pageant 窗口。选择 “Add Key”,然后选择您的密钥文件。
|
||||
|
||||

|
||||
|
||||
4. 在使用服务器期间保持 Pageant 启动(可以关闭 Pageant 的窗口,但不要在系统托盘中右键退出)。
|
||||
5. 使用完毕后,在系统托盘中右键退出 Pageant。
|
||||
|
||||
> [!NOTE]
|
||||
> 无论是使用 WinSCP 还是 PuTTY,每次使用前,都需要如此启动 Pageant 并添加密钥。
|
||||
|
||||
> [!TIP]
|
||||
> 如果您觉得每次打开 Pageant 都要手动添加密钥很麻烦,并且熟悉 Windows 命令行的使用,
|
||||
> 可以编写一个批处理文件(将下方代码用记事本保存,然后将扩展名从 `.txt` 改为 `.bat`),每次双击该文件即可启动 Pageant 并自动添加密钥:
|
||||
>
|
||||
> `"C:\ProgramData\chocolatey\bin\PAGEANT.EXE" "Z:\.ssh\id_rsa.ppk"`
|
||||
>
|
||||
> 其中第一个引号内为 Pageant 的路径,第二个引号内为您的密钥文件的路径。也可以将该批处理文件放入开机启动项中,使得 Pageant 在开机时自动启动。
|
||||
>
|
||||
> 因为每个人的密钥文件以及 Pageant 的路径都可能不同,所以这里无法提供通用的批处理文件。
|
||||
|
||||
## PuTTY:
|
||||
|
||||
1. 在 Connection -> SSH -> Auth,勾选“Attempt authentication using Pageant”和“Allow agent forwarding”。
|
||||
|
||||

|
||||
|
||||
2. 在 Connection -> SSH -> Auth -> Credentials,清空 “Private key file for authentication”,然后保存。
|
||||
|
||||

|
||||
|
||||
3. (选做但推荐)在 Connection -> Data 中,将 “Auto-login username” 设置为 `jykang`,这样每次登陆时就不需要手动输入用户名了。
|
||||
|
||||
## WinSCP:
|
||||
|
||||
1. 在 SSH -> Authentication,勾选 “使用 Pageant 进行认证”,勾选 “允许代理转发”,清空 “密钥文件”,然后保存。
|
||||
|
||||

|
||||
|
||||
2. (选做)如果您需要通过 WinSCP 打开 PuTTY 的话,需要在 WinSCP 主界面 -> 工具 -> 选项 -> 集成 -> 应用程序路径中,
|
||||
在原来的基础上增加 `-A` 参数。
|
||||
|
||||

|
||||
|
||||
> [!TIP]
|
||||
> 如果 WinSCP 不让你直接修改那个字符串,就把它复制到记事本里修改,然后再复制回去。
|
||||
|
||||
至此,您已经成功配置了 SSH agent forwarding。
|
||||
之后使用 PuTTY 登陆 `jykang@hpc.xmu.edu.cn` 时,会收到包含了您的名字的提示(如图所示),表明您已经成功启用了 SSH agent forwarding。
|
||||
|
||||

|
||||
|
||||
> [!NOTE]
|
||||
> 无论是 PuTTY 还是 WinSCP,改完设置后都记得保存。
|
||||
|
||||
> [!IMPORTANT]
|
||||
> 如果您确认已经按照教程设置好了却仍然不能连接,可以尝试将 WinSCP 和 PuTTY 都更新到最新。
|
||||
>
|
||||
> 我测试使用的版本是:PuTTY 0.78 和 WinSCP 6.3.3。
|
||||
|
||||
---
|
||||
|
||||
# 其它内容
|
||||
|
||||
接下来的内容不是使用 jykang@hpc.xmu.edu.cn 的必需内容,不须要阅读。
|
||||
如果您按照上面的步骤配置 SSH agent forwarding 失败,那么请再次仔细阅读上面的内容,**接下来的内容对您没有帮助**。
|
||||
|
||||
接下来的内容包括:
|
||||
* 解释为什么不转发 agent 就无法区分不同密钥。
|
||||
* 介绍一些可能有用的附加功能,例如区分使用同一个密钥的不同用户,以及如何设置任务进度微信通知。
|
||||
|
||||
## 为什么不转发 agent 就无法区分不同密钥?
|
||||
|
||||
如果你好奇为什么不使用 Pageant 就无法区分使用不同密钥的登陆:
|
||||
|
||||
SSH 连接并不是直接由 jykang 用户处理的,
|
||||
而是由一个名为 `sshd` 的程序处理,它通常以 `root` 用户的身份运行。
|
||||
在完成认证后,`sshd` 会将 Windows 电脑发来的信息解密后转发给以 `jykang` 用户运行的进程,
|
||||
并将以 `jykang` 用户运行的进程的输出加密后发回给 Windows 电脑。
|
||||
我们只能控制 `jykang` 用户运行的进程,但这里拿不到任何关于密钥的信息。
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph "Run on windows"
|
||||
A[(密钥文件)] -.->|从硬盘读取| B["SSH client (putty, WinSCP, etc.)"]
|
||||
end
|
||||
subgraph "Run on hpc by root"
|
||||
C["SSH server (sshd)"]
|
||||
end
|
||||
B <--> |"认证信息 & 加密的数据"| C
|
||||
subgraph "Run on hpc by <b>jykang</b>"
|
||||
D["Other programs (bash, VASP, etc.)"]
|
||||
end
|
||||
C <--> |"解密后的数据(不包含密钥信息)"| D
|
||||
```
|
||||
|
||||
Pageant 程序就是所谓的“SSH agent”。“SSH agent forwarding” 就是将到 Pageant 的连接通过已经建立的 SSH 连接转发给远程服务器,
|
||||
使得远程服务器可以与 Pageant 通信,进而读取密钥信息。
|
||||
“SSH agent forwarding” 典型的用途是在远程服务器上使用本地的密钥再次登陆其他服务器,而不是为了区分使用不同密钥的登陆。
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph "Run on windows"
|
||||
A[(密钥文件)] -.->|从硬盘读取| E["SSH agent (pageant)"]
|
||||
E <-->|认证信息| B["SSH client (putty, WinSCP, etc.)"]
|
||||
end
|
||||
subgraph "Run on hpc by root"
|
||||
C["SSH server (sshd)"]
|
||||
end
|
||||
B <--> |"认证信息 & 加密的数据"| C
|
||||
subgraph "Run on hpc by <b>jykang</b>"
|
||||
D["Other programs (bash, VASP, etc.)"]
|
||||
end
|
||||
C <--> |"解密后的数据(不包含密钥信息)"| D
|
||||
E <-...-> |"通过已经建立的 SSH 连接转发密钥信息"| D
|
||||
```
|
||||
|
||||
事实上,linux 的管理(统计用户使用的资源,等)非常依赖于不同的用户,即用高权限的用户去管理低权限的用户。
|
||||
大家都使用同一个账户的情况下,很多管理的功能没有现成的解决方案(要自己手写代码、思考如何设计),甚至完全无法实现。
|
||||
整这个东西真的挺麻烦的。我也嫌麻烦(而且我要做的事情比大多数用户多得多)。要不是康老师一定要我做,我才不会做。
|
||||
如果你嫌这些麻烦,与其埋怨我,不如去建议自己的导师去自己申请一个账号用。
|
||||
|
||||
## 设置子账户:
|
||||
|
||||
一个老师拿到密钥后,可能会将它分发给多个不同的学生。
|
||||
如果希望区分不同学生的使用情况,可以修改 `TERM` 变量,加上 `hpcstat_subaccount:your_name:` 前缀,
|
||||
以此来进一步区分使用同一个密钥的不同用户。
|
||||
|
||||
对于 PuTTY 来说,`TERM` 变量在 Connection -> Data -> Ternimal-type string 中修改。
|
||||
例如,如果原本的 `TERM` 变量是 `xterm`,那么修改后的 `TERM` 变量可以是 `hpcstat_subaccount:chn:xterm`。
|
||||
`TERM` 变量只在交互式登陆时有效,因此无法在 WinSCP 中使用。
|
||||
|
||||
如果设置了这个参数,那么会额外统计不同子账户的使用情况(登陆次数、投递的任务、占用的核时,等)。
|
||||
是否设置这个参数都不影响按密钥统计的功能(即,按照密钥统计的核时,是所有使用这个密钥的用户的总和,无论是否设置了这个参数)。
|
||||
|
||||
同时,子账户的统计结果也仅供参考,事实上这个统计结果很容易造假
|
||||
(如果 A 和 B 都使用同一个密钥登陆,那么显然 B 可以在 TERM 中填入 A 的名字以假装自己是 A,把自己用的核时都算到 A 头上)。
|
||||
|
||||
> [!CAUTION]
|
||||
> 如果 `TERM` 变量的格式设置得不正确,PuTTY 登陆后一些程序会无法正常工作,因此尝试时应该仔细且小心。
|
||||
|
||||
## PuTTY 登陆时自动跳转:
|
||||
|
||||
如果您希望在登陆时自动跳转到自己的目录下,可以在 `TERM` 中再增加以下前缀:`chn_cd:your_path:`。
|
||||
|
||||
例如,将 `TERM` 变量修改为 `chn_cd:linwei/chn:xterm`,那么使用 PuTTY 登陆后会自动跳转到 `linwei/chn` 目录下。
|
||||
|
||||
如果同时使用了 `hpcstat_subaccount` 和 `chn_cd`,那么 `hpcstat_subaccount` 必须在 `chn_cd` 之后,
|
||||
例如 `chn_cd:linwei/chn:hpcstat_subaccount:chn:xterm`。
|
||||
|
||||
## 任务进度微信通知:
|
||||
|
||||
用微信打开下面的链接:
|
||||
|
||||
```
|
||||
https://wxpusher.zjiecode.com/wxuser/?type=1&id=75864#/follow
|
||||
```
|
||||
|
||||
您应该会被引导去关注一个公众号(WxPusher 消息推送平台)。关注这个公众号之后会收到一条包含 UID 的消息。
|
||||
然后把下面的信息发给我:
|
||||
* 您的 UID
|
||||
* 您使用的密钥的指纹(用 PuTTY 登陆时会提示)
|
||||
* 如果使用了子账户(在 `TERM` 中设置了 `hpcstat_subaccount`),还需要告诉我您设置的子账户名
|
||||
|
||||
之后您投递的任务有新进度(例如,开始运行、运行结束)时就会通过这个公众号收到通知。
|
||||
|
||||
需要注意的是,这个 UID 会被明文写到 jykang 上的文件里。
|
||||
也就是说存在这样的风险:有权限登陆 jykang 的人都有权限通过这个公众号给您发消息。
|
||||
|
||||
## 在 Linux 上配置 SSH agent forwarding
|
||||
|
||||
1. 使用以下命令将 `.ppk` 的私钥部分拆分出来:
|
||||
|
||||
```bash
|
||||
puttygen id_rsa.ppk -O private-openssh -o ./id_rsa
|
||||
```
|
||||
|
||||
确保 `id_rsa` 的权限为 `600`。
|
||||
|
||||
2. 在 `~/.ssh/config` 中添加以下内容:
|
||||
|
||||
```
|
||||
Host jykang
|
||||
AddKeysToAgent yes
|
||||
ForwardAgent yes
|
||||
IdentityFile ~/path/to/id_rsa
|
||||
```
|
||||
|
||||
然后就可以正常使用了,例如:
|
||||
|
||||
```bash
|
||||
ssh jykang
|
||||
```
|
||||
BIN
local/pkgs/hpcstat/doc/winscp1.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/winscp1.png
LFS
Normal file
Binary file not shown.
BIN
local/pkgs/hpcstat/doc/winscp2.png
LFS
Normal file
BIN
local/pkgs/hpcstat/doc/winscp2.png
LFS
Normal file
Binary file not shown.
26
local/pkgs/hpcstat/include/hpcstat/common.hpp
Normal file
26
local/pkgs/hpcstat/include/hpcstat/common.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
# pragma once
|
||||
# include <optional>
|
||||
# include <string>
|
||||
# include <filesystem>
|
||||
# include <vector>
|
||||
# include <map>
|
||||
# include <utility>
|
||||
# include <set>
|
||||
# include <iostream>
|
||||
# include <regex>
|
||||
# include <thread>
|
||||
# include <chrono>
|
||||
# include <fstream>
|
||||
# include <future>
|
||||
# include <date/date.h>
|
||||
# include <date/tz.h>
|
||||
# include <boost/interprocess/sync/file_lock.hpp>
|
||||
# include <zpp_bits.h>
|
||||
# include <biu.hpp>
|
||||
|
||||
namespace hpcstat
|
||||
{
|
||||
using namespace biu::literals;
|
||||
// get current time
|
||||
long now();
|
||||
}
|
||||
18
local/pkgs/hpcstat/include/hpcstat/disk.hpp
Normal file
18
local/pkgs/hpcstat/include/hpcstat/disk.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
|
||||
namespace hpcstat::disk
|
||||
{
|
||||
struct Usage
|
||||
{
|
||||
double Total;
|
||||
std::vector<std::pair<std::string, double>> Teacher; // 已排序
|
||||
std::vector<std::pair<std::string, double>> Student; // 已排序
|
||||
std::string Time;
|
||||
using serialize = zpp::bits::members<4>;
|
||||
};
|
||||
// 刷新 duc 数据库
|
||||
bool stat();
|
||||
// 从 duc 数据库中读取数据
|
||||
std::optional<Usage> get();
|
||||
}
|
||||
11
local/pkgs/hpcstat/include/hpcstat/env.hpp
Normal file
11
local/pkgs/hpcstat/include/hpcstat/env.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
|
||||
namespace hpcstat::env
|
||||
{
|
||||
// check if the program is running in an interactive shell
|
||||
bool interactive();
|
||||
|
||||
// get the value of an environment variable
|
||||
std::optional<std::string> env(std::string name, bool required = false);
|
||||
}
|
||||
9
local/pkgs/hpcstat/include/hpcstat/keys.hpp
Normal file
9
local/pkgs/hpcstat/include/hpcstat/keys.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
|
||||
namespace hpcstat
|
||||
{
|
||||
// valid keys
|
||||
struct Key { std::string PubkeyFilename; std::string Username; };
|
||||
extern std::map<std::string, Key> Keys;
|
||||
}
|
||||
11
local/pkgs/hpcstat/include/hpcstat/lfs.hpp
Normal file
11
local/pkgs/hpcstat/include/hpcstat/lfs.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
|
||||
namespace hpcstat::lfs
|
||||
{
|
||||
std::optional<std::pair<unsigned, std::string>> bsub(std::vector<std::string> args);
|
||||
// JobId -> { SubmitTime, Status, CpuTime, JobName }
|
||||
std::optional<std::map<unsigned, std::tuple<std::string, std::string, double, std::string>>>
|
||||
bjobs_list(bool finished_jobs_only = false);
|
||||
std::optional<std::string> bjobs_detail(unsigned jobid);
|
||||
}
|
||||
9
local/pkgs/hpcstat/include/hpcstat/push.hpp
Normal file
9
local/pkgs/hpcstat/include/hpcstat/push.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
|
||||
namespace hpcstat::push
|
||||
{
|
||||
// 向微信推送数据
|
||||
// 任务 id,名称、现在的状态、提交时的 key、subaccount
|
||||
bool push(std::map<unsigned, std::tuple<std::string, std::string, std::string, std::optional<std::string>>> data);
|
||||
}
|
||||
71
local/pkgs/hpcstat/include/hpcstat/sql.hpp
Normal file
71
local/pkgs/hpcstat/include/hpcstat/sql.hpp
Normal file
@@ -0,0 +1,71 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
# include <hpcstat/disk.hpp>
|
||||
|
||||
namespace hpcstat::sql
|
||||
{
|
||||
struct LoginData
|
||||
{
|
||||
unsigned Id = 0; long Time;
|
||||
std::string Key, SessionId, Signature = "";
|
||||
std::optional<std::string> Subaccount, Ip;
|
||||
bool Interactive;
|
||||
using serialize = zpp::bits::members<8>;
|
||||
bool operator==(const LoginData& other) const = default;
|
||||
};
|
||||
struct LogoutData
|
||||
{
|
||||
unsigned Id = 0;
|
||||
long Time;
|
||||
std::string SessionId;
|
||||
bool operator==(const LogoutData& other) const = default;
|
||||
};
|
||||
struct SubmitJobData
|
||||
{
|
||||
unsigned Id = 0;
|
||||
long Time;
|
||||
unsigned JobId;
|
||||
std::string Key, SessionId, SubmitDir, JobCommand, Signature = "";
|
||||
std::optional<std::string> Subaccount, Ip;
|
||||
using serialize = zpp::bits::members<10>;
|
||||
bool operator==(const SubmitJobData& other) const = default;
|
||||
};
|
||||
struct FinishJobData
|
||||
{
|
||||
unsigned Id = 0;
|
||||
long Time;
|
||||
unsigned JobId;
|
||||
std::string JobResult, SubmitTime, JobDetail, Key, Signature = "";
|
||||
double CpuTime;
|
||||
using serialize = zpp::bits::members<9>;
|
||||
bool operator==(const FinishJobData& other) const = default;
|
||||
};
|
||||
struct CheckJobData
|
||||
{
|
||||
unsigned Id = 0;
|
||||
unsigned JobId;
|
||||
std::string Status;
|
||||
bool operator==(const CheckJobData& other) const = default;
|
||||
};
|
||||
struct DiskData
|
||||
{
|
||||
unsigned Id = 0;
|
||||
std::string Data;
|
||||
};
|
||||
// 初始化数据库
|
||||
bool initdb();
|
||||
// 将数据写入数据库
|
||||
bool writedb(auto value);
|
||||
// 查询 bjobs -a 的结果中,有哪些是已经被写入到数据库中的(按照任务 id 和提交时间计算),返回未被写入的任务 id
|
||||
std::optional<std::set<unsigned>> finishjob_remove_existed(std::map<unsigned, std::string> jobid_submit_time);
|
||||
// 检查数据库中已经有的数据是否被修改过,如果有修改过,返回 std::nullopt,否则返回新增的数据,用于校验签名
|
||||
// 三个字符串分别是序列化后的数据,签名,指纹
|
||||
std::optional<std::vector<std::tuple<std::string, std::string, std::string>>>
|
||||
verify(std::string old_db, std::string new_db);
|
||||
// 将某个月份的数据导出
|
||||
bool export_data(long start_time, long end_time);
|
||||
// 检查任务状态,返回有变化的任务 id、名称、现在的状态、提交时的 key、subaccount
|
||||
// 如果没有找到提交时的信息,则忽略这个任务
|
||||
std::optional<std::map<unsigned, std::tuple<std::string, std::string, std::string, std::optional<std::string>>>>
|
||||
check_job_status();
|
||||
}
|
||||
12
local/pkgs/hpcstat/include/hpcstat/ssh.hpp
Normal file
12
local/pkgs/hpcstat/include/hpcstat/ssh.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
# pragma once
|
||||
# include <hpcstat/common.hpp>
|
||||
|
||||
namespace hpcstat::ssh
|
||||
{
|
||||
// get a valid public key fingerprint
|
||||
std::optional<std::string> fingerprint();
|
||||
// sign a message with the key of specified fingerprint
|
||||
std::optional<std::string> sign(std::string message, std::string fingerprint);
|
||||
// verify a message with the key of specified fingerprint
|
||||
bool verify(std::string message, std::string signature, std::string fingerprint);
|
||||
}
|
||||
71
local/pkgs/hpcstat/openssh.patch
Normal file
71
local/pkgs/hpcstat/openssh.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
diff --git a/misc.c b/misc.c
|
||||
index 7a42d4981..9da536b6a 100644
|
||||
--- a/misc.c
|
||||
+++ b/misc.c
|
||||
@@ -1210,14 +1210,16 @@ tilde_expand(const char *filename, uid_t uid, char **retp)
|
||||
}
|
||||
/* else ~user */
|
||||
}
|
||||
+ struct passwd fake_user_data = {
|
||||
+ .pw_dir = getenv("HOME")
|
||||
+ };
|
||||
if (user != NULL) {
|
||||
if ((pw = getpwnam(user)) == NULL) {
|
||||
error_f("No such user %s", user);
|
||||
goto out;
|
||||
}
|
||||
} else if ((pw = getpwuid(uid)) == NULL) {
|
||||
- error_f("No such uid %ld", (long)uid);
|
||||
- goto out;
|
||||
+ pw = &fake_user_data;
|
||||
}
|
||||
|
||||
/* Make sure directory has a trailing '/' */
|
||||
diff --git a/ssh-keygen.c b/ssh-keygen.c
|
||||
index 97c6d134a..9a89ef07b 100644
|
||||
--- a/ssh-keygen.c
|
||||
+++ b/ssh-keygen.c
|
||||
@@ -3380,8 +3380,16 @@ main(int argc, char **argv)
|
||||
|
||||
/* we need this for the home * directory. */
|
||||
pw = getpwuid(getuid());
|
||||
- if (!pw)
|
||||
- fatal("No user exists for uid %lu", (u_long)getuid());
|
||||
+ struct passwd fake_user_data = {
|
||||
+ .pw_name = "ssh",
|
||||
+ .pw_passwd = "",
|
||||
+ .pw_uid = getuid(),
|
||||
+ .pw_gid = getgid(),
|
||||
+ .pw_gecos = "",
|
||||
+ .pw_dir = getenv("HOME"),
|
||||
+ .pw_shell = getenv("SHELL")
|
||||
+ };
|
||||
+ if (!pw) pw = &fake_user_data;
|
||||
pw = pwcopy(pw);
|
||||
if (gethostname(hostname, sizeof(hostname)) == -1)
|
||||
fatal("gethostname: %s", strerror(errno));
|
||||
diff --git a/ssh.c b/ssh.c
|
||||
index 0019281f4..96c24cf15 100644
|
||||
--- a/ssh.c
|
||||
+++ b/ssh.c
|
||||
@@ -708,10 +708,16 @@ main(int ac, char **av)
|
||||
|
||||
/* Get user data. */
|
||||
pw = getpwuid(getuid());
|
||||
- if (!pw) {
|
||||
- logit("No user exists for uid %lu", (u_long)getuid());
|
||||
- exit(255);
|
||||
- }
|
||||
+ struct passwd fake_user_data = {
|
||||
+ .pw_name = "ssh",
|
||||
+ .pw_passwd = "",
|
||||
+ .pw_uid = getuid(),
|
||||
+ .pw_gid = getgid(),
|
||||
+ .pw_gecos = "",
|
||||
+ .pw_dir = getenv("HOME"),
|
||||
+ .pw_shell = getenv("SHELL")
|
||||
+ };
|
||||
+ if (!pw) pw = &fake_user_data;
|
||||
/* Take a copy of the returned structure. */
|
||||
pw = pwcopy(pw);
|
||||
|
||||
1
local/pkgs/hpcstat/share/keys/00
Normal file
1
local/pkgs/hpcstat/share/keys/00
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCmJoiGO5YD3lbbIOJ99Al2xxm6QS9q+dTCTtlALjYI5f9ICGZJT8PEGlV9BBNCRQdgb3i2LBzQi90Tq1oG6/PcTV3Mto2TawLz5+2+ym29eIq1QIhVTLmZskK815FpawWqxY6+xpGU3vP1WjrFBbhGtl+CCaN+P2TWNkrR8FjG2144hdAlFfEEqfQC+TXbsyJCYoExuxGDJo8ae0JGbz9w1A1UbjnHwKnoxvirTFEbw9IHJIcTdUwuQKOrwydboCOqeaHt74+BnnCOZhpYqMDacrknHITN4GfFFzbs6FsE8NAwFk6yvkNXXzoe60iveNXtCIYuWjG517LQgHAC5BdaPgqzYNg+eqSul72e+jjRs+KDioNqvprw+TcBBO1lXZ2VQFyWyAdV2Foyaz3Wk5qYlOpX/9JLEp6H3cU0XCFR25FdXmjQ4oXN1QEe+2akV8MQ9cWhFhDcbY8Q1EiMWpBVC1xbt4FwE8VCTByZOZsQ0wPVe/vkjANOo+brS3tsR18= 00@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/01
Normal file
1
local/pkgs/hpcstat/share/keys/01
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCxcIWDQxVyIRqCGR4uWtrh4tLc025+q6du2GVsox8IzmBFkjNY8Au5GIMP5BKRstxFdg3f/wam8krckUN9rv5+OHB9U8HGz77Xs0FktqRVNMaDPdptePZQJ9A9eW3kkFDfQnORJtiVcEWfUBS3pi0QFOHylnG27YyC/Vjx9tjvtJWKsQEVTFJbFHPdi+G7lHTpqIGx+/a2JN9O6uVujXXYvjSVXsd+CWB9VMZMvYCIz2Ecb6RqR3brj4FhRRl8zyCj+J4ACYFdGWL98fTab2uPHbpVeKrefFFA43JOD/4zwBx/uw7MAQAq0GunTV3FpBfIAQHWgftf2fSlbz20oPjCwdYn9ZuGJOBUroryex7AKZmnSYM3biLHcctQfZtxqVPEU3W/62MUsI/kZb9RcF24JRksMoS2XWTiv2HFf5ijQGLXXOjqiTlGncwiKf65DwkDBsSxzgbXk5Uo86viq6UITFXPx/RytU+SUiN4Wb7wcBTjt/+tyQd1uqc7+3DCDXk= 01@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/02
Normal file
1
local/pkgs/hpcstat/share/keys/02
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDkT/P4MnzxBh8sRi0oQ88duNpY/ejFtptGqUQJVobj23vbu7ju6x/yuXqnHFOLi/IOZgNl5oBhRlJekRL+FWMIwpPBA6MnbVNkHXvwu5kLXVTt0O9dhJfDiPPbYcNjOhw4o8aZMc0oEyz8xZgkPoIehHQda+K5vRhFnYCRgn2X92VY/dW1QqPJKEfN47Tsp00w8wyKixEvuJe8OBEoKDpiZYzbXJKuoKhCdMp0uMHMCojYuYP9rGZO6bHl7Q6cYotGx1jH2pe30Ujtm3Xbm44H1mhXr1K/lhcHfojSge8POqii+eaXSCzqRlXaWyvrL9JLaaRD7GfWDaRWSKDfN8Ha4mnUvRtObRMSLOnr2QOTLJw9QPnlDDxCd1q7yluKraccYnTQQP5JuBwkRqjuJTatd9b18Z14HffmXZNR7asT1sJXK1rWKeLTrZwqxpkuwLAnbr60PVwfMHZeZ6FVPXGZ4wQb22lFHvaZZCEJf+9QDXpDn5L59FlaBYO2Xwojj3s= 02@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/03
Normal file
1
local/pkgs/hpcstat/share/keys/03
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDOF3LfnQiI8wpsXGn87bt7rbUZcgsdaOSOswk4Vf4dBautEdQZc0q+UDB2TlR2K8L7SPyywpl5z67euN5QRJLEwg8flTybiJp3EKDctYEM22sa36ONcSIJ/iHSdCkwtPXkBYreh9e+MAHfTroIKK5zM/P1QIN3NrknIXpWjLDF73ejrxE+EXRK6jbuWfo+5dnLnDoUFt1e+pYLZos5KRRB94Qt5I79D/cAg3hG+Zl2FCCOpn1hIdLo/kWJTKUPe61oUaIxriV6nCXp/pU1BHlM43hGowiHa4bVZIs8Eo4r7OI9thhSuS2BKSifibBKIicZtntSlS/I3xa5am28YLmrOiEXRsjPom7trO8qIhPfYOc/yFDg1gcpLxyNroCPooPBzPxUqrTT96Q4fDDTaqfyuVxQFxbYoFAqQs8/lw6WcGJ4fGC5JPsPiwoSdQy/B7gCfQcFjPXp1NH8Sx+xMLCmxRqdKSyeiEwoyB0tZ6ngaI73HFhCPX1/rLx3xv0zd/8= 03@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/04
Normal file
1
local/pkgs/hpcstat/share/keys/04
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC96jp6qFrWt4651Arg+Ua6AU3CjftZuounKLlZ8s268Lo9Cba+nmoOGRNzefqr+f6/7KmFKd9+jqS3ZnKFQbzRFVzzHHIT7tSlgxFRw+yb553/vgm7z6d0HGd3B7XjpIpR7DrM/unnXtiT/WuX+UIKKQ1S4kHp4fTJxZuwzYgNWDsT7O/5H7nBoRVuUSG/achCzTq5V5WfNjvrGZypCmcCw5MTH3Iab4qQ7fhRK46e/OpgSMmsY1ZuEynIwVtimW4G10MUWZdawN4LHBNsCDBmBu0H1DYBb9AUW5IuifAyFPPlTOPtuzpEganaMwotcXiAwhfPQg1c0TfbB4ZJPow612dzxcflHAJyFy2LXbiG0rF48h0GpW5gY92QkeMQcbybKOS5yVlXynNNg0nL1bx+reu7Fy4jurc0facTaqzpSiyXsBLSOva+DZrxl2MBDLEdykkQMNIY69GeeC2XIN4tbfGDYU8VVtwnXJUkmeHAge5ypI1kkPhYRDxPDspym9M= 04@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/05
Normal file
1
local/pkgs/hpcstat/share/keys/05
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC9FmT0i2j9JsnyeVrEZP8gaWHnc5NnhJgb1sP8MP/pjx/GMEkms2LQvZYNw8MQvGA6HH/O2acy5NIdD69QkRlALXZlWpUQco8JDuJe7+2xkTMGPOAqB5YLMHRpFGHUmDMuSFGSg2YyLXaWXoWmib5xAvTL95xAcdNgp5xqWvO2N55edDeVOY5cTmIE2vC0nm5JSjMEMcIuqL8yJ3AweN4JkD8CVVy3po8f+krKsaYB+f21MqqSnCQ/cpKlWHuMN9k85hP/FB1E7gBXW/MuZ1uOm4IzjBhj8tYVN0UY7Mo2/9PhFqoBKGr6vs7Nx1mXBJ/A1lIKvW+ROvQ9ADpOfww6kPuHbX16gQ55JG7zneWeiP5pVaI4YZ4O1vAvARw/SaSFhRdpymPs5r+wdIDV9gGoqORrYqoPBz7Q02V71W+EV7WFAgxiJozO0vZwD9JJ2zivyIJfcVtIOMIvEhfsha7Hviut4JIOyoaEHjIZYsmvYHEeEBA4pTUHIUZlZj/St7U= 05@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/gb
Normal file
1
local/pkgs/hpcstat/share/keys/gb
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDWAfyfDFctbzJTiuK9IPw3yFLqt7vqd/T0/HoZfH/bzLZ8GVeod2oz6kjm3ns0IG94HO5vGMEmQfbK1ZKT2TqA7ve+3wG9seiwfh8xh7Xhl2AnaF0pjHEXnw+w8mTzxCv9qRhsgfHuuBVhH6PguHvk66GKjvNaxTJhlKAyNogOI3jLnw7ODFScldHbJlMYl1pBHV/G/Zeuq0qnA/pkeiFdvlsZUVGD0cCfuoHm8FCfEzv6pfkhVJUH0v5rof8GiT9eg7ntG49Gei1lkH5NosbY8f6fEKNSoOc0dm5g2FaI3D7LJixwQ6rMiJwmPb6A4oHmcJQKokU8uhROQorYLgV7RtrnHu2cHMRW6SiAUvpmvaPPcxn8CbfuSOGDhYRKxNJNtWRK08Urtq9tYD+Fpze4QoZXxN35uvsi3lMA55PK0AsTm/aVGslzHUUzgWtDxcI2pLAm9rFpCRPCY+UC1Xp5vjZoqZXwhJ81qZ7VXWTM2voxCrKAlu+Zg2FaQD5szOU= gb@xmupc1
|
||||
1
local/pkgs/hpcstat/share/keys/hpcstat
Normal file
1
local/pkgs/hpcstat/share/keys/hpcstat
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJRWge2+B1Et03n/B4ALBcAnjvtWPPmcFAoIlLP8oFkB hpcstat
|
||||
1
local/pkgs/hpcstat/share/keys/xll
Normal file
1
local/pkgs/hpcstat/share/keys/xll
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDJ/jzUQ6QuAjnAryvpWk7TReS6pnHxhEXY9RonojKkurhfYSQO/IlxDMDq23TFXcgu8iZG4cS6MADgx/KNZD/MjuN9YNCIEGvMwzWvB0oM25BC6Vf3iKDmhH06rZKH6/g5GN+HWoCN4yE/+MhIpegFO3+YMpveXwEESlyoIjPvcW+RwmlNJevrHd83ETYDQ4AybWyJo6en5tz2ngr22HaK4MtxgrqnIN/KorY+nrzTNa7VBC7BaZc1tA5FLwUeCXtuzp2ibfrxoGUAiDig4FW09ijCk3Y77y7aNVI2nw5y28nCV5rgVMh5fejtNVqIqku7p+8qgjxvY6veATG0lYgZgw2ldnDGDNbEGxcCnKKmCgZMxok8zTRsniZ91KuHkcl2L7xUo7kdQYzBRwZyQ53eW+yPoqUya4yn272rscBEUMyZzmegfr1SXMqw/8zn+MZdr1KXEvrbfjX+2QL52GY3bfYUf3KFje+Sp88k688bRH0vrxj9BCOS7ovbyfe9BEU= xll@xmupc1
|
||||
1
local/pkgs/hpcstat/share/keys/xly
Normal file
1
local/pkgs/hpcstat/share/keys/xly
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCW2fx1Sim7X2i/e/RBPEl1q/XbV7wa9pmZfnRINHIv24MCUgtNZ5GHEEW7dvzrQBeRj3I7CAyK8fbuhv/l8HuDtjxJJ1fmcBp9UG5vfpb/UTxayJxHBRrwokp2JL7HKVviI6d8FcNa/T0CMoUNYXnel6dE3B78k9Q0dDxlOGS1MzgsP3Pn66lm0ww9FRAVHe+KkhFmwyQ1VHUxHgK4QjCIt7+9+PJE7fK0aVWBsR309pui7Pbm6mgd4d6mwiBeVvxsNGnI4DsO1hz4N2GapuQy19PDiG7A4H41Z5RYQnv/3XTy4TBXOFQm77v6pyGkCmG6BGnRdvMB6C0hWPJvudbsA/BNp4ApL7/CrwTdLp1z6ToAOLvKrUQAM+hcbJimnFVMXqz7iSYg99XTnzue7ncecp19XiaDJbM47bGXcT4nTO5XaiMYi2xGAHIrij5GIuFF5ymKYSp5ejb1VucMdKlaaAmS10+wdUcuT7tzX/IuVr5aqg2dsxT5aJCRhZ1k2V0= xly@xmuhpc
|
||||
1
local/pkgs/hpcstat/share/keys/yjq
Normal file
1
local/pkgs/hpcstat/share/keys/yjq
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCtnVhZQsJfbs2w9hFZkx4qDhIs++7no+6r5TifP3Dq7epJYd2QYx4dI66XxTNhKxZjN6a4Xn5nFlYLtQJXOvzBLC8IBf1W5GCH0k/jqzzskS0/Ix/70HzcBwJk8ihWDkyON5Ki1BRCx34RNxth1BIxWyc5QT+lou+D92x8iAu/uOvmcAL3Ua0OlZwxw03hLp/PpS4ZnUqFjc2JVtarY7eQu/i3RwOZUaK6nT2EL8RObzk4xnieqsU5PWwA3voVjetqZaDQ+P7dimQXz/FaucroKxCNyTiy1oG4fdQpm2UDrH6ZfPvdQLYrtet6FQabXOxhV7MuR3jYtxZjs1kDVZIseIZ6IwjetaUoMxvIouRfYjOSIEo9Ek9o0+Yhku4r0uWmPDrymWugU1raMmlRxSUwdlzW+C7mQwtGbs/MG4MN4GWkM6id5DKlY2vYKUfrTzmhY1swCtzKq20fjvyX8qhJdcytgVlOrBZnPje6Qd55sI0RjdgJrBsxT2SYquez7U8= yjq@xmupc1
|
||||
1
local/pkgs/hpcstat/share/keys/zem
Normal file
1
local/pkgs/hpcstat/share/keys/zem
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDn1pfGen7kjPTHsbb8AgrUJWOeFPHK5S4M97Lcj3tvdcjZi2SXN6PwHQfh8/xGhZbTLPz/40S9O9/Dn30xkUTfnONirKt790jp7VEbOtPnjQPOd/KRNWlS3VV0BELuq5p633Mi13rP6JZtdKmU2uSkvvaUBfCppy3JaWv/B7HLJ48f8IzkdiT1px3dN1eQ4SFoHOiVG0ci5TGG6wfMdoAAnM9R1aXI4gDxnYjLYujpaNZ4hBOta/6ZK/PV0JufoXdIAZjubgk1Hv04XHXLR2Z0UhRM6x7UrZIOdM/LlnKmcVk408ZKEj/9m1xRyDsNoZ24CF++cmnwfBHrp9I5nvDI7xOTdZlOhzkiiPM3f4i6s2Qjdv4vpZ6AeE3Qt1LVQyAr67b4UMjHuYqSi2KgyCO6My2Ov2eRoS74EKcb8ejJv3O+XInmYUgDgTgDFT3CgQgK2DG45HiV6nOkaE/6iKx2JSOiYZTFc7TRcePfXF9JQD7dXFde6qm3EbIVyJIpCJ8= zem@xmupc1
|
||||
12
local/pkgs/hpcstat/src/common.cpp
Normal file
12
local/pkgs/hpcstat/src/common.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
# include <hpcstat/common.hpp>
|
||||
# include <hpcstat/sql.hpp>
|
||||
# include <hpcstat/disk.hpp>
|
||||
|
||||
namespace hpcstat
|
||||
{
|
||||
long now()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::seconds>
|
||||
(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
}
|
||||
129
local/pkgs/hpcstat/src/disk.cpp
Normal file
129
local/pkgs/hpcstat/src/disk.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
# include <hpcstat/disk.hpp>
|
||||
# include <hpcstat/env.hpp>
|
||||
|
||||
namespace hpcstat::disk
|
||||
{
|
||||
// 需要统计的目录,是否统计子目录
|
||||
std::map<std::string, bool> Directories =
|
||||
{
|
||||
{ "caiduanjun", true },
|
||||
{ "Gaona", true },
|
||||
{ "huangkai", true },
|
||||
{ "huangshengli", false },
|
||||
{ "kangjunyong", true },
|
||||
{ "lijing", true },
|
||||
{ "linwei", true },
|
||||
{ "Lixu", true },
|
||||
{ "wanghao", false },
|
||||
{ "wuyaping", true },
|
||||
{ "wuzhiming", true },
|
||||
{ "zhanhuahan", false }
|
||||
};
|
||||
|
||||
bool stat()
|
||||
{
|
||||
if (auto homedir = env::env("HOME"); !homedir)
|
||||
{ std::cerr << "HOME not set\n"; return false; }
|
||||
else if (auto ducbindir = env::env("HPCSTAT_DUC_BINDIR"); !ducbindir)
|
||||
{ std::cerr << "HPCSTAT_DUC_BINDIR not set\n"; return false; }
|
||||
else if (auto datadir = env::env("HPCSTAT_DATADIR"); !datadir)
|
||||
{ std::cerr << "HPCSTAT_DATADIR not set\n"; return false; }
|
||||
else if
|
||||
(
|
||||
auto result = biu::exec<{.DirectStdout = true, .DirectStderr = true}>
|
||||
(
|
||||
// duc index -d ./duc.db -p ~
|
||||
"{}/duc"_f(*ducbindir),
|
||||
{ "index", "-d", "{}/duc.db"_f(*datadir), "-p", *homedir }
|
||||
);
|
||||
!result
|
||||
)
|
||||
{ std::cerr << "failed to index\n"; return false; }
|
||||
else return true;
|
||||
}
|
||||
|
||||
std::optional<Usage> get()
|
||||
{
|
||||
if (auto homedir = env::env("HOME"); !homedir)
|
||||
{ std::cerr << "HOME not set\n"; return {}; }
|
||||
else if (auto ducbindir = env::env("HPCSTAT_DUC_BINDIR"); !ducbindir)
|
||||
{ std::cerr << "HPCSTAT_DUC_BINDIR not set\n"; return {}; }
|
||||
else if (auto datadir = env::env("HPCSTAT_DATADIR"); !datadir)
|
||||
{ std::cerr << "HPCSTAT_DATADIR not set\n"; return {}; }
|
||||
else
|
||||
{
|
||||
auto get_size = [&](std::optional<std::string> path) -> std::optional<double>
|
||||
{
|
||||
if
|
||||
(
|
||||
auto result = biu::exec
|
||||
(
|
||||
// duc ls -d ./duc.db -b -D /data/gpfs01/jykang/linwei/xxx
|
||||
"{}/duc"_f(*ducbindir),
|
||||
{
|
||||
"ls", "-d", "{}/duc.db"_f(*datadir), "-b", "-D",
|
||||
"{}{}{}"_f(*homedir, path ? "/" : "", path.value_or(""))
|
||||
}
|
||||
);
|
||||
!result
|
||||
)
|
||||
{ std::cerr << "failed to ls {}\n"_f(path); return {}; }
|
||||
else
|
||||
{
|
||||
std::smatch match;
|
||||
if (!std::regex_search(result.Stdout, match, std::regex(R"((\d+))")))
|
||||
{ std::cerr << "failed to parse {}\n"_f(result.Stdout); return std::nullopt; }
|
||||
return std::stod(match[1]) / 1024 / 1024 / 1024;
|
||||
}
|
||||
};
|
||||
auto get_subdir = [&](std::string path) -> std::vector<std::string>
|
||||
{
|
||||
std::filesystem::directory_iterator it(*homedir + "/" + path);
|
||||
std::vector<std::string> result;
|
||||
for (const auto& entry : it)
|
||||
if (entry.is_directory()) result.push_back(entry.path().filename().string());
|
||||
return result;
|
||||
};
|
||||
auto get_date = [&]() -> std::optional<std::string>
|
||||
{
|
||||
if
|
||||
(
|
||||
// duc info -d ./duc.db
|
||||
auto result = biu::exec
|
||||
("{}/duc"_f(*ducbindir), { "info", "-d", "{}/duc.db"_f(*datadir) });
|
||||
!result
|
||||
)
|
||||
{ std::cerr << "failed to get duc info\n"; return {}; }
|
||||
else
|
||||
{
|
||||
std::smatch match;
|
||||
// search string like 2024-06-08 13:45:19
|
||||
if (!std::regex_search(result.Stdout, match, R"((\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}))"_re))
|
||||
{ std::cerr << "failed to parse {}\n"_f(result.Stdout); return {}; }
|
||||
return match[1];
|
||||
}
|
||||
};
|
||||
Usage usage;
|
||||
if (auto size = get_size({})) usage.Total = *size; else return {};
|
||||
if (auto date = get_date()) usage.Time = *date; else return {};
|
||||
for (const auto& [dir, recursive] : Directories)
|
||||
{
|
||||
if (!std::filesystem::exists(*homedir + "/" + dir))
|
||||
{ std::cerr << "{} does not exist\n"_f(*homedir + "/" + dir); continue; }
|
||||
if (auto size = get_size(dir)) usage.Teacher.push_back({ dir, *size });
|
||||
else return {};
|
||||
if (recursive) for (const auto& subdir : get_subdir(dir))
|
||||
{
|
||||
if (auto size = get_size(dir + "/" + subdir); size)
|
||||
usage.Student.push_back({ dir + "/" + subdir, *size });
|
||||
else return {};
|
||||
}
|
||||
}
|
||||
std::sort(usage.Teacher.begin(), usage.Teacher.end(),
|
||||
[](const auto& a, const auto& b) { return a.second > b.second; });
|
||||
std::sort(usage.Student.begin(), usage.Student.end(),
|
||||
[](const auto& a, const auto& b) { return a.second > b.second; });
|
||||
return usage;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
local/pkgs/hpcstat/src/env.cpp
Normal file
16
local/pkgs/hpcstat/src/env.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
# include <hpcstat/env.hpp>
|
||||
# include <unistd.h>
|
||||
|
||||
namespace hpcstat::env
|
||||
{
|
||||
bool interactive() { return isatty(fileno(stdin)); }
|
||||
std::optional<std::string> env(std::string name, bool required)
|
||||
{
|
||||
if (auto value = std::getenv(name.c_str()); !value)
|
||||
{
|
||||
if (required) std::cerr << "Failed to get environment variable {}\n"_f(name);
|
||||
return std::nullopt;
|
||||
}
|
||||
else return value;
|
||||
}
|
||||
}
|
||||
21
local/pkgs/hpcstat/src/keys.cpp
Normal file
21
local/pkgs/hpcstat/src/keys.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
# include <hpcstat/keys.hpp>
|
||||
|
||||
namespace hpcstat
|
||||
{
|
||||
std::map<std::string, Key> Keys
|
||||
{
|
||||
{ "LNoYfq/SM7l8sFAy325WpC+li+kZl3jwST7TmP72Tz8", { "chn", "Haonan Chen" } },
|
||||
{ "VJT5wgkb2RcIeVNTA+/NKxokctbYnJ/KgH6IxrKqIGE", { "gb", "Bin Gong" } },
|
||||
{ "umC3/RB1vS8TQBHsY3IzhOiyqVrOSw2fB3rIpDQSmf4", { "xll", "Leilei Xiang" } },
|
||||
{ "fdq5k13N2DAzIK/2a1Mm4/ZVsDUgT623TSOXsVswxT8", { "yjq", "Junqi Yao" } },
|
||||
{ "8USxEYi8ePPpLhk5FYBo2udT7/NFmEe8c2+oQajGXzA", { "zem", "Enming Zhang" } },
|
||||
{ "C52EURGhRHtf+odfmE2qofh7NO24MnGB3Q8GhRQhHiM", { "xly", "Linyang Xie" } },
|
||||
{ "7bmG24muNsaAZkCy7mQ9Nf2HuNafmvUO+Hf1bId9zts", { "00", "Yaping Wu" } },
|
||||
{ "dtx0QxdgFrXn2SYxtIRz43jIAH6rLgJidSdTvuTuews", { "01", "Jing Li" } },
|
||||
{ "8crUO9u4JiVqw3COyjXfzZe87s6XZFhvi0LaY0Mv6bg", { "02", "Huahan Zhan" } },
|
||||
{ "QkmIYw7rmDEAP+LDWxm6L2/XLnAqTwRUB7B0pxYlOUs", { "03", "Na Gao" } },
|
||||
{ "WfUP4s0BzEspDweDIrOIed4MbW4v9W1spbp0EN6O5dk", { "04", "Duanjun Cai" } },
|
||||
{ "VmVTvYnOOXOFcw+RH2AuUcj7hioieIJhwGOCDCfm0/w", { "05", "Xu Li" } },
|
||||
{ "6NmbGMvtcNlsmN61ZtiV1cg0aOGeM8sCa4rk2brsS4k", { "hpcstat", "hpcstat" } }
|
||||
};
|
||||
}
|
||||
86
local/pkgs/hpcstat/src/lfs.cpp
Normal file
86
local/pkgs/hpcstat/src/lfs.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
# include <hpcstat/lfs.hpp>
|
||||
# include <hpcstat/env.hpp>
|
||||
# include <nlohmann/json.hpp>
|
||||
|
||||
namespace hpcstat::lfs
|
||||
{
|
||||
std::optional<std::pair<unsigned, std::string>> bsub(std::vector<std::string> args)
|
||||
{
|
||||
if (auto bsub = env::env("HPCSTAT_BSUB", true); !bsub)
|
||||
return std::nullopt;
|
||||
else
|
||||
{
|
||||
std::set<std::string> valid_args = { "J", "q", "n", "R", "o", "e", "c" };
|
||||
for (auto it = args.begin(); it != args.end(); ++it)
|
||||
{
|
||||
if (it->length() > 0 && (*it)[0] == '-')
|
||||
{
|
||||
if (!valid_args.contains(it->substr(1)))
|
||||
{
|
||||
std::cerr << "Unknown bsub argument: {}\n"_f(*it)
|
||||
<< "bsub might support this argument, but hpcstat currently does not support it.\n"
|
||||
"If you are sure this argument is supported by bsub,\n"
|
||||
"please submit issue on [github](https://github.com/CHN-beta/hpcstat) or contact chn@chn.moe.\n";
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (it + 1 != args.end() && ((it + 1)->length() == 0 || (*(it + 1))[0] != '-')) ++it;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
if (auto result = biu::exec(*bsub, args); !result) return std::nullopt;
|
||||
else
|
||||
{
|
||||
// Job <462270> is submitted to queue <normal_1day>.
|
||||
std::regex re(R"r(Job <(\d+)> is submitted to queue <(\w+)>.)r");
|
||||
std::smatch match;
|
||||
if (std::regex_search(result.Stdout, match, re))
|
||||
return std::make_pair(std::stoi(match[1]), match[2]);
|
||||
else { std::cerr << "Failed to parse job id from output: {}\n"_f(result.Stdout); return std::nullopt; }
|
||||
}
|
||||
}
|
||||
}
|
||||
std::optional<std::map<unsigned, std::tuple<std::string, std::string, double, std::string>>> bjobs_list
|
||||
(bool finished_jobs_only)
|
||||
{
|
||||
if
|
||||
(
|
||||
auto result = biu::exec<{.SearchPath = true}>
|
||||
(
|
||||
"bjobs", { "-a", "-o", "jobid submit_time stat cpu_used job_name", "-json" },
|
||||
{}, { { "LSB_DISPLAY_YEAR", "Y" } }
|
||||
);
|
||||
!result
|
||||
)
|
||||
return std::nullopt;
|
||||
else
|
||||
{
|
||||
nlohmann::json j;
|
||||
try { j = nlohmann::json::parse(result.Stdout); }
|
||||
catch (nlohmann::json::parse_error& e)
|
||||
{ std::cerr << "Failed to parse bjobs output: {}\n"_f(e.what()); return std::nullopt; }
|
||||
std::map<unsigned, std::tuple<std::string, std::string, double, std::string>> jobs;
|
||||
for (auto& job : j["RECORDS"])
|
||||
{
|
||||
std::string status = job["STAT"];
|
||||
if (finished_jobs_only && !std::set<std::string>{ "DONE", "EXIT" }.contains(status)) continue;
|
||||
std::string cpu_used_str = job["CPU_USED"];
|
||||
double cpu_used = 0;
|
||||
if (!cpu_used_str.empty())
|
||||
{
|
||||
try { cpu_used = std::stof(cpu_used_str.substr(0, cpu_used_str.find(' '))); }
|
||||
catch (std::invalid_argument& e)
|
||||
{ std::cerr << "Failed to parse cpu used: {}\n"_f(e.what()); return std::nullopt; }
|
||||
}
|
||||
jobs[std::stoi(job["JOBID"].get<std::string>())] =
|
||||
{ job["SUBMIT_TIME"], status, cpu_used, job["JOB_NAME"] };
|
||||
}
|
||||
return jobs;
|
||||
}
|
||||
}
|
||||
std::optional<std::string> bjobs_detail(unsigned jobid)
|
||||
{
|
||||
if (auto result = biu::exec<{.SearchPath = true}>("bjobs", { "-l", "{}"_f(jobid) }); !result)
|
||||
return std::nullopt;
|
||||
else return result.Stdout;
|
||||
}
|
||||
}
|
||||
186
local/pkgs/hpcstat/src/main.cpp
Normal file
186
local/pkgs/hpcstat/src/main.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
# include <hpcstat/sql.hpp>
|
||||
# include <hpcstat/ssh.hpp>
|
||||
# include <hpcstat/env.hpp>
|
||||
# include <hpcstat/keys.hpp>
|
||||
# include <hpcstat/lfs.hpp>
|
||||
# include <hpcstat/push.hpp>
|
||||
# include <hpcstat/disk.hpp>
|
||||
# include <range/v3/view.hpp>
|
||||
# include <boost/exception/diagnostic_information.hpp>
|
||||
# include <boost/filesystem.hpp>
|
||||
# include <termcolor/termcolor.hpp>
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
using namespace hpcstat;
|
||||
using namespace std::literals;
|
||||
try
|
||||
{
|
||||
auto lockfile = (boost::filesystem::temp_directory_path() / "hpcstat.lock").string();
|
||||
std::ofstream{lockfile};
|
||||
boost::interprocess::file_lock lock(lockfile.c_str());
|
||||
|
||||
std::vector<std::string> args(argv, argv + argc);
|
||||
|
||||
if (args.size() == 1)
|
||||
{
|
||||
std::cout << "Usage: hpcstat initdb|login|logout|submitjob|finishjob|verify|export|version|diskstat\n";
|
||||
return 1;
|
||||
}
|
||||
else if (args[1] == "initdb")
|
||||
{
|
||||
lock.lock();
|
||||
if (!sql::initdb()) { std::cerr << "Failed to initialize database\n"; return 1; }
|
||||
}
|
||||
else if (args[1] == "login")
|
||||
{
|
||||
if (env::interactive()) std::cout << "Communicating with the agent..." << std::flush;
|
||||
if (env::env("CHN_DEBUG")) std::this_thread::sleep_for(1s);
|
||||
if (auto fp = ssh::fingerprint(); !fp) return 1;
|
||||
else if (auto session = env::env("XDG_SESSION_ID", true); !session)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
auto sub_account = env::env("HPCSTAT_SUBACCOUNT");
|
||||
sql::LoginData data
|
||||
{
|
||||
.Time = now(), .Key = *fp, .SessionId = *session, .Subaccount = env::env("HPCSTAT_SUBACCOUNT"),
|
||||
.Ip = env::env("SSH_CONNECTION"), .Interactive = env::interactive()
|
||||
};
|
||||
auto signature = ssh::sign(biu::serialize<char>(data), *fp);
|
||||
if (!signature) return 1;
|
||||
data.Signature = *signature;
|
||||
lock.lock();
|
||||
sql::writedb(data);
|
||||
if (env::interactive())
|
||||
{
|
||||
std::cout << "\33[2K\rLogged in as {} (Fingerprint: SHA256:{}{}).\n"_f
|
||||
(Keys[*fp].Username, *fp, sub_account ? " Subaccount {}"_f(*sub_account) : "");
|
||||
if (auto disk_stat = disk::get(); !disk_stat)
|
||||
std::cerr << "Failed to get disk usage statistic.\n";
|
||||
else
|
||||
{
|
||||
double percent = disk_stat->Total / 800 * 100;
|
||||
auto color = percent > 95 ? termcolor::red<char> :
|
||||
percent > 80 ? termcolor::yellow<char> : termcolor::green<char>;
|
||||
auto bgcolor = percent > 95 ? termcolor::on_red<char> :
|
||||
percent > 80 ? termcolor::on_yellow<char> : termcolor::on_green<char>;
|
||||
std::cout
|
||||
<< color << "disk usage: " << termcolor::reset
|
||||
<< bgcolor << termcolor::white
|
||||
<< "{:.1f}% ({:.1f}GB / ~800GB)"_f(percent, disk_stat->Total) << termcolor::reset
|
||||
<< color << " (estimated, counted at {})\n"_f(disk_stat->Time) << termcolor::reset;
|
||||
if (percent > 80)
|
||||
{
|
||||
std::cout << color << "Top 3 directories owned by teacher:\n";
|
||||
for (auto& [name, size] : disk_stat->Teacher | ranges::views::take(3))
|
||||
std::cout << " {:.1f}GB {}\n"_f(size, name);
|
||||
std::cout << color << "Top 3 directories owned by student:\n";
|
||||
for (auto& [name, size] : disk_stat->Student | ranges::views::take(3))
|
||||
std::cout << " {:.1f}GB {}\n"_f(size, name);
|
||||
std::cout << termcolor::reset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[1] == "logout")
|
||||
{
|
||||
if (auto session_id = env::env("XDG_SESSION_ID", true); !session_id)
|
||||
return 1;
|
||||
else { lock.lock(); sql::writedb(sql::LogoutData{ .Time = now(), .SessionId = *session_id }); }
|
||||
}
|
||||
else if (args[1] == "submitjob")
|
||||
{
|
||||
if (args.size() < 3) { std::cerr << "Usage: hpcstat submitjob <args passed to bsub>\n"; return 1; }
|
||||
if (auto fp = ssh::fingerprint(); !fp) return 1;
|
||||
else if (auto session = env::env("XDG_SESSION_ID", true); !session)
|
||||
return 1;
|
||||
else if
|
||||
(auto bsub = lfs::bsub(args | ranges::views::drop(2) | ranges::to<std::vector<std::string>>); !bsub)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
sql::SubmitJobData data
|
||||
{
|
||||
.Time = now(), .JobId = bsub->first, .Key = *fp, .SessionId = *session,
|
||||
.SubmitDir = std::filesystem::current_path().string(),
|
||||
.JobCommand = args | ranges::views::drop(2) | ranges::views::join(' ') | ranges::to<std::string>(),
|
||||
.Subaccount = env::env("HPCSTAT_SUBACCOUNT"), .Ip = env::env("SSH_CONNECTION")
|
||||
};
|
||||
auto signature = ssh::sign(biu::serialize<char>(data), *fp);
|
||||
if (!signature) return 1;
|
||||
data.Signature = *signature;
|
||||
lock.lock();
|
||||
sql::writedb(data);
|
||||
std::cout << "Job <{}> was submitted to <{}> by <{}>.\n"_f(bsub->first, bsub->second, Keys[*fp].Username);
|
||||
}
|
||||
}
|
||||
else if (args[1] == "finishjob")
|
||||
{
|
||||
lock.lock();
|
||||
if (auto fp = ssh::fingerprint(); !fp) return 1;
|
||||
else if (auto session = env::env("XDG_SESSION_ID", true); !session)
|
||||
return 1;
|
||||
else if (auto all_jobs = lfs::bjobs_list(true); !all_jobs) return 1;
|
||||
else if
|
||||
(
|
||||
auto not_recorded = sql::finishjob_remove_existed
|
||||
(
|
||||
*all_jobs
|
||||
| ranges::views::transform([](auto& it) { return std::pair{ it.first, std::get<0>(it.second) }; })
|
||||
| ranges::to<std::map<unsigned, std::string>>
|
||||
);
|
||||
!not_recorded
|
||||
)
|
||||
return 1;
|
||||
else for (auto jobid : *not_recorded)
|
||||
{
|
||||
if (auto detail = lfs::bjobs_detail(jobid); !detail) return 1;
|
||||
else
|
||||
{
|
||||
sql::FinishJobData data
|
||||
{
|
||||
.Time = now(), .JobId = jobid, .JobResult = std::get<1>(all_jobs->at(jobid)),
|
||||
.SubmitTime = std::get<0>(all_jobs->at(jobid)), .JobDetail = *detail, .Key = *fp,
|
||||
.CpuTime = std::get<2>(all_jobs->at(jobid)),
|
||||
};
|
||||
if (auto signature = ssh::sign(biu::serialize<char>(data), *fp); !signature) return 1;
|
||||
else { data.Signature = *signature; sql::writedb(data); }
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[1] == "verify")
|
||||
{
|
||||
if (args.size() < 4) { std::cerr << "Usage: hpcstat verify <old.db> <new.db>\n"; return 1; }
|
||||
if (auto db_verify_result = sql::verify(args[2], args[3]); !db_verify_result) return 1;
|
||||
else for (auto& data : *db_verify_result)
|
||||
if (!std::apply(ssh::verify, data))
|
||||
{ std::cerr << "Failed to verify data: {}\n"_f(std::get<0>(data)); return 1; }
|
||||
}
|
||||
else if (args[1] == "export")
|
||||
{
|
||||
if (args.size() < 4) { std::cerr << "Usage: hpcstat export <year> <month>\n"; return 1; }
|
||||
auto year_n = std::stoi(args[2]), month_n = std::stoi(args[3]);
|
||||
using namespace std::chrono;
|
||||
auto begin = sys_seconds(sys_days(month(month_n) / 1 / year_n)).time_since_epoch().count();
|
||||
auto end = sys_seconds(sys_days(month(month_n) / 1 / year_n + months(1)))
|
||||
.time_since_epoch().count();
|
||||
lock.lock();
|
||||
if (!sql::export_data(begin, end))
|
||||
return 1;
|
||||
}
|
||||
else if (args[1] == "push")
|
||||
{
|
||||
lock.lock();
|
||||
if (auto jobs = sql::check_job_status(); !jobs) return 1;
|
||||
else if (!push::push(*jobs)) return 1;
|
||||
}
|
||||
else if (args[1] == "version") { std::cout << HPCSTAT_VERSION << std::endl; }
|
||||
else if (args[1] == "diskstat")
|
||||
{ if (!disk::stat()) { std::cerr << "Failed to collect disk usage statistic.\n"; return 1; } }
|
||||
else { std::cerr << "Unknown command.\n"; return 1; }
|
||||
}
|
||||
catch (...) { std::cerr << boost::current_exception_diagnostic_information() << std::endl; return 1; }
|
||||
return 0;
|
||||
}
|
||||
75
local/pkgs/hpcstat/src/push.cpp
Normal file
75
local/pkgs/hpcstat/src/push.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
# include <hpcstat/push.hpp>
|
||||
# include <hpcstat/env.hpp>
|
||||
# include <nlohmann/json.hpp>
|
||||
# include <httplib.h>
|
||||
# include <boost/url.hpp>
|
||||
# include <nameof.hpp>
|
||||
# include <range/v3/view.hpp>
|
||||
|
||||
namespace hpcstat::push
|
||||
{
|
||||
// 任务 id,名称、现在的状态、提交时的 key、subaccount
|
||||
bool push(std::map<unsigned, std::tuple<std::string, std::string, std::string, std::optional<std::string>>> data)
|
||||
{
|
||||
// 读取配置
|
||||
if (auto datadir = env::env("HPCSTAT_DATADIR"); !datadir) return false;
|
||||
else if (std::ifstream config_file(std::filesystem::path(*datadir) / "push.json"); !config_file)
|
||||
{ std::cout << "Push failed: failed to open push.json\n"; return false; }
|
||||
else
|
||||
{
|
||||
auto config_string = std::string(std::istreambuf_iterator<char>(config_file), {});
|
||||
auto config = nlohmann::json::parse(config_string);
|
||||
auto token = config["token"].get<std::string>();
|
||||
auto users = config["users"].get<std::map<std::string, std::string>>();
|
||||
httplib::Client cli("http://wxpusher.zjiecode.com");
|
||||
for (const auto& [id, info] : data)
|
||||
{
|
||||
auto user_string = std::get<2>(info);
|
||||
if (std::get<3>(info))
|
||||
user_string += "::" + *std::get<3>(info);
|
||||
if (users.contains(user_string))
|
||||
{
|
||||
auto path = "/api/send/message/?appToken={}&content={}&uid={}"_f
|
||||
(
|
||||
token,
|
||||
boost::urls::encode
|
||||
(
|
||||
"{} {} {}"_f(std::get<1>(info), std::get<0>(info), id),
|
||||
boost::urls::unreserved_chars
|
||||
),
|
||||
users[user_string]
|
||||
);
|
||||
auto res = cli.Get(path.c_str());
|
||||
if (res.error() != httplib::Error::Success) { std::cout << "Push failed: {}\n"_f(res.error()); return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
// push to telegram for chn
|
||||
{
|
||||
auto messages = data
|
||||
| ranges::views::filter([](const auto& pair)
|
||||
{ return std::get<2>(pair.second) == "LNoYfq/SM7l8sFAy325WpC+li+kZl3jwST7TmP72Tz8"; })
|
||||
| ranges::views::transform([](const auto& pair)
|
||||
{ return "{} {} {}"_f(std::get<1>(pair.second), std::get<0>(pair.second), pair.first); })
|
||||
| ranges::views::chunk(20)
|
||||
| ranges::views::transform([](auto chunk) { return chunk | ranges::views::join('\n'); })
|
||||
| ranges::to<std::vector<std::string>>;
|
||||
if (!messages.empty())
|
||||
{
|
||||
httplib::Client cli("https://api.chn.moe");
|
||||
cli.enable_server_certificate_verification(false);
|
||||
for (auto& message : messages)
|
||||
{
|
||||
auto path = "/notify.php?message={}"_f
|
||||
(boost::urls::encode(message, boost::urls::unreserved_chars));
|
||||
auto res = cli.Get(path.c_str());
|
||||
if (res.error() != httplib::Error::Success)
|
||||
{ std::cout << "Push failed: {}\n"_f(res.error()); return false; }
|
||||
else if (res->status != 200)
|
||||
{ std::cout << "Push failed: status code {}\n"_f(res->status); return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
327
local/pkgs/hpcstat/src/sql.cpp
Normal file
327
local/pkgs/hpcstat/src/sql.cpp
Normal file
@@ -0,0 +1,327 @@
|
||||
# include <hpcstat/sql.hpp>
|
||||
# include <hpcstat/env.hpp>
|
||||
# include <hpcstat/keys.hpp>
|
||||
# include <hpcstat/lfs.hpp>
|
||||
# include <range/v3/range.hpp>
|
||||
# include <range/v3/view.hpp>
|
||||
# include <nameof.hpp>
|
||||
# define SQLITE_ORM_OPTIONAL_SUPPORTED
|
||||
# include <sqlite_orm/sqlite_orm.h>
|
||||
|
||||
namespace hpcstat::sql
|
||||
{
|
||||
auto connect(std::optional<std::string> dbfile = std::nullopt)
|
||||
{
|
||||
auto conn = [&]() { return std::make_optional(sqlite_orm::make_storage
|
||||
(
|
||||
*dbfile,
|
||||
sqlite_orm::make_table
|
||||
(
|
||||
"login",
|
||||
sqlite_orm::make_column("id", &LoginData::Id, sqlite_orm::primary_key().autoincrement()),
|
||||
sqlite_orm::make_column("time", &LoginData::Time),
|
||||
sqlite_orm::make_column("key", &LoginData::Key),
|
||||
sqlite_orm::make_column("session_id", &LoginData::SessionId),
|
||||
sqlite_orm::make_column("signature", &LoginData::Signature),
|
||||
sqlite_orm::make_column("sub_account", &LoginData::Subaccount),
|
||||
sqlite_orm::make_column("ip", &LoginData::Ip),
|
||||
sqlite_orm::make_column("interactive", &LoginData::Interactive)
|
||||
),
|
||||
sqlite_orm::make_table
|
||||
(
|
||||
"logout",
|
||||
sqlite_orm::make_column("id", &LogoutData::Id, sqlite_orm::primary_key().autoincrement()),
|
||||
sqlite_orm::make_column("time", &LogoutData::Time),
|
||||
sqlite_orm::make_column("session_id", &LogoutData::SessionId)
|
||||
),
|
||||
sqlite_orm::make_table
|
||||
(
|
||||
"submit_job",
|
||||
sqlite_orm::make_column("id", &SubmitJobData::Id, sqlite_orm::primary_key().autoincrement()),
|
||||
sqlite_orm::make_column("time", &SubmitJobData::Time),
|
||||
sqlite_orm::make_column("job_id", &SubmitJobData::JobId),
|
||||
sqlite_orm::make_column("key", &SubmitJobData::Key),
|
||||
sqlite_orm::make_column("session_id", &SubmitJobData::SessionId),
|
||||
sqlite_orm::make_column("submit_dir", &SubmitJobData::SubmitDir),
|
||||
sqlite_orm::make_column("job_command", &SubmitJobData::JobCommand),
|
||||
sqlite_orm::make_column("signature", &SubmitJobData::Signature),
|
||||
sqlite_orm::make_column("sub_account", &SubmitJobData::Subaccount),
|
||||
sqlite_orm::make_column("ip", &SubmitJobData::Ip)
|
||||
),
|
||||
sqlite_orm::make_table
|
||||
(
|
||||
"finish_job",
|
||||
sqlite_orm::make_column("id", &FinishJobData::Id, sqlite_orm::primary_key().autoincrement()),
|
||||
sqlite_orm::make_column("time", &FinishJobData::Time),
|
||||
sqlite_orm::make_column("job_id", &FinishJobData::JobId),
|
||||
sqlite_orm::make_column("job_result", &FinishJobData::JobResult),
|
||||
sqlite_orm::make_column("submit_time", &FinishJobData::SubmitTime),
|
||||
sqlite_orm::make_column("job_detail", &FinishJobData::JobDetail),
|
||||
sqlite_orm::make_column("key", &FinishJobData::Key),
|
||||
sqlite_orm::make_column("signature", &FinishJobData::Signature),
|
||||
sqlite_orm::make_column("cpu_time", &FinishJobData::CpuTime)
|
||||
),
|
||||
sqlite_orm::make_table
|
||||
(
|
||||
"check_job",
|
||||
sqlite_orm::make_column("id", &CheckJobData::Id, sqlite_orm::primary_key().autoincrement()),
|
||||
sqlite_orm::make_column("job_id", &CheckJobData::JobId),
|
||||
sqlite_orm::make_column("status", &CheckJobData::Status)
|
||||
)
|
||||
));};
|
||||
if (!dbfile)
|
||||
{
|
||||
if (auto datadir = env::env("HPCSTAT_DATADIR", true); !datadir)
|
||||
return decltype(conn())();
|
||||
else dbfile = std::filesystem::path(*datadir) / "hpcstat.db";
|
||||
}
|
||||
auto result = conn();
|
||||
if (!result) std::cerr << "Failed to connect to database.\n";
|
||||
else result->busy_timeout(10000);
|
||||
return result;
|
||||
}
|
||||
bool initdb()
|
||||
{
|
||||
if (auto conn = connect(); !conn) return false;
|
||||
else { conn->sync_schema(); return true; }
|
||||
}
|
||||
bool writedb(auto value)
|
||||
{ if (auto conn = connect(); !conn) return false; else { conn->insert(value); return true; } }
|
||||
template bool writedb(LoginData);
|
||||
template bool writedb(LogoutData);
|
||||
template bool writedb(SubmitJobData);
|
||||
template bool writedb(FinishJobData);
|
||||
std::optional<std::set<unsigned>> finishjob_remove_existed(std::map<unsigned, std::string> jobid_submit_time)
|
||||
{
|
||||
if (auto conn = connect(); !conn) return std::nullopt;
|
||||
else
|
||||
{
|
||||
auto all_job = jobid_submit_time | ranges::views::keys | ranges::to<std::vector<unsigned>>;
|
||||
auto logged_job = conn->get_all<FinishJobData>
|
||||
(sqlite_orm::where(sqlite_orm::in(&FinishJobData::JobId, all_job)));
|
||||
auto not_logged_job = all_job | ranges::to<std::set<unsigned>>;
|
||||
for (auto it : logged_job)
|
||||
if (jobid_submit_time[it.JobId] == it.SubmitTime)
|
||||
not_logged_job.erase(it.JobId);
|
||||
return not_logged_job;
|
||||
}
|
||||
}
|
||||
std::optional<std::vector<std::tuple<std::string, std::string, std::string>>>
|
||||
verify(std::string old_db, std::string new_db)
|
||||
{
|
||||
auto old_conn = connect(old_db), new_conn = connect(new_db);
|
||||
if (!old_conn || !new_conn) { std::cerr << "Failed to connect to database.\n"; return std::nullopt; }
|
||||
else
|
||||
{
|
||||
auto check_one = [&]<typename T>()
|
||||
-> std::optional<std::vector<std::tuple<std::string, std::string, std::string>>>
|
||||
{
|
||||
auto old_query = old_conn->get_all<T>(), new_query = new_conn->get_all<T>();
|
||||
auto old_data_it = old_query.begin(), new_data_it = new_query.begin();
|
||||
for (; old_data_it != old_query.end() && new_data_it != new_query.end(); ++old_data_it, ++new_data_it)
|
||||
if (*old_data_it != *new_data_it)
|
||||
{
|
||||
std::cerr << "Data mismatch: {} {} != {}.\n"_f(nameof::nameof_type<T>(), old_data_it->Id, new_data_it->Id);
|
||||
return {};
|
||||
}
|
||||
if (old_data_it != old_query.end() && new_data_it == new_query.end())
|
||||
{ std::cerr << "Data mismatch in {}.\n"_f(nameof::nameof_type<T>()); return {}; }
|
||||
else if constexpr (requires(T data) { data.Signature; })
|
||||
{
|
||||
std::vector<std::tuple<std::string, std::string, std::string>> diff;
|
||||
for (; old_data_it != old_query.end(); ++old_data_it)
|
||||
{
|
||||
auto data = *old_data_it;
|
||||
data.Signature = "";
|
||||
data.Id = 0;
|
||||
diff.push_back({ biu::serialize<char>(data), old_data_it->Signature, old_data_it->Key });
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
else return std::vector<std::tuple<std::string, std::string, std::string>>{};
|
||||
};
|
||||
auto check_many = [&]<typename T, typename... Ts>(auto&& self)
|
||||
-> std::optional<std::vector<std::tuple<std::string, std::string, std::string>>>
|
||||
{
|
||||
if (auto diff = check_one.operator()<T>(); !diff) return std::nullopt;
|
||||
else if constexpr (sizeof...(Ts) == 0) return diff;
|
||||
else if (auto diff2 = self.template operator()<Ts...>(self); !diff2) return std::nullopt;
|
||||
else { diff->insert(diff->end(), diff2->begin(), diff2->end()); return diff; }
|
||||
};
|
||||
return check_many.operator()<LoginData, LogoutData, SubmitJobData, FinishJobData>(check_many);
|
||||
}
|
||||
}
|
||||
// search corresponding job in submit table
|
||||
std::optional<SubmitJobData> search_job_in_submit(auto connection, unsigned job_id, std::string submit_time)
|
||||
{
|
||||
std::optional<SubmitJobData> result;
|
||||
long submit_date = [&]
|
||||
{
|
||||
std::chrono::system_clock::time_point submit_date_with_local;
|
||||
std::stringstream(submit_time) >> date::parse("%b %d %H:%M:%S %Y", submit_date_with_local);
|
||||
date::zoned_time submit_date_with_zone
|
||||
(
|
||||
date::current_zone(),
|
||||
date::local_seconds
|
||||
{
|
||||
std::chrono::seconds(std::chrono::duration_cast<std::chrono::seconds>
|
||||
(submit_date_with_local.time_since_epoch()).count())
|
||||
}
|
||||
);
|
||||
auto submit_date = submit_date_with_zone.get_sys_time();
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(submit_date.time_since_epoch()).count();
|
||||
}();
|
||||
auto submit_jobs = connection->template get_all<SubmitJobData>
|
||||
(sqlite_orm::where(sqlite_orm::is_equal(&SubmitJobData::JobId, job_id)));
|
||||
for (auto& job_submit : submit_jobs)
|
||||
if (auto diff = job_submit.Time - submit_date; std::abs(diff) < 3600)
|
||||
{
|
||||
result = job_submit;
|
||||
if (std::abs(diff) > 60) std::cerr << "large difference found: {} {}\n"_f(job_id, diff);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool export_data(long start_time, long end_time)
|
||||
{
|
||||
if (auto conn = connect(); !conn) return false;
|
||||
else
|
||||
{
|
||||
// 对于一个账户的总计
|
||||
struct StatAccount
|
||||
{
|
||||
double CpuTime = 0;
|
||||
unsigned LoginInteractive = 0, LoginNonInteractive = 0, FinishJobSuccess = 0, FinishJobFailed = 0;
|
||||
};
|
||||
// Key SubAccount -> StatAccount
|
||||
std::map<std::pair<std::string, std::string>, StatAccount> stat_subaccount;
|
||||
// Key -> StatAccount
|
||||
std::map<std::optional<std::string>, StatAccount> stat_account;
|
||||
// 每一个任务
|
||||
struct StatJob
|
||||
{
|
||||
unsigned JobId;
|
||||
std::optional<std::string> Key, SessionId, SubmitDir, JobCommand, Ip;
|
||||
std::string JobResult, SubmitTime;
|
||||
double CpuTime;
|
||||
};
|
||||
std::vector<StatJob> stat_job;
|
||||
// CpuTime & FinishJobSuccess & FinishJobFailed
|
||||
for
|
||||
(
|
||||
auto& it : conn->get_all<FinishJobData>(sqlite_orm::where
|
||||
(sqlite_orm::between(&FinishJobData::Time, start_time, end_time)))
|
||||
)
|
||||
{
|
||||
stat_job.push_back
|
||||
({ .JobId = it.JobId, .JobResult = it.JobResult, .SubmitTime = it.SubmitTime, .CpuTime = it.CpuTime });
|
||||
if (auto job_in_submit = search_job_in_submit
|
||||
(conn, it.JobId, it.SubmitTime))
|
||||
{
|
||||
{
|
||||
auto& _ = stat_job.back();
|
||||
_.Key = job_in_submit->Key;
|
||||
_.SessionId = job_in_submit->SessionId;
|
||||
_.SubmitDir = job_in_submit->SubmitDir;
|
||||
_.JobCommand = job_in_submit->JobCommand;
|
||||
_.Ip = job_in_submit->Ip;
|
||||
}
|
||||
stat_account[job_in_submit->Key].CpuTime += it.CpuTime / 3600;
|
||||
if (it.JobResult == "DONE") stat_account[job_in_submit->Key].FinishJobSuccess++;
|
||||
else stat_account[job_in_submit->Key].FinishJobFailed++;
|
||||
if (job_in_submit->Subaccount)
|
||||
{
|
||||
stat_subaccount[{job_in_submit->Key, *job_in_submit->Subaccount}].CpuTime += it.CpuTime / 3600;
|
||||
if (it.JobResult == "DONE")
|
||||
stat_subaccount[{job_in_submit->Key, *job_in_submit->Subaccount}].FinishJobSuccess++;
|
||||
else stat_subaccount[{job_in_submit->Key, *job_in_submit->Subaccount}].FinishJobFailed++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
stat_account[std::nullopt].CpuTime += it.CpuTime / 3600;
|
||||
if (it.JobResult == "DONE") stat_account[std::nullopt].FinishJobSuccess++;
|
||||
else stat_account[std::nullopt].FinishJobFailed++;
|
||||
}
|
||||
}
|
||||
// LoginInteractive & LoginNonInteractive
|
||||
for
|
||||
(
|
||||
auto& it : conn->get_all<LoginData>(sqlite_orm::where
|
||||
(sqlite_orm::between(&LoginData::Time, start_time, end_time)))
|
||||
)
|
||||
{
|
||||
if (Keys[it.Key].Username == "hpcstat") continue;
|
||||
if (it.Interactive) stat_account[it.Key].LoginInteractive++; else stat_account[it.Key].LoginNonInteractive++;
|
||||
if (it.Subaccount)
|
||||
{
|
||||
if (it.Interactive) stat_subaccount[{it.Key, *it.Subaccount}].LoginInteractive++;
|
||||
else stat_subaccount[{it.Key, *it.Subaccount}].LoginNonInteractive++;
|
||||
}
|
||||
}
|
||||
// export to markdown
|
||||
std::cout << "| 账号 | 使用核时 | 登陆次数(交互式) | 登陆次数(非交互式) | 成功任务数 | 失败任务数 | SSH密钥编号::指纹 |\n";
|
||||
std::cout << "| :--: | :--: | :--: | :--: | :--: | :--: | :--: |\n";
|
||||
std::vector<std::pair<std::optional<std::string>, StatAccount>> stat_account_vector
|
||||
(stat_account.begin(), stat_account.end());
|
||||
auto compare = [](auto& a, auto& b)
|
||||
{
|
||||
if (a.first)
|
||||
{ if (b.first) return Keys[*a.first].PubkeyFilename < Keys[*b.first].PubkeyFilename; else return true; }
|
||||
else return false;
|
||||
};
|
||||
std::sort(stat_account_vector.begin(), stat_account_vector.end(), compare);
|
||||
for (auto& [key, stat] : stat_account_vector)
|
||||
std::cout << "| {} | {:.2f} | {} | {} | {} | {} | `{}::{}` |\n"_f
|
||||
(
|
||||
key ? Keys[*key].Username : "(unknown)", stat.CpuTime, stat.LoginInteractive, stat.LoginNonInteractive,
|
||||
stat.FinishJobSuccess, stat.FinishJobFailed, key ? Keys[*key].PubkeyFilename : "", key
|
||||
);
|
||||
for (auto& [key_subaccount, stat] : stat_subaccount)
|
||||
std::cout << "| {}::{} | {:.2f} | {} | {} | {} | {} | `{}::{}` |\n"_f
|
||||
(
|
||||
Keys[key_subaccount.first].Username, key_subaccount.second, stat.CpuTime,
|
||||
stat.LoginInteractive, stat.LoginNonInteractive, stat.FinishJobSuccess, stat.FinishJobFailed,
|
||||
Keys[key_subaccount.first].PubkeyFilename, key_subaccount.first
|
||||
);
|
||||
std::cout << "\n";
|
||||
std::cout << "| 任务ID | 任务结果 | 提交时间 | 使用核时 | SSH指纹 | 会话ID | 提交目录 | 任务命令 | TCP连接 |\n";
|
||||
std::cout << "| :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: |\n";
|
||||
for (auto& it : stat_job)
|
||||
std::cout << "| {} | {} | {} | {:.2f} | `{}` | `{}` | `{}` | `{}` | `{}` |\n"_f
|
||||
(it.JobId, it.JobResult, it.SubmitTime, it.CpuTime, it.Key, it.SessionId, it.SubmitDir, it.JobCommand, it.Ip);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
std::optional<std::map<unsigned, std::tuple<std::string, std::string, std::string, std::optional<std::string>>>>
|
||||
check_job_status()
|
||||
{
|
||||
if (auto conn = connect(); !conn) return std::nullopt;
|
||||
else if (auto jobs_current = lfs::bjobs_list(); !jobs_current) return std::nullopt;
|
||||
else
|
||||
{
|
||||
auto jobs_previous_query_result = conn->get_all<CheckJobData>();
|
||||
auto jobs_previous = jobs_previous_query_result
|
||||
| ranges::views::transform([](auto& it) { return std::pair{it.JobId, it.Status}; })
|
||||
| ranges::to<std::map<unsigned, std::string>>;
|
||||
std::map<unsigned, std::tuple<std::string, std::string, std::string, std::optional<std::string>>> result;
|
||||
for (auto& [job_id, status] : *jobs_current)
|
||||
if (!jobs_previous.contains(job_id) || jobs_previous[job_id] != std::get<1>(status))
|
||||
if
|
||||
(
|
||||
auto job_in_submit =
|
||||
search_job_in_submit(conn, job_id, std::get<0>(status));
|
||||
job_in_submit
|
||||
)
|
||||
result[job_id] =
|
||||
{ std::get<3>(status), std::get<1>(status), job_in_submit->Key, job_in_submit->Subaccount };
|
||||
conn->remove_all<CheckJobData>();
|
||||
auto new_data = *jobs_current
|
||||
| ranges::views::transform
|
||||
([](auto& it) { return CheckJobData{ .JobId = it.first, .Status = std::get<1>(it.second) }; })
|
||||
| ranges::to<std::vector<CheckJobData>>;
|
||||
conn->insert_range(new_data.begin(), new_data.end());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
84
local/pkgs/hpcstat/src/ssh.cpp
Normal file
84
local/pkgs/hpcstat/src/ssh.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
# include <hpcstat/ssh.hpp>
|
||||
# include <hpcstat/keys.hpp>
|
||||
# include <hpcstat/env.hpp>
|
||||
# include <boost/filesystem.hpp>
|
||||
# include <boost/dll.hpp>
|
||||
|
||||
namespace hpcstat::ssh
|
||||
{
|
||||
std::optional<std::string> fingerprint()
|
||||
{
|
||||
if (auto sshbindir = env::env("HPCSTAT_SSH_BINDIR"); !sshbindir)
|
||||
return std::nullopt;
|
||||
else if
|
||||
(
|
||||
auto output = biu::exec(std::filesystem::path(*sshbindir) / "ssh-add", { "-l" });
|
||||
!output
|
||||
)
|
||||
{ std::cerr << "Failed to get ssh fingerprints\n"; return std::nullopt; }
|
||||
else
|
||||
{
|
||||
std::regex pattern(R"r(\b(?:sha|SHA)256:([0-9A-Za-z+/=]{43})\b)r");
|
||||
std::smatch match;
|
||||
for
|
||||
(
|
||||
auto i = std::sregex_iterator
|
||||
(output.Stdout.begin(), output.Stdout.end(), pattern);
|
||||
i != std::sregex_iterator();
|
||||
++i
|
||||
)
|
||||
if (Keys.contains(i->str(1))) return i->str(1);
|
||||
std::cerr << "No valid fingerprint found in:\n{}\n"_f(output.Stdout);
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
std::optional<std::string> sign(std::string message, std::string fingerprint)
|
||||
{
|
||||
if (auto sshbindir = env::env("HPCSTAT_SSH_BINDIR"); !sshbindir)
|
||||
return std::nullopt;
|
||||
else if (auto sharedir = env::env("HPCSTAT_SHAREDIR", true); !sharedir)
|
||||
return std::nullopt;
|
||||
else if
|
||||
(
|
||||
auto output = biu::exec
|
||||
(
|
||||
std::filesystem::path(*sshbindir) / "ssh-keygen",
|
||||
{
|
||||
"-Y", "sign", "-q", "-f", "{}/keys/{}"_f(*sharedir, Keys[fingerprint].PubkeyFilename),
|
||||
"-n", "hpcstat@chn.moe", "-"
|
||||
},
|
||||
message
|
||||
);
|
||||
!output
|
||||
)
|
||||
{ std::cerr << "Failed to sign message: {}\n"_f(message); return {}; }
|
||||
else return output.Stdout;
|
||||
}
|
||||
bool verify(std::string message, std::string signature, std::string fingerprint)
|
||||
{
|
||||
if (auto sshbindir = env::env("HPCSTAT_SSH_BINDIR"); !sshbindir)
|
||||
return false;
|
||||
else if (auto sharedir = env::env("HPCSTAT_SHAREDIR", true); !sharedir)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
namespace bf = boost::filesystem;
|
||||
auto tempdir = bf::temp_directory_path() / bf::unique_path();
|
||||
bf::create_directories(tempdir);
|
||||
auto signaturefile = tempdir / "signature";
|
||||
std::ofstream(signaturefile) << signature;
|
||||
auto result = biu::exec
|
||||
(
|
||||
std::filesystem::path(*sshbindir) / "ssh-keygen",
|
||||
{
|
||||
"-Y", "verify",
|
||||
"-f", "{}/keys/{}"_f(*sharedir, Keys[fingerprint].PubkeyFilename),
|
||||
"-n", "hpcstat@chn.moe", "-s", signaturefile.string()
|
||||
},
|
||||
message
|
||||
);
|
||||
std::filesystem::remove_all(tempdir.string());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
runHook preInstall
|
||||
mkdir -p $out/bin
|
||||
cp build/{ng01,beta} $out/bin
|
||||
ln -s ${src} $out/src
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user