1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-30 03:27:45 +00:00

Start refactor

This commit is contained in:
RGBCube 2025-01-11 15:51:21 +03:00
parent 99b7ccfadb
commit 06cce18e72
155 changed files with 2139 additions and 3738 deletions

17
modules/common/agenix.nix Normal file
View file

@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }: let
inherit (lib) attrNames head mkAliasOptionModule mkIf;
in {
imports = [(mkAliasOptionModule [ "secrets" ] [ "age" "secrets" ])];
age.identityPaths = [
(if config.isLinux then
"/root/.ssh/id"
else
"/Users/${config.users.users |> attrNames |> head}/.ssh/id")
];
environment = mkIf config.isDesktop {
shellAliases.agenix = "agenix --identity ~/.ssh/id";
systemPackages = [ pkgs.agenix ];
};
}

20
modules/common/bat.nix Normal file
View file

@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }: let
inherit (lib) enabled;
in {
environment.variables = {
MANPAGER = "bat --plain";
PAGER = "bat --plain";
};
environment.shellAliases = {
cat = "bat";
less = "bat --plain";
};
home-manager.sharedModules = [{
programs.bat = enabled {
config.theme = "base16";
themes.base16.src = pkgs.writeText "base16.tmTheme" config.theme.tmTheme;
config.pager = "less -FR";
};
}];
}

13
modules/common/btop.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, lib, ... }: let
inherit (lib) enabled;
in {
home-manager.sharedModules = [{
xdg.configFile."btop/themes/base16.theme".text = config.theme.btopTheme;
programs.btop = enabled {
settings.color_theme = "base16";
settings.rounded_corners = config.theme.cornerRadius > 0;
};
}];
}

View file

@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }: let
inherit (lib) merge mkIf;
in merge <| mkIf config.isDesktop {
home-manager.sharedModules = [{
xdg.configFile."Vencord/settings/quickCss.css".text = config.theme.discordCss;
}];
environment.systemPackages = mkIf config.isLinux [
((pkgs.discord.override {
withOpenASAR = true;
withVencord = true;
}).overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.makeWrapper ];
postFixup = ''
wrapProgram $out/opt/Discord/Discord \
--set ELECTRON_OZONE_PLATFORM_HINT "auto" \
--add-flags "--enable-features=UseOzonePlatform --ozone-platform=wayland"
'';
}))
];
}

24
modules/common/dns.nix Normal file
View file

@ -0,0 +1,24 @@
{ lib, ... }: let
inherit (lib) mkConst;
in {
options.dnsServers = mkConst [
"45.90.28.0#7f2bf8.dns.nextdns.io"
"2a07:a8c0::#7f2bf8.dns.nextdns.io"
"45.90.30.0#7f2bf8.dns.nextdns.io"
"2a07:a8c1::#7f2bf8.dns.nextdns.io"
];
options.fallbackDnsServers = mkConst [
"1.1.1.1#one.one.one.one"
"2606:4700:4700::1111#one.one.one.one"
"1.0.0.1#one.one.one.one"
"2606:4700:4700::1001#one.one.one.one"
"8.8.8.8#dns.google"
"2001:4860:4860::8888#dns.google"
"8.8.4.4#dns.google"
"2001:4860:4860::8844#dns.google"
];
}

View file

