Compare commits

...

2 commits

Author SHA1 Message Date
chayleaf 5a3dda7a10
server: device-specific code cleanup 2024-07-13 06:43:05 +07:00
chayleaf c85b92b4cb
home: add minimal config 2024-07-13 05:33:43 +07:00
7 changed files with 73 additions and 57 deletions

View file

@ -231,7 +231,20 @@
# for each hostname, for each user, generate an attribute "${user}@${hostname}"
homeConfigurations =
builtins.listToAttrs (builtins.concatLists
{
"chayleaf@hysteria" = inputs.home-manager.lib.homeManagerConfiguration {
pkgs = mkPkgs {
system = "x86_64-linux";
overlays = [ overlay ];
};
extraSpecialArgs = { inherit inputs; };
modules = [
./home/hosts/remote.nix
({ pkgs, ... }: { home.file.hysteria.source = pkgs.hysteria; })
];
};
}
// builtins.listToAttrs (builtins.concatLists
(lib.flip lib.mapAttrsToList config
(hostname: { system, home ? {}, ... }:
let

15
home/hosts/remote.nix Normal file
View file

@ -0,0 +1,15 @@
{ inputs
, ...
}:
{
imports = [
../modules/general.nix
inputs.nur.nixosModules.nur
];
home.stateVersion = "24.05";
home.username = "chayleaf";
home.homeDirectory = "/home/chayleaf";
minimal = true;
}

View file

@ -99,10 +99,10 @@
# the following 4 values are special in some way
# (e.g. even if you use -gx to set them, it won't work)
set -U _tide_left_items pwd git vi_mode
set -U _tide_left_items context pwd git vi_mode
set -U _tide_prompt_69105 \x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b34m\x1b\x5b44m\x20\x40PWD\x40\x20\x1b\x5b34m\x1b\x5b40m\ue0b0\x1b\x5b32m\x1b\x5b40m\x20\u276f\x20\x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b30m\ue0b0 \x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b30m\ue0b2\x1b\x5b32m\x1b\x5b40m\x20\uf00c\x20\x1b\x5b33m\x1b\x5b40m\ue0b2\x1b\x5b30m\x1b\x5b43m\x2021m\x2023s\x20\x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b33m
set -U _tide_prompt_79899 \x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b34m\x1b\x5b44m\x20\x40PWD\x40\x20\x1b\x5b34m\x1b\x5b40m\ue0b0\x1b\x5b32m\x1b\x5b40m\x20\u276f\x20\x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b30m\ue0b0 \x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b30m\ue0b2\x1b\x5b32m\x1b\x5b40m\x20\uf00c\x20\x1b\x5b33m\x1b\x5b40m\ue0b2\x1b\x5b30m\x1b\x5b43m\x2015s\x20\x1b\x28B\x1b\x5bm\x1b\x28B\x1b\x5bm\x1b\x5b33m
set -U _tide_right_items status cmd_duration context jobs rustc nix_shell
set -U _tide_right_items status cmd_duration jobs rustc nix_shell
# for the following values, -gx works too (-g doesn't)
# but it pollutes children's env, so do -U
@ -160,7 +160,7 @@
set -U tide_kubectl_color black
set -U tide_kubectl_icon \u2388
set -U tide_left_prompt_frame_enabled false
set -U tide_left_prompt_items pwd git vi_mode
set -U tide_left_prompt_items context pwd git vi_mode
set -U tide_left_prompt_prefix
set -U tide_left_prompt_separator_diff_color \ue0b0
set -U tide_left_prompt_separator_same_color \ue0b1
@ -195,7 +195,7 @@
set -U tide_pwd_icon_unwritable \uf023
set -U tide_pwd_markers \x2ebzr \x2ecitc \x2egit \x2ehg \x2enode\x2dversion \x2epython\x2dversion \x2eruby\x2dversion \x2eshorten_folder_marker \x2esvn \x2eterraform Cargo\x2etoml composer\x2ejson CVS go\x2emod package\x2ejson
set -U tide_right_prompt_frame_enabled false
set -U tide_right_prompt_items status cmd_duration context jobs node rustc java php go kubectl toolbox terraform aws nix_shell crystal
set -U tide_right_prompt_items status cmd_duration jobs node rustc java php go kubectl toolbox terraform aws nix_shell crystal
set -U tide_right_prompt_prefix \ue0b2
set -U tide_right_prompt_separator_diff_color \ue0b2
set -U tide_right_prompt_separator_same_color \ue0b3

View file

@ -11,9 +11,9 @@
./zsh.nix
./fish.nix
];
manual.json.enable = true;
manual.json.enable = !config.minimal;
services.gpg-agent = {
enable = true;
enable = !config.minimal;
enableSshSupport = true;
maxCacheTtl = 72000;
maxCacheTtlSsh = 72000;
@ -65,14 +65,14 @@
extraPackages = with pkgs; [
# utils
gnused mktemp fzf coreutils-full findutils xdg-utils gnupg whois curl
file mediainfo unzip gnutar man rclone sshfs trash-cli
file mediainfo unzip gnutar man rclone
# for preview
# exa - TODO: replace with eza wrapper?
bat
libarchive atool
glow w3m
bat libarchive atool glow
# for opening
p7zip unrar-wrapper odt2txt
p7zip unrar-wrapper
] ++ lib.optionals (!config.minimal) [
odt2txt w3m sshfs trash-cli
];
plugins = {
src = pluginSrc;
@ -92,14 +92,14 @@
home-manager.enable = true;
# i only use this as a login shell
bash = {
enable = true;
enable = !config.minimal;
initExtra = ''
bind -x '"\C-r": __atuin_history'
export ATUIN_NOBIND=true
'';
};
git = {
enable = true;
enable = !config.minimal;
package = pkgs.gitAndTools.gitFull;
delta.enable = true;
extraConfig = {
@ -135,7 +135,7 @@
};
};
ssh = {
enable = true;
enable = !config.minimal;
compression = true;
};
tmux = {
@ -145,7 +145,7 @@
keyMode = "vi";
};
gpg = {
enable = true;
enable = !config.minimal;
homedir = "${config.xdg.dataHome}/gnupg";
mutableKeys = true;
mutableTrust = true;
@ -156,7 +156,7 @@
variables.show-mode-in-prompt = true;
};
nix-index = {
enable = true;
enable = !config.minimal;
# don't add pkgs.nix to PATH
# use the nix that's already in PATH
# (because I use nix plugins and plugins are nix version-specific)
@ -168,31 +168,38 @@
# vimKeys = true;
#};
alot = {
enable = true;
enable = !config.minimal;
settings = {
handle_mouse = true;
initial_command = "search tag:inbox AND NOT tag:killed";
prefer_plaintext = true;
};
};
msmtp.enable = true;
msmtp.enable = !config.minimal;
notmuch = {
enable = true;
enable = !config.minimal;
hooks.preNew = ''
${config.services.mbsync.package}/bin/mbsync --all || ${pkgs.coreutils}/bin/true
'';
};
mbsync.enable = true;
mbsync.enable = !config.minimal;
};
#services.mbsync.enable = true;
# TODO: see https://github.com/pazz/alot/issues/1632
home.file.".mailcap".text = ''
text/html; ${pkgs.w3m}/bin/w3m -dump -o document_charset=%{charset} -o display_link_number=1 '%s'; nametemplate=%s.html; copiousoutput
'';
home.file.".mailcap" = lib.mkIf (!config.minimal) {
text = ''
text/html; ${pkgs.w3m}/bin/w3m -dump -o document_charset=%{charset} -o display_link_number=1 '%s'; nametemplate=%s.html; copiousoutput
'';
};
home.file.".cache/nix-index/files".source = assert config.xdg.cacheHome == "${config.home.homeDirectory}/.cache"; inputs.nix-index-database.packages.${pkgs.system}.nix-index-database;
home.file.".cache/nix-index/files" = lib.mkIf (!config.minimal) {
source =
assert config.xdg.cacheHome == "${config.home.homeDirectory}/.cache";
inputs.nix-index-database.packages.${pkgs.system}.nix-index-database;
};
systemd.user.tmpfiles.rules = builtins.map (file: "r! \"/home/${config.home.username}/${file}\"") [
systemd.user.tmpfiles.rules = lib.mkIf (!config.minimal)
(builtins.map (file: "r! \"/home/${config.home.username}/${file}\"") [
".local/share/clipman.json"
".local/state/lesshst" # I don't need less search history to persist across boots...
".Xauthority"
@ -301,12 +308,14 @@
] ++ builtins.map (dir: "x \"/home/${config.home.username}/${dir}/\"") [
# WHY DOES THIS KEEP PART OF THE CONFIG
".cache/keepassxc"
];
]);
home.packages = with pkgs; [
rclone sshfs fuse
file jq python3Full killall
appimage-run comma nix-output-monitor
comma nix-output-monitor
unzip p7zip unrar-wrapper
] ++ lib.optionals (!config.minimal) [
appimage-run
];
}

View file

@ -1,5 +1,9 @@
{ lib, config, ... }:
with lib; {
options.minimal = mkOption {
type = types.bool;
default = false;
};
options.phone = {
enable = mkOption {
type = types.bool;

View file

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
programs.zsh = {
enable = true;
enable = !config.minimal;
# zsh-autosuggestions
autosuggestion.enable = true;
# zsh-syntax-highlighting

View file

@ -35,7 +35,7 @@ in
"net.ipv4.tcp_congestion_control" = "bbr";
};
# as expected, systemd initrd and networking didn't work well, and i really cba to debug it
# as expected, systemd initrd didn't work well, and i really cba to debug it
networking.useDHCP = false;
networking.useNetworkd = true;
systemd.network = {
@ -50,46 +50,22 @@ in
networks."10-dhcp" = {
DHCP = "yes";
name = "e*";
networkConfig = {
IPv6AcceptRA = "yes";
};
networkConfig.IPv6AcceptRA = "yes";
dhcpV4Config = {
ClientIdentifier = "mac";
DUIDType = "link-layer";
};
dhcpV6Config = {
DUIDType = "link-layer";
};
dhcpV6Config.DUIDType = "link-layer";
};
};
boot.initrd = {
/*systemd = {
enable = true;
network = {
enable = true;
links."10-mac" = {
matchConfig.OriginalName = "e*";
linkConfig = {
MACAddressPolicy = "none";
MACAddress = router-config.router-settings.serverInitrdMac;
};
};
networks."10-dhcp" = {
DHCP = "yes";
name = "e*";
};
};
};*/
# eth0 on some kernels
# end0 on other kernels
# sometimes even version dependent
preLVMCommands = lib.mkOrder 499 ''
ip link set end0 address ${router-config.router-settings.serverInitrdMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true
'';
# postMountCommands = ''
# ip link set end0 address ${router-config.router-settings.serverMac} || ip link set eth0 address ${router-config.router-settings.serverMac} || true
# '';
network.enable = true;
network.flushBeforeStage2 = true;
network.udhcpc.enable = true;
@ -102,7 +78,6 @@ in
"/secrets/initrd/ssh_host_rsa_key"
"/secrets/initrd/ssh_host_ed25519_key"
];
# shell = "/bin/cryptsetup-askpass";
};
luks.devices.cryptroot = {
device = parts.enc;