refactoring for isServer and isWorkstation: part 4

This commit is contained in:
William 2025-03-13 15:47:49 -03:00
parent 6addea64c4
commit a52ca12286
17 changed files with 300 additions and 239 deletions

View file

@ -82,7 +82,7 @@
};
};
modules = [
./hosts/desktops/rotterdam.nix
./hosts/rotterdam.nix
agenix.nixosModules.default
home-manager.nixosModules.default
impermanence.nixosModules.impermanence
@ -108,7 +108,7 @@
};
};
modules = [
./hosts/desktops/io.nix
./hosts/io.nix
agenix.nixosModules.default
home-manager.nixosModules.default
impermanence.nixosModules.impermanence
@ -134,7 +134,7 @@
};
};
modules = [
./hosts/servers/alexandria.nix
./hosts/alexandria.nix
agenix.nixosModules.default
home-manager-stable.nixosModules.default
self.nixosModules.qbittorrent

View file

@ -3,7 +3,9 @@
{
services.postgresql.enable = true;
# TODO: remove when bug fux
# TODO: remove when bug fix
# serokell/deploy-rs/issues/57
# NixOS/nixpkgs/issues/180175
# Workaround for upstream bug in NetworkManager-wait-online.service
systemd.services.NetworkManager-wait-online.enable = false;
}

View file

@ -32,6 +32,7 @@
ls = "${pkgs.eza}/bin/eza --icons --group-directories-first";
neofetch = "fastfetch";
tree = "ls --tree";
tsh = "ssh -o RequestTTY=yes $argv tmux -u -CC new -A -s tmux-main";
syscleanup = "sudo nix-collect-garbage -d; sudo /run/current-system/bin/switch-to-configuration boot";
};
}

View file

@ -38,12 +38,18 @@
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "bkp";
users = {
user = import ../../users/user.nix;
root = import ../../users/root.nix;
};
extraSpecialArgs = {
inherit hostType;
};
};
}
# Server specific configuration
(lib.mkIf hostType.isServer {
home-manager.users.user = import ../../users/servers/user.nix;
})
# Workstation specific configuration
@ -73,8 +79,6 @@
hashedPassword = "$y$j9T$yHLUDvj6bDIP19dchU.aA/$OY4qeFNtx/GvI.VUYx4LapHiiVwi0MEvs8AT0HN7j58";
};
};
home-manager.users.user = import ../../users/desktops/user.nix;
})
];
}

View file

@ -1,8 +0,0 @@
{ ... }:
{
imports = [
./home.nix
./programs.nix
];
}

View file

@ -1,13 +0,0 @@
{ pkgs, ... }:
{
home = {
username = "user";
homeDirectory = "/home/user";
stateVersion = "22.05";
sessionVariables = {
EDITOR = "hx";
};
packages = with pkgs; [ nix-your-shell ];
};
}

View file