@ -0,0 +1,78 @@
{ config, lib, pkgs, ... }: let
inherit (lib) enabled mapAttrsToList merge mkIf;
in merge <| mkIf config.isDesktop {
home-manager.sharedModules = [{
programs.nushell.environmentVariables = {
TERMINAL = mkIf config.isLinux "ghostty";
TERM_PROGRAM = mkIf config.isDarwin "ghostty";
};
programs.ghostty = enabled {
# Don't actually install Ghostty if we are on Darwin.
# For some reason it is marked as broken.
package = mkIf config.isDarwin <| pkgs.writeScriptBin "not-ghostty" "";
# Bat syntax points to emptyDirectory.
installBatSyntax = !config.isDarwin;
clearDefaultKeybinds = true;
settings = with config.theme; {
font-size = font.size.normal;
font-family = font.mono.name;
window-padding-x = padding;
window-padding-y = padding;
confirm-close-surface = false;
window-decoration = config.isDarwin;
config-file = toString <| pkgs.writeText "base16-config" ghosttyConfig;
keybind = mapAttrsToList (name: value: "ctrl+shift+${name}=${value}") {
c = "copy_to_clipboard";
v = "paste_from_clipboard";
z = "jump_to_prompt:-2";
x = "jump_to_prompt:2";
h = "write_scrollback_file:paste";
i = "inspector:toggle";
page_down = "scroll_page_fractional:0.33";
down = "scroll_page_lines:1";
j = "scroll_page_lines:1";
page_up = "scroll_page_fractional:-0.33";
up = "scroll_page_lines:-1";
k = "scroll_page_lines:-1";
home = "scroll_to_top";
end = "scroll_to_bottom";
enter = "reset_font_size";
plus = "increase_font_size:1";
minus = "decrease_font_size:1";
t = "new_tab";
q = "close_surface";
"physical:one" = "goto_tab:1";
"physical:two" = "goto_tab:2";
"physical:three" = "goto_tab:3";
"physical:four" = "goto_tab:4";
"physical:five" = "goto_tab:5";
"physical:six" = "goto_tab:6";
"physical:seven" = "goto_tab:7";
"physical:eight" = "goto_tab:8";
"physical:nine" = "goto_tab:9";
"physical:zero" = "goto_tab:10";
} ++ mapAttrsToList (name: value: "ctrl+${name}=${value}") {
"physical:tab" = "next_tab";
"shift+physical:tab" = "previous_tab";
};
};
};
}];
}

161
modules/common/git.nix Normal file
View file

@ -0,0 +1,161 @@
{ self, config, lib, pkgs, ... }: let
inherit (lib) head mkAfter enabled merge mkIf;
inherit (lib.strings) match;
in {
environment.shellAliases = merge {
g = "git";
ga = "git add";
gaa = "git add ./";
gab = "git absorb";
gabr = "git absorb --and-rebase";
gb = "git branch";
gbv = "git branch --verbose";
gc = "git commit";
gca = "git commit --amend --no-edit";
gcm = "git commit --message";
gcam = "git commit --amend --message";
gcl = "git clone";
gd = "git diff";
gds = "git diff --staged";
gp = "git push";
gpf = "git push --force-with-lease";
gl = "git log";
glo = "git log --oneline --graph";
glp = "git log -p --ext-diff";
gpl = "git pull";
gplr = "git pull --rebase";
gplff = "git pull --ff-only";
gr = "git recent";
grb = "git rebase";
grba = "git rebase --abort";
grbc = "git rebase --continue";
grbi = "git rebase --interactive";
grbm = "git rebase master";
grl = "git reflog";
grm = "git remote";
grma = "git remote add";
grmv = "git remote --verbose";
grmsu = "git remote set-url";
grs = "git reset";
grsh = "git reset --hard";
gs = "git stash";
gsp = "git stash pop";
gsw = "git switch";
gswm = "git switch master";
gsh = "git show --ext-diff";
gst = "git status";
} <| mkIf config.isDesktop {
"\"??\"" = "gh copilot suggest --target shell";
"\"gh?\"" = "gh copilot suggest --target gh";
"\"git?\"" = "gh copilot suggest --target git";
};
environment.systemPackages = [
pkgs.git-absorb
pkgs.tig
];
home-manager.sharedModules = [
(let
# TODO: gitUrl = self.cube.services.forgejo.settings.server.ROOT_URL;
gitUrl = "https://git.rgbcu.be/";
gitDomain = head <| match "https://(.*)/" gitUrl;
# TODO: mailDomain = head self.disk.mailserver.domains;
mailDomain = "rgbcu.be";
in {
programs.nushell.configFile.text = mkAfter ''
# Sets the remote origin to the specified user and repository on my git instance
def gsr [user_and_repo: string] {
let user_and_repo = if ($user_and_repo | str index-of "/") != -1 {
$user_and_repo
} else {
"RGBCube/" + $user_and_repo
}
git remote add origin ("${gitUrl}" + $user_and_repo)
}
'';
programs.git = enabled {
package = pkgs.gitFull;
userName = "RGBCube";
userEmail = "git@${mailDomain}";
lfs = enabled;
difftastic = enabled {
background = "dark";
};
extraConfig = merge {
init.defaultBranch = "master";
commit.verbose = true;
log.date = "iso";
column.ui = "auto";
branch.sort = "-committerdate";
tag.sort = "version:refname";
diff.algorithm = "histogram";
diff.colorMoved = "default";
pull.rebase = true;
push.autoSetupRemote = true;
merge.conflictStyle = "zdiff3";
rebase.autoSquash = true;
rebase.autoStash = true;
rebase.updateRefs = true;
rerere.enabled = true;
fetch.fsckObjects = true;
receive.fsckObjects = true;
transfer.fsckobjects = true;
# https://bernsteinbear.com/git
alias.recent = "! git branch --sort=-committerdate --format=\"%(committerdate:relative)%09%(refname:short)\" | head -10";
} <| mkIf config.isDesktop {
core.sshCommand = "ssh -i ~/.ssh/id";
url."ssh://git@github.com/".insteadOf = "https://github.com/";
# TODO: url."ssh://forgejo@${gitDomain}:${toString (head self.cube.services.openssh.ports)}/".insteadOf = gitUrl;
url."ssh://forgejo@${gitDomain}:2222/".insteadOf = gitUrl;
commit.gpgSign = true;
tag.gpgSign = true;
gpg.format = "ssh";
user.signingKey = "~/.ssh/id";
};
};
})
(mkIf config.isDesktop {
programs.gh = enabled {
settings.git_protocol = "ssh";
};
})
];
}

