mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-13 12:19:22 +08:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3895c35f5e | |||
| 1c4a3eea53 | |||
| d67b60ded3 | |||
| 2d7974e256 | |||
| 840f4a2c76 | |||
| e01eac40bd | |||
| 09f2c713a0 | |||
| fe6ebb5e27 | |||
| c75ec60995 | |||
| e87911fef0 | |||
| 7367cae759 | |||
| 6fc2c61ca1 | |||
| 57cdcaada2 | |||
| 651b1870af | |||
| e44d0f192a | |||
| 8180bb4792 | |||
| 5d7dcd28de | |||
| 5e9b1fd039 | |||
| 3350ee8680 | |||
| bb598f6fa4 | |||
| 66cf4fedf5 | |||
| dab7902309 | |||
| c5a3789e16 | |||
| 16983ecbfb | |||
| d2b5f8dda8 | |||
| 4e823d30b9 | |||
| e38a8c277d | |||
| 0e1aef2bf0 | |||
| 0058d1902d | |||
| 313fd7b9dc | |||
| c348e95af4 | |||
| 2a36d775ae | |||
| fc25522bd0 | |||
| 295c8c957c | |||
| e655e97a78 | |||
| 34c90841d0 | |||
| 822c3ef607 | |||
| 910f4d64c1 | |||
| c6609aacfa | |||
| a4126c2a22 | |||
| a90a841563 | |||
| fdbf027236 | |||
| 38dd23b9ef | |||
| 27334e1620 | |||
| c1a114fee6 | |||
| 7bd3eeb3b0 | |||
| b12d519fd5 | |||
| 5bc06f6c00 | |||
| bce6b96f8a | |||
| 5ba427851e | |||
| dcaaf5fa4f | |||
| ed79903647 | |||
| 6002e7f6df | |||
| 4dffbaf2d4 | |||
| 38df611978 | |||
| 67217e164b | |||
| 4fa6352e27 | |||
| f32914efa7 | |||
| f94c5fe631 | |||
| 310bd3b2b7 | |||
| 62c798d73f | |||
| 6c0b4d5caa | |||
| 41fbbf3d52 | |||
| 63d5f339ea | |||
| 0470c1041c | |||
| 655e683b02 | |||
| 295153fa64 | |||
| 45a1c4520b | |||
| 7a152011f0 | |||
| 0d75fc01d4 | |||
| 89b04882c1 | |||
| 5dd03880c1 | |||
| aa026f332e | |||
| 2ef7d23a4e | |||
| d75e195136 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ outputs
|
||||
build
|
||||
.vscode
|
||||
.cache
|
||||
.ccls-cache
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
keys: # cat /etc/ssh/ssh_host_ed25519_key.pub | ssh-to-age
|
||||
- &chn age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
|
||||
- &pc age1ffvr5pqd2lfj24e3fh53s92z6h76fda3du4y4k6r3yjumdwvpfgqzj033a
|
||||
- &vps4 age1nnd6u8l20julg4jz4l6kw5gmj6h2tsngpm7n8dx59umgw2s66y4shq6jv4
|
||||
- &vps4 age1yvrl4y0r6yzcxzzkgfwshlrtsjt8uuya6rfwks09pnft7esfcyvqmrtm5q
|
||||
- &vps6 age164tyqklwhdm57tfm5u863mdt2xrzrrzac4py8a0j9y6kzqcjy9zsp073t6
|
||||
- &vps7 age137x7csalutwvfygvvzpemlsywvdxj3j4z93a50z2sjx03w6zau8q3r5902
|
||||
- &surface age1ck5vzs0xqx0jplmuksrkh45xwmkm2t05m2wyq5k2w2mnkmn79fxs6tvl3l
|
||||
|
||||
4
blog/.gitignore
vendored
Normal file
4
blog/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/themes
|
||||
/public
|
||||
/.hugo_build.lock
|
||||
/resources/_gen
|
||||
5
blog/archetypes/default.md
Normal file
5
blog/archetypes/default.md
Normal file
@@ -0,0 +1,5 @@
|
||||
+++
|
||||
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
|
||||
date = {{ .Date }}
|
||||
draft = true
|
||||
+++
|
||||
19
blog/content/_index.md
Normal file
19
blog/content/_index.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
type: docs
|
||||
---
|
||||
|
||||
嗨,我的朋友,欢迎你!我想我会喜欢你的(如果我们之前没有仇的话)。
|
||||
|
||||
左侧是这个网站的目录,你可以看到这个网站上有哪些文章。
|
||||
点进某一篇文章后,右侧会出现当前文章的目录。
|
||||
上方还有搜索框和一些外部网站的链接。
|
||||
|
||||
本站的主要内容被分为“文档”和“博客”两个部分。
|
||||
文档部分是一些比较系统化的内容,比如某些教程,
|
||||
会随着时间的推移而更新,并会翻译成英语(如果我觉得有必要的话)。
|
||||
博客部分是一些随手写的东西,大概写好之后就再也不会更新,其中的技术性内容也不保证完全正确,
|
||||
往往充满了我自己的主观猜测。
|
||||
|
||||
{{< callout emoji="🏗️" >}}
|
||||
早期施工中,请戴好安全帽小心前行,谨防突然出现的 404。
|
||||
{{< /callout >}}
|
||||
19
blog/content/about.md
Normal file
19
blog/content/about.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: 关于本站
|
||||
---
|
||||
|
||||
嗨,我的朋友,欢迎你!我想我会喜欢你的(如果我们之前没有仇的话)。
|
||||
|
||||
左侧是这个网站的目录,你可以看到这个网站上有哪些文章。
|
||||
点进某一篇文章后,右侧会出现当前文章的目录。
|
||||
上方还有搜索框和一些外部网站的链接。
|
||||
|
||||
本站的主要内容被分为“文档”和“博客”两个部分。
|
||||
文档部分是一些比较系统化的内容,比如某些教程,
|
||||
会随着时间的推移而更新,并会翻译成英语(如果我觉得有必要的话)。
|
||||
博客部分是一些随手写的东西,大概写好之后就再也不会更新,其中的技术性内容也不保证完全正确,
|
||||
往往充满了我自己的主观猜测。
|
||||
|
||||
{{< callout emoji="🏗️" >}}
|
||||
早期施工中,请戴好安全帽小心前行,谨防突然出现的 404。
|
||||
{{< /callout >}}
|
||||
7
blog/content/docs/example/_index.md
Normal file
7
blog/content/docs/example/_index.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
weight: 1
|
||||
bookFlatSection: true
|
||||
title: "Example Site"
|
||||
---
|
||||
|
||||
{{< callout emoji="🏗️" >}} 施工中 {{< /callout >}}
|
||||
5
blog/content/posts/_index.md
Normal file
5
blog/content/posts/_index.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: Blog
|
||||
---
|
||||
|
||||
我得在这里写点什么
|
||||
49
blog/content/posts/helloworld.md
Normal file
49
blog/content/posts/helloworld.md
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: Helloworld
|
||||
date: 2024-08-24T20:13:59+08:00
|
||||
draft: false
|
||||
summary: 为什么不问问神奇海螺呢?
|
||||
math: true
|
||||
---
|
||||
|
||||
# 一级标题
|
||||
|
||||
## 二级标题
|
||||
|
||||
### 三级标题
|
||||
|
||||
hello world!
|
||||
|
||||
* 无序列表1
|
||||
* 无序列表2
|
||||
* 无序列表3
|
||||
|
||||
1. 有序列表1
|
||||
2. 有序列表2
|
||||
3. 有序列表3
|
||||
|
||||
> 这是一个引用
|
||||
> 写了两行
|
||||
|
||||
如果段与段之间
|
||||
没有空行
|
||||
会怎样?
|
||||
|
||||
```c++
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main() {
|
||||
cout << "Hello, World!" << endl;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
这是一个行内代码`printf("Hello, World!\n");`,和行内公式 $E=mc^2$。
|
||||
|
||||
$$
|
||||
\int_{-\infty}^{+\infty} e^{-x^2} \dd x = \sqrt{\pi}
|
||||
$$
|
||||
|
||||
**这是粗体文本**,*这是斜体文本*。
|
||||
|
||||
[这是一个链接](https://www.example.com)
|
||||
6
blog/data/icons.yaml
Normal file
6
blog/data/icons.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
misskey: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 1 24 22"><path fill="currentColor" d="M8.91 16.892c-1.039.003-1.931-.63-2.352-1.366c-.225-.322-.67-.437-.676 0v2.014q0 1.215-.876 2.1q-.85.86-2.078.86q-1.2 0-2.077-.86A2.93 2.93 0 0 1 0 17.54V6.46q0-.936.526-1.695a2.86 2.86 0 0 1 1.402-1.088a2.9 2.9 0 0 1 1-.177q1.353 0 2.253 1.063l2.997 3.515c.067.05.263.437.732.437c.47 0 .692-.386.758-.437l2.972-3.515Q13.567 3.5 14.918 3.5q.501 0 1.001.177a2.73 2.73 0 0 1 1.377 1.088q.55.758.55 1.695v11.08q0 1.215-.875 2.1q-.852.86-2.078.86q-1.201 0-2.078-.86a2.93 2.93 0 0 1-.85-2.1v-2.014c-.05-.55-.531-.204-.702 0c-.45.843-1.313 1.361-2.352 1.366M21.448 8.61q-1.05 0-1.802-.733q-.726-.759-.726-1.822c0-1.063.242-1.307.726-1.796a2.44 2.44 0 0 1 1.802-.758q1.05 0 1.803.758q.75.735.75 1.796q0 1.063-.75 1.822q-.751.732-1.803.733m.025.507q1.05 0 1.777.758q.75.759.751 1.822v6.248q0 1.064-.75 1.821a2.4 2.4 0 0 1-1.778.734q-1.05 0-1.802-.733a2.5 2.5 0 0 1-.75-1.822v-6.248a2.5 2.5 0 0 1 .75-1.822a2.44 2.44 0 0 1 1.802-.758"/></svg>
|
||||
fediverse: <svg xmlns="http://www.w3.org/2000/svg" viewBox="20 20 216 216"><g fill="none"><path fill="#a730b8" d="M61.39 100.77a22.47 22.47 0 0 1-9.605 9.569l52.727 52.981l12.712-6.448zm69.548 69.882l-12.712 6.448l26.717 26.846a22.47 22.47 0 0 1 9.606-9.57z"/><path fill="#5496be" d="m191.943 121.734l-29.851 15.142l2.201 14.091l33.775-17.133a22.5 22.5 0 0 1-6.125-12.1m-47.18 23.932l-70.579 35.802a22.5 22.5 0 0 1 6.127 12.101l66.653-33.812z"/><path fill="#ce3d1a" d="m122.066 57.476l-34.057 66.548l10.055 10.103l36.059-70.459a22.45 22.45 0 0 1-12.057-6.192m-42.915 83.856l-17.25 33.708c4.56.772 8.77 2.934 12.056 6.192l15.249-29.797z"/><path fill="#d0188f" d="M51.492 110.487a22.44 22.44 0 0 1-11.218 2.347a23 23 0 0 1-2.168-.226l10.073 64.489a22.44 22.44 0 0 1 11.218-2.347q1.09.06 2.167.227z"/><path fill="#5b36e9" d="M80.364 193.888c.23 1.498.31 3.014.235 4.528a22.5 22.5 0 0 1-2.369 8.867l64.42 10.347a22.5 22.5 0 0 1-.236-4.528a22.5 22.5 0 0 1 2.37-8.867z"/><path fill="#30b873" d="m198.294 134.069l-29.733 58.102a22.45 22.45 0 0 1 12.058 6.193l29.734-58.101a22.45 22.45 0 0 1-12.059-6.194"/><path fill="#ebe305" d="M157.741 51.894a22.47 22.47 0 0 1-9.606 9.57l46.047 46.267a22.47 22.47 0 0 1 9.606-9.57z"/><path fill="#f47601" d="m115.713 45.14l-58.21 29.527a22.5 22.5 0 0 1 6.127 12.1l58.208-29.528a22.5 22.5 0 0 1-6.125-12.098"/><path fill="#57c115" d="M148.029 61.518a22.44 22.44 0 0 1-11.403 2.44a22 22 0 0 1-1.966-.206l5.157 33.048l14.069 2.26zm-5.216 54.494l12.191 78.134a22.45 22.45 0 0 1 11.055-2.265a23 23 0 0 1 2.349.258l-11.525-73.868z"/><path fill="#dbb210" d="M63.671 87.014a22.5 22.5 0 0 1 .247 4.6a22.5 22.5 0 0 1-2.334 8.803l33.043 5.312l6.494-12.695zm56.632 9.103l-6.495 12.696l78.072 12.55c-.224-1.481-.3-2.98-.226-4.476a22.5 22.5 0 0 1 2.395-8.915z"/><path fill="#ffca00" fill-opacity="0.996" d="M136.737 61.918c11.258.614 20.881-8.023 21.495-19.292c.613-11.268-8.016-20.9-19.275-21.515c-11.258-.613-20.881 8.024-21.495 19.292c-.613 11.269 8.017 20.901 19.275 21.515"/><path fill="#64ff00" fill-opacity="0.996" d="M212.966 138.513c11.259.614 20.882-8.023 21.495-19.292c.614-11.268-8.016-20.9-19.274-21.514s-20.882 8.023-21.495 19.292c-.613 11.268 8.016 20.901 19.274 21.514"/><path fill="#00a3ff" fill-opacity="0.996" d="M163.727 234.728c11.258.614 20.882-8.024 21.495-19.292s-8.016-20.901-19.274-21.515s-20.882 8.024-21.495 19.292c-.614 11.269 8.016 20.901 19.274 21.515"/><path fill="#9500ff" fill-opacity="0.996" d="M57.066 217.597c11.258.613 20.881-8.024 21.495-19.292c.613-11.269-8.017-20.901-19.275-21.515s-20.882 8.023-21.495 19.292c-.613 11.268 8.016 20.901 19.275 21.515"/><path fill="#f00" fill-opacity="0.996" d="M40.385 110.794c11.258.614 20.881-8.023 21.495-19.292c.613-11.268-8.017-20.9-19.275-21.514S21.724 78.01 21.11 89.28c-.613 11.268 8.017 20.901 19.275 21.514"/></g></svg>
|
||||
matrix: <svg xmlns="http://www.w3.org/2000/svg" viewBox="30 20 196 216"><path fill="currentColor" d="M72 216a8 8 0 0 1-8 8H40a8 8 0 0 1-8-8V40a8 8 0 0 1 8-8h24a8 8 0 0 1 0 16H48v160h16a8 8 0 0 1 8 8M216 32h-24a8 8 0 0 0 0 16h16v160h-16a8 8 0 0 0 0 16h24a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8m-32 88a32 32 0 0 0-56-21.13a31.93 31.93 0 0 0-40.71-6.15A8 8 0 0 0 72 96v64a8 8 0 0 0 16 0v-40a16 16 0 0 1 32 0v40a8 8 0 0 0 16 0v-40a16 16 0 0 1 32 0v40a8 8 0 0 0 16 0Z"/></svg>
|
||||
wechat: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M15.85 8.14c.39 0 .77.03 1.14.08C16.31 5.25 13.19 3 9.44 3c-4.25 0-7.7 2.88-7.7 6.43c0 2.05 1.15 3.86 2.94 5.04L3.67 16.5l2.76-1.19c.59.21 1.21.38 1.87.47c-.09-.39-.14-.79-.14-1.21c-.01-3.54 3.44-6.43 7.69-6.43M12 5.89a.96.96 0 1 1 0 1.92a.96.96 0 0 1 0-1.92M6.87 7.82a.96.96 0 1 1 0-1.92a.96.96 0 0 1 0 1.92"/><path fill="currentColor" d="M22.26 14.57c0-2.84-2.87-5.14-6.41-5.14s-6.41 2.3-6.41 5.14s2.87 5.14 6.41 5.14c.58 0 1.14-.08 1.67-.2L20.98 21l-1.2-2.4c1.5-.94 2.48-2.38 2.48-4.03m-8.34-.32a.96.96 0 1 1 .96-.96c.01.53-.43.96-.96.96m3.85 0a.96.96 0 1 1 0-1.92a.96.96 0 0 1 0 1.92"/></svg>
|
||||
qq: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"/><path fill="currentColor" d="M12 2a6.285 6.285 0 0 0-6.276 5.937l-.146 2.63a28 28 0 0 0-.615 1.41c-1.24 3.073-1.728 5.773-1.088 6.032c.335.135.913-.426 1.566-1.432a6.67 6.67 0 0 0 1.968 3.593c-1.027.35-1.91.828-1.91 1.33c0 .509 2.48.503 4.239.5h.001c.549-.002 1.01-.008 1.38-.057a6.7 6.7 0 0 0 1.76 0c.37.05.833.055 1.382.056c1.76.004 4.239.01 4.239-.499c0-.502-.883-.979-1.909-1.33a6.67 6.67 0 0 0 1.967-3.586c.65 1.002 1.227 1.56 1.56 1.425c.64-.259.154-2.96-1.088-6.032a28 28 0 0 0-.607-1.395l-.147-2.645A6.285 6.285 0 0 0 12 2"/></g></svg>
|
||||
gitea: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M15.46 3.206s.14-.003.245.102l.01.01c.064.06.258.244.285 1.074c0 2.902-1.405 5.882-1.405 5.882a9 9 0 0 1-.359.713c-.458.802-.786 1.153-.786 1.153s-.318.379-.675.595c-.415.265-.72.263-.72.263L7.247 13c-.636-.079-1.29-.736-1.927-1.578c-.47-.677-.779-1.413-.779-1.413s-2.51.034-3.675-1.394C.235 7.895.103 7.067.06 6.769q0-.012-.004-.029c-.05-.324-.285-1.873.821-2.86c.517-.496 1.148-.638 1.37-.684c.371-.081.667-.06.903-.044l.09.006c.391.035 3.99.216 3.99.216s1.532.066 2.27.056c0 0 .003 1.853.003 2.78q.105.048.211.1l.212.1V3.427q.494-.005.996-.017h.011c1.545-.036 4.528-.204 4.528-.204ZM2.113 8.026s.28.26.94.477c.43.152 1.094.231 1.094.231S3.699 7.5 3.516 6.757c-.22-.886-.4-2.398-.4-2.398s-.438-.015-.789.079c-.766.19-.98.763-.98.763s-.384.688.036 1.813c.244.672.73 1.013.73 1.013Zm8.084 3.607c.344-.023.499-.392.499-.392s1.24-2.486 1.4-2.878a.7.7 0 0 0 .046-.438c-.07-.267-.39-.412-.39-.412l-1.926-.935l-.165.339l-.18.369a.46.46 0 0 1 .128.341s.433.186.743.387c0 0 .257.135.32.425c.075.273-.04.488-.066.539l-.002.003s-.216.51-.343.774l-.004.007q-.07.144-.139.28a.454.454 0 1 1-.32-.15s.41-.84.468-1.033c0 0 .096-.24.048-.38a.47.47 0 0 0-.19-.188a6 6 0 0 0-.678-.34s-.076.068-.18.09a.5.5 0 0 1-.158.014l-.611 1.25a.46.46 0 0 1 .046.587a.46.46 0 0 1-.578.138a.46.46 0 0 1-.232-.51a.46.46 0 0 1 .44-.35L8.8 7.886a.457.457 0 0 1 .361-.744l.185-.375l.167-.341l-.579-.281s-.251-.125-.458-.072a.6.6 0 0 0-.114.039c-.189.084-.31.33-.31.33L6.668 9.293s-.124.254-.068.46c.048.252.325.397.325.397l2.874 1.4l.135.054s.114.04.262.03Z" clip-rule="evenodd"/></svg>
|
||||
13
blog/default.nix
Normal file
13
blog/default.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{ stdenv, hextra, hugo }: stdenv.mkDerivation
|
||||
{
|
||||
name = "blog";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [ hugo ];
|
||||
configurePhase =
|
||||
''
|
||||
mkdir themes
|
||||
ln -s ${hextra} themes/hextra
|
||||
'';
|
||||
buildPhase = "hugo";
|
||||
installPhase = "cp -r public $out";
|
||||
}
|
||||
132
blog/hugo.yaml
Normal file
132
blog/hugo.yaml
Normal file
@@ -0,0 +1,132 @@
|
||||
baseURL: https://blog.chn.moe/
|
||||
theme: hextra
|
||||
|
||||
enableRobotsTXT: true
|
||||
enableGitInfo: false
|
||||
enableEmoji: true
|
||||
hasCJKLanguage: true
|
||||
|
||||
# services:
|
||||
# googleAnalytics:
|
||||
# ID: G-MEASUREMENT_ID
|
||||
|
||||
outputs:
|
||||
home: [ html ]
|
||||
page: [ html ]
|
||||
section: [ html, rss ]
|
||||
|
||||
defaultContentLanguage: zh-cn
|
||||
languages:
|
||||
zh-cn:
|
||||
languageName: 简体中文
|
||||
languageCode: zh-CN
|
||||
weight: 1
|
||||
title: My New Hugo Site
|
||||
en:
|
||||
languageName: English
|
||||
weight: 2
|
||||
title: My New Hugo Site
|
||||
contentDir: content/en
|
||||
|
||||
# Needed for mermaid/katex shortcodes
|
||||
markup:
|
||||
goldmark:
|
||||
renderer:
|
||||
unsafe: true
|
||||
highlight:
|
||||
noClasses: false
|
||||
|
||||
enableInlineShortcodes: true
|
||||
|
||||
menu:
|
||||
main:
|
||||
- name: Search
|
||||
weight: 1
|
||||
params:
|
||||
type: search
|
||||
|
||||
sidebar:
|
||||
- identifier: more
|
||||
name: More
|
||||
params:
|
||||
type: separator
|
||||
weight: 1
|
||||
- identifier: welcome
|
||||
name: 欢迎页
|
||||
pageRef: /
|
||||
weight: 2
|
||||
- identifier: about
|
||||
name: 关于本站
|
||||
pageRef: /about
|
||||
weight: 3
|
||||
- identifier: contact
|
||||
name: 联系我
|
||||
pageRef: /contact
|
||||
weight: 4
|
||||
|
||||
params:
|
||||
description: Modern, responsive, batteries-included Hugo theme for creating beautiful static websites.
|
||||
navbar:
|
||||
displayTitle: true
|
||||
displayLogo: true
|
||||
logo:
|
||||
path: images/logo.svg
|
||||
dark: images/logo-dark.svg
|
||||
# width: 40
|
||||
# height: 20
|
||||
# link: /
|
||||
width: wide
|
||||
page:
|
||||
# full (100%), wide (90rem), normal (1280px)
|
||||
width: normal
|
||||
theme:
|
||||
# light | dark | system
|
||||
default: system
|
||||
displayToggle: true
|
||||
footer:
|
||||
enable: true
|
||||
displayCopyright: true
|
||||
displayPoweredBy: true
|
||||
width: normal
|
||||
displayUpdatedDate: true
|
||||
dateFormat: "January 2, 2006"
|
||||
search:
|
||||
enable: true
|
||||
type: flexsearch
|
||||
flexsearch:
|
||||
# index page by: content | summary | heading | title
|
||||
index: content
|
||||
# full | forward | reverse | strict
|
||||
# https://github.com/nextapps-de/flexsearch/#tokenizer-prefix-search
|
||||
tokenize: forward
|
||||
editURL:
|
||||
enable: true
|
||||
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
|
||||
blog:
|
||||
list:
|
||||
displayTags: true
|
||||
# date | lastmod | publishDate | title | weight
|
||||
sortBy: date
|
||||
sortOrder: desc # or "asc"
|
||||
highlight:
|
||||
copy:
|
||||
enable: true
|
||||
# hover | always
|
||||
display: hover
|
||||
comments:
|
||||
# TODO: enable cusdis
|
||||
enable: false
|
||||
type: giscus
|
||||
# https://giscus.app/
|
||||
giscus:
|
||||
repo: imfing/hextra
|
||||
repoId: R_kgDOJ9fJag
|
||||
category: General
|
||||
categoryId: DIC_kwDOJ9fJas4CY7gW
|
||||
# mapping: pathname
|
||||
# strict: 0
|
||||
# reactionsEnabled: 1
|
||||
# emitMetadata: 0
|
||||
# inputPosition: top
|
||||
# lang: en
|
||||
math: true
|
||||
@@ -4,6 +4,8 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDJ/jzUQ6QuAjnAryvpWk7TReS6pnHxhEXY9RonojKk
|
||||
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-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMRpyIU8ZuYTa0LvsVHmJZ1FA7Lbp4PObjkwo+UcpCP8 wp@xmupc1
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGRZp8xp9hVO7e/6eflQsnFZj853IRVywc97cTevnWbg hjp@xmupc1
|
||||
|
||||
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
|
||||
|
||||
@@ -183,11 +183,6 @@ inputs:
|
||||
};
|
||||
system.nixos.tags = [ "nvidia" ];
|
||||
};
|
||||
zen.configuration =
|
||||
{
|
||||
nixos.system.kernel = { variant = inputs.lib.mkForce "zen"; patches = inputs.lib.mkForce []; };
|
||||
system.nixos.tags = [ "zen" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ 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]
|
||||
age: ENC[AES256_GCM,data:EPjip4/tz50e+blPko9NpzDamLRO6BVy64kDnGAhUJJ/bMw6V9Of8RzuiqUupIjEmFiUcgWf9ZsV5RZO3Ai9udq0W7mYS1Y/zn4=,iv:TBs/o6mp8t+S3Ma5/QhnLhzgl852HB3sEzKy9SvKJjU=,tag:2yMUVWPua2g0VOkaXpJzKQ==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -46,8 +47,8 @@ sops:
|
||||
OUlxNjdQaXdXMkZ6bnV1ek4yZ2dpbkEKpKGOAxo5Eef2jtGrg4iSzmGCeg+vTgvu
|
||||
+K8b+O19MIkGMDBm6UbYUPtc/7eqoEZRiTUzNMTmfkLVS4ul5zou9A==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
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]
|
||||
lastmodified: "2024-09-01T15:21:26Z"
|
||||
mac: ENC[AES256_GCM,data:eigkz85LgrpqqKTw5obgc14e9jtnmZJnjkD1iTOdXkluaqQyHC8qO2mgOfzKTM3dqusDA/hij+DR8nQbFzsBCFtvVdwb9chCqZLGo/fiJKvN8xt7Ccev8K5gS9nDnVmA7aUDgu1YWjZd3f/JpILlp2rsc5cozfcEAJoGFoSeWh0=,iv:FdzSdD6K8/6X39KcpcX+FEjkoiDWp7K4LWIN2ZdqXGM=,tag:vN1VD238pLcFm4s8KJsakA==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
version: 3.9.0
|
||||
|
||||
@@ -27,8 +27,7 @@ inputs:
|
||||
nix = { substituters = [ "https://cache.nixos.org/" "https://nix-store.chn.moe" ]; githubToken.enable = true; };
|
||||
kernel = { variant = "xanmod-lts"; patches = [ "surface" "hibernate-progress" ]; };
|
||||
networking.hostname = "surface";
|
||||
gui = { enable = true; touchscreen = true; };
|
||||
initrd.unl0kr = {};
|
||||
gui.enable = true;
|
||||
};
|
||||
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
|
||||
virtualization = { docker.enable = true; waydroid.enable = true; };
|
||||
|
||||
@@ -4,6 +4,7 @@ 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]
|
||||
age: ENC[AES256_GCM,data:KEaMrk9eldR6oCqNqSpwhbJKj+JrN1KBkDL5p9itaszGf4tnDRidcleCQi1Ae17osYXIEh4+OxX/d6RKb9TP6JMLJe0iq6c9sC8=,iv:ztiP2Vz4AFZkd8ZG7xYlqYrV3JZYvmX07Ez6GtJ6yp0=,tag:PS8oSkkrrpgYYVfjbTtkaQ==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -28,8 +29,8 @@ sops:
|
||||
a2xybTRFUFZZN20zajZJTVNwVEpGcEEKglmFMk7z1q5IlZ+lZf9M0HtknmvcYt/P
|
||||
2/z5e8wLN1Hy0Zsbv0yIL/NmqwxAOGJOdzz7ElJszk/Y4kUr9aRasg==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
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]
|
||||
lastmodified: "2024-09-01T15:22:09Z"
|
||||
mac: ENC[AES256_GCM,data:Br2+miNeZI41QyTXdhJ5Mdwq5no/d4kJgESwiltcRZV/Pax8R+GFeLDg/AQFoh1fLHU6bTX45SN0wnIrIeCnkoXV0U2RiT7bdtBaDrGxqnFvjMVE0VaUrj9bpagta13tahsEfI17cyUq4BqwS4BXx60RXvbvs9jZ5/dfpYunGsc=,iv:FfWYfS40XcFgF8lEYK4IHypLzz7svFxPL+WuudQm3oA=,tag:0KDBdf7w6BdcQ8Qt3k1isg==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
version: 3.9.0
|
||||
|
||||
@@ -38,6 +38,7 @@ inputs:
|
||||
sshd = {};
|
||||
fail2ban = {};
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 64; };
|
||||
xray.server = { serverName = "xserver.vps4.chn.moe"; userNumber = 4; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
hello: ENC[AES256_GCM,data:mX0hKnLdaujfHSyIikkannf8DDo+r7R0,iv:my9nYiaburkWHQLsNetqD3dYVwsEkJhC7hoh0XagoOk=,tag:D7uhoFGMrTWT3K4LNMFcUA==,type:str]
|
||||
example_key: ENC[AES256_GCM,data:ezHOG8aSXYlosn7ymQ==,iv:NLm785UMihcL1K/M4u7k+P2XftyLlIxtQGPmMLc+rs8=,tag:h9xk+do8pYzxYzUaKKb1PQ==,type:str]
|
||||
#ENC[AES256_GCM,data:pgOf9IVK9ijocRr0uEO0ZA==,iv:aQ2dvfAVhkFWtcDM4VeJQa+NN6kw9IlvidL/usoP/lE=,tag:49iS4s1EfQK5VhlF9nqWRQ==,type:comment]
|
||||
example_array:
|
||||
- ENC[AES256_GCM,data:W8QJiOY6ofqE+XRodK0=,iv:KQ/mYY4N/YA9LhZvJtPJPqRVQq4ob/xa8JSQY06Vm4M=,tag:7NQgidSCjER//ru3AXgLzQ==,type:str]
|
||||
- ENC[AES256_GCM,data:nNML0iYEFdW4S5rJVHM=,iv:LQ1/E/7FExXB16Ur4b59XAUlWSFPub6LQBaFCY+a2lE=,tag:LqPymQ7k5ZsS8d9Z09xJuA==,type:str]
|
||||
example_number: ENC[AES256_GCM,data:UiALks+CeKFusw==,iv:8gQ0aB+9YHXKVDX7moqdQmNJLGDNGfo+glezE39xXgQ=,tag:sJG+DJNzCtx+l4bBgQTtCQ==,type:float]
|
||||
example_booleans:
|
||||
- ENC[AES256_GCM,data:n3cV5g==,iv:z2p5oh8BhEMvwwIDaO8aM8VfxmsR6Z7473pd348tsmU=,tag:oSYsNuk6vY21Nepy8Hkb7g==,type:bool]
|
||||
- ENC[AES256_GCM,data:ns3chHI=,iv:db8M/qF03VKaT/8Q4NqfCdI1zAU9H8JWZFqnzwI7QvI=,tag:FdgUanhezouVdv+9a9/gxQ==,type:bool]
|
||||
xray-server:
|
||||
clients:
|
||||
#ENC[AES256_GCM,data:d7cv,iv:RHzGIDLuuKejCTQ5YlNNITkCS3VoprsqH/kHckdpAv0=,tag:3cYw7uyUmXALo3v7SiqLJA==,type:comment]
|
||||
user0: ENC[AES256_GCM,data:o2wxpSzoqsPxs6grgYRLtPutMVwSqtzUWBrj7+7QuWWd1a1z,iv:2/5SxXq8Iw4J/LzBeclHbkrZXHitguip0WN+MINym8s=,tag:v/3oly53ORM9XAwbOzp06g==,type:str]
|
||||
#ENC[AES256_GCM,data:0nHZmEPPaw==,iv:BtOZ8/U0yg3fthHrwerNQX3+KD/H9+fcUylYGnZqiIM=,tag:DkFGSFfq//LmWfg6DGm1aA==,type:comment]
|
||||
user1: ENC[AES256_GCM,data:7ev7GuKLeJbPReMy0FnX02fLv5nNCpxdzfnQyAA+/IviwDMQ,iv:YbESsyIAiEAyvrHnj9A4lITX7NtRkuRhCrTv6hoG9Qs=,tag:8uledxLXqpXXLBh+cczm4g==,type:str]
|
||||
#ENC[AES256_GCM,data:3KN/1hzeR2I=,iv:iaqJJD6iURTUlIL8e8P7fsAzJYo+y3NGZXgWmPX+4ao=,tag:e8g/JgVrMrWJamUMpiv2pQ==,type:comment]
|
||||
user2: ENC[AES256_GCM,data:58PnLCwDayOYinsPCYPeMvuKiF7b4tZtbmEJFWEl+2Nu6HL2,iv:hSv3jCtkLm4rrm/4+ot10CBhobGwtnK5db5wR1S/XrU=,tag:SQbynYp8pDSqj4tAK6JBMQ==,type:str]
|
||||
#ENC[AES256_GCM,data:uTZDsA==,iv:6cxvQycfji/x+DW1CnO45r+yNTLwkhYkiJwDaSpUCwo=,tag:8pMw+sYeOyZBN1idHoM9+g==,type:comment]
|
||||
user3: ENC[AES256_GCM,data:WCVr0ylGm2SHtOGulb8TD/cI2xJXrbvY1d6+STXGxf0d0izb,iv:vhNshb38AVpwKCFRwUVruCQ0SxhHrOmwQ+IoQZeUj1k=,tag:OfdIjRrTAuVZBOEXTtnrQQ==,type:str]
|
||||
private-key: ENC[AES256_GCM,data:akNIeVp2bfKvnzlS6KLAdqAo7qsGfPatzCZpN1tNRLhRVXmJCcUDVSmVoA==,iv:2Rny8ioDJ2x+NR+n7/Aluv7JZ+Om3MuJKsXiwONYntg=,tag:a3xubIr7hpVjRiHjFL/q5Q==,type:str]
|
||||
acme:
|
||||
token: ENC[AES256_GCM,data:JBeN7SVxKGOe6er0eS7/v8YrXdv0nCK/KZc8Ygq0G7FIGu4hO662kg==,iv:rf59MgUCYlAA5h18wtdWoUyb2VPB13OPuJjz1VsI2dU=,tag:ViPrwduD8aWf8i8vmBG78A==,type:str]
|
||||
nginx:
|
||||
detectAuth:
|
||||
chn: ENC[AES256_GCM,data:lQHDpv8/Yl5/nycHoeTnCw==,iv:ernNxRpcTOSAllDpqRFVFg3qEw/slEEPPXDFq1AhNL0=,tag:2AVALUf9cDyOgCqI9wwgQQ==,type:str]
|
||||
led: ENC[AES256_GCM,data:zyCiiH21,iv:iEYyNClDsCpWE2oNjt2NqQZ88xOOlMr0yycjKTPdmlw=,tag:kQfbshXfTBA5PtUAgpgCcA==,type:str]
|
||||
chat: ENC[AES256_GCM,data:pXu0WPWmvUzvl2expDpQPqWwi1A4abg72npsaYXDXRcg6aVU0Ec+tgM2+uz2hT9rh3mNoBxadYXDc/zeOL1UCg==,iv:iln5UGGBK2s5pGS03PtolWTkx6KrnYBAWCFnI0V2Bag=,tag:EahTDoPIBkgWnp4MOoTCmw==,type:str]
|
||||
maxmind-license: ENC[AES256_GCM,data:8OioibcXQ9IZ0OQhJ/zHSBQjfdHzkoqwUx5zR8Zq0atNw6SSf7vKrg==,iv:z6WTI2yeqP0h7EqKG114nRQpFVJlNzZspgS6gIFtpt4=,tag:a0dBt9pXJnncBiSKt9dsAQ==,type:str]
|
||||
telegram:
|
||||
token: ENC[AES256_GCM,data:Si6yTh48HpA8OkkkvgHwtJYFhF8tW3oaQbldjwBc09QJxp9AoKgASMnZtbDZYA==,iv:GrNyZXjaZMviSjy/LGHHrYTr5PFvDkCXmT3MU4+SLpc=,tag:YifB1tKFLqsgXB/YLqYK4w==,type:str]
|
||||
chat: ENC[AES256_GCM,data:ydPky0W4ZWqn,iv:uWQrZDz2GCxiKRaijM89Npt0fQeSNHbQzDefkZCkUAE=,tag:OJQwV/889Vp2/4wjbN41JA==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -17,23 +29,23 @@ sops:
|
||||
- recipient: age19ax6vm3pv8rph5tq3mmehd9sy9jk823tw8svsd790r0lkslycquqvlwz9m
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBIaE9nWEZFaE51alYyTUgr
|
||||
RVBKZ1MvNitBdGpMWURIUkhCTlF6Y1hueVFjCnp2Q0JVL0t2UEZrSmxMbFVwZ0k5
|
||||
QVZDdXNjWmg0S3BIaXF0NDBHOThiMDAKLS0tIDBpenAyTE51MWVkaHFvTFhzNmVV
|
||||
WnlKUFZWNWtaYUpPZkplSm04Q3RFb00Kghj7jLLcLpc8njNyxPj6JWZbBRn2Ou9j
|
||||
FJLfCGLePuJPmdBBN4AGHmtrkfw/SMZJ50DXhKSJSxM91zuJSqFV1g==
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBNamN1TytweDd3blJsR2ZH
|
||||
ZmlocFZjT3ZaUjlVbG1vVSt4a2s2SjJIaGtRCjRneDV6cHYwdGJOY1BDVS9DeDVC
|
||||
cDdNbUdtSGRHNU1yZFpPc1MzRS92ME0KLS0tIFpmamNmTFYrRGRqbTFVSzBhUlNa
|
||||
VllXdzZ3bEc3UFY0YjZRKzBUcGgyVkUKqI1ojiLbF87alAkEwyrm8wuW2fLbmj8d
|
||||
YBIpoDCZ7AwR5uHWQAtl7BWJV1zab+rA3zvaf2BsrVA1A+RWOtYT/Q==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
- recipient: age1nnd6u8l20julg4jz4l6kw5gmj6h2tsngpm7n8dx59umgw2s66y4shq6jv4
|
||||
- recipient: age1yvrl4y0r6yzcxzzkgfwshlrtsjt8uuya6rfwks09pnft7esfcyvqmrtm5q
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAzYkJ1NllUR1pMaUdmZ3Z6
|
||||
OEVLWC9nZHNxNWJSZ3VZUVZ3eWlLNWN5V24wClZ3dTh3SVNRS0Z4TFJrNDJBVnJj
|
||||
aDhYNTdSV2JmUVNXR1ZkN1BOdzZzRHcKLS0tIFNhUGIxRVM5MFdvUWZWOG5kYlFM
|
||||
RjZtLzY5b00vMExFSU1xZEl0NFJQQlEK4yUe3V0u6A3niES0Nq28rRYZ1fTEL0Fh
|
||||
RBGZNCute1SShrLZPgNr/lFAc6d8DH6N0IuDKcjguuWtyHY/LFYuYw==
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBWWitsSnRVSzJDZG9ZSE5I
|
||||
bmt2NEFDanR3aFJyYVNnU1NlUldRb2RUVXhNClQrTkgzR1dPNWp3endZTUl5SmRs
|
||||
dEtkSWk4aWJEc2hhbWlXZkxpNGhacFUKLS0tIGZNSG43R0NKYmdFMzdXbmJjSExJ
|
||||
Ri9hM3NRTkM4Q1lDdmdPemEweEFBUmcKNLL5qH+JeFWX0GovkPFVVAnz+4tmfG6/
|
||||
1jN8YqbMIxf5/L8tauXPf0iIiHa6pUcjtDZPr/OEmeXebmF6Bh9u9Q==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-06-27T09:40:19Z"
|
||||
mac: ENC[AES256_GCM,data:ZdocsIbkzcWsTia7s98T5hjM5HDyBc1a0pwAb3IEFAom9Q0LjOs02BjsBKQT9Z+eMU+Ugkaz+kgP4hwYbcUuAbiVChU6sLMxUPwQDE8E7sJINZvJzth4Kl5SF4qz9fEuY8ZTP1hHc/HC6fSfWm+zH8n755aBjrzdIUvPV0Qv3xI=,iv:SSjyvgMSgZsoKHspRrNJpkmRTDdFqQlJGLUybyMcXbg=,tag:EBLpGZLNwDZxsWwh7Eva7w==,type:str]
|
||||
lastmodified: "2024-08-25T03:19:55Z"
|
||||
mac: ENC[AES256_GCM,data:v6yb7ZYcnPw/8SqEJnSWzmlE17PenjnBH2X8HZp+kIDXzNFyNvD19FcbCBZjwyjBLvN1ZF4M9FS7Y4+CvvMrN/4JcFufcY/V1NrOd8IZisfAT5N3WuopPee4IN9WEyPVOsbFnesZo6/wJKuqlV1UR8UZxCd3/wHXob9Lkz45cBw=,iv:XKIUiRfP0lj8V/Z1HbvhBankdcAjQqM8Way6TWjJJMY=,tag:PLYsVj6BmR132oWsxEKnfg==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
version: 3.9.0
|
||||
|
||||
@@ -53,7 +53,7 @@ inputs:
|
||||
(site: { name = "${site}.chn.moe"; value.upstream.address = "wireguard.vps7.chn.moe"; })
|
||||
[
|
||||
"xn--s8w913fdga" "misskey" "synapse" "syncv3.synapse" "matrix" "syncv3.matrix"
|
||||
"send" "kkmeeting" "api" "git" "grafana" "vikunja" "write"
|
||||
"send" "kkmeeting" "api" "git" "grafana" "vikunja" "write" "blog"
|
||||
]));
|
||||
applications =
|
||||
{
|
||||
@@ -62,7 +62,6 @@ inputs:
|
||||
catalog.enable = true;
|
||||
main.enable = true;
|
||||
nekomia.enable = true;
|
||||
blog.enable = true;
|
||||
};
|
||||
};
|
||||
coturn = {};
|
||||
@@ -80,7 +79,6 @@ inputs:
|
||||
};
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 64; };
|
||||
};
|
||||
user.users = [ "chn" "zqq" ];
|
||||
};
|
||||
specialisation.generic.configuration =
|
||||
{
|
||||
|
||||
@@ -45,14 +45,14 @@ inputs:
|
||||
matrix = { port = 8009; redisPort = 6380; slidingSyncPort = 9001; };
|
||||
};
|
||||
vaultwarden.enable = true;
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 1024; loadAverage = 4; };
|
||||
beesd.instances.root = { device = "/"; hashTableSizeMB = 512; };
|
||||
photoprism.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" = {}; };
|
||||
nginx.applications = { kkmeeting.enable = true; webdav.instances."webdav.chn.moe" = {}; blog = {}; };
|
||||
httpapi.enable = true;
|
||||
gitea = { enable = true; ssh = {}; };
|
||||
grafana.enable = true;
|
||||
@@ -63,7 +63,7 @@ inputs:
|
||||
peers = [ "vps6" ];
|
||||
publicKey = "n056ppNxC9oECcW7wEbALnw8GeW7nrMImtexKWYVUBk=";
|
||||
wireguardIp = "192.168.83.2";
|
||||
listenIp = "95.111.228.40";
|
||||
listenIp = "144.126.144.62";
|
||||
};
|
||||
vikunja.enable = true;
|
||||
chatgpt = {};
|
||||
|
||||
@@ -35,6 +35,8 @@ rsshub:
|
||||
youtube-client-id: ENC[AES256_GCM,data:dPo4+HsfXHdxrgF9F0qJmOGcSHDCn2KIkHx3ZYZU94iv8ImiPI9dTRfoz0zq8UIN7rwIKidQu9GxCRrg9aXk34pc35SXzEh8JQ==,iv:ROVHb0QjVsNae9eJevG6qc5dc4gkrGt+Y7S2QYrzmQ4=,tag:Advoh75OKPC7CnIeL4GFbA==,type:str]
|
||||
youtube-client-secret: ENC[AES256_GCM,data:c/ALpo/4qJdccMgYiSLg9ZgG7ddaMYxHwJYZ/ogJN2ED21k=,iv:CkrIq+Vpuq28CsRNwdKRLnBq6L8NF37y4xhhnmHQHqQ=,tag:SKtHpm/QZWnGViDtSKlUUQ==,type:str]
|
||||
youtube-refresh-token: ENC[AES256_GCM,data:pnXQ1euCdix2H7IxudmUUcpxc2OUhciKT8OcGV89c/EpoXHgx1+eLxwY5rRszroWwjge9M001RGHngvD/ny3phfWAwYmIzMJxun2f7JCPe7ybMesWmPSkiqVBss1Zfic1uB8mNM/yw==,iv:8p8/vATY8F3YuGA1TtjekiuaKOMnQyTMjrwDBJaK4VU=,tag:/jVg9FDOuLMNrupgrywpBQ==,type:str]
|
||||
twitter-auth-token: ENC[AES256_GCM,data:65SbHggbYtfSfaaxJxRgD6+HpOX4vIfjnVZmOAZ9illPMYOu9MIchQ==,iv:49UuC8n6AGj1skuHzQX39Q/QuKlB9IxogIfiiy1GBnw=,tag:Rq6b0H9UFVZ19tU8ZeelRg==,type:str]
|
||||
bilibili-cookie: ENC[AES256_GCM,data:58nO7ADu2oH/OgLJNYrEEzhf1J0zt8EpuygnSANkGXJju5oSmtM7WLnaMEjC96q14OTTA9QLiFVsbxiFY1eUnraA5W7g7+6CYRXVRZaxz91D/dhKzHGTMjB/LynnNqEIc6liONlcHbyjZNQ+WIqPtjVpCKMN7Mi8cv81/cFX/1GqAwncgDD2oXh1hMPOVY4dYcGKuOG0GjlY6RgOgTPqU3HawQjnoWQjPF+lq2rnWD5HP9ZTxOYa7hm2GgPrxkq1fkRrq+kKYeDh+6M7VLDcm5Fpf+biq6F8fZWzmw4NlVZT9BG0vJFa,iv:vxYXg9Yg9qIWFQXtwTYa4Ds0KSxZYg3M6xdtXKbdaig=,tag:TzCPehk9w+BL4wwgDc1CPg==,type:str]
|
||||
mail:
|
||||
bot-encoded: ENC[AES256_GCM,data:HstqDfhKoLqDip9O+mwYGbNlNQ==,iv:CZSTfxJHhI6nG7501cQdJiZ9l3uKS7d5YsA8iVTUuoE=,tag:Rj3rvXJzDp8XzODV/gABog==,type:str]
|
||||
bot: ENC[AES256_GCM,data:j4Y5oYeVt0sd2z2Qwuqisw==,iv:wasQCTqEMAyttbn1zm9oKck6QiByom+F7ZIMDUse9Gc=,tag:92O4ka6f0I9qnlnVy2dltA==,type:str]
|
||||
@@ -144,8 +146,8 @@ sops:
|
||||
SnFHS1Z0SXUzTFdEd29KTy9DU3Y3R0UKfhh+rUmWDrf+UGjclP57dHipPLFoXSqy
|
||||
HdelmfV6q4/c7ppx2E+oZw3VNgoZCsrxxzYZfwxHJiZb+5vkE0D8iA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-08-20T15:48:48Z"
|
||||
mac: ENC[AES256_GCM,data:buEby7ZmmEFARmRp3r7JwYdMck87u4c3TGkeF2pkc5ORnqIgwSH1XVSjlbK8vTBWz2FKXeQh9wkX3BMaam9dU873/yPBe54BnbZNggZ7jDDEpSTeddfTsM8mrka0xDO3CUHbwCsqYWFm4NLAbCfRPKhrjvSJVyEC85K3eO45Z6M=,iv:/7cOdSi6oiaaFRkSnR+1/XXapjlQdMgom31xrpIGXHk=,tag:XW4WX93bw45zPweblW4Dtg==,type:str]
|
||||
lastmodified: "2024-09-02T23:57:33Z"
|
||||
mac: ENC[AES256_GCM,data:Tp7uSF3G1WALzv7jPSXGyIJbwYLHz4sF73NUoAI6KPboLs3juhDiZjJfkBkIIv4BawWNTvvAQfBL6hbpPbn3bLpkTvU8TiHyP9yiY5kJkid37I2s8KOHHaxKSu4CXlkAeXdZX0I1iujAOsKYUd2GnN19V07K0qwCtZOVvZXvjsk=,iv:fcsE7qXrcoaRdTv0C4nmfNvIDXtTXiKyF7TCfnkvRPg=,tag:Dgdq4gT2lzhkXZ10uUCwwQ==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.9.0
|
||||
|
||||
@@ -34,7 +34,7 @@ sbatch
|
||||
提交一个 VASP GPU 任务的例子:
|
||||
|
||||
```bash
|
||||
sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" vasp-nvidia
|
||||
sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" --output=output.txt vasp-nvidia
|
||||
```
|
||||
|
||||
* `--gpus` 指定使用GPU 的情况:
|
||||
@@ -50,7 +50,7 @@ sbatch --gpus=1 --ntasks-per-gpu=1 --job-name="my great job" vasp-nvidia
|
||||
提交一个 VASP CPU 任务的例子:
|
||||
|
||||
```bash
|
||||
sbatch --ntasks=4 --cpus-per-task=4 --hint=nomultithread --job-name="my great job" vasp-intel
|
||||
sbatch --ntasks=4 --cpus-per-task=4 --hint=nomultithread --job-name="my great job" --output=output.txt vasp-intel
|
||||
```
|
||||
|
||||
* `--ntasks=4 --cpus-per-task=4` 指定使用占用多少核。
|
||||
@@ -85,6 +85,7 @@ scancel -u chn
|
||||
|
||||
```bash
|
||||
scontrol top 114514
|
||||
sudo scontrol update JobId=3337 Nice=-2147483645
|
||||
```
|
||||
|
||||
要显示一个任务的详细信息(不包括服务器重启之前算过的任务):
|
||||
@@ -130,6 +131,8 @@ sacct --units M --format=ALL -j 114514 | bat -S
|
||||
-s, --oversubscribe
|
||||
# 包裹一个二进制程序
|
||||
--wrap=
|
||||
# 设置为最低优先级
|
||||
--nice=10000
|
||||
```
|
||||
|
||||
# 支持的连接协议
|
||||
@@ -188,9 +191,7 @@ RDP 暂时没有硬件加速(主要是毛玻璃之类的特效会有点卡)
|
||||
|
||||
samba 就是 windows 共享文件夹的那个协议。
|
||||
|
||||
* 地址:xmupc1.chn.moe
|
||||
* 用户名:自己名字的拼音首字母
|
||||
* 初始密码和 ssh 一样,你可以自己修改密码(使用 `smbpasswd` 命令)。samba 的密码和 ssh/rdp 的密码是分开的,它们使用不同的验证机制。
|
||||
* 地址:因为懒得管理暂时禁用。
|
||||
|
||||
在 windows 上,可以直接在资源管理器中输入 `\\xmupc1.chn.moe` 访问。
|
||||
也可以将它作为一个网络驱动器添加(地址同样是 `\\xmupc1.chn.moe`)。
|
||||
|
||||
@@ -90,7 +90,7 @@ inputs:
|
||||
hpcstat = {};
|
||||
};
|
||||
bugs = [ "xmunet" "amdpstate" ];
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" "zqq" ];
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" "wp" "hjp" "zzn" ];
|
||||
};
|
||||
services.hardware.bolt.enable = true;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,12 @@ users:
|
||||
yjq: ENC[AES256_GCM,data:ua0DINHutjt2Pk+SfHRQRV99mT3Cnw6rRKO8VRIAlP0dY6QhK9wkNdyRYWYRBKVrWgyFQMGNFYAxIpymjF/X7mBOVI2sOHLgkw==,iv:PUZ6S0KICuqoSA2sDLxdL4gtAOQnQXOUY+5f3qDZgpc=,tag:f39P34vAUOrV23BsKkRarA==,type:str]
|
||||
#ENC[AES256_GCM,data:6qNjSdjck4Vz,iv:c/GNqCNgRgwgL+2f6Vumtjb/ub9WCBSy8R02NRCDqk8=,tag:b/tucJsHTjSfcK0vgHtE8A==,type:comment]
|
||||
gb: ENC[AES256_GCM,data:3eAKBiJoC1owCHTFd3Xq8vI8VK980evePc92xCXJJ21M9D1MdbwN8ySZ3Ovjk7VfQmEo8oRv1Ll1sftyrXYoeTHmJsNDxCpR6A==,iv:Ju/ERNuGrgO5kYlbvmkbLJkgiW3Elou34AsJTFITCUg=,tag:POVlxYh9kZ1BMSbt97IVOQ==,type:str]
|
||||
#ENC[AES256_GCM,data:oniighfvCNGWUwdhqg==,iv:RVUuZBqCd111QJ7MpgYBuP4fDCzm4NZAtbua9kXkrJM=,tag:21zF8E/3lBTDr54I9NKPVg==,type:comment]
|
||||
zqq: ENC[AES256_GCM,data:Vjbbs8xIlH3+of7+kLGFVp4bIizU8D5R1qRbCqP5FhzTadXA8KD9/uiYxtrV3oxYGwZ/RlLvriHMClob4ihyDF4U2t8Dc4eVqA==,iv:FjCftpfKPZYThiNOyNkhx9uNyWIsjC5sK5WWcaEBtiY=,tag:MTL490c2SeFGx3EhxEdvkA==,type:str]
|
||||
#ENC[AES256_GCM,data:/2y613pek/CO,iv:gqSh74Ac0BxPdO+fOsQ0K8t2YduwyTVOjMq/A5Wmoz0=,tag:jLUYXu7f27FruwH5rUUZSA==,type:comment]
|
||||
wp: ENC[AES256_GCM,data:3jeHpeu1YlFhK2+o19q2/JyJPhZFivPbUQzJJbJZ15GzAVh7i1VsTSN31LufXAgsC8KjZHAPhEZlGYvnGpCvPzoISQa5NVAJdQ==,iv:bL3ohgbjA2agFKDwgw0H3LgiHTWB4Y5KlQAtHfEMr+w=,tag:SfLtj7iDcmV3dgOlITFvxA==,type:str]
|
||||
#ENC[AES256_GCM,data:YIlY7n5pcJTp,iv:Y/+ogxaMgSl0vcMPRr3qdSHjjnnhY+N2Q6jFojzIDyQ=,tag:zat02jxJ8jI2uk8noslmHQ==,type:comment]
|
||||
hjp: ENC[AES256_GCM,data:Ii4P9ZsUOEh3cqt3AKWlgUH1CMNnmHln9QNWdTRR3vZXkkR5j5qKAIrAltml/i3xFlt4hftYNufnupog4UlAVWQJhYBlhCSE4g==,iv:eKWmUcKItjd1dsvVP1se5CAhIFqV/eVH03gPJhBau1E=,tag:ZTE0BTSoDpJGqECklGjs2g==,type:str]
|
||||
#ENC[AES256_GCM,data:hCgqHfpmeJ1Z,iv:pEKUNxhUyNAVtniTIQ2IpMPmXr2O+twq2/3Y2lIoqdw=,tag:RTqcI0XCoOymQD3r4+yS9Q==,type:comment]
|
||||
zzn: ENC[AES256_GCM,data:/CSffToFJiBotXZ5rPkz0UNgI/iC0ftusPF2Ce6Of3XckjpCcikWj6n3ahJ24XsWQjp3EvacOiBorh+Kg16LjCEl0P2RMIitTQ==,iv:u9IFdp/jw7ehTshPzQVssLeh33iBYCPjSyJSLsc5EVo=,tag:/KXgmU7dcTKG8C4Y7NcMhw==,type:str]
|
||||
mariadb:
|
||||
slurm: ENC[AES256_GCM,data:qQMD8SKNmxb3PdScXNqppF9zkX7dV5i7rvljvZuhiI5zLnu77qYCHBW6ymh0mrY14N9NjxmQZhZWX/H8TvBlcg==,iv:J5N3LjCYW3QmuEkMBpl7qvPFW1Z9ZoPLkj45jKcIW9U=,tag:Tl+ld07+lVkmzt7f/f2MqQ==,type:str]
|
||||
hpcstat:
|
||||
@@ -48,8 +52,8 @@ sops:
|
||||
ZDNHUjE2QVlCV3p0NHdKYW5IMHVBZzQKkZtfyvfroOntg3yRjMw4jQHiQj8eaB2h
|
||||
IeIHfW4y01mmVT2ofbtB0xYpjcl4gtUlQ8X3tn5iJ9P8gcVo0G598A==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-08-21T09:56:03Z"
|
||||
mac: ENC[AES256_GCM,data:9+AR9Y6ik+BH1Spk62LSTU1NFQ8ID0YROF+yf8ss2RqhfP6/5+lsrNjGC7gnEEMYF8UWVtChUuljIK3Q4MtT64JhDWgp8tenbpkJnRFGylzEe37MYajdDY7nrPP7iPUPNvS1ndo6vp/yuEigBXVhCtpjMObj7zIdGnLbtz0sczA=,iv:gNb8gVp9adnlZsMM2afOlFe46Vy15ELmC9vGaaeaInY=,tag:rltLL3WSZytjEemgjCy6Ng==,type:str]
|
||||
lastmodified: "2024-08-31T15:59:56Z"
|
||||
mac: ENC[AES256_GCM,data:zd3ivzjgdbwGZpZssHeIwwkKFfHDxo/dzvb8ptw9noZ4hDVoC5RL9M/OLN6GrRM0wtpNFZJDs7Zz0i1zMascXdVu6mou/0il6/96r+FkQVBJWbrkY36Lk7ntDAcQmZKWxSUfSF0JPHx1rbkIQSVtsLQrpui9UDxaY5DP23xjLQg=,iv:+ouEpSlo0EovK0Qh27tm7NXSYncbjEc/EMWfWHIrCqE=,tag:4CHXmsJ4LhFBmbep3Wil3w==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.9.0
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 内存:256 G。
|
||||
* 显卡:
|
||||
* 4090:24 G 显存。
|
||||
* P5000:16 G 显存。
|
||||
* ~~P5000:16 G 显存~~暂时拔掉了,否则 4090 供电不够。
|
||||
* 硬盘:18 T。
|
||||
|
||||
# 支持的连接协议
|
||||
@@ -18,14 +18,12 @@
|
||||
|
||||
## RDP
|
||||
|
||||
* 地址:xmupc2.chn.moe
|
||||
* 地址:xmupc2.chn.moe:3390
|
||||
* 用户名:自己名字的拼音首字母
|
||||
* 密码和 ssh 一样(使用同样的验证机制)。
|
||||
|
||||
## samba
|
||||
|
||||
* 地址:xmupc2.chn.moe
|
||||
* 用户名:自己名字的拼音首字母
|
||||
* 初始密码和 ssh 一样。
|
||||
因端口冲突暂时禁用。
|
||||
|
||||
其它内容请阅读 [xmupc1](../xmupc1) 的说明,两台机器的软件大致是一样的。
|
||||
|
||||
@@ -66,14 +66,14 @@ inputs:
|
||||
enable = true;
|
||||
cpu = { sockets = 2; cores = 22; threads = 2; mpiThreads = 4; openmpThreads = 10; };
|
||||
memoryMB = 253952;
|
||||
gpus = { "4090" = 1; "p5000" = 1; };
|
||||
gpus."4090" = 1;
|
||||
};
|
||||
xrdp = { enable = true; hostname = [ "xmupc2.chn.moe" ]; };
|
||||
samba = { enable = true; hostsAllowed = ""; shares = { home.path = "/home"; root.path = "/"; }; };
|
||||
groupshare = {};
|
||||
};
|
||||
bugs = [ "xmunet" ];
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" "zqq" ];
|
||||
user.users = [ "chn" "xll" "zem" "yjq" "gb" "wp" "hjp" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ users:
|
||||
yjq: ENC[AES256_GCM,data:sGPQ0xALULREnhzl9g/V91M5osMglsSps6R4gYn5OZc/4xVC1phF3qajVN3YMOr7kKgkHbF2Rjm6/2vuK0k1iYZnFswUAmFlmw==,iv:5vG1hn7SlX6HCpas2BgxBSwWqLby8OCxcH3EKNvceIc=,tag:TVwFBAuosKnEOZecq1phXw==,type:str]
|
||||
#ENC[AES256_GCM,data:ALHxkRABA+ll,iv:r1IDiHLFcTdLID3q16zrLTavAwQfddC7bXMKcFZFveI=,tag:4Pd0/Q1BmH4gJjaM4hbqqQ==,type:comment]
|
||||
gb: ENC[AES256_GCM,data:z4CrtdmdLJJ0qZzr7qvihnluJQgjtciX56KdEmtemiRu0llEJk9qz6a23aJ7m40Sfc38elF1/LsvjOuBOC87+BVkKDCj76phag==,iv:WrFVxkr3snmqDXZx5kAYCLp7ixEIzxoT7El3rV7Ovqg=,tag:iExf2Y/HObHQrKMTRvqn7A==,type:str]
|
||||
#ENC[AES256_GCM,data:UoNCXbGIHDNsmyCJxw==,iv:uTNvqg4xm7E+yn8vFaaihbEGEhLTZ2FNFNCYzdgiDlU=,tag:4bRSZbx6FFzA6MiBYVu0qw==,type:comment]
|
||||
zqq: ENC[AES256_GCM,data:sfgufV++PfTrdeUBXZhmF1JoSpD8Nj+m0QKFrUMJG/pHb0AUagJEWEJwPsI+m91tZE0qxM271ks+WKqLElmyD4Ftw7ywWzTE0Q==,iv:R05QFUF+fvIHidWpHIR/D/e+UeciS5ehnx1kx+saCgM=,tag:3Awnd+pUQRxjjQ58SUX7Mg==,type:str]
|
||||
#ENC[AES256_GCM,data:XfNExliq7noL,iv:K+rFlZHF1oY5rsTzaO0mgxiE1VlKdtPTifAaesg321k=,tag:Dja8NmPWZdJkf/J/96/wAw==,type:comment]
|
||||
wp: ENC[AES256_GCM,data:yjMDez28pJUo6riIHypQQgjGFbuLwy87eG4ek/+Li2w8b4Cm5JckRvs26o+S0blfICc8WqIqEJGakT2wVBE5O1jGfniKn3PhTA==,iv:dOA318XRd2EXxmTIlk6GhlAR/FBpbKkbPJJCXTwFCxM=,tag:9MkXNUuAoplAzE+4eJpr0w==,type:str]
|
||||
#ENC[AES256_GCM,data:YGcTkNCeu3m7,iv:jYmVrfRFwQoX1XxeSzS23wRMAD/AnzYBXQjI76Ke2FE=,tag:WJfSmjdggzPojDcJ6GzP+A==,type:comment]
|
||||
hjp: ENC[AES256_GCM,data:0R5SfBFKuLGurwINnTj31FOrwwfY9bqVS1rG/a0HqIYd+Ui8/2ffFBx0Et+tYIqcxXEJpGbvse43V0naNKmFKlLanfcy9YV/Hg==,iv:mpAUmcVHWWLoreEsG9ha09jxte8mQCLt/A7nm04iX9Y=,tag:bia9pjL0MAcs9vj1gKCVCQ==,type:str]
|
||||
mariadb:
|
||||
slurm: ENC[AES256_GCM,data:9wLQ1zF/kDaiw0s3UaRpiHgmngU7u6hwyqpddSjev0+Z0v58Q2oiJtK8vn+2VlSxx5ACfqEFbzp0PZYAxd575w==,iv:q9JTkgDymOwkbZ/PaxRAAQrtO96QmGgZcQuLTFCMoS4=,tag:dwOHlOTgZqT/1jQ+oGf7UQ==,type:str]
|
||||
sops:
|
||||
@@ -43,8 +45,8 @@ sops:
|
||||
M0xoL1dQR0kvMWpzN0RMNWVCTFQxNFUKj9LPjBo5NGOrGYNvu8qZ13PLYjLEWllU
|
||||
LARzEn4XgkeHckouwvxZYMCx7WxmAruRWaOvnxTIczzSNP7wIrqnkA==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-08-21T09:56:44Z"
|
||||
mac: ENC[AES256_GCM,data:COodLhpL5EA5g15lgimsuxs1vmqJrLDVgtjw+0FLKTq6E1pcQ+zJl+dD0b9u5fYy9BBf56TI8TLJahVPR0eGxbDFlHmx8M9GStlTqaOE3jRsDT8GsihdlvLokyVt8jEfAnaWESTIgfehVL2TrLlsMnIsoVHrzdlEhX5ATXA3QOg=,iv:U/EwFmYWOcxi7ItkR/+MT8gTu7UobH5pxS00qrH/yyU=,tag:RVMcx4X0IS9yvpHrF0owpg==,type:str]
|
||||
lastmodified: "2024-08-30T06:31:36Z"
|
||||
mac: ENC[AES256_GCM,data:UUzv3IewuF4rhbrL2haJ0495p1d4wXA7LHa5ogc5TSv+ZAYuN/HL3VCXQzzKQrzqD3LtgC3DrGgmMNGVyAIzqVFYYxVuAwb03ov+lOp3SHvLTCMqkETbcE525aAIVWNqBXp7RBn7tKC4AD4y7AQihSYhBXO8VF1PeccjaCnN7R8=,iv:G0s8qchlgcm5HVshTKnGyt8nk+D4QYyP7n+5R0TOb8A=,tag:DspvfLf1pBs+/ol8GzT7Xw==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.9.0
|
||||
|
||||
240
flake.lock
generated
240
flake.lock
generated
@@ -8,11 +8,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722680456,
|
||||
"narHash": "sha256-q3ZxjLD/6WnAGwihLlRLoEzIEaVE1AqnH5h1TePYP/I=",
|
||||
"lastModified": 1723815556,
|
||||
"narHash": "sha256-TgkChEFJHqrciuI1Va7buSs5RQHCSxbWRFmuOI+e2tY=",
|
||||
"owner": "ezKEa",
|
||||
"repo": "aagl-gtk-on-nix",
|
||||
"rev": "54264a57d0c58afd12888eb1c576f96ca811530c",
|
||||
"rev": "4d7fa422b50b612aa29bfb8487472f1cd9bad85b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -59,11 +59,11 @@
|
||||
},
|
||||
"catppuccin": {
|
||||
"locked": {
|
||||
"lastModified": 1723691425,
|
||||
"narHash": "sha256-F25VvHFMaqr26b7goaVWspXaK6XTRFz8RnILV+9OPkk=",
|
||||
"lastModified": 1724469296,
|
||||
"narHash": "sha256-p3R4LUNk6gC+fTKRUm9ByXaoRIocnQMwVuJSIxECQ8o=",
|
||||
"owner": "catppuccin",
|
||||
"repo": "nix",
|
||||
"rev": "552056779a136092eb6358c573d925630172fc30",
|
||||
"rev": "874e668ddaf3687e8d38ccd0188a641ffefe1cfb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -88,11 +88,11 @@
|
||||
"yafas": "yafas"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723531925,
|
||||
"narHash": "sha256-QPETOkVNZwm3Zx0FRfkrPWScbc46I5QwIOdBmByYtKg=",
|
||||
"lastModified": 1724689493,
|
||||
"narHash": "sha256-fNjxhUlj1/tsz4NmVvGiomEhnRlzRNi4/FUmYr7QO5I=",
|
||||
"owner": "chaotic-cx",
|
||||
"repo": "nyx",
|
||||
"rev": "b8b1c616f8b869af7bce3179ad423e3d45b0d079",
|
||||
"rev": "9fbc509c51ab1e49b5c54a8c06d492830f6d8437",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -203,11 +203,11 @@
|
||||
"eigen": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723671724,
|
||||
"narHash": "sha256-ZYRLIWSqTCUjPvUXONCPlLxUBIlgoF8P/oWEFeJSBuk=",
|
||||
"lastModified": 1724459406,
|
||||
"narHash": "sha256-CzysP5sq15+5U/hBBrP9lLecAa09OJH6a1bQ+pmWAVU=",
|
||||
"owner": "libeigen",
|
||||
"repo": "eigen",
|
||||
"rev": "92e373e6f553dd842337c8467f4ddb669e0e9199",
|
||||
"rev": "c5189ac656c2bf5eead9bc967282cf084cbaeb64",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
@@ -225,11 +225,11 @@
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719875359,
|
||||
"narHash": "sha256-JwF3XxYsnVwZwYrHnWuM1KbtiwnhALAlpw5KGpvZek0=",
|
||||
"lastModified": 1724111875,
|
||||
"narHash": "sha256-Cit1pRfzgq8G1vCMRQ4eE4YdaUJPCxvj0p3EvhIPAUY=",
|
||||
"owner": "Mic92",
|
||||
"repo": "envfs",
|
||||
"rev": "135193473c3eac12922802f42760e2228a6f5ff6",
|
||||
"rev": "c8493adca165b700f53a53e06f578f3b9f64bcfc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -238,22 +238,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fcitx5-virtualkeyboard-ui": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1724249565,
|
||||
"narHash": "sha256-flMCrq4HEhugiwKXCd4xZkgZVF+XUo0C+L0OhRXCfIE=",
|
||||
"owner": "CHN-beta",
|
||||
"repo": "fcitx5-virtualkeyboard-ui",
|
||||
"rev": "695bf005da908c79f1d461c3b0801ce651f34ade",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "CHN-beta",
|
||||
"repo": "fcitx5-virtualkeyboard-ui",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -263,11 +247,11 @@
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723444276,
|
||||
"narHash": "sha256-ErWXmB84hedrDmeaHOaFFfNShC21AopTfM4x4rlvk3c=",
|
||||
"lastModified": 1724394478,
|
||||
"narHash": "sha256-JSiv2uwI4UJo/4pxt4255BfzWCiEberJmBC6pCxnzas=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "70c22198ab822aa93c92a7ec0933908b17131edd",
|
||||
"rev": "2e7bcdc4ef73aa56abd2f970e5a8b9c0cc87e614",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -556,6 +540,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hextra": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1724317530,
|
||||
"narHash": "sha256-luENDR+fn9NbqNkn9wpLRnD41MeerFEUsrDgKRpnmg8=",
|
||||
"owner": "imfing",
|
||||
"repo": "hextra",
|
||||
"rev": "c6de4b5b6b1ec04647b0235e9c8b1158b1d58c09",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "imfing",
|
||||
"repo": "hextra",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
@@ -563,11 +563,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723399884,
|
||||
"narHash": "sha256-97wn0ihhGqfMb8WcUgzzkM/TuAxce2Gd20A8oiruju4=",
|
||||
"lastModified": 1724435763,
|
||||
"narHash": "sha256-UNky3lJNGQtUEXT2OY8gMxejakSWPTfWKvpFkpFlAfM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "086f619dd991a4d355c07837448244029fc2d9ab",
|
||||
"rev": "c2cd2a52e02f1dfa1c88f95abeb89298d46023be",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -578,11 +578,11 @@
|
||||
},
|
||||
"impermanence": {
|
||||
"locked": {
|
||||
"lastModified": 1719091691,
|
||||
"narHash": "sha256-AxaLX5cBEcGtE02PeGsfscSb/fWMnyS7zMWBXQWDKbE=",
|
||||
"lastModified": 1724489415,
|
||||
"narHash": "sha256-ey8vhwY/6XCKoh7fyTn3aIQs7WeYSYtLbYEG87VCzX4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "impermanence",
|
||||
"rev": "23c1f06316b67cb5dabdfe2973da3785cfe9c34a",
|
||||
"rev": "c7f5b394397398c023000cf843986ee2571a1fd7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -600,11 +600,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723367191,
|
||||
"narHash": "sha256-noi5tre7BLtxImN38jEHeVOtOG1Xu37sJFwHKSAPHjo=",
|
||||
"lastModified": 1724304322,
|
||||
"narHash": "sha256-/nrlMDubg9oG2VNANRBxsas5RbcJtB6IIDPZC3yHLW8=",
|
||||
"owner": "Jovian-Experiments",
|
||||
"repo": "Jovian-NixOS",
|
||||
"rev": "91178062f365b64eece94c5dff93e09b07e87d9d",
|
||||
"rev": "924a18ea8df89a39166dd202f3e73cd022825768",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -616,11 +616,11 @@
|
||||
"kylin-virtual-keyboard": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1710313521,
|
||||
"narHash": "sha256-A8Y+lvAPlh0HeTxTaHCdAD/CilQCQwsX4C+fBBKaqTU=",
|
||||
"lastModified": 1723713444,
|
||||
"narHash": "sha256-AvuoCe9ka0tfXtNW0KxInRI6xoSayiyrX+tBlAjGNLY=",
|
||||
"ref": "refs/heads/upstream",
|
||||
"rev": "a8ec88762d63d676aae4f5f1e6d9d1dedf07cf28",
|
||||
"revCount": 161,
|
||||
"rev": "eba6dbbfd5d3d4128cbd300be7e109088cd82858",
|
||||
"revCount": 162,
|
||||
"type": "git",
|
||||
"url": "https://gitee.com/openkylin/kylin-virtual-keyboard.git"
|
||||
},
|
||||
@@ -632,11 +632,11 @@
|
||||
"lepton": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723185812,
|
||||
"narHash": "sha256-Mtnoit1CAGJoc8eiJ+0vfGc9v+3tomm8V8/tWfeAj7o=",
|
||||
"lastModified": 1724686250,
|
||||
"narHash": "sha256-Ngof+vfBm/3HFtjsNZGo9sWIHuoAet8v3f/FSMbARr4=",
|
||||
"owner": "black7375",
|
||||
"repo": "Firefox-UI-Fix",
|
||||
"rev": "c79922aa45ff04a62e04ef0f8562dc53990b5208",
|
||||
"rev": "c346292707c4507e2ccd890adacba65c85dc62d1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -648,11 +648,11 @@
|
||||
"linux-surface": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723804050,
|
||||
"narHash": "sha256-MYwEgnw3KjEm6oh39XUmCq12tKdH+0QZj9SZlWbwyxo=",
|
||||
"lastModified": 1723861744,
|
||||
"narHash": "sha256-a4rrhMYb75Kk4G7JEZkacJPWI4u7o5xX88hwgty38D8=",
|
||||
"owner": "linux-surface",
|
||||
"repo": "linux-surface",
|
||||
"rev": "4439a5efb6516c443df5f52173cb55aef01560d1",
|
||||
"rev": "9103a6bf08d622fd583fd9839d2dc4ef9b2a46e2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -664,11 +664,11 @@
|
||||
"lmod": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723142745,
|
||||
"narHash": "sha256-bNTOW6MffUpiGEfZxP1MSioa2MpYW456wymXHO5Uvr4=",
|
||||
"lastModified": 1724105894,
|
||||
"narHash": "sha256-MhoKG0QwTAccK0NE8vnm325T8Azqy4VKf77LGaSDNZI=",
|
||||
"owner": "TACC",
|
||||
"repo": "Lmod",
|
||||
"rev": "efd893e9a2dab1300a0d6f3ea998dc3503fd8d39",
|
||||
"rev": "c7974de5ba3376c7bdc123c42a8e9c3648a84ec4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -746,11 +746,11 @@
|
||||
"nc4nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1724033015,
|
||||
"narHash": "sha256-L0HSyoCAfrPF0zdlMmwu7Bpcqz43UsRFkTnXPZjLRiY=",
|
||||
"lastModified": 1724637826,
|
||||
"narHash": "sha256-/ZI1Bs96JyTxOnG12Rqx2o8aYfwqKxF7IMCUIfLBX3w=",
|
||||
"owner": "helsinki-systems",
|
||||
"repo": "nc4nix",
|
||||
"rev": "924dc2b20cac3bf48f7204d58255a9c62bf80f96",
|
||||
"rev": "c082bb1e4d237090bec9cb845af43627766724a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -826,11 +826,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723352546,
|
||||
"narHash": "sha256-WTIrvp0yV8ODd6lxAq4F7EbrPQv0gscBnyfn559c3k8=",
|
||||
"lastModified": 1724576102,
|
||||
"narHash": "sha256-uM7n5nNL6fmA0bwMJBNll11f4cMWOFa2Ni6F5KeIldM=",
|
||||
"owner": "Mic92",
|
||||
"repo": "nix-index-database",
|
||||
"rev": "ec78079a904d7d55e81a0468d764d0fffb50ac06",
|
||||
"rev": "e333d62b70b179da1dd78d94315e8a390f2d12e5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -847,11 +847,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723352546,
|
||||
"narHash": "sha256-WTIrvp0yV8ODd6lxAq4F7EbrPQv0gscBnyfn559c3k8=",
|
||||
"lastModified": 1723950649,
|
||||
"narHash": "sha256-dHMkGjwwCGj0c2MKyCjRXVBXq2Sz3TWbbM23AS7/5Hc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-index-database",
|
||||
"rev": "ec78079a904d7d55e81a0468d764d0fffb50ac06",
|
||||
"rev": "392828aafbed62a6ea6ccab13728df2e67481805",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -869,11 +869,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723685172,
|
||||
"narHash": "sha256-TXrwOBvk9yQnfS9zgyG6jWJA7bK+UVfnSoGX1Gp4/uU=",
|
||||
"lastModified": 1724635787,
|
||||
"narHash": "sha256-01rsv0PLT/x5BZybqTnrlYipnG1CFF5s7ZX9otCnFlM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nix-vscode-extensions",
|
||||
"rev": "e470c879f34c9f3915d7f1fe95c33f9a958f8c10",
|
||||
"rev": "d1980fd00e84460f6769cc1684899fead5224080",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -915,11 +915,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1724171353,
|
||||
"narHash": "sha256-Qdxgirl1bChkSnTgvHibkzF0wnak6HtRA0bLB4cindQ=",
|
||||
"lastModified": 1724925520,
|
||||
"narHash": "sha256-MfvD4Ed4wCTG1V+h3rUN9j9csEi+2tgpRwhGAV4MFqw=",
|
||||
"owner": "CHN-beta",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3f0bb934a09d868ce7e5a4a4ce415afb71a2655e",
|
||||
"rev": "8c66b7335f2f4ab354e41d828b74d851c64c4b85",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -995,11 +995,11 @@
|
||||
},
|
||||
"nixpkgs-24_05": {
|
||||
"locked": {
|
||||
"lastModified": 1723556749,
|
||||
"narHash": "sha256-+CHVZnTnIYRLYsARInHYoWkujzcRkLY/gXm3s5bE52o=",
|
||||
"lastModified": 1723938990,
|
||||
"narHash": "sha256-9tUadhnZQbWIiYVXH8ncfGXGvkNq3Hag4RCBEMUk7MI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4a92571f9207810b559c9eac203d1f4d79830073",
|
||||
"rev": "c42fcfbdfeae23e68fc520f9182dde9f38ad1890",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1065,6 +1065,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nu-scripts": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1725014865,
|
||||
"narHash": "sha256-EmlwDTEby2PAOQBUAhjiBJ8ymVW3H23V78dFaF8DQKw=",
|
||||
"owner": "nushell",
|
||||
"repo": "nu_scripts",
|
||||
"rev": "614b0733104a7753ed7d775224fe5918877b71de",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nushell",
|
||||
"repo": "nu_scripts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nur-linyinfeng": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
@@ -1079,11 +1095,11 @@
|
||||
"treefmt-nix": "treefmt-nix_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723573880,
|
||||
"narHash": "sha256-OWRxvKlh7+s4VhYiLEC8Dr5MLQ6vlTWFgCTIkO80XMs=",
|
||||
"lastModified": 1724610772,
|
||||
"narHash": "sha256-XAOnvYuIAMv7V2YVnVLUpMb+kzmxFxaXCaQASyJq7Ho=",
|
||||
"owner": "linyinfeng",
|
||||
"repo": "nur-packages",
|
||||
"rev": "70d09e1e7c10f81b697e3ac2315cbf6779ed62b0",
|
||||
"rev": "4593675609c0064d9a01e11df2e5c1ff369b98be",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1105,11 +1121,11 @@
|
||||
"treefmt-nix": "treefmt-nix_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723629877,
|
||||
"narHash": "sha256-gd0Dnx1igw1wHvkmihrtVPf/9sWdHgWCsCTpQglBZs0=",
|
||||
"lastModified": 1724379880,
|
||||
"narHash": "sha256-PatYnOuctc4rYrY7EqUDXbGkeRbyvhNIC845b0HS+oQ=",
|
||||
"owner": "xddxdd",
|
||||
"repo": "nur-packages",
|
||||
"rev": "68859480c1412142ad1e011b9f41f12bbee132c1",
|
||||
"rev": "655aedb45bb67e16c7ac2a116614f28d36eec8b9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1173,16 +1189,17 @@
|
||||
"openxlsx": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1722960074,
|
||||
"narHash": "sha256-KaexHI/Bl3aChkt2glN2oRJREYqFSOAO0Qn6pPccSXw=",
|
||||
"lastModified": 1716560554,
|
||||
"narHash": "sha256-Aqn1830lG4g7BbwEeePhvGawLarmrIMnF2MXROTUBCw=",
|
||||
"owner": "troldal",
|
||||
"repo": "OpenXLSX",
|
||||
"rev": "06425d541d09907799e93a4226691126bd60af5e",
|
||||
"rev": "f85f7f1bd632094b5d78d4d1f575955fc3801886",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "troldal",
|
||||
"repo": "OpenXLSX",
|
||||
"rev": "f85f7f1bd632094b5d78d4d1f575955fc3801886",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
@@ -1196,11 +1213,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723587631,
|
||||
"narHash": "sha256-FZ27DsgOROvv/4Cvo34UcIqEJLQ6cKIWHcQsM3zLN3I=",
|
||||
"lastModified": 1724556439,
|
||||
"narHash": "sha256-gPR3sxkKxISUvydnqoj54znpUkK8av/HVFuFJuYUw3w=",
|
||||
"owner": "pjones",
|
||||
"repo": "plasma-manager",
|
||||
"rev": "76dab4ba280ddd1b6c5aec0bb0aa0ace201c39ae",
|
||||
"rev": "5c97fe8af2a2e561f14195ed357d8c451fdbff4c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1220,11 +1237,11 @@
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723202784,
|
||||
"narHash": "sha256-qbhjc/NEGaDbyy0ucycubq4N3//gDFFH3DOmp1D3u1Q=",
|
||||
"lastModified": 1723803910,
|
||||
"narHash": "sha256-yezvUuFiEnCFbGuwj/bQcqg7RykIEqudOy/RBrId0pc=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "c7012d0c18567c889b948781bc74a501e92275d1",
|
||||
"rev": "bfef0ada09e2c8ac55bbcd0831bd0c9d42e651ba",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1240,11 +1257,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723036528,
|
||||
"narHash": "sha256-/w7Yv1c16nz9O8DQQsBUNWLaR1Y278g8ebHCTD8Wb1E=",
|
||||
"lastModified": 1724664864,
|
||||
"narHash": "sha256-VEaGrv5sGNIdN6eQADXH9GylMp7X7qKCfOBmX93lsik=",
|
||||
"owner": "Nix-QChem",
|
||||
"repo": "NixOS-QChem",
|
||||
"rev": "437d809ed9c6cdc4cee9b0e1d04ac6061f8f30f1",
|
||||
"rev": "7fcab915d585fd3c4261ec21585d4e9e117bc2c9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1267,9 +1284,9 @@
|
||||
"date": "date",
|
||||
"eigen": "eigen",
|
||||
"envfs": "envfs",
|
||||
"fcitx5-virtualkeyboard-ui": "fcitx5-virtualkeyboard-ui",
|
||||
"git-lfs-transfer": "git-lfs-transfer",
|
||||
"gricad": "gricad",
|
||||
"hextra": "hextra",
|
||||
"home-manager": "home-manager",
|
||||
"impermanence": "impermanence",
|
||||
"kylin-virtual-keyboard": "kylin-virtual-keyboard",
|
||||
@@ -1292,6 +1309,7 @@
|
||||
"nixpkgs-23.05": "nixpkgs-23.05",
|
||||
"nixpkgs-23.11": "nixpkgs-23.11",
|
||||
"nodesoup": "nodesoup",
|
||||
"nu-scripts": "nu-scripts",
|
||||
"nur-linyinfeng": "nur-linyinfeng",
|
||||
"nur-xddxdd": "nur-xddxdd",
|
||||
"openxlsx": "openxlsx",
|
||||
@@ -1312,11 +1330,11 @@
|
||||
"rsshub": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723692588,
|
||||
"narHash": "sha256-4z39e+om3z3Rcm66NmV5VUfbMueZ/iE+A51SvDf4I9c=",
|
||||
"lastModified": 1725304080,
|
||||
"narHash": "sha256-Hq64xQwl6r6bEwJHtQ745Bf8mjid8BfUlix7HRvGaU0=",
|
||||
"owner": "DIYgod",
|
||||
"repo": "RSSHub",
|
||||
"rev": "351578a8767f8faa06a26eeace168622503e7682",
|
||||
"rev": "b5ad2fa0cb08e4a718285de575a97b107152eea1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1328,11 +1346,11 @@
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723304838,
|
||||
"narHash": "sha256-xAxVDxuvCs8WWkrxVWjCiqxTkHhGj7sSppr1YMuEdT8=",
|
||||
"lastModified": 1724345276,
|
||||
"narHash": "sha256-MKvjkqVL/RJ3QXOA8tSUoK7HHXVGSB2AL+vKxU4Cf+c=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "0daeb5c0b05cfdf2101b0f078c27539099bf38e6",
|
||||
"rev": "9b724459b5900c2424f5069023d6596a8617284b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1345,11 +1363,11 @@
|
||||
"rycee": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723694590,
|
||||
"narHash": "sha256-7cufibbD4mf84wPBOTq0bNYjtUz5/Aq1azv9Nil5bzk=",
|
||||
"lastModified": 1724645012,
|
||||
"narHash": "sha256-XJ8B9ecksgZBlWV9pnDgBWVePyHDg/cLYJ/6YF/RdRA=",
|
||||
"owner": "rycee",
|
||||
"repo": "nur-expressions",
|
||||
"rev": "bc49bde3aa2e9408a22bf62d2faf4358508ce4b6",
|
||||
"rev": "70645c904b41b9ddf70f7218898c48df93e8254f",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
@@ -1416,11 +1434,11 @@
|
||||
"sqlite-orm": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1679666045,
|
||||
"narHash": "sha256-KqphGFcnR1Y11KqL7sxODSv7lEvcURdF6kLd3cg84kc=",
|
||||
"lastModified": 1724485979,
|
||||
"narHash": "sha256-jgRCYOtCyXj2E5J3iYBffX2AyBwvhune+i4Pb2eCBrA=",
|
||||
"owner": "fnc12",
|
||||
"repo": "sqlite_orm",
|
||||
"rev": "ff7c878af872f7987b62d825284fb25d6043af10",
|
||||
"rev": "6630268477b1df9d22a6a563c62aec2c91ee4249",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1555,11 +1573,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723454642,
|
||||
"narHash": "sha256-S0Gvsenh0II7EAaoc9158ZB4vYyuycvMGKGxIbERNAM=",
|
||||
"lastModified": 1724338379,
|
||||
"narHash": "sha256-kKJtaiU5Ou+e/0Qs7SICXF22DLx4V/WhG1P6+k4yeOE=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "349de7bc435bdff37785c2466f054ed1766173be",
|
||||
"rev": "070f834771efa715f3e74cd8ab93ecc96fabc951",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1576,11 +1594,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1723454642,
|
||||
"narHash": "sha256-S0Gvsenh0II7EAaoc9158ZB4vYyuycvMGKGxIbERNAM=",
|
||||
"lastModified": 1723808491,
|
||||
"narHash": "sha256-rhis3qNuGmJmYC/okT7Dkc4M8CeUuRCSvW6kC2f3hBc=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "349de7bc435bdff37785c2466f054ed1766173be",
|
||||
"rev": "1d07739554fdc4f8481068f1b11d6ab4c1a4167a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
22
flake.nix
22
flake.nix
@@ -61,12 +61,13 @@
|
||||
kylin-virtual-keyboard = { url = "git+https://gitee.com/openkylin/kylin-virtual-keyboard.git"; 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; };
|
||||
openxlsx = { url = "github:troldal/OpenXLSX?rev=f85f7f1bd632094b5d78d4d1f575955fc3801886"; flake = false; };
|
||||
sqlite-orm = { url = "github:fnc12/sqlite_orm"; flake = false; };
|
||||
sockpp = { url = "github:fpagliughi/sockpp"; flake = false; };
|
||||
git-lfs-transfer = { url = "github:charmbracelet/git-lfs-transfer"; flake = false; };
|
||||
nc4nix = { url = "github:helsinki-systems/nc4nix"; flake = false; };
|
||||
fcitx5-virtualkeyboard-ui = { url = "github:CHN-beta/fcitx5-virtualkeyboard-ui"; flake = false; };
|
||||
hextra = { url = "github:imfing/hextra"; flake = false; };
|
||||
nu-scripts = { url = "github:nushell/nu_scripts"; flake = false; };
|
||||
|
||||
# does not support lfs yet
|
||||
# nixos-wallpaper = { url = "git+https://git.chn.moe/chn/nixos-wallpaper.git"; flake = false; };
|
||||
@@ -112,6 +113,7 @@
|
||||
matplotplusplus = pkgs.pkgsStatic.localPackages.matplotplusplus.override { libtiff = null; };
|
||||
in pkgs.pkgsStatic.localPackages.ufo.override { inherit biu tbb matplotplusplus; };
|
||||
chn-bsub = pkgs.pkgsStatic.localPackages.chn-bsub;
|
||||
blog = pkgs.callPackage ./blog { inherit (inputs) hextra; };
|
||||
}
|
||||
// (builtins.listToAttrs (builtins.map
|
||||
(system:
|
||||
@@ -163,7 +165,7 @@
|
||||
config = { archive = false; branch = "production"; };
|
||||
devShells.x86_64-linux = let inherit (inputs.self.packages.x86_64-linux) pkgs; in
|
||||
{
|
||||
biu = pkgs.mkShell
|
||||
biu = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
|
||||
{
|
||||
inputsFrom = [ pkgs.localPackages.biu ];
|
||||
packages = [ pkgs.clang-tools_18 ];
|
||||
@@ -181,10 +183,10 @@
|
||||
packages = [ pkgs.clang-tools_18 ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
ufo = pkgs.mkShell
|
||||
ufo = pkgs.mkShell.override { stdenv = pkgs.gcc14Stdenv; }
|
||||
{
|
||||
inputsFrom = [ (inputs.self.packages.x86_64-linux.ufo.override { version = null; }) ];
|
||||
packages = [ pkgs.clang-tools_18 ];
|
||||
packages = [ pkgs.ccls ];
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
chn-bsub = pkgs.mkShell
|
||||
@@ -202,5 +204,15 @@
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS = "1";
|
||||
};
|
||||
};
|
||||
src = let inherit (inputs.self.packages.x86_64-linux) pkgs; in
|
||||
{
|
||||
nixos-wallpaper = pkgs.fetchgit
|
||||
{
|
||||
url = "https://git.chn.moe/chn/nixos-wallpaper.git";
|
||||
rev = "1ad78b20b21c9f4f7ba5f4c897f74276763317eb";
|
||||
sha256 = "0faahbzsr44bjmwr6508wi5hg59dfb57fzh5x6jh7zwmv4pzhqlb";
|
||||
fetchLFS = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
32
lib.nix
32
lib.nix
@@ -54,4 +54,36 @@ lib: rec
|
||||
else null
|
||||
else null)
|
||||
(attrsToList (builtins.readDir path))));
|
||||
|
||||
# replace the value in a nested attrset. example:
|
||||
# deepReplace
|
||||
# [ { path = [ "a" "b" 1 ]; value = "new value"; } ]
|
||||
# { a = { b = [ "old value" "old value" ]; }; }
|
||||
# => { a = { b = [ "old value" "new value" ]; }; }
|
||||
deepReplace = pattern: origin:
|
||||
let replace = { path, value, content }:
|
||||
if path == [] then
|
||||
if (builtins.typeOf value) == "lambda" then value content
|
||||
else value
|
||||
else let currentPath = builtins.head path; nextPath = builtins.tail path; in
|
||||
if (builtins.typeOf currentPath) == "string" then
|
||||
if (builtins.typeOf content) != "set" then builtins.throw "content should be a set"
|
||||
else builtins.mapAttrs
|
||||
(n: v: if n == currentPath then replace { path = nextPath; inherit value; content = v; } else v) content
|
||||
else if (builtins.typeOf currentPath) == "int" then
|
||||
if (builtins.typeOf content) != "list" then builtins.throw "content should be a list"
|
||||
else lib.imap0
|
||||
(i: v: if i == currentPath then replace { path = nextPath; inherit value; content = v; } else v) content
|
||||
else if (builtins.typeOf currentPath) != "lambda" then throw "path should be a lambda"
|
||||
else
|
||||
if (builtins.typeOf content) == "list" then builtins.map
|
||||
(v: if currentPath v then replace { path = nextPath; inherit value; content = v; } else v) content
|
||||
else if (builtins.typeOf content) == "set" then builtins.listToAttrs (builtins.map
|
||||
(v: if currentPath v then replace { path = nextPath; inherit value; content = v; } else v)
|
||||
(attrsToList content))
|
||||
else throw "content should be a list or a set.";
|
||||
in
|
||||
if (builtins.typeOf pattern) != "list" then throw "pattern should be a list"
|
||||
else if pattern == [] then origin
|
||||
else deepReplace (builtins.tail pattern) (replace ((builtins.head pattern) // { content = origin; }));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ inputs:
|
||||
# themes
|
||||
catppuccin catppuccin-sddm catppuccin-cursors catppuccinifier-gui catppuccinifier-cli catppuccin-plymouth
|
||||
(catppuccin-kde.override { flavour = [ "latte" ]; }) (catppuccin-kvantum.override { variant = "latte"; })
|
||||
klassy
|
||||
localPackages.slate localPackages.blurred-wallpaper tela-circle-icon-theme
|
||||
# terminal
|
||||
warp-terminal
|
||||
@@ -61,7 +62,7 @@ inputs:
|
||||
nix-template nil pnpm-lock-export bundix
|
||||
# instant messager
|
||||
element-desktop telegram-desktop discord fluffychat zoom-us signal-desktop slack nur-linyinfeng.wemeet
|
||||
cinny-desktop nheko # qq nur-xddxdd.wechat-uos
|
||||
nheko # qq nur-xddxdd.wechat-uos TODO: cinny-desktop
|
||||
# browser
|
||||
google-chrome tor-browser microsoft-edge
|
||||
# office
|
||||
@@ -77,6 +78,8 @@ inputs:
|
||||
wineWowPackages.stagingFull virt-viewer bottles genymotion
|
||||
# media
|
||||
nur-xddxdd.svp
|
||||
# for kdenlive auto subtitle
|
||||
openai-whisper
|
||||
]
|
||||
++ (builtins.filter (p: !((p.meta.broken or false) || (builtins.elem p.pname or null [ "falkon" "kalzium" ])))
|
||||
(builtins.filter inputs.lib.isDerivation (builtins.attrValues kdePackages.kdeGear)));
|
||||
@@ -92,15 +95,32 @@ inputs:
|
||||
[{
|
||||
config.programs =
|
||||
{
|
||||
plasma =
|
||||
plasma =
|
||||
{
|
||||
enable = true;
|
||||
configFile =
|
||||
{
|
||||
plasma-localerc = { Formats.LANG.value = "en_US.UTF-8"; Translations.LANGUAGE.value = "zh_CN"; };
|
||||
baloofilerc."Basic Settings".Indexing-Enabled.value = false;
|
||||
plasmarc.Wallpapers.usersWallpapers.value =
|
||||
let
|
||||
inherit (inputs.topInputs.self.src) nixos-wallpaper;
|
||||
isPicture = f: builtins.elem (inputs.lib.last (inputs.lib.splitString "." f))
|
||||
[ "png" "jpg" "jpeg" "webp" ];
|
||||
in builtins.concatStringsSep "," (builtins.map (f: "${nixos-wallpaper}/${f.name}")
|
||||
(builtins.filter (f: (isPicture f.name) && (f.value == "regular"))
|
||||
(inputs.localLib.attrsToList (builtins.readDir nixos-wallpaper))));
|
||||
};
|
||||
powerdevil = { AC.autoSuspend.action = "nothing"; battery.autoSuspend.action = "nothing"; };
|
||||
powerdevil =
|
||||
let config =
|
||||
{
|
||||
autoSuspend.action = "nothing";
|
||||
dimDisplay.enable = false;
|
||||
powerButtonAction = "turnOffScreen";
|
||||
turnOffDisplay.idleTimeout = "never";
|
||||
whenLaptopLidClosed = "turnOffScreen";
|
||||
};
|
||||
in { AC = config; battery = config; lowBattery = config; };
|
||||
};
|
||||
obs-studio =
|
||||
{
|
||||
|
||||
@@ -12,7 +12,63 @@ inputs:
|
||||
{
|
||||
enable = true;
|
||||
languagePacks = [ "zh-CN" "en-US" ];
|
||||
nativeMessagingHosts.packages = with inputs.pkgs; [ uget-integrator ];
|
||||
nativeMessagingHosts.packages = with inputs.pkgs; [ uget-integrator firefoxpwa ];
|
||||
};
|
||||
nixos =
|
||||
{
|
||||
packages.packages._packages = [ inputs.pkgs.firefoxpwa ];
|
||||
user.sharedModules =
|
||||
[{
|
||||
config =
|
||||
{
|
||||
programs.firefox =
|
||||
{
|
||||
enable = true;
|
||||
nativeMessagingHosts = with inputs.pkgs; [ plasma-browser-integration uget-integrator firefoxpwa ];
|
||||
# TODO: use fixed-version of plugins
|
||||
policies.DefaultDownloadDirectory = "\${home}/Downloads";
|
||||
profiles.default =
|
||||
{
|
||||
extensions = with inputs.pkgs.firefox-addons;
|
||||
[
|
||||
immersive-translate tampermonkey bitwarden cookies-txt dualsub firefox-color i-dont-care-about-cookies
|
||||
metamask pakkujs switchyomega rsshub-radar rsspreview tabliss tree-style-tab ublock-origin wallabagger
|
||||
wappalyzer grammarly plasma-integration zotero-connector
|
||||
(buildFirefoxXpiAddon
|
||||
{
|
||||
pname = "pwas-for-firefox";
|
||||
version = "2.12.1";
|
||||
addonId = "firefoxpwa@filips.si";
|
||||
url = "https://addons.mozilla.org/firefox/downloads/file/4293028/pwas_for_firefox-2.12.1.xpi";
|
||||
sha256 = "sha256-m8BCAlQt37RxVnWw+2hIPnmofTicNa5OWkwXp/IXdWY=";
|
||||
meta = {};
|
||||
})
|
||||
];
|
||||
search = { default = "Google"; force = true; };
|
||||
userChrome = builtins.readFile "${inputs.topInputs.lepton}/userChrome.css";
|
||||
userContent = builtins.readFile "${inputs.topInputs.lepton}/userContent.css";
|
||||
extraConfig = builtins.readFile "${inputs.topInputs.lepton}/user.js";
|
||||
settings =
|
||||
{
|
||||
# general
|
||||
"browser.search.region" = "CN";
|
||||
"intl.locale.requested" = "zh-CN,en-US";
|
||||
"browser.aboutConfig.showWarning" = false;
|
||||
"browser.bookmarks.showMobileBookmarks" = true;
|
||||
"browser.download.panel.shown" = true;
|
||||
"browser.download.useDownloadDir" = true;
|
||||
"browser.newtab.extensionControlled" = true;
|
||||
"browser.toolbars.bookmarks.visibility" = "never";
|
||||
# allow to apply userChrome.css
|
||||
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
|
||||
# automatically enable extensions
|
||||
"extensions.autoDisableScopes" = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
home.file.".mozilla/firefox/profiles.ini".force = true;
|
||||
};
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
51
modules/packages/nushell.nix
Normal file
51
modules/packages/nushell.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.packages.nushell = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = {};
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.packages) nushell; in inputs.lib.mkIf (nushell != null)
|
||||
{
|
||||
nixos =
|
||||
{
|
||||
packages.packages._packages = [ inputs.pkgs.nushell ];
|
||||
user.sharedModules =
|
||||
[{
|
||||
config.programs =
|
||||
{
|
||||
nushell =
|
||||
{
|
||||
enable = true;
|
||||
extraConfig =
|
||||
''
|
||||
source ${inputs.topInputs.nu-scripts}/aliases/git/git-aliases.nu
|
||||
$env.PATH = ($env.PATH | split row (char esep) | append "~/bin")
|
||||
'';
|
||||
};
|
||||
carapace.enable = true;
|
||||
oh-my-posh =
|
||||
{
|
||||
enable = true;
|
||||
enableZshIntegration = false;
|
||||
settings = inputs.localLib.deepReplace
|
||||
[
|
||||
{
|
||||
path = [ "blocks" 0 "segments" (v: v.type or "" == "path") "properties" "style" ];
|
||||
value = "powerlevel";
|
||||
}
|
||||
{
|
||||
path = [ "blocks" 0 "segments" (v: v.type or "" == "executiontime") "template" ];
|
||||
value = v: builtins.replaceStrings [ "⠀" ] [ " " ] v;
|
||||
}
|
||||
]
|
||||
(builtins.fromJSON (builtins.readFile
|
||||
"${inputs.pkgs.oh-my-posh}/share/oh-my-posh/themes/atomic.omp.json"));
|
||||
};
|
||||
zoxide.enable = true;
|
||||
direnv.enable = true;
|
||||
};
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -10,7 +10,7 @@ inputs:
|
||||
[
|
||||
# basic tools
|
||||
beep dos2unix gnugrep pv tmux screen parallel tldr cowsay jq zellij ipfetch localPackages.pslist
|
||||
fastfetch reptyr nushell duc ncdu progress libva-utils ksh neofetch
|
||||
fastfetch reptyr duc ncdu progress libva-utils ksh neofetch
|
||||
# lsxx
|
||||
pciutils usbutils lshw util-linux lsof dmidecode lm_sensors
|
||||
# top
|
||||
@@ -34,7 +34,7 @@ inputs:
|
||||
# nix tools
|
||||
nix-output-monitor nix-tree ssh-to-age (callPackage "${inputs.topInputs.nix-fast-build}" {}) nix-inspect
|
||||
# development
|
||||
gdb try inputs.topInputs.plasma-manager.packages.${inputs.pkgs.system}.rc2nix rr hexo-cli gh nix-init
|
||||
gdb try inputs.topInputs.plasma-manager.packages.${inputs.pkgs.system}.rc2nix rr hexo-cli gh nix-init hugo
|
||||
# stupid things
|
||||
toilet lolcat
|
||||
# office
|
||||
@@ -44,7 +44,7 @@ inputs:
|
||||
++ (inputs.lib.optional (inputs.config.nixos.system.nixpkgs.arch == "x86_64") rar);
|
||||
_pythonPackages = [(pythonPackages: with pythonPackages;
|
||||
[
|
||||
openai python-telegram-bot fastapi pypdf2 pandas matplotlib plotly gunicorn redis jinja2
|
||||
openai python-telegram-bot fastapi-cli pypdf2 pandas matplotlib plotly gunicorn redis jinja2
|
||||
certifi charset-normalizer idna orjson psycopg2 inquirerpy requests tqdm pydbus
|
||||
])];
|
||||
};
|
||||
@@ -64,5 +64,8 @@ inputs:
|
||||
fwupd.enable = true;
|
||||
};
|
||||
home-manager = { useGlobalPkgs = true; useUserPackages = true; };
|
||||
# allow everyone run compsize
|
||||
security.wrappers.compsize =
|
||||
{ setuid = true; owner = "root"; group = "root"; source = "${inputs.pkgs.compsize}/bin/compsize"; };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ inputs:
|
||||
vps7 =
|
||||
{
|
||||
ed25519 = "AAAAC3NzaC1lZDI1NTE5AAAAIF5XkdilejDAlg5hZZD0oq69k8fQpe9hIJylTo/aLRgY";
|
||||
hostnames = [ "vps7.chn.moe" "wireguard.vps7.chn.moe" "ssh.git.chn.moe" "95.111.228.40" "192.168.83.2" ];
|
||||
hostnames = [ "vps7.chn.moe" "wireguard.vps7.chn.moe" "ssh.git.chn.moe" "144.126.144.62" "192.168.83.2" ];
|
||||
};
|
||||
"initrd.vps7" =
|
||||
{
|
||||
ed25519 = "AAAAC3NzaC1lZDI1NTE5AAAAIGZyQpdQmEZw3nLERFmk2tS1gpSvXwW0Eish9UfhrRxC";
|
||||
hostnames = [ "initrd.vps7.chn.moe" "95.111.228.40" ];
|
||||
hostnames = [ "initrd.vps7.chn.moe" "144.126.144.62" ];
|
||||
};
|
||||
nas =
|
||||
{
|
||||
|
||||
@@ -43,6 +43,7 @@ inputs:
|
||||
SMTP_PORT = 465;
|
||||
USER = "bot@chn.moe";
|
||||
};
|
||||
service.REGISTER_MANUAL_CONFIRM = true;
|
||||
};
|
||||
};
|
||||
nixos.services =
|
||||
|
||||
@@ -4,7 +4,11 @@ inputs:
|
||||
{
|
||||
type = types.nullOr (types.submodule { options =
|
||||
{
|
||||
users = mkOption { type = types.listOf types.nonEmptyStr; default = [ "chn" "gb" "xll" "yjq" "zem" ]; };
|
||||
users = mkOption
|
||||
{
|
||||
type = types.listOf types.nonEmptyStr;
|
||||
default = [ "chn" "gb" "xll" "yjq" "zem" "gb" "wp" "hjp" ];
|
||||
};
|
||||
};});
|
||||
default = null;
|
||||
};
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
inputs:
|
||||
{
|
||||
options.nixos.services.nginx.applications.blog = let inherit (inputs.lib) mkOption types; in
|
||||
options.nixos.services.nginx.applications.blog = let inherit (inputs.lib) mkOption types; in mkOption
|
||||
{
|
||||
enable = mkOption { type = types.bool; default = false; };
|
||||
type = types.nullOr (types.submodule {});
|
||||
default = null;
|
||||
};
|
||||
config =
|
||||
let
|
||||
inherit (inputs.config.nixos.services.nginx.applications) blog;
|
||||
inherit (inputs.lib) mkIf;
|
||||
in mkIf blog.enable
|
||||
config = let inherit (inputs.config.nixos.services.nginx.applications) blog; in inputs.lib.mkIf (blog != null)
|
||||
{
|
||||
nixos.services.nginx.https."blog.chn.moe".location."/".static =
|
||||
{ root = "/srv/blog"; index = [ "index.html" ]; };
|
||||
systemd.tmpfiles.rules = [ "d /srv/blog 0700 nginx nginx" "Z /srv/blog - nginx nginx" ];
|
||||
{ root = builtins.toString inputs.topInputs.self.packages.x86_64-linux.blog; index = [ "index.html" ]; };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ inputs:
|
||||
settings =
|
||||
{
|
||||
unix_socket_permissions = "0700";
|
||||
shared_buffers = "8192MB";
|
||||
shared_buffers = "512MB";
|
||||
work_mem = "512MB";
|
||||
autovacuum = "on";
|
||||
};
|
||||
|
||||
@@ -13,22 +13,27 @@ inputs:
|
||||
inherit (builtins) map listToAttrs toString;
|
||||
in mkIf rsshub.enable
|
||||
{
|
||||
systemd.services.rsshub =
|
||||
systemd =
|
||||
{
|
||||
description = "rsshub";
|
||||
after = [ "network.target" "redis-rsshub.service" ];
|
||||
requires = [ "redis-rsshub.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig =
|
||||
services.rsshub =
|
||||
{
|
||||
User = inputs.config.users.users.rsshub.name;
|
||||
Group = inputs.config.users.users.rsshub.group;
|
||||
EnvironmentFile = inputs.config.sops.templates."rsshub/env".path;
|
||||
WorkingDirectory = "${inputs.pkgs.localPackages.rsshub}";
|
||||
ExecStart = "${inputs.pkgs.localPackages.rsshub}/bin/rsshub";
|
||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||
description = "rsshub";
|
||||
after = [ "network.target" "redis-rsshub.service" ];
|
||||
requires = [ "redis-rsshub.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig =
|
||||
{
|
||||
User = inputs.config.users.users.rsshub.name;
|
||||
Group = inputs.config.users.users.rsshub.group;
|
||||
EnvironmentFile = inputs.config.sops.templates."rsshub/env".path;
|
||||
WorkingDirectory = "${inputs.pkgs.localPackages.rsshub}";
|
||||
ExecStart = "${inputs.pkgs.localPackages.rsshub}/bin/rsshub";
|
||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||
};
|
||||
restartTriggers = [ inputs.config.sops.templates."rsshub/env".content ];
|
||||
};
|
||||
tmpfiles.rules = [ "d /var/cache/rsshub 0700 rsshub rsshub" ];
|
||||
};
|
||||
sops =
|
||||
{
|
||||
@@ -46,11 +51,17 @@ inputs:
|
||||
YOUTUBE_CLIENT_ID='${placeholder."rsshub/youtube-client-id"}'
|
||||
YOUTUBE_CLIENT_SECRET='${placeholder."rsshub/youtube-client-secret"}'
|
||||
YOUTUBE_REFRESH_TOKEN='${placeholder."rsshub/youtube-refresh-token"}'
|
||||
TWITTER_AUTH_TOKEN='${placeholder."rsshub/twitter-auth-token"}'
|
||||
XDG_CONFIG_HOME='/var/cache/rsshub/chromium'
|
||||
XDG_CACHE_HOME='/var/cache/rsshub/chromium'
|
||||
BILIBILI_COOKIE_data0='${placeholder."rsshub/bilibili-cookie"}'
|
||||
'';
|
||||
secrets = (listToAttrs (map (secret: { name = "rsshub/${secret}"; value = {}; })
|
||||
[
|
||||
"pixiv-refreshtoken"
|
||||
"youtube-key" "youtube-client-id" "youtube-client-secret" "youtube-refresh-token"
|
||||
"twitter-auth-token"
|
||||
"bilibili-cookie"
|
||||
]));
|
||||
};
|
||||
users =
|
||||
|
||||
@@ -83,6 +83,9 @@ inputs:
|
||||
SchedulerParameters=enable_user_top
|
||||
|
||||
SlurmdDebug=debug2
|
||||
|
||||
# automatically resume node after drain
|
||||
ReturnToService=2
|
||||
'';
|
||||
extraConfigPaths =
|
||||
let gpuString = builtins.concatStringsSep "\n" (builtins.map
|
||||
|
||||
@@ -192,6 +192,7 @@ inputs:
|
||||
admin_contact = "mailto:chn@chn.moe";
|
||||
enable_registration = true;
|
||||
registrations_require_3pid = [ "email" ];
|
||||
registration_requires_token = true;
|
||||
turn_uris = [ "turns:coturn.chn.moe" "turn:coturn.chn.moe" ];
|
||||
max_upload_size = "1024M";
|
||||
web_client_location = "https://element.chn.moe/";
|
||||
|
||||
@@ -5,7 +5,6 @@ inputs:
|
||||
enable = mkOption { type = types.bool; default = false; };
|
||||
preferred = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.enable; };
|
||||
autoStart = mkOption { type = types.bool; default = inputs.config.nixos.system.gui.preferred; };
|
||||
touchscreen = mkOption { type = types.bool; default = false; };
|
||||
};
|
||||
config = let inherit (inputs.config.nixos.system) gui; in inputs.lib.mkIf gui.enable
|
||||
{
|
||||
@@ -39,13 +38,9 @@ inputs:
|
||||
{
|
||||
enable = true;
|
||||
type = "fcitx5";
|
||||
fcitx5.addons = (builtins.map (p: inputs.pkgs."fcitx5-${p}")
|
||||
[ "rime" "chinese-addons" "mozc" "nord" "material-color" ])
|
||||
++ inputs.lib.mkIf gui.touchscreen (inputs.pkgs.localPackages.fcitx5-virtualkeyboard-ui);
|
||||
fcitx5.addons = builtins.map (p: inputs.pkgs."fcitx5-${p}")
|
||||
[ "rime" "chinese-addons" "mozc" "nord" "material-color" ];
|
||||
};
|
||||
programs.dconf.enable = true;
|
||||
nixpkgs.overlays = inputs.lib.mkIf gui.touchscreen
|
||||
[(final: prev: { fcitx5 = prev.fcitx5.overrideAttrs (prev:
|
||||
{ patches = prev.patches or [] ++ [ ./fcitx5.patch ]; });})];
|
||||
};
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
From 5662218e904bc245c47ce4b33f04c2e3a74c7d92 Mon Sep 17 00:00:00 2001
|
||||
From: Daijiro Fukuda <fukuda@clear-code.com>
|
||||
Date: Mon, 28 Feb 2022 15:08:40 +0900
|
||||
Subject: [PATCH 1/3] Add simple group enumerating function for addons (#452)
|
||||
|
||||
---
|
||||
src/lib/fcitx/inputmethodmanager.cpp | 22 ++++++++++++++++++++++
|
||||
src/lib/fcitx/inputmethodmanager.h | 3 +++
|
||||
2 files changed, 25 insertions(+)
|
||||
|
||||
diff --git a/src/lib/fcitx/inputmethodmanager.cpp b/src/lib/fcitx/inputmethodmanager.cpp
|
||||
index 6e842ee07..e2e0d6184 100644
|
||||
--- a/src/lib/fcitx/inputmethodmanager.cpp
|
||||
+++ b/src/lib/fcitx/inputmethodmanager.cpp
|
||||
@@ -276,6 +276,28 @@ const InputMethodGroup &InputMethodManager::currentGroup() const {
|
||||
return d->groups_.find(d->groupOrder_.front())->second;
|
||||
}
|
||||
|
||||
+void InputMethodManager::enumerateGroup(bool forward) {
|
||||
+ FCITX_D();
|
||||
+ if (groupCount() < 2) {
|
||||
+ return;
|
||||
+ }
|
||||
+ emit<InputMethodManager::CurrentGroupAboutToChange>(d->groupOrder_.front());
|
||||
+ if (forward) {
|
||||
+ d->groupOrder_.splice(
|
||||
+ d->groupOrder_.end(),
|
||||
+ d->groupOrder_,
|
||||
+ d->groupOrder_.begin()
|
||||
+ );
|
||||
+ } else {
|
||||
+ d->groupOrder_.splice(
|
||||
+ d->groupOrder_.begin(),
|
||||
+ d->groupOrder_,
|
||||
+ std::prev(d->groupOrder_.end())
|
||||
+ );
|
||||
+ }
|
||||
+ emit<InputMethodManager::CurrentGroupChanged>(d->groupOrder_.front());
|
||||
+}
|
||||
+
|
||||
void InputMethodManager::setDefaultInputMethod(const std::string &name) {
|
||||
FCITX_D();
|
||||
auto ¤tGroup = d->groups_.find(d->groupOrder_.front())->second;
|
||||
diff --git a/src/lib/fcitx/inputmethodmanager.h b/src/lib/fcitx/inputmethodmanager.h
|
||||
index 0069c4108..0be42630d 100644
|
||||
--- a/src/lib/fcitx/inputmethodmanager.h
|
||||
+++ b/src/lib/fcitx/inputmethodmanager.h
|
||||
@@ -84,6 +84,9 @@ class FCITXCORE_EXPORT InputMethodManager : public ConnectableObject {
|
||||
/// Return the current group.
|
||||
const InputMethodGroup ¤tGroup() const;
|
||||
|
||||
+ /// Simply enumerate input method groups.
|
||||
+ void enumerateGroup(bool forward);
|
||||
+
|
||||
/**
|
||||
* Set default input method for current group.
|
||||
*
|
||||
|
||||
From 3891b04380a5dd36b48af753b85c81472e6c03a4 Mon Sep 17 00:00:00 2001
|
||||
From: Takuro Ashie <ashie@clear-code.com>
|
||||
Date: Mon, 7 Mar 2022 12:09:34 +0900
|
||||
Subject: [PATCH 2/3] Make sure to show UI on activate
|
||||
|
||||
---
|
||||
src/frontend/waylandim/waylandimserver.cpp | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/src/frontend/waylandim/waylandimserver.cpp b/src/frontend/waylandim/waylandimserver.cpp
|
||||
index 58a4b713f..abbe3d8a4 100644
|
||||
--- a/src/frontend/waylandim/waylandimserver.cpp
|
||||
+++ b/src/frontend/waylandim/waylandimserver.cpp
|
||||
@@ -168,6 +168,7 @@ void WaylandIMInputContextV1::activate(wayland::ZwpInputMethodContextV1 *ic) {
|
||||
ic_->modifiersMap(&array);
|
||||
wl_array_release(&array);
|
||||
focusIn();
|
||||
+ updateUserInterface(UserInterfaceComponent::InputPanel);
|
||||
}
|
||||
|
||||
void WaylandIMInputContextV1::deactivate(wayland::ZwpInputMethodContextV1 *ic) {
|
||||
|
||||
From 861f59bd40916936daeac796fc74844a43f11aaa Mon Sep 17 00:00:00 2001
|
||||
From: daipom <fukuda@clear-code.com>
|
||||
Date: Fri, 14 Jan 2022 11:24:42 +0900
|
||||
Subject: [PATCH 3/3] Add function to handle virtual key events to InputContext
|
||||
|
||||
We can use `InputContext::virtualKeyEvent` to handle KeyEvents the same
|
||||
way as physical key events.
|
||||
---
|
||||
src/frontend/waylandim/waylandimserver.cpp | 41 +++++++++++++++++++---
|
||||
src/frontend/waylandim/waylandimserver.h | 2 ++
|
||||
src/lib/fcitx/inputcontext.cpp | 18 ++++++++++
|
||||
src/lib/fcitx/inputcontext.h | 13 +++++++
|
||||
4 files changed, 70 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/frontend/waylandim/waylandimserver.cpp b/src/frontend/waylandim/waylandimserver.cpp
|
||||
index abbe3d8a4..87bd3da33 100644
|
||||
--- a/src/frontend/waylandim/waylandimserver.cpp
|
||||
+++ b/src/frontend/waylandim/waylandimserver.cpp
|
||||
@@ -413,13 +413,44 @@ void WaylandIMInputContextV1::keyCallback(uint32_t serial, uint32_t time,
|
||||
server_->modifiers_, code),
|
||||
state == WL_KEYBOARD_KEY_STATE_RELEASED, time);
|
||||
|
||||
- if (state == WL_KEYBOARD_KEY_STATE_RELEASED && key == repeatKey_) {
|
||||
+ processKeyEvent(event, false, serial);
|
||||
+}
|
||||
+
|
||||
+void WaylandIMInputContextV1::virtualKeyEventImpl(KeyEvent &event) {
|
||||
+ // `mods_locked` value seems to be 16 usually.
|
||||
+ // It will be 18 with the capslocked state,
|
||||
+ // but we don't have to consider about it in virtual key process.
|
||||
+ if (event.rawKey().hasModifier()) {
|
||||
+ if (event.rawKey().states().test(KeyState::Shift)) {
|
||||
+ modifiersCallback(serial_, (uint32_t)KeyState::Shift, 0, 16, 0);
|
||||
+ }
|
||||
+ } else {
|
||||
+ modifiersCallback(serial_, 0, 0, 16, 0);
|
||||
+ }
|
||||
+
|
||||
+ processKeyEvent(event, true, serial_);
|
||||
+}
|
||||
+
|
||||
+void WaylandIMInputContextV1::processKeyEvent(KeyEvent &event,
|
||||
+ bool isVirtualKey,
|
||||
+ uint32_t serial) {
|
||||
+ const uint32_t key = event.rawKey().code() > 8 ? event.rawKey().code() - 8
|
||||
+ : 0;
|
||||
+ const auto state = event.isRelease() ? WL_KEYBOARD_KEY_STATE_RELEASED
|
||||
+ : WL_KEYBOARD_KEY_STATE_PRESSED;
|
||||
+
|
||||
+ const auto cancelRepeat = isVirtualKey
|
||||
+ ? (state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||
+ // Strict condition for physical keys.
|
||||
+ : (state == WL_KEYBOARD_KEY_STATE_RELEASED && key == repeatKey_);
|
||||
+
|
||||
+ if (cancelRepeat) {
|
||||
timeEvent_->setEnabled(false);
|
||||
} else if (state == WL_KEYBOARD_KEY_STATE_PRESSED &&
|
||||
- xkb_keymap_key_repeats(server_->keymap_.get(), code)) {
|
||||
+ xkb_keymap_key_repeats(server_->keymap_.get(), event.rawKey().code())) {
|
||||
if (repeatRate_) {
|
||||
repeatKey_ = key;
|
||||
- repeatTime_ = time;
|
||||
+ repeatTime_ = event.time();
|
||||
repeatSym_ = event.rawKey().sym();
|
||||
// Let's trick the key event system by fake our first.
|
||||
// Remove 100 from the initial interval.
|
||||
@@ -430,11 +461,13 @@ void WaylandIMInputContextV1::keyCallback(uint32_t serial, uint32_t time,
|
||||
|
||||
WAYLANDIM_DEBUG() << event.key().toString()
|
||||
<< " IsRelease=" << event.isRelease();
|
||||
+
|
||||
if (!keyEvent(event)) {
|
||||
- ic_->key(serial, time, key, state);
|
||||
+ ic_->key(serial, event.time(), key, state);
|
||||
}
|
||||
server_->display_->flush();
|
||||
}
|
||||
+
|
||||
void WaylandIMInputContextV1::modifiersCallback(uint32_t serial,
|
||||
uint32_t mods_depressed,
|
||||
uint32_t mods_latched,
|
||||
diff --git a/src/frontend/waylandim/waylandimserver.h b/src/frontend/waylandim/waylandimserver.h
|
||||
index 1ffed14db..3b7871a2f 100644
|
||||
--- a/src/frontend/waylandim/waylandimserver.h
|
||||
+++ b/src/frontend/waylandim/waylandimserver.h
|
||||
@@ -84,6 +84,7 @@ class WaylandIMInputContextV1 : public InputContext {
|
||||
void deactivate(wayland::ZwpInputMethodContextV1 *id);
|
||||
|
||||
protected:
|
||||
+ void virtualKeyEventImpl(KeyEvent &event) override;
|
||||
void commitStringImpl(const std::string &text) override {
|
||||
if (!ic_) {
|
||||
return;
|
||||
@@ -120,6 +121,7 @@ class WaylandIMInputContextV1 : public InputContext {
|
||||
void keymapCallback(uint32_t format, int32_t fd, uint32_t size);
|
||||
void keyCallback(uint32_t serial, uint32_t time, uint32_t key,
|
||||
uint32_t state);
|
||||
+ void processKeyEvent(KeyEvent &event, bool isVirtualKey, uint32_t serial);
|
||||
void modifiersCallback(uint32_t serial, uint32_t mods_depressed,
|
||||
uint32_t mods_latched, uint32_t mods_locked,
|
||||
uint32_t group);
|
||||
diff --git a/src/lib/fcitx/inputcontext.cpp b/src/lib/fcitx/inputcontext.cpp
|
||||
index e6138036f..1fdc16358 100644
|
||||
--- a/src/lib/fcitx/inputcontext.cpp
|
||||
+++ b/src/lib/fcitx/inputcontext.cpp
|
||||
@@ -243,6 +243,19 @@ bool InputContext::keyEvent(KeyEvent &event) {
|
||||
return result;
|
||||
}
|
||||
|
||||
+void InputContext::virtualKeyEvent(KeyEvent &event) {
|
||||
+ decltype(std::chrono::steady_clock::now()) start;
|
||||
+ // Don't query time if we don't want log.
|
||||
+ if (::keyTrace().checkLogLevel(LogLevel::Debug)) {
|
||||
+ start = std::chrono::steady_clock::now();
|
||||
+ }
|
||||
+ virtualKeyEventImpl(event);
|
||||
+ FCITX_KEYTRACE() << "KeyEvent handling time: "
|
||||
+ << std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
+ std::chrono::steady_clock::now() - start)
|
||||
+ .count();
|
||||
+}
|
||||
+
|
||||
void InputContext::invokeAction(InvokeActionEvent &event) {
|
||||
FCITX_D();
|
||||
RETURN_IF_HAS_NO_FOCUS();
|
||||
@@ -333,6 +346,11 @@ StatusArea &InputContext::statusArea() {
|
||||
return d->statusArea_;
|
||||
}
|
||||
|
||||
+void InputContext::virtualKeyEventImpl(KeyEvent &event) {
|
||||
+ FCITX_D();
|
||||
+ d->postEvent(event);
|
||||
+}
|
||||
+
|
||||
void InputContext::updateClientSideUIImpl() {}
|
||||
|
||||
InputContextEventBlocker::InputContextEventBlocker(InputContext *inputContext)
|
||||
diff --git a/src/lib/fcitx/inputcontext.h b/src/lib/fcitx/inputcontext.h
|
||||
index 58363b506..8e56f7628 100644
|
||||
--- a/src/lib/fcitx/inputcontext.h
|
||||
+++ b/src/lib/fcitx/inputcontext.h
|
||||
@@ -133,6 +133,10 @@ class FCITXCORE_EXPORT InputContext : public TrackableObject<InputContext> {
|
||||
/// Send a key event to current input context.
|
||||
bool keyEvent(KeyEvent &event);
|
||||
|
||||
+ /// Send a virtual key event to current input context.
|
||||
+ /// This handles the event the same way as physical key events.
|
||||
+ void virtualKeyEvent(KeyEvent &event);
|
||||
+
|
||||
/// Returns whether the input context holds the input focus. Input context
|
||||
/// need to have focus.
|
||||
bool hasFocus() const;
|
||||
@@ -253,6 +257,15 @@ class FCITXCORE_EXPORT InputContext : public TrackableObject<InputContext> {
|
||||
void updateProperty(const InputContextPropertyFactory *factory);
|
||||
|
||||
protected:
|
||||
+ /**
|
||||
+ * Process the virtual key event.
|
||||
+ *
|
||||
+ * @param event KeyEvent
|
||||
+ *
|
||||
+ * @see virtualKeyEvent
|
||||
+ */
|
||||
+ virtual void virtualKeyEventImpl(KeyEvent &event);
|
||||
+
|
||||
/**
|
||||
* Send the committed string to client
|
||||
*
|
||||
@@ -33,7 +33,8 @@ inputs:
|
||||
# resolved does not work in initrd, causing network.target to fail
|
||||
services.resolved.enable = false;
|
||||
};
|
||||
kernelParams = [ "ip=dhcp" ];
|
||||
# ip=dhcp only attain ipv4
|
||||
kernelParams = [ "ip=on" ];
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
@@ -128,11 +128,6 @@ inputs:
|
||||
let version = inputs.lib.versions.majorMinor inputs.config.boot.kernelPackages.kernel.version;
|
||||
in ./hibernate-progress-${version}.patch;
|
||||
}];
|
||||
amdgpu =
|
||||
[{
|
||||
name = "amdgpu";
|
||||
patch = ./0001-drm-amdgpu-sdma5.2-limit-wptr-workaround-to-sdma-5.2.patch;
|
||||
}];
|
||||
# TODO: remove in 6.11
|
||||
btrfs =
|
||||
[{
|
||||
@@ -141,6 +136,11 @@ inputs:
|
||||
let version = inputs.lib.versions.majorMinor inputs.config.boot.kernelPackages.kernel.version;
|
||||
in if version == "6.10" then ./btrfs.patch else null;
|
||||
}];
|
||||
amdgpu =
|
||||
[{
|
||||
name = "amdgpu";
|
||||
patch = ./0001-drm-amdgpu-sdma5.2-limit-wptr-workaround-to-sdma-5.2.patch;
|
||||
}];
|
||||
};
|
||||
in builtins.concatLists (builtins.map (name: patches.${name}) (kernel.patches ++ [ "btrfs" ]));
|
||||
};
|
||||
|
||||
@@ -104,6 +104,8 @@ inputs:
|
||||
networkmanager.unmanaged = with networking.networkd; dhcp ++ (builtins.attrNames static);
|
||||
useNetworkd = true;
|
||||
};
|
||||
# dnsable dns fallback, use provided dns servers or no dns
|
||||
services.resolved.fallbackDns = [];
|
||||
})
|
||||
# wpa_supplicant
|
||||
(inputs.lib.mkIf (networking.wireless != [])
|
||||
|
||||
@@ -23,7 +23,7 @@ inputs:
|
||||
nixpkgs =
|
||||
let
|
||||
permittedInsecurePackages =
|
||||
[ "openssl_1_1" "python2" "zotero" "electron_27" "electron_28" ];
|
||||
[ "openssl_1_1" "python2" "zotero" "electron_27" "electron_28" "olm" "fluffychat" ];
|
||||
hostPlatform = if nixpkgs.march != null
|
||||
then { system = "${nixpkgs.arch}-linux"; gcc = { arch = nixpkgs.march; tune = nixpkgs.march; }; }
|
||||
else "${nixpkgs.arch}-linux";
|
||||
|
||||
@@ -8,7 +8,8 @@ inputs:
|
||||
extraGroups = inputs.lib.intersectLists
|
||||
[ "adbusers" "networkmanager" "wheel" "wireshark" "libvirtd" "ipfs" ]
|
||||
(builtins.attrNames inputs.config.users.groups);
|
||||
autoSubUidGidRange = true;
|
||||
subUidRanges = [{ startUid = 100000; count = 65536; } ];
|
||||
subGidRanges = [{ startGid = 100000; count = 65536; } ];
|
||||
hashedPassword = "$y$j9T$xJwVBoGENJEDSesJ0LfkU1$VEExaw7UZtFyB4VY1yirJvl7qS7oiF49KbEBrV0.hhC";
|
||||
};
|
||||
home-manager.users.chn =
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
inputs:
|
||||
{
|
||||
config = inputs.lib.mkIf (inputs.config.nixos.packages.firefox != null)
|
||||
{
|
||||
home-manager.users.chn.config =
|
||||
{
|
||||
programs.firefox =
|
||||
{
|
||||
enable = true;
|
||||
nativeMessagingHosts = [ inputs.pkgs.plasma-browser-integration ];
|
||||
# TODO: switch to chromium as default browser
|
||||
# TODO: use fixed-version of plugins
|
||||
policies.DefaultDownloadDirectory = "\${home}/Downloads";
|
||||
profiles.default =
|
||||
{
|
||||
extensions = with inputs.pkgs.firefox-addons;
|
||||
[
|
||||
immersive-translate tampermonkey bitwarden cookies-txt dualsub firefox-color i-dont-care-about-cookies
|
||||
metamask pakkujs switchyomega rsshub-radar rsspreview tabliss tree-style-tab ublock-origin wallabagger
|
||||
wappalyzer grammarly plasma-integration zotero-connector
|
||||
];
|
||||
search = { default = "Google"; force = true; };
|
||||
userChrome = builtins.readFile "${inputs.topInputs.lepton}/userChrome.css";
|
||||
userContent = builtins.readFile "${inputs.topInputs.lepton}/userContent.css";
|
||||
extraConfig = builtins.readFile "${inputs.topInputs.lepton}/user.js";
|
||||
settings =
|
||||
{
|
||||
# general
|
||||
"browser.search.region" = "CN";
|
||||
"intl.locale.requested" = "zh-CN,en-US";
|
||||
"browser.aboutConfig.showWarning" = false;
|
||||
"browser.bookmarks.showMobileBookmarks" = true;
|
||||
"browser.download.panel.shown" = true;
|
||||
"browser.download.useDownloadDir" = true;
|
||||
"browser.newtab.extensionControlled" = true;
|
||||
"browser.toolbars.bookmarks.visibility" = "never";
|
||||
# allow to apply userChrome.css
|
||||
"toolkit.legacyUserProfileCustomizations.stylesheets" = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
home.file.".mozilla/firefox/profiles.ini".force = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOH3AvxMlB3omzH6SFQt0Z5+f05x9nMJpFfSLH4OIYV+ chn@pc
|
||||
@@ -68,10 +68,7 @@ inputs:
|
||||
(builtins.readFile "${inputs.pkgs.konsole}/share/konsole/Breeze.colorscheme");
|
||||
};
|
||||
environment.persistence =
|
||||
let impermanence = inputs.config.nixos.system.impermanence;
|
||||
in inputs.lib.mkIf impermanence.enable (inputs.lib.mkMerge (builtins.map
|
||||
(user:
|
||||
{ "${impermanence.root}".users.${user}.directories = [ ".local/share/konsole" ".local/share/yakuake" ]; })
|
||||
inputs.config.nixos.user.users));
|
||||
let impermanence = inputs.config.nixos.system.impermanence; in inputs.lib.mkIf impermanence.enable
|
||||
{ "${impermanence.root}".users.chn.directories = [ ".local/share/konsole" ".local/share/yakuake" ]; };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,29 +4,31 @@ inputs:
|
||||
{
|
||||
home-manager.users.chn.config =
|
||||
{
|
||||
home.file.".config/Kvantum/catppuccin-latte-blue#/catppuccin-latte-blue#.kvconfig".source =
|
||||
./catppuccin-latte-blue.kvconfig;
|
||||
programs.plasma =
|
||||
{
|
||||
workspace =
|
||||
{
|
||||
theme = "breeze-light";
|
||||
colorScheme = "CatppuccinLatteBlue";
|
||||
colorScheme = "BreezeLight";
|
||||
cursor.theme = "breeze_cursors";
|
||||
lookAndFeel = "Catppuccin-Latte-Blue";
|
||||
lookAndFeel = "org.kde.klassylighttraditional.desktop";
|
||||
# ~/.config/kdeglobals [Icons]
|
||||
iconTheme = "Tela-circle";
|
||||
iconTheme = "klassy";
|
||||
};
|
||||
configFile =
|
||||
{
|
||||
kdeglobals.KDE.widgetStyle.value = "kvantum";
|
||||
"Kvantum/kvantum.kvconfig".General.theme.value = "catppuccin-latte-blue#";
|
||||
kwinrc =
|
||||
{
|
||||
Effect-blur.BlurStrength.value = 10;
|
||||
Effect-kwin4_effect_translucency.MoveResize.value = 75;
|
||||
Effect-wobblywindows =
|
||||
{ AdvancedMode.value = true; Drag.value = 85; Stiffness.value = 10; WobblynessLevel.value = 1; };
|
||||
{
|
||||
AdvancedMode.value = true;
|
||||
Drag.value = 85;
|
||||
Stiffness.value = 10;
|
||||
WobblynessLevel.value = 1;
|
||||
ResizeWobble.value = false;
|
||||
};
|
||||
Plugins =
|
||||
{
|
||||
blurEnabled.value = true;
|
||||
@@ -1,466 +0,0 @@
|
||||
[%General]
|
||||
author=elkrien based on Arc Dark style
|
||||
comment=Catppuccin-Latte-Blue
|
||||
spread_menuitems=true
|
||||
left_tabs=true
|
||||
mirror_doc_tabs=true
|
||||
scroll_width=8
|
||||
attach_active_tab=true
|
||||
composite=true
|
||||
menu_shadow_depth=7
|
||||
tooltip_shadow_depth=0
|
||||
splitter_width=7
|
||||
check_size=16
|
||||
slider_width=4
|
||||
slider_handle_width=18
|
||||
slider_handle_length=18
|
||||
textless_progressbar=false
|
||||
menubar_mouse_tracking=true
|
||||
slim_toolbars=false
|
||||
toolbutton_style=1
|
||||
x11drag=menubar_and_primary_toolbar
|
||||
double_click=false
|
||||
translucent_windows=true
|
||||
blurring=true
|
||||
popup_blurring=true
|
||||
opaque=kaffeine,kmplayer,subtitlecomposer,kdenlive,vlc,smplayer,smplayer2,avidemux,avidemux2_qt4,avidemux3_qt4,avidemux3_qt5,kamoso,QtCreator,VirtualBox,trojita,dragon,digikam,qmplay2
|
||||
group_toolbar_buttons=false
|
||||
vertical_spin_indicators=false
|
||||
fill_rubberband=false
|
||||
spread_progressbar=true
|
||||
merge_menubar_with_toolbar=true
|
||||
small_icon_size=16
|
||||
large_icon_size=32
|
||||
button_icon_size=16
|
||||
scroll_arrows=false
|
||||
iconless_pushbutton=true
|
||||
toolbar_icon_size=16
|
||||
combo_as_lineedit=true
|
||||
button_contents_shift=false
|
||||
groupbox_top_label=true
|
||||
inline_spin_indicators=true
|
||||
joined_inactive_tabs=false
|
||||
layout_spacing=2
|
||||
submenu_overlap=0
|
||||
tooltip_delay=-1
|
||||
animate_states=false
|
||||
transient_scrollbar=true
|
||||
alt_mnemonic=true
|
||||
combo_menu=true
|
||||
layout_margin=4
|
||||
no_window_pattern=false
|
||||
respect_DE=true
|
||||
scroll_min_extent=36
|
||||
scrollable_menu=false
|
||||
scrollbar_in_view=false
|
||||
spin_button_width=16
|
||||
submenu_delay=250
|
||||
tree_branch_line=true
|
||||
progressbar_thickness=8
|
||||
click_behavior=0
|
||||
contrast=1.00
|
||||
dialog_button_layout=0
|
||||
drag_from_buttons=false
|
||||
hide_combo_checkboxes=false
|
||||
intensity=1.00
|
||||
no_inactiveness=false
|
||||
reduce_menu_opacity=20
|
||||
reduce_window_opacity=20
|
||||
saturation=1.00
|
||||
shadowless_popup=false
|
||||
transient_groove=false
|
||||
menu_blur_radius=0
|
||||
tooltip_blur_radius=0
|
||||
|
||||
[GeneralColors]
|
||||
window.color=#EFF1F5
|
||||
base.color=#E6E9EF
|
||||
alt.base.color=#E6E9EF
|
||||
button.color=#CCD0DA
|
||||
light.color=#BCC0CC
|
||||
mid.light.color=#BCC0CC
|
||||
dark.color=#E6E9EF
|
||||
mid.color=#E6E9EF
|
||||
highlight.color=#1E66F5
|
||||
inactive.highlight.color=#1E66F5
|
||||
text.color=#4C4F69
|
||||
window.text.color=#4C4F69
|
||||
button.text.color=#4C4F69
|
||||
disabled.text.color=#ACB0BE
|
||||
tooltip.text.color=#4C4F69
|
||||
highlight.text.color=#E6E9EF
|
||||
link.color=#DC8A78
|
||||
link.visited.color=#1E66F5
|
||||
|
||||
[ItemView]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=itemview
|
||||
interior.element=itemview
|
||||
frame=true
|
||||
interior=true
|
||||
text.iconspacing=3
|
||||
text.toggle.color=#E6E9EF
|
||||
|
||||
[RadioButton]
|
||||
inherits=PanelButtonCommand
|
||||
frame=false
|
||||
interior.element=radio
|
||||
|
||||
[CheckBox]
|
||||
inherits=PanelButtonCommand
|
||||
frame=false
|
||||
interior.element=checkbox
|
||||
|
||||
[TreeExpander]
|
||||
indicator.element=tree
|
||||
indicator.size=8
|
||||
|
||||
[ToolTip]
|
||||
frame.top=4
|
||||
frame.right=4
|
||||
frame.bottom=4
|
||||
frame.left=4
|
||||
frame=true
|
||||
|
||||
[PanelButtonCommand]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=button
|
||||
frame.element=button
|
||||
text.normal.color=#4C4F69
|
||||
text.focus.color=#4C4F69
|
||||
text.press.color=#E6E9EF
|
||||
text.toggle.color=#E6E9EF
|
||||
|
||||
[PanelButtonTool]
|
||||
inherits=PanelButtonCommand
|
||||
|
||||
[DockTitle]
|
||||
inherits=PanelButtonCommand
|
||||
interior=false
|
||||
frame=false
|
||||
text.margin.top=5
|
||||
text.margin.bottom=5
|
||||
text.margin.left=5
|
||||
text.margin.right=5
|
||||
indicator.size=0
|
||||
|
||||
[Dock]
|
||||
interior.element=toolbar
|
||||
frame.element=toolbar
|
||||
frame=true
|
||||
interior=true
|
||||
|
||||
[GroupBox]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=tabframe
|
||||
interior=true
|
||||
frame=false
|
||||
|
||||
[Focus]
|
||||
inherits=PanelButtonCommand
|
||||
frame=true
|
||||
frame.element=focus
|
||||
frame.top=1
|
||||
frame.bottom=1
|
||||
frame.left=1
|
||||
frame.right=1
|
||||
frame.patternsize=20
|
||||
|
||||
[GenericFrame]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=common
|
||||
frame.top=1
|
||||
frame.bottom=1
|
||||
frame.left=1
|
||||
frame.right=1
|
||||
|
||||
[Slider]
|
||||
inherits=PanelButtonCommand
|
||||
interior=true
|
||||
frame.element=slider
|
||||
interior.element=slider
|
||||
frame.top=3
|
||||
frame.bottom=3
|
||||
frame.left=3
|
||||
frame.right=3
|
||||
focusFrame=true
|
||||
|
||||
[SliderCursor]
|
||||
inherits=PanelButtonCommand
|
||||
interior=true
|
||||
interior.element=slidercursor
|
||||
frame=false
|
||||
|
||||
[LineEdit]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=lineedit
|
||||
interior.element=lineedit
|
||||
|
||||
[IndicatorSpinBox]
|
||||
inherits=LineEdit
|
||||
frame.element=lineedit
|
||||
interior.element=lineedit
|
||||
frame.top=0
|
||||
frame.bottom=2
|
||||
frame.left=2
|
||||
frame.right=2
|
||||
indicator.size=8
|
||||
|
||||
[DropDownButton]
|
||||
inherits=PanelButtonCommand
|
||||
frame.top=2
|
||||
frame.bottom=2
|
||||
frame.left=0
|
||||
frame.right=1
|
||||
indicator.size=8
|
||||
|
||||
[ToolboxTab]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=tabframe
|
||||
frame.top=1
|
||||
frame.bottom=1
|
||||
frame.left=1
|
||||
frame.right=1
|
||||
|
||||
[Tab]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=tab
|
||||
frame.element=tab
|
||||
frame.top=2
|
||||
frame.bottom=3
|
||||
frame.left=3
|
||||
frame.right=3
|
||||
indicator.size=10
|
||||
text.normal.color=#ACB0BE
|
||||
text.focus.color=#4C4F69
|
||||
text.press.color=#4C4F69
|
||||
text.toggle.color=#4C4F69
|
||||
focusFrame=true
|
||||
|
||||
[TabBarFrame]
|
||||
inherits=GenericFrame
|
||||
frame=true
|
||||
frame.element=tabBarFrame
|
||||
interior=false
|
||||
frame.top=4
|
||||
frame.bottom=4
|
||||
frame.left=4
|
||||
frame.right=4
|
||||
|
||||
[TabFrame]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=tabframe
|
||||
interior.element=tabframe
|
||||
|
||||
[Dialog]
|
||||
inherits=TabBarFrame
|
||||
frame.element=tabframe
|
||||
interior=false
|
||||
frame=false
|
||||
frame.top=1
|
||||
frame.bottom=1
|
||||
frame.left=1
|
||||
frame.right=1
|
||||
|
||||
[HeaderSection]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=header
|
||||
frame.element=header
|
||||
frame.top=0
|
||||
frame.bottom=1
|
||||
frame.left=1
|
||||
frame.right=1
|
||||
frame.expansion=0
|
||||
text.normal.color=#4C4F69
|
||||
text.focus.color=#1E66F5
|
||||
text.press.color=#4C4F69
|
||||
text.toggle.color=#4C4F69
|
||||
indicator.element=harrow
|
||||
|
||||
[SizeGrip]
|
||||
inherits=PanelButtonCommand
|
||||
frame=false
|
||||
interior=false
|
||||
indicator.element=resize-grip
|
||||
indicator.size=0
|
||||
|
||||
[Toolbar]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=menubar
|
||||
frame.element=menubar
|
||||
frame=true
|
||||
frame.bottom=4
|
||||
frame.left=4
|
||||
frame.right=4
|
||||
text.normal.color=#4C4F69
|
||||
text.focus.color=#4C4F69
|
||||
text.press.color=#1E66F5
|
||||
text.toggle.color=#1E66F5
|
||||
text.bold=false
|
||||
|
||||
[MenuBar]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=menubar
|
||||
interior.element=menubar
|
||||
frame.bottom=0
|
||||
text.normal.color=#4C4F69
|
||||
frame.expansion=0
|
||||
text.bold=false
|
||||
|
||||
[ToolbarButton]
|
||||
frame.element=tbutton
|
||||
interior.element=tbutton
|
||||
indicator.element=arrow
|
||||
text.normal.color=#4C4F69
|
||||
text.focus.color=#4C4F69
|
||||
text.press.color=#E6E9EF
|
||||
text.toggle.color=#E6E9EF
|
||||
text.bold=false
|
||||
|
||||
[Scrollbar]
|
||||
inherits=PanelButtonCommand
|
||||
indicator.size=0
|
||||
interior=false
|
||||
frame=false
|
||||
|
||||
[ScrollbarGroove]
|
||||
inherits=PanelButtonCommand
|
||||
interior=false
|
||||
frame=false
|
||||
|
||||
[ScrollbarSlider]
|
||||
inherits=PanelButtonCommand
|
||||
interior=false
|
||||
frame.element=scrollbarslider
|
||||
frame.top=4
|
||||
frame.bottom=4
|
||||
frame.left=4
|
||||
frame.right=4
|
||||
|
||||
[ProgressbarContents]
|
||||
inherits=PanelButtonCommand
|
||||
frame=true
|
||||
frame.element=progress-pattern
|
||||
interior.element=progress-pattern
|
||||
frame.top=2
|
||||
frame.bottom=2
|
||||
frame.left=2
|
||||
frame.right=2
|
||||
|
||||
[Progressbar]
|
||||
inherits=PanelButtonCommand
|
||||
frame.element=progress
|
||||
interior.element=progress
|
||||
frame.top=2
|
||||
frame.bottom=2
|
||||
frame.left=2
|
||||
frame.right=2
|
||||
text.margin=0
|
||||
text.normal.color=#4C4F69
|
||||
text.focus.color=#4C4F69
|
||||
text.press.color=#E6E9EF
|
||||
text.toggle.color=#E6E9EF
|
||||
text.bold=false
|
||||
frame.expansion=18
|
||||
|
||||
[RadioButton]
|
||||
inherits=PanelButtonCommand
|
||||
|
||||
[Menu]
|
||||
frame.element=menu
|
||||
interior.element=menu
|
||||
inherits=PanelButtonCommand
|
||||
text.press.color=#E6E9EF
|
||||
text.toggle.color=#E6E9EF
|
||||
text.bold=false
|
||||
frame.top=3
|
||||
frame.bottom=3
|
||||
frame.left=3
|
||||
frame.right=3
|
||||
|
||||
[MenuItem]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=menuitem
|
||||
indicator.size=8
|
||||
text.focus.color=#4C4F69
|
||||
text.press.color=#4C4F69
|
||||
|
||||
[MenuBarItem]
|
||||
inherits=PanelButtonCommand
|
||||
interior.element=menubaritem
|
||||
frame=false
|
||||
text.margin.top=3
|
||||
text.margin.bottom=3
|
||||
text.margin.left=5
|
||||
text.margin.right=5
|
||||
|
||||
[StatusBar]
|
||||
inherits=Toolbar
|
||||
frame.element=toolbar
|
||||
font.bold=true
|
||||
text.normal.color=#4C4F69
|
||||
frame=true
|
||||
frame.top=0
|
||||
frame.bottom=0
|
||||
|
||||
[TitleBar]
|
||||
inherits=PanelButtonCommand
|
||||
frame=false
|
||||
interior=false
|
||||
text.margin.top=2
|
||||
text.margin.bottom=2
|
||||
text.margin.left=3
|
||||
text.margin.right=3
|
||||
|
||||
[ComboBox]
|
||||
inherits=PanelButtonCommand
|
||||
indicator.size=8
|
||||
frame.top=3
|
||||
frame.bottom=3
|
||||
frame.left=3
|
||||
frame.right=3
|
||||
text.margin.top=1
|
||||
text.margin.bottom=1
|
||||
text.margin.left=3
|
||||
text.margin.right=3
|
||||
text.toggle.color=#4C4F69
|
||||
|
||||
[ToolboxTab]
|
||||
inherits=PanelButtonCommand
|
||||
text.normal.color=#4C4F69
|
||||
text.press.color=#4C4F69
|
||||
text.focus.color=#4C4F69
|
||||
|
||||
[Hacks]
|
||||
transparent_dolphin_view=true
|
||||
blur_konsole=true
|
||||
transparent_ktitle_label=true
|
||||
transparent_menutitle=true
|
||||
respect_darkness=true
|
||||
kcapacitybar_as_progressbar=true
|
||||
force_size_grip=false
|
||||
iconless_pushbutton=true
|
||||
iconless_menu=false
|
||||
disabled_icon_opacity=100
|
||||
lxqtmainmenu_iconsize=0
|
||||
normal_default_pushbutton=true
|
||||
single_top_toolbar=false
|
||||
tint_on_mouseover=0
|
||||
transparent_pcmanfm_sidepane=true
|
||||
transparent_pcmanfm_view=true
|
||||
blur_translucent=true
|
||||
centered_forms=false
|
||||
kinetic_scrolling=false
|
||||
middle_click_scroll=false
|
||||
no_selection_tint=false
|
||||
noninteger_translucency=false
|
||||
style_vertical_toolbars=false
|
||||
blur_only_active_window=false
|
||||
|
||||
[Window]
|
||||
interior=true
|
||||
interior.element=window
|
||||
frame.top=0
|
||||
frame.bottom=0
|
||||
frame.left=0
|
||||
frame.right=0
|
||||
@@ -2,13 +2,7 @@ inputs:
|
||||
{
|
||||
config.home-manager.users.chn.config.programs.plasma.configFile =
|
||||
let
|
||||
nixos-wallpaper = inputs.pkgs.fetchgit
|
||||
{
|
||||
url = "https://git.chn.moe/chn/nixos-wallpaper.git";
|
||||
rev = "1ad78b20b21c9f4f7ba5f4c897f74276763317eb";
|
||||
sha256 = "0faahbzsr44bjmwr6508wi5hg59dfb57fzh5x6jh7zwmv4pzhqlb";
|
||||
fetchLFS = true;
|
||||
};
|
||||
inherit (inputs.topInputs.self.src) nixos-wallpaper;
|
||||
wallpaper =
|
||||
{
|
||||
pc = "${nixos-wallpaper}/pixiv-117612023.png";
|
||||
|
||||
16
modules/user/chn/sops.nix
Normal file
16
modules/user/chn/sops.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
inputs:
|
||||
{
|
||||
config = inputs.lib.mkIf
|
||||
(
|
||||
(builtins.elem "chn" inputs.config.nixos.user.users)
|
||||
&& (builtins.elem inputs.config.nixos.system.networking.hostname [ "pc" "surface" ])
|
||||
)
|
||||
{
|
||||
home-manager.users.chn = homeInputs:
|
||||
{
|
||||
config.xdg.configFile."sops/age/keys.txt".source =
|
||||
homeInputs.config.lib.file.mkOutOfStoreSymlink inputs.config.sops.secrets.age.path;
|
||||
};
|
||||
sops.secrets.age.owner = "chn";
|
||||
};
|
||||
}
|
||||
@@ -18,7 +18,9 @@ inputs:
|
||||
zem = 1004;
|
||||
gb = 1005;
|
||||
test = 1006;
|
||||
zqq = 1007;
|
||||
wp = 1007;
|
||||
hjp = 1008;
|
||||
zzn = 1009;
|
||||
misskey-misskey = 2000;
|
||||
misskey-misskey-old = 2001;
|
||||
frp = 2002;
|
||||
@@ -107,8 +109,7 @@ inputs:
|
||||
users.users.root =
|
||||
{
|
||||
shell = inputs.pkgs.zsh;
|
||||
openssh.authorizedKeys.keys =
|
||||
[ (builtins.readFile ./chn/id_ed25519_sk.pub) (builtins.readFile ./chn/id_ed25519.pub) ];
|
||||
openssh.authorizedKeys.keys = [(builtins.readFile ./chn/id_ed25519_sk.pub)];
|
||||
hashedPassword = "$y$j9T$.UyKKvDnmlJaYZAh6./rf/$65dRqishAiqxCE6LEMjqruwJPZte7uiyYLVKpzdZNH5";
|
||||
};
|
||||
home-manager.users.root =
|
||||
|
||||
1
modules/user/hjp/id_ed25519.pub
Normal file
1
modules/user/hjp/id_ed25519.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGRZp8xp9hVO7e/6eflQsnFZj853IRVywc97cTevnWbg hjp@xmupc1
|
||||
1
modules/user/wp/id_ed25519.pub
Normal file
1
modules/user/wp/id_ed25519.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMRpyIU8ZuYTa0LvsVHmJZ1FA7Lbp4PObjkwo+UcpCP8 wp@xmupc1
|
||||
@@ -1 +0,0 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPM+Hi3Jo/xb7vDm5L75jybjjrE6z7quveuKd0mTeXDP zqq@xmupc1
|
||||
1
modules/user/zzn/id_ed25519.pub
Normal file
1
modules/user/zzn/id_ed25519.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG+BwKfT2xCiu8qzTGCN2An9GHt0t0egwgMffWyk4WTD zzn
|
||||
@@ -13,16 +13,22 @@ endif()
|
||||
|
||||
find_package(magic_enum REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem)
|
||||
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system)
|
||||
find_package(range-v3 REQUIRED)
|
||||
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
find_package(HighFive REQUIRED)
|
||||
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
|
||||
find_package(TgBot REQUIRED)
|
||||
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
|
||||
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
|
||||
|
||||
add_library(biu src/common.cpp)
|
||||
add_library(biu src/common.cpp src/hdf5.cpp src/logger.cpp src/string.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})
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ${NAMEOF_INCLUDE_DIR} ${ZPP_BITS_INCLUDE_DIR}
|
||||
${LIBBACKTRACE_INCLUDE_DIR})
|
||||
target_link_libraries(biu PUBLIC magic_enum::magic_enum fmt::fmt Boost::headers Boost::iostreams Boost::filesystem
|
||||
range-v3::range-v3 Eigen3::Eigen)
|
||||
range-v3::range-v3 Eigen3::Eigen HighFive_HighFive TgBot::TgBot ${LIBBACKTRACE_LIBRARY})
|
||||
set_property(TARGET biu PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
install(TARGETS biu EXPORT biuTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
@@ -48,3 +54,15 @@ add_executable(test-eigen test/eigen.cpp)
|
||||
target_link_libraries(test-eigen PRIVATE biu)
|
||||
set_property(TARGET test-eigen PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-eigen COMMAND test-eigen)
|
||||
add_executable(test-common test/common.cpp)
|
||||
target_link_libraries(test-common PRIVATE biu)
|
||||
set_property(TARGET test-common PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-common COMMAND test-common)
|
||||
add_executable(test-format test/format.cpp)
|
||||
target_link_libraries(test-format PRIVATE biu)
|
||||
set_property(TARGET test-format PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-format COMMAND test-format)
|
||||
add_executable(test-atomic test/atomic.cpp)
|
||||
target_link_libraries(test-atomic PRIVATE biu)
|
||||
set_property(TARGET test-atomic PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-atomic COMMAND test-atomic)
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
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(Boost REQUIRED COMPONENTS headers iostreams filesystem system)
|
||||
find_package(range-v3 REQUIRED)
|
||||
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
find_package(HighFive REQUIRED)
|
||||
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
|
||||
find_package(TgBot REQUIRED)
|
||||
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
|
||||
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
stdenv, cmake, lib,
|
||||
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits
|
||||
magic-enum, fmt, boost, eigen, range-v3, nameof, zpp-bits, highfive, tgbot-cpp, libbacktrace
|
||||
}: stdenv.mkDerivation rec
|
||||
{
|
||||
name = "biu";
|
||||
src = ./.;
|
||||
buildInputs = [ magic-enum fmt boost range-v3 nameof zpp-bits eigen ];
|
||||
buildInputs = [ magic-enum fmt boost range-v3 nameof zpp-bits eigen highfive tgbot-cpp libbacktrace ];
|
||||
propagatedBuildInputs = buildInputs;
|
||||
nativeBuildInputs = [ cmake ];
|
||||
doCheck = true;
|
||||
|
||||
57
packages/biu/fmt.patch
Normal file
57
packages/biu/fmt.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
diff --git a/include/fmt/std.h b/include/fmt/std.h
|
||||
index 1e69b8b2..ae485344 100644
|
||||
--- a/include/fmt/std.h
|
||||
+++ b/include/fmt/std.h
|
||||
@@ -211,7 +211,7 @@ template <typename Char>
|
||||
struct formatter<std::thread::id, Char> : basic_ostream_formatter<Char> {};
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
-#ifdef __cpp_lib_optional
|
||||
+#ifdef __cpp_lib_optional_
|
||||
FMT_BEGIN_NAMESPACE
|
||||
FMT_EXPORT
|
||||
template <typename T, typename Char>
|
||||
diff --git a/test/std-test.cc b/test/std-test.cc
|
||||
index bcc7bd5f..24981d87 100644
|
||||
--- a/test/std-test.cc
|
||||
+++ b/test/std-test.cc
|
||||
@@ -56,7 +56,7 @@ TEST(ranges_std_test, format_quote_path) {
|
||||
std::vector<std::filesystem::path>{"path1/file1.txt", "path2/file2.txt"};
|
||||
EXPECT_EQ(fmt::format("{}", vec),
|
||||
"[\"path1/file1.txt\", \"path2/file2.txt\"]");
|
||||
-# ifdef __cpp_lib_optional
|
||||
+# ifdef __cpp_lib_optional_
|
||||
auto o = std::optional<std::filesystem::path>("path/file.txt");
|
||||
EXPECT_EQ(fmt::format("{}", o), "optional(\"path/file.txt\")");
|
||||
EXPECT_EQ(fmt::format("{:?}", o), "optional(\"path/file.txt\")");
|
||||
@@ -109,7 +109,7 @@ TEST(std_test, source_location) {
|
||||
#endif
|
||||
|
||||
TEST(std_test, optional) {
|
||||
-#ifdef __cpp_lib_optional
|
||||
+#ifdef __cpp_lib_optional_
|
||||
EXPECT_EQ(fmt::format("{}", std::optional<int>{}), "none");
|
||||
EXPECT_EQ(fmt::format("{}", std::pair{1, "second"}), "(1, \"second\")");
|
||||
EXPECT_EQ(fmt::format("{}", std::vector{std::optional{1}, std::optional{2},
|
||||
@@ -184,7 +184,7 @@ class my_class {
|
||||
};
|
||||
} // namespace my_nso
|
||||
TEST(std_test, optional_format_as) {
|
||||
-#ifdef __cpp_lib_optional
|
||||
+#ifdef __cpp_lib_optional_
|
||||
EXPECT_EQ(fmt::format("{}", std::optional<my_nso::my_number>{}), "none");
|
||||
EXPECT_EQ(fmt::format("{}", std::optional{my_nso::my_number::one}),
|
||||
"optional(\"first\")");
|
||||
diff --git a/test/xchar-test.cc b/test/xchar-test.cc
|
||||
index 312e632b..6210e244 100644
|
||||
--- a/test/xchar-test.cc
|
||||
+++ b/test/xchar-test.cc
|
||||
@@ -590,7 +590,7 @@ TEST(std_test_xchar, complex) {
|
||||
}
|
||||
|
||||
TEST(std_test_xchar, optional) {
|
||||
-# ifdef __cpp_lib_optional
|
||||
+# ifdef __cpp_lib_optional_
|
||||
EXPECT_EQ(fmt::format(L"{}", std::optional{L'C'}), L"optional(\'C\')");
|
||||
EXPECT_EQ(fmt::format(L"{}", std::optional{std::wstring{L"wide string"}}),
|
||||
L"optional(\"wide string\")");
|
||||
@@ -1,12 +1,11 @@
|
||||
# pragma once
|
||||
// # include <biu/atomic/atomic.tpp>
|
||||
// # include <biu/called_by.hpp>
|
||||
# include <biu/atomic.tpp>
|
||||
# include <biu/called_by.hpp>
|
||||
# include <biu/common.tpp>
|
||||
# include <biu/concepts.tpp>
|
||||
# include <biu/string.tpp>
|
||||
# include <biu/format.tpp>
|
||||
# include <biu/eigen.tpp>
|
||||
// # include <biu/logger.tpp>
|
||||
// # include <biu/smartref.tpp>
|
||||
|
||||
|
||||
# include <biu/hdf5.tpp>
|
||||
# include <biu/logger.tpp>
|
||||
# include <biu/smartref.tpp>
|
||||
|
||||
68
packages/biu/include/biu/atomic.hpp
Normal file
68
packages/biu/include/biu/atomic.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
# pragma once
|
||||
# include <mutex>
|
||||
# include <optional>
|
||||
# include <condition_variable>
|
||||
# include <cstddef>
|
||||
# include <experimental/memory>
|
||||
# include <biu/common.hpp>
|
||||
# include <biu/concepts.hpp>
|
||||
# include <biu/called_by.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <DecayedType ValueType> class Atomic
|
||||
{
|
||||
protected: mutable std::mutex Mutex_;
|
||||
protected: mutable std::condition_variable ConditionVariable_;
|
||||
protected: ValueType Value_;
|
||||
|
||||
public: template <bool Const> class Guard
|
||||
{
|
||||
protected: std::unique_lock<std::mutex> Lock_;
|
||||
protected: std::experimental::observer_ptr
|
||||
<std::conditional_t<Const, const Atomic<ValueType>, Atomic<ValueType>>> Value_;
|
||||
|
||||
public: template <bool OtherConst> Guard(Guard<OtherConst>&& other) requires (Const || !OtherConst);
|
||||
public: Guard
|
||||
(decltype(Lock_)&& lock, decltype(Value_) value, CalledBy<Atomic<ValueType>>);
|
||||
public: ~Guard();
|
||||
|
||||
public: std::conditional_t<Const, const ValueType&, ValueType&> operator*() const&;
|
||||
public: std::conditional_t<Const, const ValueType*, ValueType*> operator->() const&;
|
||||
public: std::conditional_t<Const, const ValueType&, ValueType&> value() const&;
|
||||
};
|
||||
|
||||
public: Atomic() = default;
|
||||
public: Atomic(auto&& value);
|
||||
public: Atomic& operator=(auto&& value);
|
||||
|
||||
public: ValueType get(this auto&& self);
|
||||
public: operator ValueType(this auto&& self);
|
||||
|
||||
protected: template <bool Throw = false> auto lock_(this auto&& self, auto&& condition_function, auto timeout);
|
||||
|
||||
// Apply a function to stored value.
|
||||
// Wait for some time (if provided) until condition funciton returns true (if provided)
|
||||
// before applying the function.
|
||||
// NoReturn: throw exception if timeout, ignore function result, and return *this, if true;
|
||||
// return bool or std::optional wrapped result of function, if false.
|
||||
// Useful when chaining multiple apply() calls.
|
||||
public: template <bool NoReturn = false> decltype(auto) apply
|
||||
(this auto&& self, auto&& function, auto&& condition_function, auto&& timeout);
|
||||
public: template <bool NoReturn = false> decltype(auto) apply
|
||||
(this auto&& self, auto&& function, auto&& condition_function);
|
||||
public: template <bool NoReturn = false> decltype(auto) apply(this auto&& self, auto&& function);
|
||||
|
||||
// Wait until condition funciton returns true or *this, with an optional timeout
|
||||
public: template <bool NoReturn = false> decltype(auto) wait
|
||||
(this auto&& self, auto&& condition_function, auto timeout);
|
||||
public: template <bool NoReturn = false> decltype(auto) wait
|
||||
(this auto&& self, auto&& condition_function);
|
||||
|
||||
// Attain lock from outside when constructing, and release when destructing.
|
||||
// Throw: same effect as NoReturn.
|
||||
public: template <bool Throw = false> auto lock(this auto&& self, auto&& condition_function, auto timeout);
|
||||
public: template <bool Throw = false> auto lock(this auto&& self, auto&& condition_function);
|
||||
public: template <bool Throw = false> auto lock(this auto&& self);
|
||||
};
|
||||
}
|
||||
156
packages/biu/include/biu/atomic.tpp
Normal file
156
packages/biu/include/biu/atomic.tpp
Normal file
@@ -0,0 +1,156 @@
|
||||
# pragma once
|
||||
# include <biu/atomic.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <DecayedType ValueType> template <bool Const> template <bool OtherConst>
|
||||
Atomic<ValueType>::Guard<Const>::Guard(Guard<OtherConst>&& other) requires (Const || !OtherConst)
|
||||
: Lock_{std::move(other.Lock_)}, Value_{std::move(other.Value_)} {}
|
||||
template <DecayedType ValueType> template <bool Const> Atomic<ValueType>::Guard<Const>::Guard
|
||||
(decltype(Lock_)&& lock, decltype(Value_) value, CalledBy<Atomic<ValueType>>)
|
||||
: Lock_{std::move(lock)}, Value_{value} {}
|
||||
template <DecayedType ValueType> template <bool Const> Atomic<ValueType>::Guard<Const>::~Guard()
|
||||
{ if constexpr (!Const) Value_->ConditionVariable_.notify_all(); }
|
||||
|
||||
template <DecayedType ValueType> template <bool Const> std::conditional_t<Const, const ValueType&, ValueType&>
|
||||
Atomic<ValueType>::Guard<Const>::operator*() const&
|
||||
{ return Value_->Value_; }
|
||||
template <DecayedType ValueType> template <bool Const> std::conditional_t<Const, const ValueType*, ValueType*>
|
||||
Atomic<ValueType>::Guard<Const>::operator->() const&
|
||||
{ return &Value_->Value_; }
|
||||
template <DecayedType ValueType> template <bool Const> std::conditional_t<Const, const ValueType&, ValueType&>
|
||||
Atomic<ValueType>::Guard<Const>::value() const&
|
||||
{ return Value_->Value_; }
|
||||
|
||||
template <DecayedType ValueType> Atomic<ValueType>::Atomic(auto&& value)
|
||||
: Value_{std::forward<decltype(value)>(value)} {}
|
||||
template <DecayedType ValueType> Atomic<ValueType>& Atomic<ValueType>::operator=(auto&& value)
|
||||
{
|
||||
std::scoped_lock lock(Mutex_);
|
||||
Value_ = std::forward<decltype(value)>(value);
|
||||
ConditionVariable_.notify_all();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <DecayedType ValueType> ValueType Atomic<ValueType>::get(this auto&& self)
|
||||
{ std::scoped_lock lock(self.Mutex_); return self.Value_; }
|
||||
template <DecayedType ValueType> Atomic<ValueType>::operator ValueType(this auto&& self)
|
||||
{ return self.get(); }
|
||||
|
||||
template <DecayedType ValueType> template <bool Throw> auto Atomic<ValueType>::lock_
|
||||
(this auto&& self, auto&& condition_function, auto timeout)
|
||||
{
|
||||
if constexpr (Nullptr<decltype(condition_function)>)
|
||||
return Guard<std::is_const_v<decltype(self)>>
|
||||
(std::unique_lock{self.Mutex_}, std::experimental::make_observer(&self), {});
|
||||
else if constexpr (Nullptr<decltype(timeout)>)
|
||||
{
|
||||
std::unique_lock lock(self.Mutex_);
|
||||
self.ConditionVariable_.wait(lock, [&]
|
||||
{ return std::forward<decltype(condition_function)>(condition_function)(std::as_const(self.Value_)); });
|
||||
return Guard<std::is_const_v<decltype(self)>>(std::move(lock), std::experimental::make_observer(&self), {});
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_lock lock(self.Mutex_);
|
||||
if (!self.ConditionVariable_.wait_for(lock, timeout, [&]
|
||||
{ return std::forward<decltype(condition_function)>(condition_function)(std::as_const(self.Value_)); }))
|
||||
{
|
||||
if constexpr (Throw) throw std::runtime_error("Timeout");
|
||||
else return std::optional<Guard<std::is_const_v<decltype(self)>>>();
|
||||
}
|
||||
else return std::optional(Guard<std::is_const_v<decltype(self)>>
|
||||
(std::move(lock), std::experimental::make_observer(&self), {}));
|
||||
}
|
||||
}
|
||||
|
||||
template <DecayedType ValueType> template <bool NoReturn> decltype(auto) Atomic<ValueType>::apply
|
||||
(this auto&& self, auto&& function, auto&& condition_function, auto&& timeout)
|
||||
{
|
||||
using function_return_type = std::invoke_result_t<decltype(function), MoveQualifiers<decltype(self), ValueType>>;
|
||||
auto&& lock = std::forward<decltype(self)>(self).template lock_<NoReturn>
|
||||
(std::forward<decltype(condition_function)>(condition_function), timeout);
|
||||
// 如果得到的是 optional
|
||||
if constexpr (SpecializationOf<std::remove_cvref_t<decltype(lock)>, std::optional>)
|
||||
// 如果超时了,返回 false 或者对应的 nullopt
|
||||
if (!lock)
|
||||
if constexpr (std::is_void_v<function_return_type>) return false;
|
||||
else return std::optional<function_return_type>();
|
||||
// 否则,执行函数
|
||||
else
|
||||
if constexpr (std::is_void_v<function_return_type>)
|
||||
{
|
||||
std::forward<decltype(function)>(function)
|
||||
(std::forward<MoveQualifiers<decltype(self), ValueType>>(self.Value_));
|
||||
// 如果函数本身返回 void 并且不可能超时,返回 *this,否则返回 true
|
||||
if constexpr (Nullptr<decltype(condition_function)> || Nullptr<decltype(timeout)>)
|
||||
return std::forward<decltype(self)>(self);
|
||||
else return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto&& result = std::forward<decltype(function)>(function)
|
||||
(std::forward<MoveQualifiers<decltype(self), ValueType>>(self.Value_));
|
||||
return std::make_optional(std::forward<decltype(result)>(result));
|
||||
}
|
||||
// 否则,说明不可能超时,返回函数的返回值或者 *this
|
||||
else
|
||||
if constexpr (std::is_void_v<function_return_type>)
|
||||
{
|
||||
std::forward<decltype(function)>(function)
|
||||
(std::forward<MoveQualifiers<decltype(self), ValueType>>(self.Value_));
|
||||
return std::forward<decltype(self)>(self);
|
||||
}
|
||||
else
|
||||
return std::forward<decltype(function)>(function)
|
||||
(std::forward<MoveQualifiers<decltype(self), ValueType>>(self.Value_));
|
||||
}
|
||||
template <DecayedType ValueType> template <bool NoReturn> decltype(auto) Atomic<ValueType>::apply
|
||||
(this auto&& self, auto&& function, auto&& condition_function)
|
||||
{
|
||||
return std::forward<decltype(self)>(self).template apply<NoReturn>
|
||||
(
|
||||
std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function),
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
template <DecayedType ValueType> template <bool NoReturn> decltype(auto) Atomic<ValueType>::apply
|
||||
(this auto&& self, auto&& function)
|
||||
{
|
||||
return std::forward<decltype(self)>(self).template apply<NoReturn>
|
||||
(std::forward<decltype(function)>(function), nullptr, nullptr);
|
||||
}
|
||||
|
||||
template <DecayedType ValueType> template <bool NoReturn> decltype(auto) Atomic<ValueType>::wait
|
||||
(this auto&& self, auto&& condition_function, auto timeout)
|
||||
{
|
||||
auto result = std::forward<decltype(self)>(self).template lock_<NoReturn>
|
||||
(std::forward<decltype(condition_function)>(condition_function), timeout);
|
||||
if constexpr (SpecializationOf<decltype(result), std::optional>) return result.has_value();
|
||||
else return std::forward<decltype(result)>(result);
|
||||
}
|
||||
template <DecayedType ValueType> template <bool NoReturn> decltype(auto) Atomic<ValueType>::wait
|
||||
(this auto&& self, auto&& condition_function)
|
||||
{
|
||||
return std::forward<decltype(self)>(self).template wait<NoReturn>
|
||||
(std::forward<decltype(condition_function)>(condition_function), nullptr);
|
||||
}
|
||||
|
||||
template <DecayedType ValueType> template <bool Throw> auto Atomic<ValueType>::lock
|
||||
(this auto&& self, auto&& condition_function, auto timeout)
|
||||
{
|
||||
// self 不能是右值引用
|
||||
static_assert(!std::is_rvalue_reference_v<decltype(self)>, "rvalue atomic cannot be locked");
|
||||
return std::forward<decltype(self)>(self).template lock_<Throw>
|
||||
(std::forward<decltype(condition_function)>(condition_function), timeout);
|
||||
}
|
||||
template <DecayedType ValueType> template <bool Throw> auto Atomic<ValueType>::lock
|
||||
(this auto&& self, auto&& condition_function)
|
||||
{
|
||||
return std::forward<decltype(self)>(self).template lock<Throw>
|
||||
(std::forward<decltype(condition_function)>(condition_function), nullptr);
|
||||
}
|
||||
template <DecayedType ValueType> template <bool Throw> auto Atomic<ValueType>::lock(this auto&& self)
|
||||
{ return std::forward<decltype(self)>(self).template lock<Throw>(nullptr, nullptr); }
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
# pragma once
|
||||
# include <biu/logger.hpp>
|
||||
|
||||
namespace biu::detail_
|
||||
{
|
||||
template <DecayedType ValueType> class AtomicBase<ValueType, true>
|
||||
: public Logger::ObjectMonitor<Atomic<ValueType, true>>, protected AtomicBase<ValueType, false>
|
||||
{
|
||||
using DeepBase_ = AtomicBase<ValueType, false>;
|
||||
using DeepBase_::AtomicBase;
|
||||
public: class TimeoutException : public Logger::Exception<TimeoutException>
|
||||
{
|
||||
using Logger::Exception<TimeoutException>::Exception;
|
||||
};
|
||||
|
||||
protected: template
|
||||
<
|
||||
bool ReturnFunctionResult,
|
||||
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t, bool Nothrow = false
|
||||
> static auto apply_
|
||||
(
|
||||
auto&& atomic, auto&& function,
|
||||
ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr
|
||||
) -> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(atomic), ReturnFunctionResult, ConditionFunction, Duration, Nothrow>
|
||||
requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(atomic), ConditionFunction, Duration>;
|
||||
|
||||
protected: template <bool Nothrow = false, typename Duration = std::nullptr_t> static auto wait_
|
||||
(auto&& atomic, auto&& condition_function, Duration timeout = nullptr)
|
||||
-> DeepBase_::template WaitReturnType_<decltype(atomic), decltype(condition_function), Duration, Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), Duration>;
|
||||
|
||||
protected: template
|
||||
<bool Nothrow = false, typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t>
|
||||
static auto lock_
|
||||
(auto&& atomic, ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr)
|
||||
-> DeepBase_::template LockReturnType_<decltype(atomic), Duration, Nothrow>
|
||||
requires DeepBase_::template LockConstraint_<ConditionFunction, Duration>;
|
||||
};
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
# pragma once
|
||||
# include <mutex>
|
||||
# include <optional>
|
||||
# include <condition_variable>
|
||||
# include <cstddef>
|
||||
# include <experimental/memory>
|
||||
# include <biu/common.hpp>
|
||||
# include <biu/concepts.hpp>
|
||||
# include <biu/called_by.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <DecayedType ValueType, bool UseLogger = true> class Atomic;
|
||||
namespace detail_
|
||||
{
|
||||
template <DecayedType ValueType, bool UseLogger> class AtomicBase;
|
||||
template <DecayedType ValueType> class AtomicBase<ValueType, false>
|
||||
{
|
||||
protected: mutable std::recursive_mutex Mutex_;
|
||||
protected: mutable std::condition_variable_any ConditionVariable_;
|
||||
protected: ValueType Value_;
|
||||
|
||||
AtomicBase() = default;
|
||||
AtomicBase(const ValueType& value);
|
||||
AtomicBase(ValueType&& value);
|
||||
|
||||
public: class TimeoutException : public std::exception
|
||||
{
|
||||
protected: std::string Message_;
|
||||
public: explicit TimeoutException(std::string message);
|
||||
public: const char* what() const noexcept override;
|
||||
};
|
||||
|
||||
// Apply a function to stored value.
|
||||
// Wait for some time (if provided) until condition funciton returns true (if provided)
|
||||
// before applying the function.
|
||||
protected: template
|
||||
<
|
||||
typename Function, typename Atomic,
|
||||
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t
|
||||
>
|
||||
constexpr static bool ApplyConstraint_ =
|
||||
(
|
||||
(std::invocable<Function, MoveQualifiers<Atomic, ValueType>> && std::is_null_pointer_v<ConditionFunction>)
|
||||
|| (
|
||||
InvocableWithResult<ConditionFunction, bool, const ValueType&>
|
||||
&& (std::is_null_pointer_v<Duration> || SpecializationOf<Duration, std::chrono::duration>)
|
||||
)
|
||||
);
|
||||
protected: template
|
||||
<
|
||||
typename Function, typename Atomic, bool ReturnFunctionResult,
|
||||
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t,
|
||||
bool Nothrow = false
|
||||
> using ApplyReturnType_ = std::conditional_t
|
||||
<
|
||||
Nothrow,
|
||||
std::conditional_t
|
||||
<
|
||||
ReturnFunctionResult && !std::is_void_v<std::invoke_result<Function, ValueType>>,
|
||||
std::optional<std::remove_cvref_t<FallbackIfNoTypeDeclared<std::invoke_result
|
||||
<Function, MoveQualifiers<Atomic, ValueType>, int>>>>,
|
||||
bool
|
||||
>,
|
||||
std::conditional_t
|
||||
<
|
||||
ReturnFunctionResult,
|
||||
std::invoke_result_t<Function, MoveQualifiers<Atomic, ValueType>>,
|
||||
Atomic&&
|
||||
>
|
||||
>;
|
||||
protected: template
|
||||
<
|
||||
bool ReturnFunctionResult,
|
||||
typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t,
|
||||
bool Nothrow = false
|
||||
> static auto apply_
|
||||
(
|
||||
auto&& atomic, auto&& function,
|
||||
ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr
|
||||
) -> ApplyReturnType_
|
||||
<decltype(function), decltype(atomic), ReturnFunctionResult, ConditionFunction, Duration, Nothrow>
|
||||
requires ApplyConstraint_<decltype(function), decltype(atomic), ConditionFunction, Duration>;
|
||||
|
||||
// Wait until condition funciton returns true, with an optional timeout
|
||||
protected: template <typename ConditionFunction, typename Duration = std::nullptr_t>
|
||||
constexpr static bool WaitConstraint_
|
||||
= (InvocableWithResult<ConditionFunction, bool, const ValueType&>
|
||||
&& (std::is_null_pointer_v<Duration> || SpecializationOf<Duration, std::chrono::duration>));
|
||||
protected: template
|
||||
<typename Atomic, typename ConditionFunction, typename Duration = std::nullptr_t, bool Nothrow = false>
|
||||
using WaitReturnType_
|
||||
= std::conditional_t<Nothrow && !std::is_null_pointer_v<Duration>, bool, Atomic&&>;
|
||||
protected: template <bool Nothrow = false, typename Duration = std::nullptr_t> static auto wait_
|
||||
(auto&& atomic, auto&& condition_function, Duration timeout = nullptr)
|
||||
-> WaitReturnType_<decltype(atomic), decltype(condition_function), Duration, Nothrow>
|
||||
requires WaitConstraint_<decltype(condition_function), Duration>;
|
||||
|
||||
protected: template <typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t>
|
||||
constexpr static bool LockConstraint_
|
||||
= std::is_null_pointer_v<ConditionFunction> ||
|
||||
(
|
||||
InvocableWithResult<ConditionFunction, bool, const ValueType&>
|
||||
&& (std::is_null_pointer_v<Duration> || SpecializationOf<Duration, std::chrono::duration>)
|
||||
);
|
||||
protected: template <typename Atomic, typename Duration = std::nullptr_t, bool Nothrow = false>
|
||||
using LockReturnType_
|
||||
= std::conditional_t
|
||||
<
|
||||
Nothrow && !std::is_null_pointer_v<Duration>,
|
||||
std::optional<std::conditional_t
|
||||
<
|
||||
std::is_const_v<Atomic>,
|
||||
typename std::remove_reference_t<Atomic>::template Guard<true>,
|
||||
typename std::remove_reference_t<Atomic>::template Guard<false>
|
||||
>>,
|
||||
std::conditional_t
|
||||
<
|
||||
std::is_const_v<Atomic>,
|
||||
typename std::remove_reference_t<Atomic>::template Guard<true>,
|
||||
typename std::remove_reference_t<Atomic>::template Guard<false>
|
||||
>
|
||||
>;
|
||||
protected: template
|
||||
<bool Nothrow = false, typename ConditionFunction = std::nullptr_t, typename Duration = std::nullptr_t>
|
||||
static auto lock_
|
||||
(auto&& atomic, ConditionFunction&& condition_function = nullptr, Duration timeout = nullptr)
|
||||
-> LockReturnType_<decltype(atomic), Duration, Nothrow>
|
||||
requires LockConstraint_<ConditionFunction, Duration>;
|
||||
};
|
||||
}
|
||||
|
||||
// Thread safe wrapper of custom class
|
||||
template <DecayedType ValueType, bool UseLogger> class Atomic : public detail_::AtomicBase<ValueType, UseLogger>
|
||||
{
|
||||
public: Atomic() = default;
|
||||
public: Atomic(const ValueType& value);
|
||||
public: Atomic(ValueType&& value);
|
||||
public: template <bool OtherUseLogger> Atomic(const Atomic<ValueType, OtherUseLogger>& other);
|
||||
public: template <bool OtherUseLogger> Atomic(Atomic<ValueType, OtherUseLogger>&& other);
|
||||
public: Atomic<ValueType, UseLogger>& operator=(const ValueType& value);
|
||||
public: Atomic<ValueType, UseLogger>& operator=(ValueType&& value);
|
||||
public: template <bool OtherUseLogger>
|
||||
Atomic<ValueType, UseLogger>& operator=(const Atomic<ValueType, OtherUseLogger>& other);
|
||||
public: template <bool OtherUseLogger>
|
||||
Atomic<ValueType, UseLogger>& operator=(Atomic<ValueType, OtherUseLogger>&& other);
|
||||
public: ValueType get() const&;
|
||||
public: ValueType get() &&;
|
||||
public: operator ValueType() const&;
|
||||
public: operator ValueType() &&;
|
||||
|
||||
protected: using DeepBase_ = detail_::AtomicBase<ValueType, false>;
|
||||
|
||||
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function) const&
|
||||
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>;
|
||||
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function) &
|
||||
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>;
|
||||
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function) &&
|
||||
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>;
|
||||
public: template <bool ReturnFunctionResult = false>
|
||||
auto apply(auto&& function, auto&& condition_function) const&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
|
||||
requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function)>;
|
||||
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function, auto&& condition_function) &
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
|
||||
requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function)>;
|
||||
public: template <bool ReturnFunctionResult = false> auto apply(auto&& function, auto&& condition_function) &&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
|
||||
requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function)>;
|
||||
public: template <bool ReturnFunctionResult = false, bool Nothrow = false>
|
||||
auto apply(auto&& function, auto&& condition_function, auto timeout) const&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<
|
||||
decltype(function), decltype(*this), ReturnFunctionResult,
|
||||
decltype(condition_function), decltype(timeout), Nothrow
|
||||
> requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>;
|
||||
public: template <bool ReturnFunctionResult = false, bool Nothrow = false>
|
||||
auto apply(auto&& function, auto&& condition_function, auto timeout) &
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<
|
||||
decltype(function), decltype(*this), ReturnFunctionResult,
|
||||
decltype(condition_function), decltype(timeout), Nothrow
|
||||
> requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>;
|
||||
public: template <bool ReturnFunctionResult = false, bool Nothrow = false>
|
||||
auto apply(auto&& function, auto&& condition_function, auto timeout) &&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<
|
||||
decltype(function), decltype(*this), ReturnFunctionResult,
|
||||
decltype(condition_function), decltype(timeout), Nothrow
|
||||
> requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>;
|
||||
|
||||
public: auto wait(auto&& condition_function) const&
|
||||
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>;
|
||||
public: auto wait(auto&& condition_function) &
|
||||
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>;
|
||||
public: auto wait(auto&& condition_function) &&
|
||||
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>;
|
||||
public: template <bool Nothrow = false> auto wait(auto&& condition_function, auto timeout) const&
|
||||
-> DeepBase_::template WaitReturnType_
|
||||
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>;
|
||||
public: template <bool Nothrow = false> auto wait(auto&& condition_function, auto timeout) &
|
||||
-> DeepBase_::template WaitReturnType_
|
||||
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>;
|
||||
public: template <bool Nothrow = false> auto wait(auto&& condition_function, auto timeout) &&
|
||||
-> DeepBase_::template WaitReturnType_
|
||||
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>;
|
||||
|
||||
// Attain lock from outside when constructing, and release when destructing.
|
||||
// For non-const variant, When destructing, ConditionVariable_.notify_all() is called.
|
||||
public: template <bool Const> class Guard
|
||||
{
|
||||
protected: std::unique_lock<std::recursive_mutex> Lock_;
|
||||
protected: std::experimental::observer_ptr
|
||||
<std::conditional_t<Const, const Atomic<ValueType, UseLogger>, Atomic<ValueType, UseLogger>>> Value_;
|
||||
|
||||
public: template <bool OtherConst> Guard(const Guard<OtherConst>& other) requires (Const || !OtherConst);
|
||||
public: Guard
|
||||
(decltype(Lock_)&& lock, decltype(Value_) value, CalledBy<detail_::AtomicBase<ValueType, UseLogger>>);
|
||||
public: ~Guard();
|
||||
|
||||
public: std::conditional_t<Const, const ValueType&, ValueType&> operator*() const&;
|
||||
public: std::conditional_t<Const, const ValueType*, ValueType*> operator->() const&;
|
||||
public: std::conditional_t<Const, const ValueType&, ValueType&> value() const&;
|
||||
public: auto operator*() const&& = delete;
|
||||
public: auto operator->() const&& = delete;
|
||||
public: auto value() const&& = delete;
|
||||
};
|
||||
|
||||
public: auto lock() const& -> DeepBase_::template LockReturnType_<decltype(*this)>
|
||||
requires DeepBase_::template LockConstraint_<>;
|
||||
public: auto lock() & -> DeepBase_::template LockReturnType_<decltype(*this)>
|
||||
requires DeepBase_::template LockConstraint_<>;
|
||||
public: auto lock() const&& = delete;
|
||||
public: auto lock(auto&& condition_function) const&
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function)>;
|
||||
public: auto lock(auto&& condition_function) &
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function)>;
|
||||
public: auto lock(auto&& condition_function) const&& = delete;
|
||||
public: template <bool Nothrow = false> auto lock(auto&& condition_function, auto timeout) const&
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>;
|
||||
public: template <bool Nothrow = false> auto lock(auto&& condition_function, auto timeout) &
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>;
|
||||
public: template <bool Nothrow = false> auto lock(auto&& condition_function, auto timeout) const&& = delete;
|
||||
};
|
||||
}
|
||||
@@ -1,366 +0,0 @@
|
||||
# pragma once
|
||||
# include <biu/atomic/nolog.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
template <DecayedType ValueType> detail_::AtomicBase<ValueType, false>::AtomicBase(const ValueType& value)
|
||||
: Value_{value} {}
|
||||
template <DecayedType ValueType> detail_::AtomicBase<ValueType, false>::AtomicBase(ValueType&& value)
|
||||
: Value_{std::move(value)} {}
|
||||
|
||||
template <DecayedType ValueType>
|
||||
detail_::AtomicBase<ValueType, false>::TimeoutException::TimeoutException(std::string)
|
||||
: Message_{"TimeoutException"} {}
|
||||
template <DecayedType ValueType>
|
||||
const char* detail_::AtomicBase<ValueType, false>::TimeoutException::what() const noexcept
|
||||
{return Message_.c_str();}
|
||||
|
||||
template <DecayedType ValueType>
|
||||
template <bool ReturnFunctionResult, typename ConditionFunction, typename Duration, bool Nothrow>
|
||||
auto detail_::AtomicBase<ValueType, false>::apply_
|
||||
(auto&& atomic, auto&& function, ConditionFunction&& condition_function, Duration timeout)
|
||||
-> ApplyReturnType_
|
||||
<decltype(function), decltype(atomic), ReturnFunctionResult, ConditionFunction, Duration, Nothrow>
|
||||
requires ApplyConstraint_<decltype(function), decltype(atomic), ConditionFunction, Duration>
|
||||
{
|
||||
std::unique_lock lock{atomic.Mutex_};
|
||||
|
||||
// try to meet the condition
|
||||
if constexpr (!std::is_null_pointer_v<ConditionFunction>)
|
||||
{
|
||||
if constexpr (std::is_null_pointer_v<Duration>)
|
||||
atomic.ConditionVariable_.wait(lock, [&]
|
||||
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));});
|
||||
else if (!atomic.ConditionVariable_.wait_for(lock, timeout, [&]
|
||||
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));}))
|
||||
{
|
||||
if constexpr (Nothrow)
|
||||
{
|
||||
if constexpr
|
||||
(ReturnFunctionResult && !std::is_void_v<std::invoke_result_t<decltype(function), ValueType>>)
|
||||
return std::nullopt;
|
||||
else return false;
|
||||
}
|
||||
else throw TimeoutException{};
|
||||
}
|
||||
}
|
||||
|
||||
// apply the function and return
|
||||
if constexpr (ReturnFunctionResult && !std::is_void_v<std::invoke_result_t<decltype(function), ValueType>>)
|
||||
{
|
||||
auto&& result = std::forward<decltype(function)>(function)
|
||||
(static_cast<MoveQualifiers<decltype(atomic), ValueType>&&>(atomic.Value_));
|
||||
if constexpr (!std::is_const_v<decltype(atomic)>) atomic.ConditionVariable_.notify_all();
|
||||
return std::forward<decltype(result)>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::forward<decltype(function)>(function)
|
||||
(static_cast<MoveQualifiers<decltype(atomic), ValueType>&&>(atomic.Value_));
|
||||
if constexpr (!std::is_const_v<decltype(atomic)>) atomic.ConditionVariable_.notify_all();
|
||||
if constexpr (ReturnFunctionResult && std::is_void_v<std::invoke_result_t<decltype(function), ValueType>>)
|
||||
return;
|
||||
else return std::forward<decltype(atomic)>(atomic);
|
||||
}
|
||||
}
|
||||
|
||||
template <DecayedType ValueType> template <bool Nothrow, typename Duration>
|
||||
auto detail_::AtomicBase<ValueType, false>::wait_(auto&& atomic, auto&& condition_function, Duration timeout)
|
||||
-> WaitReturnType_<decltype(atomic), decltype(condition_function), Duration, Nothrow>
|
||||
requires WaitConstraint_<decltype(condition_function), Duration>
|
||||
{
|
||||
std::unique_lock lock{atomic.Mutex_};
|
||||
|
||||
if constexpr (std::is_null_pointer_v<Duration>)
|
||||
{
|
||||
atomic.ConditionVariable_.wait(lock, [&]
|
||||
{return std::forward<decltype(condition_function)>(condition_function)(std::as_const(atomic.Value_));});
|
||||
return std::forward<decltype(atomic)>(atomic);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!atomic.ConditionVariable_.wait_for(lock, timeout, [&]
|
||||
{return std::forward<decltype(condition_function)>(condition_function)(std::as_const(atomic.Value_));}))
|
||||
{
|
||||
if constexpr (Nothrow) return false;
|
||||
else throw TimeoutException{};
|
||||
}
|
||||
else
|
||||
{
|
||||
if constexpr (Nothrow) return true;
|
||||
else return std::forward<decltype(atomic)>(atomic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <DecayedType ValueType> template <bool Nothrow, typename ConditionFunction, typename Duration>
|
||||
auto detail_::AtomicBase<ValueType, false>::lock_
|
||||
(auto&& atomic, ConditionFunction&& condition_function, Duration timeout)
|
||||
-> LockReturnType_<decltype(atomic), Duration, Nothrow> requires LockConstraint_<ConditionFunction, Duration>
|
||||
{
|
||||
if constexpr (std::is_null_pointer_v<ConditionFunction>)
|
||||
return {std::unique_lock{atomic.Mutex_}, std::experimental::make_observer(&atomic), {}};
|
||||
else if constexpr (std::is_null_pointer_v<Duration>)
|
||||
{
|
||||
std::unique_lock lock{atomic.Mutex_};
|
||||
atomic.ConditionVariable_.wait(lock, [&]
|
||||
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));});
|
||||
return {std::move(lock), std::experimental::make_observer(&atomic), {}};
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_lock lock{atomic.Mutex_};
|
||||
if (!atomic.ConditionVariable_.wait_for(lock, timeout, [&]
|
||||
{return std::forward<ConditionFunction>(condition_function)(std::as_const(atomic.Value_));}))
|
||||
{
|
||||
if constexpr (Nothrow) return std::nullopt;
|
||||
else throw TimeoutException{};
|
||||
}
|
||||
else
|
||||
return {{std::move(lock), std::experimental::make_observer(&atomic), {}}};
|
||||
}
|
||||
}
|
||||
|
||||
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::Atomic(const ValueType& value)
|
||||
: detail_::AtomicBase<ValueType, UseLogger>{value} {}
|
||||
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::Atomic(ValueType&& value)
|
||||
: detail_::AtomicBase<ValueType, UseLogger>{std::move(value)} {}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
|
||||
Atomic<ValueType, UseLogger>::Atomic(const Atomic<ValueType, OtherUseLogger>& other)
|
||||
: detail_::AtomicBase<ValueType, UseLogger>{other} {}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
|
||||
Atomic<ValueType, UseLogger>::Atomic(Atomic<ValueType, OtherUseLogger>&& other)
|
||||
: detail_::AtomicBase<ValueType, UseLogger>{std::move(other)} {}
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
Atomic<ValueType, UseLogger>& Atomic<ValueType, UseLogger>::operator=(const ValueType& value)
|
||||
{
|
||||
std::scoped_lock lock{DeepBase_::Mutex_};
|
||||
DeepBase_::Value_ = value;
|
||||
DeepBase_::ConditionVariable_.notify_all();
|
||||
return *this;
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
Atomic<ValueType, UseLogger>& Atomic<ValueType, UseLogger>::operator=(ValueType&& value)
|
||||
{
|
||||
std::scoped_lock lock{DeepBase_::Mutex_};
|
||||
DeepBase_::Value_ = std::move(value);
|
||||
DeepBase_::ConditionVariable_.notify_all();
|
||||
return *this;
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
|
||||
Atomic<ValueType, UseLogger>& operator=(const Atomic<ValueType, OtherUseLogger>& other)
|
||||
{
|
||||
std::scoped_lock lock{DeepBase_::Mutex_};
|
||||
DeepBase_::Value_ = value;
|
||||
DeepBase_::ConditionVariable_.notify_all();
|
||||
return *this;
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool OtherUseLogger>
|
||||
Atomic<ValueType, UseLogger>& operator=(Atomic<ValueType, OtherUseLogger>&& other)
|
||||
{
|
||||
std::scoped_lock lock{DeepBase_::Mutex_};
|
||||
DeepBase_::Value_ = std::move(value);
|
||||
DeepBase_::ConditionVariable_.notify_all();
|
||||
return *this;
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> ValueType Atomic<ValueType, UseLogger>::get() const&
|
||||
{
|
||||
std::scoped_lock lock{DeepBase_::Mutex_};
|
||||
return DeepBase_::Value_;
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> ValueType Atomic<ValueType, UseLogger>::get() &&
|
||||
{
|
||||
std::scoped_lock lock{DeepBase_::Mutex_};
|
||||
return std::move(DeepBase_::Value_);
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::operator ValueType() const&
|
||||
{return get();}
|
||||
template <DecayedType ValueType, bool UseLogger> Atomic<ValueType, UseLogger>::operator ValueType() &&
|
||||
{return std::move(*this).get();}
|
||||
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function) const&
|
||||
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>
|
||||
{return apply_<ReturnFunctionResult>(*this, std::forward<decltype(function)>(function));}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function) &
|
||||
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>
|
||||
{return apply_<ReturnFunctionResult>(*this, std::forward<decltype(function)>(function));}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function) &&
|
||||
-> DeepBase_::template ApplyReturnType_<decltype(function), decltype(*this), ReturnFunctionResult>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this)>
|
||||
{return apply_<ReturnFunctionResult>(std::move(*this), std::forward<decltype(function)>(function));}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function) const&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this), decltype(condition_function)>
|
||||
{
|
||||
return apply_<ReturnFunctionResult>
|
||||
(
|
||||
*this, std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function)
|
||||
);
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function) &
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this), decltype(condition_function)>
|
||||
{
|
||||
return apply_<ReturnFunctionResult>
|
||||
(
|
||||
*this, std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function)
|
||||
);
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function) &&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<decltype(function), decltype(*this), ReturnFunctionResult, decltype(condition_function)>
|
||||
requires DeepBase_::template ApplyConstraint_<decltype(function), decltype(*this), decltype(condition_function)>
|
||||
{
|
||||
return apply_<ReturnFunctionResult>
|
||||
(
|
||||
std::move(*this), std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function)
|
||||
);
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult, bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function, auto timeout) const&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<
|
||||
decltype(function), decltype(*this), ReturnFunctionResult,
|
||||
decltype(condition_function), decltype(timeout), Nothrow
|
||||
> requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>
|
||||
{
|
||||
return apply_<ReturnFunctionResult, Nothrow>
|
||||
(
|
||||
*this, std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function), timeout
|
||||
);
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult, bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function, auto timeout) &
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<
|
||||
decltype(function), decltype(*this), ReturnFunctionResult,
|
||||
decltype(condition_function), decltype(timeout), Nothrow
|
||||
> requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>
|
||||
{
|
||||
return apply_<ReturnFunctionResult, Nothrow>
|
||||
(
|
||||
*this, std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function), timeout
|
||||
);
|
||||
}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool ReturnFunctionResult, bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::apply(auto&& function, auto&& condition_function, auto timeout) &&
|
||||
-> DeepBase_::template ApplyReturnType_
|
||||
<
|
||||
decltype(function), decltype(*this), ReturnFunctionResult,
|
||||
decltype(condition_function), decltype(timeout), Nothrow
|
||||
> requires DeepBase_::template ApplyConstraint_
|
||||
<decltype(function), decltype(*this), decltype(condition_function), decltype(timeout)>
|
||||
{
|
||||
return apply_<ReturnFunctionResult, Nothrow>
|
||||
(
|
||||
std::move(*this), std::forward<decltype(function)>(function),
|
||||
std::forward<decltype(condition_function)>(condition_function), timeout
|
||||
);
|
||||
}
|
||||
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function) const&
|
||||
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>
|
||||
{return wait_(*this, std::forward<decltype(condition_function)>(condition_function));}
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function) &
|
||||
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>
|
||||
{return wait_(*this, std::forward<decltype(condition_function)>(condition_function));}
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function) &&
|
||||
-> DeepBase_::template WaitReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function)>
|
||||
{return wait_(std::move(*this), std::forward<decltype(condition_function)>(condition_function));}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function, auto timeout) const&
|
||||
-> DeepBase_::template WaitReturnType_
|
||||
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>
|
||||
{return wait_<Nothrow>(*this, std::forward<decltype(condition_function)>(condition_function), timeout);}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function, auto timeout) &
|
||||
-> DeepBase_::template WaitReturnType_
|
||||
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>
|
||||
{return wait_<Nothrow>(*this, std::forward<decltype(condition_function)>(condition_function), timeout);}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::wait(auto&& condition_function, auto timeout) &&
|
||||
-> DeepBase_::template WaitReturnType_
|
||||
<decltype(*this), decltype(condition_function), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template WaitConstraint_<decltype(condition_function), decltype(timeout)>
|
||||
{
|
||||
return wait_<Nothrow>
|
||||
(std::move(*this), std::forward<decltype(condition_function)>(condition_function), timeout);
|
||||
}
|
||||
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Const> template <bool OtherConst>
|
||||
Atomic<ValueType, UseLogger>::Guard<Const>::Guard(const Guard<OtherConst>& other)
|
||||
requires (Const || !OtherConst)
|
||||
: Lock_{other.Lock_}, Value_{other.Value_} {}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Const>
|
||||
Atomic<ValueType, UseLogger>::Guard<Const>::Guard
|
||||
(decltype(Lock_)&& lock, decltype(Value_) value, CalledBy<detail_::AtomicBase<ValueType, UseLogger>>)
|
||||
: Lock_{std::move(lock)}, Value_{value} {}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Const>
|
||||
Atomic<ValueType, UseLogger>::Guard<Const>::~Guard()
|
||||
{Value_->ConditionVariable_.notify_all();}
|
||||
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Const>
|
||||
std::conditional_t<Const, const ValueType&, ValueType&>
|
||||
Atomic<ValueType, UseLogger>::Guard<Const>::operator*() const&
|
||||
{return Value_->Value_;}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Const>
|
||||
std::conditional_t<Const, const ValueType*, ValueType*>
|
||||
Atomic<ValueType, UseLogger>::Guard<Const>::operator->() const&
|
||||
{return &Value_->Value_;}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Const>
|
||||
std::conditional_t<Const, const ValueType&, ValueType&>
|
||||
Atomic<ValueType, UseLogger>::Guard<Const>::value() const&
|
||||
{return Value_->Value_;}
|
||||
|
||||
template <DecayedType ValueType, bool UseLogger> auto Atomic<ValueType, UseLogger>::lock() const&
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this)> requires DeepBase_::template LockConstraint_<>
|
||||
{return lock_(*this);}
|
||||
template <DecayedType ValueType, bool UseLogger> auto Atomic<ValueType, UseLogger>::lock() &
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this)> requires DeepBase_::template LockConstraint_<>
|
||||
{return lock_(*this);}
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function) const&
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function)>
|
||||
{return lock_(*this, condition_function);}
|
||||
template <DecayedType ValueType, bool UseLogger>
|
||||
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function) &
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(condition_function)>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function)>
|
||||
{return lock_(*this, condition_function);}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function, auto timeout) const&
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>
|
||||
{return lock_<Nothrow>(*this, condition_function, timeout);}
|
||||
template <DecayedType ValueType, bool UseLogger> template <bool Nothrow>
|
||||
auto Atomic<ValueType, UseLogger>::lock(auto&& condition_function, auto timeout) &
|
||||
-> DeepBase_::template LockReturnType_<decltype(*this), decltype(timeout), Nothrow>
|
||||
requires DeepBase_::template LockConstraint_<decltype(condition_function), decltype(timeout)>
|
||||
{return lock_<Nothrow>(*this, condition_function, timeout);}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
# include <regex>
|
||||
# include <optional>
|
||||
# include <filesystem>
|
||||
# include <generator>
|
||||
# include <type_traits>
|
||||
# include <fmt/format.h>
|
||||
# include <magic_enum_all.hpp>
|
||||
|
||||
@@ -100,8 +102,12 @@ namespace biu
|
||||
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);
|
||||
|
||||
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array from, Array to);
|
||||
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array to);
|
||||
}
|
||||
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;
|
||||
common::MoveQualifiers, common::FallbackIfNoTypeDeclared, common::exec, common::serialize, common::deserialize,
|
||||
common::sequence;
|
||||
}
|
||||
|
||||
@@ -47,4 +47,27 @@ namespace biu::common
|
||||
auto begin = reinterpret_cast<const std::byte*>(serialized_data.data()), end = begin + serialized_data.size();
|
||||
return deserialize<T>(std::vector<std::byte>{begin, end});
|
||||
}
|
||||
|
||||
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array from, Array to)
|
||||
{
|
||||
# ifndef NDEBUG
|
||||
assert(from.size() == to.size());
|
||||
for (std::size_t i = 0; i < from.size(); i++) assert(from[i] < to[i]);
|
||||
# endif
|
||||
Array current = from;
|
||||
std::size_t total = 0;
|
||||
auto make_next = [&](this auto&& self, std::size_t i)
|
||||
{
|
||||
if (i == from.size()) return false;
|
||||
else if (current[i] + 1 == to[i]) { current[i] = from[i]; return self(i + 1); }
|
||||
else { current[i]++; total++; return true; }
|
||||
};
|
||||
do { co_yield {current, total}; } while (make_next(0));
|
||||
}
|
||||
template <typename Array> std::generator<std::pair<Array, std::size_t>> sequence(Array to)
|
||||
{
|
||||
auto from = to;
|
||||
for (std::size_t i = 0; i < from.size(); i++) from[i] = 0;
|
||||
return sequence(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +46,11 @@ namespace biu
|
||||
= std::is_invocable_r_v<Result, Function, Args...>;
|
||||
|
||||
template <typename T> concept Arithmetic = std::is_arithmetic<T>::value || SpecializationOf<T, std::complex>;
|
||||
|
||||
template <typename T> concept Nullptr = std::is_null_pointer_v<std::remove_cvref_t<T>>;
|
||||
}
|
||||
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;
|
||||
concepts::InvocableWithResult, concepts::Arithmetic, concepts::Nullptr;
|
||||
}
|
||||
|
||||
@@ -32,10 +32,12 @@ namespace biu
|
||||
// if size is specified as a number, convert to fixed-size Eigen::Vector if specified size equals the size of the
|
||||
// input, otherwise throw an error
|
||||
// return deduced size if the size is deducible in compile time, otherwise return Empty
|
||||
template <std::size_t ToSize, typename Container> constexpr auto deduce_eigen_size();
|
||||
template <std::size_t ToSize, typename Container> consteval auto deduce_eigen_size();
|
||||
|
||||
// helper operator| to specify the size of the destination container
|
||||
template <std::size_t Row, std::size_t Col> struct ToEigenHelper {};
|
||||
template <std::size_t Size> struct FromEigenVectorHelper {};
|
||||
template <std::size_t Row, std::size_t Col> struct FromEigenMatrixHelper {};
|
||||
|
||||
// convert 1D standard container to Eigen::Matrix, the second argument should always be unspecified
|
||||
template <typename From, std::size_t ToSize> auto operator|
|
||||
@@ -51,11 +53,23 @@ namespace biu
|
||||
&& detail_::StandardContainer<typename From::value_type, typename From::value_type::value_type>
|
||||
&& Arithmetic<typename From::value_type::value_type>
|
||||
);
|
||||
|
||||
// convert 1D Eigen matrix to std::vector or std::array
|
||||
template <typename Vector, std::size_t ToSize> auto operator|
|
||||
(const Vector&, const detail_::FromEigenVectorHelper<ToSize>&);
|
||||
|
||||
// convert 2D Eigen matrix to std::vector or std::array
|
||||
template <typename Matrix, std::size_t ToRow, std::size_t ToCol> auto operator|
|
||||
(const Matrix&, const detail_::FromEigenMatrixHelper<ToRow, ToCol>&);
|
||||
}
|
||||
|
||||
// usage: some_value | toEigen<Row, Col>
|
||||
template <std::size_t Row = detail_::unspecifiedSize, std::size_t Col = detail_::unspecifiedSize>
|
||||
inline constexpr detail_::ToEigenHelper<Row, Col> toEigen;
|
||||
template <std::size_t Size = detail_::unspecifiedSize>
|
||||
inline constexpr detail_::FromEigenVectorHelper<Size> fromEigenVector;
|
||||
template <std::size_t Row = detail_::unspecifiedSize, std::size_t Col = detail_::unspecifiedSize>
|
||||
inline constexpr detail_::FromEigenMatrixHelper<Row, Col> fromEigenMatrix;
|
||||
|
||||
// test if a class is an eigen matrix
|
||||
namespace detail_
|
||||
@@ -66,7 +80,7 @@ namespace biu
|
||||
}
|
||||
template <typename Matrix> concept EigenMatrix = detail_::EigenMatrix<Matrix>::value;
|
||||
}
|
||||
using eigen::toEigen, eigen::EigenMatrix;
|
||||
using eigen::toEigen, eigen::fromEigenVector, eigen::fromEigenMatrix, eigen::EigenMatrix;
|
||||
}
|
||||
|
||||
// archive a matrix
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# pragma once
|
||||
# include <utility>
|
||||
# include <biu/eigen.hpp>
|
||||
# include <biu/common.hpp>
|
||||
# include <range/v3/view.hpp>
|
||||
@@ -6,10 +7,10 @@
|
||||
|
||||
namespace biu::eigen
|
||||
{
|
||||
template <std::size_t ToSize, typename Container> constexpr auto detail_::deduce_eigen_size()
|
||||
template <std::size_t ToSize, typename Container> consteval auto detail_::deduce_eigen_size()
|
||||
{
|
||||
if constexpr (ToSize == detail_::dynamicSize) return Empty{};
|
||||
else if constexpr (ToSize == detail_::unspecifiedSize)
|
||||
if constexpr (ToSize == dynamicSize) return Empty{};
|
||||
else if constexpr (ToSize == unspecifiedSize)
|
||||
if constexpr (SpecializationOfArray<Container>) return Container{}.size();
|
||||
else return Empty{};
|
||||
else
|
||||
@@ -105,6 +106,157 @@ namespace biu::eigen
|
||||
return Matrix(Eigen::Map<const Matrix>(data.data()));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Vector, std::size_t ToSize> auto detail_::operator|
|
||||
(const Vector& vector, const detail_::FromEigenVectorHelper<ToSize>&)
|
||||
{
|
||||
// 尽量在编译时获得大小并检查大小是否匹配,第一个返回值为确定的大小,第二个返回值为用于在运行时检查大小的函数
|
||||
auto get_size = []<std::size_t to_size>(this auto&& self) consteval
|
||||
{
|
||||
// 如果没有指定
|
||||
if constexpr (to_size == unspecifiedSize)
|
||||
// 如果两个维度都是动态的,那么作为动态大小处理
|
||||
if constexpr
|
||||
(
|
||||
Vector::CompileTimeTraits::RowsAtCompileTime == Eigen::Dynamic
|
||||
&& Vector::CompileTimeTraits::ColsAtCompileTime == Eigen::Dynamic
|
||||
)
|
||||
return std::make_pair
|
||||
(dynamicSize, [](const Vector& vector) { return vector.nrows() <= 1 && vector.ncols() <= 1; });
|
||||
// 如果两个维度都是固定的
|
||||
else if constexpr
|
||||
(
|
||||
Vector::CompileTimeTraits::RowsAtCompileTime != Eigen::Dynamic
|
||||
&& Vector::CompileTimeTraits::ColsAtCompileTime != Eigen::Dynamic
|
||||
)
|
||||
// 如果两个维度都超过了 1
|
||||
if constexpr
|
||||
(Vector::CompileTimeTraits::RowsAtCompileTime > 1 && Vector::CompileTimeTraits::ColsAtCompileTime > 1)
|
||||
throw std::invalid_argument("The size of the destination Eigen container mismatches the input container");
|
||||
// 否则返回两个维度的乘积
|
||||
else return std::make_pair
|
||||
(
|
||||
Vector::CompileTimeTraits::RowsAtCompileTime * Vector::CompileTimeTraits::ColsAtCompileTime,
|
||||
[](const Vector&) consteval { return true; }
|
||||
);
|
||||
// 如果固定的那个维度等于 1,那么为动态大小(大小取决于另外一个没有固定的维度)
|
||||
// 否则,大小等于这个维度,另一个维度是否为 1 留作之后检查
|
||||
else if constexpr (Vector::CompileTimeTraits::RowsAtCompileTime != Eigen::Dynamic)
|
||||
if constexpr (Vector::CompileTimeTraits::RowsAtCompileTime == 1)
|
||||
return std::make_pair(dynamicSize, [](const Vector&) consteval { return true; });
|
||||
else
|
||||
return std::make_pair
|
||||
(
|
||||
Vector::CompileTimeTraits::RowsAtCompileTime,
|
||||
[](const Vector& vector) { return vector.ncols() <= 1; }
|
||||
);
|
||||
else if constexpr (Vector::CompileTimeTraits::ColsAtCompileTime != Eigen::Dynamic)
|
||||
if constexpr (Vector::CompileTimeTraits::ColsAtCompileTime == 1)
|
||||
return std::make_pair(dynamicSize, [](const Vector&) consteval { return true; });
|
||||
else
|
||||
return std::make_pair
|
||||
(
|
||||
Vector::CompileTimeTraits::ColsAtCompileTime,
|
||||
[](const Vector& vector) { return vector.nrows() <= 1; }
|
||||
);
|
||||
else
|
||||
std::unreachable();
|
||||
// 如果指定了为动态:同样按照上述检查,但返回动态大小
|
||||
else if constexpr (to_size == dynamicSize)
|
||||
return std::make_pair(dynamicSize, self->template operator()<unspecifiedSize>().second);
|
||||
// 如果指定了大小:按照上述检查,如果判断为静态大小且大小不一致则报错,如果判断为动态大小则额外判断大小
|
||||
else
|
||||
{
|
||||
auto result = self->template operator()<unspecifiedSize>();
|
||||
if constexpr (result.first != dynamicSize)
|
||||
if constexpr (result.first != to_size)
|
||||
throw std::invalid_argument("The size of the destination Eigen container mismatches the input container");
|
||||
else
|
||||
return result;
|
||||
else
|
||||
return std::make_pair
|
||||
(
|
||||
to_size,
|
||||
[size = to_size](const Vector& vector) { return vector.size() == size; }
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// decomposition declarations can't be constexpr
|
||||
constexpr auto size = get_size.template operator()<ToSize>();
|
||||
# ifndef NDEBUG
|
||||
if (!size.second(vector))
|
||||
throw std::invalid_argument("The size of the destination Eigen container mismatches the input container");
|
||||
# endif
|
||||
if constexpr (size.first == dynamicSize)
|
||||
return std::vector<typename Vector::Scalar>(vector.data(), vector.data() + vector.size());
|
||||
else
|
||||
{
|
||||
auto to_array = []<std::size_t N, std::size_t... I>(const auto& vector, std::index_sequence<I...>)
|
||||
{ return std::array<typename Vector::Scalar, N>{vector[I]...}; };
|
||||
return to_array.template operator()<size.first>(vector.data(), std::make_index_sequence<size.first>());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Matrix, std::size_t ToRow, std::size_t ToCol> auto detail_::operator|
|
||||
(const Matrix& matrix, const detail_::FromEigenMatrixHelper<ToRow, ToCol>&)
|
||||
{
|
||||
auto get_size = [] consteval
|
||||
{
|
||||
auto get_one_size = []<std::size_t to_size, int eigen_size> consteval
|
||||
{
|
||||
// 如果没有指定
|
||||
if constexpr (to_size == unspecifiedSize)
|
||||
// 如果原大小是动态的,那么作为动态大小处理
|
||||
if constexpr (eigen_size == Eigen::Dynamic)
|
||||
return std::make_pair(dynamicSize, [](int) { return true; });
|
||||
// 否则返回原大小
|
||||
else return std::make_pair(eigen_size, [](int) { return true; });
|
||||
// 如果指定为动态大小:直接返回动态大小
|
||||
else if constexpr (to_size == dynamicSize)
|
||||
return std::make_pair(dynamicSize, [](int) { return true; });
|
||||
// 如果指定了大小:如果原大小是动态的则返回指定的大小,并在稍后检查;否则现在检查并返回
|
||||
else
|
||||
if constexpr (eigen_size == Eigen::Dynamic)
|
||||
return std::make_pair(to_size, [](int original_size) { return to_size == original_size; });
|
||||
else
|
||||
if constexpr (to_size == eigen_size)
|
||||
return std::make_pair(to_size, [](int) { return true; });
|
||||
else
|
||||
throw std::invalid_argument("The size of the destination Eigen container mismatches the input container");
|
||||
};
|
||||
constexpr auto row = get_one_size.template operator()<ToRow, Matrix::CompileTimeTraits::RowsAtCompileTime>();
|
||||
constexpr auto col = get_one_size.template operator()<ToCol, Matrix::CompileTimeTraits::ColsAtCompileTime>();
|
||||
return std::make_pair
|
||||
(
|
||||
std::make_pair(row.first, col.first),
|
||||
[row_check = row.second, col_check = col.second](const Matrix& matrix)
|
||||
{ return row_check(matrix.rows()) && col_check(matrix.cols()); }
|
||||
);
|
||||
};
|
||||
|
||||
// decomposition declarations can't be constexpr
|
||||
constexpr auto size = get_size();
|
||||
# ifndef NDEBUG
|
||||
if (!size.second(matrix))
|
||||
throw std::invalid_argument("The size of the destination Eigen container mismatches the input container");
|
||||
# endif
|
||||
|
||||
using container_per_row = std::conditional_t<size.first.second == dynamicSize,
|
||||
std::vector<typename Matrix::Scalar>, std::array<typename Matrix::Scalar, size.first.second>>;
|
||||
using container = std::conditional_t<size.first.first == dynamicSize,
|
||||
std::vector<container_per_row>, std::array<container_per_row, size.first.first>>;
|
||||
container result;
|
||||
if constexpr (size.first.first == dynamicSize) result.resize(matrix.rows());
|
||||
if constexpr (size.first.second == dynamicSize) for (auto& row : result) row.resize(matrix.cols());
|
||||
for (int i = 0; i < matrix.rows(); i++)
|
||||
{
|
||||
using RowVector = Eigen::RowVector
|
||||
<typename Matrix::Scalar, size.first.second == dynamicSize ? Eigen::Dynamic : size.first.second>;
|
||||
Eigen::Map<RowVector>(result[i].data(), 1, matrix.cols()) = matrix.row(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
template <typename Matrix> constexpr auto Eigen::serialize(auto & archive, Matrix& matrix)
|
||||
requires biu::EigenMatrix<std::remove_cvref_t<Matrix>>
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
# pragma once
|
||||
# include <variant>
|
||||
# include <optional>
|
||||
# include <experimental/memory>
|
||||
# include <fmt/ostream.h>
|
||||
# include <biu/string.hpp>
|
||||
# include <biu/concepts.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
namespace concepts
|
||||
{ template <typename T, typename Char = char> concept Formattable = fmt::is_formattable<T, Char>::value; }
|
||||
using concepts::Formattable;
|
||||
|
||||
namespace detail_
|
||||
namespace format::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(); }
|
||||
{ template <typename Char, Char... c> consteval format::detail_::FormatLiteralHelper<Char, c...> operator""_f(); }
|
||||
|
||||
namespace detail_
|
||||
namespace format::detail_
|
||||
{
|
||||
template <typename T> concept OptionalWrap
|
||||
= SpecializationOf<T, std::optional> || SpecializationOf<T, std::shared_ptr>
|
||||
@@ -32,14 +28,14 @@ namespace biu
|
||||
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
|
||||
template <typename T, typename Char> struct FormatterReuseProxy
|
||||
{
|
||||
constexpr auto parse(fmt::format_parse_context& ctx)
|
||||
-> std::invoke_result_t<decltype(&fmt::format_parse_context::begin), fmt::format_parse_context>;
|
||||
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx)
|
||||
-> typename fmt::basic_format_parse_context<Char>::iterator;
|
||||
};
|
||||
template <typename T>
|
||||
template <typename T, typename Char>
|
||||
requires (!SpecializationOf<T, std::weak_ptr> && std::default_initializable<fmt::formatter<T>>)
|
||||
struct FormatterReuseProxy<T> : fmt::formatter<T> {};
|
||||
struct FormatterReuseProxy<T, Char> : fmt::formatter<T, Char> {};
|
||||
}
|
||||
inline namespace stream_operators
|
||||
{
|
||||
@@ -50,20 +46,28 @@ namespace biu
|
||||
|
||||
namespace fmt
|
||||
{
|
||||
template <typename Char, biu::detail_::OptionalWrap Wrap> struct formatter<Wrap, Char>
|
||||
: biu::detail_::FormatterReuseProxy<typename biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type>
|
||||
template <typename Char, biu::format::detail_::OptionalWrap Wrap> struct formatter<Wrap, Char>
|
||||
: biu::format::detail_::FormatterReuseProxy
|
||||
<typename biu::format::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type, Char>
|
||||
{
|
||||
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx)
|
||||
-> std::invoke_result_t<decltype(&FormatContext::out), FormatContext>;
|
||||
template <typename FormatContext> auto format(const Wrap& wrap, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator;
|
||||
};
|
||||
|
||||
template <biu::SpecializationOf<std::sub_match> SubMatch> struct formatter<SubMatch, typename SubMatch::value_type>
|
||||
: formatter<std::basic_string<typename SubMatch::value_type>, typename SubMatch::value_type>
|
||||
{
|
||||
template <typename FormatContext> auto format(const SubMatch& match, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator;
|
||||
};
|
||||
|
||||
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>;
|
||||
constexpr auto parse(fmt::basic_format_parse_context<Char>& ctx)
|
||||
-> typename fmt::basic_format_parse_context<Char>::iterator;
|
||||
template <typename FormatContext> auto format(const T& value, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator;
|
||||
};
|
||||
|
||||
template <typename Char, typename... Ts> struct formatter<std::variant<Ts...>, Char>
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
# pragma once
|
||||
# include <fmt/core.h>
|
||||
# include <fmt/ranges.h>
|
||||
# include <fmt/std.h>
|
||||
# include <fmt/ostream.h>
|
||||
# include <fmt/chrono.h>
|
||||
# include <fmt/xchar.h>
|
||||
# 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
|
||||
std::basic_string<Char> format::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()
|
||||
format::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>
|
||||
template <typename T, typename Char> constexpr
|
||||
auto format::detail_::FormatterReuseProxy<T, Char>::parse(fmt::basic_format_parse_context<Char>& ctx)
|
||||
-> typename fmt::basic_format_parse_context<Char>::iterator
|
||||
{
|
||||
if (ctx.begin() != ctx.end() && *ctx.begin() != '}')
|
||||
throw fmt::format_error
|
||||
@@ -33,7 +38,8 @@ namespace biu
|
||||
{
|
||||
if (holds_alternative<T>(value))
|
||||
{
|
||||
if constexpr (biu::Formattable<T, Char>) os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
|
||||
if constexpr (fmt::is_formattable<T, Char>::value)
|
||||
os << "({}: {})"_f(nameof::nameof_full_type<T>(), get<T>(value));
|
||||
else os << "({}: {})"_f(nameof::nameof_full_type<T>(), "non-null unformattable value");
|
||||
}
|
||||
};
|
||||
@@ -44,16 +50,17 @@ namespace biu
|
||||
|
||||
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>
|
||||
template <typename Char, biu::format::detail_::OptionalWrap Wrap> template <typename FormatContext>
|
||||
auto formatter<Wrap, Char>::format(const Wrap& wrap, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator
|
||||
{
|
||||
using value_t = biu::detail_::UnderlyingTypeOfOptionalWrap<Wrap>::Type;
|
||||
using value_t = biu::format::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");
|
||||
if constexpr (!fmt::is_formattable<value_t, Char>::value)
|
||||
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);
|
||||
biu::format::detail_::FormatterReuseProxy<value_t, Char>::format(value, ctx);
|
||||
else fmt::format_to(ctx.out(), "{}", value);
|
||||
};
|
||||
fmt::format_to(ctx.out(), "(");
|
||||
@@ -73,8 +80,16 @@ namespace fmt
|
||||
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>
|
||||
template <biu::SpecializationOf<std::sub_match> SubMatch> template <typename FormatContext>
|
||||
auto formatter<SubMatch, typename SubMatch::value_type>::format(const SubMatch& match, FormatContext& ctx) const
|
||||
-> typename FormatContext::iterator
|
||||
{
|
||||
return formatter<std::basic_string<typename SubMatch::value_type>, typename SubMatch::value_type>::format
|
||||
(match.str(), ctx);
|
||||
}
|
||||
|
||||
template <typename Char, biu::Enumerable T> constexpr auto formatter<T, Char>::parse
|
||||
(fmt::basic_format_parse_context<Char>& ctx) -> typename fmt::basic_format_parse_context<Char>::iterator
|
||||
{
|
||||
auto it = ctx.begin();
|
||||
if (it != ctx.end() && *it == 'f') { full = true; it++; }
|
||||
@@ -83,8 +98,7 @@ namespace fmt
|
||||
}
|
||||
|
||||
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>
|
||||
auto formatter<T, Char>::format(const T& value, FormatContext& ctx) const -> typename FormatContext::iterator
|
||||
{
|
||||
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));
|
||||
|
||||
28
packages/biu/include/biu/hdf5.hpp
Normal file
28
packages/biu/include/biu/hdf5.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
# pragma once
|
||||
# include <highfive/H5File.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
namespace hdf5
|
||||
{
|
||||
struct PhonopyComplex { double r, i; };
|
||||
namespace detail_
|
||||
{
|
||||
HighFive::CompoundType create_phonopy_complex();
|
||||
}
|
||||
|
||||
class Hdf5file
|
||||
{
|
||||
public:
|
||||
Hdf5file(std::string filename, bool readonly = false);
|
||||
template <typename T> Hdf5file& read(std::string name, T& object);
|
||||
template <typename T> T read(std::string name);
|
||||
template <typename T> Hdf5file& write(std::string name, const T& object);
|
||||
protected:
|
||||
HighFive::File File_;
|
||||
};
|
||||
}
|
||||
using hdf5::Hdf5file, hdf5::PhonopyComplex;
|
||||
}
|
||||
|
||||
HIGHFIVE_REGISTER_TYPE(biu::hdf5::PhonopyComplex, biu::hdf5::detail_::create_phonopy_complex)
|
||||
12
packages/biu/include/biu/hdf5.tpp
Normal file
12
packages/biu/include/biu/hdf5.tpp
Normal file
@@ -0,0 +1,12 @@
|
||||
# pragma once
|
||||
# include <biu/hdf5.hpp>
|
||||
|
||||
namespace biu::hdf5
|
||||
{
|
||||
template <typename T> Hdf5file& Hdf5file::read(std::string name, T& object)
|
||||
{ object = File_.getDataSet(name).read<std::remove_cvref_t<decltype(object)>>(); return *this; }
|
||||
template <typename T> T Hdf5file::read(std::string name)
|
||||
{ std::remove_cvref_t<T> object; read(name, object); return object; }
|
||||
template <typename T> Hdf5file& Hdf5file::write(std::string name, const T& object)
|
||||
{ File_.createDataSet(name, object); return *this; }
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
# pragma once
|
||||
# include <map>
|
||||
# include <boost/stacktrace.hpp>
|
||||
# include <biu/atomic/nolog.hpp>
|
||||
# include <biu/atomic.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
@@ -17,7 +17,6 @@ namespace biu
|
||||
{
|
||||
None,
|
||||
Error,
|
||||
Access,
|
||||
Info,
|
||||
Debug
|
||||
};
|
||||
@@ -27,18 +26,17 @@ namespace biu
|
||||
std::shared_ptr<std::ostream> StreamStorage;
|
||||
Logger::Level Level;
|
||||
};
|
||||
protected: static Atomic<std::optional<LoggerConfigType_>, false> LoggerConfig_;
|
||||
protected: static Atomic<std::optional<LoggerConfigType_>> LoggerConfig_;
|
||||
public: static void init(std::experimental::observer_ptr<std::ostream> stream, Level level);
|
||||
public: static void init(std::shared_ptr<std::ostream> stream, Level level);
|
||||
|
||||
// Send a telegram message if token and chat id are set, all the functions are thread-safe
|
||||
protected: static Atomic<std::optional<std::pair<std::string, std::string>>, false> TelegramConfig_;
|
||||
protected: static Atomic<std::optional<std::pair<std::string, std::string>>> TelegramConfig_;
|
||||
public: static void telegram_init(const std::string& token, const std::string& chat_id);
|
||||
public: static void telegram_notify(const std::string& message);
|
||||
public: static void telegram_notify_async(const std::string& message);
|
||||
public: static void telegram_notify(const std::string& message, bool async = false);
|
||||
|
||||
// Monitor the lifetime of an object
|
||||
// usage: struct my_class : protected Logger::ObjectMonitor<my_class> {}
|
||||
// usage: struct my_class : protected Logger::ObjectMonitor<my_class> { ... }
|
||||
public: template <typename T> class ObjectMonitor
|
||||
{
|
||||
protected: const std::chrono::time_point<std::chrono::steady_clock> CreateTime_;
|
||||
@@ -52,7 +50,7 @@ namespace biu
|
||||
template <typename T> friend class ObjectMonitor;
|
||||
|
||||
// List of objects that is being monitored by ObjectMonitor, {address, type}
|
||||
protected: static Atomic<std::multimap<const void*, std::string_view>, false> Objects_;
|
||||
protected: static Atomic<std::multimap<const void*, std::string_view>> Objects_;
|
||||
|
||||
public: template <typename FinalException> class Exception : public std::exception
|
||||
{
|
||||
@@ -70,16 +68,18 @@ namespace biu
|
||||
{
|
||||
protected: thread_local static unsigned Indent_;
|
||||
protected: const std::chrono::time_point<std::chrono::steady_clock> StartTime_;
|
||||
protected: std::size_t get_time_ms() const;
|
||||
protected: std::size_t get_thread_id() const;
|
||||
|
||||
// if sizeof...(Param) > 0, call log<Debug>("begin function with {arguments}.");
|
||||
// else call log<Debug>("begin function.");
|
||||
public: template <typename... Param> [[gnu::always_inline]] explicit Guard(Param&&... param);
|
||||
|
||||
// call log<Debug>("end function after {duration} ms.")
|
||||
public: [[gnu::always_inline]] virtual ~Guard();
|
||||
public: [[gnu::always_inline]] inline virtual ~Guard();
|
||||
|
||||
// call log<Debug>("reached after {duration} ms.")
|
||||
public: [[gnu::always_inline]] void operator()() const;
|
||||
public: [[gnu::always_inline]] inline void operator()() const;
|
||||
|
||||
// call log<Debug>("return {return} after {duration} ms.")
|
||||
public: template <typename T> [[gnu::always_inline]] T rtn(T&& value) const;
|
||||
@@ -88,6 +88,9 @@ namespace biu
|
||||
// LoggerConfig_
|
||||
// [ {time} {thread} {indent} {filename}:{line} {function_name} ] {message}
|
||||
public: template <Level L> [[gnu::always_inline]] void log(const std::string& message) const;
|
||||
public: [[gnu::always_inline]] inline void error(const std::string& message) const;
|
||||
public: [[gnu::always_inline]] inline void info(const std::string& message) const;
|
||||
public: [[gnu::always_inline]] inline void debug(const std::string& message) const;
|
||||
|
||||
public: template <typename FinalException> [[gnu::always_inline]] void print_exception
|
||||
(
|
||||
@@ -98,6 +101,6 @@ namespace biu
|
||||
friend class Guard;
|
||||
|
||||
// list of threads which is being monitored by Guard and number of Guard created in this thread so far
|
||||
protected: static Atomic<std::map<std::size_t, std::size_t>, false> Threads_;
|
||||
protected: static Atomic<std::map<std::size_t, std::size_t>> Threads_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,9 +11,8 @@ namespace biu
|
||||
: CreateTime_{std::chrono::steady_clock::now()}
|
||||
{
|
||||
Guard guard;
|
||||
guard.log<Level::Debug>("create {} at {}."_f(nameof::nameof_full_type<T>(), fmt::ptr(this)));
|
||||
auto&& lock = Objects_.lock();
|
||||
lock->emplace(this, nameof::nameof_full_type<T>());
|
||||
Objects_.lock()->emplace(this, nameof::nameof_full_type<T>());
|
||||
guard.debug("create {} at {}."_f(nameof::nameof_full_type<T>(), fmt::ptr(this)));
|
||||
}
|
||||
template <typename T> Logger::ObjectMonitor<T>::~ObjectMonitor()
|
||||
{
|
||||
@@ -26,80 +25,41 @@ namespace biu
|
||||
));
|
||||
auto&& lock = Objects_.lock();
|
||||
auto range = lock->equal_range(this);
|
||||
for (auto it = range.first; it != range.second; it++)
|
||||
if (it->second == nameof::nameof_full_type<T>())
|
||||
{
|
||||
lock->erase(it);
|
||||
return;
|
||||
}
|
||||
guard.log<Level::Error>
|
||||
("{} {} not found in Logger::Objects."_f(fmt::ptr(this), nameof::nameof_full_type<T>()));
|
||||
for (auto it = range.first; it != range.second; it++) if (it->second == nameof::nameof_full_type<T>())
|
||||
{ lock->erase(it); return; }
|
||||
guard.error("{} {} not found in Logger::Objects."_f(fmt::ptr(this), nameof::nameof_full_type<T>()));
|
||||
}
|
||||
|
||||
template <typename FinalException> Logger::Exception<FinalException>::Exception(const std::string& message)
|
||||
{
|
||||
Logger::Guard log{message};
|
||||
log.print_exception(nameof::nameof_full_type<FinalException>(), message, Stacktrace_);
|
||||
Logger::Guard log(message);
|
||||
log.print_exception(nameof::nameof_full_type<FinalException>(), message, Stacktrace_, {});
|
||||
}
|
||||
|
||||
template <typename... Param> inline Logger::Guard::Guard(Param&&... param)
|
||||
template <typename... Param> Logger::Guard::Guard(Param&&... param)
|
||||
: StartTime_{std::chrono::steady_clock::now()}
|
||||
{
|
||||
Indent_++;
|
||||
auto&& lock = Threads_.lock();
|
||||
auto thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id());
|
||||
if (lock->contains(thread_id))
|
||||
lock.value()[thread_id]++;
|
||||
else
|
||||
lock->emplace(thread_id, 1);
|
||||
if (auto thread_id = get_thread_id(); lock->contains(thread_id)) lock.value()[thread_id]++;
|
||||
else lock->emplace(thread_id, 1);
|
||||
if constexpr (sizeof...(Param) > 0)
|
||||
{
|
||||
std::stringstream ss;
|
||||
std::vector<std::string> params = {"{}"_f(std::forward<Param>(param))...};
|
||||
ss << "begin function with {";
|
||||
for (auto& param : params)
|
||||
ss << param << ", ";
|
||||
ss.seekp(-2, ss.cur);
|
||||
ss << "}.";
|
||||
log<Level::Debug>(ss.str());
|
||||
}
|
||||
else
|
||||
log<Level::Debug>("begin function.");
|
||||
debug("begin function with {{{}}}."_f(fmt::join({"{}"_f(std::forward<Param>(param))...}, ", ")));
|
||||
else debug("begin function.");
|
||||
}
|
||||
inline Logger::Guard::~Guard()
|
||||
|
||||
Logger::Guard::~Guard()
|
||||
{
|
||||
log<Level::Debug>("end function after {} ms."_f(std::chrono::duration_cast<std::chrono::milliseconds>
|
||||
(std::chrono::steady_clock::now() - StartTime_).count()));
|
||||
debug("end function after {} ms."_f(get_time_ms()));
|
||||
Indent_--;
|
||||
auto&& lock = Threads_.lock();
|
||||
auto thread_id = std::hash<std::thread::id>{}(std::this_thread::get_id());
|
||||
if (lock->contains(thread_id))
|
||||
{
|
||||
lock.value()[thread_id]--;
|
||||
if (lock.value()[thread_id] == 0)
|
||||
lock->erase(thread_id);
|
||||
}
|
||||
if (auto thread_id = get_thread_id(); lock->contains(thread_id))
|
||||
{ lock.value()[thread_id]--; if (lock.value()[thread_id] == 0) lock->erase(thread_id); }
|
||||
else [[unlikely]]
|
||||
log<Level::Debug>("{:08x} not found in Logger::Threads."_f
|
||||
(std::hash<std::thread::id>{}(std::this_thread::get_id()) % std::numeric_limits<std::uint64_t>::max()));
|
||||
error("{:08x} not found in Logger::Threads."_f(thread_id % std::numeric_limits<std::uint64_t>::max()));
|
||||
}
|
||||
inline void Logger::Guard::operator()() const
|
||||
{
|
||||
log<Level::Debug>("reached after {} ms."_f
|
||||
(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - StartTime_).count()
|
||||
));
|
||||
}
|
||||
template <typename T> inline T Logger::Guard::rtn(T&& value) const
|
||||
{
|
||||
log<Level::Debug>("return {} after {} ms."_f
|
||||
(
|
||||
std::forward<T>(value),
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - StartTime_).count()
|
||||
));
|
||||
return std::forward<T>(value);
|
||||
}
|
||||
template <Logger::Level L> inline void Logger::Guard::log(const std::string& message) const
|
||||
void Logger::Guard::operator()() const { debug("reached after {} ms."_f(get_time_ms())); }
|
||||
template <Logger::Level L> void Logger::Guard::log(const std::string& message) const
|
||||
{
|
||||
if (auto&& lock = LoggerConfig_.lock(); *lock && lock.value()->Level >= L)
|
||||
{
|
||||
@@ -110,8 +70,7 @@ namespace biu
|
||||
(
|
||||
time,
|
||||
std::chrono::time_point_cast<std::chrono::milliseconds>(time).time_since_epoch().count() % 1000,
|
||||
std::hash<std::thread::id>{}(std::this_thread::get_id())
|
||||
% std::numeric_limits<std::uint64_t>::max(),
|
||||
get_thread_id() % std::numeric_limits<std::uint64_t>::max(),
|
||||
Indent_,
|
||||
stack[0].source_file().empty() ? "??"s : stack[0].source_file(),
|
||||
stack[0].source_line() == 0 ? "??"s : "{}"_f(stack[0].source_line()),
|
||||
@@ -120,6 +79,16 @@ namespace biu
|
||||
) << std::flush;
|
||||
}
|
||||
}
|
||||
void Logger::Guard::error(const std::string& message) const { log<Level::Error>(message); }
|
||||
void Logger::Guard::info(const std::string& message) const { log<Level::Info>(message); }
|
||||
void Logger::Guard::debug(const std::string& message) const { log<Level::Debug>(message); }
|
||||
|
||||
template <typename T> inline T Logger::Guard::rtn(T&& value) const
|
||||
{
|
||||
debug("return {} after {} ms."_f(std::forward<T>(value), get_time_ms()));
|
||||
return std::forward<T>(value);
|
||||
}
|
||||
|
||||
template <typename FinalException> inline void Logger::Guard::print_exception
|
||||
(
|
||||
const std::string& type, const std::string& message, const boost::stacktrace::stacktrace& stacktrace,
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
# include <string>
|
||||
# include <string_view>
|
||||
# include <iostream>
|
||||
# include <generator>
|
||||
# include <biu/concepts.hpp>
|
||||
# include <biu/smartref.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
@@ -36,6 +38,13 @@ namespace biu
|
||||
template <std::size_t M> requires (M<=N) constexpr BasicVariableString(const Char (&str)[M]);
|
||||
};
|
||||
template <std::size_t N> using VariableString = BasicVariableString<char, N>;
|
||||
|
||||
// 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().
|
||||
std::generator<std::pair<std::string_view, std::sregex_iterator>> find
|
||||
(SmartRef<const std::string> data, SmartRef<const std::regex> regex);
|
||||
std::string replace
|
||||
(const std::string& data, const std::regex& regex, std::function<std::string(const std::smatch&)> function);
|
||||
}
|
||||
using string::BasicStaticString, string::StaticString, string::BasicFixedString, string::FixedString,
|
||||
string::BasicVariableString, string::VariableString;
|
||||
@@ -105,13 +114,3 @@ namespace biu
|
||||
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);
|
||||
// }
|
||||
|
||||
15
packages/biu/src/hdf5.cpp
Normal file
15
packages/biu/src/hdf5.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
# include <biu.hpp>
|
||||
|
||||
namespace biu::hdf5
|
||||
{
|
||||
Hdf5file::Hdf5file(std::string filename, bool readonly)
|
||||
: File_
|
||||
(
|
||||
filename,
|
||||
readonly ? HighFive::File::ReadOnly
|
||||
: HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Truncate
|
||||
)
|
||||
{}
|
||||
HighFive::CompoundType detail_::create_phonopy_complex()
|
||||
{ return {{ "r", HighFive::AtomicType<double>{}}, {"i", HighFive::AtomicType<double>{}}}; }
|
||||
}
|
||||
@@ -3,34 +3,37 @@
|
||||
|
||||
namespace biu
|
||||
{
|
||||
Atomic<std::optional<typename Logger::LoggerConfigType_>, false> Logger::LoggerConfig_;
|
||||
Atomic<std::optional<Logger::LoggerConfigType_>> Logger::LoggerConfig_;
|
||||
void Logger::init(std::experimental::observer_ptr<std::ostream> stream, Level level)
|
||||
{
|
||||
auto&& lock = LoggerConfig_.lock();
|
||||
lock->emplace(stream, nullptr, level);
|
||||
}
|
||||
{ LoggerConfig_ = LoggerConfigType_{stream, nullptr, level}; }
|
||||
void Logger::init(std::shared_ptr<std::ostream> stream, Level level)
|
||||
{
|
||||
auto&& lock = LoggerConfig_.lock();
|
||||
lock->emplace(std::experimental::make_observer(stream.get()), stream, level);
|
||||
}
|
||||
{ LoggerConfig_ = LoggerConfigType_{std::experimental::make_observer(stream.get()), stream, level}; }
|
||||
|
||||
Atomic<std::optional<std::pair<std::string, std::string>>, false> Logger::TelegramConfig_;
|
||||
Atomic<std::optional<std::pair<std::string, std::string>>> Logger::TelegramConfig_;
|
||||
void Logger::telegram_init(const std::string& token, const std::string& chat_id)
|
||||
{TelegramConfig_ = std::make_pair(token, chat_id);}
|
||||
void Logger::telegram_notify(const std::string& message)
|
||||
{ TelegramConfig_ = std::make_pair(token, chat_id); }
|
||||
void Logger::telegram_notify(const std::string& message, bool async)
|
||||
{
|
||||
if (auto&& lock = TelegramConfig_.lock(); *lock)
|
||||
auto notify = [](const std::string& message)
|
||||
{
|
||||
TgBot::Bot bot{lock.value()->first};
|
||||
auto&& lock = TelegramConfig_.lock();
|
||||
TgBot::Bot bot(lock.value()->first);
|
||||
bot.getApi().sendMessage(lock.value()->first, message);
|
||||
}
|
||||
};
|
||||
if (async) std::thread(notify, message).detach();
|
||||
else notify(message);
|
||||
}
|
||||
void Logger::telegram_notify_async(const std::string& message)
|
||||
{std::thread{Logger::telegram_notify, message}.detach();}
|
||||
|
||||
Atomic<std::multimap<const void*, std::string_view>, false> Logger::Objects_;
|
||||
Atomic<std::multimap<const void*, std::string_view>> Logger::Objects_;
|
||||
|
||||
thread_local unsigned Logger::Guard::Indent_ = 0;
|
||||
Atomic<std::map<std::size_t, std::size_t>, false> Logger::Threads_;
|
||||
std::size_t Logger::Guard::get_time_ms() const
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>
|
||||
(std::chrono::steady_clock::now() - StartTime_).count();
|
||||
}
|
||||
std::size_t Logger::Guard::get_thread_id() const
|
||||
{ return std::hash<std::thread::id>{}(std::this_thread::get_id()); }
|
||||
|
||||
Atomic<std::map<std::size_t, std::size_t>> Logger::Threads_;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# include <fmt/chrono.h>
|
||||
# include <biu.hpp>
|
||||
|
||||
namespace biu
|
||||
{
|
||||
concurrencpp::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
|
||||
std::generator<std::pair<std::string_view, std::sregex_iterator>> string::find
|
||||
(SmartRef<const std::string> data, SmartRef<const std::regex> regex)
|
||||
{
|
||||
Logger::Guard log;
|
||||
@@ -11,17 +10,14 @@ namespace biu
|
||||
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{}) 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)));
|
||||
log.debug("distance: {}"_f(std::distance(unmatched_prefix_begin, unmatched_prefix_end)));
|
||||
}
|
||||
else
|
||||
unmatched_prefix_end = (*regit)[0].first;
|
||||
else unmatched_prefix_end = (*regit)[0].first;
|
||||
co_yield
|
||||
{
|
||||
std::string_view
|
||||
@@ -31,8 +27,7 @@ namespace biu
|
||||
},
|
||||
regit
|
||||
};
|
||||
if (regit == std::sregex_iterator{})
|
||||
break;
|
||||
if (regit == std::sregex_iterator{}) break;
|
||||
unmatched_prefix_begin = (*regit)[0].second;
|
||||
}
|
||||
}
|
||||
@@ -45,8 +40,7 @@ namespace biu
|
||||
for (auto matched : find(data, regex))
|
||||
{
|
||||
result.append(matched.first);
|
||||
if (matched.second != std::sregex_iterator{})
|
||||
result.append(function(*matched.second));
|
||||
if (matched.second != std::sregex_iterator{}) result.append(function(*matched.second));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
16
packages/biu/test/atomic.cpp
Normal file
16
packages/biu/test/atomic.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
# include <biu.hpp>
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
biu::Atomic<std::string> a("hello");
|
||||
a = "world";
|
||||
a.apply([](auto& value) { value += "!"; });
|
||||
auto b = a.get();
|
||||
auto lock = a.lock();
|
||||
*lock = "!";
|
||||
static_assert(std::same_as<decltype(a.apply([](auto& value) { value += "!"; })), biu::Atomic<std::string>&>);
|
||||
static_assert(std::same_as<decltype(a.apply([](auto&) { return 3; })), int>);
|
||||
static_assert(std::same_as<decltype(a.apply([](auto&) {}, [](auto&){ return true; }, 1s)), bool>);
|
||||
static_assert
|
||||
(std::same_as<decltype(a.apply([](auto&) { return 3; }, [](auto&){ return true; }, 1s)), std::optional<int>>);
|
||||
}
|
||||
8
packages/biu/test/common.cpp
Normal file
8
packages/biu/test/common.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
# include <biu.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
for (auto [a, b] : biu::sequence(std::array{2, 2, 2}))
|
||||
std::cout << "{} {}\n"_f(a, b);
|
||||
}
|
||||
@@ -15,6 +15,13 @@ int main()
|
||||
auto d = std::array{std::array{1, 2}, std::array{3, 4}, std::array{5, 6}}
|
||||
| biu::eigen::toEigen<>;
|
||||
static_assert(std::same_as<decltype(d), Eigen::Matrix<int, 3, 2, Eigen::RowMajor | Eigen::AutoAlign>>);
|
||||
auto f = std::vector{1, 2, 3, 4, 5};
|
||||
assert(f == (f | biu::toEigen<> | biu::fromEigenVector<>));
|
||||
auto h = std::array{1, 2, 3};
|
||||
assert(h == (h | biu::toEigen<> | biu::fromEigenVector<>));
|
||||
auto g = std::vector
|
||||
{std::array{1, 2}, std::array{3, 4}, std::array{5, 6}};
|
||||
assert(g == (g | biu::toEigen<> | biu::fromEigenMatrix<>));
|
||||
|
||||
auto e = biu::deserialize<decltype(c)>(biu::serialize(c));
|
||||
static_assert(std::same_as<decltype(e), decltype(c)>);
|
||||
|
||||
15
packages/biu/test/format.cpp
Normal file
15
packages/biu/test/format.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
# include <biu.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
|
||||
std::optional<int> a = 3;
|
||||
std::cout << "{}\n"_f(a);
|
||||
|
||||
auto b = "hello"s;
|
||||
auto c = "h(ell)o"_re;
|
||||
std::smatch d;
|
||||
assert(std::regex_match(b, d, c));
|
||||
assert("{}"_f(d[1]) == "ell");
|
||||
}
|
||||
@@ -58,22 +58,29 @@ inputs: rec
|
||||
mumax = inputs.pkgs.callPackage ./mumax.nix { src = inputs.topInputs.mumax; };
|
||||
kylin-virtual-keyboard = inputs.pkgs.libsForQt5.callPackage ./kylin-virtual-keyboard.nix
|
||||
{ src = inputs.topInputs.kylin-virtual-keyboard; };
|
||||
biu = inputs.pkgs.callPackage ./biu { inherit nameof zpp-bits; };
|
||||
biu = inputs.pkgs.callPackage ./biu
|
||||
{
|
||||
inherit nameof zpp-bits tgbot-cpp;
|
||||
stdenv = inputs.pkgs.gcc14Stdenv;
|
||||
fmt = inputs.pkgs.fmt_11.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./biu/fmt.patch ]; });
|
||||
};
|
||||
zxorm = inputs.pkgs.callPackage ./zxorm.nix { src = inputs.topInputs.zxorm; };
|
||||
hpcstat = inputs.pkgs.callPackage ./hpcstat
|
||||
{ inherit sqlite-orm date biu openxlsx; stdenv = inputs.pkgs.gcc14Stdenv; };
|
||||
openxlsx = inputs.pkgs.callPackage ./openxlsx.nix { src = inputs.topInputs.openxlsx; };
|
||||
sqlite-orm = inputs.pkgs.callPackage ./sqlite-orm.nix { src = inputs.topInputs.sqlite-orm; };
|
||||
mkPnpmPackage = inputs.pkgs.callPackage ./mkPnpmPackage.nix {};
|
||||
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; };
|
||||
sbatch-tui = inputs.pkgs.callPackage ./sbatch-tui { inherit biu; stdenv = inputs.pkgs.gcc14Stdenv; };
|
||||
ufo = inputs.pkgs.callPackage ./ufo
|
||||
{ inherit concurrencpp biu matplotplusplus zpp-bits; tbb = inputs.pkgs.tbb_2021_11; };
|
||||
{
|
||||
inherit concurrencpp biu matplotplusplus zpp-bits;
|
||||
tbb = inputs.pkgs.tbb_2021_11;
|
||||
stdenv = inputs.pkgs.gcc14Stdenv;
|
||||
};
|
||||
chn-bsub = inputs.pkgs.callPackage ./chn-bsub { inherit biu; };
|
||||
winjob = inputs.pkgs.callPackage ./winjob { stdenv = inputs.pkgs.gcc14Stdenv; };
|
||||
sockpp = inputs.pkgs.callPackage ./sockpp.nix { src = inputs.topInputs.sockpp; };
|
||||
git-lfs-transfer = inputs.pkgs.callPackage ./git-lfs-transfer.nix { src = inputs.topInputs.git-lfs-transfer; };
|
||||
fcitx5-virtualkeyboard-ui = inputs.pkgs.callPackage ./fcitx5-virtualkeyboard-ui.nix
|
||||
{ src = inputs.topInputs.fcitx5-virtualkeyboard-ui; };
|
||||
|
||||
fromYaml = content: builtins.fromJSON (builtins.readFile
|
||||
(inputs.pkgs.runCommand "toJSON" {}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
lib, stdenv, src, substituteAll,
|
||||
cmake, extra-cmake-modules, fcitx5, gettext, fmt, cairo, expat, libXdmcp, pango, pcre2, util-linux, libselinux,
|
||||
libsepol, fribidi, libthai, libdatrie, xorg, kdePackages, egl-wayland, eglexternalplatform, gdk-pixbuf, lerc
|
||||
}: stdenv.mkDerivation
|
||||
{
|
||||
name = "fcitx5-virtualkeyboard-ui";
|
||||
inherit src;
|
||||
cmakeFlags = [ "-DWAYLAND_PROTOCOLS_PKGDATADIR=${kdePackages.wayland-protocols}/share/wayland-protocols" ];
|
||||
|
||||
nativeBuildInputs = [ cmake extra-cmake-modules ];
|
||||
buildInputs =
|
||||
[
|
||||
fcitx5 gettext fmt cairo expat libXdmcp pango pcre2 util-linux libselinux libsepol fribidi libthai libdatrie
|
||||
xorg.xcbutil xorg.xcbutilwm xorg.xcbutilkeysyms kdePackages.wayland kdePackages.wayland-protocols egl-wayland
|
||||
eglexternalplatform gdk-pixbuf lerc
|
||||
];
|
||||
}
|
||||
@@ -38,3 +38,9 @@ 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}")
|
||||
|
||||
include(CTest)
|
||||
add_executable(test-main test/main.cpp)
|
||||
target_link_libraries(test-main PRIVATE biu::biu)
|
||||
set_property(TARGET test-main PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
|
||||
add_test(NAME test-main COMMAND test-main)
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
--set HPCSTAT_DATADIR /var/lib/hpcstat --set HPCSTAT_SSH_BINDIR ${openssh}/bin \
|
||||
--set HPCSTAT_DUC_BINDIR ${duc}/bin
|
||||
'';
|
||||
doCheck = true;
|
||||
}
|
||||
|
||||
1
packages/hpcstat/share/keys/hjp
Normal file
1
packages/hpcstat/share/keys/hjp
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGRZp8xp9hVO7e/6eflQsnFZj853IRVywc97cTevnWbg hjp@xmupc1
|
||||
1
packages/hpcstat/share/keys/wp
Normal file
1
packages/hpcstat/share/keys/wp
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMRpyIU8ZuYTa0LvsVHmJZ1FA7Lbp4PObjkwo+UcpCP8 wp@xmupc1
|
||||
@@ -110,13 +110,11 @@ namespace hpcstat::disk
|
||||
{
|
||||
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))
|
||||
{
|
||||
if (auto size = get_size(dir + "/" + subdir); size)
|
||||
usage.Teacher.push_back({ dir, *size });
|
||||
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(),
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace hpcstat
|
||||
{ "fdq5k13N2DAzIK/2a1Mm4/ZVsDUgT623TSOXsVswxT8", { "yjq", "Junqi Yao" } },
|
||||
{ "8USxEYi8ePPpLhk5FYBo2udT7/NFmEe8c2+oQajGXzA", { "zem", "Enming Zhang" } },
|
||||
{ "C52EURGhRHtf+odfmE2qofh7NO24MnGB3Q8GhRQhHiM", { "xly", "Linyang Xie" } },
|
||||
{ "JODRKZ9E0+pjruWN9TPksC6Xsns/GZijKLbYfZqpSeY", { "wp", "Peng Wang" } },
|
||||
{ "uL/ZfBXKko30VpeuKb5dnnxbhJ8IAuHo8W+n2uwQhCI", { "hjp", "JiaPeng Huang" } },
|
||||
{ "7bmG24muNsaAZkCy7mQ9Nf2HuNafmvUO+Hf1bId9zts", { "00", "Yaping Wu" } },
|
||||
{ "dtx0QxdgFrXn2SYxtIRz43jIAH6rLgJidSdTvuTuews", { "01", "Jing Li" } },
|
||||
{ "8crUO9u4JiVqw3COyjXfzZe87s6XZFhvi0LaY0Mv6bg", { "02", "Huahan Zhan" } },
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user