@ -1,156 +0,0 @@
{ pkgs, ... }:
{
programs = {
password-store.enable = true;
bash = {
enable = true;
historyFile = "~/.cache/bash_history";
};
helix = {
enable = true;
settings = {
editor = {
file-picker.hidden = false;
idle-timeout = 0;
line-number = "relative";
cursor-shape = {
normal = "block";
insert = "bar";
select = "underline";
};
soft-wrap.enable = true;
auto-format = true;
indent-guides.render = true;
};
keys.normal.space = {
space = "file_picker";
w = ":w";
q = ":q";
esc = [
"collapse_selection"
"keep_primary_selection"
];
};
};
languages = {
language = [
{
name = "nix";
auto-format = true;
formatter.command = "nixfmt";
}
{
name = "typst";
auto-format = true;
formatter.command = "typstyle -c 1000 -i";
}
];
};
};
direnv = {
enable = true;
nix-direnv.enable = true;
};
tmux = {
enable = true;
clock24 = true;
terminal = "xterm-256color";
mouse = true;
keyMode = "vi";
};
starship = {
enable = true;
enableBashIntegration = true;
enableFishIntegration = true;
settings = {
add_newline = false;
format = ''
$directory$git_branch$git_status$nix_shell
[ ](bold green)
'';
right_format = "$cmd_duration$character";
character = {
error_symbol = "[](red)";
success_symbol = "[󱐋](green)";
};
cmd_duration = {
format = "[󰄉 $duration ]($style)";
style = "yellow";
min_time = 500;
};
git_branch = {
symbol = " ";
style = "purple";
};
git_status.style = "red";
nix_shell = {
format = "via [$symbol$state]($style)";
heuristic = true;
style = "blue";
symbol = "󱄅 ";
};
};
};
git = {
enable = true;
diff-so-fancy.enable = true;
userName = "William";
userEmail = "baduhai@proton.me";
};
btop = {
enable = true;
settings = {
theme_background = false;
proc_sorting = "cpu direct";
update_ms = 500;
};
};
fish = {
enable = true;
interactiveShellInit = "nix-your-shell fish | source";
loginShellInit = "nix-your-shell fish | source";
functions = {
fish_greeting = "";
tsh = "ssh -o RequestTTY=yes $argv tmux -u -CC new -A -s tmux-main";
};
plugins = [
{
name = "bang-bang";
src = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-bang-bang";
rev = "f969c618301163273d0a03d002614d9a81952c1e";
sha256 = "sha256-A8ydBX4LORk+nutjHurqNNWFmW6LIiBPQcxS3x4nbeQ=";
};
}
{
name = "z";
src = pkgs.fetchFromGitHub {
owner = "jethrokuan";
repo = "z";
rev = "85f863f20f24faf675827fb00f3a4e15c7838d76";
sha256 = "sha256-+FUBM7CodtZrYKqU542fQD+ZDGrd2438trKM0tIESs0=";
};
}
{
name = "sponge";
src = pkgs.fetchFromGitHub {
owner = "meaningful-ooo";
repo = "sponge";
rev = "384299545104d5256648cee9d8b117aaa9a6d7be";
sha256 = "sha256-MdcZUDRtNJdiyo2l9o5ma7nAX84xEJbGFhAVhK+Zm1w=";
};
}
];
};
};
}

View file

@ -1,37 +0,0 @@
{ pkgs, ... }:
{
fonts.fontconfig.enable = true;
programs = {
password-store.package = pkgs.pass-wayland;
mangohud.enable = true;
obs-studio = {
enable = true;
plugins = [
pkgs.obs-studio-plugins.obs-vkcapture
pkgs.obs-studio-plugins.obs-backgroundremoval
pkgs.obs-studio-plugins.obs-pipewire-audio-capture
];
};
fish = {
functions = {
sysrebuild = "nh os switch --ask";
sysrebuild-boot = "nh os boot --ask";
sysupdate = "nix flake update --commit-lock-file --flake /home/user/Projects/personal/nix-config";
};
};
};
gtk = {
gtk3.extraConfig = {
gtk-decoration-layout = "appmenu:";
};
gtk4.extraConfig = {
gtk-decoration-layout = "appmenu:";
};
};
}

View file

@ -1,10 +0,0 @@
{ ... }:
{
imports = [
# Host-common imports
../common
# Desktop-common imports
./common
];
}

View file

@ -0,0 +1,7 @@
{...}:
{
imports = [
./programs.nix
];
}

View file

@ -0,0 +1,98 @@
{
config,
hostType,
lib,
pkgs,
...
}:
{
config = lib.mkMerge [
# Common configuration
{
home = {
sessionVariables = {
EDITOR = "hx";
};
};
programs = {
bash = {
enable = true;
historyFile = "~/.cache/bash_history";
};
helix = {
enable = true;
settings = {
editor = {
file-picker.hidden = false;
idle-timeout = 0;
line-number = "relative";
cursor-shape = {
normal = "block";
insert = "bar";
select = "underline";
};
soft-wrap.enable = true;
auto-format = true;
indent-guides.render = true;
};
keys.normal.space = {
space = "file_picker";
w = ":w";
q = ":q";
esc = [
"collapse_selection"
"keep_primary_selection"
];
};
};
};
fish = {
enable = true;
functions.fish_greeting = "";
plugins = [
{
name = "bang-bang";
src = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-bang-bang";
rev = "f969c618301163273d0a03d002614d9a81952c1e";
sha256 = "sha256-A8ydBX4LORk+nutjHurqNNWFmW6LIiBPQcxS3x4nbeQ=";
};
}
{
name = "z";
src = pkgs.fetchFromGitHub {
owner = "jethrokuan";
repo = "z";
rev = "85f863f20f24faf675827fb00f3a4e15c7838d76";
sha256 = "sha256-+FUBM7CodtZrYKqU542fQD+ZDGrd2438trKM0tIESs0=";
};
}
{
name = "sponge";
src = pkgs.fetchFromGitHub {
owner = "meaningful-ooo";
repo = "sponge";
rev = "384299545104d5256648cee9d8b117aaa9a6d7be";
sha256 = "sha256-MdcZUDRtNJdiyo2l9o5ma7nAX84xEJbGFhAVhK+Zm1w=";
};
}
];
};
};
}
# Server specific configuration
(lib.mkIf hostType.isServer {
})
# Workstation specific configuration
(lib.mkIf hostType.isWorkstation {
})
];
}