196
modules/common/helix.nix Normal file
View file

@ -0,0 +1,196 @@
{ config, lib, pkgs, ... }: let
inherit (lib) const enabled genAttrs mkAfter mkIf;
in {
environment = {
variables.EDITOR = "hx";
shellAliases.x = "hx";
};
home-manager.sharedModules = [{
programs.nushell.configFile.text = mkIf (config.isDesktop && config.isLinux) <| mkAfter ''
def --wrapped hx [...arguments] {
if $env.TERM == "xterm-kitty" {
kitty @ set-spacing padding=0
}
^hx ...$arguments
if $env.TERM == "xterm-kitty" {
kitty @ set-spacing padding=${toString config.theme.padding}
}
}
'';
programs.helix = enabled {
languages.language = let
denoFormatter = language: {
command = "deno";
args = [ "fmt" "-" "--ext" language ];
};
denoFormatterLanguages = map (name: {
inherit name;
auto-format = true;
formatter = denoFormatter name;
}) [ "markdown" "json" ];
prettier = language: {
command = "prettier";
args = [ "--parser" language ];
};
prettierLanguages = map (name: {
inherit name;
auto-format = true;
formatter = prettier name;
}) [ "css" "scss" "yaml" ];
in denoFormatterLanguages ++ prettierLanguages ++ [
{
name = "nix";
auto-format = false;
formatter.command = "alejandra";
}
{
name = "html";
# Added vto.
file-types = [ "asp" "aspx" "htm" "html" "jshtm" "jsp" "rhtml" "shtml" "volt" "vto" "xht" "xhtml" ];
auto-format = false;
formatter = prettier "html";
}
{
name = "javascript";
auto-format = true;
formatter = denoFormatter "js";
language-servers = [ "deno" ];
}
{
name = "jsx";
auto-format = true;
formatter = denoFormatter "jsx";
language-servers = [ "deno" ];
}
{
name = "typescript";
auto-format = true;
formatter = denoFormatter "ts";
language-servers = [ "deno" ];
}
{
name = "tsx";
auto-format = true;
formatter = denoFormatter "tsx";
language-servers = [ "deno" ];
}
];
languages.language-server = {
deno = {
command = "deno";
args = [ "lsp" ];
environment.NO_COLOR = "1";
config.deno = enabled {
lint = true;
unstable = true;
suggest.imports.hosts."https://deno.land" = true;
inlayHints = {
enumMemberValues.enabled = true;
functionLikeReturnTypes.enabled = true;
parameterNames.enabled = "all";
parameterTypes.enabled = true;
propertyDeclarationTypes.enabled = true;
variableTypes.enabled = true;
};
};
};
rust-analyzer.config.check.command = "clippy";
};
settings.theme = "gruvbox_dark_hard";
settings.editor = {
color-modes = true;
completion-replace = true;
completion-trigger-len = 0;
cursor-shape.insert = "bar";
cursorline = true;
bufferline = "multiple";
file-picker.hidden = false;
idle-timeout = 0;
line-number = "relative";
shell = [ "bash" "-c" ];
text-width = 100;
};
settings.editor.indent-guides = {
character = "";
render = true;
};
settings.editor.statusline.mode = {
insert = "INSERT";
normal = "NORMAL";
select = "SELECT";
};
settings.editor.whitespace = {
characters.tab = "";
render.tab = "all";
};
settings.keys = genAttrs [ "normal" "select" ] (const {
D = "extend_to_line_end";
});
};
}];
environment.systemPackages = mkIf config.isDesktop [
# CMAKE
pkgs.cmake-language-server
# GO
pkgs.gopls
# HTML
pkgs.vscode-langservers-extracted
pkgs.nodePackages_latest.prettier
# KOTLIN
pkgs.kotlin-language-server
# LATEX
pkgs.texlab
# LUA
pkgs.lua-language-server
# MARKDOWN
pkgs.marksman
# NIX
pkgs.alejandra
pkgs.nil
# PYTHON
pkgs.python311Packages.python-lsp-server
# RUST
pkgs.rust-analyzer-nightly
# TYPESCRIPT & OTHERS
pkgs.deno
# YAML
pkgs.yaml-language-server
# ZIG
pkgs.zls
];
}

