mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 04:19:22 +08:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c51cdb4fba | |||
| b48355b192 | |||
| 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,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
|
||||
+++
|
||||
6
blog/content/_index.md
Normal file
6
blog/content/_index.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
title: Introduction
|
||||
type: docs
|
||||
---
|
||||
|
||||
这里是主页
|
||||
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=":building_construction:" >}} 施工中 {{< /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)
|
||||
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";
|
||||
}
|
||||
144
blog/hugo.yaml
Normal file
144
blog/hugo.yaml
Normal file
@@ -0,0 +1,144 @@
|
||||
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:
|
||||
- identifier: documentation
|
||||
name: Documentation
|
||||
pageRef: /docs
|
||||
weight: 1
|
||||
- identifier: blog
|
||||
name: Blog
|
||||
pageRef: /blog
|
||||
weight: 2
|
||||
- identifier: about
|
||||
name: About
|
||||
pageRef: /about
|
||||
weight: 3
|
||||
- name: Search
|
||||
weight: 4
|
||||
params:
|
||||
type: search
|
||||
- name: GitHub
|
||||
weight: 5
|
||||
url: "https://github.com/imfing/hextra"
|
||||
params:
|
||||
icon: github
|
||||
sidebar:
|
||||
- identifier: more
|
||||
name: More
|
||||
params:
|
||||
type: separator
|
||||
weight: 1
|
||||
- identifier: about
|
||||
name: "About"
|
||||
pageRef: "/about"
|
||||
weight: 2
|
||||
- identifier: hugoDocs
|
||||
name: "Hugo Docs ↗"
|
||||
url: "https://gohugo.io/documentation/"
|
||||
weight: 3
|
||||
|
||||
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" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ inputs:
|
||||
kernel = { variant = "xanmod-lts"; patches = [ "surface" "hibernate-progress" ]; };
|
||||
networking.hostname = "surface";
|
||||
gui.enable = true;
|
||||
initrd.unl0kr = {};
|
||||
};
|
||||
hardware = { cpus = [ "intel" ]; gpu.type = "intel"; };
|
||||
virtualization = { docker.enable = true; waydroid.enable = true; };
|
||||
|
||||
@@ -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 =
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ inputs:
|
||||
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;
|
||||
|
||||
@@ -188,9 +188,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" ];
|
||||
};
|
||||
services.hardware.bolt.enable = true;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,10 @@ 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]
|
||||
mariadb:
|
||||
slurm: ENC[AES256_GCM,data:qQMD8SKNmxb3PdScXNqppF9zkX7dV5i7rvljvZuhiI5zLnu77qYCHBW6ymh0mrY14N9NjxmQZhZWX/H8TvBlcg==,iv:J5N3LjCYW3QmuEkMBpl7qvPFW1Z9ZoPLkj45jKcIW9U=,tag:Tl+ld07+lVkmzt7f/f2MqQ==,type:str]
|
||||
hpcstat:
|
||||
@@ -48,8 +50,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-30T06:31:26Z"
|
||||
mac: ENC[AES256_GCM,data:3t5jUl0FE4mqMMZp5RFlgmHPdy0jhwFZqtgP5NsAPfHRnQdL10YenqinIHue+R/Bp/0Auq7h+OKX/puibsPpyyqKPtACU2ONmyDqHqDuR+dj4rqFHMiIuU4qCF14J7XUh/PkDGLdASO5GsGPxOJPAGEcj77a8N/zWNSXY0K9NlI=,iv:RYE7lWzAnEgvAvgNDSsNYZcgqR1Yf7rbNHumizxwHjs=,tag:mNs/5JJ40C04apBIo3DoyA==,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
|
||||
|
||||
223
flake.lock
generated
223
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": {
|
||||
@@ -247,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": {
|
||||
@@ -540,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": [
|
||||
@@ -547,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": {
|
||||
@@ -562,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": {
|
||||
@@ -584,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": {
|
||||
@@ -600,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"
|
||||
},
|
||||
@@ -616,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": {
|
||||
@@ -632,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": {
|
||||
@@ -648,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": {
|
||||
@@ -730,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": {
|
||||
@@ -810,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": {
|
||||
@@ -831,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": {
|
||||
@@ -853,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": {
|
||||
@@ -899,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": {
|
||||
@@ -979,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": {
|
||||
@@ -1049,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",
|
||||
@@ -1063,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": {
|
||||
@@ -1089,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": {
|
||||
@@ -1157,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"
|
||||
}
|
||||
},
|
||||
@@ -1180,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": {
|
||||
@@ -1204,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": {
|
||||
@@ -1224,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": {
|
||||
@@ -1253,6 +1286,7 @@
|
||||
"envfs": "envfs",
|
||||
"git-lfs-transfer": "git-lfs-transfer",
|
||||
"gricad": "gricad",
|
||||
"hextra": "hextra",
|
||||
"home-manager": "home-manager",
|
||||
"impermanence": "impermanence",
|
||||
"kylin-virtual-keyboard": "kylin-virtual-keyboard",
|
||||
@@ -1275,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",
|
||||
@@ -1295,11 +1330,11 @@
|
||||
"rsshub": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1723692588,
|
||||
"narHash": "sha256-4z39e+om3z3Rcm66NmV5VUfbMueZ/iE+A51SvDf4I9c=",
|
||||
"lastModified": 1724689272,
|
||||
"narHash": "sha256-iTkKoHSO/mD+TPR3hT9PO9TdHnxiqJDREyHb6a2LqaY=",
|
||||
"owner": "DIYgod",
|
||||
"repo": "RSSHub",
|
||||
"rev": "351578a8767f8faa06a26eeace168622503e7682",
|
||||
"rev": "6709293f140f38fbbcf3df8fc4e851f88800eafd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -1311,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": {
|
||||
@@ -1328,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": {
|
||||
@@ -1399,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": {
|
||||
@@ -1538,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": {
|
||||
@@ -1559,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": {
|
||||
|
||||
@@ -61,11 +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; };
|
||||
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; };
|
||||
@@ -111,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:
|
||||
@@ -162,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 ];
|
||||
@@ -180,7 +183,7 @@
|
||||
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 ];
|
||||
|
||||
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)));
|
||||
@@ -100,7 +103,16 @@ inputs:
|
||||
plasma-localerc = { Formats.LANG.value = "en_US.UTF-8"; Translations.LANGUAGE.value = "zh_CN"; };
|
||||
baloofilerc."Basic Settings".Indexing-Enabled.value = false;
|
||||
};
|
||||
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 =
|
||||
{
|
||||
|
||||
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 | 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
|
||||
])];
|
||||
};
|
||||
|
||||
@@ -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" ]; };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,22 +13,26 @@ 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" ];
|
||||
};
|
||||
};
|
||||
tmpfiles.rules = [ "d /var/cache/rsshub 0700 rsshub rsshub" ];
|
||||
};
|
||||
sops =
|
||||
{
|
||||
@@ -46,6 +50,8 @@ 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"}'
|
||||
XDG_CONFIG_HOME='/var/cache/rsshub/chromium'
|
||||
XDG_CACHE_HOME='/var/cache/rsshub/chromium'
|
||||
'';
|
||||
secrets = (listToAttrs (map (secret: { name = "rsshub/${secret}"; value = {}; })
|
||||
[
|
||||
|
||||
@@ -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/";
|
||||
|
||||
@@ -33,7 +33,6 @@ inputs:
|
||||
# resolved does not work in initrd, causing network.target to fail
|
||||
services.resolved.enable = false;
|
||||
};
|
||||
kernelParams = [ "ip=dhcp" ];
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -10,6 +10,7 @@ inputs:
|
||||
(builtins.attrNames inputs.config.users.groups);
|
||||
autoSubUidGidRange = true;
|
||||
hashedPassword = "$y$j9T$xJwVBoGENJEDSesJ0LfkU1$VEExaw7UZtFyB4VY1yirJvl7qS7oiF49KbEBrV0.hhC";
|
||||
shell = inputs.lib.mkForce inputs.pkgs.nushell;
|
||||
};
|
||||
home-manager.users.chn =
|
||||
{
|
||||
|
||||
@@ -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
|
||||
@@ -18,7 +18,8 @@ inputs:
|
||||
zem = 1004;
|
||||
gb = 1005;
|
||||
test = 1006;
|
||||
zqq = 1007;
|
||||
wp = 1007;
|
||||
hjp = 1008;
|
||||
misskey-misskey = 2000;
|
||||
misskey-misskey-old = 2001;
|
||||
frp = 2002;
|
||||
|
||||
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
|
||||
@@ -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,16 +58,25 @@ 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; };
|
||||
|
||||
@@ -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" } },
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace hpcstat::lfs
|
||||
else
|
||||
{
|
||||
// Job <462270> is submitted to queue <normal_1day>.
|
||||
std::regex re(R"r(Job <(\d+)> is submitted to queue <(\w+)>.)r");
|
||||
// Job <462270> is submitted to default queue <normal>.
|
||||
std::regex re(R"r(Job <(\d+)> is submitted to(?: default)? queue <(\w+)>.)r");
|
||||
std::smatch match;
|
||||
if (std::regex_search(result.Stdout, match, re))
|
||||
return std::make_pair(std::stoi(match[1]), match[2]);
|
||||
if (std::regex_search(result.Stdout, match, re)) return std::make_pair(std::stoi(match[1]), match[2]);
|
||||
else { std::cerr << "Failed to parse job id from output: {}\n"_f(result.Stdout); return std::nullopt; }
|
||||
}
|
||||
}
|
||||
|
||||
12
packages/hpcstat/test/main.cpp
Normal file
12
packages/hpcstat/test/main.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
# include <biu.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace biu::literals;
|
||||
std::string s1 = "Job <462270> is submitted to queue <normal_1day>.";
|
||||
std::string s2 = "Job <462270> is submitted to default queue <normal>.";
|
||||
std::regex re(R"r(Job <(\d+)> is submitted to(?: default)? queue <(\w+)>.)r");
|
||||
std::smatch match;
|
||||
assert(std::regex_match(s1, match, re) && ("{}_{}"_f(match[1], match[2]) == "462270_normal_1day"));
|
||||
assert(std::regex_match(s2, match, re) && ("{}_{}"_f(match[1], match[2]) == "462270_normal"));
|
||||
}
|
||||
@@ -10,18 +10,14 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
endif()
|
||||
|
||||
find_package(yaml-cpp REQUIRED)
|
||||
find_package(Eigen3 REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(concurrencpp REQUIRED)
|
||||
find_package(HighFive REQUIRED)
|
||||
find_package(TBB REQUIRED)
|
||||
find_package(Matplot++ REQUIRED)
|
||||
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
|
||||
find_package(biu REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_executable(ufo src/solver.cpp src/fold.cpp src/unfold.cpp src/plot.cpp src/main.cpp)
|
||||
target_include_directories(ufo PRIVATE ${PROJECT_SOURCE_DIR}/include ${ZPP_BITS_INCLUDE_DIR})
|
||||
target_link_libraries(ufo PRIVATE
|
||||
yaml-cpp Eigen3::Eigen fmt::fmt concurrencpp::concurrencpp HighFive_HighFive TBB::tbb Matplot++::matplot)
|
||||
target_include_directories(ufo PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
||||
target_link_libraries(ufo PRIVATE yaml-cpp TBB::tbb Matplot++::matplot biu::biu)
|
||||
target_compile_features(ufo PRIVATE cxx_std_23)
|
||||
|
||||
install(TARGETS ufo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
@@ -7,4 +7,5 @@
|
||||
src = ./.;
|
||||
buildInputs = [ yaml-cpp eigen fmt concurrencpp highfive tbb matplotplusplus biu zpp-bits ];
|
||||
nativeBuildInputs = [ cmake pkg-config ];
|
||||
doCheck = true;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,6 @@
|
||||
# pragma once
|
||||
# include <iostream>
|
||||
# include <array>
|
||||
# include <numbers>
|
||||
# include <numeric>
|
||||
# include <fstream>
|
||||
# include <optional>
|
||||
# include <array>
|
||||
# include <utility>
|
||||
# include <execution>
|
||||
# include <syncstream>
|
||||
# include <any>
|
||||
# include <map>
|
||||
# include <vector>
|
||||
# include <span>
|
||||
# include <yaml-cpp/yaml.h>
|
||||
# include <Eigen/Dense>
|
||||
# include <concurrencpp/concurrencpp.h>
|
||||
# include <fmt/format.h>
|
||||
# include <fmt/std.h>
|
||||
# include <fmt/ranges.h>
|
||||
# include <highfive/H5File.hpp>
|
||||
# include <zpp_bits.h>
|
||||
# include <matplot/matplot.h>
|
||||
# include <biu.hpp>
|
||||
|
||||
@@ -31,18 +11,7 @@
|
||||
|
||||
namespace ufo
|
||||
{
|
||||
using namespace std::literals;
|
||||
struct PhonopyComplex { double r, i; };
|
||||
inline HighFive::CompoundType create_compound_complex()
|
||||
{ return {{ "r", HighFive::AtomicType<double>{}}, {"i", HighFive::AtomicType<double>{}}}; }
|
||||
|
||||
namespace detail_
|
||||
{
|
||||
template <typename T> struct SpecializationOfBitsMembersHelper : std::false_type {};
|
||||
template <std::size_t N> struct SpecializationOfBitsMembersHelper<zpp::bits::members<N>> : std::true_type {};
|
||||
}
|
||||
template <typename T> concept ZppSerializable
|
||||
= requires() { detail_::SpecializationOfBitsMembersHelper<T>::value == true; };
|
||||
using namespace biu::literals;
|
||||
|
||||
class Solver
|
||||
{
|
||||
@@ -50,19 +19,15 @@ namespace ufo
|
||||
virtual Solver& operator()() = 0;
|
||||
virtual ~Solver() = default;
|
||||
|
||||
static concurrencpp::generator<std::pair<Eigen::Vector<unsigned, 3>, unsigned>>
|
||||
triplet_sequence(Eigen::Vector<unsigned, 3> range);
|
||||
|
||||
template <ZppSerializable T> inline static void zpp_write(const T& object, std::string filename)
|
||||
inline static void zpp_write(const auto& object, std::string filename)
|
||||
{
|
||||
auto [data, out] = zpp::bits::data_out();
|
||||
out(object).or_throw();
|
||||
static_assert(sizeof(char) == sizeof(std::byte));
|
||||
auto data = biu::serialize(object);
|
||||
std::ofstream file(filename, std::ios::binary | std::ios::out);
|
||||
file.exceptions(std::ios::badbit | std::ios::failbit);
|
||||
static_assert(sizeof(std::byte) == sizeof(char));
|
||||
file.write(reinterpret_cast<const char*>(data.data()), data.size());
|
||||
}
|
||||
template <ZppSerializable T> inline static T zpp_read(std::string filename)
|
||||
template <typename T> inline static T zpp_read(std::string filename)
|
||||
{
|
||||
auto input = std::ifstream(filename, std::ios::binary | std::ios::in);
|
||||
input.exceptions(std::ios::badbit | std::ios::failbit);
|
||||
@@ -76,46 +41,15 @@ namespace ufo
|
||||
reinterpret_cast<std::byte*>(string.data() + string.size())
|
||||
);
|
||||
}
|
||||
auto in = zpp::bits::in(data);
|
||||
T output;
|
||||
in(output).or_throw();
|
||||
return output;
|
||||
return biu::deserialize<T>(data);
|
||||
}
|
||||
|
||||
class Hdf5file
|
||||
{
|
||||
public:
|
||||
inline Hdf5file& open_for_read(std::string filename)
|
||||
{
|
||||
File_ = HighFive::File(filename, HighFive::File::ReadOnly);
|
||||
return *this;
|
||||
}
|
||||
inline Hdf5file& open_for_write(std::string filename)
|
||||
{
|
||||
File_ = HighFive::File(filename, HighFive::File::ReadWrite | HighFive::File::Create
|
||||
| HighFive::File::Truncate);
|
||||
return *this;
|
||||
}
|
||||
template <typename T> inline Hdf5file& read(T& object, std::string name)
|
||||
{
|
||||
object = File_->getDataSet(name).read<std::remove_cvref_t<decltype(object)>>();
|
||||
return *this;
|
||||
}
|
||||
template <typename T> inline Hdf5file& write(const T& object, std::string name)
|
||||
{
|
||||
File_->createDataSet(name, object);
|
||||
return *this;
|
||||
}
|
||||
protected:
|
||||
std::optional<HighFive::File> File_;
|
||||
};
|
||||
|
||||
struct DataFile
|
||||
{
|
||||
std::string Filename;
|
||||
std::string Format;
|
||||
std::map<std::string, std::any> ExtraParameters;
|
||||
inline DataFile() = default;
|
||||
DataFile() = default;
|
||||
DataFile
|
||||
(
|
||||
YAML::Node node, std::set<std::string> supported_format,
|
||||
@@ -125,5 +59,3 @@ namespace ufo
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
HIGHFIVE_REGISTER_TYPE(ufo::PhonopyComplex, ufo::create_compound_complex)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ufo
|
||||
std::stringstream print;
|
||||
print << "Qpoints:\n";
|
||||
for (auto& qpoint : Qpoints)
|
||||
print << fmt::format(" - [ {:.8f}, {:.8f}, {:.8f} ]\n", qpoint(0), qpoint(1), qpoint(2));
|
||||
print << (" - [ {:.8f}, {:.8f}, {:.8f} ]\n"_f(qpoint(0), qpoint(1), qpoint(2)));
|
||||
return print.str();
|
||||
}();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,7 @@ namespace ufo
|
||||
PlotSolver::InputType::InputType(std::string config_file)
|
||||
{
|
||||
auto input = YAML::LoadFile(config_file);
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
for (unsigned j = 0; j < 3; j++)
|
||||
PrimativeCell(i, j) = input["PrimativeCell"][i][j].as<double>();
|
||||
PrimativeCell = input["PrimativeCell"].as<std::array<std::array<double, 3>, 3>>() | biu::toEigen<>;
|
||||
for (auto& figure : input["Figures"].as<std::vector<YAML::Node>>())
|
||||
{
|
||||
Figures.emplace_back();
|
||||
@@ -53,11 +51,11 @@ namespace ufo
|
||||
{
|
||||
std::vector resolution{ Resolution.first, Resolution.second };
|
||||
std::vector range{ Range.first, Range.second };
|
||||
Hdf5file{}.open_for_write(filename).write(Values, "Values")
|
||||
.write(XTicks, "XTicks")
|
||||
.write(YTicks, "YTicks")
|
||||
.write(resolution, "Resolution")
|
||||
.write(range, "Range");
|
||||
biu::Hdf5file(filename).write("Values", Values)
|
||||
.write("XTicks", XTicks)
|
||||
.write("YTicks", YTicks)
|
||||
.write("Resolution", resolution)
|
||||
.write("Range", range);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -2,19 +2,6 @@
|
||||
|
||||
namespace ufo
|
||||
{
|
||||
concurrencpp::generator<std::pair<Eigen::Vector<unsigned, 3>, unsigned>> Solver::triplet_sequence
|
||||
(Eigen::Vector<unsigned, 3> range)
|
||||
{
|
||||
for (unsigned x = 0; x < range[0]; x++)
|
||||
for (unsigned y = 0; y < range[1]; y++)
|
||||
for (unsigned z = 0; z < range[2]; z++)
|
||||
co_yield
|
||||
{
|
||||
Eigen::Vector<unsigned, 3>{{x}, {y}, {z}},
|
||||
x * range[1] * range[2] + y * range[2] + z
|
||||
};
|
||||
}
|
||||
|
||||
Solver::DataFile::DataFile
|
||||
(YAML::Node node, std::set<std::string> supported_format, std::string config_file, bool allow_same_as_config_file)
|
||||
{
|
||||
@@ -34,7 +21,7 @@ namespace ufo
|
||||
Filename = node["Filename"].as<std::string>();
|
||||
Format = node["Format"].as<std::string>();
|
||||
if (!supported_format.contains(Format))
|
||||
throw std::runtime_error(fmt::format("Unsupported format: \"{}\"", Format));
|
||||
throw std::runtime_error("Unsupported format: \"{}\""_f(Format));
|
||||
if (auto _ = node["RelativeToConfigFile"])
|
||||
{
|
||||
auto __ = _.as<bool>();
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# include <thread>
|
||||
# include <syncstream>
|
||||
# include <execution>
|
||||
# include <ufo/unfold.hpp>
|
||||
|
||||
namespace ufo
|
||||
@@ -7,23 +10,12 @@ namespace ufo
|
||||
// read main input file
|
||||
{
|
||||
auto node = YAML::LoadFile(filename);
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
for (unsigned j = 0; j < 3; j++)
|
||||
PrimativeCell(i, j) = node["PrimativeCell"][i][j].as<double>();
|
||||
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
SuperCellMultiplier(i) = node["SuperCellMultiplier"][i].as<int>();
|
||||
PrimativeCell = node["PrimativeCell"].as<std::array<std::array<double, 3>, 3>>() | biu::toEigen<>;
|
||||
SuperCellMultiplier = node["SuperCellMultiplier"].as<std::array<unsigned, 3>>() | biu::toEigen<>;
|
||||
|
||||
if (auto value = node["SuperCellDeformation"])
|
||||
{
|
||||
SuperCellDeformation.emplace();
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
for (unsigned j = 0; j < 3; j++)
|
||||
(*SuperCellDeformation)(i, j) = value[i][j].as<double>();
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
PrimativeCellBasisNumber(i) = node["PrimativeCellBasisNumber"][i].as<int>();
|
||||
SuperCellDeformation = value.as<std::array<std::array<double, 3>, 3>>() | biu::toEigen<>;
|
||||
PrimativeCellBasisNumber = node["PrimativeCellBasisNumber"].as<std::array<unsigned, 3>>() | biu::toEigen<>;
|
||||
|
||||
AtomPositionInputFile = DataFile
|
||||
(
|
||||
@@ -57,8 +49,7 @@ namespace ufo
|
||||
points = node["unit_cell"]["points"].as<std::vector<YAML::Node>>();
|
||||
auto atom_position_to_super_cell = Eigen::MatrixX3d(points.size(), 3);
|
||||
for (unsigned i = 0; i < points.size(); i++)
|
||||
for (unsigned j = 0; j < 3; j++)
|
||||
atom_position_to_super_cell(i, j) = points[i]["coordinates"][j].as<double>();
|
||||
atom_position_to_super_cell.row(i) = points[i]["coordinates"].as<std::array<double, 3>>() | biu::toEigen<>;
|
||||
auto super_cell = (SuperCellDeformation.value_or(Eigen::Matrix3d::Identity())
|
||||
* SuperCellMultiplier.cast<double>().asDiagonal() * PrimativeCell).eval();
|
||||
AtomPosition = atom_position_to_super_cell * super_cell;
|
||||
@@ -70,8 +61,7 @@ namespace ufo
|
||||
QpointData.resize(phonon.size());
|
||||
for (unsigned i = 0; i < phonon.size(); i++)
|
||||
{
|
||||
for (unsigned j = 0; j < 3; j++)
|
||||
QpointData[i].Qpoint(j) = phonon[i]["q-position"][j].as<double>();
|
||||
QpointData[i].Qpoint = phonon[i]["q-position"].as<std::array<double, 3>>() | biu::toEigen<>;
|
||||
auto band = phonon[i]["band"].as<std::vector<YAML::Node>>();
|
||||
QpointData[i].ModeData.resize(band.size());
|
||||
for (unsigned j = 0; j < band.size(); j++)
|
||||
@@ -98,10 +88,10 @@ namespace ufo
|
||||
else if (QpointDataInputFile.Format == "hdf5")
|
||||
{
|
||||
std::vector<std::vector<std::vector<double>>> frequency, path;
|
||||
std::vector<std::vector<std::vector<std::vector<PhonopyComplex>>>> eigenvector_vector;
|
||||
Hdf5file{}.open_for_read(QpointDataInputFile.Filename).read(frequency, "/frequency")
|
||||
.read(eigenvector_vector, "/eigenvector")
|
||||
.read(path, "/path");
|
||||
std::vector<std::vector<std::vector<std::vector<biu::PhonopyComplex>>>> eigenvector_vector;
|
||||
biu::Hdf5file(QpointDataInputFile.Filename, true).read("/frequency", frequency)
|
||||
.read("/eigenvector", eigenvector_vector)
|
||||
.read("/path", path);
|
||||
std::vector size = { frequency.size(), frequency[0].size(), frequency[0][0].size() };
|
||||
QpointData.resize(size[0] * size[1]);
|
||||
for (unsigned i = 0; i < size[0]; i++)
|
||||
@@ -138,14 +128,14 @@ namespace ufo
|
||||
print << "QpointData:\n";
|
||||
for (auto& qpoint: QpointData)
|
||||
{
|
||||
print << fmt::format(" - Qpoint: [ {1:.{0}f}, {2:.{0}f}, {3:.{0}f} ]\n",
|
||||
percision, qpoint.Qpoint[0], qpoint.Qpoint[1], qpoint.Qpoint[2]);
|
||||
print << fmt::format(" Source: [ {1:.{0}f}, {2:.{0}f}, {3:.{0}f} ]\n",
|
||||
percision, qpoint.Source[0], qpoint.Source[1], qpoint.Source[2]);
|
||||
print << " - Qpoint: [ {1:.{0}f}, {2:.{0}f}, {3:.{0}f} ]\n"_f
|
||||
(percision, qpoint.Qpoint[0], qpoint.Qpoint[1], qpoint.Qpoint[2]);
|
||||
print << " Source: [ {1:.{0}f}, {2:.{0}f}, {3:.{0}f} ]\n"_f
|
||||
(percision, qpoint.Source[0], qpoint.Source[1], qpoint.Source[2]);
|
||||
print << " ModeData:\n";
|
||||
for (auto& mode: qpoint.ModeData)
|
||||
print << fmt::format(" - {{ Frequency: {1:.{0}f}, Weight: {2:.{0}f} }}\n",
|
||||
percision, mode.Frequency, mode.Weight);
|
||||
print << " - {{ Frequency: {1:.{0}f}, Weight: {2:.{0}f} }}\n"_f
|
||||
(percision, mode.Frequency, mode.Weight);
|
||||
}
|
||||
return print.str();
|
||||
}();
|
||||
@@ -211,10 +201,10 @@ namespace ufo
|
||||
Weight.back().push_back(mode.Weight);
|
||||
}
|
||||
}
|
||||
Hdf5file{}.open_for_write(filename).write(Qpoint, "/Qpoint")
|
||||
.write(Source, "/Source")
|
||||
.write(Frequency, "/Frequency")
|
||||
.write(Weight, "/Weight");
|
||||
biu::Hdf5file(filename).write("/Qpoint", Qpoint)
|
||||
.write("/Source", Source)
|
||||
.write("/Frequency", Frequency)
|
||||
.write("/Weight", Weight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,10 +291,10 @@ namespace ufo
|
||||
// 每个 q 点对应的一组 sub qpoint。不同的 q 点所对应的 sub qpoint 是不一样的,但 sub qpoint 与 q 点的相对位置一致。
|
||||
// 这里 xyz_of_diff_of_sub_qpoint 即表示这个相对位置,单位为超胞的倒格矢
|
||||
for (auto [xyz_of_diff_of_sub_qpoint_by_reciprocal_modified_super_cell, i_of_sub_qpoint]
|
||||
: triplet_sequence(super_cell_multiplier))
|
||||
: biu::sequence(super_cell_multiplier))
|
||||
{
|
||||
basis[i_of_sub_qpoint].resize(primative_cell_basis_number.prod());
|
||||
for (auto [xyz_of_basis, i_of_basis] : triplet_sequence(primative_cell_basis_number))
|
||||
for (auto [xyz_of_basis, i_of_basis] : biu::sequence(primative_cell_basis_number))
|
||||
{
|
||||
// 计算 q 点的坐标, 单位为单胞的倒格矢
|
||||
auto diff_of_sub_qpoint_by_reciprocal_primative_cell = xyz_of_basis.cast<double>()
|
||||
@@ -378,7 +368,7 @@ namespace ufo
|
||||
)
|
||||
{
|
||||
for (auto [xyz_of_diff_of_sub_qpoint_by_reciprocal_modified_super_cell, i_of_sub_qpoint]
|
||||
: triplet_sequence(super_cell_multiplier))
|
||||
: biu::sequence(super_cell_multiplier))
|
||||
{
|
||||
auto& _ = output.QpointData.emplace_back();
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user