Compare commits
200 Commits
f4a0e2a862
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
1da87ebdb8
|
|||
|
24d72349b2
|
|||
|
5630df0be7
|
|||
|
abeca5f52e
|
|||
| 211b4bef15 | |||
| 3417ee5618 | |||
| a4ed789ae9 | |||
| 2f6c5feda7 | |||
| e4087c9da8 | |||
| 291563bba3 | |||
|
993b77d5d0
|
|||
|
8c635dc3ad
|
|||
|
cffae80d70
|
|||
|
491a1ebb40
|
|||
|
25533605d3
|
|||
|
502920af58
|
|||
|
149397f16a
|
|||
|
3435e99cb1
|
|||
|
9faf6cdfe4
|
|||
|
3d116fe3a7
|
|||
|
97761a3af5
|
|||
|
92ee55e82a
|
|||
|
2d324de58a
|
|||
|
42fbf5cee6
|
|||
|
a1d873cc30
|
|||
|
e327d6acaf
|
|||
|
a9149d86c7
|
|||
|
bdddabcd52
|
|||
|
b2860d63c5
|
|||
|
dc15d79266
|
|||
|
b6992f554a
|
|||
|
06c0a24d98
|
|||
|
9aa25642ee
|
|||
|
b6a6f966dc
|
|||
|
754caf00d4
|
|||
|
ce8d76886a
|
|||
|
b3c173f0fa
|
|||
|
d6850b86dc
|
|||
|
9e38cb0712
|
|||
|
75b4d87dfa
|
|||
|
35358cf01c
|
|||
|
5a1880587f
|
|||
|
9c22723970
|
|||
|
cb3578bb0d
|
|||
|
3313dfc89b
|
|||
|
29734f85ba
|
|||
|
afe06213de
|
|||
|
69d6588c30
|
|||
|
aee0fb44d5
|
|||
|
602f599823
|
|||
|
df0a21913e
|
|||
|
a56e9bdaf2
|
|||
|
e574a70020
|
|||
|
c6a3fde1bd
|
|||
|
b3cd3fe209
|
|||
|
ad2aca84f0
|
|||
|
a07bcd9bab
|
|||
|
7eb32cfabc
|
|||
|
f9308dda9e
|
|||
|
99aea69128
|
|||
|
d0cffe4f1c
|
|||
|
b8597104b3
|
|||
|
3bd682e800
|
|||
|
296f250eba
|
|||
|
4ab322f08d
|
|||
|
e112f5f21d
|
|||
|
5bfd7bf857
|
|||
|
7a8e7ca9d7
|
|||
|
91c539ad99
|
|||
|
4c63836d35
|
|||
|
a2eaa6f72d
|
|||
|
c9edeca311
|
|||
|
6482506cc3
|
|||
|
7f250e19ef
|
|||
|
5feb543129
|
|||
|
454ad5885d
|
|||
|
f4c1b313ce
|
|||
|
4509f9edf5
|
|||
|
bc197eb3ca
|
|||
|
d5f027f586
|
|||
|
3d6620a308
|
|||
|
3196ebd920
|
|||
|
9c920b2cdf
|
|||
|
7b705fad80
|
|||
|
f3f00c14ad
|
|||
|
9ae37ea439
|
|||
|
99103ff9d2
|
|||
|
4c74679f85
|
|||
|
90b85963cd
|
|||
|
010789965a
|
|||
|
5988a98a09
|
|||
|
814511c939
|
|||
|
b96a93b1bf
|
|||
|
b92ada78e5
|
|||
|
eb5ca52004
|
|||
|
7952d72048
|
|||
|
cb5c3eff2e
|
|||
|
17c5344666
|
|||
|
8d7a4aed01
|
|||
|
475837cd66
|
|||
|
4f043b6ad1
|
|||
|
5d3fc65be5
|
|||
|
3a82f9b652
|
|||
|
cbdf26d69f
|
|||
|
80792c399c
|
|||
|
b1546b5ee8
|
|||
|
52261371c0
|
|||
|
ab6dadd113
|
|||
|
837f865b4f
|
|||
|
e3b5a1d6c3
|
|||
|
d161fd3e87
|
|||
|
2118c69dd8
|
|||
|
c7cf3336a0
|
|||
|
15ac780c9d
|
|||
|
3cb98cfeb0
|
|||
|
4ae4f3bb2b
|
|||
|
9273df1ab8
|
|||
|
374a3ef071
|
|||
|
0983d5b058
|
|||
|
e8f025b9c5
|
|||
|
4144c14868
|
|||
|
1417822aa6
|
|||
|
3ea322dd0f
|
|||
|
86c85676ea
|
|||
|
b302abb724
|
|||
|
4817576834
|
|||
|
0683ced027
|
|||
|
cec8f7897a
|
|||
|
78a062432f
|
|||
|
4f77ac9385
|
|||
|
73e490f523
|
|||
|
12c381da5f
|
|||
|
23a24820c5
|
|||
|
d6e0b0ef96
|
|||
|
ef913abe9e
|
|||
|
4d0cd7b1e7
|
|||
|
9482ba860f
|
|||
|
44aca8ce69
|
|||
|
792aaa20d5
|
|||
|
959956409d
|
|||
|
41969ab2e0
|
|||
|
e228fdc222
|
|||
|
6bc50deb6a
|
|||
|
090677e101
|
|||
|
8ae8e6f9b1
|
|||
|
3acd90bbdd
|
|||
|
e9204bb2f5
|
|||
|
362d610f1d
|
|||
|
5a671c3ece
|
|||
|
f2111f7771
|
|||
|
c71710867f
|
|||
|
465eb3c608
|
|||
|
9696d4f343
|
|||
|
4218dbeb80
|
|||
|
c167e3ac64
|
|||
|
f07598688f
|
|||
|
e696472c5b
|
|||
|
dcfd134a4e
|
|||
|
77d0a1c449
|
|||
|
7b1044214f
|
|||
|
faba8a05e6
|
|||
|
1eaee50e82
|
|||
|
763c55b68e
|
|||
|
95fc23da50
|
|||
|
a6006d362d
|
|||
|
57cc21a1cd
|
|||
|
e78a3af90c
|
|||
|
3652579508
|
|||
|
1036d4ce0b
|
|||
|
354525129e
|
|||
|
7e9875ac38
|
|||
|
a9089d81b1
|
|||
|
d61cd261e0
|
|||
|
3f206e08c2
|
|||
|
2677ed4594
|
|||
|
905274fe73
|
|||
|
23b30d3a84
|
|||
|
5bead3c20f
|
|||
|
dd2f880a3b
|
|||
|
1869ae86f1
|
|||
|
b7d6cd3dbf
|
|||
|
900b66796b
|
|||
|
44a479d6b4
|
|||
|
b5dca35878
|
|||
|
a1fa09008b
|
|||
|
375c9b59b9
|
|||
|
90f0b4aa63
|
|||
|
fba506e06d
|
|||
|
8b303fb0f0
|
|||
|
49bbfe094a
|
|||
|
3c5c96d623
|
|||
|
5a5fb9a426
|
|||
|
82ba9038ed
|
|||
|
d22d597cf1
|
|||
|
c61b1e8961
|
|||
|
475acb7fd1
|
|||
|
3ef2f7da09
|
|||
|
fbc5a9ee8e
|
|||
|
f46ad8a2f3
|
|||
|
c14a3682ff
|
13
.editorconfig
Normal file
13
.editorconfig
Normal file
@@ -0,0 +1,13 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{nix,lua,yaml,css}]
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_size = 4
|
||||
20
.lazy.lua
Normal file
20
.lazy.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
vim.lsp.config("nixd", {
|
||||
settings = {
|
||||
nixd = {
|
||||
options = {
|
||||
nixos = {
|
||||
expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.'
|
||||
.. vim.uv.os_gethostname()
|
||||
.. ".options",
|
||||
},
|
||||
},
|
||||
diagnostic = {
|
||||
suppress = {
|
||||
"sema-primop-overridden",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return {}
|
||||
51
Justfile
Normal file
51
Justfile
Normal file
@@ -0,0 +1,51 @@
|
||||
set export
|
||||
|
||||
IMPURE_ROOT := `pwd`
|
||||
|
||||
all: fmt switch
|
||||
|
||||
@switch:
|
||||
echo "Rebuilding NixOS..."
|
||||
nh os switch . --impure
|
||||
|
||||
@switch-offline:
|
||||
echo "Rebuilding NixOS without net..."
|
||||
nh os switch . --impure --no-net
|
||||
|
||||
alias offline := switch-offline
|
||||
|
||||
@boot:
|
||||
echo "Rebuilding NixOS..."
|
||||
nh os boot . --impure
|
||||
|
||||
@test:
|
||||
echo "Rebuilding NixOS..."
|
||||
nh os test . --impure
|
||||
|
||||
@vm:
|
||||
echo "Building NixOS VM..."
|
||||
nh os build-vm . --impure
|
||||
|
||||
@update:
|
||||
echo "Updating flakes..."
|
||||
nix flake update
|
||||
|
||||
@repl:
|
||||
nixos-rebuild repl --flake .
|
||||
|
||||
@cleandry:
|
||||
echo "Listing all generations older than 15 days..."
|
||||
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --dry-run --older-than 15d
|
||||
nix profile wipe-history --profile ~/.local/state/nix/profiles/profile --dry-run --older-than 15d
|
||||
|
||||
@clean:
|
||||
echo "Removing all generations older than 15 days..."
|
||||
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 15d
|
||||
nix profile wipe-history --profile ~/.local/state/nix/profiles/profile --older-than 15d
|
||||
|
||||
@gc:
|
||||
nix store gc --debug
|
||||
|
||||
@fmt:
|
||||
echo "Formatting files..."
|
||||
nix fmt
|
||||
49
Makefile
49
Makefile
@@ -1,49 +0,0 @@
|
||||
all: fmt switch
|
||||
|
||||
switch:
|
||||
@echo "Rebuilding NixOS..."
|
||||
@nh os switch .
|
||||
|
||||
boot:
|
||||
@echo "Rebuilding NixOS..."
|
||||
@nh os boot .
|
||||
|
||||
test:
|
||||
@echo "Rebuilding NixOS..."
|
||||
@nh os test .
|
||||
|
||||
vm:
|
||||
@echo "Building NixOS VM..."
|
||||
@nh os build-vm .
|
||||
|
||||
update:
|
||||
@echo "Updating flakes..."
|
||||
@nix flake update
|
||||
|
||||
history:
|
||||
@nix profile history --profile /nix/var/nix/profiles/system
|
||||
|
||||
replpkgs:
|
||||
@nix repl -f flake:nixpkgs
|
||||
|
||||
repl:
|
||||
@nh os repl .
|
||||
|
||||
cleandry:
|
||||
@echo "Listing all generations older than 15 days..."
|
||||
@sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --dry-run --older-than 15d
|
||||
@nix profile wipe-history --profile ~/.local/state/nix/profiles/home-manager --dry-run --older-than 15d
|
||||
|
||||
clean:
|
||||
@echo "Removing all generations older than 15 days..."
|
||||
@sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 15d
|
||||
@nix profile wipe-history --profile ~/.local/state/nix/profiles/home-manager --older-than 15d
|
||||
|
||||
gc:
|
||||
@nix store gc --debug
|
||||
|
||||
fmt:
|
||||
@echo "Formatting nix files..."
|
||||
@nix fmt
|
||||
|
||||
.PHONY: os home news update history repl clean gc fmt
|
||||
37
README.md
37
README.md
@@ -10,7 +10,7 @@ Currently, this repository contains the nix code that builds:
|
||||
2. NixOS home server
|
||||
3. NixOS WSL
|
||||
|
||||
See [./config/hosts](./config/hosts) for details of each host.
|
||||
See [./hosts](./hosts) for details of each host.
|
||||
|
||||
## Why NixOS & Flakes?
|
||||
|
||||
@@ -22,30 +22,25 @@ forever. If someone else shares their configuration, anyone else can just use it
|
||||
As for Flakes, refer to
|
||||
[Introduction to Flakes - NixOS & Nix Flakes Book](https://nixos-and-flakes.thiscute.world/nixos-with-flakes/introduction-to-flakes)
|
||||
|
||||
## Components
|
||||
|
||||
| | NixOS(Wayland) |
|
||||
| ----------------------------- | :------------------------------------------------------ |
|
||||
| **Window Manager** | Niri |
|
||||
| **Terminal Emulator** | Alacritty & Kitty & Foot & Ghostty |
|
||||
| **Bar** | Waybar |
|
||||
| **Application Launcher** | wofi |
|
||||
| **Notification Daemon** | SwayNotificationCenter |
|
||||
| **Input method framework** | Fcitx5 |
|
||||
| **Shell** | Zsh |
|
||||
| **Netease Cloudmusic Player** | go-musicfox |
|
||||
| **Media Player** | mpv |
|
||||
| **Text Editor** | Neovim |
|
||||
| **Fonts** | Noto Sans CJK & Jetbrains Mono & Nerd Font |
|
||||
| **Filesystem** | btrfs subvolumes, clean '/' every boot for impermanence |
|
||||
|
||||
And more...
|
||||
This configuration uses [flake-parts](https://flake.parts/) for better flake organization and modularity,
|
||||
enabling declarative host definitions and cleaner separation of concerns.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
- `modules/` - custom NixOS modules
|
||||
- `config/base.nix` - generic configs
|
||||
- `config/hosts/<name>/` - hosts-specific configs
|
||||
- `modules/core/` - core system modules (nix, persistence, time, user, xdg)
|
||||
- `modules/cli/` - command-line tools and utilities
|
||||
- `modules/coding/` - development environments and editors
|
||||
- `modules/desktop/` - desktop applications and window managers
|
||||
- `modules/virt/` - virtualization configurations
|
||||
- `profiles/` - system configuration profiles
|
||||
- `profiles/base.nix` - base configuration for all hosts
|
||||
- `profiles/desktop.nix` - desktop environment configuration
|
||||
- `profiles/server.nix` - server-specific configuration
|
||||
- `profiles/wsl.nix` - WSL-specific configuration
|
||||
- `hosts/<name>/` - host-specific configs
|
||||
- `flake/` - flake-parts modules
|
||||
- `flake/hosts.nix` - declarative host definitions
|
||||
- `lib/` - custom nix library
|
||||
- `pkgs/` - custom packages
|
||||
- `overlays/` - nixpkgs overlays
|
||||
|
||||
BIN
assets/avatar.jpg
Normal file
BIN
assets/avatar.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@@ -1,42 +0,0 @@
|
||||
{
|
||||
config,
|
||||
hostname,
|
||||
...
|
||||
}:
|
||||
{
|
||||
# I prefer this to the default issue text
|
||||
# ported from ArchLinux IIRC
|
||||
environment.etc.issue.text = "\\e{lightcyan}\\S\\e{reset} Login (\\l)\n\n";
|
||||
networking.hostName = hostname;
|
||||
# don't change this unless you know what you are doing!
|
||||
# for further information, see wiki.nixos.org
|
||||
system.stateVersion = "24.11";
|
||||
# disable this since we already have machine-id persisted
|
||||
systemd.services."systemd-machine-id-commit".enable = !config.my.persist.enable;
|
||||
|
||||
my = {
|
||||
home = {
|
||||
# nicely reload system units when changing configs
|
||||
systemd.user.startServices = "sd-switch";
|
||||
home.stateVersion = "24.11";
|
||||
};
|
||||
|
||||
xdg.enable = true;
|
||||
persist = {
|
||||
nixosDirs = [
|
||||
"/root"
|
||||
"/var"
|
||||
"/etc/ssh"
|
||||
];
|
||||
nixosFiles = [
|
||||
"/etc/machine-id"
|
||||
];
|
||||
homeDirs = [
|
||||
{
|
||||
directory = ".ssh";
|
||||
mode = "0700";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.open-webui = {
|
||||
enable = true;
|
||||
host = "127.0.0.1";
|
||||
port = 8089;
|
||||
package = pkgs.open-webui;
|
||||
};
|
||||
services.caddy.virtualHosts."ai.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8089 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
{ config, ... }:
|
||||
{
|
||||
services.postgresql.ensureUsers = [
|
||||
{
|
||||
name = "coder";
|
||||
ensureDBOwnership = true;
|
||||
}
|
||||
];
|
||||
services.postgresql.ensureDatabases = [ "coder" ];
|
||||
virtualisation.oci-containers.containers.coder = {
|
||||
image = "ghcr.io/coder/coder:latest";
|
||||
environment = {
|
||||
CODER_ACCESS_URL = "https://coder.imxyy.top";
|
||||
CODER_HTTP_ADDRESS = "0.0.0.0:8086";
|
||||
CODER_PG_CONNECTION_URL = "postgresql://coder:coderdatabase@127.0.0.1/coder?sslmode=disable";
|
||||
};
|
||||
extraOptions = [
|
||||
"--network=host"
|
||||
"--group-add=${toString config.users.groups.podman.gid}"
|
||||
];
|
||||
volumes = [
|
||||
"/var/lib/coder:/home/coder/.config"
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
];
|
||||
ports = [ "8086:8086" ];
|
||||
};
|
||||
services.caddy.virtualHosts."coder.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8086 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./nixos.nix
|
||||
./hardware.nix
|
||||
./home.nix
|
||||
./virt.nix
|
||||
./docker.nix
|
||||
./minecraft.nix
|
||||
./samba.nix
|
||||
./net.nix
|
||||
./caddy.nix
|
||||
./nextcloud.nix
|
||||
./mail.nix
|
||||
./gitea.nix
|
||||
./vault.nix
|
||||
./homepage.nix
|
||||
./code.nix
|
||||
./yesplaymusic.nix
|
||||
./ai.nix
|
||||
./grafana.nix
|
||||
./note.nix
|
||||
./matrix.nix
|
||||
./minio.nix
|
||||
./build.nix
|
||||
./immich.nix
|
||||
];
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
http_addr = "0.0.0.0";
|
||||
http_port = 8090;
|
||||
domain = "grafana.imxyy.top";
|
||||
};
|
||||
};
|
||||
};
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
package = pkgs.stable.prometheus;
|
||||
port = 8091;
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
port = 8092;
|
||||
enabledCollectors = [
|
||||
"systemd"
|
||||
"zfs"
|
||||
];
|
||||
};
|
||||
};
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "node";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "127.0.0.1:8092" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
services.caddy.virtualHosts."grafana.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8090 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
{
|
||||
config,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
{
|
||||
sops.secrets.tuwunel-reg-token = {
|
||||
sopsFile = secrets.tuwunel-reg-token;
|
||||
format = "binary";
|
||||
owner = config.services.matrix-tuwunel.user;
|
||||
group = config.services.matrix-tuwunel.group;
|
||||
};
|
||||
services.matrix-tuwunel = {
|
||||
enable = true;
|
||||
settings.global = {
|
||||
address = [ "127.0.0.1" ];
|
||||
port = [ 8094 ];
|
||||
server_name = "imxyy.top";
|
||||
allow_registration = true;
|
||||
registration_token_file = config.sops.secrets.tuwunel-reg-token.path;
|
||||
};
|
||||
};
|
||||
services.caddy.virtualHosts."imxyy.top" = {
|
||||
extraConfig = ''
|
||||
handle /.well-known/matrix/client {
|
||||
header Content-Type application/json
|
||||
header "Access-Control-Allow-Origin" "*"
|
||||
|
||||
respond `{"m.homeserver": {"base_url": "https://matrix.imxyy.top"}}` 200
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."imxyy.top:8448" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8094
|
||||
|
||||
handle /.well-known/matrix/client {
|
||||
header Content-Type application/json
|
||||
header "Access-Control-Allow-Origin" "*"
|
||||
|
||||
respond `{"m.homeserver": {"base_url": "https://matrix.imxyy.top"}}` 200
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."matrix.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8094
|
||||
|
||||
handle /.well-known/matrix/client {
|
||||
header Content-Type application/json
|
||||
header "Access-Control-Allow-Origin" "*"
|
||||
|
||||
respond `{"m.homeserver": {"base_url": "https://matrix.imxyy.top"}}` 200
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."matrix.imxyy.top:8448" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8094
|
||||
|
||||
handle /.well-known/matrix/client {
|
||||
header Content-Type application/json
|
||||
header "Access-Control-Allow-Origin" "*"
|
||||
|
||||
respond `{"m.homeserver": {"base_url": "https://matrix.imxyy.top"}}` 200
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
/*
|
||||
systemd.services."fabric1.20.6" = {
|
||||
description = "fabric 1.20.6 minecraft server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
WorkingDirectory = "/opt/minecraft/fabric1.20.6";
|
||||
ExecStart = "${lib.getExe' pkgs.openjdk21 "java"} -Xms1G -Xmx5G -jar fabric-server-mc.1.20.6-loader.0.15.11-launcher.1.0.1.jar";
|
||||
Restart = "always";
|
||||
RestartSec = 120;
|
||||
};
|
||||
};
|
||||
*/
|
||||
my.persist = {
|
||||
nixosDirs = [
|
||||
"/opt/minecraft"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,617 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
username,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot.kernelParams = [
|
||||
"biosdevname=0"
|
||||
"net.ifnames=0"
|
||||
];
|
||||
networking = {
|
||||
useDHCP = lib.mkForce false;
|
||||
dhcpcd = {
|
||||
wait = "background";
|
||||
IPv6rs = true;
|
||||
extraConfig = ''
|
||||
interface mac0
|
||||
noipv4
|
||||
'';
|
||||
};
|
||||
interfaces = {
|
||||
eth0.wakeOnLan.enable = true;
|
||||
eth1.wakeOnLan.enable = true;
|
||||
mac0 = {
|
||||
useDHCP = true;
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = "192.168.3.2";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
macvlans."mac0" = {
|
||||
interface = "eth0";
|
||||
mode = "bridge";
|
||||
};
|
||||
defaultGateway = {
|
||||
address = "192.168.3.1";
|
||||
interface = "mac0";
|
||||
};
|
||||
nameservers = [
|
||||
"192.168.3.2"
|
||||
];
|
||||
|
||||
firewall.enable = false;
|
||||
nftables = {
|
||||
enable = true;
|
||||
flushRuleset = true;
|
||||
ruleset = ''
|
||||
table inet firewall {
|
||||
set LANv4 {
|
||||
type ipv4_addr
|
||||
flags interval
|
||||
|
||||
elements = { 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 }
|
||||
}
|
||||
set LANv6 {
|
||||
type ipv6_addr
|
||||
flags interval
|
||||
|
||||
elements = { fd00::/8, fe80::/10 }
|
||||
}
|
||||
set tcp_ports {
|
||||
type inet_service
|
||||
flags interval
|
||||
|
||||
elements = {
|
||||
http,
|
||||
https,
|
||||
2222,
|
||||
25565
|
||||
}
|
||||
}
|
||||
|
||||
chain prerouting {
|
||||
type filter hook prerouting priority mangle; policy accept;
|
||||
|
||||
ip daddr @LANv4 accept
|
||||
ip6 daddr @LANv6 accept
|
||||
}
|
||||
|
||||
chain output {
|
||||
type filter hook output priority 100; policy accept;
|
||||
|
||||
ip daddr @LANv4 accept
|
||||
ip6 daddr @LANv6 accept
|
||||
}
|
||||
|
||||
chain input {
|
||||
type filter hook input priority 0; policy drop;
|
||||
iif lo accept
|
||||
ct state invalid drop
|
||||
ct state established,related accept
|
||||
|
||||
ip protocol { icmp, igmp } accept
|
||||
|
||||
ip saddr @LANv4 accept
|
||||
ip6 saddr @LANv6 accept
|
||||
|
||||
tcp dport 2222 ct state new limit rate 15/minute counter accept
|
||||
|
||||
tcp dport @tcp_ports counter accept
|
||||
}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy accept;
|
||||
}
|
||||
|
||||
chain nat {
|
||||
type nat hook postrouting priority 0; policy accept;
|
||||
ip saddr 192.168.3.0/24 masquerade
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# PermitRootLogin = "yes";
|
||||
PermitRootLogin = "prohibit-password";
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBWOy0QmAyxENg/O5m3cus8U3c9jCLioivwcWsh5/a82 imxyy-hisense-pad"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8pivvE8PMtsOxmccfNhH/4KehDKhBfUfJbQZxo/SZT imxyy-ace5"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMb5G/ieEYBOng66YeyttBQLThyM6W//z2POsNyq4Rw/ imxyy@imxyy-nix-x16"
|
||||
];
|
||||
users.users.${username}.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBWOy0QmAyxENg/O5m3cus8U3c9jCLioivwcWsh5/a82 imxyy-hisense-pad"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8pivvE8PMtsOxmccfNhH/4KehDKhBfUfJbQZxo/SZT imxyy-ace5"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMb5G/ieEYBOng66YeyttBQLThyM6W//z2POsNyq4Rw/ imxyy@imxyy-nix-x16"
|
||||
];
|
||||
|
||||
sops.secrets.dae-imxyy-nix-server = {
|
||||
sopsFile = secrets.dae-imxyy-nix-server;
|
||||
format = "binary";
|
||||
};
|
||||
services.dae = {
|
||||
enable = true;
|
||||
configFile = config.sops.secrets.dae-imxyy-nix-server.path;
|
||||
};
|
||||
systemd.services.dae.after = [ "sops-nix.service" ];
|
||||
sops.secrets.mihomo = {
|
||||
sopsFile = secrets.mihomo;
|
||||
format = "yaml";
|
||||
key = "";
|
||||
};
|
||||
systemd.services.mihomo.after = [ "sops-nix.service" ];
|
||||
services.mihomo = {
|
||||
enable = true;
|
||||
configFile = config.sops.secrets.mihomo.path;
|
||||
webui = pkgs.metacubexd;
|
||||
};
|
||||
|
||||
sops.secrets.frp-env = {
|
||||
sopsFile = secrets.frp;
|
||||
format = "dotenv";
|
||||
};
|
||||
systemd.services.frp.serviceConfig.EnvironmentFile = [
|
||||
config.sops.secrets.frp-env.path
|
||||
];
|
||||
services.frp = {
|
||||
enable = true;
|
||||
role = "client";
|
||||
settings = {
|
||||
serverAddr = "hk.vkvm.imxyy.top";
|
||||
serverPort = 7000;
|
||||
auth.token = "{{ .Envs.FRP_AUTH_TOKEN }}";
|
||||
proxies = [
|
||||
{
|
||||
name = "nextcloud-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "nextcloud.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "nextcloud-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "nextcloud.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "oidc-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "oidc.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "oidc-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "oidc.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "headscale-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "headscale.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "headscale-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "headscale.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "mail-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "mail.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "mail-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "mail.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "gitea-ssh";
|
||||
type = "tcp";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 2222;
|
||||
remotePort = 2222;
|
||||
}
|
||||
{
|
||||
name = "gitea-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "git.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "gitea-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "git.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "vault-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "vault.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "vault-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "vault.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "home-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "home.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "home-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "home.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "coder-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "coder.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "coder-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "coder.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "music-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "music.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "music-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "music.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "ai-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "ai.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "ai-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "ai.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "grafana-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "grafana.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "grafana-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "grafana.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "note-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "note.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "note-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "note.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "siyuan-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "sy.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "siyuan-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "sy.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "matrix-root-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-root-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "matrix.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "matrix.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-fed";
|
||||
type = "tcp";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 8448;
|
||||
remotePort = 8448;
|
||||
}
|
||||
|
||||
{
|
||||
name = "immich-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "immich.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "immich-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "immich.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "memo-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "memo.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "memo-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "memo.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "minecraft";
|
||||
type = "tcp";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 25565;
|
||||
remotePort = 25565;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.tailscale = {
|
||||
enable = true;
|
||||
useRoutingFeatures = "both";
|
||||
extraSetFlags = [ "--accept-dns=false" ];
|
||||
};
|
||||
services.headscale = {
|
||||
enable = true;
|
||||
address = "0.0.0.0";
|
||||
port = 8080;
|
||||
settings = {
|
||||
logtail.enabled = false;
|
||||
server_url = "https://headscale.imxyy.top";
|
||||
dns.magic_dns = false;
|
||||
dns.override_local_dns = false;
|
||||
ip_prefixes = "100.64.0.0/10";
|
||||
|
||||
oidc = {
|
||||
only_start_if_oidc_is_available = true;
|
||||
issuer = "https://oidc.imxyy.top";
|
||||
client_id = "https://headscale.imxyy.top";
|
||||
allowed_domains = [
|
||||
"imxyy.top"
|
||||
"*.imxyy.top"
|
||||
];
|
||||
client_secret = "";
|
||||
expiry = 0;
|
||||
extra_params.domain_hint = "imxyy.top";
|
||||
};
|
||||
};
|
||||
};
|
||||
systemd.services."headscale" = {
|
||||
after = [
|
||||
"podman-obligator.service"
|
||||
];
|
||||
requires = [
|
||||
"podman-obligator.service"
|
||||
];
|
||||
};
|
||||
|
||||
sops.secrets.et-imxyy-nix-server = {
|
||||
sopsFile = secrets.et-imxyy-nix-server;
|
||||
format = "binary";
|
||||
};
|
||||
environment.systemPackages = [ pkgs.easytier ];
|
||||
systemd.services."easytier" = {
|
||||
enable = true;
|
||||
script = "${pkgs.easytier}/bin/easytier-core -c ${config.sops.secrets.et-imxyy-nix-server.path}";
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = 30;
|
||||
User = "root";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [
|
||||
"network.target"
|
||||
"sops-nix.service"
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers.obligator = {
|
||||
image = "anderspitman/obligator:latest";
|
||||
volumes = [
|
||||
"/var/lib/obligator:/data"
|
||||
"/var/lib/obligator:/api"
|
||||
];
|
||||
ports = [ "8081:1616" ];
|
||||
cmd = [
|
||||
"-storage-dir"
|
||||
"/data"
|
||||
"-api-socket-dir"
|
||||
"/api"
|
||||
"-root-uri"
|
||||
"https://oidc.imxyy.top"
|
||||
"-port"
|
||||
"1616"
|
||||
];
|
||||
};
|
||||
services.caddy.virtualHosts."headscale.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8080 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."oidc.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8081 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services.ddns-go =
|
||||
let
|
||||
ddns-go = pkgs.buildGoModule rec {
|
||||
pname = "ddns-go";
|
||||
version = "6.6.7";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jeessy2";
|
||||
repo = "ddns-go";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-Ejoe6e9GFhHxQ9oIBDgDRQW9Xx1XZK+qSAXiRXLdn+c=";
|
||||
};
|
||||
meta.mainProgram = "ddns-go";
|
||||
vendorHash = "sha256-XZii7gV3DmTunYyGYzt5xXhv/VpTPIoYKbW4LnmlAgs=";
|
||||
doCheck = false;
|
||||
};
|
||||
in
|
||||
{
|
||||
description = "Go Dynamic DNS";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${lib.getExe ddns-go} -l :9876 -f 10 -cacheTimes 180 -c /var/lib/ddns-go/config.yaml";
|
||||
Restart = "always";
|
||||
RestartSec = 120;
|
||||
};
|
||||
path = [
|
||||
pkgs.bash
|
||||
];
|
||||
};
|
||||
|
||||
services.dnsmasq =
|
||||
let
|
||||
subDomains = [
|
||||
"home"
|
||||
"nextcloud"
|
||||
"mail"
|
||||
"git"
|
||||
"vault"
|
||||
"coder"
|
||||
"headscale"
|
||||
"grafana"
|
||||
"matrix"
|
||||
"note"
|
||||
"oidc"
|
||||
"mc"
|
||||
"music"
|
||||
"ai"
|
||||
"sy"
|
||||
"minio"
|
||||
"immich"
|
||||
];
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
resolveLocalQueries = false;
|
||||
settings = {
|
||||
server = [
|
||||
"120.53.53.53"
|
||||
"223.5.5.5"
|
||||
];
|
||||
address = map (sub: "/${sub}.imxyy.top/192.168.3.2") subDomains ++ [
|
||||
"/imxyy-nix-server/192.168.3.2"
|
||||
"/imxyy-cloudwin/192.168.3.4"
|
||||
"/printer.home/192.168.3.53"
|
||||
];
|
||||
cache-size = 0;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
virtualisation.oci-containers.containers."YesPlayMusic" = {
|
||||
image = "git.imxyy.top/imxyy1soope1/yesplaymusic:latest";
|
||||
environment = {
|
||||
"NODE_TLS_REJECT_UNAUTHORIZED" = "0";
|
||||
};
|
||||
volumes = [
|
||||
"/etc/localtime:/etc/localtime:ro"
|
||||
];
|
||||
ports = [
|
||||
"8088:80/tcp"
|
||||
];
|
||||
log-driver = "journald";
|
||||
};
|
||||
|
||||
services.caddy.virtualHosts."music.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8088 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./nixos.nix
|
||||
./home.nix
|
||||
];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{ lib, username, ... }:
|
||||
{
|
||||
my.home.programs.zsh.shellAliases = {
|
||||
localproxy_on = "export http_proxy=http://192.168.128.1:7890 https_proxy=http://192.168.128.1:7890 all_proxy=socks://192.168.128.1:7890";
|
||||
};
|
||||
my = {
|
||||
sops.sshKeyFile = "/home/${username}/.ssh/id_ed25519";
|
||||
coding.all.enable = true;
|
||||
coding.editor.vscode.enable = lib.mkForce false;
|
||||
cli.misc.enable = true;
|
||||
xdg.enable = true;
|
||||
cli.media.all.enable = true;
|
||||
};
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./nixos.nix
|
||||
./hardware.nix
|
||||
./home.nix
|
||||
./net.nix
|
||||
];
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
username,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
{
|
||||
security.pam.loginLimits = [
|
||||
{
|
||||
domain = "*";
|
||||
type = "soft";
|
||||
item = "nofile";
|
||||
value = "524288";
|
||||
}
|
||||
];
|
||||
|
||||
boot.kernelParams = [
|
||||
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
|
||||
];
|
||||
|
||||
boot.loader = {
|
||||
efi.canTouchEfiVariables = true;
|
||||
systemd-boot.enable = true;
|
||||
grub.enable = false;
|
||||
timeout = 0;
|
||||
};
|
||||
|
||||
hardware.graphics.enable = true;
|
||||
hardware.graphics.enable32Bit = true;
|
||||
|
||||
systemd.services.nix-daemon = {
|
||||
environment.TMPDIR = "/var/cache/nix";
|
||||
serviceConfig.CacheDirectory = "nix";
|
||||
};
|
||||
environment.variables.NIX_REMOTE = "daemon";
|
||||
|
||||
fonts = {
|
||||
enableDefaultPackages = false;
|
||||
fontDir.enable = true;
|
||||
|
||||
packages = with pkgs; [
|
||||
noto-fonts
|
||||
noto-fonts-cjk-sans
|
||||
noto-fonts-emoji
|
||||
|
||||
jetbrains-mono
|
||||
|
||||
nerd-fonts.symbols-only
|
||||
];
|
||||
|
||||
fontconfig.defaultFonts = {
|
||||
serif = [
|
||||
"Noto Serif CJK SC"
|
||||
"Noto Serif"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
sansSerif = [
|
||||
"Noto Sans CJK SC"
|
||||
"Noto Sans"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
monospace = [
|
||||
"JetBrains Mono"
|
||||
"Noto Sans Mono CJK SC"
|
||||
"Symbols Nerd Font Mono"
|
||||
];
|
||||
emoji = [ "Noto Color Emoji" ];
|
||||
};
|
||||
};
|
||||
|
||||
services.printing.enable = true;
|
||||
|
||||
services.upower.enable = true;
|
||||
services.power-profiles-daemon.enable = true;
|
||||
|
||||
services.keyd = {
|
||||
enable = true;
|
||||
keyboards.default.settings = {
|
||||
main = {
|
||||
capslock = "overload(control, esc)";
|
||||
home = "end";
|
||||
};
|
||||
shift = {
|
||||
home = "home";
|
||||
};
|
||||
control = {
|
||||
delete = "print";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.gvfs.enable = true;
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# Forbid root login through SSH.
|
||||
PermitRootLogin = null;
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.rclone
|
||||
];
|
||||
|
||||
sops.secrets.imxyy-nix-rclone = {
|
||||
sopsFile = secrets.imxyy-nix-rclone;
|
||||
format = "binary";
|
||||
};
|
||||
fileSystems = {
|
||||
"/home/${username}/Nextcloud" = {
|
||||
device = "Nextcloud:";
|
||||
fsType = "rclone";
|
||||
options = [
|
||||
"nodev"
|
||||
"nofail"
|
||||
"allow_other"
|
||||
"args2env"
|
||||
"config=${config.sops.secrets.imxyy-nix-rclone.path}"
|
||||
"uid=1000"
|
||||
"gid=100"
|
||||
"rw"
|
||||
"no-check-certificate"
|
||||
"vfs-cache-mode=full"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
my.persist.nixosDirs = [ "/etc/NetworkManager/system-connections" ];
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
imports = [
|
||||
./nixos.nix
|
||||
./hardware.nix
|
||||
./home.nix
|
||||
./virt.nix
|
||||
./net.nix
|
||||
];
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
username,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
let
|
||||
btreset = pkgs.writeScriptBin "btreset" ''
|
||||
#!${lib.getExe pkgs.python3}
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
|
||||
SYM = "BT"
|
||||
|
||||
def action(line: str) -> bool:
|
||||
if line.find(SYM) == -1:
|
||||
return False
|
||||
temp = line.split(" ")
|
||||
bus = temp[1]
|
||||
device = temp[3][:-1]
|
||||
subprocess.run(["${lib.getExe' pkgs.usbutils "usbreset"}", f"{bus}/{device}"])
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.exists("/tmp/.btreseted") and len(sys.argv) == 1 and "-f" not in sys.argv[1:]:
|
||||
exit(0)
|
||||
res_byte = subprocess.check_output("/run/current-system/sw/bin/lsusb")
|
||||
res = res_byte.decode()
|
||||
lst = res.split("\n")
|
||||
|
||||
if any(tuple(map(action, lst))):
|
||||
with open("/tmp/.btreseted", "w"):
|
||||
...
|
||||
'';
|
||||
in
|
||||
{
|
||||
security.pam.loginLimits = [
|
||||
{
|
||||
domain = "*";
|
||||
type = "soft";
|
||||
item = "nofile";
|
||||
value = "524288";
|
||||
}
|
||||
];
|
||||
|
||||
systemd.services.btreset = {
|
||||
script = lib.getExe btreset;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
boot.kernelParams = [
|
||||
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
|
||||
"fsck.mode=skip"
|
||||
];
|
||||
|
||||
boot.loader = {
|
||||
efi.canTouchEfiVariables = true;
|
||||
systemd-boot.enable = true;
|
||||
grub.enable = false;
|
||||
timeout = 0;
|
||||
};
|
||||
|
||||
hardware.graphics.enable = true;
|
||||
hardware.graphics.enable32Bit = true;
|
||||
|
||||
systemd.services.nix-daemon = {
|
||||
environment.TMPDIR = "/var/cache/nix";
|
||||
serviceConfig.CacheDirectory = "nix";
|
||||
};
|
||||
environment.variables.NIX_REMOTE = "daemon";
|
||||
|
||||
fonts = {
|
||||
enableDefaultPackages = false;
|
||||
fontDir.enable = true;
|
||||
|
||||
packages = with pkgs; [
|
||||
noto-fonts
|
||||
noto-fonts-cjk-sans
|
||||
noto-fonts-emoji
|
||||
|
||||
jetbrains-mono
|
||||
|
||||
nerd-fonts.symbols-only
|
||||
];
|
||||
|
||||
fontconfig.defaultFonts = {
|
||||
serif = [
|
||||
"Noto Serif CJK SC"
|
||||
"Noto Serif"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
sansSerif = [
|
||||
"Noto Sans CJK SC"
|
||||
"Noto Sans"
|
||||
"Symbols Nerd Font"
|
||||
];
|
||||
monospace = [
|
||||
"JetBrains Mono"
|
||||
"Noto Sans Mono CJK SC"
|
||||
"Symbols Nerd Font Mono"
|
||||
];
|
||||
emoji = [ "Noto Color Emoji" ];
|
||||
};
|
||||
};
|
||||
|
||||
services.printing.enable = true;
|
||||
|
||||
services.keyd = {
|
||||
enable = true;
|
||||
keyboards.default.settings = {
|
||||
main = {
|
||||
capslock = "overload(control, esc)";
|
||||
home = "end";
|
||||
};
|
||||
shift = {
|
||||
home = "home";
|
||||
};
|
||||
control = {
|
||||
delete = "print";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.gvfs.enable = true;
|
||||
|
||||
programs.wireshark.enable = true;
|
||||
programs.wireshark.package = pkgs.wireshark;
|
||||
users.users.${username}.extraGroups = [ "wireshark" ];
|
||||
|
||||
services.sunshine = {
|
||||
enable = true;
|
||||
autoStart = true;
|
||||
capSysAdmin = true;
|
||||
applications.apps = [
|
||||
{
|
||||
name = "Desktop";
|
||||
image-path = "desktop.png";
|
||||
}
|
||||
];
|
||||
};
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# Forbid root login through SSH.
|
||||
PermitRootLogin = null;
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.rclone
|
||||
btreset
|
||||
];
|
||||
|
||||
sops.secrets.imxyy-nix-rclone = {
|
||||
sopsFile = secrets.imxyy-nix-rclone;
|
||||
format = "binary";
|
||||
};
|
||||
fileSystems = {
|
||||
"/home/${username}/Nextcloud" = {
|
||||
device = "Nextcloud:";
|
||||
fsType = "rclone";
|
||||
options = [
|
||||
"nodev"
|
||||
"nofail"
|
||||
"allow_other"
|
||||
"args2env"
|
||||
"config=${config.sops.secrets.imxyy-nix-rclone.path}"
|
||||
"uid=1000"
|
||||
"gid=100"
|
||||
"rw"
|
||||
"no-check-certificate"
|
||||
"vfs-cache-mode=full"
|
||||
];
|
||||
};
|
||||
"/home/${username}/NAS" = {
|
||||
device = "//192.168.3.2/share";
|
||||
fsType = "cifs";
|
||||
options = [
|
||||
"username=nas"
|
||||
"password=nasshare"
|
||||
"x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"
|
||||
"nodev"
|
||||
"nofail"
|
||||
"uid=1000"
|
||||
"gid=100"
|
||||
"vers=3"
|
||||
"rw"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
652
flake.lock
generated
652
flake.lock
generated
File diff suppressed because it is too large
Load Diff
300
flake.nix
300
flake.nix
@@ -3,209 +3,145 @@
|
||||
|
||||
inputs = {
|
||||
# Nixpkgs
|
||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
||||
nixpkgs-stable.url = "github:nixos/nixpkgs/release-25.05";
|
||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
nixpkgs-stable.url = "github:nixos/nixpkgs/release-25.11";
|
||||
nixpkgs-master.url = "github:nixos/nixpkgs/master";
|
||||
# nixpkgs.follows = "nixpkgs-stable";
|
||||
nixpkgs.follows = "nixpkgs-unstable";
|
||||
# nixpkgs.follows = "nixpkgs-master";
|
||||
|
||||
# Nyxpkgs
|
||||
chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
|
||||
|
||||
# TODO: sops-nix: remove pr patch once merged
|
||||
# https://github.com/Mic92/sops-nix/pull/779
|
||||
sops-nix.url = "github:Mic92/sops-nix/pull/779/merge";
|
||||
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# Home manager
|
||||
home-manager.url = "github:nix-community/home-manager/master";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# Impermanence
|
||||
impermanence.url = "github:nix-community/impermanence";
|
||||
|
||||
# NUR
|
||||
nur.url = "github:nix-community/NUR";
|
||||
|
||||
# Niri
|
||||
niri.url = "github:sodiboo/niri-flake";
|
||||
|
||||
darkly.url = "github:Bali10050/Darkly";
|
||||
darkly.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
stylix.url = "github:danth/stylix";
|
||||
stylix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# go-musicfox
|
||||
go-musicfox.url = "github:imxyy1soope1/go-musicfox/master";
|
||||
go-musicfox.inputs.nixpkgs.follows = "nixpkgs";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager/master";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# NixOS-WSL
|
||||
nixos-wsl.url = "github:nix-community/NixOS-WSL";
|
||||
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nixos-wsl = {
|
||||
url = "github:nix-community/NixOS-WSL";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
fenix.url = "github:nix-community/fenix";
|
||||
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
# Flake organization tools
|
||||
# keep-sorted start block=yes
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
haumea = {
|
||||
url = "github:nix-community/haumea/v0.2.2";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
infuse = {
|
||||
url = "git+https://codeberg.org/amjoseph/infuse.nix";
|
||||
flake = false;
|
||||
};
|
||||
# keep-sorted end
|
||||
|
||||
zen.url = "github:0xc000022070/zen-browser-flake";
|
||||
# Useful modules
|
||||
# keep-sorted start block=yes
|
||||
catppuccin = {
|
||||
url = "github:catppuccin/nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
impermanence.url = "github:nix-community/impermanence";
|
||||
# TODO: sops-nix: remove pr patch once merged
|
||||
# https://github.com/Mic92/sops-nix/pull/779
|
||||
sops-nix = {
|
||||
url = "github:Mic92/sops-nix/pull/779/merge";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
stylix = {
|
||||
url = "github:danth/stylix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
system76-scheduler-niri = {
|
||||
url = "github:Kirottu/system76-scheduler-niri";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
# keep-sorted end
|
||||
|
||||
# Useful software
|
||||
# keep-sorted start block=yes
|
||||
angrr = {
|
||||
url = "github:linyinfeng/angrr";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
darkly = {
|
||||
url = "github:Bali10050/Darkly";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
go-musicfox = {
|
||||
url = "github:imxyy1soope1/go-musicfox";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
niri.url = "github:sodiboo/niri-flake";
|
||||
noctalia = {
|
||||
url = "github:noctalia-dev/noctalia-shell/v4.5.0";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
zen.inputs.nixpkgs.follows = "nixpkgs";
|
||||
zen.url = "github:0xc000022070/zen-browser-flake";
|
||||
# keep-sorted end
|
||||
|
||||
catppuccin.url = "github:catppuccin/nix";
|
||||
catppuccin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
infuse.url = "git+https://codeberg.org/amjoseph/infuse.nix";
|
||||
infuse.flake = false;
|
||||
|
||||
haumea.url = "github:nix-community/haumea/v0.2.2";
|
||||
haumea.inputs.nixpkgs.follows = "nixpkgs";
|
||||
# Misc
|
||||
treefmt = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
plant = {
|
||||
url = "git+ssh://git@git.imxyy.top:2222/imxyy1soope1/HF-plant.git?rev=08dc0b3889797eb3618c7475c3c367ec0e5fdf40";
|
||||
flake = false;
|
||||
};
|
||||
my-templates.url = "git+https://git.imxyy.top/imxyy1soope1/flake-templates";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-parts,
|
||||
...
|
||||
}@inputs:
|
||||
let
|
||||
inherit (self) outputs;
|
||||
vars = import ./vars.nix;
|
||||
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
|
||||
forAllHosts =
|
||||
mkSystem:
|
||||
lib.mergeAttrsList (
|
||||
builtins.map (hostname: {
|
||||
${hostname} = mkSystem hostname;
|
||||
}) (builtins.attrNames (builtins.readDir ./config/hosts))
|
||||
);
|
||||
flake-parts.lib.mkFlake
|
||||
{
|
||||
inherit inputs;
|
||||
specialArgs.lib = import ./lib {
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
inherit inputs;
|
||||
};
|
||||
}
|
||||
{
|
||||
systems = [ "x86_64-linux" ];
|
||||
|
||||
lib = (import ./lib/stdlib-extended.nix nixpkgs.lib).extend (
|
||||
final: prev: {
|
||||
inherit (inputs.home-manager.lib) hm;
|
||||
inherit infuse;
|
||||
haumea = inputs.haumea.lib;
|
||||
}
|
||||
);
|
||||
infuse = (import inputs.infuse { inherit (nixpkgs) lib; }).v1.infuse;
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (
|
||||
system:
|
||||
lib.haumea.load {
|
||||
src = ./pkgs;
|
||||
loader = [
|
||||
{
|
||||
matches = str: builtins.match ".*\\.nix" str != null;
|
||||
loader = _: path: nixpkgs.legacyPackages.${system}.callPackage path { };
|
||||
}
|
||||
];
|
||||
transformer = lib.haumea.transformers.liftDefault;
|
||||
}
|
||||
);
|
||||
imports = [
|
||||
./flake/hosts.nix
|
||||
./flake/pkgs.nix
|
||||
./treefmt.nix
|
||||
./overlays
|
||||
];
|
||||
|
||||
# workaround for "treefmt warning"
|
||||
formatter = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "nixfmt-wrapper";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
fd
|
||||
nixfmt-rfc-style
|
||||
];
|
||||
|
||||
text = ''
|
||||
fd "$@" -t f -e nix -x nixfmt '{}'
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
overlays = import ./overlays {
|
||||
inherit inputs lib;
|
||||
};
|
||||
|
||||
nixosConfigurations = forAllHosts (
|
||||
hostname:
|
||||
let
|
||||
overlays = builtins.attrValues self.overlays ++ [
|
||||
inputs.go-musicfox.overlays.default
|
||||
inputs.niri.overlays.niri
|
||||
inputs.fenix.overlays.default
|
||||
(final: prev: {
|
||||
darkly-qt5 = inputs.darkly.packages.${final.system}.darkly-qt5;
|
||||
darkly-qt6 = inputs.darkly.packages.${final.system}.darkly-qt6;
|
||||
})
|
||||
(final: prev: {
|
||||
inherit lib;
|
||||
})
|
||||
];
|
||||
home = {
|
||||
home-manager = {
|
||||
sharedModules = [
|
||||
inputs.sops-nix.homeManagerModules.sops
|
||||
inputs.impermanence.nixosModules.home-manager.impermanence
|
||||
inputs.stylix.homeModules.stylix
|
||||
inputs.zen.homeModules.beta
|
||||
# workaround for annoying stylix
|
||||
(
|
||||
{ lib, ... }:
|
||||
{
|
||||
nixpkgs.overlays = lib.mkForce null;
|
||||
}
|
||||
)
|
||||
];
|
||||
useGlobalPkgs = true;
|
||||
};
|
||||
nixosHosts = {
|
||||
imxyy-nix = {
|
||||
profiles = [ "desktop" ];
|
||||
};
|
||||
pkgsConf.nixpkgs = {
|
||||
inherit overlays;
|
||||
config.allowUnfree = true;
|
||||
flake.setNixPath = false;
|
||||
|
||||
imxyy-nix-server = {
|
||||
profiles = [ "server" ];
|
||||
};
|
||||
in
|
||||
lib.nixosSystem {
|
||||
specialArgs = {
|
||||
inherit
|
||||
inputs
|
||||
outputs
|
||||
hostname
|
||||
;
|
||||
secrets =
|
||||
with lib.haumea;
|
||||
load {
|
||||
src = ./secrets;
|
||||
loader = [
|
||||
(matchers.always loaders.path)
|
||||
];
|
||||
};
|
||||
}
|
||||
// vars;
|
||||
modules =
|
||||
(lib.umport {
|
||||
paths = [ ./modules ];
|
||||
exclude = [
|
||||
./modules/virt/types
|
||||
./modules/desktop/wm/niri/waybar
|
||||
];
|
||||
recursive = true;
|
||||
})
|
||||
++ [
|
||||
(lib.mkAliasOptionModule [ "my" "home" ] [ "home-manager" "users" vars.username ])
|
||||
./config/base.nix
|
||||
./config/hosts/${hostname}
|
||||
inputs.chaotic.nixosModules.default
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
inputs.home-manager.nixosModules.default
|
||||
inputs.niri.nixosModules.niri
|
||||
inputs.catppuccin.nixosModules.catppuccin
|
||||
home
|
||||
pkgsConf
|
||||
|
||||
imxyy-nix-wsl = {
|
||||
profiles = [ "wsl" ];
|
||||
modules = [
|
||||
inputs.nixos-wsl.nixosModules.default
|
||||
];
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
imxyy-nix-x16 = {
|
||||
profiles = [ "desktop" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
144
flake/hosts.nix
Normal file
144
flake/hosts.nix
Normal file
@@ -0,0 +1,144 @@
|
||||
{
|
||||
self,
|
||||
lib,
|
||||
inputs,
|
||||
withSystem,
|
||||
config,
|
||||
pkgsParams,
|
||||
...
|
||||
}:
|
||||
let
|
||||
vars = import ../vars.nix;
|
||||
pkgsModule = {
|
||||
nixpkgs = pkgsParams;
|
||||
};
|
||||
hmModule = {
|
||||
home-manager = {
|
||||
sharedModules = [
|
||||
# keep-sorted start
|
||||
inputs.noctalia.homeModules.default
|
||||
inputs.sops-nix.homeManagerModules.sops
|
||||
inputs.stylix.homeModules.stylix
|
||||
inputs.system76-scheduler-niri.homeModules.default
|
||||
inputs.zen.homeModules.beta
|
||||
# keep-sorted end
|
||||
{
|
||||
stylix.overlays.enable = lib.mkForce false;
|
||||
}
|
||||
];
|
||||
useGlobalPkgs = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.nixosHosts = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
system = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "x86_64-linux";
|
||||
description = "System architecture";
|
||||
};
|
||||
|
||||
profiles = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
description = "List of profile names (e.g., 'desktop', 'server', 'wsl')";
|
||||
};
|
||||
|
||||
modules = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.deferredModule;
|
||||
default = (
|
||||
lib.umport {
|
||||
paths = [ ../hosts/${name} ];
|
||||
extraExcludePredicate = path: lib.hasInfix "/_" (toString path);
|
||||
recursive = true;
|
||||
}
|
||||
);
|
||||
description = "Additional NixOS modules specific to this host";
|
||||
};
|
||||
|
||||
extraSpecialArgs = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
default = { };
|
||||
description = "Extra special arguments to pass to modules";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = { };
|
||||
description = "Declarative host definitions";
|
||||
};
|
||||
|
||||
config = {
|
||||
# Generate nixosConfigurations from declarative host definitions
|
||||
flake.nixosConfigurations = lib.mapAttrs (
|
||||
hostname: hostConfig:
|
||||
withSystem hostConfig.system (
|
||||
{ ... }:
|
||||
lib.nixosSystem {
|
||||
inherit (hostConfig) system;
|
||||
|
||||
specialArgs = {
|
||||
inherit
|
||||
inputs
|
||||
self
|
||||
hostname
|
||||
;
|
||||
assets =
|
||||
with lib.haumea;
|
||||
load {
|
||||
src = ../assets;
|
||||
loader = [ (matchers.always loaders.path) ];
|
||||
};
|
||||
secrets =
|
||||
with lib.haumea;
|
||||
load {
|
||||
src = ../secrets;
|
||||
loader = [ (matchers.always loaders.path) ];
|
||||
};
|
||||
}
|
||||
// vars
|
||||
// hostConfig.extraSpecialArgs;
|
||||
|
||||
modules =
|
||||
# Automatically import all feature modules
|
||||
(lib.umport {
|
||||
paths = [ ../modules ];
|
||||
extraExcludePredicate = path: lib.hasInfix "/_" (toString path);
|
||||
recursive = true;
|
||||
})
|
||||
++ [
|
||||
# Base profile (always included)
|
||||
../profiles/base.nix
|
||||
]
|
||||
# Add requested profiles
|
||||
++ (map (profile: ../profiles/${profile}.nix) hostConfig.profiles)
|
||||
# Add host-specific modules
|
||||
++ hostConfig.modules
|
||||
++ [
|
||||
(lib.mkAliasOptionModule [ "my" "hm" ] [ "home-manager" "users" vars.username ])
|
||||
|
||||
# Upstream modules
|
||||
# keep-sorted start
|
||||
inputs.angrr.nixosModules.angrr
|
||||
inputs.catppuccin.nixosModules.catppuccin
|
||||
inputs.home-manager.nixosModules.default
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
inputs.niri.nixosModules.niri
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
# keep-sorted end
|
||||
|
||||
# pkgs and home-manager configuration
|
||||
pkgsModule
|
||||
hmModule
|
||||
];
|
||||
}
|
||||
)
|
||||
) config.nixosHosts;
|
||||
};
|
||||
}
|
||||
55
flake/pkgs.nix
Normal file
55
flake/pkgs.nix
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
pkgsParams,
|
||||
...
|
||||
}:
|
||||
{
|
||||
_module.args = {
|
||||
pkgsParams = {
|
||||
overlays = builtins.attrValues config.flake.overlays ++ [
|
||||
inputs.go-musicfox.overlays.default
|
||||
inputs.niri.overlays.niri
|
||||
inputs.fenix.overlays.default
|
||||
inputs.angrr.overlays.default
|
||||
(final: prev: {
|
||||
darkly-qt5 = inputs.darkly.packages.${final.stdenv.hostPlatform.system}.darkly-qt5;
|
||||
darkly-qt6 = inputs.darkly.packages.${final.stdenv.hostPlatform.system}.darkly-qt6;
|
||||
|
||||
noctalia-shell = inputs.noctalia.packages.${final.stdenv.hostPlatform.system}.default;
|
||||
})
|
||||
];
|
||||
config.allowUnfree = true;
|
||||
flake.setNixPath = false;
|
||||
};
|
||||
};
|
||||
|
||||
perSystem =
|
||||
{
|
||||
system,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
_module.args.pkgs = import inputs.nixpkgs (pkgsParams // { inherit system; });
|
||||
legacyPackages = pkgs;
|
||||
packages = lib.genAttrs (builtins.attrNames (config.flake.overlays.additions pkgs pkgs)) (
|
||||
pkg: pkgs.${pkg}
|
||||
);
|
||||
};
|
||||
|
||||
flake.overlays.additions =
|
||||
final: prev:
|
||||
with lib.haumea;
|
||||
load {
|
||||
src = ../pkgs;
|
||||
loader = [
|
||||
{
|
||||
matches = str: builtins.match ".*\\.nix" str != null;
|
||||
loader = _: path: final.callPackage path { };
|
||||
}
|
||||
];
|
||||
transformer = transformers.liftDefault;
|
||||
};
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
secrets,
|
||||
hosts,
|
||||
...
|
||||
}:
|
||||
{
|
||||
sops.secrets.et-imxyy-nix-server-nixremote = {
|
||||
sopsFile = secrets.et-imxyy-nix-server-nixremote;
|
||||
restartUnits = [ "easytier-nixremote.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
environment.systemPackages = [ pkgs.easytier ];
|
||||
@@ -29,13 +32,7 @@
|
||||
isSystemUser = true;
|
||||
description = "nix remote build user";
|
||||
group = "nixremote";
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBWOy0QmAyxENg/O5m3cus8U3c9jCLioivwcWsh5/a82 imxyy-hisense-pad"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8pivvE8PMtsOxmccfNhH/4KehDKhBfUfJbQZxo/SZT imxyy-ace5"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKALTBn/QSGcSPgMg0ViSazFcaA0+nEF05EJpjbsI6dE imxyy_soope_@imxyy-cloudwin"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMb5G/ieEYBOng66YeyttBQLThyM6W//z2POsNyq4Rw/ imxyy@imxyy-nix-x16"
|
||||
|
||||
openssh.authorizedKeys.keys = (lib.mapAttrsToList (host: key: "${key} ${host}") hosts) ++ [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIENauvvhVMLsUwH9cPYsvnOg7VCL3a4yEiKm8I524TE efl@efl-nix"
|
||||
];
|
||||
};
|
||||
15
hosts/imxyy-nix-server/code.nix
Normal file
15
hosts/imxyy-nix-server/code.nix
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
services.coder = {
|
||||
enable = true;
|
||||
accessUrl = "https://coder.imxyy.top";
|
||||
listenAddress = "127.0.0.1:8086";
|
||||
};
|
||||
users.users.coder.extraGroups = [ "podman" ];
|
||||
services.caddy.virtualHosts."coder.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8086 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -5,5 +5,10 @@
|
||||
enable = true;
|
||||
dockerCompat = true;
|
||||
dockerSocket.enable = true;
|
||||
defaultNetwork.settings.dns_enabled = true;
|
||||
};
|
||||
# avoid collision with dnsmasq
|
||||
virtualisation.containers = {
|
||||
containersConf.settings.network.dns_bind_port = 5353;
|
||||
};
|
||||
}
|
||||
56
hosts/imxyy-nix-server/efl.nix
Normal file
56
hosts/imxyy-nix-server/efl.nix
Normal file
@@ -0,0 +1,56 @@
|
||||
{ config, secrets, ... }:
|
||||
{
|
||||
sops.secrets.efl-tuwunel-env = {
|
||||
sopsFile = secrets.efl-tuwunel;
|
||||
restartUnits = [ "podman-tuwunel.service" ];
|
||||
format = "dotenv";
|
||||
};
|
||||
virtualisation.oci-containers.containers = {
|
||||
tuwunel = {
|
||||
image = "ghcr.io/matrix-construct/tuwunel:latest";
|
||||
volumes = [
|
||||
"tuwunel_db:/var/lib/tuwunel"
|
||||
];
|
||||
ports = [ "6167:6167" ];
|
||||
networks = [ "podman" ];
|
||||
extraOptions = [ "--pids-limit=-1" ];
|
||||
environment = {
|
||||
TUWUNEL_SERVER_NAME = "mtx.eflx.top";
|
||||
TUWUNEL_PORT = "6167";
|
||||
TUWUNEL_ADDRESS = "0.0.0.0";
|
||||
TUWUNEL_WELL_KNOWN__SERVER = "mtx.eflx.top:443";
|
||||
TUWUNEL_WELL_KNOWN__CLIENT = "https://mtx.eflx.top";
|
||||
};
|
||||
environmentFiles = [
|
||||
config.sops.secrets.efl-tuwunel-env.path
|
||||
];
|
||||
};
|
||||
mautrix-telegram = {
|
||||
image = "dock.mau.dev/mautrix/telegram:latest";
|
||||
ports = [ "8099:8099" ];
|
||||
networks = [ "podman" ];
|
||||
extraOptions = [ "--ip=10.88.0.254" ];
|
||||
volumes = [ "/var/lib/efl-mautrix-telegram:/data" ];
|
||||
};
|
||||
|
||||
send = {
|
||||
image = "lanol/filecodebox:latest";
|
||||
ports = [ "12345:12345" ];
|
||||
volumes = [ "/var/lib/send:/app/data:rw" ];
|
||||
};
|
||||
};
|
||||
services.caddy.virtualHosts."mtx.eflx.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :6167 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."send.eflx.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :12345 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -18,15 +18,14 @@ in
|
||||
];
|
||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos;
|
||||
services.scx.enable = true;
|
||||
boot.kernelPackages = lib.mkForce pkgs.linuxPackages_xanmod_stable;
|
||||
boot.extraModulePackages = [ ];
|
||||
boot.tmp.useTmpfs = true;
|
||||
boot.supportedFilesystems = [ "zfs" ];
|
||||
boot.zfs = {
|
||||
package = pkgs.zfs_unstable;
|
||||
extraPools = [ "data" ];
|
||||
forceImportRoot = false;
|
||||
package = pkgs.zfs_cachyos;
|
||||
};
|
||||
services.zfs.autoScrub.enable = true;
|
||||
services.btrfs.autoScrub.enable = true;
|
||||
@@ -1,11 +1,14 @@
|
||||
{ ... }:
|
||||
{ lib, ... }:
|
||||
{
|
||||
my = {
|
||||
cli.all.enable = true;
|
||||
cli.media.all.enable = lib.mkForce false;
|
||||
coding.editor.neovim.enable = true;
|
||||
coding.misc.enable = true;
|
||||
coding.langs.lua.enable = true;
|
||||
coding.langs.rust.enable = true;
|
||||
coding.langs.js.enable = true;
|
||||
fonts.enable = lib.mkForce false;
|
||||
persist = {
|
||||
enable = true;
|
||||
homeDirs = [
|
||||
107
hosts/imxyy-nix-server/matrix.nix
Normal file
107
hosts/imxyy-nix-server/matrix.nix
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
config,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
{
|
||||
nixpkgs.config.permittedInsecurePackages = [
|
||||
"olm-3.2.16"
|
||||
];
|
||||
sops.secrets.tuwunel-reg-token = {
|
||||
sopsFile = secrets.tuwunel-reg-token;
|
||||
restartUnits = [ "tuwunel.service" ];
|
||||
format = "binary";
|
||||
owner = config.services.matrix-tuwunel.user;
|
||||
group = config.services.matrix-tuwunel.group;
|
||||
};
|
||||
sops.secrets.tuwunel-turn-secret = {
|
||||
sopsFile = secrets.tuwunel-turn-secret;
|
||||
restartUnits = [ "tuwunel.service" ];
|
||||
format = "binary";
|
||||
owner = config.services.matrix-tuwunel.user;
|
||||
group = config.services.matrix-tuwunel.group;
|
||||
};
|
||||
services.matrix-tuwunel = {
|
||||
enable = true;
|
||||
settings.global = {
|
||||
address = [ "127.0.0.1" ];
|
||||
port = [ 8094 ];
|
||||
server_name = "imxyy.top";
|
||||
well_known = {
|
||||
server = "matrix.imxyy.top:443";
|
||||
client = "https://matrix.imxyy.top";
|
||||
};
|
||||
|
||||
allow_registration = true;
|
||||
registration_token_file = config.sops.secrets.tuwunel-reg-token.path;
|
||||
|
||||
suppress_push_when_active = true;
|
||||
|
||||
turn_uris = [
|
||||
"turn:hk.vkvm.imxyy.top?transport=udp"
|
||||
"turn:hk.vkvm.imxyy.top?transport=tcp"
|
||||
];
|
||||
turn_secret_file = config.sops.secrets.tuwunel-turn-secret.path;
|
||||
|
||||
new_user_displayname_suffix = "";
|
||||
};
|
||||
};
|
||||
services.caddy.virtualHosts."imxyy.top" = {
|
||||
extraConfig = ''
|
||||
handle /.well-known/matrix/server {
|
||||
header Content-Type application/json
|
||||
header "Access-Control-Allow-Origin" "*"
|
||||
|
||||
respond `{"m.server": "matrix.imxyy.top:443"}` 200
|
||||
}
|
||||
handle /.well-known/matrix/client {
|
||||
header Content-Type application/json
|
||||
header "Access-Control-Allow-Origin" "*"
|
||||
|
||||
respond `{"m.homeserver": {"base_url": "https://matrix.imxyy.top/"}}` 200
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.caddy.virtualHosts."matrix.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8094
|
||||
'';
|
||||
};
|
||||
|
||||
sops.secrets.mautrix-telegram = {
|
||||
sopsFile = secrets.mautrix-telegram;
|
||||
restartUnits = [ "mautrix-telegram.service" ];
|
||||
format = "dotenv";
|
||||
owner = "mautrix-telegram";
|
||||
group = "mautrix-telegram";
|
||||
};
|
||||
services.mautrix-telegram = {
|
||||
enable = true;
|
||||
environmentFile = config.sops.secrets.mautrix-telegram.path;
|
||||
settings = {
|
||||
homeserver = {
|
||||
address = "http://127.0.0.1:8094";
|
||||
domain = "imxyy.top";
|
||||
};
|
||||
appservice = {
|
||||
address = "http://127.0.0.1:8098";
|
||||
hostname = "127.0.0.1";
|
||||
port = "8098";
|
||||
bot_username = "telegrambot";
|
||||
};
|
||||
bridge = {
|
||||
username_template = "telegram_{userid}";
|
||||
alias_template = "telegram_{groupname}";
|
||||
displayname_template = "{displayname} (Telegram)";
|
||||
permissions = {
|
||||
"@imxyy_soope_:imxyy.top" = "admin";
|
||||
};
|
||||
};
|
||||
telegram = {
|
||||
# borrowed from https://github.com/telegramdesktop/tdesktop/blob/9bdc19e2fd4d497c8f403891848383a88faadc25/snap/snapcraft.yaml#L134-L135
|
||||
api_id = "611335";
|
||||
api_hash = "d524b414d21f4d37f08684c1df41ac9c";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
20
hosts/imxyy-nix-server/minecraft.nix
Normal file
20
hosts/imxyy-nix-server/minecraft.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
systemd.services."fabric1.20.6" = {
|
||||
description = "fabric 1.20.6 minecraft server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
WorkingDirectory = "/opt/minecraft/fabric1.20.6";
|
||||
ExecStart = "${lib.getExe' pkgs.openjdk21 "java"} -Xms1G -Xmx5G -jar fabric-server-mc.1.20.6-loader.0.15.11-launcher.1.0.1.jar";
|
||||
Restart = "always";
|
||||
RestartSec = 120;
|
||||
};
|
||||
};
|
||||
|
||||
my.persist = {
|
||||
nixosDirs = [
|
||||
"/opt/minecraft"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
{
|
||||
sops.secrets.minio-env = {
|
||||
sopsFile = secrets.minio;
|
||||
restartUnits = [ "minio.service" ];
|
||||
format = "dotenv";
|
||||
};
|
||||
services.minio = {
|
||||
@@ -16,11 +17,4 @@
|
||||
];
|
||||
rootCredentialsFile = config.sops.secrets.minio-env.path;
|
||||
};
|
||||
services.caddy.virtualHosts."minio.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
handle_path /* {
|
||||
reverse_proxy :9000
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
511
hosts/imxyy-nix-server/net.nix
Normal file
511
hosts/imxyy-nix-server/net.nix
Normal file
@@ -0,0 +1,511 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
username,
|
||||
hosts,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot.kernelParams = [
|
||||
"biosdevname=0"
|
||||
"net.ifnames=0"
|
||||
];
|
||||
networking = {
|
||||
useDHCP = lib.mkForce false;
|
||||
dhcpcd = {
|
||||
wait = "background";
|
||||
IPv6rs = true;
|
||||
extraConfig = ''
|
||||
interface mac0
|
||||
noipv4
|
||||
'';
|
||||
};
|
||||
interfaces = {
|
||||
eth0.wakeOnLan.enable = true;
|
||||
eth1.wakeOnLan.enable = true;
|
||||
mac0 = {
|
||||
useDHCP = true;
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = "192.168.3.2";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
macvlans."mac0" = {
|
||||
interface = "eth0";
|
||||
mode = "bridge";
|
||||
};
|
||||
defaultGateway = {
|
||||
address = "192.168.3.1";
|
||||
interface = "mac0";
|
||||
};
|
||||
nameservers = [
|
||||
"192.168.3.2"
|
||||
];
|
||||
|
||||
firewall.enable = false;
|
||||
nftables = {
|
||||
enable = true;
|
||||
flushRuleset = true;
|
||||
ruleset = ''
|
||||
table inet firewall {
|
||||
set LANv4 {
|
||||
type ipv4_addr
|
||||
flags interval
|
||||
|
||||
elements = { 10.0.0.0/8, 100.64.0.0/10, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16 }
|
||||
}
|
||||
set LANv6 {
|
||||
type ipv6_addr
|
||||
flags interval
|
||||
|
||||
elements = { fd00::/8, fe80::/10 }
|
||||
}
|
||||
set tcp_ports {
|
||||
type inet_service
|
||||
flags interval
|
||||
|
||||
elements = {
|
||||
http,
|
||||
https,
|
||||
2222,
|
||||
25565
|
||||
}
|
||||
}
|
||||
|
||||
chain prerouting {
|
||||
type filter hook prerouting priority mangle; policy accept;
|
||||
|
||||
ip daddr @LANv4 accept
|
||||
ip6 daddr @LANv6 accept
|
||||
}
|
||||
|
||||
chain output {
|
||||
type filter hook output priority 100; policy accept;
|
||||
|
||||
ip daddr @LANv4 accept
|
||||
ip6 daddr @LANv6 accept
|
||||
}
|
||||
|
||||
chain input {
|
||||
type filter hook input priority 0; policy drop;
|
||||
iif lo accept
|
||||
ct state invalid drop
|
||||
ct state established,related accept
|
||||
|
||||
ip protocol { icmp, igmp } accept
|
||||
|
||||
ip saddr @LANv4 accept
|
||||
ip6 saddr @LANv6 accept
|
||||
|
||||
tcp dport 2222 ct state new limit rate 15/minute counter accept
|
||||
|
||||
tcp dport @tcp_ports counter accept
|
||||
}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy accept;
|
||||
}
|
||||
|
||||
chain nat {
|
||||
type nat hook postrouting priority 0; policy accept;
|
||||
ip saddr 192.168.3.0/24 masquerade
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# PermitRootLogin = "yes";
|
||||
PermitRootLogin = "prohibit-password";
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
users.users.root.openssh.authorizedKeys.keys = lib.mapAttrsToList (
|
||||
host: key: "${key} ${host}"
|
||||
) hosts;
|
||||
users.users.${username}.openssh.authorizedKeys.keys = lib.mapAttrsToList (
|
||||
host: key: "${key} ${host}"
|
||||
) hosts;
|
||||
|
||||
sops.secrets.dae-imxyy-nix-server = {
|
||||
sopsFile = secrets.dae-imxyy-nix-server;
|
||||
restartUnits = [ "dae.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
services.dae = {
|
||||
enable = true;
|
||||
configFile = config.sops.secrets.dae-imxyy-nix-server.path;
|
||||
};
|
||||
systemd.services.dae = {
|
||||
after = [ "sops-nix.service" ];
|
||||
serviceConfig.MemoryMax = "1G";
|
||||
};
|
||||
sops.secrets.mihomo = {
|
||||
sopsFile = secrets.mihomo;
|
||||
restartUnits = [ "mihomo.service" ];
|
||||
format = "yaml";
|
||||
key = "";
|
||||
};
|
||||
systemd.services.mihomo.after = [ "sops-nix.service" ];
|
||||
services.mihomo = {
|
||||
enable = true;
|
||||
configFile = config.sops.secrets.mihomo.path;
|
||||
webui = pkgs.metacubexd;
|
||||
};
|
||||
|
||||
sops.secrets.frp-env = {
|
||||
sopsFile = secrets.frp;
|
||||
restartUnits = [ "frp.service" ];
|
||||
format = "dotenv";
|
||||
};
|
||||
systemd.services.frp.serviceConfig.EnvironmentFile = [
|
||||
config.sops.secrets.frp-env.path
|
||||
];
|
||||
services.frp = {
|
||||
instances."" = {
|
||||
enable = true;
|
||||
role = "client";
|
||||
settings = {
|
||||
serverAddr = "{{ .Envs.FRP_SERVER_ADDR }}";
|
||||
serverPort = 7000;
|
||||
auth.token = "{{ .Envs.FRP_AUTH_TOKEN }}";
|
||||
proxies = [
|
||||
{
|
||||
name = "nextcloud-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "nextcloud.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "nextcloud-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "nextcloud.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "oidc-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "oidc.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "oidc-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "oidc.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "mail-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "mail.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "mail-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "mail.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "gitea-ssh";
|
||||
type = "tcp";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 2222;
|
||||
remotePort = 2222;
|
||||
}
|
||||
{
|
||||
name = "gitea-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "git.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "gitea-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "git.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "vault-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "vault.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "vault-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "vault.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "home-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "home.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "home-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "home.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "coder-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "coder.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "coder-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "coder.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "siyuan-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "sy.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "siyuan-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "sy.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "matrix-root-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-root-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "matrix.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "matrix-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "matrix.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "immich-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "immich.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "immich-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "immich.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "memo-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "memo.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "memo-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "memo.imxyy.top" ];
|
||||
}
|
||||
|
||||
{
|
||||
name = "efl-matrix-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "mtx.eflx.top" ];
|
||||
}
|
||||
{
|
||||
name = "efl-matrix-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "mtx.eflx.top" ];
|
||||
}
|
||||
{
|
||||
name = "efl-send-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "send.eflx.top" ];
|
||||
}
|
||||
{
|
||||
name = "efl-send-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "send.eflx.top" ];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sops.secrets.et-imxyy-nix-server = {
|
||||
sopsFile = secrets.et-imxyy-nix-server;
|
||||
restartUnits = [ "easytier.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
environment.systemPackages = [ pkgs.easytier ];
|
||||
systemd.services."easytier" = {
|
||||
enable = true;
|
||||
script = "${pkgs.easytier}/bin/easytier-core -c ${config.sops.secrets.et-imxyy-nix-server.path}";
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = 30;
|
||||
User = "root";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [
|
||||
"network.target"
|
||||
"sops-nix.service"
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers.obligator = {
|
||||
image = "anderspitman/obligator:latest";
|
||||
volumes = [
|
||||
"/var/lib/obligator:/data"
|
||||
"/var/lib/obligator:/api"
|
||||
];
|
||||
ports = [ "8081:1616" ];
|
||||
cmd = [
|
||||
"-storage-dir"
|
||||
"/data"
|
||||
"-api-socket-dir"
|
||||
"/api"
|
||||
"-root-uri"
|
||||
"https://oidc.imxyy.top"
|
||||
"-port"
|
||||
"1616"
|
||||
];
|
||||
};
|
||||
services.caddy.virtualHosts."oidc.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8081 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services.ddns-go =
|
||||
let
|
||||
version = "6.6.7";
|
||||
ddns-go = pkgs.buildGoModule {
|
||||
inherit version;
|
||||
pname = "ddns-go";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "jeessy2";
|
||||
repo = "ddns-go";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-Ejoe6e9GFhHxQ9oIBDgDRQW9Xx1XZK+qSAXiRXLdn+c=";
|
||||
};
|
||||
meta.mainProgram = "ddns-go";
|
||||
vendorHash = "sha256-XZii7gV3DmTunYyGYzt5xXhv/VpTPIoYKbW4LnmlAgs=";
|
||||
doCheck = false;
|
||||
};
|
||||
in
|
||||
{
|
||||
description = "Go Dynamic DNS";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${lib.getExe ddns-go} -l :9876 -f 10 -cacheTimes 180 -c /var/lib/ddns-go/config.yaml";
|
||||
Restart = "always";
|
||||
RestartSec = 120;
|
||||
};
|
||||
path = [
|
||||
pkgs.bash
|
||||
];
|
||||
};
|
||||
|
||||
services.dnsmasq =
|
||||
let
|
||||
subDomains = [
|
||||
"home"
|
||||
"nextcloud"
|
||||
"mail"
|
||||
"git"
|
||||
"vault"
|
||||
"coder"
|
||||
"matrix"
|
||||
"note"
|
||||
"oidc"
|
||||
"mc"
|
||||
"music"
|
||||
"sy"
|
||||
"immich"
|
||||
];
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
resolveLocalQueries = false;
|
||||
settings = {
|
||||
no-resolv = true;
|
||||
server = [ "192.168.3.1" ];
|
||||
address = map (sub: "/${sub}.imxyy.top/192.168.3.2") subDomains ++ [
|
||||
"/imxyy-nix-server/192.168.3.2"
|
||||
"/imxyy-cloudwin/192.168.3.4"
|
||||
"/printer.home/192.168.3.53"
|
||||
];
|
||||
cache-size = 0;
|
||||
log-queries = "extra";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -17,9 +17,9 @@ in
|
||||
|
||||
services.nextcloud = {
|
||||
enable = true;
|
||||
package = pkgs.nextcloud31;
|
||||
package = pkgs.nextcloud32;
|
||||
extraApps = {
|
||||
inherit (pkgs.nextcloud31.packages.apps)
|
||||
inherit (pkgs.nextcloud32.packages.apps)
|
||||
bookmarks
|
||||
previewgenerator
|
||||
spreed
|
||||
@@ -31,20 +31,26 @@ in
|
||||
hostName = nextcloud;
|
||||
home = "/mnt/nas/nextcloud";
|
||||
https = true;
|
||||
nginx.recommendedHttpHeaders = true;
|
||||
caching.redis = true;
|
||||
configureRedis = true;
|
||||
database.createLocally = true;
|
||||
notify_push.enable = true;
|
||||
config = {
|
||||
dbtype = "pgsql";
|
||||
adminpassFile = toString (pkgs.writeText "nextcloud-pass" "admin12345!");
|
||||
adminuser = "admin";
|
||||
};
|
||||
settings.trusted_domains = [
|
||||
hostname
|
||||
"192.168.3.2"
|
||||
"10.0.0.1"
|
||||
];
|
||||
settings = {
|
||||
trusted_domains = [
|
||||
hostname
|
||||
"192.168.3.2"
|
||||
"10.0.0.1"
|
||||
];
|
||||
trusted_proxies = [
|
||||
"127.0.0.1"
|
||||
"192.168.3.0/24"
|
||||
];
|
||||
};
|
||||
phpExtraExtensions =
|
||||
all: with all; [
|
||||
pdlib
|
||||
@@ -53,7 +59,7 @@ in
|
||||
phpOptions = {
|
||||
"opcache.enable" = 1;
|
||||
"opcache.enable_cli" = 1;
|
||||
"opcache.interned_strings_buffer" = 8;
|
||||
"opcache.interned_strings_buffer" = 23;
|
||||
"opcache.max_accelerated_files" = 10000;
|
||||
"opcache.memory_consumption" = 128;
|
||||
"opcache.save_comments" = 1;
|
||||
@@ -94,9 +100,12 @@ in
|
||||
*/
|
||||
services.caddy.virtualHosts."nextcloud.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8084 {
|
||||
header_up X-Real-IP {remote_host}
|
||||
reverse_proxy http://127.0.0.1:8084 {
|
||||
trusted_proxies 192.168.3.0/24
|
||||
}
|
||||
|
||||
redir /.well-known/carddav /remote.php/dav/ 301
|
||||
redir /.well-known/caldav /remote.php/dav/ 301
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -6,21 +6,6 @@
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot.loader = {
|
||||
efi.canTouchEfiVariables = true;
|
||||
systemd-boot.enable = true;
|
||||
grub.enable = false;
|
||||
timeout = 0;
|
||||
};
|
||||
|
||||
systemd.services.nix-daemon = {
|
||||
environment.TMPDIR = "/var/cache/nix";
|
||||
serviceConfig.CacheDirectory = "nix";
|
||||
};
|
||||
environment.variables.NIX_REMOTE = "daemon";
|
||||
|
||||
my.audio.enable = false;
|
||||
|
||||
sops.secrets.imxyy-nix-server-hashed-password = {
|
||||
sopsFile = secrets.imxyy-nix-server-hashed-password;
|
||||
format = "binary";
|
||||
@@ -4,27 +4,12 @@
|
||||
...
|
||||
}:
|
||||
{
|
||||
sops.secrets = {
|
||||
flatnote-env = {
|
||||
sopsFile = secrets.flatnote;
|
||||
format = "dotenv";
|
||||
};
|
||||
siyuan-env = {
|
||||
sopsFile = secrets.siyuan;
|
||||
format = "dotenv";
|
||||
};
|
||||
sops.secrets.siyuan-env = {
|
||||
sopsFile = secrets.siyuan;
|
||||
restartUnits = [ "siyuan.service" ];
|
||||
format = "dotenv";
|
||||
};
|
||||
virtualisation.oci-containers.containers = {
|
||||
flatnotes = {
|
||||
image = "dullage/flatnotes:latest";
|
||||
volumes = [
|
||||
"/mnt/nas/flatnotes/data:/data"
|
||||
];
|
||||
environmentFiles = [
|
||||
"${config.sops.secrets.flatnote-env.path}"
|
||||
];
|
||||
ports = [ "8093:8080" ];
|
||||
};
|
||||
siyuan = {
|
||||
image = "apkdv/siyuan-unlock:v3.1.30";
|
||||
volumes = [
|
||||
@@ -52,11 +37,6 @@
|
||||
};
|
||||
};
|
||||
services.caddy.virtualHosts = {
|
||||
"note.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8093
|
||||
'';
|
||||
};
|
||||
"sy.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8095
|
||||
74
hosts/imxyy-nix-server/plant.nix
Normal file
74
hosts/imxyy-nix-server/plant.nix
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
inputs,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
app = pkgs.buildNpmPackage (finalAttrs: {
|
||||
pname = "HF-plant";
|
||||
version = "unstable-2025-09-21";
|
||||
|
||||
src = inputs.plant;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
npm run build
|
||||
npm run build:proxy
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir $out
|
||||
mv dist $out
|
||||
cp .env proxy-server-bundled.js $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
npmDepsHash = "sha256-ret4BtjrEt8L1nlvJmFiejAKmbz89Z7NSiKs+qlB51w=";
|
||||
});
|
||||
in
|
||||
{
|
||||
systemd.services.HF-plant-proxy = {
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${lib.getExe pkgs.bash} -c 'source ${app}/.env; export FEISHU_APP_ID FEISHU_APP_SECRET AMAP_JSCODE; ${lib.getExe pkgs.nodejs} ${app}/proxy-server-bundled.js'";
|
||||
Restart = "always";
|
||||
RestartSec = 120;
|
||||
};
|
||||
};
|
||||
services.caddy.virtualHosts."plant.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
handle /api/* {
|
||||
reverse_proxy localhost:3001
|
||||
}
|
||||
|
||||
handle /* {
|
||||
root * ${app}/dist
|
||||
try_files {path} /index.html
|
||||
file_server
|
||||
}
|
||||
'';
|
||||
};
|
||||
services.frp.instances."".settings.proxies = [
|
||||
{
|
||||
name = "plant-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "plant.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "plant-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "plant.imxyy.top" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
55
hosts/imxyy-nix-server/rss.nix
Normal file
55
hosts/imxyy-nix-server/rss.nix
Normal file
@@ -0,0 +1,55 @@
|
||||
{ config, secrets, ... }:
|
||||
let
|
||||
redisUrl = config.services.redis.servers.rsshub.unixSocket;
|
||||
in
|
||||
{
|
||||
sops.secrets.rsshub-env = {
|
||||
sopsFile = secrets.rsshub;
|
||||
restartUnits = [ "podman-rsshub.service" ];
|
||||
format = "dotenv";
|
||||
};
|
||||
users.users.rsshub = {
|
||||
home = "/var/empty";
|
||||
group = "rsshub";
|
||||
isSystemUser = true;
|
||||
};
|
||||
users.groups.rsshub.members = [ "rsshub" ];
|
||||
services.redis.servers.rsshub = {
|
||||
enable = true;
|
||||
user = "rsshub";
|
||||
};
|
||||
virtualisation.oci-containers.containers.rsshub = {
|
||||
image = "diygod/rsshub";
|
||||
volumes = [
|
||||
"${redisUrl}:${redisUrl}"
|
||||
];
|
||||
ports = [ "8100:1200" ];
|
||||
networks = [ "podman" ];
|
||||
environment = {
|
||||
CACHE_TYPE = "redis";
|
||||
REDIS_URL = "${redisUrl}";
|
||||
};
|
||||
environmentFiles = [ config.sops.secrets.rsshub-env.path ];
|
||||
};
|
||||
services.caddy.virtualHosts."rss.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8100
|
||||
'';
|
||||
};
|
||||
services.frp.instances."".settings.proxies = [
|
||||
{
|
||||
name = "rsshub-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "rss.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "rsshub-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "rss.imxyy.top" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
};
|
||||
share = {
|
||||
path = "/mnt/nas/share";
|
||||
browseable = "yes";
|
||||
browsable = "yes";
|
||||
"read only" = "no";
|
||||
"guest ok" = "no";
|
||||
"create mask" = "0664";
|
||||
49
hosts/imxyy-nix-server/sshwifty.nix
Normal file
49
hosts/imxyy-nix-server/sshwifty.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{ config, secrets, ... }:
|
||||
{
|
||||
sops.secrets.sshwifty = {
|
||||
sopsFile = secrets.sshwifty;
|
||||
format = "binary";
|
||||
};
|
||||
services.sshwifty = {
|
||||
enable = true;
|
||||
sharedKeyFile = config.sops.secrets.sshwifty.path;
|
||||
settings = {
|
||||
Servers = [
|
||||
{
|
||||
ListenInterface = "0.0.0.0";
|
||||
ListenPort = 8101;
|
||||
InitialTimeout = 10;
|
||||
ReadTimeout = 120;
|
||||
WriteTimeout = 120;
|
||||
HeartbeatTimeout = 10;
|
||||
ReadDelay = 10;
|
||||
WriteDelay = 10;
|
||||
TLSCertificateFile = "";
|
||||
TLSCertificateKeyFile = "";
|
||||
ServerMessage = "";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
services.caddy.virtualHosts."ssh.imxyy.top" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy :8101
|
||||
'';
|
||||
};
|
||||
services.frp.instances."".settings.proxies = [
|
||||
{
|
||||
name = "sshwifty-http";
|
||||
type = "http";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 80;
|
||||
customDomains = [ "ssh.imxyy.top" ];
|
||||
}
|
||||
{
|
||||
name = "sshwifty-https";
|
||||
type = "https";
|
||||
localIP = "127.0.0.1";
|
||||
localPort = 443;
|
||||
customDomains = [ "ssh.imxyy.top" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
{
|
||||
sops.secrets.vaultwarden-env = {
|
||||
sopsFile = secrets.vaultwarden;
|
||||
restartUnits = [ "vaultwarden.service" ];
|
||||
format = "dotenv";
|
||||
};
|
||||
services.postgresql.ensureUsers = [
|
||||
19
hosts/imxyy-nix-wsl/home.nix
Normal file
19
hosts/imxyy-nix-wsl/home.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{ lib, username, ... }:
|
||||
{
|
||||
my.hm = {
|
||||
programs.zsh.shellAliases = {
|
||||
localproxy_on = "export http_proxy=http://192.168.128.1:7890 https_proxy=http://192.168.128.1:7890 all_proxy=socks://192.168.128.1:7890";
|
||||
};
|
||||
programs.fish.shellAliases = {
|
||||
localproxy_on = "export http_proxy=http://192.168.128.1:7890 https_proxy=http://192.168.128.1:7890 all_proxy=socks://192.168.128.1:7890";
|
||||
};
|
||||
};
|
||||
my = {
|
||||
sops.sshKeyFile = "/home/${username}/.ssh/id_ed25519";
|
||||
coding.all.enable = true;
|
||||
coding.editor.vscode.enable = lib.mkForce false;
|
||||
cli.misc.enable = true;
|
||||
xdg.enable = true;
|
||||
cli.media.all.enable = true;
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
let
|
||||
@@ -22,7 +21,7 @@ in
|
||||
verbose = false;
|
||||
};
|
||||
|
||||
kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos;
|
||||
kernelPackages = lib.mkForce pkgs.linuxPackages_xanmod_latest;
|
||||
kernelModules = [ "kvm-amd" ];
|
||||
|
||||
tmp.useTmpfs = true;
|
||||
@@ -30,7 +29,6 @@ in
|
||||
"fs.file-max" = 9223372036854775807;
|
||||
};
|
||||
};
|
||||
services.scx.enable = true;
|
||||
|
||||
fileSystems."/" = {
|
||||
device = btrfs;
|
||||
@@ -1,24 +1,26 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
{
|
||||
my.home = {
|
||||
my.hm = {
|
||||
home.packages = with pkgs; [
|
||||
localsend
|
||||
|
||||
wpsoffice-cn
|
||||
wps-office-fonts
|
||||
ttf-wps-fonts
|
||||
evince
|
||||
papers
|
||||
|
||||
anki
|
||||
|
||||
ayugram-desktop
|
||||
signal-desktop
|
||||
signal-desktop-wayland
|
||||
element-desktop
|
||||
qq
|
||||
fractal
|
||||
qq-wayland
|
||||
wechat
|
||||
|
||||
gnome-clocks
|
||||
@@ -28,6 +30,9 @@
|
||||
PATH = "/home/${username}/bin:$PATH";
|
||||
};
|
||||
};
|
||||
programs.fish.interactiveShellInit = ''
|
||||
set -gp PATH $HOME/bin
|
||||
'';
|
||||
|
||||
programs.niri.settings = {
|
||||
environment.STEAM_FORCE_DESKTOPUI_SCALING = "1.25";
|
||||
@@ -58,18 +63,17 @@
|
||||
enable = true;
|
||||
defaultApplications =
|
||||
let
|
||||
browser = [ "zen-beta.desktop" ];
|
||||
editor = [ "codium.desktop" ];
|
||||
imageviewer = [ "org.gnome.Shotwell-Viewer.desktop" ];
|
||||
browser = [ config.my.desktop.browser.default.desktop ];
|
||||
editor = [ "nvim.desktop" ];
|
||||
imageviewer = [ "org.gnome.Loupe.desktop" ];
|
||||
in
|
||||
{
|
||||
"inode/directory" = [ "nemo.desktop" ];
|
||||
"inode/directory" = [ "org.gnome.Nautilus.desktop" ];
|
||||
|
||||
"application/pdf" = [ "org.gnome.Evince.desktop" ];
|
||||
"application/pdf" = [ "org.gnome.Papers.desktop" ];
|
||||
|
||||
"text/*" = editor;
|
||||
"application/json" = editor;
|
||||
"text/html" = editor;
|
||||
"text/xml" = editor;
|
||||
"application/xml" = editor;
|
||||
"application/xhtml+xml" = editor;
|
||||
@@ -82,6 +86,7 @@
|
||||
"application/x-extension-xht" = editor;
|
||||
"application/x-extension-xhtml" = editor;
|
||||
|
||||
"text/html" = browser;
|
||||
"x-scheme-handler/about" = browser;
|
||||
"x-scheme-handler/ftp" = browser;
|
||||
"x-scheme-handler/http" = browser;
|
||||
@@ -116,6 +121,7 @@
|
||||
".local/share/Kingsoft"
|
||||
|
||||
".local/share/AyuGramDesktop"
|
||||
".local/share/fractal"
|
||||
".config/Signal"
|
||||
".config/Element"
|
||||
".config/QQ"
|
||||
@@ -9,6 +9,7 @@
|
||||
"biosdevname=0"
|
||||
"net.ifnames=0"
|
||||
];
|
||||
my.persist.nixosDirs = [ "/etc/NetworkManager/system-connections" ];
|
||||
networking = {
|
||||
networkmanager.enable = true;
|
||||
firewall.enable = false;
|
||||
@@ -54,6 +55,7 @@
|
||||
|
||||
sops.secrets.dae-imxyy-nix-x16 = {
|
||||
sopsFile = secrets.dae-imxyy-nix-x16;
|
||||
restartUnits = [ "dae.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
services.dae = {
|
||||
@@ -63,6 +65,7 @@
|
||||
systemd.services.dae.after = [ "sops-nix.service" ];
|
||||
sops.secrets.mihomo = {
|
||||
sopsFile = secrets.mihomo;
|
||||
restartUnits = [ "mihomo.service" ];
|
||||
format = "yaml";
|
||||
key = "";
|
||||
};
|
||||
@@ -75,6 +78,7 @@
|
||||
|
||||
sops.secrets.et-imxyy-nix-x16 = {
|
||||
sopsFile = secrets.et-imxyy-nix-x16;
|
||||
restartUnits = [ "easytier.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
environment.systemPackages = with pkgs; [
|
||||
67
hosts/imxyy-nix-x16/nixos.nix
Normal file
67
hosts/imxyy-nix-x16/nixos.nix
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
username,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
{
|
||||
boot.kernelParams = [
|
||||
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
|
||||
];
|
||||
|
||||
services.upower.enable = true;
|
||||
services.power-profiles-daemon.enable = true;
|
||||
|
||||
services.keyd = {
|
||||
enable = true;
|
||||
keyboards.default.settings = {
|
||||
main = {
|
||||
capslock = "overload(control, esc)";
|
||||
home = "end";
|
||||
};
|
||||
shift = {
|
||||
home = "home";
|
||||
};
|
||||
control = {
|
||||
delete = "print";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# Forbid root login through SSH.
|
||||
PermitRootLogin = null;
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.rclone
|
||||
];
|
||||
|
||||
sops.secrets.imxyy-nix-rclone = {
|
||||
sopsFile = secrets.imxyy-nix-rclone;
|
||||
format = "binary";
|
||||
};
|
||||
fileSystems = {
|
||||
"/home/${username}/Nextcloud" = {
|
||||
device = "Nextcloud:";
|
||||
fsType = "rclone";
|
||||
options = [
|
||||
"nodev"
|
||||
"nofail"
|
||||
"allow_other"
|
||||
"args2env"
|
||||
"config=${config.sops.secrets.imxyy-nix-rclone.path}"
|
||||
"uid=1000"
|
||||
"gid=100"
|
||||
"rw"
|
||||
"no-check-certificate"
|
||||
"vfs-cache-mode=full"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -23,7 +23,7 @@ in
|
||||
verbose = false;
|
||||
};
|
||||
|
||||
kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos;
|
||||
kernelPackages = lib.mkForce pkgs.linuxPackages_xanmod_latest;
|
||||
kernelModules = [ "kvm-amd" ];
|
||||
|
||||
tmp.useTmpfs = true;
|
||||
@@ -36,7 +36,6 @@ in
|
||||
"resume_offset=6444127"
|
||||
];
|
||||
};
|
||||
services.scx.enable = true;
|
||||
|
||||
fileSystems."/" = {
|
||||
device = btrfs;
|
||||
@@ -1,49 +1,57 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
{
|
||||
my.home = {
|
||||
my.hm = {
|
||||
home.packages = with pkgs; [
|
||||
localsend
|
||||
|
||||
wpsoffice-cn
|
||||
wps-office-fonts
|
||||
ttf-wps-fonts
|
||||
evince
|
||||
papers
|
||||
|
||||
anki
|
||||
|
||||
ayugram-desktop
|
||||
signal-desktop
|
||||
signal-desktop-wayland
|
||||
element-desktop
|
||||
qq
|
||||
fractal
|
||||
qq-wayland
|
||||
wechat
|
||||
|
||||
gnome-clocks
|
||||
];
|
||||
programs.zsh = {
|
||||
shellAliases = {
|
||||
cageterm = "cage -m DP-2 -s -- alacritty -o font.size=20";
|
||||
cagefoot = "cage -m DP-2 -s -- foot --font=monospace:size=20";
|
||||
cagekitty = "cage -m DP-2 -s -- kitty -o font_size=20";
|
||||
cageterm = "cage -m DP-1 -s -- alacritty -o font.size=20";
|
||||
cagefoot = "cage -m DP-1 -s -- foot --font=monospace:size=20";
|
||||
cagekitty = "cage -m DP-1 -s -- kitty -o font_size=20";
|
||||
};
|
||||
sessionVariables = {
|
||||
no_proxy = "192.168.3.0/24";
|
||||
PATH = "/home/${username}/bin:$PATH";
|
||||
};
|
||||
profileExtra = ''
|
||||
if [ `tty` = "/dev/tty6" ]; then
|
||||
clear
|
||||
fi
|
||||
};
|
||||
programs.fish = {
|
||||
shellAliases = {
|
||||
cageterm = "cage -m DP-1 -s -- alacritty -o font.size=20";
|
||||
cagefoot = "cage -m DP-1 -s -- foot --font=monospace:size=20";
|
||||
cagekitty = "cage -m DP-1 -s -- kitty -o font_size=20";
|
||||
};
|
||||
interactiveShellInit = ''
|
||||
set -g no_proxy "192.168.3.0/24"
|
||||
set -gp PATH $HOME/bin
|
||||
'';
|
||||
};
|
||||
|
||||
programs.niri.settings = {
|
||||
environment.STEAM_FORCE_DESKTOPUI_SCALING = "1.25";
|
||||
outputs = {
|
||||
DP-2 = {
|
||||
DP-1 = {
|
||||
enable = true;
|
||||
mode = {
|
||||
width = 2560;
|
||||
@@ -56,7 +64,7 @@
|
||||
y = 0;
|
||||
};
|
||||
};
|
||||
DP-3 = {
|
||||
DP-2 = {
|
||||
enable = true;
|
||||
mode = {
|
||||
width = 2560;
|
||||
@@ -87,18 +95,17 @@
|
||||
enable = true;
|
||||
defaultApplications =
|
||||
let
|
||||
browser = [ "zen-beta.desktop" ];
|
||||
editor = [ "codium.desktop" ];
|
||||
imageviewer = [ "org.gnome.Shotwell-Viewer.desktop" ];
|
||||
browser = [ config.my.desktop.browser.default.desktop ];
|
||||
editor = [ "nvim.desktop" ];
|
||||
imageviewer = [ "org.gnome.Loupe.desktop" ];
|
||||
in
|
||||
{
|
||||
"inode/directory" = [ "nemo.desktop" ];
|
||||
"inode/directory" = [ "org.gnome.Nautilus.desktop" ];
|
||||
|
||||
"application/pdf" = [ "org.gnome.Evince.desktop" ];
|
||||
"application/pdf" = [ "org.gnome.Papers.desktop" ];
|
||||
|
||||
"text/*" = editor;
|
||||
"application/json" = editor;
|
||||
"text/html" = editor;
|
||||
"text/xml" = editor;
|
||||
"application/xml" = editor;
|
||||
"application/xhtml+xml" = editor;
|
||||
@@ -111,6 +118,7 @@
|
||||
"application/x-extension-xht" = editor;
|
||||
"application/x-extension-xhtml" = editor;
|
||||
|
||||
"text/html" = browser;
|
||||
"x-scheme-handler/about" = browser;
|
||||
"x-scheme-handler/ftp" = browser;
|
||||
"x-scheme-handler/http" = browser;
|
||||
@@ -143,6 +151,7 @@
|
||||
".local/share/Kingsoft"
|
||||
|
||||
".local/share/AyuGramDesktop"
|
||||
".local/share/fractal"
|
||||
".config/Signal"
|
||||
".config/Element"
|
||||
".config/QQ"
|
||||
@@ -154,6 +163,11 @@
|
||||
".config/sunshine"
|
||||
|
||||
".gemini"
|
||||
".claude"
|
||||
".claude-code-router"
|
||||
];
|
||||
homeFiles = [
|
||||
".claude.json"
|
||||
];
|
||||
};
|
||||
};
|
||||
@@ -69,6 +69,7 @@
|
||||
chain input {
|
||||
type filter hook input priority 0; policy drop;
|
||||
iif lo accept
|
||||
iifname waydroid0 accept
|
||||
ct state invalid drop
|
||||
ct state established,related accept
|
||||
|
||||
@@ -78,6 +79,9 @@
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy drop;
|
||||
|
||||
iifname waydroid0 accept
|
||||
oifname waydroid0 accept
|
||||
}
|
||||
}
|
||||
'';
|
||||
@@ -86,6 +90,7 @@
|
||||
|
||||
sops.secrets.dae-imxyy-nix = {
|
||||
sopsFile = secrets.dae-imxyy-nix;
|
||||
restartUnits = [ "dae.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
services.dae = {
|
||||
@@ -95,6 +100,7 @@
|
||||
systemd.services.dae.after = [ "sops-nix.service" ];
|
||||
sops.secrets.mihomo = {
|
||||
sopsFile = secrets.mihomo;
|
||||
restartUnits = [ "mihomo.service" ];
|
||||
format = "yaml";
|
||||
key = "";
|
||||
};
|
||||
@@ -107,6 +113,7 @@
|
||||
|
||||
sops.secrets.et-imxyy-nix = {
|
||||
sopsFile = secrets.et-imxyy-nix;
|
||||
restartUnits = [ "easytier.service" ];
|
||||
format = "binary";
|
||||
};
|
||||
environment.systemPackages = [ pkgs.easytier ];
|
||||
130
hosts/imxyy-nix/nixos.nix
Normal file
130
hosts/imxyy-nix/nixos.nix
Normal file
@@ -0,0 +1,130 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
username,
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
let
|
||||
btreset = pkgs.writeShellScriptBin "btreset" ''
|
||||
LOCKFILE="/tmp/.btreseted"
|
||||
SYM="BT"
|
||||
|
||||
if [ -f "$LOCKFILE" ] && [ "$1" != "-f" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${lib.getExe' pkgs.usbutils "lsusb"} | grep "$SYM" | while read -r line; do
|
||||
bus=$(echo "$line" | awk '{print $2}')
|
||||
dev=$(echo "$line" | awk '{print $4}' | tr -d ':')
|
||||
${lib.getExe' pkgs.usbutils "usbreset"} "$bus/$dev"
|
||||
|
||||
touch "$LOCKFILE"
|
||||
done
|
||||
'';
|
||||
in
|
||||
{
|
||||
systemd.services.btreset = {
|
||||
script = lib.getExe btreset;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
|
||||
boot.kernelParams = [
|
||||
"usbcore.autosuspend=-1" # Avoid usb autosuspend (for usb bluetooth adapter)
|
||||
"fsck.mode=skip"
|
||||
];
|
||||
|
||||
services.keyd = {
|
||||
enable = true;
|
||||
keyboards = {
|
||||
default.settings = {
|
||||
main = {
|
||||
capslock = "overload(control, esc)";
|
||||
home = "end";
|
||||
};
|
||||
shift = {
|
||||
home = "home";
|
||||
};
|
||||
control = {
|
||||
delete = "print";
|
||||
};
|
||||
};
|
||||
kone-pro-owl-eye = {
|
||||
ids = [ "1e7d:2dcd" ];
|
||||
settings.main.mouse2 = "rightmouse";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs.wireshark.enable = true;
|
||||
programs.wireshark.package = pkgs.wireshark;
|
||||
users.users.${username}.extraGroups = [ "wireshark" ];
|
||||
|
||||
virtualisation.waydroid.enable = true;
|
||||
my.persist.homeDirs = [ ".local/share/waydroid" ];
|
||||
|
||||
services.sunshine = {
|
||||
enable = true;
|
||||
autoStart = true;
|
||||
capSysAdmin = true;
|
||||
applications.apps = [
|
||||
{
|
||||
name = "Desktop";
|
||||
image-path = "desktop.png";
|
||||
}
|
||||
];
|
||||
};
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# Forbid root login through SSH.
|
||||
PermitRootLogin = null;
|
||||
PasswordAuthentication = true;
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.rclone
|
||||
btreset
|
||||
];
|
||||
|
||||
sops.secrets.imxyy-nix-rclone = {
|
||||
sopsFile = secrets.imxyy-nix-rclone;
|
||||
format = "binary";
|
||||
};
|
||||
fileSystems = {
|
||||
"/home/${username}/Nextcloud" = {
|
||||
device = "Nextcloud:";
|
||||
fsType = "rclone";
|
||||
options = [
|
||||
"nodev"
|
||||
"nofail"
|
||||
"allow_other"
|
||||
"args2env"
|
||||
"config=${config.sops.secrets.imxyy-nix-rclone.path}"
|
||||
"uid=1000"
|
||||
"gid=100"
|
||||
"rw"
|
||||
"no-check-certificate"
|
||||
"vfs-cache-mode=full"
|
||||
];
|
||||
};
|
||||
"/home/${username}/NAS" = {
|
||||
device = "//192.168.3.2/share";
|
||||
fsType = "cifs";
|
||||
options = [
|
||||
"username=nas"
|
||||
"password=nasshare"
|
||||
"x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"
|
||||
"nodev"
|
||||
"nofail"
|
||||
"uid=1000"
|
||||
"gid=100"
|
||||
"vers=3"
|
||||
"rw"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
36
hosts/imxyy-nix/podman.nix
Normal file
36
hosts/imxyy-nix/podman.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
{
|
||||
virtualisation.podman = {
|
||||
enable = true;
|
||||
dockerCompat = true;
|
||||
dockerSocket.enable = true;
|
||||
};
|
||||
users.users.${username}.extraGroups = [ "podman" ];
|
||||
environment.systemPackages = [ pkgs.distrobox ];
|
||||
my.hm.programs.distrobox = {
|
||||
enable = true;
|
||||
settings = {
|
||||
container_image_default = "docker.io/archlinux:latest";
|
||||
};
|
||||
containers = {
|
||||
archlinux = {
|
||||
image = "archlinux:latest";
|
||||
additional_packages = "nvim";
|
||||
};
|
||||
};
|
||||
};
|
||||
my.hm.programs.zsh.initContent = lib.mkBefore ''
|
||||
if [ -n "''${CONTAINER_ID+1}" ]; then
|
||||
export ZSH_DISABLE_COMPFIX=true
|
||||
fi
|
||||
'';
|
||||
my.persist.homeDirs = [
|
||||
".config/containers"
|
||||
".local/share/containers"
|
||||
];
|
||||
}
|
||||
111
lib/default.nix
111
lib/default.nix
@@ -1,102 +1,9 @@
|
||||
{ lib }:
|
||||
|
||||
{
|
||||
makeSwitch =
|
||||
{
|
||||
default ? false,
|
||||
config,
|
||||
optionPath,
|
||||
optionName,
|
||||
config',
|
||||
}:
|
||||
let
|
||||
cfg = lib.getAttrFromPath optionPath config.my;
|
||||
in
|
||||
{
|
||||
options.my = lib.setAttrByPath (optionPath) {
|
||||
enable = (lib.mkEnableOption optionName) // {
|
||||
inherit default;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable config';
|
||||
};
|
||||
|
||||
makeHomePackageConfig =
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
packageName,
|
||||
packagePath,
|
||||
optionPath,
|
||||
extraConfig ? { },
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config optionPath;
|
||||
optionName = packageName;
|
||||
config' = lib.mkMerge [
|
||||
{
|
||||
my.home.home.packages = [ (lib.getAttrFromPath packagePath pkgs) ];
|
||||
}
|
||||
extraConfig
|
||||
];
|
||||
};
|
||||
|
||||
makeHomeProgramConfig =
|
||||
{
|
||||
config,
|
||||
programName,
|
||||
optionPath,
|
||||
extraConfig ? { },
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config optionPath;
|
||||
optionName = programName;
|
||||
|
||||
config' = lib.mkMerge [
|
||||
{
|
||||
my.home.programs = lib.setAttrByPath [ programName "enable" ] true;
|
||||
}
|
||||
extraConfig
|
||||
];
|
||||
};
|
||||
|
||||
makeNixosPackageConfig =
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
packageName,
|
||||
packagePath,
|
||||
optionPath,
|
||||
extraConfig ? { },
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config optionPath;
|
||||
optionName = packageName;
|
||||
config' = lib.mkMerge [
|
||||
{
|
||||
environment.systemPackages = [ (lib.getAttrFromPath packagePath pkgs) ];
|
||||
}
|
||||
extraConfig
|
||||
];
|
||||
};
|
||||
|
||||
makeNixosProgramConfig =
|
||||
{
|
||||
config,
|
||||
programName,
|
||||
optionPath,
|
||||
extraConfig ? { },
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config optionPath;
|
||||
optionName = programName;
|
||||
|
||||
config' = lib.mkMerge [
|
||||
{
|
||||
programs = lib.setAttrByPath [ programName "enable" ] true;
|
||||
}
|
||||
extraConfig
|
||||
];
|
||||
};
|
||||
}
|
||||
{ lib, inputs }:
|
||||
lib.extend (
|
||||
self: super: {
|
||||
inherit (inputs.home-manager.lib) hm;
|
||||
umport = import ./umport.nix { lib = self; };
|
||||
haumea = inputs.haumea.lib;
|
||||
infuse = (import inputs.infuse { inherit lib; }).v1.infuse;
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# Just a convenience function that returns the given Nixpkgs standard
|
||||
# library extended with the imxyy library.
|
||||
|
||||
stdlib:
|
||||
|
||||
let
|
||||
mkMyLib = import ./.;
|
||||
in
|
||||
stdlib.extend (
|
||||
self: super: {
|
||||
my = mkMyLib { lib = self; };
|
||||
umport = import ./umport.nix { lib = self; };
|
||||
}
|
||||
)
|
||||
@@ -13,6 +13,7 @@ let
|
||||
paths ? [ ],
|
||||
include ? [ ],
|
||||
exclude ? [ ],
|
||||
extraExcludePredicate ? _: true,
|
||||
recursive ? true,
|
||||
}:
|
||||
with lib;
|
||||
@@ -22,26 +23,22 @@ let
|
||||
excludedDirs = filter (path: pathIsDirectory path) exclude;
|
||||
isExcluded =
|
||||
path:
|
||||
if elem path excludedFiles then
|
||||
true
|
||||
else
|
||||
(filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ];
|
||||
(elem path excludedFiles)
|
||||
|| ((filter (excludedDir: lib.path.hasPrefix excludedDir path) excludedDirs) != [ ])
|
||||
|| extraExcludePredicate path;
|
||||
in
|
||||
unique (
|
||||
(filter
|
||||
(file: pathIsRegularFile file && hasSuffix ".nix" (builtins.toString file) && !isExcluded file)
|
||||
(
|
||||
concatMap (
|
||||
_path:
|
||||
if recursive then
|
||||
toList _path
|
||||
else
|
||||
mapAttrsToList (
|
||||
name: type: _path + (if type == "directory" then "/${name}/default.nix" else "/${name}")
|
||||
) (builtins.readDir _path)
|
||||
) (unique (if path == null then paths else [ path ] ++ paths))
|
||||
)
|
||||
)
|
||||
(filter (file: pathIsRegularFile file && hasSuffix ".nix" (toString file) && !isExcluded file) (
|
||||
concatMap (
|
||||
path:
|
||||
if recursive then
|
||||
toList path
|
||||
else
|
||||
mapAttrsToList (
|
||||
name: type: path + (if type == "directory" then "/${name}/default.nix" else "/${name}")
|
||||
) (builtins.readDir path)
|
||||
) (unique (if path == null then paths else [ path ] ++ paths))
|
||||
))
|
||||
++ (if recursive then concatMap (path: toList path) (unique include) else unique include)
|
||||
);
|
||||
in
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
username,
|
||||
...
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
default = true;
|
||||
optionName = "default audio settings";
|
||||
optionPath = [ "audio" ];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.audio;
|
||||
in
|
||||
{
|
||||
options.my.audio = {
|
||||
enable = lib.mkEnableOption "default audio settings";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
security.rtkit.enable = true;
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
@@ -21,6 +24,6 @@ lib.my.makeSwitch {
|
||||
};
|
||||
users.extraUsers.${username}.extraGroups = [ "audio" ];
|
||||
my.persist.homeDirs = [ ".local/state/wireplumber" ];
|
||||
my.home.home.packages = [ pkgs.pwvucontrol ];
|
||||
my.hm.home.packages = [ pkgs.pwvucontrol ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
default = true;
|
||||
optionName = "default bluetooth settings";
|
||||
optionPath = [ "bluetooth" ];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.bluetooth;
|
||||
in
|
||||
{
|
||||
options.my.bluetooth = {
|
||||
enable = lib.mkEnableOption "default bluetooth settings";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.bluetooth = {
|
||||
enable = true;
|
||||
powerOnBoot = true;
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all command line tools";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.all;
|
||||
in
|
||||
{
|
||||
options.my.cli.all = {
|
||||
enable = lib.mkEnableOption "all command line tools";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.cli = {
|
||||
media.all.enable = true;
|
||||
misc.enable = true;
|
||||
monitor.all.enable = true;
|
||||
shell.all.enable = true;
|
||||
vcs.all.enable = true;
|
||||
|
||||
shpool.enable = true;
|
||||
tmux.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all command line media tools";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"media"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.media.all;
|
||||
in
|
||||
{
|
||||
options.my.cli.media.all = {
|
||||
enable = lib.mkEnableOption "all command line media tools";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.cli.media = {
|
||||
go-musicfox.enable = true;
|
||||
mpd.enable = true;
|
||||
ffmpeg.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
lib.my.makeHomePackageConfig {
|
||||
inherit config pkgs;
|
||||
packageName = "ffmpeg";
|
||||
packagePath = [ "ffmpeg" ];
|
||||
optionPath = [
|
||||
"cli"
|
||||
"media"
|
||||
"ffmpeg"
|
||||
];
|
||||
let
|
||||
cfg = config.my.cli.media.ffmpeg;
|
||||
in
|
||||
{
|
||||
options.my.cli.media.ffmpeg = {
|
||||
enable = lib.mkEnableOption "ffmpeg";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm.home.packages = [ pkgs.ffmpeg ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,35 +5,34 @@
|
||||
secrets,
|
||||
...
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "go-musicfox";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"media"
|
||||
"go-musicfox"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.media.go-musicfox;
|
||||
in
|
||||
{
|
||||
options.my.cli.media.go-musicfox = {
|
||||
enable = lib.mkEnableOption "go-musicfox";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my = {
|
||||
home = {
|
||||
home.packages = with pkgs; [
|
||||
playerctl
|
||||
go-musicfox
|
||||
hm = {
|
||||
home.packages = [
|
||||
pkgs.go-musicfox
|
||||
];
|
||||
sops.secrets.go-musicfox = {
|
||||
sopsFile = secrets."go-musicfox.ini";
|
||||
sopsFile = secrets.go-musicfox;
|
||||
format = "binary";
|
||||
path = "${config.my.home.xdg.configHome}/go-musicfox/go-musicfox.ini";
|
||||
path = "${config.my.hm.xdg.configHome}/go-musicfox/config.toml";
|
||||
};
|
||||
};
|
||||
|
||||
cli.media.mpd.enable = true;
|
||||
desktop.media.mpv.enable = lib.mkForce true;
|
||||
|
||||
persist.homeDirs = [
|
||||
".config/go-musicfox/db"
|
||||
".local/share/go-musicfox/db"
|
||||
];
|
||||
persist.homeFiles = [
|
||||
".config/go-musicfox/cookie"
|
||||
".local/share/go-musicfox/cookie"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "mpd";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"media"
|
||||
"mpd"
|
||||
];
|
||||
config' = {
|
||||
my.home = {
|
||||
home.packages = with pkgs.stable; [
|
||||
mpd
|
||||
mpc-cli
|
||||
];
|
||||
services.mpris-proxy.enable = true;
|
||||
xdg.configFile."mpd/mpd.conf".source = ./mpd.conf;
|
||||
};
|
||||
my.persist.homeFiles = [
|
||||
".config/mpd/mpd.db"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
bind_to_address "127.0.0.1"
|
||||
port "6600"
|
||||
music_directory "/home/imxyy/Music/go-musicfox/.cache"
|
||||
pid_file "/home/imxyy/.config/mpd/mpd.pid"
|
||||
db_file "/home/imxyy/.config/mpd/mpd.db"
|
||||
|
||||
input {
|
||||
plugin "file"
|
||||
enabled "yes"
|
||||
}
|
||||
|
||||
input {
|
||||
plugin "curl"
|
||||
enabled "yes"
|
||||
}
|
||||
|
||||
decoder {
|
||||
plugin "ffmpeg"
|
||||
enabled "yes"
|
||||
}
|
||||
|
||||
audio_output {
|
||||
type "pipewire"
|
||||
name "pipewire"
|
||||
}
|
||||
@@ -2,24 +2,24 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
username,
|
||||
userfullname,
|
||||
useremail,
|
||||
...
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
default = true;
|
||||
optionName = "misc command line tools";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"misc"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.misc;
|
||||
in
|
||||
{
|
||||
options.my.cli.misc = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Enable misc command line tools";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
vim
|
||||
wget
|
||||
git
|
||||
|
||||
file
|
||||
gnused
|
||||
@@ -30,10 +30,14 @@ lib.my.makeSwitch {
|
||||
xz
|
||||
p7zip
|
||||
unrar-free
|
||||
ouch
|
||||
|
||||
pciutils
|
||||
usbutils
|
||||
|
||||
dust
|
||||
dysk
|
||||
|
||||
lsof
|
||||
|
||||
nmap
|
||||
@@ -42,41 +46,39 @@ lib.my.makeSwitch {
|
||||
dnsutils
|
||||
|
||||
killall
|
||||
|
||||
comma
|
||||
];
|
||||
|
||||
programs.dconf.enable = true;
|
||||
|
||||
my.home = {
|
||||
home.packages = with pkgs; [
|
||||
lsd
|
||||
fd
|
||||
neofetch
|
||||
fzf
|
||||
bat
|
||||
ripgrep
|
||||
|
||||
aria2
|
||||
socat
|
||||
];
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
extraConfig = "set-option -g mouse on";
|
||||
plugins = [
|
||||
(pkgs.tmuxPlugins.mkTmuxPlugin {
|
||||
pluginName = "tokyo-night-tmux";
|
||||
rtpFilePath = "tokyo-night.tmux";
|
||||
version = "legacy";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "janoamaral";
|
||||
repo = "tokyo-night-tmux";
|
||||
rev = "16469dfad86846138f594ceec780db27039c06cd";
|
||||
hash = "sha256-EKCgYan0WayXnkSb2fDJxookdBLW0XBKi2hf/YISwJE=";
|
||||
};
|
||||
})
|
||||
];
|
||||
my.persist.homeDirs = [
|
||||
".local/share/zoxide"
|
||||
".config/television/cable"
|
||||
];
|
||||
my.hm = {
|
||||
programs.fish.shellAliases = {
|
||||
x = "ouch d";
|
||||
};
|
||||
programs.zsh.shellAliases = {
|
||||
x = "ouch d";
|
||||
};
|
||||
|
||||
home.packages = with pkgs; [
|
||||
# keep-sorted start
|
||||
aria2
|
||||
bat
|
||||
comma
|
||||
fastfetch
|
||||
fd
|
||||
fzf
|
||||
jq
|
||||
keep-sorted
|
||||
lsd
|
||||
neofetch
|
||||
ripgrep
|
||||
socat
|
||||
typos
|
||||
# keep-sorted end
|
||||
];
|
||||
programs.tealdeer = {
|
||||
enable = true;
|
||||
enableAutoUpdates = true;
|
||||
@@ -85,7 +87,122 @@ lib.my.makeSwitch {
|
||||
programs.television = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
enableFishIntegration = true;
|
||||
};
|
||||
programs.zoxide = {
|
||||
enable = true;
|
||||
enableZshIntegration = true;
|
||||
enableFishIntegration = true;
|
||||
};
|
||||
xdg.configFile."fastfetch/config.jsonc".text = ''
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"display": {
|
||||
"separator": " "
|
||||
},
|
||||
"modules": [
|
||||
// Title
|
||||
{
|
||||
"type": "title",
|
||||
"format": "{user-name-colored}{#}@{host-name-colored}"
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "---------------"
|
||||
},
|
||||
// System Information
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "{#}System Information"
|
||||
},
|
||||
{
|
||||
"type": "os",
|
||||
"key": "{#keys} OS"
|
||||
},
|
||||
{
|
||||
"type": "kernel",
|
||||
"key": "{#keys} Kernel"
|
||||
},
|
||||
{
|
||||
"type": "uptime",
|
||||
"key": "{#keys} Uptime"
|
||||
},
|
||||
{
|
||||
"type": "packages",
|
||||
"key": "{#keys} Packages",
|
||||
"format": "{all}"
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": ""
|
||||
},
|
||||
// Desktop Environment
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "{#}Desktop Environment"
|
||||
},
|
||||
{
|
||||
"type": "de",
|
||||
"key": "{#keys} DE"
|
||||
},
|
||||
{
|
||||
"type": "wm",
|
||||
"key": "{#keys} WM"
|
||||
},
|
||||
{
|
||||
"type": "wmtheme",
|
||||
"key": "{#keys} Theme"
|
||||
},
|
||||
{
|
||||
"type": "display",
|
||||
"key": "{#keys} Resolution"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"key": "{#keys} Shell"
|
||||
},
|
||||
{
|
||||
"type": "terminalfont",
|
||||
"key": "{#keys} Font"
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": ""
|
||||
},
|
||||
// Hardware Information
|
||||
{
|
||||
"type": "custom",
|
||||
"format": "{#}Hardware Information"
|
||||
},
|
||||
{
|
||||
"type": "cpu",
|
||||
"key": "{#keys} CPU"
|
||||
},
|
||||
{
|
||||
"type": "gpu",
|
||||
"key": "{#keys} GPU"
|
||||
},
|
||||
{
|
||||
"type": "memory",
|
||||
"key": "{#keys} Memory"
|
||||
},
|
||||
{
|
||||
"type": "disk",
|
||||
"key": "{#keys} Disk (/)",
|
||||
"folders": "/"
|
||||
},
|
||||
{
|
||||
"type": "custom",
|
||||
"format": ""
|
||||
},
|
||||
// Colors
|
||||
{
|
||||
"type": "colors",
|
||||
"symbol": "circle"
|
||||
},
|
||||
]
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all command line monitor tools";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"monitor"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.monitor.all;
|
||||
in
|
||||
{
|
||||
options.my.cli.monitor.all = {
|
||||
enable = lib.mkEnableOption "all command line monitor tools";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.cli.monitor = {
|
||||
btop.enable = true;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ theme[main_fg]="#D8DEE9"
|
||||
# Title color for boxes
|
||||
theme[title]="#8FBCBB"
|
||||
|
||||
# Higlight color for keyboard shortcuts
|
||||
# Highlight color for keyboard shortcuts
|
||||
theme[hi_fg]="#5E81AC"
|
||||
|
||||
# Background color of selected item in processes box
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
lib.my.makeHomePackageConfig {
|
||||
inherit config pkgs;
|
||||
packageName = "btop";
|
||||
packagePath = [ "btop" ];
|
||||
optionPath = [
|
||||
"cli"
|
||||
"monitor"
|
||||
"btop"
|
||||
];
|
||||
extraConfig = {
|
||||
my.home.xdg.configFile."btop" = {
|
||||
let
|
||||
cfg = config.my.cli.monitor.btop;
|
||||
in
|
||||
{
|
||||
options.my.cli.monitor.btop = {
|
||||
enable = lib.mkEnableOption "btop";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm.home.packages = [ pkgs.btop ];
|
||||
my.hm.xdg.configFile."btop" = {
|
||||
source = ./config;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all shells";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"shell"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.shell.all;
|
||||
in
|
||||
{
|
||||
options.my.cli.shell.all = {
|
||||
enable = lib.mkEnableOption "all shells";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.cli.shell = {
|
||||
zsh.enable = true;
|
||||
fish.enable = true;
|
||||
starship.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
34
modules/cli/shell/defaultShell.nix
Normal file
34
modules/cli/shell/defaultShell.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.my.cli.shell;
|
||||
in
|
||||
{
|
||||
options.my.cli.shell.default = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"fish"
|
||||
"zsh"
|
||||
];
|
||||
default = "fish";
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (cfg.default == "fish") {
|
||||
my.cli.shell.fish.enable = true;
|
||||
users.users.${username} = {
|
||||
shell = config.my.hm.programs.fish.package;
|
||||
# do not need `programs.fish.enable = true` since fish is managed by home-manager
|
||||
ignoreShellProgramCheck = true;
|
||||
};
|
||||
})
|
||||
|
||||
(lib.mkIf (cfg.default == "zsh") {
|
||||
my.cli.shell.zsh.enable = true;
|
||||
users.users.${username}.shell = config.my.hm.programs.zsh.package;
|
||||
})
|
||||
];
|
||||
}
|
||||
96
modules/cli/shell/fish.nix
Normal file
96
modules/cli/shell/fish.nix
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.my.cli.shell.fish;
|
||||
in
|
||||
{
|
||||
options.my.cli.shell.fish = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Enable default fish settings";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.persist = {
|
||||
homeDirs = [
|
||||
".local/share/fish"
|
||||
];
|
||||
};
|
||||
my.hm = {
|
||||
xdg.configFile."fish/themes/tokyonight_storm.theme".source = builtins.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/folke/tokyonight.nvim/refs/tags/v4.14.1/extras/fish_themes/tokyonight_storm.theme";
|
||||
sha256 = "02n1w5x65683c8mlwg1rav06iqm3xk90zq45qmygpm7pzyn8dqh1";
|
||||
};
|
||||
programs.starship.enableFishIntegration = false;
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
shellAliases = {
|
||||
la = "lsd -lah";
|
||||
ls = "lsd";
|
||||
svim = "doasedit";
|
||||
nf = "fastfetch";
|
||||
};
|
||||
interactiveShellInit = lib.mkBefore ''
|
||||
fish_vi_key_bindings
|
||||
fish_config theme choose tokyonight_storm
|
||||
${lib.optionalString config.my.cli.shell.starship.enable "source ${./starship.fish}"}
|
||||
'';
|
||||
functions = {
|
||||
fish_greeting = "";
|
||||
yank_to_clipboard = {
|
||||
description = "Insert latest killring entry into the system clipboard";
|
||||
body = ''printf "%s" "$fish_killring[1]" | fish_clipboard_copy'';
|
||||
};
|
||||
fish_user_key_bindings = ''
|
||||
# make vi mode yanks copy to clipboard
|
||||
bind yy kill-whole-line yank_to_clipboard yank
|
||||
bind Y kill-whole-line yank_to_clipboard yank
|
||||
bind y,\$ kill-line yank_to_clipboard yank
|
||||
bind y,\^ backward-kill-line yank_to_clipboard yank
|
||||
bind y,0 backward-kill-line yank_to_clipboard yank
|
||||
bind y,w kill-word yank_to_clipboard yank
|
||||
bind y,W kill-bigword yank_to_clipboard yank
|
||||
bind y,i,w forward-single-char forward-single-char backward-word kill-word yank_to_clipboard yank
|
||||
bind y,i,W forward-single-char forward-single-char backward-bigword kill-bigword yank_to_clipboard yank
|
||||
bind y,a,w forward-single-char forward-single-char backward-word kill-word yank_to_clipboard yank
|
||||
bind y,a,W forward-single-char forward-single-char backward-bigword kill-bigword yank_to_clipboard yank
|
||||
bind y,e kill-word yank_to_clipboard yank
|
||||
bind y,E kill-bigword yank_to_clipboard yank
|
||||
bind y,b backward-kill-word yank_to_clipboard yank
|
||||
bind y,B backward-kill-bigword yank_to_clipboard yank
|
||||
bind y,g,e backward-kill-word yank_to_clipboard yank
|
||||
bind y,g,E backward-kill-bigword yank_to_clipboard yank
|
||||
bind y,f begin-selection forward-jump kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,t begin-selection forward-jump-till kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,F begin-selection backward-jump kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,T begin-selection backward-jump-till kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,h backward-char begin-selection kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,l begin-selection kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,i,b jump-till-matching-bracket and jump-till-matching-bracket and begin-selection jump-till-matching-bracket kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,a,b jump-to-matching-bracket and jump-to-matching-bracket and begin-selection jump-to-matching-bracket kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,i backward-jump-till and repeat-jump-reverse and begin-selection repeat-jump kill-selection yank_to_clipboard yank end-selection
|
||||
bind y,a backward-jump and repeat-jump-reverse and begin-selection repeat-jump kill-selection yank_to_clipboard yank end-selection
|
||||
bind -M visual -m default y kill-selection yank_to_clipboard yank end-selection repaint-mode
|
||||
|
||||
# use system clipboard for vi mode pastes
|
||||
bind -s p 'set -g fish_cursor_end_mode exclusive' forward-char 'set -g fish_cursor_end_mode inclusive' fish_clipboard_paste
|
||||
bind -s P fish_clipboard_paste
|
||||
'';
|
||||
|
||||
nix-closure-size = {
|
||||
body = ''
|
||||
nix path-info --recursive --size --closure-size \
|
||||
--human-readable $(readlink -f $(which $program))
|
||||
'';
|
||||
argumentNames = [ "program" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
143
modules/cli/shell/starship.fish
Normal file
143
modules/cli/shell/starship.fish
Normal file
@@ -0,0 +1,143 @@
|
||||
# This file is modified from:
|
||||
# https://github.com/tyler-stefani/starship/blob/main/conf.d/starship.fish
|
||||
# The MIT License can be found here:
|
||||
# https://github.com/tyler-stefani/starship/blob/main/LICENSE
|
||||
|
||||
status is-interactive
|
||||
or exit 0
|
||||
|
||||
# set temp file and signal for async prompts
|
||||
if test -n "$XDG_RUNTIME_DIR"
|
||||
set -g starship_temp_dir "$XDG_RUNTIME_DIR"/fish-async-prompt
|
||||
else
|
||||
set -g starship_temp_dir /tmp/fish-async-prompt
|
||||
end
|
||||
mkdir -p "$starship_temp_dir"
|
||||
set -g starship_temp_file "$starship_temp_dir"/"$fish_pid"_last_prompt
|
||||
set -g starship_async_signal SIGUSR1
|
||||
|
||||
function fish_prompt
|
||||
if test "$TRANSIENT" = "1"
|
||||
starship_transient_prompt_func
|
||||
else if test -e $starship_temp_file
|
||||
cat $starship_temp_file
|
||||
else
|
||||
starship_transient_prompt_func
|
||||
end
|
||||
end
|
||||
|
||||
function starship_transient_prompt_func
|
||||
# Clear from cursor to end of screen as `commandline -f repaint` does not do this
|
||||
# See https://github.com/fish-shell/fish-shell/issues/8418
|
||||
printf \e\[0J
|
||||
starship module character
|
||||
end
|
||||
|
||||
|
||||
function fish_right_prompt
|
||||
switch "$fish_key_bindings"
|
||||
case fish_hybrid_key_bindings fish_vi_key_bindings
|
||||
set STARSHIP_KEYMAP "$fish_bind_mode"
|
||||
case '*'
|
||||
set STARSHIP_KEYMAP insert
|
||||
end
|
||||
set STARSHIP_CMD_PIPESTATUS $pipestatus
|
||||
set STARSHIP_CMD_STATUS $status
|
||||
# Account for changes in variable name between v2.7 and v3.0
|
||||
set STARSHIP_DURATION "$CMD_DURATION$cmd_duration"
|
||||
set STARSHIP_JOBS (count (jobs -p))
|
||||
if test "$TRANSIENT" = "1"
|
||||
if type -q starship_transient_rprompt_func
|
||||
starship_transient_rprompt_func
|
||||
else
|
||||
printf ""
|
||||
end
|
||||
else
|
||||
starship prompt --right --terminal-width="$COLUMNS" --status=$STARSHIP_CMD_STATUS --pipestatus="$STARSHIP_CMD_PIPESTATUS" --keymap=$STARSHIP_KEYMAP --cmd-duration=$STARSHIP_DURATION --jobs=$STARSHIP_JOBS
|
||||
end
|
||||
end
|
||||
|
||||
# Disable virtualenv prompt, it breaks starship
|
||||
set -g VIRTUAL_ENV_DISABLE_PROMPT 1
|
||||
|
||||
# Remove default mode prompt
|
||||
builtin functions -e fish_mode_prompt
|
||||
|
||||
set -gx STARSHIP_SHELL fish
|
||||
|
||||
# Transience related functions
|
||||
function reset-transient --on-event fish_postexec
|
||||
set -g TRANSIENT 0
|
||||
end
|
||||
|
||||
function transient_execute
|
||||
if commandline --is-valid
|
||||
set -g TRANSIENT 1
|
||||
commandline -f repaint
|
||||
else
|
||||
set -g TRANSIENT 0
|
||||
end
|
||||
commandline -f execute
|
||||
end
|
||||
|
||||
function transient_cancel
|
||||
if string length -q -- (commandline)
|
||||
set -g TRANSIENT 1
|
||||
commandline -f repaint
|
||||
end
|
||||
commandline -f cancel-commandline
|
||||
end
|
||||
|
||||
# --user is the default, but listed anyway to make it explicit.
|
||||
function enable_transience --description 'enable transient prompt keybindings'
|
||||
bind --user \r transient_execute
|
||||
bind --user -M insert \r transient_execute
|
||||
bind --user \cc transient_cancel
|
||||
end
|
||||
|
||||
# Erase the transient prompt related key bindings.
|
||||
# --user is the default, but listed anyway to make it explicit.
|
||||
# Erasing a user binding will revert to the preset.
|
||||
function disable_transience --description 'remove transient prompt keybindings'
|
||||
bind --user -e \r
|
||||
bind --user -M insert -e \r
|
||||
bind --user -e \cc
|
||||
end
|
||||
|
||||
# Set up the session key that will be used to store logs
|
||||
# We don't use `random [min] [max]` because it is unavailable in older versions of fish shell
|
||||
set -gx STARSHIP_SESSION_KEY (string sub -s1 -l16 (random)(random)(random)(random)(random)0000000000000000)
|
||||
|
||||
# async related functions
|
||||
function write_prompt_to_temp --on-event fish_prompt
|
||||
switch "$fish_key_bindings"
|
||||
case fish_hybrid_key_bindings fish_vi_key_bindings
|
||||
set STARSHIP_KEYMAP "$fish_bind_mode"
|
||||
case '*'
|
||||
set STARSHIP_KEYMAP insert
|
||||
end
|
||||
set STARSHIP_CMD_PIPESTATUS $pipestatus
|
||||
set STARSHIP_CMD_STATUS $status
|
||||
# Account for changes in variable name between v2.7 and v3.0
|
||||
set STARSHIP_DURATION "$CMD_DURATION$cmd_duration"
|
||||
set STARSHIP_JOBS (count (jobs -p))
|
||||
|
||||
# MODIFIED: '"$STARSHIP_CMD_PIPESTATUS"' -> '$STARSHIP_CMD_PIPESTATUS'
|
||||
fish -c 'starship prompt \
|
||||
--terminal-width='"$COLUMNS"' \
|
||||
--status='$STARSHIP_CMD_STATUS' \
|
||||
--pipestatus='$STARSHIP_CMD_PIPESTATUS' \
|
||||
--keymap='$STARSHIP_KEYMAP' \
|
||||
--cmd-duration='$STARSHIP_DURATION' \
|
||||
--jobs='$STARSHIP_JOBS' > '$starship_temp_file' \
|
||||
&& kill -s '"$starship_async_signal"' '"$fish_pid"'' &
|
||||
disown
|
||||
end
|
||||
|
||||
function repaint_prompt_on_signal --on-signal "$starship_async_signal"
|
||||
commandline -f repaint
|
||||
end
|
||||
|
||||
function remove_temp_prompt_on_exit --on-event fish_exit
|
||||
rm -f $starship_temp_file
|
||||
end
|
||||
57
modules/cli/shell/starship.nix
Normal file
57
modules/cli/shell/starship.nix
Normal file
@@ -0,0 +1,57 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.cli.shell.starship;
|
||||
in
|
||||
{
|
||||
options.my.cli.shell.starship = {
|
||||
enable = lib.mkEnableOption "starship prompt";
|
||||
format = lib.mkOption {
|
||||
type = with lib.types; listOf singleLineStr;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
settings = lib.recursiveUpdate (with builtins; fromTOML (readFile ./starship-preset.toml)) {
|
||||
add_newline = false;
|
||||
command_timeout = 2000;
|
||||
nix_shell.disabled = true;
|
||||
format =
|
||||
let
|
||||
dedupDollar =
|
||||
list:
|
||||
let
|
||||
result =
|
||||
builtins.foldl'
|
||||
(
|
||||
acc: elem:
|
||||
if lib.hasPrefix "$" elem then
|
||||
if builtins.elem elem acc.seen then
|
||||
acc
|
||||
else
|
||||
acc
|
||||
// {
|
||||
result = acc.result ++ [ elem ];
|
||||
seen = acc.seen ++ [ elem ];
|
||||
}
|
||||
else
|
||||
acc // { result = acc.result ++ [ elem ]; }
|
||||
)
|
||||
{
|
||||
result = [ ];
|
||||
seen = [ ];
|
||||
}
|
||||
(lib.reverseList list);
|
||||
in
|
||||
lib.reverseList result.result;
|
||||
in
|
||||
"$all" + lib.concatStrings (dedupDollar cfg.format);
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
@@ -4,114 +4,57 @@
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
default = true;
|
||||
optionName = "default zsh settings";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"shell"
|
||||
"zsh"
|
||||
];
|
||||
config' = {
|
||||
my.persist.homeDirs = [ ".local/share/zoxide" ];
|
||||
my.home =
|
||||
let
|
||||
stateHome = config.my.home.xdg.stateHome;
|
||||
zsh-syntax-highlighting = pkgs.fetchFromGitHub {
|
||||
owner = "zsh-users";
|
||||
repo = "zsh-syntax-highlighting";
|
||||
rev = "0.8.0";
|
||||
hash = "sha256-iJdWopZwHpSyYl5/FQXEW7gl/SrKaYDEtTH9cGP7iPo=";
|
||||
};
|
||||
fzf-tab = pkgs.fetchFromGitHub {
|
||||
owner = "Aloxaf";
|
||||
repo = "fzf-tab";
|
||||
rev = "v1.2.0";
|
||||
hash = "sha256-q26XVS/LcyZPRqDNwKKA9exgBByE0muyuNb0Bbar2lY=";
|
||||
};
|
||||
in
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
fzf
|
||||
zoxide
|
||||
];
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
settings = lib.recursiveUpdate (with builtins; fromTOML (readFile ./starship-preset.toml)) {
|
||||
add_newline = false;
|
||||
custom = {
|
||||
jj = {
|
||||
ignore_timeout = true;
|
||||
description = "The current jj status";
|
||||
when = true;
|
||||
command = ''
|
||||
jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template '
|
||||
separate(" ",
|
||||
" ",
|
||||
change_id.shortest(4),
|
||||
bookmarks,
|
||||
"|",
|
||||
concat(
|
||||
if(conflict, "💥"),
|
||||
if(divergent, "🚧"),
|
||||
if(hidden, "👻"),
|
||||
if(immutable, "🔒"),
|
||||
),
|
||||
raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"),
|
||||
raw_escape_sequence("\x1b[1;32m") ++ coalesce(
|
||||
truncate_end(29, description.first_line(), "…"),
|
||||
"(no description set)",
|
||||
) ++ raw_escape_sequence("\x1b[0m"),
|
||||
)
|
||||
' || (starship module git_branch && starship module git_status)
|
||||
'';
|
||||
};
|
||||
};
|
||||
git_state.disabled = true;
|
||||
git_commit.disabled = true;
|
||||
git_metrics.disabled = true;
|
||||
git_branch.disabled = true;
|
||||
git_status.disabled = true;
|
||||
nix_shell.disabled = true;
|
||||
};
|
||||
};
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
dotDir = "${config.my.home.xdg.configHome}/zsh";
|
||||
history = {
|
||||
path = "${stateHome}/zsh_history";
|
||||
ignorePatterns = [
|
||||
"la"
|
||||
];
|
||||
};
|
||||
initContent = lib.mkAfter ''
|
||||
source ${fzf-tab}/fzf-tab.plugin.zsh
|
||||
let
|
||||
cfg = config.my.cli.shell.zsh;
|
||||
in
|
||||
{
|
||||
options.my.cli.shell.zsh = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Enable default zsh settings";
|
||||
};
|
||||
};
|
||||
|
||||
eval "$(zoxide init zsh)"
|
||||
source ${zsh-syntax-highlighting}/zsh-syntax-highlighting.plugin.zsh
|
||||
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
'';
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
theme = "gentoo";
|
||||
plugins = [
|
||||
"git"
|
||||
"git-extras"
|
||||
"extract"
|
||||
"sudo"
|
||||
"dotenv"
|
||||
];
|
||||
};
|
||||
shellAliases = {
|
||||
x = "extract";
|
||||
ls = "lsd";
|
||||
svim = "sudoedit";
|
||||
nf = "neofetch";
|
||||
tmux = "tmux -T RGB,focus,overline,mouse,clipboard,usstyle";
|
||||
pastart = "pasuspender true";
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
home.packages = with pkgs; [
|
||||
fzf
|
||||
];
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
dotDir = "${config.my.hm.xdg.configHome}/zsh";
|
||||
history = {
|
||||
path = "${config.my.hm.xdg.stateHome}/zsh_history";
|
||||
ignorePatterns = [
|
||||
"la"
|
||||
];
|
||||
};
|
||||
autosuggestion.enable = true;
|
||||
syntaxHighlighting.enable = true;
|
||||
plugins = [
|
||||
{
|
||||
name = "fzf-tab";
|
||||
src = pkgs.zsh-fzf-tab;
|
||||
file = "share/fzf-tab/fzf-tab.plugin.zsh";
|
||||
}
|
||||
];
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
theme = "gentoo";
|
||||
plugins = [
|
||||
"git"
|
||||
"git-extras"
|
||||
"extract"
|
||||
"sudo"
|
||||
];
|
||||
};
|
||||
shellAliases = {
|
||||
ls = "lsd";
|
||||
svim = "doasedit";
|
||||
nf = "fastfetch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
43
modules/cli/shpool.nix
Normal file
43
modules/cli/shpool.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.my.cli.shpool;
|
||||
in
|
||||
{
|
||||
options.my.cli.shpool = {
|
||||
enable = lib.mkEnableOption "shpool";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
services.shpool = {
|
||||
enable = true;
|
||||
systemd = true;
|
||||
settings = {
|
||||
motd = "never";
|
||||
prompt_prefix = "";
|
||||
forward_env = [ "PATH" ];
|
||||
};
|
||||
};
|
||||
programs.starship = {
|
||||
settings = {
|
||||
custom.shpool = {
|
||||
description = "Display current shpool session name";
|
||||
when = ''test -n "$SHPOOL_SESSION_NAME"'';
|
||||
command = "echo $SHPOOL_SESSION_NAME";
|
||||
symbol = " ";
|
||||
style = "fg:#dea584";
|
||||
format = "[$symbol \\[$output\\] ]($style)";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
my.cli.shell.starship.format = [
|
||||
"\${custom.shpool}"
|
||||
"$character"
|
||||
];
|
||||
};
|
||||
}
|
||||
55
modules/cli/tmux.nix
Normal file
55
modules/cli/tmux.nix
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.my.cli.tmux;
|
||||
in
|
||||
{
|
||||
options.my.cli.tmux = {
|
||||
enable = lib.mkEnableOption "tmux";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
set-option -g mouse on
|
||||
set-option -a terminal-features ",xterm-256color:RGB,focus,clipboard,usstyle"
|
||||
'';
|
||||
plugins = [
|
||||
(pkgs.tmuxPlugins.mkTmuxPlugin {
|
||||
pluginName = "tokyo-night-tmux";
|
||||
rtpFilePath = "tokyo-night.tmux";
|
||||
version = "legacy";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "janoamaral";
|
||||
repo = "tokyo-night-tmux";
|
||||
rev = "16469dfad86846138f594ceec780db27039c06cd";
|
||||
hash = "sha256-EKCgYan0WayXnkSb2fDJxookdBLW0XBKi2hf/YISwJE=";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
programs.starship = {
|
||||
settings = {
|
||||
custom.tmux = {
|
||||
description = "Display current tmux session name";
|
||||
when = ''test -n "$TMUX"'';
|
||||
command = "tmux display-message -p '#S'";
|
||||
symbol = " ";
|
||||
style = "bold green";
|
||||
format = "[$symbol \\[$output\\] ]($style)";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
my.cli.shell.starship.format = [
|
||||
"\${custom.tmux}"
|
||||
"$character"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all command line tools";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"vcs"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.cli.vcs.all;
|
||||
in
|
||||
{
|
||||
options.my.cli.vcs.all = {
|
||||
enable = lib.mkEnableOption "all command line tools";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.cli.vcs = {
|
||||
git.enable = true;
|
||||
jj.enable = true;
|
||||
|
||||
@@ -4,35 +4,43 @@
|
||||
pkgs,
|
||||
username,
|
||||
userfullname,
|
||||
useremail,
|
||||
emails,
|
||||
hosts,
|
||||
...
|
||||
}:
|
||||
lib.my.makeHomeProgramConfig {
|
||||
inherit config;
|
||||
programName = "git";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"vcs"
|
||||
"git"
|
||||
];
|
||||
extraConfig = {
|
||||
my.home = {
|
||||
let
|
||||
cfg = config.my.cli.vcs.git;
|
||||
in
|
||||
{
|
||||
options.my.cli.vcs.git = {
|
||||
enable = lib.mkEnableOption "git";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
programs.git = {
|
||||
userName = "${userfullname}";
|
||||
userEmail = "${useremail}";
|
||||
enable = true;
|
||||
settings = {
|
||||
gpg.ssh.allowedSignersFile =
|
||||
hosts
|
||||
|> lib.mapAttrsToList (
|
||||
host: key: map (email: "${email} ${key} ${host}") (builtins.attrValues emails)
|
||||
)
|
||||
|> lib.flatten
|
||||
|> lib.concatStringsSep "\n"
|
||||
|> pkgs.writeText "allowed-signers"
|
||||
|> toString;
|
||||
push.autoSetupRemote = true;
|
||||
user = {
|
||||
name = userfullname;
|
||||
email = emails.default;
|
||||
};
|
||||
};
|
||||
signing = {
|
||||
format = "ssh";
|
||||
signByDefault = true;
|
||||
key = "/home/${username}/.ssh/id_ed25519";
|
||||
};
|
||||
extraConfig = {
|
||||
push.autoSetupRemote = true;
|
||||
gpg.ssh.allowedSignersFile =
|
||||
(pkgs.writeText "allowed_signers" ''
|
||||
imxyy1soope1@gmail.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix
|
||||
imxyy@imxyy.top ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix
|
||||
'').outPath;
|
||||
};
|
||||
};
|
||||
programs.lazygit = {
|
||||
enable = true;
|
||||
|
||||
@@ -4,24 +4,36 @@
|
||||
pkgs,
|
||||
username,
|
||||
userfullname,
|
||||
useremail,
|
||||
emails,
|
||||
hosts,
|
||||
...
|
||||
}:
|
||||
lib.my.makeHomeProgramConfig {
|
||||
inherit config;
|
||||
programName = "jujutsu";
|
||||
optionPath = [
|
||||
"cli"
|
||||
"vcs"
|
||||
"jj"
|
||||
];
|
||||
extraConfig = {
|
||||
my.home = {
|
||||
let
|
||||
cfg = config.my.cli.vcs.jj;
|
||||
in
|
||||
{
|
||||
options.my.cli.vcs.jj = {
|
||||
enable = lib.mkEnableOption "jujutsu";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
programs.jujutsu = {
|
||||
enable = true;
|
||||
settings = {
|
||||
# take the closest ancestor bookmark and move them the current change.
|
||||
# https://shaddy.dev/notes/jj-tug
|
||||
aliases.tug = [
|
||||
"bookmark"
|
||||
"move"
|
||||
"--from"
|
||||
"heads(::@- & bookmarks())"
|
||||
"--to"
|
||||
"@-"
|
||||
];
|
||||
user = {
|
||||
name = "${userfullname}";
|
||||
email = "${useremail}";
|
||||
name = userfullname;
|
||||
email = emails.default;
|
||||
};
|
||||
ui = {
|
||||
graph.style = "square";
|
||||
@@ -33,14 +45,56 @@ lib.my.makeHomeProgramConfig {
|
||||
behavior = "own";
|
||||
key = "/home/${username}/.ssh/id_ed25519";
|
||||
backends.backends.ssh.allowed-signers =
|
||||
(pkgs.writeText "allowed_signers" ''
|
||||
imxyy1soope1@gmail.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix
|
||||
imxyy@imxyy.top ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix
|
||||
'').outPath;
|
||||
hosts
|
||||
|> lib.mapAttrsToList (
|
||||
host: key: map (email: "${email} ${key} ${host}") (builtins.attrValues emails)
|
||||
)
|
||||
|> lib.flatten
|
||||
|> lib.concatStringsSep "\n"
|
||||
|> pkgs.writeText "allowed-signers"
|
||||
|> toString;
|
||||
};
|
||||
};
|
||||
};
|
||||
home.packages = [ pkgs.lazyjj ];
|
||||
programs.jjui.enable = true;
|
||||
programs.starship = {
|
||||
settings = {
|
||||
custom = {
|
||||
# Borrowed from https://github.com/jj-vcs/jj/wiki/Starship/b18afc53417848f58333b24d446b8e2522b42bd2#alternative-prompt
|
||||
jj = {
|
||||
ignore_timeout = true;
|
||||
description = "The current jj status";
|
||||
when = true;
|
||||
command = ''
|
||||
jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template '
|
||||
separate(" ",
|
||||
" ",
|
||||
change_id.shortest(4),
|
||||
bookmarks,
|
||||
"|",
|
||||
concat(
|
||||
if(conflict, "💥"),
|
||||
if(divergent, "🚧"),
|
||||
if(hidden, "👻"),
|
||||
if(immutable, "🔒"),
|
||||
),
|
||||
raw_escape_sequence("\x1b[1;32m") ++ if(empty, "(empty)"),
|
||||
raw_escape_sequence("\x1b[1;32m") ++ coalesce(
|
||||
truncate_end(29, description.first_line(), "…"),
|
||||
"(no description set)",
|
||||
) ++ raw_escape_sequence("\x1b[0m"),
|
||||
)
|
||||
' || {starship module git_branch && starship module git_status}
|
||||
'';
|
||||
};
|
||||
};
|
||||
git_state.disabled = true;
|
||||
git_commit.disabled = true;
|
||||
git_metrics.disabled = true;
|
||||
git_branch.disabled = true;
|
||||
git_status.disabled = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all coding tools";
|
||||
optionPath = [
|
||||
"coding"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.coding.all;
|
||||
in
|
||||
{
|
||||
options.my.coding.all = {
|
||||
enable = lib.mkEnableOption "all coding tools";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.coding = {
|
||||
editor.all.enable = true;
|
||||
langs.all.enable = true;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{ config, lib, ... }:
|
||||
lib.my.makeSwitch {
|
||||
inherit config;
|
||||
optionName = "all coding editors";
|
||||
optionPath = [
|
||||
"coding"
|
||||
"editor"
|
||||
"all"
|
||||
];
|
||||
config' = {
|
||||
let
|
||||
cfg = config.my.coding.editor.all;
|
||||
in
|
||||
{
|
||||
options.my.coding.editor.all = {
|
||||
enable = lib.mkEnableOption "all coding editors";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.coding.editor = {
|
||||
neovim.enable = true;
|
||||
vscode.enable = true;
|
||||
|
||||
@@ -2,23 +2,20 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
impure,
|
||||
...
|
||||
}:
|
||||
lib.my.makeHomeProgramConfig {
|
||||
inherit config;
|
||||
programName = "neovim";
|
||||
optionPath = [
|
||||
"coding"
|
||||
"editor"
|
||||
"neovim"
|
||||
];
|
||||
extraConfig = {
|
||||
my.home = {
|
||||
xdg.configFile."nvim/init.lua".source = ./nvim/init.lua;
|
||||
xdg.configFile."nvim/lua" = {
|
||||
source = ./nvim/lua;
|
||||
recursive = true;
|
||||
};
|
||||
let
|
||||
cfg = config.my.coding.editor.neovim;
|
||||
in
|
||||
{
|
||||
options.my.coding.editor.neovim = {
|
||||
enable = lib.mkEnableOption "neovim";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hm = {
|
||||
xdg.configFile."nvim".source = impure.mkImpureLink ./nvim;
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
@@ -29,6 +26,11 @@ lib.my.makeHomeProgramConfig {
|
||||
gcc # treesitter
|
||||
|
||||
ripgrep # telescope
|
||||
|
||||
vscode-json-languageserver
|
||||
vscode-langservers-extracted
|
||||
taplo
|
||||
typos-lsp
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
44
modules/coding/editor/neovim/nvim/lazy-lock.json
Normal file
44
modules/coding/editor/neovim/nvim/lazy-lock.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
|
||||
"LuaSnip": { "branch": "master", "commit": "de10d8414235b0a8cabfeba60d07c24304e71f5c" },
|
||||
"blink.cmp": { "branch": "main", "commit": "f9e855c4d96e1264f7c818844f5a0166ad48c212" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "c7d37ca22b461f64e26f8f6701b2586128ed0bef" },
|
||||
"glance.nvim": { "branch": "master", "commit": "bf86d8b79dce808e65fdb6e9269d0b4ed6d2eefc" },
|
||||
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
||||
"inlay-hints.nvim": { "branch": "master", "commit": "990e1f96699b8293b6665b9e73b16128c66684e6" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" },
|
||||
"leap.nvim": { "branch": "main", "commit": "02bf52e49c72cc5dabb53ec9494d10d304f0b2c9" },
|
||||
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
||||
"mini.nvim": { "branch": "main", "commit": "8c40d95931cbe6138391af9180e59439ed2e69df" },
|
||||
"neo-tree.nvim": { "branch": "main", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" },
|
||||
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
|
||||
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
|
||||
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "276ce3bc878243dc63c32b75790c4296d11848f6" },
|
||||
"nvim-notify": { "branch": "master", "commit": "397c7c1184745fca649e5104de659e6392ef5a4d" },
|
||||
"nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" },
|
||||
"nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "3362099de3368aa620a8105b19ed04c2053e38c0" },
|
||||
"outline.nvim": { "branch": "main", "commit": "0eb9289ab39c91caf8b3ed0e3a17764809d69558" },
|
||||
"pest.vim": { "branch": "master", "commit": "7cfcb43f824e74d13dfe631359fff2ec23836a77" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"rainbow-delimiters.nvim": { "branch": "master", "commit": "97bf4b8ef9298644a29fcd9dd41a0210cf08cac7" },
|
||||
"render-markdown.nvim": { "branch": "main", "commit": "3da7bb459f6cff03980dd1e106c46f3e62ff4d9f" },
|
||||
"ripgrep": { "branch": "master", "commit": "119a58a400ea948c2d2b0cd4ec58361e74478641" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
|
||||
"tree-sitter-nu": { "branch": "main", "commit": "6544c4383643cf8608d50def2247a7af8314e148" },
|
||||
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
|
||||
"vim-floaterm": { "branch": "master", "commit": "fd4bdd66eca56c6cc59f2119e4447496d8cde2ea" },
|
||||
"vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" },
|
||||
"workspace-diagnostics.nvim": { "branch": "main", "commit": "60f9175b2501ae3f8b1aba9719c0df8827610c8e" }
|
||||
}
|
||||
@@ -63,7 +63,7 @@ function G.buf_kill(kill_command, bufnr, force)
|
||||
else
|
||||
return
|
||||
end
|
||||
elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then
|
||||
elseif api.nvim_get_option_value("buftype", { buf = bufnr }) == "terminal" then
|
||||
choice = fn.confirm(fmt([[Close "%s"?]], bufname), "&Yes\n&No\n&Cancel")
|
||||
if choice == 1 then
|
||||
force = true
|
||||
|
||||
@@ -7,6 +7,8 @@ local buf_kill = globals.buf_kill
|
||||
|
||||
keymap.set("v", "<S-pageup>", ":m '<-2<CR>gv=gv", opt)
|
||||
keymap.set("v", "<S-pagedown>", ":m '>+1<CR>gv=gv", opt)
|
||||
keymap.set({ "i", "n", "v" }, "<S-up>", "<up>", opt)
|
||||
keymap.set({ "i", "n", "v" }, "<S-down>", "<down>", opt)
|
||||
|
||||
keymap.set("n", "<leader>nh", ":nohl<CR>", opt)
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@ opt.timeoutlen = 500
|
||||
|
||||
opt.completeopt = ""
|
||||
|
||||
opt.exrc = true
|
||||
|
||||
opt.autoread = true
|
||||
vim.g.autoread = true
|
||||
|
||||
vim.g.loaded_ruby_provider = 0
|
||||
|
||||
-- Hightlight on yank
|
||||
-- Highlight on yank
|
||||
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
@@ -53,12 +55,12 @@ vim.cmd([[
|
||||
\ endif
|
||||
]])
|
||||
|
||||
-- Automaticly switch input method
|
||||
-- Automatically switch input method
|
||||
Last_input_method = 1
|
||||
vim.api.nvim_create_augroup("AutoInputMethod", {})
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
pattern = "*",
|
||||
desc = "Automaticly switch input method",
|
||||
desc = "Automatically switch input method",
|
||||
callback = function()
|
||||
Last_input_method = require("core.globals").switch_input_method(1)
|
||||
end,
|
||||
@@ -66,7 +68,7 @@ vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
})
|
||||
vim.api.nvim_create_autocmd("CmdlineLeave", {
|
||||
pattern = "*",
|
||||
desc = "Automaticly switch input method",
|
||||
desc = "Automatically switch input method",
|
||||
callback = function()
|
||||
require("core.globals").switch_input_method(1)
|
||||
end,
|
||||
@@ -74,7 +76,7 @@ vim.api.nvim_create_autocmd("CmdlineLeave", {
|
||||
})
|
||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
pattern = "*",
|
||||
desc = "Automaticly switch input method",
|
||||
desc = "Automatically switch input method",
|
||||
callback = function()
|
||||
require("core.globals").switch_input_method(Last_input_method)
|
||||
end,
|
||||
|
||||
@@ -4,9 +4,6 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
desc = "auto format Go files",
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
-- vim.fn.system("go fmt " .. vim.fn.expand("%:p"))
|
||||
-- vim.fn.system("goimports -w " .. vim.fn.expand("%:p"))
|
||||
-- vim.cmd("edit")
|
||||
end,
|
||||
group = "Go",
|
||||
})
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
require("langs.go")
|
||||
-- require("langs.rust")
|
||||
require("langs.lualang")
|
||||
require("langs.nix")
|
||||
require("langs.markdown")
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
vim.api.nvim_create_augroup("Lua", {})
|
||||
|
||||
local old = {}
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = { "*.lua" },
|
||||
desc = "auto lua file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
old.tabstop = opt.tabstop
|
||||
old.shiftwidth = opt.shiftwidth
|
||||
old.softtabstop = opt.softtabstop
|
||||
old.expandtab = opt.expandtab
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.softtabstop = 2
|
||||
opt.expandtab = true
|
||||
opt.autoindent = true
|
||||
end,
|
||||
group = "Lua",
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufLeave", {
|
||||
pattern = { "*.lua" },
|
||||
desc = "auto lua file indent",
|
||||
callback = function()
|
||||
local opt = vim.opt
|
||||
-- Tab width setting
|
||||
opt.tabstop = old.tabstop
|
||||
opt.shiftwidth = old.shiftwidth
|
||||
opt.softtabstop = old.softtabstop
|
||||
opt.expandtab = old.expandtab
|
||||
end,
|
||||
group = "Lua",
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user