View file

@ -0,0 +1,6 @@
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
};
}

61
modules/common/nix.nix Normal file
View file

@ -0,0 +1,61 @@
{ self, config, inputs, lib, pkgs, ... }: let
inherit (lib) concatStringsSep const disabled filterAttrs flip isType mapAttrs mapAttrsToList merge mkAfter optionalAttrs;
inherit (lib.strings) toJSON;
registryMap = inputs
|> filterAttrs (const <| isType "flake");
in {
# We don't want this to be garbage collected away because if
# that happens rebuilds are slow thanks to my garbage WiFi.
environment.etc.".system-inputs.json".text = toJSON registryMap;
nix.nixPath = registryMap
|> mapAttrsToList (name: value: "${name}=${value}")
|> concatStringsSep ":";
nix.registry = registryMap // { default = inputs.nixpkgs; }
|> mapAttrs (_: flake: { inherit flake; });
nix.channel = disabled;
nix.settings = (import <| self + /flake.nix).nixConfig
|> flip removeAttrs (if config.isDarwin then [ "use-cgroups" ] else []);
nix.gc = merge {
automatic = true;
options = "--delete-older-than 3d";
} <| optionalAttrs config.isLinux {
dates = "weekly";
persistent = true;
};
nix.optimise.automatic = true;
environment.systemPackages = [
pkgs.nh
pkgs.nix-index
pkgs.nix-output-monitor
];
home-manager.sharedModules = [{
programs.nushell.configFile.text = mkAfter ''
def --wrapped nr [program: string = "", ...arguments] {
if ($program | str contains "#") or ($program | str contains ":") {
nix run $program -- ...$arguments
} else {
nix run ("default#" + $program) -- ...$arguments
}
}
def --wrapped ns [...programs] {
nix shell ...($programs | each {
if ($in | str contains "#") or ($in | str contains ":") {
$in
} else {
"default#" + $in
}
})
}
'';
}];
}

View file

