init: public
This commit is contained in:
9
.sops.yaml
Normal file
9
.sops.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
keys:
|
||||||
|
- &imxyy-nix age1jf5pg2x6ta8amj40xdy0stvcvrdlkwc2nrwtmkpymu0qclk0eg5qmm9kns
|
||||||
|
- &imxyy-nix-server age1hpgg6psejh4y6jcdd34wxuml75fnweqpe0kh8376yqsctsfn9qxs037kk6
|
||||||
|
creation_rules:
|
||||||
|
- path_regex: secrets/.*\.(yaml|toml|json|env|dae|txt)$
|
||||||
|
key_groups:
|
||||||
|
- age:
|
||||||
|
- *imxyy-nix
|
||||||
|
- *imxyy-nix-server
|
||||||
45
Makefile
Normal file
45
Makefile
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
all: fmt switch
|
||||||
|
|
||||||
|
switch:
|
||||||
|
@echo "Rebuilding NixOS..."
|
||||||
|
@nixos-rebuild switch --flake . --use-remote-sudo
|
||||||
|
|
||||||
|
boot:
|
||||||
|
@echo "Rebuilding NixOS..."
|
||||||
|
@nixos-rebuild boot --flake . --use-remote-sudo
|
||||||
|
|
||||||
|
vm:
|
||||||
|
@echo "Building NixOS VM..."
|
||||||
|
@nixos-rebuild build-vm --flake .
|
||||||
|
|
||||||
|
update:
|
||||||
|
@echo "Updating flakes..."
|
||||||
|
@nix flake update
|
||||||
|
|
||||||
|
history:
|
||||||
|
@nix profile history --profile /nix/var/nix/profiles/system
|
||||||
|
|
||||||
|
replpkgs:
|
||||||
|
@nix repl -f flake:nixpkgs
|
||||||
|
|
||||||
|
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 run home-manager#home-manager -- expire-generations -15days --dry-run
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo "Removing all generations older than 15 days..."
|
||||||
|
@sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 15d
|
||||||
|
@nix run home-manager#home-manager -- expire-generations -15days
|
||||||
|
|
||||||
|
gc:
|
||||||
|
@nix store gc --debug
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
@echo "Formatting nix files..."
|
||||||
|
@nix fmt
|
||||||
|
|
||||||
|
.PHONY: os home news update history repl clean gc fmt
|
||||||
290
README.md.bak
290
README.md.bak
@@ -1,290 +0,0 @@
|
|||||||
# Nix Starter Config
|
|
||||||
|
|
||||||
This repo contains a few a simple nix flake templates for getting started with
|
|
||||||
NixOS + home-manager.
|
|
||||||
|
|
||||||
# What this provides
|
|
||||||
|
|
||||||
- [Minimal version](./minimal):
|
|
||||||
- NixOS configuration on `nixos/configuration.nix`, accessible via
|
|
||||||
`nixos-rebuild --flake .`
|
|
||||||
- Home-manager configuration on `home-manager/home.nix`, accessible via
|
|
||||||
`home-manager --flake .`
|
|
||||||
- [Standard version](./standard):
|
|
||||||
- Basic boilerplate for adding custom packages (under `pkgs`) and overlays
|
|
||||||
(under `overlay`). Accessible on your system, home config, as well as `nix
|
|
||||||
build .#package-name`.
|
|
||||||
- Boilerplate for custom NixOS (`modules/nixos`) and home-manager
|
|
||||||
(`modules/home-manager`) modules
|
|
||||||
- NixOS and home-manager configurations from minimal, and they should
|
|
||||||
also use your overlays and custom packages right out of the box.
|
|
||||||
|
|
||||||
# Getting started
|
|
||||||
|
|
||||||
Assuming you have a basic NixOS booted up (either live or installed, anything
|
|
||||||
works). [Here's a link to the latest NixOS downloads, just for
|
|
||||||
you](https://nixos.org/download#download-nixos).
|
|
||||||
|
|
||||||
Alternatively, you can totally use `nix` and `home-manager` on your existing
|
|
||||||
distro (or even on Darwin). [Install nix](https://nixos.org/download.html#nix)
|
|
||||||
and follow along (just ignore the `nixos-*` commands).
|
|
||||||
|
|
||||||
## What template to chose?
|
|
||||||
|
|
||||||
If this is your first trying flakes, or you're attempting to migrate your
|
|
||||||
(simple) config to it; you should use the minimal version.
|
|
||||||
|
|
||||||
If you're here looking for inspiration/tips/good practices (and you already use
|
|
||||||
flakes), or you're migrating a config that already has overlays and custom
|
|
||||||
packages; try the standard version.
|
|
||||||
|
|
||||||
## I like your funny words, magic man
|
|
||||||
|
|
||||||
Not sure what this all means?
|
|
||||||
|
|
||||||
Take a look at [the learn hub on the NixOS
|
|
||||||
website](https://nixos.org/learn.html) (scroll down to guides, the manuals, and
|
|
||||||
the other awesome learning resources).
|
|
||||||
|
|
||||||
Learning the basics of what Nix (the package manager) is, how the Nix language
|
|
||||||
works, and a bit of NixOS basics should get you up and running. Don't worry if
|
|
||||||
it seems a little confusing at first. Get confortable with the basic concepts
|
|
||||||
and come back here to get your feet wet, it's the best way to learn!
|
|
||||||
|
|
||||||
## The repo
|
|
||||||
|
|
||||||
- [Install git](https://nixos.wiki/wiki/git), if you haven't already.
|
|
||||||
- Create a repository for your config, for example:
|
|
||||||
```bash
|
|
||||||
cd ~/Documents
|
|
||||||
git init nix-config
|
|
||||||
cd nix-config
|
|
||||||
```
|
|
||||||
- Make sure you're running Nix 2.4+, and opt into the experimental `flakes` and `nix-command` features:
|
|
||||||
```bash
|
|
||||||
# Should be 2.4+
|
|
||||||
nix --version
|
|
||||||
export NIX_CONFIG="experimental-features = nix-command flakes"
|
|
||||||
```
|
|
||||||
- Get the template:
|
|
||||||
```bash
|
|
||||||
# For minimal version
|
|
||||||
nix flake init -t github:misterio77/nix-starter-config#minimal
|
|
||||||
|
|
||||||
# For standard version
|
|
||||||
nix flake init -t github:misterio77/nix-starter-config#standard
|
|
||||||
```
|
|
||||||
- If you want to use NixOS: add stuff you currently have on `/etc/nixos/` to
|
|
||||||
`nixos` (usually `configuration.nix` and `hardware-configuration.nix`, when
|
|
||||||
you're starting out).
|
|
||||||
- The included file has some options you might want, specially if you don't
|
|
||||||
have a configuration ready. Make sure you have generated your own
|
|
||||||
`hardware-configuration.nix`; if not, just mount your partitions to
|
|
||||||
`/mnt` and run: `nixos-generate-config --root /mnt`.
|
|
||||||
- If you want to use home-manager: add your stuff from `~/.config/nixpkgs`
|
|
||||||
to `home-manager` (probably `home.nix`).
|
|
||||||
- The included file is also a good starting point if you don't have a config
|
|
||||||
yet.
|
|
||||||
- Take a look at `flake.nix`, making sure to fill out anything marked with
|
|
||||||
FIXME (required) or TODO (usually tips or optional stuff you might want)
|
|
||||||
- `git add` and `git push` your changes! Or at least copy them somewhere if
|
|
||||||
you're on a live medium.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
- Run `sudo nixos-rebuild switch --flake .#hostname` to apply your system
|
|
||||||
configuration.
|
|
||||||
- If you're still on a live installation medium, run `nixos-install --flake
|
|
||||||
.#hostname` instead, and reboot.
|
|
||||||
- Run `home-manager switch --flake .#username@hostname` to apply your home
|
|
||||||
configuration.
|
|
||||||
- If you don't have home-manager installed, try `nix shell nixpkgs#home-manager`.
|
|
||||||
|
|
||||||
And that's it, really! You're ready to have fun with your configurations using
|
|
||||||
the latest and greatest nix3 flake-enabled command UX.
|
|
||||||
|
|
||||||
# What next?
|
|
||||||
|
|
||||||
## Use home-manager as a NixOS module
|
|
||||||
|
|
||||||
If you prefer to build your home configuration together with your NixOS one,
|
|
||||||
it's pretty simple.
|
|
||||||
|
|
||||||
Simply remove the `homeConfigurations` block from the `flake.nix` file; then
|
|
||||||
add this to your NixOS configuration (either directly on
|
|
||||||
`nixos/configuration.nix` or on a separate file and import it):
|
|
||||||
|
|
||||||
```nix
|
|
||||||
{ inputs, outputs, ... }: {
|
|
||||||
imports = [
|
|
||||||
# Import home-manager's NixOS module
|
|
||||||
inputs.home-manager.nixosModules.home-manager
|
|
||||||
];
|
|
||||||
|
|
||||||
home-manager = {
|
|
||||||
extraSpecialArgs = { inherit inputs outputs; };
|
|
||||||
users = {
|
|
||||||
# Import your home-manager configuration
|
|
||||||
your-username = import ../home-manager/home.nix;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this setup, the `home-manager` tool will not be installed (see
|
|
||||||
[nix-community/home-manager#4342](https://github.com/nix-community/home-manager/pull/4342)).
|
|
||||||
To rebuild your home configuration, use `nixos-rebuild` instead.
|
|
||||||
|
|
||||||
But if you want to install the `home-manager` tool anyways, you can add the
|
|
||||||
package into your configuration:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
# To install it for a specific user
|
|
||||||
users.users = {
|
|
||||||
your-username = {
|
|
||||||
packages = [ inputs.home-manager.packages.${pkgs.system}.default ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# To install it globally
|
|
||||||
environment.systemPackages =
|
|
||||||
[ inputs.home-manager.packages.${pkgs.system}.default ];
|
|
||||||
```
|
|
||||||
|
|
||||||
## Adding more hosts or users
|
|
||||||
|
|
||||||
You can organize them by hostname and username on `nixos` and `home-manager`
|
|
||||||
directories, be sure to also add them to `flake.nix`.
|
|
||||||
|
|
||||||
You can take a look at my (beware, here be reproductible dragons)
|
|
||||||
[configuration repo](https://github.com/misterio77/nix-config) for ideas.
|
|
||||||
|
|
||||||
NixOS makes it easy to share common configuration between hosts (you might want
|
|
||||||
to create a common directory for these), while keeping everything in sync.
|
|
||||||
home-manager can help you sync your environment (from editor to WM and
|
|
||||||
everything in between) anywhere you use it. Have fun!
|
|
||||||
|
|
||||||
## User password and secrets
|
|
||||||
|
|
||||||
You have basically two ways of setting up default passwords:
|
|
||||||
- By default, you'll be prompted for a root password when installing with
|
|
||||||
`nixos-install`. After you reboot, be sure to add a password to your own
|
|
||||||
account and lock root using `sudo passwd -l root`.
|
|
||||||
- Alternatively, you can specify `initialPassword` for your user. This will
|
|
||||||
give your account a default password, be sure to change it after rebooting!
|
|
||||||
If you do, you should pass `--no-root-passwd` to `nixos-install`, to skip
|
|
||||||
setting a password on the root account.
|
|
||||||
|
|
||||||
If you don't want to set your password imperatively, you can also use
|
|
||||||
`passwordFile` for safely and declaratively setting a password from a file
|
|
||||||
outside the nix store.
|
|
||||||
|
|
||||||
There's also [more advanced options for secret
|
|
||||||
management](https://nixos.wiki/wiki/Comparison_of_secret_managing_schemes),
|
|
||||||
including some that can include them (encrypted) into your config repo and/or
|
|
||||||
nix store, be sure to check them out if you're interested.
|
|
||||||
|
|
||||||
## Dotfile management with home-manager
|
|
||||||
|
|
||||||
Besides just adding packages to your environment, home-manager can also manage
|
|
||||||
your dotfiles. I strongly recommend you do, it's awesome!
|
|
||||||
|
|
||||||
For full nix goodness, check out the home-manager options with `man
|
|
||||||
home-configuration.nix`. Using them, you'll be able to fully configure any
|
|
||||||
program with nix syntax and its powerful abstractions.
|
|
||||||
|
|
||||||
Alternatively, if you're still not ready to rewrite all your configs to nix
|
|
||||||
syntax, there's home-manager options (such as `xdg.configFile`) for including
|
|
||||||
files from your config repository into your usual dot directories. Add your
|
|
||||||
existing dotfiles to this repo and try it out!
|
|
||||||
|
|
||||||
## Try opt-in persistance
|
|
||||||
|
|
||||||
You might have noticed that there's impurity in your NixOS system, in the form
|
|
||||||
of configuration files and other cruft your system generates when running. What
|
|
||||||
if you change them in a whim to get something working and forget about it?
|
|
||||||
Boom, your system is not fully reproductible anymore.
|
|
||||||
|
|
||||||
You can instead fully delete your `/` and `/home` on every boot! Nix is okay
|
|
||||||
with a empty root on boot (all you need is `/boot` and `/nix`), and will
|
|
||||||
happily reapply your configurations.
|
|
||||||
|
|
||||||
There's two main approaches to this: mount a `tmpfs` (RAM disk) to `/`, or
|
|
||||||
(using a filesystem such as btrfs or zfs) mount a blank snapshot and reset it
|
|
||||||
on boot.
|
|
||||||
|
|
||||||
For stuff that can't be managed through nix (such as games downloaded from
|
|
||||||
steam, or logs), use [impermanence](https://github.com/nix-community/impermanence)
|
|
||||||
for mounting stuff you to keep to a separate partition/volume (such as
|
|
||||||
`/nix/persist` or `/persist`). This makes everything vanish by default, and you
|
|
||||||
can keep track of what you specifically asked to be kept.
|
|
||||||
|
|
||||||
Here's some awesome blog posts about it:
|
|
||||||
- [Erase your darlings](https://grahamc.com/blog/erase-your-darlings)
|
|
||||||
- [Encrypted BTRFS with Opt-In State on
|
|
||||||
NixOS](https://mt-caret.github.io/blog/posts/2020-06-29-optin-state.html)
|
|
||||||
- [NixOS: tmpfs as root](https://elis.nu/blog/2020/05/nixos-tmpfs-as-root/) and
|
|
||||||
[tmpfs as home](https://elis.nu/blog/2020/06/nixos-tmpfs-as-home/)
|
|
||||||
|
|
||||||
Note that for `home-manager` to work correctly here, you need to set up its
|
|
||||||
NixOS module, as described in the [previous section](#use-home-manager-as-a-nixos-module).
|
|
||||||
|
|
||||||
## Adding custom packages
|
|
||||||
|
|
||||||
Something you want to use that's not in nixpkgs yet? You can easily build and
|
|
||||||
iterate on a derivation (package) from this very repository.
|
|
||||||
|
|
||||||
Create a folder with the desired name inside `pkgs`, and add a `default.nix`
|
|
||||||
file containing a derivation. Be sure to also `callPackage` them on
|
|
||||||
`pkgs/default.nix`.
|
|
||||||
|
|
||||||
You'll be able to refer to that package from anywhere on your
|
|
||||||
home-manager/nixos configurations, build them with `nix build .#package-name`,
|
|
||||||
or bring them into your shell with `nix shell .#package-name`.
|
|
||||||
|
|
||||||
See [the manual](https://nixos.org/manual/nixpkgs/stable/) for some tips on how
|
|
||||||
to package stuff.
|
|
||||||
|
|
||||||
## Adding overlays
|
|
||||||
|
|
||||||
Found some outdated package on nixpkgs you need the latest version of? Perhaps
|
|
||||||
you want to apply a patch to fix a behaviour you don't like? Nix makes it easy
|
|
||||||
and manageble with overlays!
|
|
||||||
|
|
||||||
Use the `overlays/default.nix` file for this.
|
|
||||||
|
|
||||||
If you're creating patches, you can keep them on the `overlays` folder as well.
|
|
||||||
|
|
||||||
See [the wiki article](https://nixos.wiki/wiki/Overlays) to see how it all
|
|
||||||
works.
|
|
||||||
|
|
||||||
## Adding your own modules
|
|
||||||
|
|
||||||
Got some configurations you want to create an abstraction of? Modules are the
|
|
||||||
answer. These awesome files can expose _options_ and implement _configurations_
|
|
||||||
based on how the options are set.
|
|
||||||
|
|
||||||
Create a file for them on either `modules/nixos` or `modules/home-manager`. Be
|
|
||||||
sure to also add them to the listing at `modules/nixos/default.nix` or
|
|
||||||
`modules/home-manager/default.nix`.
|
|
||||||
|
|
||||||
See [the wiki article](https://nixos.wiki/wiki/Module) to learn more about
|
|
||||||
them.
|
|
||||||
|
|
||||||
# Troubleshooting / FAQ
|
|
||||||
|
|
||||||
Please [let me know](https://github.com/Misterio77/nix-starter-config/issues)
|
|
||||||
any questions or issues you face with these templates, so I can add more info
|
|
||||||
here!
|
|
||||||
|
|
||||||
## Nix says my repo files don't exist, even though they do!
|
|
||||||
|
|
||||||
Nix flakes only see files that git is currently tracked, so just `git add .`
|
|
||||||
and you should be good to go. Files on `.gitignore`, of course, are invisible
|
|
||||||
to nix - this is to guarantee your build won't depend on anything that is not
|
|
||||||
on your repo.
|
|
||||||
|
|
||||||
<!--
|
|
||||||
# Learning resources
|
|
||||||
TODO
|
|
||||||
-->
|
|
||||||
26
config/base.nix
Normal file
26
config/base.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{ lib, hostname, ... }:
|
||||||
|
{
|
||||||
|
environment.etc.issue.text = "\\e{lightcyan}\\S\\e{reset} Login (\\l)\n\n";
|
||||||
|
networking.hostName = hostname;
|
||||||
|
system.stateVersion = "24.11";
|
||||||
|
systemd.services."systemd-machine-id-commit".enable = lib.mkForce false;
|
||||||
|
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
nixosFiles = [
|
||||||
|
"/etc/machine-id"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
15
config/hosts/imxyy-nix-server/ai.nix
Normal file
15
config/hosts/imxyy-nix-server/ai.nix
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.open-webui = {
|
||||||
|
enable = true;
|
||||||
|
host = "127.0.0.1";
|
||||||
|
port = 8089;
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."ai.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8089 {
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
11
config/hosts/imxyy-nix-server/caddy.nix
Normal file
11
config/hosts/imxyy-nix-server/caddy.nix
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.caddy = {
|
||||||
|
enable = true;
|
||||||
|
email = "acme@imxyy.top";
|
||||||
|
};
|
||||||
|
security.acme = {
|
||||||
|
acceptTerms = true;
|
||||||
|
defaults.email = "acme@imxyy.top";
|
||||||
|
};
|
||||||
|
}
|
||||||
38
config/hosts/imxyy-nix-server/code.nix
Normal file
38
config/hosts/imxyy-nix-server/code.nix
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{ 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}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
26
config/hosts/imxyy-nix-server/default.nix
Normal file
26
config/hosts/imxyy-nix-server/default.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
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
|
||||||
|
];
|
||||||
|
}
|
||||||
9
config/hosts/imxyy-nix-server/docker.nix
Normal file
9
config/hosts/imxyy-nix-server/docker.nix
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers.backend = lib.mkForce "podman";
|
||||||
|
virtualisation.podman = {
|
||||||
|
enable = true;
|
||||||
|
dockerCompat = true;
|
||||||
|
dockerSocket.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
46
config/hosts/imxyy-nix-server/gitea.nix
Normal file
46
config/hosts/imxyy-nix-server/gitea.nix
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.caddy.virtualHosts."git.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8082 {
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
services.gitea = {
|
||||||
|
enable = true;
|
||||||
|
appName = "imxyy_soope_'s Gitea";
|
||||||
|
user = "git";
|
||||||
|
group = "git";
|
||||||
|
mailerPasswordFile = "/var/lib/gitea/smtp_password";
|
||||||
|
stateDir = "/mnt/nas/gitea";
|
||||||
|
settings = {
|
||||||
|
globalSection = {
|
||||||
|
LANDING_PAGE = "explore";
|
||||||
|
};
|
||||||
|
server = {
|
||||||
|
DOMAIN = "git.imxyy.top";
|
||||||
|
HTTP_ADDR = "127.0.0.1";
|
||||||
|
HTTP_PORT = 8082;
|
||||||
|
ROOT_URL = "https://git.imxyy.top/";
|
||||||
|
SSH_PORT = 2222;
|
||||||
|
};
|
||||||
|
service = {
|
||||||
|
REGISTER_MANUAL_CONFIRM = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.openssh.ports = [
|
||||||
|
22
|
||||||
|
2222
|
||||||
|
];
|
||||||
|
users = {
|
||||||
|
users.git = {
|
||||||
|
isNormalUser = true;
|
||||||
|
description = "git user";
|
||||||
|
group = "git";
|
||||||
|
home = "/mnt/nas/gitea";
|
||||||
|
};
|
||||||
|
groups.git = { };
|
||||||
|
};
|
||||||
|
}
|
||||||
45
config/hosts/imxyy-nix-server/grafana.nix
Normal file
45
config/hosts/imxyy-nix-server/grafana.nix
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{ 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}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
99
config/hosts/imxyy-nix-server/hardware.nix
Normal file
99
config/hosts/imxyy-nix-server/hardware.nix
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"xhci_pci"
|
||||||
|
"ahci"
|
||||||
|
"nvme"
|
||||||
|
"usbhid"
|
||||||
|
"usb_storage"
|
||||||
|
"sd_mod"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||||
|
boot.kernelModules = [ "kvm-amd" ];
|
||||||
|
boot.kernelPackages = lib.mkForce pkgs.stable.linuxKernel.packages.linux_zen;
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
boot.supportedFilesystems = [ "zfs" ];
|
||||||
|
boot.zfs = {
|
||||||
|
extraPools = [ "data" ];
|
||||||
|
forceImportRoot = false;
|
||||||
|
};
|
||||||
|
services.zfs.autoScrub.enable = true;
|
||||||
|
services.btrfs.autoScrub.enable = true;
|
||||||
|
networking.hostId = "10ca95b4";
|
||||||
|
|
||||||
|
fileSystems."/" = {
|
||||||
|
device = "/dev/disk/by-uuid/c7889c5c-c5b6-4e3c-9645-dfd49c2e84d0";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"compress=zstd"
|
||||||
|
"subvol=root"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/nix" = {
|
||||||
|
device = "/dev/disk/by-uuid/c7889c5c-c5b6-4e3c-9645-dfd49c2e84d0";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"compress=zstd"
|
||||||
|
"subvol=nix"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/persistent" = {
|
||||||
|
device = "/dev/disk/by-uuid/c7889c5c-c5b6-4e3c-9645-dfd49c2e84d0";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"compress=zstd"
|
||||||
|
"subvol=persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||||
|
mkdir /btrfs_tmp
|
||||||
|
mount /dev/disk/by-uuid/c7889c5c-c5b6-4e3c-9645-dfd49c2e84d0 /btrfs_tmp
|
||||||
|
mkdir -p /btrfs_tmp/old_roots
|
||||||
|
if [[ -e /btrfs_tmp/root ]]; then
|
||||||
|
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
|
||||||
|
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
delete_subvolume_recursively() {
|
||||||
|
IFS=$'\n'
|
||||||
|
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||||
|
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||||
|
done
|
||||||
|
btrfs subvolume delete "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +14); do
|
||||||
|
delete_subvolume_recursively "$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
btrfs subvolume create /btrfs_tmp/root
|
||||||
|
umount /btrfs_tmp
|
||||||
|
'';
|
||||||
|
|
||||||
|
fileSystems."/boot" = {
|
||||||
|
device = "/dev/disk/by-uuid/32AA-2998";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
networking.useDHCP = lib.mkDefault false;
|
||||||
|
|
||||||
|
hardware.enableRedistributableFirmware = lib.mkDefault true;
|
||||||
|
hardware.cpu.amd.updateMicrocode = config.hardware.enableRedistributableFirmware;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
|
||||||
|
}
|
||||||
37
config/hosts/imxyy-nix-server/home.nix
Normal file
37
config/hosts/imxyy-nix-server/home.nix
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
my.home = {
|
||||||
|
programs.zsh = {
|
||||||
|
shellAliases = {
|
||||||
|
proxy_on = lib.mkForce "export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890 all_proxy=socks://127.0.0.1:7891";
|
||||||
|
};
|
||||||
|
sessionVariables = {
|
||||||
|
no_proxy = "192.168.3.0/24";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
my = {
|
||||||
|
cmd.all.enable = true;
|
||||||
|
coding.editor.neovim.enable = true;
|
||||||
|
coding.misc.enable = true;
|
||||||
|
coding.langs.lua.enable = true;
|
||||||
|
persist = {
|
||||||
|
enable = true;
|
||||||
|
homeDirs = [
|
||||||
|
"workspace"
|
||||||
|
"Virt"
|
||||||
|
|
||||||
|
".ssh"
|
||||||
|
".local/state"
|
||||||
|
".local/share"
|
||||||
|
".local/share/nvim"
|
||||||
|
".cache"
|
||||||
|
|
||||||
|
".ollama"
|
||||||
|
];
|
||||||
|
nixosDirs = [
|
||||||
|
"/etc/ssh"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
19
config/hosts/imxyy-nix-server/homepage.nix
Normal file
19
config/hosts/imxyy-nix-server/homepage.nix
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers = {
|
||||||
|
containers = {
|
||||||
|
sun-panel = {
|
||||||
|
image = "hslr/sun-panel:latest";
|
||||||
|
volumes = [
|
||||||
|
"/var/lib/sun-panel:/app/conf"
|
||||||
|
];
|
||||||
|
ports = [ "8085:3002" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."home.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8085
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
54
config/hosts/imxyy-nix-server/mail.nix
Normal file
54
config/hosts/imxyy-nix-server/mail.nix
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
services.roundcube = {
|
||||||
|
enable = true;
|
||||||
|
hostName = "mail.imxyy.top";
|
||||||
|
plugins = [
|
||||||
|
"contextmenu"
|
||||||
|
"persistent_login"
|
||||||
|
];
|
||||||
|
package = pkgs.roundcube.withPlugins (
|
||||||
|
plugins: with plugins; [
|
||||||
|
contextmenu
|
||||||
|
persistent_login
|
||||||
|
]
|
||||||
|
);
|
||||||
|
extraConfig = ''
|
||||||
|
# starttls needed for authentication, so the fqdn required to match
|
||||||
|
# the certificate
|
||||||
|
$config['imap_conn_options'] = [
|
||||||
|
'ssl' => [
|
||||||
|
'verify_peer_name' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$config['imap_host'] = "tls://mail10.serv00.com";
|
||||||
|
$config['imap_user'] = "%u";
|
||||||
|
$config['imap_pass'] = "%p";
|
||||||
|
$config['smtp_conn_options'] = [
|
||||||
|
'ssl' => [
|
||||||
|
'verify_peer_name' => false,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$config['smtp_host'] = "tls://mail10.serv00.com";
|
||||||
|
$config['smtp_user'] = "%u";
|
||||||
|
$config['smtp_pass'] = "%p";
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
services.nginx.virtualHosts."mail.imxyy.top" = {
|
||||||
|
listen = [
|
||||||
|
{
|
||||||
|
addr = "0.0.0.0";
|
||||||
|
port = 8087;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
forceSSL = false;
|
||||||
|
enableACME = false;
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."mail.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8087 {
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
47
config/hosts/imxyy-nix-server/matrix.nix
Normal file
47
config/hosts/imxyy-nix-server/matrix.nix
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.matrix-synapse = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
server_name = "matrix.imxyy.top";
|
||||||
|
public_baseurl = "https://matrix.imxyy.top";
|
||||||
|
listeners = [
|
||||||
|
{
|
||||||
|
port = 8094;
|
||||||
|
bind_addresses = [ "127.0.0.1" ];
|
||||||
|
type = "http";
|
||||||
|
tls = false;
|
||||||
|
x_forwarded = true;
|
||||||
|
resources = [
|
||||||
|
{
|
||||||
|
names = [
|
||||||
|
"client"
|
||||||
|
"federation"
|
||||||
|
];
|
||||||
|
compress = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
turn_uris = [ "turns:vkvm.imxyy.top:5349" ];
|
||||||
|
turn_shared_secret = "ac779a48c03bb451839569d295a29aa6ab8c264277bec2df9c9c7f5e22936288";
|
||||||
|
turn_user_lifetime = "1h";
|
||||||
|
database_type = "psycopg2";
|
||||||
|
database_args.database = "matrix-synapse";
|
||||||
|
};
|
||||||
|
extraConfigFiles = [
|
||||||
|
"/var/lib/matrix-synapse/secret"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."matrix.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8094
|
||||||
|
handle_path /_matrix {
|
||||||
|
reverse_proxy :8094
|
||||||
|
}
|
||||||
|
handle_path /_synapse/client {
|
||||||
|
reverse_proxy :8094
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
19
config/hosts/imxyy-nix-server/minecraft.nix
Normal file
19
config/hosts/imxyy-nix-server/minecraft.nix
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{ 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 = "10s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
my.persist = {
|
||||||
|
nixosDirs = [
|
||||||
|
"/opt/minecraft"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
26
config/hosts/imxyy-nix-server/minio.nix
Normal file
26
config/hosts/imxyy-nix-server/minio.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{ config, sopsRoot, ... }:
|
||||||
|
{
|
||||||
|
sops.secrets.minio-env = {
|
||||||
|
sopsFile = sopsRoot + /minio.env;
|
||||||
|
format = "dotenv";
|
||||||
|
};
|
||||||
|
services.minio = {
|
||||||
|
enable = true;
|
||||||
|
listenAddress = ":9000";
|
||||||
|
consoleAddress = ":9001";
|
||||||
|
region = "cn-south-gz";
|
||||||
|
|
||||||
|
configDir = "/mnt/nas/minio/config";
|
||||||
|
dataDir = [
|
||||||
|
"/mnt/nas/minio/data"
|
||||||
|
];
|
||||||
|
rootCredentialsFile = config.sops.secrets.minio-env.path;
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."minio.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
handle_path /* {
|
||||||
|
reverse_proxy :9000
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
645
config/hosts/imxyy-nix-server/net.nix
Normal file
645
config/hosts/imxyy-nix-server/net.nix
Normal file
@@ -0,0 +1,645 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
username,
|
||||||
|
sopsRoot,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
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.1"
|
||||||
|
];
|
||||||
|
|
||||||
|
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 AAAAC3NzaC1lZDI1NTE5AAAAIKqza/3b6a9JxsNxytHF5GPe4gQhbLrKxAPyZ0GpfVQt imxyy-hisense-pad"
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8pivvE8PMtsOxmccfNhH/4KehDKhBfUfJbQZxo/SZT imxyy-ace5"
|
||||||
|
];
|
||||||
|
users.users.${username}.openssh.authorizedKeys.keys = [
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOEFLUkyeaK8ZPPZdVNEmtx8zvoxi7xqS2Z6oxRBuUPO imxyy@imxyy-nix"
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKqza/3b6a9JxsNxytHF5GPe4gQhbLrKxAPyZ0GpfVQt imxyy-hisense-pad"
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8pivvE8PMtsOxmccfNhH/4KehDKhBfUfJbQZxo/SZT imxyy-ace5"
|
||||||
|
];
|
||||||
|
|
||||||
|
sops.secrets.dae-imxyy-nix-server = {
|
||||||
|
sopsFile = sopsRoot + /dae-imxyy-nix-server.dae;
|
||||||
|
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 = sopsRoot + /mihomo.yaml;
|
||||||
|
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 = sopsRoot + /frp.env;
|
||||||
|
format = "dotenv";
|
||||||
|
};
|
||||||
|
systemd.services.frp.serviceConfig.EnvironmentFile = [
|
||||||
|
config.sops.secrets.frp-env.path
|
||||||
|
];
|
||||||
|
services.frp = {
|
||||||
|
enable = true;
|
||||||
|
role = "client";
|
||||||
|
settings = {
|
||||||
|
serverAddr = "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-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 = "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 = {
|
||||||
|
base_domain = "tailnet.imxyy.top";
|
||||||
|
extra_records = [
|
||||||
|
{
|
||||||
|
"name" = "home.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "nextcloud.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "mail.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "git.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "vault.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "mc.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "home.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "coder.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"name" = "music.imxyy.top";
|
||||||
|
"type" = "A";
|
||||||
|
"value" = "100.64.0.2";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
ip_prefixes = "100.64.0.0/10";
|
||||||
|
derp.paths = [
|
||||||
|
(toString (
|
||||||
|
pkgs.writeText "derp.yaml" ''
|
||||||
|
regions:
|
||||||
|
900:
|
||||||
|
regionid: 900
|
||||||
|
regioncode: custom-tok
|
||||||
|
regionname: imxyy_soope_ Tokyo
|
||||||
|
nodes:
|
||||||
|
- name: 900a
|
||||||
|
regionid: 900
|
||||||
|
hostname: vkvm.imxyy.top
|
||||||
|
# 901:
|
||||||
|
# regionid: 901
|
||||||
|
# regioncode: custom-cn
|
||||||
|
# regionname: imxyy_soope_ Hu Bei
|
||||||
|
# nodes:
|
||||||
|
# - name: 901a
|
||||||
|
# regionid: 901
|
||||||
|
# hostname: ry.imxyy.top
|
||||||
|
# derpport: 1443
|
||||||
|
''
|
||||||
|
))
|
||||||
|
];
|
||||||
|
derp.urls = lib.mkForce [ ];
|
||||||
|
|
||||||
|
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";
|
||||||
|
strip_email_domain = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
systemd.services."headscale" = {
|
||||||
|
serviceConfig = {
|
||||||
|
Restart = lib.mkOverride 500 "always";
|
||||||
|
RestartMaxDelaySec = lib.mkOverride 500 "1m";
|
||||||
|
RestartSec = lib.mkOverride 500 "100ms";
|
||||||
|
RestartSteps = lib.mkOverride 500 9;
|
||||||
|
};
|
||||||
|
after = [
|
||||||
|
"podman-obligator.service"
|
||||||
|
];
|
||||||
|
requires = [
|
||||||
|
"podman-obligator.service"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
sops.secrets.et-imxyy-nix-server = {
|
||||||
|
sopsFile = sopsRoot + /et-imxyy-nix-server.toml;
|
||||||
|
format = "binary";
|
||||||
|
};
|
||||||
|
environment.systemPackages = [ pkgs.easytier ];
|
||||||
|
systemd.services."easytier" = {
|
||||||
|
enable = true;
|
||||||
|
script = "easytier-core -c ${config.sops.secrets.et-imxyy-nix-server.path}";
|
||||||
|
serviceConfig = {
|
||||||
|
Restart = lib.mkOverride 500 "always";
|
||||||
|
RestartMaxDelaySec = lib.mkOverride 500 "1m";
|
||||||
|
RestartSec = lib.mkOverride 500 "100ms";
|
||||||
|
RestartSteps = lib.mkOverride 500 9;
|
||||||
|
User = "root";
|
||||||
|
};
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [
|
||||||
|
"network.target"
|
||||||
|
"sops-nix.service"
|
||||||
|
];
|
||||||
|
path = with pkgs; [
|
||||||
|
easytier
|
||||||
|
iproute2
|
||||||
|
bash
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.dnsmasq =
|
||||||
|
let
|
||||||
|
subDomains = [
|
||||||
|
"home"
|
||||||
|
"nextcloud"
|
||||||
|
"mail"
|
||||||
|
"git"
|
||||||
|
"vault"
|
||||||
|
"coder"
|
||||||
|
"headscale"
|
||||||
|
"oidc"
|
||||||
|
"mc"
|
||||||
|
"music"
|
||||||
|
"ai"
|
||||||
|
];
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
143
config/hosts/imxyy-nix-server/nextcloud.nix
Normal file
143
config/hosts/imxyy-nix-server/nextcloud.nix
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
hostname,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
nextcloud = "nextcloud.${imxyy}";
|
||||||
|
imxyy = "imxyy.top";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
exiftool
|
||||||
|
ffmpeg
|
||||||
|
rclone
|
||||||
|
];
|
||||||
|
|
||||||
|
services.nextcloud = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.nextcloud31;
|
||||||
|
extraApps = {
|
||||||
|
inherit (pkgs.nextcloud31.packages.apps)
|
||||||
|
bookmarks
|
||||||
|
previewgenerator
|
||||||
|
spreed
|
||||||
|
notes
|
||||||
|
registration
|
||||||
|
;
|
||||||
|
};
|
||||||
|
extraAppsEnable = true;
|
||||||
|
hostName = nextcloud;
|
||||||
|
home = "/mnt/nas/nextcloud";
|
||||||
|
https = true;
|
||||||
|
nginx.recommendedHttpHeaders = true;
|
||||||
|
caching.redis = true;
|
||||||
|
configureRedis = true;
|
||||||
|
database.createLocally = 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"
|
||||||
|
];
|
||||||
|
phpExtraExtensions =
|
||||||
|
all: with all; [
|
||||||
|
pdlib
|
||||||
|
];
|
||||||
|
maxUploadSize = "16G";
|
||||||
|
phpOptions = {
|
||||||
|
"opcache.enable" = 1;
|
||||||
|
"opcache.enable_cli" = 1;
|
||||||
|
"opcache.interned_strings_buffer" = 8;
|
||||||
|
"opcache.max_accelerated_files" = 10000;
|
||||||
|
"opcache.memory_consumption" = 128;
|
||||||
|
"opcache.save_comments" = 1;
|
||||||
|
"opcache.revalidate_freq" = 1;
|
||||||
|
memory_limit = lib.mkForce "2G";
|
||||||
|
};
|
||||||
|
poolSettings = {
|
||||||
|
pm = "dynamic";
|
||||||
|
"pm.max_children" = "12";
|
||||||
|
"pm.min_spare_servers" = "6";
|
||||||
|
"pm.max_spare_servers" = "12";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.nginx.virtualHosts."nextcloud.imxyy.top" = {
|
||||||
|
listen = [
|
||||||
|
{
|
||||||
|
addr = "0.0.0.0";
|
||||||
|
port = 8084;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
services.caddy.virtualHosts.":80" = {
|
||||||
|
extraConfig = ''
|
||||||
|
redir https://{host}{uri}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts.":443" = {
|
||||||
|
extraConfig =
|
||||||
|
let
|
||||||
|
path = "/var/lib/caddy/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/nextcloud.imxyy.top";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
reverse_proxy :8084
|
||||||
|
tls ${path}/nextcloud.imxyy.top.crt ${path}/nextcloud.imxyy.top.key
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
services.caddy.virtualHosts."nextcloud.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8084 {
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
systemd.timers."kopia" = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "daily";
|
||||||
|
Persistent = true;
|
||||||
|
Unit = "kopia.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
systemd.services."kopia" = {
|
||||||
|
script = ''
|
||||||
|
${pkgs.kopia}/bin/kopia snapshot create /mnt/nas/share
|
||||||
|
${pkgs.kopia}/bin/kopia snapshot create /mnt/nas/nextcloud/data
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "nextcloud";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers."nextcloud-cronjobs" = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "daily";
|
||||||
|
Persistent = true;
|
||||||
|
Unit = "nextcloud-cronjobs.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services."nextcloud-cronjobs" = {
|
||||||
|
script = ''
|
||||||
|
/run/current-system/sw/bin/nextcloud-occ preview:pre-generate
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "nextcloud";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
15
config/hosts/imxyy-nix-server/nginx.nix
Normal file
15
config/hosts/imxyy-nix-server/nginx.nix
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
recommendedGzipSettings = true;
|
||||||
|
recommendedOptimisation = true;
|
||||||
|
recommendedProxySettings = true;
|
||||||
|
recommendedTlsSettings = true;
|
||||||
|
clientMaxBodySize = "0";
|
||||||
|
};
|
||||||
|
security.acme = {
|
||||||
|
acceptTerms = true;
|
||||||
|
defaults.email = "acme@imxyy.top";
|
||||||
|
};
|
||||||
|
}
|
||||||
32
config/hosts/imxyy-nix-server/nixos.nix
Normal file
32
config/hosts/imxyy-nix-server/nixos.nix
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
username,
|
||||||
|
sopsRoot,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
boot.loader = {
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
systemd-boot.enable = true;
|
||||||
|
grub.enable = false;
|
||||||
|
timeout = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
hardware.bluetooth.enable = true;
|
||||||
|
hardware.bluetooth.powerOnBoot = true;
|
||||||
|
|
||||||
|
systemd.services.nix-daemon = {
|
||||||
|
environment.TMPDIR = "/var/cache/nix";
|
||||||
|
serviceConfig.CacheDirectory = "nix";
|
||||||
|
};
|
||||||
|
environment.variables.NIX_REMOTE = "daemon";
|
||||||
|
|
||||||
|
sops.secrets.imxyy-nix-server-hashed-password = {
|
||||||
|
sopsFile = sopsRoot + /imxyy-nix-server-hashed-password.txt;
|
||||||
|
format = "binary";
|
||||||
|
};
|
||||||
|
users.users.${username}.hashedPasswordPath =
|
||||||
|
lib.mkForce config.sops.secrets.imxyy-nix-server-hashed-password.path;
|
||||||
|
users.users.root.hashedPassword = lib.mkForce config.sops.secrets.imxyy-nix-server-hashed-password.path;
|
||||||
|
}
|
||||||
61
config/hosts/imxyy-nix-server/note.nix
Normal file
61
config/hosts/imxyy-nix-server/note.nix
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
sopsRoot,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
sops.secrets = {
|
||||||
|
flatnote-env = {
|
||||||
|
sopsFile = sopsRoot + /flatnote.env;
|
||||||
|
format = "dotenv";
|
||||||
|
};
|
||||||
|
siyuan-env = {
|
||||||
|
sopsFile = sopsRoot + /siyuan.env;
|
||||||
|
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.24";
|
||||||
|
volumes = [
|
||||||
|
"/mnt/nas/siyuan/workspace:/workspace"
|
||||||
|
"/mnt/nas/siyuan:/home/siyuan"
|
||||||
|
];
|
||||||
|
cmd = [
|
||||||
|
"--workspace=/workspace"
|
||||||
|
];
|
||||||
|
environment = {
|
||||||
|
PUID = "0";
|
||||||
|
PGID = "0";
|
||||||
|
};
|
||||||
|
environmentFiles = [
|
||||||
|
"${config.sops.secrets.siyuan-env.path}"
|
||||||
|
];
|
||||||
|
ports = [ "8095:6806" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts = {
|
||||||
|
"note.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8093
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
"sy.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8095
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
36
config/hosts/imxyy-nix-server/samba.nix
Normal file
36
config/hosts/imxyy-nix-server/samba.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.samba = {
|
||||||
|
enable = true;
|
||||||
|
nsswins = true;
|
||||||
|
settings = {
|
||||||
|
global = {
|
||||||
|
security = "user";
|
||||||
|
"netbios name" = "NAS";
|
||||||
|
};
|
||||||
|
share = {
|
||||||
|
path = "/mnt/nas/share";
|
||||||
|
browseable = "yes";
|
||||||
|
"read only" = "no";
|
||||||
|
"guest ok" = "no";
|
||||||
|
"create mask" = "0664";
|
||||||
|
"directory mask" = "0775";
|
||||||
|
"force user" = "nextcloud";
|
||||||
|
"force group" = "nextcloud";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.samba-wsdd.enable = true;
|
||||||
|
# ensure dir exists
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"d /mnt/nas/share 0775 nextcloud nextcloud - -"
|
||||||
|
];
|
||||||
|
users = {
|
||||||
|
users.nas = {
|
||||||
|
isNormalUser = true;
|
||||||
|
home = "/var/empty";
|
||||||
|
description = "nas user";
|
||||||
|
group = "nextcloud";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
31
config/hosts/imxyy-nix-server/vault.nix
Normal file
31
config/hosts/imxyy-nix-server/vault.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{ config, sopsRoot, ... }:
|
||||||
|
{
|
||||||
|
sops.secrets.vaultwarden-env = {
|
||||||
|
sopsFile = sopsRoot + /vaultwarden.env;
|
||||||
|
format = "dotenv";
|
||||||
|
};
|
||||||
|
services.postgresql.ensureUsers = [
|
||||||
|
{
|
||||||
|
name = "vaultwarden";
|
||||||
|
ensureDBOwnership = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
services.postgresql.ensureDatabases = [ "vaultwarden" ];
|
||||||
|
services.vaultwarden = {
|
||||||
|
enable = true;
|
||||||
|
dbBackend = "postgresql";
|
||||||
|
config = {
|
||||||
|
ROCKET_ADDRESS = "127.0.0.1";
|
||||||
|
ROCKET_PORT = 8083;
|
||||||
|
DOMAIN = "https://vault.imxyy.top";
|
||||||
|
};
|
||||||
|
environmentFile = "${config.sops.secrets.vaultwarden-env.path}";
|
||||||
|
};
|
||||||
|
services.caddy.virtualHosts."vault.imxyy.top" = {
|
||||||
|
extraConfig = ''
|
||||||
|
reverse_proxy :8083 {
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
28
config/hosts/imxyy-nix-server/virt.nix
Normal file
28
config/hosts/imxyy-nix-server/virt.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
# T400
|
||||||
|
gpuIDs = [
|
||||||
|
"8086:56a0" # A770
|
||||||
|
|
||||||
|
"10de:1f82" # 1650
|
||||||
|
"10de:10fa" # 1650
|
||||||
|
|
||||||
|
"10de:1fb2" # T400
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
boot = {
|
||||||
|
initrd.kernelModules = [
|
||||||
|
"vfio_pci"
|
||||||
|
"vfio"
|
||||||
|
"vfio_iommu_type1"
|
||||||
|
];
|
||||||
|
kernelParams = [
|
||||||
|
"pcie_acs_override=downstream,multifunction"
|
||||||
|
"amd_iommu=on"
|
||||||
|
"vfio-pci.ids=${lib.concatStringsSep "," gpuIDs}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
virtualisation.spiceUSBRedirection.enable = true;
|
||||||
|
my.virt.enable = true;
|
||||||
|
}
|
||||||
24
config/hosts/imxyy-nix-server/yesplaymusic.nix
Normal file
24
config/hosts/imxyy-nix-server/yesplaymusic.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
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}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
7
config/hosts/imxyy-nix-wsl/default.nix
Normal file
7
config/hosts/imxyy-nix-wsl/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./nixos.nix
|
||||||
|
./home.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
13
config/hosts/imxyy-nix-wsl/home.nix
Normal file
13
config/hosts/imxyy-nix-wsl/home.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
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 = {
|
||||||
|
coding.all.enable = true;
|
||||||
|
cmd.misc.enable = true;
|
||||||
|
xdg.enable = true;
|
||||||
|
cmd.media.all.enable = true;
|
||||||
|
desktop.media.all.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
17
config/hosts/imxyy-nix-wsl/nixos.nix
Normal file
17
config/hosts/imxyy-nix-wsl/nixos.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{ username, nixos-wsl, ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
nixos-wsl.nixosModules.wsl
|
||||||
|
];
|
||||||
|
wsl.enable = true;
|
||||||
|
wsl.defaultUser = "${username}";
|
||||||
|
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
# Forbid root login through SSH.
|
||||||
|
PermitRootLogin = "no";
|
||||||
|
PasswordAuthentication = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
10
config/hosts/imxyy-nix/default.nix
Normal file
10
config/hosts/imxyy-nix/default.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./nixos.nix
|
||||||
|
./hardware.nix
|
||||||
|
./home.nix
|
||||||
|
./virt.nix
|
||||||
|
./net.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
165
config/hosts/imxyy-nix/hardware.nix
Normal file
165
config/hosts/imxyy-nix/hardware.nix
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
username,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
boot = {
|
||||||
|
initrd = {
|
||||||
|
kernelModules = [ "amdgpu" ];
|
||||||
|
availableKernelModules = [
|
||||||
|
"xhci_pci"
|
||||||
|
"ahci"
|
||||||
|
"nvme"
|
||||||
|
"usbhid"
|
||||||
|
"usb_storage"
|
||||||
|
"sd_mod"
|
||||||
|
];
|
||||||
|
verbose = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
kernelPackages = lib.mkForce pkgs.linuxKernel.packages.linux_zen;
|
||||||
|
kernelModules = [ "kvm-amd" ];
|
||||||
|
|
||||||
|
tmp.useTmpfs = true;
|
||||||
|
kernel.sysctl = {
|
||||||
|
"fs.file-max" = 9223372036854775807;
|
||||||
|
};
|
||||||
|
|
||||||
|
resumeDevice = "/dev/disk/by-uuid/0404de0a-9c4d-4c98-b3e5-b8ff8115f36c";
|
||||||
|
kernelParams = [
|
||||||
|
"resume_offset=6444127"
|
||||||
|
|
||||||
|
# "quiet"
|
||||||
|
# "splash"
|
||||||
|
# "log_level=3"
|
||||||
|
];
|
||||||
|
consoleLogLevel = 3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
plymouth = {
|
||||||
|
enable = true;
|
||||||
|
theme = "bgrt";
|
||||||
|
themePackages = [ pkgs.nixos-bgrt-plymouth ];
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/" = {
|
||||||
|
device = "/dev/disk/by-uuid/0404de0a-9c4d-4c98-b3e5-b8ff8115f36c";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"compress=zstd"
|
||||||
|
"subvol=root"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/nix" = {
|
||||||
|
device = "/dev/disk/by-uuid/843c36ae-f6d0-46a1-b5c7-8ab569e1e63f";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [ "compress=zstd" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/persistent" = {
|
||||||
|
device = "/dev/disk/by-uuid/0404de0a-9c4d-4c98-b3e5-b8ff8115f36c";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"compress=zstd"
|
||||||
|
"subvol=persistent"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/swap" = {
|
||||||
|
device = "/dev/disk/by-uuid/0404de0a-9c4d-4c98-b3e5-b8ff8115f36c";
|
||||||
|
fsType = "btrfs";
|
||||||
|
options = [
|
||||||
|
"compress=zstd"
|
||||||
|
"subvol=swap"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||||
|
mkdir /btrfs_tmp
|
||||||
|
mount /dev/disk/by-uuid/0404de0a-9c4d-4c98-b3e5-b8ff8115f36c /btrfs_tmp
|
||||||
|
mkdir -p /btrfs_tmp/old_roots
|
||||||
|
if [[ -e /btrfs_tmp/root ]]; then
|
||||||
|
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
|
||||||
|
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
delete_subvolume_recursively() {
|
||||||
|
IFS=$'\n'
|
||||||
|
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||||
|
delete_subvolume_recursively "/btrfs_tmp/$i"
|
||||||
|
done
|
||||||
|
btrfs subvolume delete "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +14); do
|
||||||
|
delete_subvolume_recursively "$i"
|
||||||
|
done
|
||||||
|
|
||||||
|
btrfs subvolume create /btrfs_tmp/root
|
||||||
|
umount /btrfs_tmp
|
||||||
|
'';
|
||||||
|
|
||||||
|
fileSystems."/boot" = {
|
||||||
|
device = "/dev/disk/by-uuid/B7DC-E9AC";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/home/${username}/Documents" = {
|
||||||
|
device = "/dev/disk/by-uuid/a4e37dcd-764a-418c-aa1c-484f1fbd4bbe";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/home/${username}/Downloads" = {
|
||||||
|
device = "/dev/disk/by-uuid/18717cb4-49ac-40fa-95d4-29523a458dd0";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/home/${username}/Videos" = {
|
||||||
|
device = "/dev/disk/by-uuid/b67bbeab-58bc-4814-b5e3-08404e78b25e";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/home/${username}/Pictures" = {
|
||||||
|
device = "/dev/disk/by-uuid/a31bfe7e-cc17-4bd2-af74-ae5de9be35d3";
|
||||||
|
fsType = "ext4";
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSystems."/home/${username}/Music" = {
|
||||||
|
device = "//192.168.3.2/share/imxyy_soope_/Music";
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = [
|
||||||
|
{
|
||||||
|
device = "/swap/swapfile";
|
||||||
|
size = 32 * 1024;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
networking.useDHCP = lib.mkDefault false;
|
||||||
|
|
||||||
|
hardware.enableRedistributableFirmware = lib.mkDefault true;
|
||||||
|
hardware.cpu.amd.updateMicrocode = config.hardware.enableRedistributableFirmware;
|
||||||
|
|
||||||
|
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
|
||||||
|
}
|
||||||
215
config/hosts/imxyy-nix/home.nix
Normal file
215
config/hosts/imxyy-nix/home.nix
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
username,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
my.home = {
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
localsend
|
||||||
|
|
||||||
|
rclone
|
||||||
|
|
||||||
|
wpsoffice-cn
|
||||||
|
wps-office-fonts
|
||||||
|
evince
|
||||||
|
# siyuan-unlock
|
||||||
|
|
||||||
|
anki
|
||||||
|
|
||||||
|
ayugram-desktop
|
||||||
|
telegram-desktop
|
||||||
|
signal-desktop
|
||||||
|
cinny-desktop
|
||||||
|
discord
|
||||||
|
qq
|
||||||
|
|
||||||
|
gnome-clocks
|
||||||
|
|
||||||
|
wineWowPackages.waylandFull
|
||||||
|
|
||||||
|
pavucontrol
|
||||||
|
pamixer
|
||||||
|
];
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
sessionVariables = {
|
||||||
|
no_proxy = "192.168.3.0/24";
|
||||||
|
PATH = "/home/${username}/bin:$PATH";
|
||||||
|
};
|
||||||
|
profileExtra = ''
|
||||||
|
if [ `tty` = "/dev/tty1" -a $XDG_RUNTIME_DIR ]; then
|
||||||
|
echo 'Starting Niri...'
|
||||||
|
exec uwsm start niri-uwsm.desktop
|
||||||
|
elif [ `tty` = "/dev/tty6" ]; then
|
||||||
|
clear
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.niri.settings.outputs = {
|
||||||
|
DP-2 = {
|
||||||
|
enable = true;
|
||||||
|
mode = {
|
||||||
|
width = 2560;
|
||||||
|
height = 1440;
|
||||||
|
refresh = 75.033;
|
||||||
|
};
|
||||||
|
scale = 1.25;
|
||||||
|
position = {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
DP-3 = {
|
||||||
|
enable = true;
|
||||||
|
mode = {
|
||||||
|
width = 2560;
|
||||||
|
height = 1440;
|
||||||
|
refresh = 75.033;
|
||||||
|
};
|
||||||
|
scale = 1.25;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
my = {
|
||||||
|
autologin = {
|
||||||
|
enable = true;
|
||||||
|
user = "${username}";
|
||||||
|
ttys = [
|
||||||
|
1
|
||||||
|
6
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
gpg.enable = true;
|
||||||
|
cmd.all.enable = true;
|
||||||
|
coding.all.enable = true;
|
||||||
|
desktop.all.enable = true;
|
||||||
|
|
||||||
|
desktop.wm.dwm.enable = lib.mkForce false;
|
||||||
|
|
||||||
|
desktop.browser.librewolf.enable = lib.mkForce false;
|
||||||
|
|
||||||
|
i18n.fcitx5.enable = true;
|
||||||
|
|
||||||
|
xdg = {
|
||||||
|
enable = true;
|
||||||
|
defaultApplications =
|
||||||
|
let
|
||||||
|
browser = [ "chromium-browser.desktop" ];
|
||||||
|
editor = [ "codium.desktop" ];
|
||||||
|
imageviewer = [ "org.gnome.Shotwell-Viewer.desktop" ];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"inode/directory" = [ "nemo.desktop" ];
|
||||||
|
|
||||||
|
"application/pdf" = [ "evince.desktop" ];
|
||||||
|
|
||||||
|
"text/*" = editor;
|
||||||
|
"application/json" = editor;
|
||||||
|
"text/html" = editor;
|
||||||
|
"text/xml" = editor;
|
||||||
|
"application/xml" = editor;
|
||||||
|
"application/xhtml+xml" = editor;
|
||||||
|
"application/xhtml_xml" = editor;
|
||||||
|
"application/rdf+xml" = editor;
|
||||||
|
"application/rss+xml" = editor;
|
||||||
|
"application/x-extension-htm" = editor;
|
||||||
|
"application/x-extension-html" = editor;
|
||||||
|
"application/x-extension-shtml" = editor;
|
||||||
|
"application/x-extension-xht" = editor;
|
||||||
|
"application/x-extension-xhtml" = editor;
|
||||||
|
|
||||||
|
"x-scheme-handler/about" = browser;
|
||||||
|
"x-scheme-handler/ftp" = browser;
|
||||||
|
"x-scheme-handler/http" = browser;
|
||||||
|
"x-scheme-handler/https" = browser;
|
||||||
|
"x-scheme-handler/unknown" = browser;
|
||||||
|
|
||||||
|
"audio/*" = imageviewer;
|
||||||
|
"video/*" = imageviewer;
|
||||||
|
"image/*" = imageviewer;
|
||||||
|
"image/gif" = imageviewer;
|
||||||
|
"image/jpeg" = imageviewer;
|
||||||
|
"image/png" = imageviewer;
|
||||||
|
"image/webp" = imageviewer;
|
||||||
|
};
|
||||||
|
extraBookmarks =
|
||||||
|
let
|
||||||
|
homedir = config.my.home.home.homeDirectory;
|
||||||
|
in
|
||||||
|
[
|
||||||
|
"file://${homedir}/Documents/%E7%8F%AD%E7%BA%A7%E4%BA%8B%E5%8A%A1 班级事务"
|
||||||
|
"file://${homedir}/NAS NAS"
|
||||||
|
"file://${homedir}/NAS/imxyy_soope_ NAS imxyy_soope_"
|
||||||
|
"file://${homedir}/NAS/imxyy_soope_/OS NAS OS"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
persist = {
|
||||||
|
enable = true;
|
||||||
|
homeDirs = [
|
||||||
|
".android"
|
||||||
|
"Android"
|
||||||
|
|
||||||
|
".ssh"
|
||||||
|
|
||||||
|
"bin"
|
||||||
|
"workspace"
|
||||||
|
"WineApps"
|
||||||
|
"Virt"
|
||||||
|
|
||||||
|
".cache"
|
||||||
|
".local/state"
|
||||||
|
".local/share/Anki2"
|
||||||
|
".local/share/dooit"
|
||||||
|
".local/share/nvim"
|
||||||
|
".local/share/shotwell"
|
||||||
|
".local/share/Steam"
|
||||||
|
".local/share/SteamOS"
|
||||||
|
".local/share/Trash"
|
||||||
|
".local/share/cheat.sh"
|
||||||
|
".local/share/Kingsoft"
|
||||||
|
".local/share/oss.krtirtho.spotube"
|
||||||
|
|
||||||
|
".local/share/AyuGramDesktop"
|
||||||
|
".local/share/TelegramDesktop"
|
||||||
|
".local/share/cinny"
|
||||||
|
".config/Signal"
|
||||||
|
".config/discord"
|
||||||
|
".config/QQ"
|
||||||
|
|
||||||
|
".config/Kingsoft"
|
||||||
|
".config/dconf"
|
||||||
|
".config/gh"
|
||||||
|
".config/pulse"
|
||||||
|
".config/chromium"
|
||||||
|
".config/go-musicfox/db"
|
||||||
|
".config/tmux/plugins"
|
||||||
|
".config/pip"
|
||||||
|
".config/obs-studio"
|
||||||
|
".config/libreoffice"
|
||||||
|
".config/Moonlight Game Streaming Project"
|
||||||
|
".config/sunshine"
|
||||||
|
];
|
||||||
|
nixosDirs = [
|
||||||
|
"/etc/ssh"
|
||||||
|
];
|
||||||
|
homeFiles = [
|
||||||
|
".config/mpd/mpd.db" # requires bindfs
|
||||||
|
".config/go-musicfox/cookie"
|
||||||
|
".hmcl.json"
|
||||||
|
];
|
||||||
|
nixosFiles = [
|
||||||
|
"/etc/davfs2/secrets"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
136
config/hosts/imxyy-nix/net.nix
Normal file
136
config/hosts/imxyy-nix/net.nix
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
sopsRoot,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
boot.kernelParams = [
|
||||||
|
"biosdevname=0"
|
||||||
|
"net.ifnames=0"
|
||||||
|
];
|
||||||
|
networking = {
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
dhcpcd = {
|
||||||
|
wait = "background";
|
||||||
|
IPv6rs = true;
|
||||||
|
extraConfig = ''
|
||||||
|
interface eth0
|
||||||
|
noipv4
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
interfaces = {
|
||||||
|
eth0 = {
|
||||||
|
useDHCP = lib.mkForce true;
|
||||||
|
wakeOnLan.enable = true;
|
||||||
|
macAddress = "3C:7C:3F:7C:D3:9D";
|
||||||
|
ipv4 = {
|
||||||
|
addresses = [
|
||||||
|
{
|
||||||
|
address = "192.168.3.3";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = {
|
||||||
|
address = "192.168.3.1";
|
||||||
|
interface = "eth0";
|
||||||
|
};
|
||||||
|
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 }
|
||||||
|
}
|
||||||
|
|
||||||
|
chain output {
|
||||||
|
type filter hook output priority 100; policy accept;
|
||||||
|
}
|
||||||
|
|
||||||
|
chain input {
|
||||||
|
type filter hook input priority 0; policy drop;
|
||||||
|
iif lo accept
|
||||||
|
ct state invalid drop
|
||||||
|
ct state established,related accept
|
||||||
|
|
||||||
|
ip saddr @LANv4 accept
|
||||||
|
ip6 saddr @LANv6 accept
|
||||||
|
}
|
||||||
|
|
||||||
|
chain forward {
|
||||||
|
type filter hook forward priority 0; policy drop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sops.secrets.dae-imxyy-nix = {
|
||||||
|
sopsFile = sopsRoot + /dae-imxyy-nix.dae;
|
||||||
|
format = "binary";
|
||||||
|
};
|
||||||
|
services.dae = {
|
||||||
|
enable = true;
|
||||||
|
configFile = config.sops.secrets.dae-imxyy-nix.path;
|
||||||
|
};
|
||||||
|
systemd.services.dae.after = [ "sops-nix.service" ];
|
||||||
|
sops.secrets.mihomo = {
|
||||||
|
sopsFile = sopsRoot + /mihomo.yaml;
|
||||||
|
format = "yaml";
|
||||||
|
key = "";
|
||||||
|
};
|
||||||
|
systemd.services.mihomo.after = [ "sops-nix.service" ];
|
||||||
|
services.mihomo = {
|
||||||
|
enable = true;
|
||||||
|
configFile = config.sops.secrets.mihomo.path;
|
||||||
|
webui = pkgs.metacubexd;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.tailscale.enable = true;
|
||||||
|
|
||||||
|
sops.secrets.et-imxyy-nix = {
|
||||||
|
sopsFile = sopsRoot + /et-imxyy-nix.toml;
|
||||||
|
format = "binary";
|
||||||
|
};
|
||||||
|
environment.systemPackages = [ pkgs.easytier ];
|
||||||
|
systemd.services."easytier" = {
|
||||||
|
enable = true;
|
||||||
|
script = "easytier-core -c ${config.sops.secrets.et-imxyy-nix.path}";
|
||||||
|
serviceConfig = {
|
||||||
|
Restart = lib.mkOverride 500 "always";
|
||||||
|
RestartMaxDelaySec = lib.mkOverride 500 "1m";
|
||||||
|
RestartSec = lib.mkOverride 500 "100ms";
|
||||||
|
RestartSteps = lib.mkOverride 500 9;
|
||||||
|
User = "root";
|
||||||
|
};
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [
|
||||||
|
"network.target"
|
||||||
|
"sops-nix.service"
|
||||||
|
];
|
||||||
|
path = with pkgs; [
|
||||||
|
easytier
|
||||||
|
iproute2
|
||||||
|
bash
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
319
config/hosts/imxyy-nix/nixos.nix
Normal file
319
config/hosts/imxyy-nix/nixos.nix
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
username,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
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 usbreset}", f"/dev/bus/usb/{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"):
|
||||||
|
...
|
||||||
|
'';
|
||||||
|
usbreset = pkgs.writeCBin "usbreset" ''
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include <linux/usbdevice_fs.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
const char *filename;
|
||||||
|
int fd;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: usbreset device-filename\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
filename = argv[1];
|
||||||
|
|
||||||
|
fd = open(filename, O_WRONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("Error opening output file");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Resetting USB device %s\n", filename);
|
||||||
|
rc = ioctl(fd, USBDEVFS_RESET, 0);
|
||||||
|
if (rc < 0) {
|
||||||
|
perror("Error in ioctl");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("Reset successful\n");
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
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";
|
||||||
|
|
||||||
|
# services.pipewire.enable = false;
|
||||||
|
security.rtkit.enable = true;
|
||||||
|
services.pipewire = {
|
||||||
|
enable = true;
|
||||||
|
# alsa.enable = true;
|
||||||
|
# alsa.support32Bit = true;
|
||||||
|
# pulse.enable = true;
|
||||||
|
alsa.enable = false;
|
||||||
|
alsa.support32Bit = false;
|
||||||
|
pulse.enable = false;
|
||||||
|
audio.enable = false;
|
||||||
|
configPackages = [
|
||||||
|
/*
|
||||||
|
(pkgs.writeTextDir "share/pipewire/media-session.d/bluez-monitor.conf" ''
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
actions = {
|
||||||
|
update-props = {
|
||||||
|
bluez5.autoswitch-profile = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
'')
|
||||||
|
*/
|
||||||
|
];
|
||||||
|
};
|
||||||
|
services.pipewire.wireplumber.extraConfig = {
|
||||||
|
/*
|
||||||
|
"10-bluez" = {
|
||||||
|
"monitor.bluez.properties" = {
|
||||||
|
"bluez5.enable-sbc-xq" = true;
|
||||||
|
"bluez5.enable-msbc" = true;
|
||||||
|
"bluez5.enable-hw-volume" = true;
|
||||||
|
"bluez5.roles" = [
|
||||||
|
"hsp_hs"
|
||||||
|
"hsp_ag"
|
||||||
|
"hfp_hf"
|
||||||
|
"hfp_ag"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
"11-bluetooth-policy" = {
|
||||||
|
"wireplumber.settings" = {
|
||||||
|
"bluetooth.autoswitch-to-headset-profile" = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
services.pulseaudio = {
|
||||||
|
enable = true;
|
||||||
|
support32Bit = true;
|
||||||
|
package = pkgs.pulseaudioFull;
|
||||||
|
extraConfig = ''
|
||||||
|
load-module module-switch-on-connect
|
||||||
|
unload-module module-suspend-on-idle
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
hardware.bluetooth = {
|
||||||
|
enable = true;
|
||||||
|
powerOnBoot = true;
|
||||||
|
settings = {
|
||||||
|
General.Enable = "Source,Sink,Media,Socket";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
users.extraUsers.${username}.extraGroups = [ "audio" ];
|
||||||
|
|
||||||
|
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"
|
||||||
|
"Noto Color Emoji"
|
||||||
|
];
|
||||||
|
sansSerif = [
|
||||||
|
"Noto Sans CJK SC"
|
||||||
|
"Noto Sans"
|
||||||
|
"Symbols Nerd Font"
|
||||||
|
"Noto Color Emoji"
|
||||||
|
];
|
||||||
|
monospace = [
|
||||||
|
"JetBrains Mono"
|
||||||
|
"Noto Sans Mono CJK SC"
|
||||||
|
"Symbols Nerd Font Mono"
|
||||||
|
"Noto Color Emoji"
|
||||||
|
];
|
||||||
|
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;
|
||||||
|
|
||||||
|
virtualisation.waydroid.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
|
||||||
|
];
|
||||||
|
|
||||||
|
fileSystems =
|
||||||
|
let
|
||||||
|
config = pkgs.writeText "rclone.conf" ''
|
||||||
|
[Nextcloud]
|
||||||
|
type = webdav
|
||||||
|
url = https://192.168.3.2/remote.php/dav/files/imxyy_soope_
|
||||||
|
vendor = nextcloud
|
||||||
|
user = imxyy_soope_
|
||||||
|
pass = C2UUiMyPoynWWKS9kf_Fr8rcoXxgUswPYi4s
|
||||||
|
|
||||||
|
[NAS]
|
||||||
|
type = smb
|
||||||
|
host = 192.168.3.2
|
||||||
|
user = nas
|
||||||
|
pass = O74S6-7jDFykwCvZ8vuIxohh00Ty7XJF
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"/home/${username}/Nextcloud" = {
|
||||||
|
device = "Nextcloud:";
|
||||||
|
fsType = "rclone";
|
||||||
|
options = [
|
||||||
|
"nodev"
|
||||||
|
"nofail"
|
||||||
|
"allow_other"
|
||||||
|
"args2env"
|
||||||
|
"config=${toString config}"
|
||||||
|
"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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
35
config/hosts/imxyy-nix/rule_sets/steamcn.json
Normal file
35
config/hosts/imxyy-nix/rule_sets/steamcn.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"domain": [
|
||||||
|
"cm.steampowered.com",
|
||||||
|
"ol.epicgames.com",
|
||||||
|
"csgo.wmsj.cn",
|
||||||
|
"dota2.wmsj.cn",
|
||||||
|
"wmsjsteam.com",
|
||||||
|
"dl.steam.clngaa.com",
|
||||||
|
"dl.steam.ksyna.com",
|
||||||
|
"gstore.val.manlaxy.com",
|
||||||
|
"st.dl.bscstorage.net",
|
||||||
|
"st.dl.eccdnx.com",
|
||||||
|
"st.dl.pinyuncloud.com",
|
||||||
|
"steampipe.steamcontent.tnkjmec.com",
|
||||||
|
"steampowered.com.8686c.com",
|
||||||
|
"steamstatic.com.8686c.com",
|
||||||
|
"steambroadcast.akamaized.net",
|
||||||
|
"steamcdn-a.akamaihd.net",
|
||||||
|
"steamcommunity-a.akamaihd.net",
|
||||||
|
"steamstore-a.akamaihd.net",
|
||||||
|
"steamusercontent-a.akamaihd.net",
|
||||||
|
"steamuserimages-a.akamaihd.net"
|
||||||
|
],
|
||||||
|
"domain_suffix": [
|
||||||
|
".steamcontent.com",
|
||||||
|
".steamserver.net",
|
||||||
|
".steamchina.com"
|
||||||
|
],
|
||||||
|
"invert": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
12
config/hosts/imxyy-nix/virt.nix
Normal file
12
config/hosts/imxyy-nix/virt.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
hardware.graphics.enable = true;
|
||||||
|
virtualisation.spiceUSBRedirection.enable = true;
|
||||||
|
|
||||||
|
my.virt = {
|
||||||
|
enable = true;
|
||||||
|
moonlight.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
11
docker_proxy.sh
Executable file
11
docker_proxy.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
sudo mkdir -p /run/systemd/system/docker.service.d
|
||||||
|
sudo su -c 'cat << EOF >/run/systemd/system/docker.service.d/override.conf
|
||||||
|
[Service]
|
||||||
|
Environment="http_proxy=http://127.0.0.1:7890"
|
||||||
|
Environment="https_proxy=http://127.0.0.1:7890"
|
||||||
|
Environment="all_proxy=socks5h://127.0.0.1:7891"
|
||||||
|
EOF'
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl restart docker
|
||||||
1419
flake.lock
generated
Normal file
1419
flake.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
239
flake.nix
239
flake.nix
@@ -1,84 +1,205 @@
|
|||||||
{
|
{
|
||||||
description = "Your new nix config";
|
description = "imxyy_soope_'s NixOS (flake) config";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
# Nixpkgs
|
# Nixpkgs
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
||||||
# You can access packages and modules from different nixpkgs revs
|
nixpkgs-stable.url = "github:nixos/nixpkgs/release-24.11";
|
||||||
# at the same time. Here's an working example:
|
nixpkgs-master.url = "github:nixos/nixpkgs/master";
|
||||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
# nixpkgs.follows = "nixpkgs-stable";
|
||||||
# Also see the 'unstable-packages' overlay at 'overlays/default.nix'.
|
nixpkgs.follows = "nixpkgs-unstable";
|
||||||
|
|
||||||
|
# SOPS
|
||||||
|
sops-nix.url = "github:Mic92/sops-nix";
|
||||||
|
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
# Home manager
|
# Home manager
|
||||||
home-manager.url = "github:nix-community/home-manager/release-23.05";
|
home-manager.url = "github:nix-community/home-manager/master";
|
||||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
# TODO: Add any other flake you might need
|
# Impermanence
|
||||||
# hardware.url = "github:nixos/nixos-hardware";
|
impermanence.url = "github:nix-community/impermanence";
|
||||||
|
|
||||||
# Shameless plug: looking for a way to nixify your themes and make
|
# NUR
|
||||||
# everything match nicely? Try nix-colors!
|
nur.url = "github:nix-community/NUR";
|
||||||
# nix-colors.url = "github:misterio77/nix-colors";
|
|
||||||
|
# NeoVim nightly
|
||||||
|
# neovim-nightly.url = "github:nix-community/neovim-nightly-overlay";
|
||||||
|
# neovim-nightly.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
|
||||||
|
|
||||||
|
# OMZ
|
||||||
|
omz.url = "github:imxyy1soope1/omz/master";
|
||||||
|
omz.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
# dwm
|
||||||
|
dwm.url = "github:imxyy1soope1/dwm/master";
|
||||||
|
dwm.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
# Niri
|
||||||
|
niri.url = "github:sodiboo/niri-flake";
|
||||||
|
niri.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
niri.inputs.nixpkgs-stable.follows = "nixpkgs-stable";
|
||||||
|
|
||||||
|
quickshell.url = "git+https://git.outfoxxed.me/outfoxxed/quickshell";
|
||||||
|
quickshell.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
# NixOS-WSL
|
||||||
|
nixos-wsl.url = "github:nix-community/NixOS-WSL";
|
||||||
|
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
fenix.url = "github:nix-community/fenix";
|
||||||
|
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs =
|
||||||
|
{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
home-manager,
|
nixos-wsl,
|
||||||
...
|
...
|
||||||
} @ inputs: let
|
}@inputs:
|
||||||
|
let
|
||||||
inherit (self) outputs;
|
inherit (self) outputs;
|
||||||
# Supported systems for your flake packages, shell, etc.
|
variables = import ./variables.nix;
|
||||||
systems = [
|
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||||
"aarch64-linux"
|
forAllHosts =
|
||||||
"i686-linux"
|
gen:
|
||||||
"x86_64-linux"
|
nixpkgs.lib.attrsets.mergeAttrsList (
|
||||||
"aarch64-darwin"
|
builtins.map (
|
||||||
"x86_64-darwin"
|
{ hostname, ... }@host:
|
||||||
];
|
{
|
||||||
# This is a function that generates an attribute by calling a function you
|
${hostname} = gen host;
|
||||||
# pass to it, with each system as an argument
|
}
|
||||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
) variables.hosts
|
||||||
in {
|
);
|
||||||
# Your custom packages
|
in
|
||||||
# Accessible through 'nix build', 'nix shell', etc
|
{
|
||||||
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
|
packages = forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
|
||||||
# Formatter for your nix files, available through 'nix fmt'
|
formatter = forAllSystems (
|
||||||
# Other options beside 'alejandra' include 'nixpkgs-fmt'
|
system:
|
||||||
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "nixfmt-wrapper";
|
||||||
|
|
||||||
|
runtimeInputs = [
|
||||||
|
pkgs.fd
|
||||||
|
pkgs.nixfmt-rfc-style
|
||||||
|
];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
fd "$@" -t f -e nix -x nixfmt '{}'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
# Your custom packages and modifications, exported as overlays
|
|
||||||
overlays = import ./overlays { inherit inputs; };
|
overlays = import ./overlays { inherit inputs; };
|
||||||
# Reusable nixos modules you might want to export
|
|
||||||
# These are usually stuff you would upstream into nixpkgs
|
|
||||||
nixosModules = import ./modules/nixos;
|
|
||||||
# Reusable home-manager modules you might want to export
|
|
||||||
# These are usually stuff you would upstream into home-manager
|
|
||||||
homeManagerModules = import ./modules/home-manager;
|
|
||||||
|
|
||||||
# NixOS configuration entrypoint
|
# Available through 'nixos-rebuild --flake .#{hostname}'
|
||||||
# Available through 'nixos-rebuild --flake .#your-hostname'
|
nixosConfigurations = forAllHosts (
|
||||||
nixosConfigurations = {
|
{ hostname, system }:
|
||||||
imxyy-nix = nixpkgs.lib.nixosSystem {
|
let
|
||||||
specialArgs = {inherit inputs outputs;};
|
lib = import ./lib/stdlib-extended.nix (
|
||||||
modules = [
|
nixpkgs.lib.extend (
|
||||||
# > Our main nixos configuration file <
|
final: prev: {
|
||||||
./nixos/configuration.nix
|
inherit (inputs.home-manager.lib) hm;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
overlays = builtins.attrValues self.overlays ++ [
|
||||||
|
inputs.go-musicfox.overlays.default
|
||||||
|
inputs.omz.overlays.default
|
||||||
|
inputs.dwm.overlays.default
|
||||||
|
inputs.niri.overlays.niri
|
||||||
|
# inputs.neovim-nightly.overlays.default
|
||||||
|
inputs.fenix.overlays.default
|
||||||
|
inputs.nix-vscode-extensions.overlays.default
|
||||||
|
(final: prev: {
|
||||||
|
darkly-qt5 = inputs.darkly.packages.${final.system}.darkly-qt5;
|
||||||
|
darkly-qt6 = inputs.darkly.packages.${final.system}.darkly-qt6;
|
||||||
|
})
|
||||||
|
(final: prev: {
|
||||||
|
quickshell = inputs.quickshell.packages.${final.system}.default.override {
|
||||||
|
withJemalloc = true;
|
||||||
|
withQtSvg = true;
|
||||||
|
withWayland = true;
|
||||||
|
withPipewire = false;
|
||||||
|
withPam = false;
|
||||||
|
withX11 = false;
|
||||||
|
withHyprland = false;
|
||||||
|
};
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
};
|
specialArgs = {
|
||||||
|
inherit (variables)
|
||||||
|
username
|
||||||
|
userdesc
|
||||||
|
userfullname
|
||||||
|
useremail
|
||||||
|
;
|
||||||
|
|
||||||
# Standalone home-manager configuration entrypoint
|
inherit
|
||||||
# Available through 'home-manager --flake .#your-username@your-hostname'
|
inputs
|
||||||
homeConfigurations = {
|
outputs
|
||||||
"imxyy@imxyy-nix" = home-manager.lib.homeManagerConfiguration {
|
nixos-wsl
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
|
system
|
||||||
extraSpecialArgs = {inherit inputs outputs;};
|
hostname
|
||||||
|
;
|
||||||
|
|
||||||
|
sopsRoot = ./secrets;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.nixosSystem {
|
||||||
|
inherit specialArgs;
|
||||||
modules = [
|
modules = [
|
||||||
# > Our main home-manager configuration file <
|
./modules
|
||||||
./home-manager/home.nix
|
./config/base.nix
|
||||||
];
|
./config/hosts/${hostname}
|
||||||
};
|
{
|
||||||
};
|
nixpkgs = {
|
||||||
|
inherit pkgs;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
inputs.sops-nix.nixosModules.sops
|
||||||
|
inputs.impermanence.nixosModules.impermanence
|
||||||
|
inputs.home-manager.nixosModules.default
|
||||||
|
{
|
||||||
|
home-manager = {
|
||||||
|
sharedModules = [
|
||||||
|
inputs.sops-nix.homeManagerModules.sops
|
||||||
|
inputs.impermanence.nixosModules.home-manager.impermanence
|
||||||
|
inputs.stylix.homeManagerModules.stylix
|
||||||
|
inputs.niri.homeModules.niri
|
||||||
|
(
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = lib.mkForce null;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
|
useGlobalPkgs = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
# This is your home-manager configuration file
|
|
||||||
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
|
|
||||||
{
|
|
||||||
inputs,
|
|
||||||
outputs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: {
|
|
||||||
# You can import other home-manager modules here
|
|
||||||
imports = [
|
|
||||||
# If you want to use modules your own flake exports (from modules/home-manager):
|
|
||||||
# outputs.homeManagerModules.example
|
|
||||||
|
|
||||||
# Or modules exported from other flakes (such as nix-colors):
|
|
||||||
# inputs.nix-colors.homeManagerModules.default
|
|
||||||
|
|
||||||
# You can also split up your configuration and import pieces of it here:
|
|
||||||
# ./nvim.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
nixpkgs = {
|
|
||||||
# You can add overlays here
|
|
||||||
overlays = [
|
|
||||||
# Add overlays your own flake exports (from overlays and pkgs dir):
|
|
||||||
outputs.overlays.additions
|
|
||||||
outputs.overlays.modifications
|
|
||||||
outputs.overlays.unstable-packages
|
|
||||||
|
|
||||||
# You can also add overlays exported from other flakes:
|
|
||||||
# neovim-nightly-overlay.overlays.default
|
|
||||||
|
|
||||||
# Or define it inline, for example:
|
|
||||||
# (final: prev: {
|
|
||||||
# hi = final.hello.overrideAttrs (oldAttrs: {
|
|
||||||
# patches = [ ./change-hello-to-hi.patch ];
|
|
||||||
# });
|
|
||||||
# })
|
|
||||||
];
|
|
||||||
# Configure your nixpkgs instance
|
|
||||||
config = {
|
|
||||||
# Disable if you don't want unfree packages
|
|
||||||
allowUnfree = true;
|
|
||||||
# Workaround for https://github.com/nix-community/home-manager/issues/2942
|
|
||||||
allowUnfreePredicate = _: true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
home = {
|
|
||||||
username = "imxyy";
|
|
||||||
homeDirectory = "/home/imxyy";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Add stuff for your user as you see fit:
|
|
||||||
# programs.neovim.enable = true;
|
|
||||||
# home.packages = with pkgs; [ steam ];
|
|
||||||
|
|
||||||
# Enable home-manager and git
|
|
||||||
programs.home-manager.enable = true;
|
|
||||||
programs.git.enable = true;
|
|
||||||
|
|
||||||
# Nicely reload system units when changing configs
|
|
||||||
systemd.user.startServices = "sd-switch";
|
|
||||||
|
|
||||||
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
|
|
||||||
home.stateVersion = "23.11";
|
|
||||||
}
|
|
||||||
102
lib/default.nix
Normal file
102
lib/default.nix
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
{ 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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
13
lib/stdlib-extended.nix
Normal file
13
lib/stdlib-extended.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# 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; };
|
||||||
|
}
|
||||||
|
)
|
||||||
17
modules/cmd/all.nix
Normal file
17
modules/cmd/all.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "all command line tools";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"all"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.cmd = {
|
||||||
|
media.all.enable = true;
|
||||||
|
misc.enable = true;
|
||||||
|
monitor.all.enable = true;
|
||||||
|
shell.all.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
10
modules/cmd/default.nix
Normal file
10
modules/cmd/default.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./all.nix
|
||||||
|
./media
|
||||||
|
./misc
|
||||||
|
./monitor
|
||||||
|
./shell
|
||||||
|
];
|
||||||
|
}
|
||||||
18
modules/cmd/media/all.nix
Normal file
18
modules/cmd/media/all.nix
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "all command line media tools";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"media"
|
||||||
|
"all"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.cmd.media = {
|
||||||
|
cava.enable = true;
|
||||||
|
go-musicfox.enable = true;
|
||||||
|
mpd.enable = true;
|
||||||
|
ffmpeg.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
167
modules/cmd/media/cava/config/config
Normal file
167
modules/cmd/media/cava/config/config
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
## Configuration file for CAVA. Default values are commented out. Use either ';' or '#' for commenting.
|
||||||
|
|
||||||
|
|
||||||
|
[general]
|
||||||
|
|
||||||
|
# Smoothing mode. Can be 'normal', 'scientific' or 'waves'.
|
||||||
|
mode = normal
|
||||||
|
|
||||||
|
# Accepts only non-negative values.
|
||||||
|
framerate = 60
|
||||||
|
|
||||||
|
# 'autosens' will attempt to decrease sensitivity if the bars peak. 1 = on, 0 = off
|
||||||
|
# 'overshoot' allows bars to overshoot (in % of terminal height) without initiating autosens.
|
||||||
|
; autosens = 1
|
||||||
|
; overshoot = 20
|
||||||
|
|
||||||
|
# Manual sensitivity in %. Autosens must be turned off for this to take effect.
|
||||||
|
# 200 means double height. Accepts only non-negative values.
|
||||||
|
; sensitivity = 100
|
||||||
|
|
||||||
|
# The number of bars (0-200). 0 sets it to auto (fill up console).
|
||||||
|
# Bars' width and space between bars in number of characters.
|
||||||
|
bars = 0
|
||||||
|
bar_width = 5
|
||||||
|
bar_spacing = 1
|
||||||
|
|
||||||
|
# Lower and higher cutoff frequencies for lowest and highest bars
|
||||||
|
# the bandwidth of the visualizer.
|
||||||
|
# Note: there is a minimum total bandwidth of 43Mhz x number of bars.
|
||||||
|
# Cava will automatically increase the higher cutoff if a too low band is specified.
|
||||||
|
; lower_cutoff_freq = 50
|
||||||
|
; higher_cutoff_freq = 10000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
# Audio capturing method. Possible methods are: 'pulse', 'alsa' or 'fifo'.
|
||||||
|
# Defaults to 'pulse', 'alsa' or 'fifo', in that order, dependent on what support cava was built with.
|
||||||
|
#
|
||||||
|
# All input methods uses the same config variable 'source'
|
||||||
|
# to define where it should get the audio.
|
||||||
|
#
|
||||||
|
# For pulseaudio 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
|
||||||
|
# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them).
|
||||||
|
#
|
||||||
|
# For alsa 'source' will be the capture device.
|
||||||
|
# For fifo 'source' will be the path to fifo-file.
|
||||||
|
method = pulse
|
||||||
|
source = auto
|
||||||
|
|
||||||
|
; method = alsa
|
||||||
|
; source = hw:Loopback,1
|
||||||
|
|
||||||
|
; method = fifo
|
||||||
|
; source = /tmp/mpd.fifo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[output]
|
||||||
|
|
||||||
|
# Ouput method. Can be 'ncurses', 'noncurses' or 'raw'.
|
||||||
|
# 'noncurses' is for systems that does not suport ncurses.
|
||||||
|
# 'raw' is a 16 bit data stream of the bar heights that can be used to send to other applications.
|
||||||
|
# 'raw' defaults to 200 bars, which can be adjusted in the 'bars' option above.
|
||||||
|
method = ncurses
|
||||||
|
|
||||||
|
# Visual styles. Can be 'stereo' or 'mono'.
|
||||||
|
# 'stereo' mirrors both channels with low frequencies in center.
|
||||||
|
# 'mono' averages both channels and outputs left to right lowest to highest frequencies.
|
||||||
|
style = mono
|
||||||
|
|
||||||
|
# Raw output target. A fifo will be created if target does not exist.
|
||||||
|
; raw_target = /dev/stdout
|
||||||
|
|
||||||
|
# Raw data format. Can be 'binary' or 'ascii'.
|
||||||
|
; data_format = binary
|
||||||
|
|
||||||
|
# Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530).
|
||||||
|
; bit_format = 16bit
|
||||||
|
|
||||||
|
# Ascii max value. In 'ascii' mode range will run from 0 to value specified here
|
||||||
|
; ascii_max_range = 1000
|
||||||
|
|
||||||
|
# Ascii delimiters. In ascii format each bar and frame is separated by a delimiters.
|
||||||
|
# Use decimal value in ascii table (i.e. 59 = ';' and 10 = '\n' (line feed)).
|
||||||
|
; bar_delimiter = 59
|
||||||
|
; frame_delimiter = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [color]
|
||||||
|
|
||||||
|
# # Colors can be one of seven predefined: black, blue, cyan, green, magenta, red, white, yellow.
|
||||||
|
# # Or defined by hex code '#xxxxxx' (hex code must be within ''). User defined colors requires a
|
||||||
|
# # terminal that can change color definitions such as Gnome-terminal or rxvt.
|
||||||
|
# ; background = black
|
||||||
|
# ; foreground = cyan
|
||||||
|
|
||||||
|
# # Gradient mode, only hex defined colors are supported, background must also be defined in hex
|
||||||
|
# # or remain commented out. 1 = on, 0 = off. Warning: for certain terminal emulators cava will
|
||||||
|
# # not able to restore color definitions on exit, simply restart your terminal to restore colors.
|
||||||
|
# gradient = 1
|
||||||
|
# gradient_color_1 = '#0099ff'
|
||||||
|
# gradient_color_2 = '#ff3399'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[smoothing]
|
||||||
|
|
||||||
|
# Multiplier for the integral smoothing calculations. Takes values from 0-0.99.
|
||||||
|
# Higher values means smoother, but less precise. Set to 0 to disable.
|
||||||
|
; integral = 0.7
|
||||||
|
|
||||||
|
# Disables or enables the so-called "Monstercat smoothing". Set to 0 to disable.
|
||||||
|
; monstercat = 1
|
||||||
|
; waves = 1
|
||||||
|
|
||||||
|
# Set gravity multiplier for "drop off". Higher values means bars will drop faster.
|
||||||
|
# Accepts only non-negative values. 0.5 means half gravity, 2 means double. Set to 0 to disable "drop off".
|
||||||
|
; gravity = 2
|
||||||
|
|
||||||
|
|
||||||
|
# In bar height, bars that would have been lower that this will not be drawn.
|
||||||
|
; ignore = 0
|
||||||
|
|
||||||
|
|
||||||
|
[eq]
|
||||||
|
|
||||||
|
# This one is tricky. You can have as much keys as you want.
|
||||||
|
# Remember to uncomment more then one key! More keys = more precision.
|
||||||
|
# Look at readme.md on github for further explanations and examples.
|
||||||
|
#; 1 = 1 # bass
|
||||||
|
#; 2 = 1
|
||||||
|
#; 3 = 1 # midtone
|
||||||
|
#; 4 = 1
|
||||||
|
#; 5 = 1 # treble
|
||||||
|
1=1
|
||||||
|
2=1
|
||||||
|
3=2
|
||||||
|
4=1
|
||||||
|
5=1
|
||||||
|
|
||||||
|
[color]
|
||||||
|
|
||||||
|
#background = '#191724'
|
||||||
|
gradient = 1
|
||||||
|
gradient_count = 6
|
||||||
|
gradient_color_1 = '#31748f'
|
||||||
|
gradient_color_2 = '#9ccfd8'
|
||||||
|
gradient_color_3 = '#c4a7e7'
|
||||||
|
gradient_color_4 = '#ebbcba'
|
||||||
|
gradient_color_5 = '#f6c177'
|
||||||
|
gradient_color_6 = '#eb6f92'
|
||||||
|
|
||||||
|
[color]
|
||||||
|
|
||||||
|
gradient = 1
|
||||||
|
|
||||||
|
gradient_color_1 = '#94e2d5'
|
||||||
|
gradient_color_2 = '#89dceb'
|
||||||
|
gradient_color_3 = '#74c7ec'
|
||||||
|
gradient_color_4 = '#89b4fa'
|
||||||
|
gradient_color_5 = '#cba6f7'
|
||||||
|
gradient_color_6 = '#f5c2e7'
|
||||||
|
gradient_color_7 = '#eba0ac'
|
||||||
|
gradient_color_8 = '#f38ba8'
|
||||||
167
modules/cmd/media/cava/config/config-applet
Normal file
167
modules/cmd/media/cava/config/config-applet
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
## Configuration file for CAVA. Default values are commented out. Use either ';' or '#' for commenting.
|
||||||
|
|
||||||
|
|
||||||
|
[general]
|
||||||
|
|
||||||
|
# Smoothing mode. Can be 'normal', 'scientific' or 'waves'.
|
||||||
|
mode = normal
|
||||||
|
|
||||||
|
# Accepts only non-negative values.
|
||||||
|
framerate = 60
|
||||||
|
|
||||||
|
# 'autosens' will attempt to decrease sensitivity if the bars peak. 1 = on, 0 = off
|
||||||
|
# 'overshoot' allows bars to overshoot (in % of terminal height) without initiating autosens.
|
||||||
|
; autosens = 1
|
||||||
|
; overshoot = 20
|
||||||
|
|
||||||
|
# Manual sensitivity in %. Autosens must be turned off for this to take effect.
|
||||||
|
# 200 means double height. Accepts only non-negative values.
|
||||||
|
; sensitivity = 100
|
||||||
|
|
||||||
|
# The number of bars (0-200). 0 sets it to auto (fill up console).
|
||||||
|
# Bars' width and space between bars in number of characters.
|
||||||
|
bars = 0
|
||||||
|
bar_width = 2
|
||||||
|
bar_spacing = 1
|
||||||
|
|
||||||
|
# Lower and higher cutoff frequencies for lowest and highest bars
|
||||||
|
# the bandwidth of the visualizer.
|
||||||
|
# Note: there is a minimum total bandwidth of 43Mhz x number of bars.
|
||||||
|
# Cava will automatically increase the higher cutoff if a too low band is specified.
|
||||||
|
; lower_cutoff_freq = 50
|
||||||
|
; higher_cutoff_freq = 10000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
# Audio capturing method. Possible methods are: 'pulse', 'alsa' or 'fifo'.
|
||||||
|
# Defaults to 'pulse', 'alsa' or 'fifo', in that order, dependent on what support cava was built with.
|
||||||
|
#
|
||||||
|
# All input methods uses the same config variable 'source'
|
||||||
|
# to define where it should get the audio.
|
||||||
|
#
|
||||||
|
# For pulseaudio 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
|
||||||
|
# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them).
|
||||||
|
#
|
||||||
|
# For alsa 'source' will be the capture device.
|
||||||
|
# For fifo 'source' will be the path to fifo-file.
|
||||||
|
method = pulse
|
||||||
|
source = auto
|
||||||
|
|
||||||
|
; method = alsa
|
||||||
|
; source = hw:Loopback,1
|
||||||
|
|
||||||
|
; method = fifo
|
||||||
|
; source = /tmp/mpd.fifo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[output]
|
||||||
|
|
||||||
|
# Ouput method. Can be 'ncurses', 'noncurses' or 'raw'.
|
||||||
|
# 'noncurses' is for systems that does not suport ncurses.
|
||||||
|
# 'raw' is a 16 bit data stream of the bar heights that can be used to send to other applications.
|
||||||
|
# 'raw' defaults to 200 bars, which can be adjusted in the 'bars' option above.
|
||||||
|
method = ncurses
|
||||||
|
|
||||||
|
# Visual styles. Can be 'stereo' or 'mono'.
|
||||||
|
# 'stereo' mirrors both channels with low frequencies in center.
|
||||||
|
# 'mono' averages both channels and outputs left to right lowest to highest frequencies.
|
||||||
|
style = mono
|
||||||
|
|
||||||
|
# Raw output target. A fifo will be created if target does not exist.
|
||||||
|
; raw_target = /dev/stdout
|
||||||
|
|
||||||
|
# Raw data format. Can be 'binary' or 'ascii'.
|
||||||
|
; data_format = binary
|
||||||
|
|
||||||
|
# Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530).
|
||||||
|
; bit_format = 16bit
|
||||||
|
|
||||||
|
# Ascii max value. In 'ascii' mode range will run from 0 to value specified here
|
||||||
|
; ascii_max_range = 1000
|
||||||
|
|
||||||
|
# Ascii delimiters. In ascii format each bar and frame is separated by a delimiters.
|
||||||
|
# Use decimal value in ascii table (i.e. 59 = ';' and 10 = '\n' (line feed)).
|
||||||
|
; bar_delimiter = 59
|
||||||
|
; frame_delimiter = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [color]
|
||||||
|
|
||||||
|
# # Colors can be one of seven predefined: black, blue, cyan, green, magenta, red, white, yellow.
|
||||||
|
# # Or defined by hex code '#xxxxxx' (hex code must be within ''). User defined colors requires a
|
||||||
|
# # terminal that can change color definitions such as Gnome-terminal or rxvt.
|
||||||
|
# ; background = black
|
||||||
|
# ; foreground = cyan
|
||||||
|
|
||||||
|
# # Gradient mode, only hex defined colors are supported, background must also be defined in hex
|
||||||
|
# # or remain commented out. 1 = on, 0 = off. Warning: for certain terminal emulators cava will
|
||||||
|
# # not able to restore color definitions on exit, simply restart your terminal to restore colors.
|
||||||
|
# gradient = 1
|
||||||
|
# gradient_color_1 = '#0099ff'
|
||||||
|
# gradient_color_2 = '#ff3399'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[smoothing]
|
||||||
|
|
||||||
|
# Multiplier for the integral smoothing calculations. Takes values from 0-0.99.
|
||||||
|
# Higher values means smoother, but less precise. Set to 0 to disable.
|
||||||
|
; integral = 0.7
|
||||||
|
|
||||||
|
# Disables or enables the so-called "Monstercat smoothing". Set to 0 to disable.
|
||||||
|
; monstercat = 1
|
||||||
|
; waves = 1
|
||||||
|
|
||||||
|
# Set gravity multiplier for "drop off". Higher values means bars will drop faster.
|
||||||
|
# Accepts only non-negative values. 0.5 means half gravity, 2 means double. Set to 0 to disable "drop off".
|
||||||
|
; gravity = 1
|
||||||
|
|
||||||
|
|
||||||
|
# In bar height, bars that would have been lower that this will not be drawn.
|
||||||
|
; ignore = 0
|
||||||
|
|
||||||
|
|
||||||
|
[eq]
|
||||||
|
|
||||||
|
# This one is tricky. You can have as much keys as you want.
|
||||||
|
# Remember to uncomment more then one key! More keys = more precision.
|
||||||
|
# Look at readme.md on github for further explanations and examples.
|
||||||
|
#; 1 = 1 # bass
|
||||||
|
#; 2 = 1
|
||||||
|
#; 3 = 1 # midtone
|
||||||
|
#; 4 = 1
|
||||||
|
#; 5 = 1 # treble
|
||||||
|
1=1
|
||||||
|
2=1
|
||||||
|
3=2
|
||||||
|
4=1
|
||||||
|
5=1
|
||||||
|
|
||||||
|
[color]
|
||||||
|
|
||||||
|
#background = '#191724'
|
||||||
|
gradient = 1
|
||||||
|
gradient_count = 6
|
||||||
|
gradient_color_1 = '#31748f'
|
||||||
|
gradient_color_2 = '#9ccfd8'
|
||||||
|
gradient_color_3 = '#c4a7e7'
|
||||||
|
gradient_color_4 = '#ebbcba'
|
||||||
|
gradient_color_5 = '#f6c177'
|
||||||
|
gradient_color_6 = '#eb6f92'
|
||||||
|
|
||||||
|
[color]
|
||||||
|
|
||||||
|
gradient = 1
|
||||||
|
|
||||||
|
gradient_color_1 = '#94e2d5'
|
||||||
|
gradient_color_2 = '#89dceb'
|
||||||
|
gradient_color_3 = '#74c7ec'
|
||||||
|
gradient_color_4 = '#89b4fa'
|
||||||
|
gradient_color_5 = '#cba6f7'
|
||||||
|
gradient_color_6 = '#f5c2e7'
|
||||||
|
gradient_color_7 = '#eba0ac'
|
||||||
|
gradient_color_8 = '#f38ba8'
|
||||||
79
modules/cmd/media/cava/config/shaders/bar_spectrum.frag
Normal file
79
modules/cmd/media/cava/config/shaders/bar_spectrum.frag
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 fragCoord;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
// bar values. defaults to left channels first (low to high), then right (high to low).
|
||||||
|
uniform float bars[512];
|
||||||
|
|
||||||
|
uniform int bars_count; // number of bars (left + right) (configurable)
|
||||||
|
uniform int bar_width; // bar width (configurable), not used here
|
||||||
|
uniform int bar_spacing; // space bewteen bars (configurable)
|
||||||
|
|
||||||
|
uniform vec3 u_resolution; // window resolution
|
||||||
|
|
||||||
|
//colors, configurable in cava config file (r,g,b) (0.0 - 1.0)
|
||||||
|
uniform vec3 bg_color; // background color
|
||||||
|
uniform vec3 fg_color; // foreground color
|
||||||
|
|
||||||
|
uniform int gradient_count;
|
||||||
|
uniform vec3 gradient_colors[8]; // gradient colors
|
||||||
|
|
||||||
|
vec3 normalize_C(float y,vec3 col_1, vec3 col_2, float y_min, float y_max)
|
||||||
|
{
|
||||||
|
//create color based on fraction of this color and next color
|
||||||
|
float yr = (y - y_min) / (y_max - y_min);
|
||||||
|
return col_1 * (1.0 - yr) + col_2 * yr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// find which bar to use based on where we are on the x axis
|
||||||
|
float x = u_resolution.x * fragCoord.x;
|
||||||
|
int bar = int(bars_count * fragCoord.x);
|
||||||
|
|
||||||
|
//calculate a bar size
|
||||||
|
float bar_size = u_resolution.x / bars_count;
|
||||||
|
|
||||||
|
//the y coordinate and bar values are the same
|
||||||
|
float y = bars[bar];
|
||||||
|
|
||||||
|
// make sure there is a thin line at bottom
|
||||||
|
if (y * u_resolution.y < 1.0)
|
||||||
|
{
|
||||||
|
y = 1.0 / u_resolution.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw the bar up to current height
|
||||||
|
if (y > fragCoord.y)
|
||||||
|
{
|
||||||
|
//make some space between bars basen on settings
|
||||||
|
if (x > (bar + 1) * (bar_size) - bar_spacing)
|
||||||
|
{
|
||||||
|
fragColor = vec4(bg_color,1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gradient_count == 0)
|
||||||
|
{
|
||||||
|
fragColor = vec4(fg_color,1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//find which color in the configured gradient we are at
|
||||||
|
int color = int((gradient_count - 1) * fragCoord.y);
|
||||||
|
|
||||||
|
//find where on y this and next color is supposed to be
|
||||||
|
float y_min = color / (gradient_count - 1.0);
|
||||||
|
float y_max = (color + 1.0) / (gradient_count - 1.0);
|
||||||
|
|
||||||
|
//make color
|
||||||
|
fragColor = vec4(normalize_C(fragCoord.y, gradient_colors[color], gradient_colors[color + 1], y_min, y_max), 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fragColor = vec4(bg_color,1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
modules/cmd/media/cava/config/shaders/normalized_bars.frag
Normal file
38
modules/cmd/media/cava/config/shaders/normalized_bars.frag
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 fragCoord;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
// bar values. defaults to left channels first (low to high), then right (high to low).
|
||||||
|
uniform float bars[512];
|
||||||
|
|
||||||
|
uniform int bars_count; // number of bars (left + right) (configurable)
|
||||||
|
|
||||||
|
uniform vec3 u_resolution; // window resolution, not used here
|
||||||
|
|
||||||
|
//colors, configurable in cava config file
|
||||||
|
uniform vec3 bg_color; // background color(r,g,b) (0.0 - 1.0), not used here
|
||||||
|
uniform vec3 fg_color; // foreground color, not used here
|
||||||
|
|
||||||
|
float normalize_C(float x, float x_min, float x_max, float r_min, float r_max )
|
||||||
|
{
|
||||||
|
float xr;
|
||||||
|
xr = (r_max-r_min) * (x - x_min) / (x_max - x_min) + r_min;
|
||||||
|
return xr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// find which bar to use based on where we are on the x axis
|
||||||
|
int bar = int(bars_count * fragCoord.x);
|
||||||
|
|
||||||
|
// create a normal along the y axis based on the bar height
|
||||||
|
float x = normalize_C(fragCoord.y, 1.0, 0.0, 0.0, bars[bar]);
|
||||||
|
|
||||||
|
// set color
|
||||||
|
fragColor.r=fg_color.x*x;
|
||||||
|
fragColor.g=fg_color.y*x;
|
||||||
|
fragColor.b=fg_color.z*x;
|
||||||
|
fragColor.a=1.0;
|
||||||
|
|
||||||
|
}
|
||||||
34
modules/cmd/media/cava/config/shaders/northern_lights.frag
Normal file
34
modules/cmd/media/cava/config/shaders/northern_lights.frag
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 fragCoord;
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
// bar values. defaults to left channels first (low to high), then right (high to low).
|
||||||
|
uniform float bars[512];
|
||||||
|
|
||||||
|
uniform int bars_count; // number of bars (left + right) (configurable)
|
||||||
|
|
||||||
|
uniform vec3 u_resolution; // window resolution, not used here
|
||||||
|
|
||||||
|
//colors, configurable in cava config file
|
||||||
|
uniform vec3 bg_color; // background color(r,g,b) (0.0 - 1.0), not used here
|
||||||
|
uniform vec3 fg_color; // foreground color, not used here
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// find which bar to use based on where we are on the x axis
|
||||||
|
int bar = int(bars_count * fragCoord.x);
|
||||||
|
|
||||||
|
float bar_y = 1.0 - abs((fragCoord.y - 0.5)) * 2.0;
|
||||||
|
float y = (bars[bar]) * bar_y;
|
||||||
|
|
||||||
|
float bar_x = (fragCoord.x - float(bar) / float(bars_count)) * bars_count;
|
||||||
|
float bar_r = 1.0 - abs((bar_x - 0.5)) * 2;
|
||||||
|
|
||||||
|
bar_r = bar_r * bar_r * 2;
|
||||||
|
|
||||||
|
// set color
|
||||||
|
fragColor.r = fg_color.x * y * bar_r;
|
||||||
|
fragColor.g = fg_color.y * y * bar_r;
|
||||||
|
fragColor.b = fg_color.z * y * bar_r;
|
||||||
|
}
|
||||||
14
modules/cmd/media/cava/config/shaders/pass_through.vert
Normal file
14
modules/cmd/media/cava/config/shaders/pass_through.vert
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
|
||||||
|
// Input vertex data, different for all executions of this shader.
|
||||||
|
layout(location = 0) in vec3 vertexPosition_modelspace;
|
||||||
|
|
||||||
|
// Output data ; will be interpolated for each fragment.
|
||||||
|
out vec2 fragCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(vertexPosition_modelspace,1);
|
||||||
|
fragCoord = (vertexPosition_modelspace.xy+vec2(1,1))/2.0;
|
||||||
|
}
|
||||||
22
modules/cmd/media/cava/default.nix
Normal file
22
modules/cmd/media/cava/default.nix
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeHomePackageConfig {
|
||||||
|
inherit config pkgs;
|
||||||
|
packageName = "cava";
|
||||||
|
packagePath = [ "cava" ];
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"media"
|
||||||
|
"cava"
|
||||||
|
];
|
||||||
|
extraConfig = {
|
||||||
|
my.home.xdg.configFile."cava" = {
|
||||||
|
source = ./config;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
10
modules/cmd/media/default.nix
Normal file
10
modules/cmd/media/default.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./all.nix
|
||||||
|
./ffmpeg.nix
|
||||||
|
./mpd
|
||||||
|
./cava
|
||||||
|
./go-musicfox
|
||||||
|
];
|
||||||
|
}
|
||||||
16
modules/cmd/media/ffmpeg.nix
Normal file
16
modules/cmd/media/ffmpeg.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeHomePackageConfig {
|
||||||
|
inherit config pkgs;
|
||||||
|
packageName = "ffmpeg";
|
||||||
|
packagePath = [ "ffmpeg" ];
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"media"
|
||||||
|
"ffmpeg"
|
||||||
|
];
|
||||||
|
}
|
||||||
28
modules/cmd/media/go-musicfox/default.nix
Normal file
28
modules/cmd/media/go-musicfox/default.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "go-musicfox";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"media"
|
||||||
|
"go-musicfox"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my = {
|
||||||
|
home = {
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
playerctl
|
||||||
|
go-musicfox
|
||||||
|
];
|
||||||
|
xdg.configFile."go-musicfox/go-musicfox.ini".source = ./go-musicfox.ini;
|
||||||
|
};
|
||||||
|
|
||||||
|
cmd.media.mpd.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
97
modules/cmd/media/go-musicfox/go-musicfox.ini
Normal file
97
modules/cmd/media/go-musicfox/go-musicfox.ini
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
# 启动页配置
|
||||||
|
[startup]
|
||||||
|
# 是否显示启动页
|
||||||
|
show=false
|
||||||
|
# 启动页进度条是否有回弹效果
|
||||||
|
progressOutBounce=true
|
||||||
|
# 启动页时长
|
||||||
|
loadingSeconds=2
|
||||||
|
# 启动页欢迎语
|
||||||
|
welcome=musicfox
|
||||||
|
# 启动时自动签到
|
||||||
|
signin=false
|
||||||
|
|
||||||
|
# 进度条配置
|
||||||
|
[progress]
|
||||||
|
# 进度条已加载字符
|
||||||
|
fullChar=#
|
||||||
|
# 进度条未加载字符
|
||||||
|
emptyChar=
|
||||||
|
|
||||||
|
# 主页面配置
|
||||||
|
[main]
|
||||||
|
# 是否显示标题
|
||||||
|
showTitle=true
|
||||||
|
# 加载中提示
|
||||||
|
loadingText=[加载中...]
|
||||||
|
# 歌曲音质,可选项:standard, exhigh, lossless, hires, jyeffect(高清环绕声), sky(沉浸环绕声), jymaster(超清母带) 进行音质判断
|
||||||
|
songLevel=hires
|
||||||
|
# 主题颜色
|
||||||
|
# 随机
|
||||||
|
# primaryColor=random
|
||||||
|
# 经典网易云音乐红
|
||||||
|
#primaryColor="#ea403f"
|
||||||
|
primaryColor="#6186D9"
|
||||||
|
# 是否显示歌词
|
||||||
|
showLyric=true
|
||||||
|
# 歌词偏移 ms
|
||||||
|
lyricOffset=0
|
||||||
|
# 显示歌词翻译
|
||||||
|
showLyricTrans=true
|
||||||
|
# 是否显示通知信息
|
||||||
|
showNotify=false
|
||||||
|
# 开启pprof, --pprof时会开启
|
||||||
|
pprofPort=9876
|
||||||
|
# altScreen显示模式
|
||||||
|
altScreen=true
|
||||||
|
# 双列显示,开启务必使用等宽字体
|
||||||
|
doubleColumn=true
|
||||||
|
# 下载目录,默认为$HOME/.go-musicfox/download
|
||||||
|
downloadDir=/home/imxyy/Music/go-musicfox
|
||||||
|
# 缓存目录,默认为${MUSICFOX_ROOT}/cache
|
||||||
|
cacheDir=/home/imxyy/Music/go-musicfox/.cache
|
||||||
|
# 缓存大小(以MB为单位),0为不使用缓存,-1为不限制,默认为0
|
||||||
|
cacheLimit=-1
|
||||||
|
# 是否显示歌单下所有歌曲,默认不开启,仅获取歌单前1000首,开启后可能会占用更多内存(大量歌曲数据)和带宽(会同时发送多个请求获取歌单下歌曲数据)
|
||||||
|
showAllSongsOfPlaylist=false
|
||||||
|
# 动态显示menu行数
|
||||||
|
dynamicMenuRows=true
|
||||||
|
enableMouseEvent = false
|
||||||
|
|
||||||
|
[autoplay]
|
||||||
|
# 是否开启自动播放,默认不开启
|
||||||
|
autoPlay=true
|
||||||
|
# 自动播放歌单,dailyReco,like,no(保持上次退出时的设置,无视offset),name:歌单名,默认dailyReco
|
||||||
|
autoPlayList="no"
|
||||||
|
# 播放偏移,0为第一首,-1为最后一首,默认为0
|
||||||
|
offset=0
|
||||||
|
# 播放模式,listLoop, order, singleLoop, random, intelligent(心动), last(上次退出时的模式),default,默认为last
|
||||||
|
playMode=singleLoop
|
||||||
|
|
||||||
|
[player]
|
||||||
|
# 播放引擎 beep / mpd(需要安装配置mpd) / osx(Mac才可用)
|
||||||
|
# 不填Mac默认使用osx,其他系统默认使用beep(推荐的配置)
|
||||||
|
engine=mpd
|
||||||
|
# beep使用的mp3解码器,可选:go-mp3, minimp3 (minimp3更少的CPU占用,但是稳定性不如go-mp3)
|
||||||
|
#beepMp3Decoder=go-mp3
|
||||||
|
|
||||||
|
# mpd配置
|
||||||
|
mpdBin=mpd
|
||||||
|
# !!!注意!!! 一定要在配置文件中设置pid_file,否则在退出时不会kill掉mpd进程
|
||||||
|
mpdConfigFile=/home/imxyy/.config/mpd/mpd.conf
|
||||||
|
mpdNetwork=tcp
|
||||||
|
mpdAddr=127.0.0.1:6600
|
||||||
|
|
||||||
|
[unm]
|
||||||
|
# UNM开关
|
||||||
|
switch=true
|
||||||
|
# UNM源: kuwo,kugou,migu,qq
|
||||||
|
sources=kuwo,kugou
|
||||||
|
# UNM搜索其他平台限制 0-3
|
||||||
|
searchLimit=0
|
||||||
|
# 解除会员限制
|
||||||
|
enableLocalVip=true
|
||||||
|
# 解除音质限制
|
||||||
|
unlockSoundEffects=true
|
||||||
|
# QQ音乐cookie文件
|
||||||
|
qqCookieFile=
|
||||||
25
modules/cmd/media/mpd/default.nix
Normal file
25
modules/cmd/media/mpd/default.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "mpd";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"media"
|
||||||
|
"mpd"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.home = {
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
mpd
|
||||||
|
mpc-cli
|
||||||
|
];
|
||||||
|
services.mpris-proxy.enable = true;
|
||||||
|
xdg.configFile."mpd/mpd.conf".source = ./mpd.conf;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
30
modules/cmd/media/mpd/mpd.conf
Normal file
30
modules/cmd/media/mpd/mpd.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
audio_output {
|
||||||
|
type "pulse"
|
||||||
|
name "pulseaudio"
|
||||||
|
}
|
||||||
88
modules/cmd/misc/default.nix
Normal file
88
modules/cmd/misc/default.nix
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
userfullname,
|
||||||
|
useremail,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
default = true;
|
||||||
|
optionName = "misc command line tools";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"misc"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
vim
|
||||||
|
wget
|
||||||
|
git
|
||||||
|
|
||||||
|
file
|
||||||
|
gnused
|
||||||
|
gnutar
|
||||||
|
|
||||||
|
zip
|
||||||
|
unzip
|
||||||
|
xz
|
||||||
|
p7zip
|
||||||
|
rar
|
||||||
|
unrar
|
||||||
|
|
||||||
|
pciutils
|
||||||
|
usbutils
|
||||||
|
|
||||||
|
lsof
|
||||||
|
|
||||||
|
nmap
|
||||||
|
traceroute
|
||||||
|
tcping-go
|
||||||
|
dnsutils
|
||||||
|
|
||||||
|
killall
|
||||||
|
];
|
||||||
|
|
||||||
|
programs.zsh.enable = true;
|
||||||
|
programs.dconf.enable = true;
|
||||||
|
|
||||||
|
my.home = {
|
||||||
|
programs.home-manager.enable = true;
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = "${userfullname}";
|
||||||
|
userEmail = "${useremail}";
|
||||||
|
extraConfig = {
|
||||||
|
pull.rebase = true;
|
||||||
|
push.autoSetupRemote = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
lsd
|
||||||
|
fd
|
||||||
|
neofetch
|
||||||
|
fzf
|
||||||
|
bat
|
||||||
|
ripgrep
|
||||||
|
|
||||||
|
aria2
|
||||||
|
socat
|
||||||
|
|
||||||
|
nix-output-monitor
|
||||||
|
|
||||||
|
tmux
|
||||||
|
|
||||||
|
trash-cli
|
||||||
|
|
||||||
|
cht-sh
|
||||||
|
|
||||||
|
dooit
|
||||||
|
|
||||||
|
# translate-shell
|
||||||
|
];
|
||||||
|
xdg.configFile."tmux/tmux.conf".source = ./tmux.conf;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
9
modules/cmd/misc/tmux.conf
Normal file
9
modules/cmd/misc/tmux.conf
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
set-option -g mouse on
|
||||||
|
|
||||||
|
set -g @plugin 'tmux-plugins/tpm'
|
||||||
|
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||||
|
|
||||||
|
set -g @plugin "janoamaral/tokyo-night-tmux#legacy"
|
||||||
|
|
||||||
|
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||||
|
run '~/.config/tmux/plugins/tpm/tpm'
|
||||||
15
modules/cmd/monitor/all.nix
Normal file
15
modules/cmd/monitor/all.nix
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "all command line monitor tools";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"monitor"
|
||||||
|
"all"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.cmd.monitor = {
|
||||||
|
btop.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
212
modules/cmd/monitor/btop/config/btop.conf
Normal file
212
modules/cmd/monitor/btop/config/btop.conf
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
#? Config file for btop v. 1.2.13
|
||||||
|
|
||||||
|
#* Name of a btop++/bpytop/bashtop formatted ".theme" file, "Default" and "TTY" for builtin themes.
|
||||||
|
#* Themes should be placed in "../share/btop/themes" relative to binary or "$HOME/.config/btop/themes"
|
||||||
|
color_theme = "nord.theme"
|
||||||
|
|
||||||
|
#* If the theme set background should be shown, set to False if you want terminal background transparency.
|
||||||
|
theme_background = False
|
||||||
|
|
||||||
|
#* Sets if 24-bit truecolor should be used, will convert 24-bit colors to 256 color (6x6x6 color cube) if false.
|
||||||
|
truecolor = True
|
||||||
|
|
||||||
|
#* Set to true to force tty mode regardless if a real tty has been detected or not.
|
||||||
|
#* Will force 16-color mode and TTY theme, set all graph symbols to "tty" and swap out other non tty friendly symbols.
|
||||||
|
force_tty = False
|
||||||
|
|
||||||
|
#* Define presets for the layout of the boxes. Preset 0 is always all boxes shown with default settings. Max 9 presets.
|
||||||
|
#* Format: "box_name:P:G,box_name:P:G" P=(0 or 1) for alternate positions, G=graph symbol to use for box.
|
||||||
|
#* Use whitespace " " as separator between different presets.
|
||||||
|
#* Example: "cpu:0:default,mem:0:tty,proc:1:default cpu:0:braille,proc:0:tty"
|
||||||
|
presets = "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:default cpu:0:block,net:0:tty"
|
||||||
|
|
||||||
|
#* Set to True to enable "h,j,k,l,g,G" keys for directional control in lists.
|
||||||
|
#* Conflicting keys for h:"help" and k:"kill" is accessible while holding shift.
|
||||||
|
vim_keys = False
|
||||||
|
|
||||||
|
#* Rounded corners on boxes, is ignored if TTY mode is ON.
|
||||||
|
rounded_corners = True
|
||||||
|
|
||||||
|
#* Default symbols to use for graph creation, "braille", "block" or "tty".
|
||||||
|
#* "braille" offers the highest resolution but might not be included in all fonts.
|
||||||
|
#* "block" has half the resolution of braille but uses more common characters.
|
||||||
|
#* "tty" uses only 3 different symbols but will work with most fonts and should work in a real TTY.
|
||||||
|
#* Note that "tty" only has half the horizontal resolution of the other two, so will show a shorter historical view.
|
||||||
|
graph_symbol = "braille"
|
||||||
|
|
||||||
|
# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
|
||||||
|
graph_symbol_cpu = "default"
|
||||||
|
|
||||||
|
# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
|
||||||
|
graph_symbol_mem = "default"
|
||||||
|
|
||||||
|
# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
|
||||||
|
graph_symbol_net = "default"
|
||||||
|
|
||||||
|
# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
|
||||||
|
graph_symbol_proc = "default"
|
||||||
|
|
||||||
|
#* Manually set which boxes to show. Available values are "cpu mem net proc", separate values with whitespace.
|
||||||
|
shown_boxes = "cpu mem net proc"
|
||||||
|
|
||||||
|
#* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs.
|
||||||
|
update_ms = 200
|
||||||
|
|
||||||
|
#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct",
|
||||||
|
#* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly.
|
||||||
|
proc_sorting = "memory"
|
||||||
|
|
||||||
|
#* Reverse sorting order, True or False.
|
||||||
|
proc_reversed = False
|
||||||
|
|
||||||
|
#* Show processes as a tree.
|
||||||
|
proc_tree = True
|
||||||
|
|
||||||
|
#* Use the cpu graph colors in the process list.
|
||||||
|
proc_colors = True
|
||||||
|
|
||||||
|
#* Use a darkening gradient in the process list.
|
||||||
|
proc_gradient = False
|
||||||
|
|
||||||
|
#* If process cpu usage should be of the core it's running on or usage of the total available cpu power.
|
||||||
|
proc_per_core = False
|
||||||
|
|
||||||
|
#* Show process memory as bytes instead of percent.
|
||||||
|
proc_mem_bytes = True
|
||||||
|
|
||||||
|
#* Show cpu graph for each process.
|
||||||
|
proc_cpu_graphs = True
|
||||||
|
|
||||||
|
#* Use /proc/[pid]/smaps for memory information in the process info box (very slow but more accurate)
|
||||||
|
proc_info_smaps = False
|
||||||
|
|
||||||
|
#* Show proc box on left side of screen instead of right.
|
||||||
|
proc_left = False
|
||||||
|
|
||||||
|
#* (Linux) Filter processes tied to the Linux kernel(similar behavior to htop).
|
||||||
|
proc_filter_kernel = True
|
||||||
|
|
||||||
|
#* Sets the CPU stat shown in upper half of the CPU graph, "total" is always available.
|
||||||
|
#* Select from a list of detected attributes from the options menu.
|
||||||
|
cpu_graph_upper = "total"
|
||||||
|
|
||||||
|
#* Sets the CPU stat shown in lower half of the CPU graph, "total" is always available.
|
||||||
|
#* Select from a list of detected attributes from the options menu.
|
||||||
|
cpu_graph_lower = "total"
|
||||||
|
|
||||||
|
#* Toggles if the lower CPU graph should be inverted.
|
||||||
|
cpu_invert_lower = False
|
||||||
|
|
||||||
|
#* Set to True to completely disable the lower CPU graph.
|
||||||
|
cpu_single_graph = True
|
||||||
|
|
||||||
|
#* Show cpu box at bottom of screen instead of top.
|
||||||
|
cpu_bottom = False
|
||||||
|
|
||||||
|
#* Shows the system uptime in the CPU box.
|
||||||
|
show_uptime = True
|
||||||
|
|
||||||
|
#* Show cpu temperature.
|
||||||
|
check_temp = True
|
||||||
|
|
||||||
|
#* Which sensor to use for cpu temperature, use options menu to select from list of available sensors.
|
||||||
|
cpu_sensor = "Auto"
|
||||||
|
|
||||||
|
#* Show temperatures for cpu cores also if check_temp is True and sensors has been found.
|
||||||
|
show_coretemp = True
|
||||||
|
|
||||||
|
#* Set a custom mapping between core and coretemp, can be needed on certain cpus to get correct temperature for correct core.
|
||||||
|
#* Use lm-sensors or similar to see which cores are reporting temperatures on your machine.
|
||||||
|
#* Format "x:y" x=core with wrong temp, y=core with correct temp, use space as separator between multiple entries.
|
||||||
|
#* Example: "4:0 5:1 6:3"
|
||||||
|
cpu_core_map = ""
|
||||||
|
|
||||||
|
#* Which temperature scale to use, available values: "celsius", "fahrenheit", "kelvin" and "rankine".
|
||||||
|
temp_scale = "celsius"
|
||||||
|
|
||||||
|
#* Use base 10 for bits/bytes sizes, KB = 1000 instead of KiB = 1024.
|
||||||
|
base_10_sizes = False
|
||||||
|
|
||||||
|
#* Show CPU frequency.
|
||||||
|
show_cpu_freq = True
|
||||||
|
|
||||||
|
#* Draw a clock at top of screen, formatting according to strftime, empty string to disable.
|
||||||
|
#* Special formatting: /host = hostname | /user = username | /uptime = system uptime
|
||||||
|
clock_format = "%X"
|
||||||
|
|
||||||
|
#* Update main ui in background when menus are showing, set this to false if the menus is flickering too much for comfort.
|
||||||
|
background_update = True
|
||||||
|
|
||||||
|
#* Custom cpu model name, empty string to disable.
|
||||||
|
custom_cpu_name = ""
|
||||||
|
|
||||||
|
#* Optional filter for shown disks, should be full path of a mountpoint, separate multiple values with whitespace " ".
|
||||||
|
#* Begin line with "exclude=" to change to exclude filter, otherwise defaults to "most include" filter. Example: disks_filter="exclude=/boot /home/user".
|
||||||
|
disks_filter = ""
|
||||||
|
|
||||||
|
#* Show graphs instead of meters for memory values.
|
||||||
|
mem_graphs = True
|
||||||
|
|
||||||
|
#* Show mem box below net box instead of above.
|
||||||
|
mem_below_net = False
|
||||||
|
|
||||||
|
#* Count ZFS ARC in cached and available memory.
|
||||||
|
zfs_arc_cached = True
|
||||||
|
|
||||||
|
#* If swap memory should be shown in memory box.
|
||||||
|
show_swap = False
|
||||||
|
|
||||||
|
#* Show swap as a disk, ignores show_swap value above, inserts itself after first disk.
|
||||||
|
swap_disk = True
|
||||||
|
|
||||||
|
#* If mem box should be split to also show disks info.
|
||||||
|
show_disks = False
|
||||||
|
|
||||||
|
#* Filter out non physical disks. Set this to False to include network disks, RAM disks and similar.
|
||||||
|
only_physical = True
|
||||||
|
|
||||||
|
#* Read disks list from /etc/fstab. This also disables only_physical.
|
||||||
|
use_fstab = False
|
||||||
|
|
||||||
|
#* Setting this to True will hide all datasets, and only show ZFS pools. (IO stats will be calculated per-pool)
|
||||||
|
zfs_hide_datasets = False
|
||||||
|
|
||||||
|
#* Set to true to show available disk space for privileged users.
|
||||||
|
disk_free_priv = False
|
||||||
|
|
||||||
|
#* Toggles if io activity % (disk busy time) should be shown in regular disk usage view.
|
||||||
|
show_io_stat = False
|
||||||
|
|
||||||
|
#* Toggles io mode for disks, showing big graphs for disk read/write speeds.
|
||||||
|
io_mode = True
|
||||||
|
|
||||||
|
#* Set to True to show combined read/write io graphs in io mode.
|
||||||
|
io_graph_combined = False
|
||||||
|
|
||||||
|
#* Set the top speed for the io graphs in MiB/s (100 by default), use format "mountpoint:speed" separate disks with whitespace " ".
|
||||||
|
#* Example: "/mnt/media:100 /:20 /boot:1".
|
||||||
|
io_graph_speeds = ""
|
||||||
|
|
||||||
|
#* Set fixed values for network graphs in Mebibits. Is only used if net_auto is also set to False.
|
||||||
|
net_download = 100
|
||||||
|
|
||||||
|
net_upload = 100
|
||||||
|
|
||||||
|
#* Use network graphs auto rescaling mode, ignores any values set above and rescales down to 10 Kibibytes at the lowest.
|
||||||
|
net_auto = False
|
||||||
|
|
||||||
|
#* Sync the auto scaling for download and upload to whichever currently has the highest scale.
|
||||||
|
net_sync = True
|
||||||
|
|
||||||
|
#* Starts with the Network Interface specified here.
|
||||||
|
net_iface = "eth0"
|
||||||
|
|
||||||
|
#* Show battery stats in top right if battery is present.
|
||||||
|
show_battery = False
|
||||||
|
|
||||||
|
#* Which battery to use if multiple are present. "Auto" for auto detection.
|
||||||
|
selected_battery = "Auto"
|
||||||
|
|
||||||
|
#* Set loglevel for "~/.config/btop/btop.log" levels are: "ERROR" "WARNING" "INFO" "DEBUG".
|
||||||
|
#* The level set includes all lower levels, i.e. "DEBUG" will show all logging info.
|
||||||
|
log_level = "WARNING"
|
||||||
89
modules/cmd/monitor/btop/config/themes/nord.theme
Normal file
89
modules/cmd/monitor/btop/config/themes/nord.theme
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
#Bashtop theme with nord palette (https://www.nordtheme.com)
|
||||||
|
#by Justin Zobel <justin.zobel@gmail.com>
|
||||||
|
|
||||||
|
# Colors should be in 6 or 2 character hexadecimal or single spaced rgb decimal: "#RRGGBB", "#BW" or "0-255 0-255 0-255"
|
||||||
|
# example for white: "#ffffff", "#ff" or "255 255 255".
|
||||||
|
|
||||||
|
# All graphs and meters can be gradients
|
||||||
|
# For single color graphs leave "mid" and "end" variable empty.
|
||||||
|
# Use "start" and "end" variables for two color gradient
|
||||||
|
# Use "start", "mid" and "end" for three color gradient
|
||||||
|
|
||||||
|
# Main background, empty for terminal default, need to be empty if you want transparent background
|
||||||
|
theme[main_bg]="#2E3440"
|
||||||
|
|
||||||
|
# Main text color
|
||||||
|
theme[main_fg]="#D8DEE9"
|
||||||
|
|
||||||
|
# Title color for boxes
|
||||||
|
theme[title]="#8FBCBB"
|
||||||
|
|
||||||
|
# Higlight color for keyboard shortcuts
|
||||||
|
theme[hi_fg]="#5E81AC"
|
||||||
|
|
||||||
|
# Background color of selected item in processes box
|
||||||
|
theme[selected_bg]="#4C566A"
|
||||||
|
|
||||||
|
# Foreground color of selected item in processes box
|
||||||
|
theme[selected_fg]="#ECEFF4"
|
||||||
|
|
||||||
|
# Color of inactive/disabled text
|
||||||
|
theme[inactive_fg]="#4C566A"
|
||||||
|
|
||||||
|
# Misc colors for processes box including mini cpu graphs, details memory graph and details status text
|
||||||
|
theme[proc_misc]="#5E81AC"
|
||||||
|
|
||||||
|
# Cpu box outline color
|
||||||
|
theme[cpu_box]="#4C566A"
|
||||||
|
|
||||||
|
# Memory/disks box outline color
|
||||||
|
theme[mem_box]="#4C566A"
|
||||||
|
|
||||||
|
# Net up/down box outline color
|
||||||
|
theme[net_box]="#4C566A"
|
||||||
|
|
||||||
|
# Processes box outline color
|
||||||
|
theme[proc_box]="#4C566A"
|
||||||
|
|
||||||
|
# Box divider line and small boxes line color
|
||||||
|
theme[div_line]="#4C566A"
|
||||||
|
|
||||||
|
# Temperature graph colors
|
||||||
|
theme[temp_start]="#81A1C1"
|
||||||
|
theme[temp_mid]="#88C0D0"
|
||||||
|
theme[temp_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# CPU graph colors
|
||||||
|
theme[cpu_start]="#81A1C1"
|
||||||
|
theme[cpu_mid]="#88C0D0"
|
||||||
|
theme[cpu_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# Mem/Disk free meter
|
||||||
|
theme[free_start]="#81A1C1"
|
||||||
|
theme[free_mid]="#88C0D0"
|
||||||
|
theme[free_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# Mem/Disk cached meter
|
||||||
|
theme[cached_start]="#81A1C1"
|
||||||
|
theme[cached_mid]="#88C0D0"
|
||||||
|
theme[cached_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# Mem/Disk available meter
|
||||||
|
theme[available_start]="#81A1C1"
|
||||||
|
theme[available_mid]="#88C0D0"
|
||||||
|
theme[available_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# Mem/Disk used meter
|
||||||
|
theme[used_start]="#81A1C1"
|
||||||
|
theme[used_mid]="#88C0D0"
|
||||||
|
theme[used_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# Download graph colors
|
||||||
|
theme[download_start]="#81A1C1"
|
||||||
|
theme[download_mid]="#88C0D0"
|
||||||
|
theme[download_end]="#ECEFF4"
|
||||||
|
|
||||||
|
# Upload graph colors
|
||||||
|
theme[upload_start]="#81A1C1"
|
||||||
|
theme[upload_mid]="#88C0D0"
|
||||||
|
theme[upload_end]="#ECEFF4"
|
||||||
22
modules/cmd/monitor/btop/default.nix
Normal file
22
modules/cmd/monitor/btop/default.nix
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeHomePackageConfig {
|
||||||
|
inherit config pkgs;
|
||||||
|
packageName = "btop";
|
||||||
|
packagePath = [ "btop" ];
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"monitor"
|
||||||
|
"btop"
|
||||||
|
];
|
||||||
|
extraConfig = {
|
||||||
|
my.home.xdg.configFile."btop" = {
|
||||||
|
source = ./config;
|
||||||
|
recursive = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
7
modules/cmd/monitor/default.nix
Normal file
7
modules/cmd/monitor/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./all.nix
|
||||||
|
./btop
|
||||||
|
];
|
||||||
|
}
|
||||||
15
modules/cmd/shell/all.nix
Normal file
15
modules/cmd/shell/all.nix
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "all shells";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"shell"
|
||||||
|
"all"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.cmd.shell = {
|
||||||
|
zsh.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
7
modules/cmd/shell/default.nix
Normal file
7
modules/cmd/shell/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./all.nix
|
||||||
|
./zsh.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
49
modules/cmd/shell/zsh.nix
Normal file
49
modules/cmd/shell/zsh.nix
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
default = true;
|
||||||
|
optionName = "default zsh settings";
|
||||||
|
optionPath = [
|
||||||
|
"cmd"
|
||||||
|
"shell"
|
||||||
|
"zsh"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.home =
|
||||||
|
let
|
||||||
|
stateHome = config.my.home.xdg.stateHome;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home.packages = [ pkgs.omz ];
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
dotDir = ".config/zsh";
|
||||||
|
history = {
|
||||||
|
path = "${stateHome}/zsh_history";
|
||||||
|
ignorePatterns = [
|
||||||
|
"la"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
initExtra = ''
|
||||||
|
source ${pkgs.omz}/share/omz/omz.zsh
|
||||||
|
'';
|
||||||
|
sessionVariables = {
|
||||||
|
_ZL_DATA = "${stateHome}/zlua";
|
||||||
|
_FZF_HISTORY = "${stateHome}/fzf_history";
|
||||||
|
};
|
||||||
|
shellAliases = {
|
||||||
|
ls = "lsd";
|
||||||
|
svim = "sudoedit";
|
||||||
|
nf = "neofetch";
|
||||||
|
tmux = "tmux -T RGB,focus,overline,mouse,clipboard,usstyle";
|
||||||
|
pastart = "pasuspender true";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
16
modules/coding/all.nix
Normal file
16
modules/coding/all.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "all coding tools";
|
||||||
|
optionPath = [
|
||||||
|
"coding"
|
||||||
|
"all"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.coding = {
|
||||||
|
editor.all.enable = true;
|
||||||
|
langs.all.enable = true;
|
||||||
|
misc.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
9
modules/coding/default.nix
Normal file
9
modules/coding/default.nix
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./all.nix
|
||||||
|
./misc.nix
|
||||||
|
./langs
|
||||||
|
./editor
|
||||||
|
];
|
||||||
|
}
|
||||||
16
modules/coding/editor/all.nix
Normal file
16
modules/coding/editor/all.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
lib.my.makeSwitch {
|
||||||
|
inherit config;
|
||||||
|
optionName = "all coding editors";
|
||||||
|
optionPath = [
|
||||||
|
"coding"
|
||||||
|
"editor"
|
||||||
|
"all"
|
||||||
|
];
|
||||||
|
config' = {
|
||||||
|
my.coding.editor = {
|
||||||
|
neovim.enable = true;
|
||||||
|
vscode.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
8
modules/coding/editor/default.nix
Normal file
8
modules/coding/editor/default.nix
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./all.nix
|
||||||
|
./neovim
|
||||||
|
./vscode
|
||||||
|
];
|
||||||
|
}
|
||||||
61
modules/coding/editor/neovim/default.nix
Normal file
61
modules/coding/editor/neovim/default.nix
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
programs.neovim = {
|
||||||
|
package = pkgs.neovim-unwrapped.overrideAttrs {
|
||||||
|
treesitter-parsers = { };
|
||||||
|
};
|
||||||
|
enable = true;
|
||||||
|
defaultEditor = true;
|
||||||
|
viAlias = true;
|
||||||
|
vimAlias = true;
|
||||||
|
vimdiffAlias = true;
|
||||||
|
extraPackages = with pkgs; [
|
||||||
|
gcc
|
||||||
|
gnumake
|
||||||
|
|
||||||
|
pyright
|
||||||
|
|
||||||
|
clang-tools
|
||||||
|
|
||||||
|
rust-analyzer
|
||||||
|
pest-ide-tools
|
||||||
|
|
||||||
|
nil
|
||||||
|
|
||||||
|
gotools
|
||||||
|
gopls
|
||||||
|
|
||||||
|
stylua
|
||||||
|
lua-language-server
|
||||||
|
|
||||||
|
nodePackages.vscode-langservers-extracted
|
||||||
|
nodePackages.typescript-language-server
|
||||||
|
vue-language-server
|
||||||
|
typescript
|
||||||
|
nodejs
|
||||||
|
|
||||||
|
ripgrep
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
9
modules/coding/editor/neovim/nvim/init.lua
Normal file
9
modules/coding/editor/neovim/nvim/init.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
require("core.options")
|
||||||
|
require("core.keymaps")
|
||||||
|
|
||||||
|
require("langs.langs-setup")
|
||||||
|
|
||||||
|
require("plugins.plugins-setup")
|
||||||
|
|
||||||
|
require("core.autostart")
|
||||||
|
|
||||||
7
modules/coding/editor/neovim/nvim/lua/core/autostart.lua
Normal file
7
modules/coding/editor/neovim/nvim/lua/core/autostart.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
-- Open tree when in config dir
|
||||||
|
local configdir = vim.fn.system("echo $HOME/.config")
|
||||||
|
configdir = string.sub(configdir, 1, string.len(configdir) - 1)
|
||||||
|
if string.find(vim.fn.system("pwd"), configdir) ~= nil then
|
||||||
|
vim.cmd("NvimTreeOpen")
|
||||||
|
vim.cmd("NvimTmuxNavigateRight")
|
||||||
|
end
|
||||||
113
modules/coding/editor/neovim/nvim/lua/core/globals.lua
Normal file
113
modules/coding/editor/neovim/nvim/lua/core/globals.lua
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
G = {}
|
||||||
|
|
||||||
|
G.keymap_opt = { noremap = true, silent = true }
|
||||||
|
|
||||||
|
function G.close_empty_buffer()
|
||||||
|
local flag = false
|
||||||
|
local cleaned = true
|
||||||
|
local empties = {}
|
||||||
|
for _, b in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
|
local info = vim.fn.getbufinfo(b)[1]
|
||||||
|
if info.loaded == 1 and info.listed == 1 and info.name ~= "" then
|
||||||
|
flag = true
|
||||||
|
elseif info.loaded == 1 and info.name == "" and info.changed == 0 then
|
||||||
|
if flag and not cleaned then
|
||||||
|
for e in table do
|
||||||
|
G.buf_kill("bd", e, false)
|
||||||
|
end
|
||||||
|
cleaned = true
|
||||||
|
elseif cleaned then
|
||||||
|
G.buf_kill("bd", b, false)
|
||||||
|
else
|
||||||
|
table.insert(empties, b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not flag and #empties == 0 then
|
||||||
|
vim.cmd("enew")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function G.switch_input_method(req)
|
||||||
|
local input_status = tonumber(vim.fn.system("fcitx5-remote"))
|
||||||
|
if input_status ~= req then
|
||||||
|
vim.fn.system("fcitx5-remote -t")
|
||||||
|
end
|
||||||
|
return input_status
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function G.buf_kill(kill_command, bufnr, force)
|
||||||
|
kill_command = kill_command or "bd"
|
||||||
|
|
||||||
|
local bo = vim.bo
|
||||||
|
local api = vim.api
|
||||||
|
local fmt = string.format
|
||||||
|
local fn = vim.fn
|
||||||
|
|
||||||
|
if bufnr == 0 or bufnr == nil then
|
||||||
|
bufnr = api.nvim_get_current_buf()
|
||||||
|
end
|
||||||
|
|
||||||
|
local bufname = api.nvim_buf_get_name(bufnr)
|
||||||
|
|
||||||
|
if not force then
|
||||||
|
local choice
|
||||||
|
if bo[bufnr].modified then
|
||||||
|
choice = fn.confirm(fmt([[Save changes to "%s"?]], bufname), "&Yes\n&No\n&Cancel")
|
||||||
|
if choice == 1 then
|
||||||
|
vim.api.nvim_buf_call(bufnr, function()
|
||||||
|
vim.cmd("w")
|
||||||
|
end)
|
||||||
|
elseif choice == 2 then
|
||||||
|
force = true
|
||||||
|
else return
|
||||||
|
end
|
||||||
|
elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then
|
||||||
|
choice = fn.confirm(fmt([[Close "%s"?]], bufname), "&Yes\n&No\n&Cancel")
|
||||||
|
if choice == 1 then
|
||||||
|
force = true
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get list of windows IDs with the buffer to close
|
||||||
|
local windows = vim.tbl_filter(function(win)
|
||||||
|
return api.nvim_win_get_buf(win) == bufnr
|
||||||
|
end, api.nvim_list_wins())
|
||||||
|
|
||||||
|
if force then
|
||||||
|
kill_command = kill_command .. "!"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get list of active buffers
|
||||||
|
local buffers = vim.tbl_filter(function(buf)
|
||||||
|
return api.nvim_buf_is_valid(buf) and bo[buf].buflisted
|
||||||
|
end, api.nvim_list_bufs())
|
||||||
|
|
||||||
|
-- If there is only one buffer (which has to be the current one), vim will
|
||||||
|
-- create a new buffer on :bd.
|
||||||
|
-- For more than one buffer, pick the previous buffer (wrapping around if necessary)
|
||||||
|
if #buffers > 1 and #windows > 0 then
|
||||||
|
for i, v in ipairs(buffers) do
|
||||||
|
if v == bufnr then
|
||||||
|
local prev_buf_idx = i == 1 and #buffers or (i - 1)
|
||||||
|
local prev_buffer = buffers[prev_buf_idx]
|
||||||
|
for _, win in ipairs(windows) do
|
||||||
|
api.nvim_win_set_buf(win, prev_buffer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if buffer still exists, to ensure the target buffer wasn't killed
|
||||||
|
-- due to options like bufhidden=wipe.
|
||||||
|
if api.nvim_buf_is_valid(bufnr) and bo[bufnr].buflisted then
|
||||||
|
vim.cmd(string.format("%s %d", kill_command, bufnr))
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return G
|
||||||
71
modules/coding/editor/neovim/nvim/lua/core/keymaps.lua
Normal file
71
modules/coding/editor/neovim/nvim/lua/core/keymaps.lua
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
local keymap = vim.keymap
|
||||||
|
local globals = require("core.globals")
|
||||||
|
local opt = globals.keymap_opt
|
||||||
|
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("n", "<leader>nh", ":nohl<CR>", opt)
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>sv", "<C-w>v", opt)
|
||||||
|
keymap.set("n", "<leader>sh", "<C-w>s", opt)
|
||||||
|
|
||||||
|
keymap.set("i", "<S-up>", "<ESC>v<up>", opt)
|
||||||
|
keymap.set("i", "<S-down>", "<ESC>v<down>", opt)
|
||||||
|
keymap.set("n", "<S-up>", "v<up>", opt)
|
||||||
|
keymap.set("n", "<S-down>", "v<down>", opt)
|
||||||
|
keymap.set("v", "<S-up>", "<up>", opt)
|
||||||
|
keymap.set("v", "<S-down>", "<down>", opt)
|
||||||
|
|
||||||
|
keymap.set("i", "<S-left>", "<ESC>v<left>", opt)
|
||||||
|
keymap.set("i", "<S-right>", "<ESC>v<right>", opt)
|
||||||
|
keymap.set("n", "<S-left>", "v<left>", opt)
|
||||||
|
keymap.set("n", "<S-right>", "v<right>", opt)
|
||||||
|
keymap.set("v", "<S-left>", "<left>", opt)
|
||||||
|
keymap.set("v", "<S-right>", "<right>", opt)
|
||||||
|
|
||||||
|
keymap.set("v", ".", ">gv", opt)
|
||||||
|
keymap.set("v", ",", "<gv", opt)
|
||||||
|
|
||||||
|
keymap.set({ "n", "v" }, "<pageup>", "9k", opt)
|
||||||
|
keymap.set({ "n", "v" }, "<pagedown>", "9j", opt)
|
||||||
|
keymap.set("i", "<pageup>", "<up><up><up><up><up><up><up><up><up>", opt)
|
||||||
|
keymap.set("i", "<pagedown>", "<down><down><down><down><down><down><down><down><down>", opt)
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>ww", ":w<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>so", ":so<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>qq", ":q<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>qa", ":qa<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>c", function () buf_kill("bd", nil, false) end, opt)
|
||||||
|
|
||||||
|
keymap.set("n", "<C-up>", ":resize +5<CR>", opt)
|
||||||
|
keymap.set("n", "<C-down>", ":resize -5<CR>", opt)
|
||||||
|
keymap.set("n", "<C-right>", ":vert resize +5<CR>", opt)
|
||||||
|
keymap.set("n", "<C-left>", ":vert resize -5<CR>", opt)
|
||||||
|
|
||||||
|
-- buffer
|
||||||
|
keymap.set("n", "H", ":BufferLineCyclePrev<CR>", opt)
|
||||||
|
keymap.set("n", "L", ":BufferLineCycleNext<CR>", opt)
|
||||||
|
keymap.set("n", "<A-h>", ":BufferLineMovePrev<CR>", opt)
|
||||||
|
keymap.set("n", "<A-l>", ":BufferLineMoveNext<CR>", opt)
|
||||||
|
|
||||||
|
-- reload config
|
||||||
|
keymap.set("n", "<leader>rc", ":so ~/.config/nvim/init.lua<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>rp", ":so ~/.config/nvim/lua/plugins/plugins-setup.lua<CR>", opt)
|
||||||
|
|
||||||
|
-- Workspaces
|
||||||
|
keymap.set("n", "<leader>wo", ":Telescope workspaces<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>wa", ":WorkspacesAdd<CR>", opt)
|
||||||
|
keymap.set("n", "<leader>wr", ":WorkspacesRemove<CR>", opt)
|
||||||
|
|
||||||
|
-- Neovide config
|
||||||
|
if vim.g.neovide then
|
||||||
|
keymap.set("v", "<C-C>", "\"+y", opt)
|
||||||
|
keymap.set("n", "<C-V>", "\"+P", opt)
|
||||||
|
keymap.set("i", "<C-V>", "<ESC>l\"+Pli", opt)
|
||||||
|
keymap.set("c", "<C-V>", "<C-R>+", opt)
|
||||||
|
end
|
||||||
|
|
||||||
140
modules/coding/editor/neovim/nvim/lua/core/options.lua
Normal file
140
modules/coding/editor/neovim/nvim/lua/core/options.lua
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
|
-- Tab width setting
|
||||||
|
opt.tabstop = 4
|
||||||
|
opt.shiftwidth = 4
|
||||||
|
opt.softtabstop = 4
|
||||||
|
opt.expandtab = true
|
||||||
|
opt.autoindent = true
|
||||||
|
|
||||||
|
-- Linenumber setting
|
||||||
|
opt.number = true
|
||||||
|
opt.relativenumber = true
|
||||||
|
opt.wrap = false
|
||||||
|
opt.cursorline = true
|
||||||
|
|
||||||
|
opt.mouse:append("a")
|
||||||
|
opt.clipboard:append("unnamedplus")
|
||||||
|
opt.splitright = true
|
||||||
|
opt.splitbelow = true
|
||||||
|
opt.ignorecase = true
|
||||||
|
opt.smartcase = true
|
||||||
|
opt.termguicolors = true
|
||||||
|
opt.signcolumn = "yes"
|
||||||
|
opt.colorcolumn = "110"
|
||||||
|
opt.scrolloff = 8
|
||||||
|
opt.sidescrolloff = 8
|
||||||
|
|
||||||
|
opt.updatetime = 500
|
||||||
|
opt.timeoutlen = 500
|
||||||
|
|
||||||
|
opt.completeopt = ""
|
||||||
|
|
||||||
|
opt.autoread = true
|
||||||
|
vim.g.autoread = true
|
||||||
|
|
||||||
|
vim.g.loaded_ruby_provider = 0
|
||||||
|
|
||||||
|
-- Hightlight on yank
|
||||||
|
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
|
callback = function()
|
||||||
|
vim.highlight.on_yank()
|
||||||
|
end,
|
||||||
|
group = highlight_group,
|
||||||
|
pattern = "*",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Remember last position
|
||||||
|
vim.cmd([[
|
||||||
|
autocmd BufReadPost *
|
||||||
|
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
||||||
|
\ exe "normal! g`\"" |
|
||||||
|
\ endif
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Automaticly 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",
|
||||||
|
callback = function()
|
||||||
|
Last_input_method = require("core.globals").switch_input_method(1)
|
||||||
|
end,
|
||||||
|
group = "AutoInputMethod"
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("CmdlineLeave", {
|
||||||
|
pattern = "*",
|
||||||
|
desc = "Automaticly switch input method",
|
||||||
|
callback = function()
|
||||||
|
require("core.globals").switch_input_method(1)
|
||||||
|
end,
|
||||||
|
group = "AutoInputMethod"
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||||
|
pattern = "*",
|
||||||
|
desc = "Automaticly switch input method",
|
||||||
|
callback = function()
|
||||||
|
require("core.globals").switch_input_method(Last_input_method)
|
||||||
|
end,
|
||||||
|
group = "AutoInputMethod"
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = { "lua" },
|
||||||
|
desc = "fix gf functionality inside .lua files",
|
||||||
|
callback = function()
|
||||||
|
---@diagnostic disable: assign-type-mismatch
|
||||||
|
-- credit: https://github.com/sam4llis/nvim-lua-gf
|
||||||
|
vim.opt_local.include = [[\v<((do|load)file|require|reload)[^''"]*[''"]\zs[^''"]+]]
|
||||||
|
vim.opt_local.includeexpr = "substitute(v:fname,'\\.','/','g')"
|
||||||
|
vim.opt_local.suffixesadd:prepend ".lua"
|
||||||
|
vim.opt_local.suffixesadd:prepend "init.lua"
|
||||||
|
|
||||||
|
for _, path in pairs(vim.api.nvim_list_runtime_paths()) do
|
||||||
|
vim.opt_local.path:append(path .. "/lua")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- fix https://github.com/neovim/neovim/issues/21856
|
||||||
|
vim.api.nvim_create_autocmd({ "VimLeave" }, {
|
||||||
|
callback = function()
|
||||||
|
vim.fn.jobstart("", { detach = true })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- MkDir
|
||||||
|
vim.api.nvim_create_user_command("MakeDirectory", function()
|
||||||
|
---@diagnostic disable-next-line: missing-parameter
|
||||||
|
local path = vim.fn.expand("%")
|
||||||
|
local dir = vim.fn.fnamemodify(path, ":p:h")
|
||||||
|
if vim.fn.isdirectory(dir) == 0 then
|
||||||
|
vim.fn.mkdir(dir, "p")
|
||||||
|
else
|
||||||
|
vim.notify("Directory already exists", vim.log.levels.WARN, { title = "Nvim" })
|
||||||
|
end
|
||||||
|
end, { desc = "Create directory if it doesn't exist" })
|
||||||
|
|
||||||
|
-- Neovide config
|
||||||
|
if vim.g.neovide then
|
||||||
|
local global = vim.g
|
||||||
|
vim.o.guifont = "monospace:h14"
|
||||||
|
global.neovide_padding_top = 0
|
||||||
|
global.neovide_padding_bottom = 0
|
||||||
|
global.neovide_padding_right = 0
|
||||||
|
global.neovide_padding_left = 0
|
||||||
|
global.neovide_hide_mouse_when_typing = true
|
||||||
|
global.neovide_cursor_animation_length = 0.05
|
||||||
|
global.neovide_cursor_trail_size = 0.15
|
||||||
|
global.neovide_confirm_quit = true
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
||||||
|
callback = function()
|
||||||
|
-- A dumb way to clear annoying NeoVim startup screen
|
||||||
|
vim.cmd("normal ia")
|
||||||
|
vim.cmd("normal u")
|
||||||
|
end,
|
||||||
|
})
|
||||||
13
modules/coding/editor/neovim/nvim/lua/langs/go.lua
Normal file
13
modules/coding/editor/neovim/nvim/lua/langs/go.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
vim.api.nvim_create_augroup("Go", {})
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
pattern = { "*.go" },
|
||||||
|
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",
|
||||||
|
})
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
require("langs.go")
|
||||||
|
-- require("langs.rust")
|
||||||
|
require("langs.lualang")
|
||||||
|
require("langs.nix")
|
||||||
|
require("langs.markdown")
|
||||||
35
modules/coding/editor/neovim/nvim/lua/langs/lualang.lua
Normal file
35
modules/coding/editor/neovim/nvim/lua/langs/lualang.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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",
|
||||||
|
})
|
||||||
|
|
||||||
35
modules/coding/editor/neovim/nvim/lua/langs/markdown.lua
Normal file
35
modules/coding/editor/neovim/nvim/lua/langs/markdown.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
vim.api.nvim_create_augroup("Markdown", {})
|
||||||
|
|
||||||
|
local old = {}
|
||||||
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
|
pattern = { "*.md" },
|
||||||
|
desc = "auto md 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 = "Markdown",
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("BufLeave", {
|
||||||
|
pattern = { "*.md" },
|
||||||
|
desc = "auto markdown 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 = "Markdown",
|
||||||
|
})
|
||||||
|
|
||||||
35
modules/coding/editor/neovim/nvim/lua/langs/nix.lua
Normal file
35
modules/coding/editor/neovim/nvim/lua/langs/nix.lua
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
vim.api.nvim_create_augroup("Nix", {})
|
||||||
|
|
||||||
|
local old = {}
|
||||||
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
|
pattern = { "*.nix" },
|
||||||
|
desc = "auto nix 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 = "Nix",
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("BufLeave", {
|
||||||
|
pattern = { "*.nix" },
|
||||||
|
desc = "auto nix 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 = "Nix",
|
||||||
|
})
|
||||||
|
|
||||||
11
modules/coding/editor/neovim/nvim/lua/langs/rust.lua
Normal file
11
modules/coding/editor/neovim/nvim/lua/langs/rust.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
vim.api.nvim_create_augroup("Rust", {})
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
pattern = { "*.rs" },
|
||||||
|
desc = "auto format Rust files",
|
||||||
|
callback = function()
|
||||||
|
vim.fn.system("rustfmt " .. vim.fn.expand("%:p"))
|
||||||
|
vim.cmd("edit")
|
||||||
|
end,
|
||||||
|
group = "Rust",
|
||||||
|
})
|
||||||
|
|
||||||
26
modules/coding/editor/neovim/nvim/lua/plugins/autopairs.lua
Normal file
26
modules/coding/editor/neovim/nvim/lua/plugins/autopairs.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
M = {
|
||||||
|
check_ts = true,
|
||||||
|
ts_config = {
|
||||||
|
lua = { "string", "source" },
|
||||||
|
javascript = { "string", "template_string" },
|
||||||
|
},
|
||||||
|
fast_wrap = {
|
||||||
|
map = '<M-e>',
|
||||||
|
chars = { '{', '[', '(', '"', "'" },
|
||||||
|
pattern = [=[[%'%"%)%>%]%)%}%,]]=],
|
||||||
|
end_key = '$',
|
||||||
|
keys = 'qwertyuiopzxcvbnmasdfghjkl',
|
||||||
|
check_comma = true,
|
||||||
|
highlight = 'Search',
|
||||||
|
highlight_grey='Comment'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||||
|
local ok, cmp = pcall(require, "cmp")
|
||||||
|
if ok then
|
||||||
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
31
modules/coding/editor/neovim/nvim/lua/plugins/bufferline.lua
Normal file
31
modules/coding/editor/neovim/nvim/lua/plugins/bufferline.lua
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
local buf_kill = require("core.globals").buf_kill
|
||||||
|
|
||||||
|
M = {
|
||||||
|
highlights = {
|
||||||
|
buffer_selected = {
|
||||||
|
bold = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
diagnostics = "nvim_lsp",
|
||||||
|
offsets = {
|
||||||
|
{
|
||||||
|
filetype = "NvimTree",
|
||||||
|
text = "File Explorer",
|
||||||
|
highlight = "Directory",
|
||||||
|
text_align = "center"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
close_command = function (bufnr)
|
||||||
|
buf_kill("bd", bufnr, false)
|
||||||
|
end,
|
||||||
|
right_mouse_command = function (bufnr)
|
||||||
|
buf_kill("bd", bufnr, true)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
68
modules/coding/editor/neovim/nvim/lua/plugins/cmp/cmp.lua
Normal file
68
modules/coding/editor/neovim/nvim/lua/plugins/cmp/cmp.lua
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
M = {
|
||||||
|
window = {
|
||||||
|
completion = {
|
||||||
|
border = 'rounded',
|
||||||
|
scrollbar = '║',
|
||||||
|
},
|
||||||
|
documentation = {
|
||||||
|
border = 'rounded',
|
||||||
|
scrollbar = '║',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
format = require('lspkind').cmp_format({
|
||||||
|
mode = "symbol",
|
||||||
|
maxwidth = 50,
|
||||||
|
ellipsis_char = '...',
|
||||||
|
symbol_map = { Codeium = "", }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<Escape>"] = cmp.mapping.abort(),
|
||||||
|
["<Tab>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<Up>"] = cmp.mapping(function (fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
"i",
|
||||||
|
"s"
|
||||||
|
}),
|
||||||
|
["<Down>"] = cmp.mapping(function (fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
"i",
|
||||||
|
"s"
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
-- { name = "codeium" },
|
||||||
|
{ name = "path" },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.o.wildmenu = true
|
||||||
|
vim.o.pumheight = 10
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
M = {
|
||||||
|
sources = {
|
||||||
|
friendly_snippets = true
|
||||||
|
},
|
||||||
|
history = true,
|
||||||
|
updateevents = { "TextChanged", "TextChangedI" }
|
||||||
|
}
|
||||||
|
|
||||||
|
-- vscode format
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" }
|
||||||
|
|
||||||
|
-- snipmate format
|
||||||
|
require("luasnip.loaders.from_snipmate").load()
|
||||||
|
require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" }
|
||||||
|
|
||||||
|
-- lua format
|
||||||
|
require("luasnip.loaders.from_lua").load()
|
||||||
|
require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" }
|
||||||
|
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||||
|
callback = function()
|
||||||
|
if
|
||||||
|
luasnip.session.current_nodes[vim.api.nvim_get_current_buf()]
|
||||||
|
and not luasnip.session.jump_active
|
||||||
|
then
|
||||||
|
luasnip.unlink_current()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
M = {}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
local opt = require("core.globals").keymap_opt
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>tt", ":FloatermNew<CR>", opt)
|
||||||
19
modules/coding/editor/neovim/nvim/lua/plugins/gitsigns.lua
Normal file
19
modules/coding/editor/neovim/nvim/lua/plugins/gitsigns.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
M = {
|
||||||
|
signs = {
|
||||||
|
add = { text = '▎', color = "green" },
|
||||||
|
change = { text = '▎', color = "blue" },
|
||||||
|
delete = { text = '_' },
|
||||||
|
topdelete = { text = '‾' },
|
||||||
|
changedelete = { text = '~' },
|
||||||
|
},
|
||||||
|
current_line_blame = true,
|
||||||
|
current_line_blame_opts = {
|
||||||
|
virt_text = true,
|
||||||
|
virt_text_pos = 'eol',
|
||||||
|
delay = 0,
|
||||||
|
ignore_whitespace = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
M = {
|
||||||
|
enabled = true,
|
||||||
|
indent = {
|
||||||
|
tab_char = "▎"
|
||||||
|
},
|
||||||
|
scope = {
|
||||||
|
enabled = true,
|
||||||
|
show_start = false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.opt.list = true
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
M = {}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
local servers = {
|
||||||
|
"lua_ls",
|
||||||
|
"pyright",
|
||||||
|
"gopls",
|
||||||
|
"clangd",
|
||||||
|
"rust_analyzer",
|
||||||
|
"ts_ls",
|
||||||
|
"jsonls",
|
||||||
|
"cssls",
|
||||||
|
"nil_ls",
|
||||||
|
"html",
|
||||||
|
}
|
||||||
|
|
||||||
|
local extra_config = {
|
||||||
|
lua_ls = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
workspace = {
|
||||||
|
library = {
|
||||||
|
vim.api.nvim_get_runtime_file("", true),
|
||||||
|
"${3rd}/luv/library",
|
||||||
|
"${3rd}/luassert/library",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
globals = {
|
||||||
|
"vim"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = "Replace"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rust_analyzer = {
|
||||||
|
settings = {
|
||||||
|
rust_analyzer = {
|
||||||
|
check = {
|
||||||
|
command = "clippy"
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
command = { "rustfmt" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
local opts = {
|
||||||
|
focusable = false,
|
||||||
|
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||||
|
border = "rounded",
|
||||||
|
source = "always",
|
||||||
|
prefix = " ",
|
||||||
|
scope = "line",
|
||||||
|
}
|
||||||
|
vim.diagnostic.open_float(nil, opts)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities.textDocument.foldingRange = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true,
|
||||||
|
}
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
for _, server in ipairs(servers) do
|
||||||
|
local extra = extra_config[server] or {}
|
||||||
|
local config = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
for k, v in pairs(extra) do
|
||||||
|
config[k] = v
|
||||||
|
end
|
||||||
|
lspconfig[server].setup(config)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_lines = true
|
||||||
|
})
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
M = {
|
||||||
|
-- ensure_installed = require("plugins.lsp.servers")
|
||||||
|
ensure_installed = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
12
modules/coding/editor/neovim/nvim/lua/plugins/lsp/mason.lua
Normal file
12
modules/coding/editor/neovim/nvim/lua/plugins/lsp/mason.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
M = {
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
package_installed = "✓",
|
||||||
|
package_pending = "➜",
|
||||||
|
package_uninstalled = "✗"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
29
modules/coding/editor/neovim/nvim/lua/plugins/lsp/others.lua
Normal file
29
modules/coding/editor/neovim/nvim/lua/plugins/lsp/others.lua
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
-- Keymaps
|
||||||
|
local opt = require("core.globals").keymap_opt
|
||||||
|
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opt)
|
||||||
|
vim.keymap.set("n", "<leader>lR", vim.lsp.buf.rename, opt)
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = { spacing = 4, prefix = "●" },
|
||||||
|
signs = true,
|
||||||
|
underline = true,
|
||||||
|
update_in_insert = true,
|
||||||
|
severity_sort = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||||
|
for type, icon in pairs(signs) do
|
||||||
|
local hl = "DiagnosticSign" .. type
|
||||||
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
|
border = "single",
|
||||||
|
})
|
||||||
|
--[[ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||||
|
border = "single",
|
||||||
|
focusable = false,
|
||||||
|
relative = "cursor",
|
||||||
|
}) ]]
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
M = {}
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>",
|
||||||
|
{ desc = "Toggle Outline" })
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
M = {
|
||||||
|
"lua_ls",
|
||||||
|
"pyright",
|
||||||
|
"gopls",
|
||||||
|
"clangd",
|
||||||
|
"rust_analyzer",
|
||||||
|
"ts_ls",
|
||||||
|
"jsonls",
|
||||||
|
"cssls",
|
||||||
|
"nil_ls",
|
||||||
|
"html",
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user