Run formatter over project. Tidy up laptop packages.

This commit is contained in:
Fern Garden 2025-07-10 18:14:36 +08:00
parent 5b08fb0d7f
commit 091c1562f2
14 changed files with 205 additions and 210 deletions

View file

@ -1,5 +1,5 @@
{
self,
nixpkgs,
pkgs,
lib,
hostname,
@ -10,15 +10,15 @@ with lib; {
# NixOS version.
system.stateVersion = "25.05";
# Set $NIX_PATH to flake input.
nix.nixPath = ["nixpkgs=${self.inputs.nixpkgs}"];
# Enable flakes.
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
# Set $NIX_PATH to flake input.
nix.nixPath = ["nixpkgs=${nixpkgs}"];
# Enable redistributable firmware.
hardware.enableRedistributableFirmware = true;
@ -66,25 +66,14 @@ with lib; {
programs.fish = {
enable = true;
interactiveShellInit = ''
# nnn cd on quit.
function n --wraps nnn --description 'support nnn quit and change directory'
if test -n "$NNNLVL" -a "$NNNLVL" -ge 1
echo "nnn is already running"
return
end
if test -n "$XDG_CONFIG_HOME"
set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
else
set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
end
command ${pkgs.nnn}/bin/nnn $argv
if test -e $NNN_TMPFILE
source $NNN_TMPFILE
rm -- $NNN_TMPFILE
end
# yazi cd on quit.
function y
set tmp (mktemp -t "yazi-cwd.XXXXXX")
${pkgs.yazi}/bin/yazi $argv --cwd-file="$tmp"
if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
builtin cd -- "$cwd"
end
rm -f -- "$tmp"
end
# kanagawa theme.
@ -123,6 +112,7 @@ with lib; {
'';
};
# https://nixos.wiki/wiki/Fish#Setting_fish_as_your_shell
programs.bash = {
interactiveShellInit = ''
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
@ -131,136 +121,153 @@ with lib; {
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
'';
}; # https://nixos.wiki/wiki/Fish#Setting_fish_as_your_shell
};
# Install some packages.
programs.git.enable = true;
programs.lazygit.enable = true;
programs = {
git.enable = true;
lazygit.enable = true;
programs.nixvim = {
enable = true;
globals.mapleader = " ";
keymaps = [
{
key = "<Leader>t";
action = "<cmd> ToggleTerm direction=float <CR>";
mode = "n";
options = {
silent = true;
desc = "Open floating terminal.";
};
}
{
key = "<Leader>e";
action = "<cmd> Neotree toggle <CR>";
mode = "n";
options.desc = "Show/hide file browser.";
}
{
key = "<Leader>f";
action = "<cmd> Telescope fd <CR>";
mode = "n";
options.desc = "Find files.";
}
{
key = "<Leader>g";
action = "<cmd> LazyGit <CR>";
mode = "n";
options.desc = "Open LazyGit.";
}
];
colorschemes.kanagawa = {
nixvim = {
enable = true;
settings = {
background.dark = "dragon";
colors.theme.all.ui.bg_gutter = "none";
overrides = ''
function(colors)
local theme = colors.theme
return {
NormalFloat = { bg = "none" },
FloatBorder = { bg = "none" },
FloatTitle = { bg = "none" },
TelescopeTitle = { fg = theme.ui.special, bold = true },
TelescopePromptNormal = { bg = theme.ui.bg_p1 },
TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 },
TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 },
TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 },
TelescopePreviewNormal = { bg = theme.ui.bg_dim },
TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim },
globals.mapleader = " ";
Pmenu = { fg = theme.ui.shade0, bg = theme.ui.bg_p1 }, -- add `blend = vim.o.pumblend` to enable transparency
PmenuSel = { fg = "NONE", bg = theme.ui.bg_p2 },
PmenuSbar = { bg = theme.ui.bg_m1 },
PmenuThumb = { bg = theme.ui.bg_p2 },
}
end,
'';
};
};
keymaps = [
{
key = "<Leader>t";
action = "<cmd> ToggleTerm direction=float <CR>";
mode = "n";
options = {
silent = true;
desc = "Open floating terminal.";
};
}
opts = rec {
shiftwidth = 2;
tabstop = shiftwidth;
softtabstop = shiftwidth;
expandtab = true;
number = true;
cursorline = true;
undofile = true;
clipboard = "unnamedplus";
};
{
key = "<Leader>g";
action = "<cmd> LazyGit <CR>";
mode = "n";
options.desc = "Open LazyGit.";
}
clipboard.providers.wl-copy.enable = true;
{
key = "<Leader>y";
action = "<cmd> Yazi toggle <CR>";
mode = "n";
options.desc = "Show/hide file browser.";
}
plugins = {
colorizer.enable = true;
gitsigns.enable = true;
lazygit.enable = true;
lsp-format.enable = true;
mini-statusline.enable = true;
mini-tabline.enable = true;
notify.enable = true;
nvim-autopairs.enable = true;
telescope.enable = true;
toggleterm.enable = true;
trouble.enable = true;
web-devicons.enable = true;
which-key.enable = true;
{
key = "<Leader>ff";
action = "<cmd> Telescope fd <CR>";
mode = "n";
options.desc = "Find files.";
}
blink-cmp = {
{
key = "<Leader>fb";
action = "<cmd> Telescope buffers <CR>";
mode = "n";
options.desc = "Switch between buffers with telescope.";
}
{
key = "<Leader>fg";
action = "<cmd> Telescope live_grep <CR>";
mode = "n";
options.desc = "Grep files.";
}
];
colorschemes.kanagawa = {
enable = true;
settings = {
keymap.preset = "enter";
menu.auto_show = true;
completion.documentation.auto_show = true;
background.dark = "dragon";
colors.theme.all.ui.bg_gutter = "none";
overrides = ''
function(colors)
local theme = colors.theme
return {
NormalFloat = { bg = "none" },
FloatBorder = { bg = "none" },
FloatTitle = { bg = "none" },
TelescopeTitle = { fg = theme.ui.special, bold = true },
TelescopePromptNormal = { bg = theme.ui.bg_p1 },
TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 },
TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 },
TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 },
TelescopePreviewNormal = { bg = theme.ui.bg_dim },
TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim },
Pmenu = { fg = theme.ui.shade0, bg = theme.ui.bg_p1 }, -- add `blend = vim.o.pumblend` to enable transparency
PmenuSel = { fg = "NONE", bg = theme.ui.bg_p2 },
PmenuSbar = { bg = theme.ui.bg_m1 },
PmenuThumb = { bg = theme.ui.bg_p2 },
}
end,
'';
};
};
lsp = {
enable = true;
inlayHints = true;
servers = {
nixd = {
enable = true;
settings.formatting.command = ["alejandra"];
settings.options.nixos.expr = "(builtins.getFlake (builtins.toString /home/fern/Repositories/flock)).nixosConfigurations.muskduck.options";
opts = rec {
shiftwidth = 2;
tabstop = shiftwidth;
softtabstop = shiftwidth;
expandtab = true;
number = true;
cursorline = true;
undofile = true;
clipboard = "unnamedplus";
};
clipboard.providers.wl-copy.enable = true;
plugins = {
colorizer.enable = true;
gitsigns.enable = true;
lazygit.enable = true;
lsp-format.enable = true;
mini-statusline.enable = true;
mini-tabline.enable = true;
notify.enable = true;
nvim-autopairs.enable = true;
telescope.enable = true;
toggleterm.enable = true;
trouble.enable = true;
web-devicons.enable = true;
which-key.enable = true;
yazi.enable = true;
blink-cmp = {
enable = true;
settings = {
keymap.preset = "enter";
menu.auto_show = true;
completion.documentation.auto_show = true;
};
};
};
treesitter = {
enable = true;
settings = {
highlight.enable = true;
incremental_selection.enable = true;
indent.enable = true;
lsp = {
enable = true;
inlayHints = true;
servers = {
nixd = {
enable = true;
settings.formatting.command = ["alejandra"];
settings.options.nixos.expr = "(builtins.getFlake (builtins.toString /home/fern/Repositories/flock)).nixosConfigurations.muskduck.options";
};
};
};
treesitter = {
enable = true;
settings = {
highlight.enable = true;
incremental_selection.enable = true;
indent.enable = true;
};
};
};
};
@ -271,10 +278,10 @@ with lib; {
btop
lynx
ncdu
nnn
rsync
tmux
trash-cli
yazi
];
# Enable avahi hostname resolution.

View file

@ -4,8 +4,7 @@
lib,
...
}:
with lib;
{
with lib; {
# Configure the bootloader.
boot = {
# Enable secure boot.
@ -58,7 +57,7 @@ with lib;
desktopManager.gnome = {
enable = true;
# Enable fractional scaling.
extraGSettingsOverridePackages = [ pkgs.mutter ];
extraGSettingsOverridePackages = [pkgs.mutter];
extraGSettingsOverrides = ''
[org.gnome.mutter]
experimental-features=['scale-monitor-framebuffer']
@ -74,34 +73,29 @@ with lib;
# Exclude some default gnome applications.
environment.gnome.excludePackages = (
with pkgs;
[
epiphany
gnome-connections
gnome-console
gnome-maps
gnome-music
gnome-tour
totem
yelp
with pkgs; [
epiphany # Browser (replaced by Firefox).
gnome-connections # Remote desktop viewer.
gnome-console # Terminal (replaced by ghostTTY).
gnome-maps # Maps viewer.
gnome-music # Music player.
gnome-tour # First-boot tour.
totem # Movie player (replaced by Celluloid).
yelp # Help viewer.
]
);
# Remove NixOS HTML manual
documentation.doc.enable = false;
# Use ghostty for the "open in terminal" option in file manager.
programs.nautilus-open-any-terminal = {
enable = true;
terminal = "ghostty";
};
# Run electron apps under wayland.
environment.sessionVariables.NIXOS_OZONE_WL = "1";
# Install some packages.
programs.steam.enable = true;
programs.firefox.enable = true;
programs = {
steam.enable = true;
firefox.enable = true;
};
environment.systemPackages = with pkgs; [
adwsteamgtk
@ -109,7 +103,6 @@ with lib;
caligula
celluloid
discord
userPackages.feishin
ghostty
gimp3
glabels-qt
@ -121,14 +114,12 @@ with lib;
libreoffice
merriweather
merriweather-sans
nixd # nix language server
alejandra # nix language formatter
nerd-fonts.fira-code
obsidian
protonmail-desktop
signal-desktop
smile
vscodium
userPackages.feishin
yubioath-flutter
# PrismLauncher with temurin jre.
@ -142,18 +133,20 @@ with lib;
(userPackages.fluffychat.overrideAttrs (
finalAttrs: previousAttrs: {
desktopItems = [
((builtins.elemAt previousAttrs.desktopItems 0).override { startupWMClass = "fluffychat"; })
((builtins.elemAt previousAttrs.desktopItems 0).override {startupWMClass = "fluffychat";})
];
}
))
];
# Enable gamemode service
# Enable gamemode service.
programs.gamemode.enable = true;
# Enable CUPS to print documents.
services.printing.enable = true;
services.printing.drivers = [ pkgs.brlaser ];
services.printing = {
enable = true;
drivers = [pkgs.brlaser];
};
# If you don't set this Wireguard won't work.
networking.firewall.checkReversePath = false;
@ -170,6 +163,6 @@ with lib;
# Enable CPU frequency scaling management.
services.power-profiles-daemon.enable = mkForce false; # enabled by gnome
services.tlp.enable = lib.mkForce false; # enabled by nixos-hardware
services.tlp.enable = mkForce false; # enabled by nixos-hardware
services.auto-cpufreq.enable = true;
}

View file

@ -1,10 +1,6 @@
{
modulesPath,
...
}:
{
{modulesPath, ...}: {
imports = [
(modulesPath + "/virtualisation/proxmox-lxc.nix")
./server.nix
];
}
}

View file

@ -1,13 +1,16 @@
{ user, lib, ... }:
with lib;
{
# Passwordless sudo
user,
lib,
...
}:
with lib; {
# Passwordless sudo.
security.sudo.wheelNeedsPassword = false;
# Enable all terminfo (for ghostty)
# Enable all terminfo (for ghostty).
environment.enableAllTerminfo = true;
# Enable SSH server
# Enable SSH server.
services.openssh.enable = true;
users.users.${user} = {
@ -17,9 +20,9 @@ with lib;
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBEJYq1fMxVOzCMfE/td6DtWS8nUk76U9seYD3Z9RYAz u0_a399@fairywren"
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIMoJvPcUJDVVzO4dHROCFNlgJdDZSP5xyPx2s40zcx5QAAAABHNzaDo= YubiKey5NFC"
];
extraGroups = mkIf (user == "docker") [ "docker" ];
extraGroups = mkIf (user == "docker") ["docker"];
};
# Enable docker.
virtualisation.docker.enable = mkIf (user == "docker") true;
}
}

View file

@ -3,8 +3,7 @@
lib,
...
}:
with lib;
{
with lib; {
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
./server.nix
@ -19,7 +18,7 @@ with lib;
"sd_mod"
];
boot.kernelModules = [ "kvm-intel" ];
boot.kernelModules = ["kvm-intel"];
# Enable DHCP.
networking.useDHCP = mkDefault true;