@ -0,0 +1,412 @@
$env.config = {
bracketed_paste: true
buffer_editor: ""
datetime_format: {}
edit_mode: vi
error_style: fancy
float_precision: 2
footer_mode: 25
render_right_prompt_on_last_line: false
show_banner: false
use_ansi_coloring: true
use_kitty_protocol: true
shell_integration: {
osc2: false
osc7: true
osc8: true
osc9_9: false
osc133: true
osc633: true
reset_application_mode: true
}
}
$env.config.color_config = {
binary: white
block: white
bool: {|| if $in { "light_green" } else { "light_red" } }
cell-path: white
date: purple
duration: white
empty: blue
filesize: cyan
float: white
header: green_bold
hints: dark_gray
int: white
list: white
nothing: white
range: white
record: white
row_index: green_bold
search_result: { bg: red fg: white }
separator: white
string: {|| if $in =~ "^(#|0x)[a-fA-F0-9]+$" { ($in | str replace "0x" "#") } else { "white" } }
leading_trailing_space_bg: { attr: n }
shape_and: purple_bold
shape_binary: purple_bold
shape_block: blue_bold
shape_bool: light_cyan
shape_closure: green_bold
shape_custom: green
shape_datetime: cyan_bold
shape_directory: cyan
shape_external: cyan
shape_externalarg: green_bold
shape_filepath: cyan
shape_flag: blue_bold
shape_float: purple_bold
shape_garbage: { fg: white bg: red attr: b}
shape_globpattern: cyan_bold
shape_int: purple_bold
shape_internalcall: cyan_bold
shape_list: cyan_bold
shape_literal: blue
shape_match_pattern: green
shape_nothing: light_cyan
shape_operator: yellow
shape_or: purple_bold
shape_pipe: purple_bold
shape_range: yellow_bold
shape_record: cyan_bold
shape_redirection: purple_bold
shape_signature: green_bold
shape_string: green
shape_table: blue_bold
shape_vardecl: purple
shape_variable: purple
shape_matching_brackets: { attr: u }
shape_string_interpolation: cyan_bold
}
$env.config.ls = {
clickable_links: true
use_ls_colors: true
}
$env.config.rm.always_trash = false
$env.config.table = {
header_on_separator: false
index_mode: always
mode: rounded
padding: { left: 1 right: 1 }
show_empty: true
trim: {
methodology: wrapping
wrapping_try_keep_words: true
truncating_suffix: "..."
}
}
$env.config.explore = {
command_bar_text: { fg: "#C4C9C6" }
highlight: { fg: black bg: yellow }
status: {
error: { fg: white bg: red }
warn: {}
info: {}
}
status_bar_background: { fg: "#1D1F21" bg: "#C4C9C6" }
table: {
split_line: { fg: "#404040" }
selected_cell: { bg: light_blue }
selected_row: {}
selected_column: {}
}
}
$env.config.history = {
file_format: sqlite
isolation: false
max_size: 100_000
sync_on_enter: true
}
$env.config.completions = {
algorithm: prefix
case_sensitive: false
partial: true
quick: true
external: {
enable: true
max_results: 100
completer: {|tokens: list<string>|
let expanded = scope aliases | where name == $tokens.0 | get --ignore-errors expansion.0
mut expanded_tokens = if $expanded != null and $tokens.0 != "cd" {
$expanded | split row " " | append ($tokens | skip 1)
} else {
$tokens
}
$expanded_tokens.0 = ($expanded_tokens.0 | str trim --left --char "^")
fish --command $"complete '--do-complete=($expanded_tokens | str join ' ')'"
| $"value(char tab)description(char newline)" + $in
| from tsv --flexible --no-infer
}
}
}
$env.config.filesize = {
format: auto
metric: true
}
$env.config.cursor_shape = {
vi_insert: line
vi_normal: block
}
$env.config.hooks = {
command_not_found: {||}
display_output: "table --expand"
env_change: {}
pre_execution: [
{
let prompt = commandline | str trim
if ($prompt | is-empty) {
return
}
print $"(ansi title)($prompt) — nu(char bel)"
}
]
pre_prompt: []
}
$env.config.menus = [
{
marker: "| "
name: completion_menu
only_buffer_difference: false
style: {
description_text: yellow
selected_text: green_reverse
text: green
}
type: {
col_padding: 2
col_width: 20
columns: 4
layout: columnar
}
}
{
marker: "? "
name: history_menu
only_buffer_difference: true
style: {
description_text: yellow
selected_text: green_reverse
text: green
}
type: {
layout: list
page_size: 10
}
}
{
marker: "? "
name: help_menu
only_buffer_difference: true
style: {
description_text: yellow
selected_text: green_reverse
text: green
}
type: {
col_padding: 2
col_width: 20
columns: 4
description_rows: 10
layout: description
selection_rows: 4
}
}
]
$env.config.keybindings = [
{
name: completion_menu
modifier: none
keycode: tab
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: menu name: completion_menu }
{ send: menunext }
{ edit: complete }
]
}
}
{
name: history_menu
modifier: control
keycode: char_h
mode: [ vi_insert vi_normal ]
event: { send: menu name: history_menu }
}
{
name: escape
modifier: none
keycode: escape
mode: [ vi_normal vi_insert ]
event: { send: esc }
}
{
name: cancel_command
modifier: control
keycode: char_c
mode: [ vi_normal vi_insert ]
event: { send: ctrlc }
}
{
name: quit_shell
modifier: control
keycode: char_d
mode: [ vi_normal vi_insert ]
event: { send: ctrld }
}
{
name: clear_screen
modifier: control
keycode: char_l
mode: [ vi_normal vi_insert ]
event: { send: clearscreen }
}
{
name: open_command_editor
modifier: control
keycode: char_o
mode: [ vi_normal vi_insert ]
event: { send: openeditor }
}
{
name: abbr
modifier: control
keycode: space
mode: [ vi_normal vi_insert ]
event: [
{ send: menu name: abbr_menu }
{ edit: insertchar, value: " " }
]
}
{
name: move_up
modifier: none
keycode: up
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: menuup }
{ send: up }
]
}
}
{
name: move_down
modifier: none
keycode: down
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: menudown }
{ send: down }
]
}
}
{
name: move_left
modifier: none
keycode: left
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: menuleft }
{ send: left }
]
}
}
{
name: move_right_or_take_history_hint
modifier: none
keycode: right
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: historyhintcomplete }
{ send: menuright }
{ send: right }
]
}
}
{
name: move_one_word_left
modifier: control
keycode: left
mode: [ vi_normal vi_insert ]
event: { edit: movewordleft }
}
{
name: move_one_word_right_or_take_history_hint
modifier: control
keycode: right
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: historyhintwordcomplete }
{ edit: movewordright }
]
}
}
{
name: move_to_line_start
modifier: control
keycode: char_a
mode: [ vi_normal vi_insert ]
event: { edit: movetolinestart }
}
{
name: move_to_line_end_or_take_history_hint
modifier: control
keycode: char_e
mode: [ vi_normal vi_insert ]
event: {
until: [
{ send: historyhintcomplete }
{ edit: movetolineend }
]
}
}
{
name: delete_one_character_backward
modifier: none
keycode: backspace
mode: vi_insert
event: { edit: backspace }
}
{
name: delete_one_word_backward
modifier: control
keycode: backspace
mode: vi_insert
event: { edit: backspaceword }
}
{
name: newline_or_run_command
modifier: none
keycode: enter
mode: vi_insert
event: { send: enter }
}
]
$env.LS_COLORS = (open ~/.config/nushell/ls_colors.txt)
source ~/.config/nushell/zoxide.nu
source ~/.config/nushell/starship.nu