14
users/root.nix Normal file
View file

@ -0,0 +1,14 @@
{ ... }:
{
home = {
username = "root";
homeDirectory = "/root";
stateVersion = "22.05";
};
imports = [
./modules
./root
];
}

5
users/root/default.nix Normal file
View file

@ -0,0 +1,5 @@
{ ... }:
{
imports = [ ];
}

View file

@ -1,8 +0,0 @@
{ ... }:
{
imports = [
# Host-common imports
../common
];
}

14
users/user.nix Normal file
View file

@ -0,0 +1,14 @@
{ ... }:
{
home = {
username = "user";
homeDirectory = "/home/user";
stateVersion = "22.05";
};
imports = [
./modules
./user
];
}

148
users/user/programs.nix Normal file
View file

@ -0,0 +1,148 @@
{
config,
hostType,
lib,
pkgs,
...
}:
{
config = lib.mkMerge [
# Common configuration
{
home = {
packages = with pkgs; [ nix-your-shell ];
};
programs = {
helix.languages = {
language = [
{
name = "nix";
auto-format = true;
formatter.command = "nixfmt";
}
{
name = "typst";
auto-format = true;
formatter.command = "typstyle -c 1000 -i";
}
];
};
password-store.enable = true;
direnv = {
enable = true;
nix-direnv.enable = true;
};
fish = {
interactiveShellInit = "nix-your-shell fish | source";
loginShellInit = "nix-your-shell fish | source";
};
tmux = {
enable = true;
clock24 = true;
terminal = "xterm-256color";
mouse = true;
keyMode = "vi";
};
starship = {
enable = true;
enableBashIntegration = true;
enableFishIntegration = true;
settings = {
add_newline = false;
format = ''
$directory$git_branch$git_status$nix_shell
[ ](bold green)
'';
right_format = "$cmd_duration$character";
character = {
error_symbol = "[](red)";
success_symbol = "[󱐋](green)";
};
cmd_duration = {
format = "[󰄉 $duration ]($style)";
style = "yellow";
min_time = 500;
};
git_branch = {
symbol = " ";
style = "purple";
};
git_status.style = "red";
nix_shell = {
format = "via [$symbol$state]($style)";
heuristic = true;
style = "blue";
symbol = "󱄅 ";
};
};
};
git = {
enable = true;
diff-so-fancy.enable = true;
userName = "William";
userEmail = "baduhai@proton.me";
};
btop = {
enable = true;
settings = {
theme_background = false;
proc_sorting = "cpu direct";
update_ms = 500;
};
};
};
}
# Server specific configuration
(lib.mkIf hostType.isServer {
})
# Workstation specific configuration
(lib.mkIf hostType.isWorkstation {
fonts.fontconfig.enable = true;
programs = {
password-store.package = pkgs.pass-wayland;
mangohud.enable = true;
obs-studio = {
enable = true;
plugins = [
pkgs.obs-studio-plugins.obs-vkcapture
pkgs.obs-studio-plugins.obs-backgroundremoval
pkgs.obs-studio-plugins.obs-pipewire-audio-capture
];
};
fish = {
functions = {
sysrebuild = "nh os switch --ask";
sysrebuild-boot = "nh os boot --ask";
sysupdate = "nix flake update --commit-lock-file --flake /home/user/Projects/personal/nix-config";
};
};
};
gtk = {
gtk3.extraConfig = {
gtk-decoration-layout = "appmenu:";
};
gtk4.extraConfig = {
gtk-decoration-layout = "appmenu:";
};
};
})
];
}