View file

@ -0,0 +1,92 @@
{ config, lib, pkgs, ... }: let
inherit (lib) enabled filter first foldl' getExe last match mkIf nameValuePair optionalAttrs readFile removeAttrs splitString;
in {
users = optionalAttrs config.isLinux { defaultUserShell = pkgs.nushell; };
environment.shells = mkIf config.isDarwin [ pkgs.nushell ];
environment.shellAliases = {
la = "ls --all";
lla = "ls --long --all";
sl = "ls";
cp = "cp --recursive --verbose --progress";
mk = "mkdir";
mv = "mv --verbose";
rm = "rm --recursive --verbose";
pstree = "pstree -g 2";
tree = "tree -CF --dirsfirst";
};
environment.systemPackages = [
pkgs.fish # For completions.
pkgs.zoxide # For completions and better cd.
];
environment.variables.STARSHIP_LOG = "error";
home-manager.sharedModules = [(homeArgs: {
xdg.configFile = {
"nushell/zoxide.nu".source = pkgs.runCommand "zoxide.nu" {} ''
${getExe pkgs.zoxide} init nushell --cmd cd > $out
'';
"nushell/ls_colors.txt".source = pkgs.runCommand "ls_colors.txt" {} ''
${getExe pkgs.vivid} generate gruvbox-dark-hard > $out
'';
"nushell/starship.nu".source = pkgs.runCommand "starship.nu" {} ''
${getExe pkgs.starship} init nu > $out
'';
};
programs.starship = enabled {
# No because we are doing it at build time instead of the way
# this retarded does it. Why the hell do you generate the config
# every time the shell is launched?
enableNushellIntegration = false;
settings = {
command_timeout = 100;
scan_timeout = 20;
cmd_duration.show_notifications = config.isDesktop;
package.disabled = config.isServer;
character.error_symbol = "";
character.success_symbol = "";
};
};
programs.nushell = enabled {
configFile.text = readFile ./configuration.nu;
envFile.text = readFile ./environment.nu;
environmentVariables = let
environmentVariables = config.environment.variables;
homeVariables = homeArgs.config.home.sessionVariables;
homeVariablesExtra = pkgs.runCommand "home-variables-extra.env" {} ''
alias export=echo
# echo foo > $out
# FIXME
eval $(cat ${homeArgs.config.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh) > $out
''
# |> (aaa: (_: break _) aaa)
|> readFile
|> splitString "\n"
|> filter (s: s != "")
|> map (match "([^=]+)=(.*)")
|> map (keyAndValue: nameValuePair (first keyAndValue) (last keyAndValue))
|> foldl' (x: y: x // y) {};
in environmentVariables // homeVariables // homeVariablesExtra;
shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // {
cdtmp = "cd (mktemp --directory)";
ll = "ls --long";
};
};
})];
}

View file

@ -0,0 +1,19 @@
$env.ENV_CONVERSIONS.PATH = {
from_string: {|string|
$string | split row (char esep) | path expand --no-symlink
}
to_string: {|value|
$value | path expand --no-symlink | str join (char esep)
}
}
def --env mc [path: path] {
mkdir $path
cd $path
}
def --env mcg [path: path] {
mkdir $path
cd $path
git init
}

View file

@ -0,0 +1,58 @@
{ config, lib, pkgs, ... }: let
inherit (lib) optionals;
in {
environment.systemPackages = [
pkgs.asciinema
pkgs.cowsay
pkgs.curlHTTP3
pkgs.dig
pkgs.doggo
pkgs.fastfetch
pkgs.fd
(pkgs.fortune.override { withOffensive = true; })
pkgs.hyperfine
pkgs.moreutils
pkgs.openssl
pkgs.p7zip
pkgs.pstree
pkgs.rsync
pkgs.timg
pkgs.tree
pkgs.uutils-coreutils-noprefix
pkgs.yazi
pkgs.yt-dlp
] ++ optionals config.isLinux [
pkgs.traceroute
pkgs.usbutils
pkgs.strace
] ++ optionals config.isDesktop [
pkgs.clang_16
pkgs.clang-tools_16
pkgs.deno
pkgs.gh
pkgs.go
pkgs.jdk
pkgs.lld
pkgs.maven
pkgs.zig
pkgs.element-desktop
pkgs.qbittorrent
] ++ optionals (config.isLinux && config.isDesktop) [
pkgs.thunderbird
pkgs.whatsapp-for-linux
pkgs.zulip
pkgs.fractal
pkgs.obs-studio
pkgs.krita
pkgs.libreoffice
pkgs.hunspellDicts.en_US
pkgs.hunspellDicts.en_GB-ize
];
}

10
modules/common/python.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, ... }: {
environment.systemPackages = [
(pkgs.python311.withPackages (pkgs: [
pkgs.pip
pkgs.requests
]))
pkgs.uv
];
}

View file

@ -0,0 +1,14 @@
{ lib, ... }: let
inherit (lib) enabled;
in {
environment.shellAliases.todo = ''rg "todo|fixme" --colors match:fg:yellow --colors match:style:bold'';
home-manager.sharedModules = [{
programs.ripgrep = enabled {
arguments = [
"--line-number"
"--smart-case"
];
};
}];
}

18
modules/common/rust.nix Normal file
View file

@ -0,0 +1,18 @@
{ pkgs, ... }: {
environment.variables.CARGO_NET_GIT_FETCH_WITH_CLI = "true";
environment.systemPackages = [
pkgs.cargo-expand
pkgs.cargo-fuzz
pkgs.evcxr
(pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
])
];
}

View file

@ -0,0 +1,12 @@
age-encryption.org/v1
-> ssh-ed25519 +rZ0Tw nOt0AMht8Aod+1V2bTWMJnMWtYVm8AckH27mnwFAQS4
rBp+kJFoQwh8jD0q5Dv9O6O/iT7tTbPioQGUnOE4Eyc
-> ssh-ed25519 spFFQA 7s4U2WKZZwRIYRsZNBmnXI7Yawkh7ZZ0YuTDeaoHCww
NX/akV5Cj5WEyeg86kd2JVPGq8f54oixuyR020c6aqs
-> ssh-ed25519 dASlBQ fGx+vne56PxD8gaACu1f8iR+Nhscxqs292rH4uEeChc
mVq1++pve3Kk0kRbhf4LCTutiEJBEbmsy4fVS+QYrYM
-> ssh-ed25519 CzqbPQ Pj0lZnFQXqQrJk9fyi15923rqnVA2GbhR+kRxNMm3Ec
yu14hvCAV2MzexoDeiza5CfisuKC5e1p2JbDHbyPy0E
--- 8UNtL1+o7GYCfWOYk0E+mIXFt3kb7NhAVzTnBkx0YPQ
årm÷õJ)Á²4¢UCßܘ¸JÕÃ`°çvY,ÜÚ<C39C>ô˜Áâ|<7C>`¶'[œw"þ@I
.'Ã{nkEÐø@Õ §­Ô6È

View file

@ -0,0 +1,61 @@
{ self, config, lib, pkgs, ... }: let
inherit (lib) enabled mkIf;
controlPath = "~/.ssh/control";
in {
secrets.sshConfig = {
file = ./config.age;
mode = "444";
};
home-manager.sharedModules = [{
home.activation.createControlPath = {
after = [ "writeBoundary" ];
before = [];
data = "mkdir --parents ${controlPath}";
};
programs.ssh = enabled {
controlMaster = "auto";
controlPath = "${controlPath}/%r@%n:%p";
controlPersist = "60m";
serverAliveCountMax = 2;
serverAliveInterval = 60;
includes = [ config.secrets.sshConfig.path ];
matchBlocks = {
"*" = {
setEnv.COLORTERM = "truecolor";
setEnv.TERM = "xterm-256color";
identityFile = "~/.ssh/id";
};
# TODO: Maybe autogenerate these?
# cube = {
# hostname = self.cube.networking.ipv4;
# user = "rgb";
# port = 2222;
# };
# disk = {
# hostname = self.disk.networking.ipv4;
# user = "floppy";
# port = 2222;
# };
# nine = {
# hostname = self.nine.networking.ipv4;
# user = "seven";
# port = 2222;
# };
};
};
}];
environment.systemPackages = mkIf config.isDesktop [
pkgs.mosh
];
}

13
modules/common/system.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, lib, ... }: let
inherit (lib) any elem last mapAttrsToList mkConst splitString;
in {
options = {
os = mkConst <| last <| splitString "-" config.nixpkgs.hostPlatform.system;
isLinux = mkConst <| config.os == "linux";
isDarwin = mkConst <| config.os == "darwin";
isDesktop = mkConst <| config.isDarwin || (any <| mapAttrsToList (_: value: elem "graphical" value.extraGroups) config.users.users);
isServer = mkConst <| !config.isDesktop;
};
}

View file

@ -0,0 +1,7 @@
{ lib, ... }: let
inherit (lib) enabled;
in {
environment.shellAliases.ts = "sudo tailscale";
services.tailscale = enabled;
}

View file

@ -0,0 +1,4 @@
{
environment.shellAliases.tb = "nc termbin.com 9999";
}

24
modules/common/theme.nix Normal file
View file

@ -0,0 +1,24 @@
{ lib, pkgs, themes, ... }: let
inherit (lib) mkValue;
in {
options.theme = mkValue <| themes.custom <| themes.raw.gruvbox-dark-hard // {
cornerRadius = 4;
borderWidth = 2;
margin = 0;
padding = 8;
font.size.normal = 16;
font.size.big = 20;
font.sans.name = "Lexend";
font.sans.package = pkgs.lexend;
font.mono.name = "JetBrainsMono Nerd Font";
font.mono.package = pkgs.nerd-fonts.jetbrains-mono;
icons.name = "Gruvbox-Plus-Dark";
icons.package = pkgs.gruvbox-plus-icons;
};
}

10
modules/common/w3m.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, ... }: {
environment.shellAliases = {
ddg = "w3m lite.duckduckgo.com";
web = "w3m";
};
environment.systemPackages = [
pkgs.w3m
];
}