feat: format via 'ls **/*.nix | each { |it| nixfmt $it.name }'

This commit is contained in:
Ryan Yin
2025-07-30 12:17:24 +08:00
parent d10b30b06b
commit 13bb77108c
219 changed files with 2103 additions and 1728 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
{mylib, ...}: {
{ mylib, ... }:
{
imports = mylib.scanPaths ./.;
}
+7 -5
View File
@@ -3,16 +3,18 @@
config,
lib,
...
}: let
}:
let
cfg = config.modules.desktop;
in {
in
{
options.modules.desktop = {
fonts.enable = lib.mkEnableOption "Rich Fonts - Add NerdFonts Icons, emojis & CJK Fonts";
};
config.fonts.packages = with pkgs;
lib.mkIf cfg.fonts.enable
[
config.fonts.packages =
with pkgs;
lib.mkIf cfg.fonts.enable [
# icon fonts
material-design-icons
font-awesome
+7 -3
View File
@@ -3,7 +3,8 @@
config,
myvars,
...
}: {
}:
{
# auto upgrade nix to the unstable version
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/tools/package-management/nix/default.nix#L284
# nix.package = pkgs.nixVersions.latest;
@@ -13,12 +14,15 @@
nix.settings = {
# enable flakes globally
experimental-features = ["nix-command" "flakes"];
experimental-features = [
"nix-command"
"flakes"
];
# given the users in this list the right to specify additional substituters via:
# 1. `nixConfig.substituers` in `flake.nix`
# 2. command line args `--options substituers http://xxx`
trusted-users = [myvars.username];
trusted-users = [ myvars.username ];
# substituers that will be considered before the official ones(https://cache.nixos.org)
substituters = [
+6 -6
View File
@@ -1,7 +1,7 @@
{nuenv, ...} @ args: {
nixpkgs.overlays =
[
nuenv.overlays.default
]
++ (import ../../overlays args);
{ nuenv, ... }@args:
{
nixpkgs.overlays = [
nuenv.overlays.default
]
++ (import ../../overlays args);
}
+2 -1
View File
@@ -1,4 +1,5 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
# for security reasons, do not load neovim's user config
# since EDITOR may be used to edit some critical files
environment.variables.EDITOR = "nvim --clean";
+2 -1
View File
@@ -1,4 +1,5 @@
{myvars, ...}: {
{ myvars, ... }:
{
programs.ssh = myvars.networking.ssh;
users.users.${myvars.username} = {
+14 -13
View File
@@ -53,12 +53,12 @@ let
# HTTPS_PROXY = "http://127.0.0.1:7890";
};
homebrew_env_script =
lib.attrsets.foldlAttrs
(acc: name: value: acc + "\nexport ${name}=${value}")
""
(homebrew_mirror_env // local_proxy_env);
in {
homebrew_env_script = lib.attrsets.foldlAttrs (
acc: name: value:
acc + "\nexport ${name}=${value}"
) "" (homebrew_mirror_env // local_proxy_env);
in
{
# Install packages from nix's official package repository.
#
# The packages installed here are available to all users, and are reproducible across machines, and are rollbackable.
@@ -75,13 +75,14 @@ in {
# darwin only apps
utm # virtual machine
];
environment.variables =
{
# Fix https://github.com/LnL7/nix-darwin/wiki/Terminfo-issues
TERMINFO_DIRS = map (path: path + "/share/terminfo") config.environment.profiles ++ ["/usr/share/terminfo"];
}
# Set variables for you to manually install homebrew packages.
// homebrew_mirror_env;
environment.variables = {
# Fix https://github.com/LnL7/nix-darwin/wiki/Terminfo-issues
TERMINFO_DIRS = map (path: path + "/share/terminfo") config.environment.profiles ++ [
"/usr/share/terminfo"
];
}
# Set variables for you to manually install homebrew packages.
// homebrew_mirror_env;
# Set environment variables for nix-darwin before run `brew bundle`.
system.activationScripts.homebrew.text = lib.mkBefore ''
+11 -10
View File
@@ -1,4 +1,4 @@
{lib, ...}:
{ lib, ... }:
# ===================================================================
# Remove packages that are not well supported for the Darwin platform
# ===================================================================
@@ -19,15 +19,16 @@ let
"ncdu"
"racket-minimal"
];
in {
in
{
nixpkgs.overlays = [
(_: super: let
removeUnwantedPackages = pname:
lib.warn "the ${pname} has been removed on the darwin platform"
super.emptyDirectory;
in
lib.genAttrs
brokenPackages
removeUnwantedPackages)
(
_: super:
let
removeUnwantedPackages =
pname: lib.warn "the ${pname} has been removed on the darwin platform" super.emptyDirectory;
in
lib.genAttrs brokenPackages removeUnwantedPackages
)
];
}
+5 -6
View File
@@ -1,7 +1,6 @@
{mylib, ...}: {
imports =
(mylib.scanPaths ./.)
++ [
../base
];
{ mylib, ... }:
{
imports = (mylib.scanPaths ./.) ++ [
../base
];
}
+2 -1
View File
@@ -1,4 +1,5 @@
{config, ...}: {
{ config, ... }:
{
###################################################################################
#
# Core configuration for nix-darwin
+4 -2
View File
@@ -2,9 +2,11 @@
config,
myvars,
...
}: let
}:
let
homeDir = config.users.users."${myvars.username}".home;
in {
in
{
# https://github.com/LnL7/nix-darwin/blob/master/modules/programs/gnupg.nix
# try `pkill gpg-agent` if you have issues(such as `no pinentry`)
programs.gnupg.agent = {
+2 -1
View File
@@ -1,4 +1,5 @@
{myvars, ...}: {
{ myvars, ... }:
{
# Define a user account. Don't forget to set a password with passwd.
users.users."${myvars.username}" = {
home = "/Users/${myvars.username}";
+2 -1
View File
@@ -1,4 +1,5 @@
{lib, ...}: {
{ lib, ... }:
{
boot.loader.systemd-boot = {
# we use Git for version control, so we don't need to keep too many generations.
configurationLimit = lib.mkDefault 10;
+2 -1
View File
@@ -1,3 +1,4 @@
{mylib, ...}: {
{ mylib, ... }:
{
imports = mylib.scanPaths ./.;
}
+2 -1
View File
@@ -2,7 +2,8 @@
config,
lib,
...
}: {
}:
{
# to install chrome, you need to enable unfree packages
nixpkgs.config.allowUnfree = lib.mkForce true;
+2 -1
View File
@@ -1,4 +1,5 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
+53 -50
View File
@@ -1,4 +1,5 @@
{myvars, ...}: {
{ myvars, ... }:
{
####################################################################
#
# NixOS's Configuration for Remote Building / Distributed Building
@@ -13,57 +14,59 @@
# set local's max-job to 0 to force remote building(disable local building)
# nix.settings.max-jobs = 0;
nix.distributedBuilds = true;
nix.buildMachines = let
sshUser = myvars.username;
# ssh key's path on local machine
sshKey = "/etc/agenix/ssh-key-romantic";
systems = [
# native arch
"x86_64-linux"
nix.buildMachines =
let
sshUser = myvars.username;
# ssh key's path on local machine
sshKey = "/etc/agenix/ssh-key-romantic";
systems = [
# native arch
"x86_64-linux"
# emulated arch using binfmt_misc and qemu-user
"aarch64-linux"
"riscv64-linux"
# emulated arch using binfmt_misc and qemu-user
"aarch64-linux"
"riscv64-linux"
];
# all available system features are poorly documentd here:
# https://github.com/NixOS/nix/blob/e503ead/src/libstore/globals.hh#L673-L687
supportedFeatures = [
"benchmark"
"big-parallel"
"kvm"
];
in
[
# Nix seems always try to build on the machine remotely
# to make use of the local machine's high-performance CPU, do not set remote builder's maxJobs too high.
# {
# # some of my remote builders are running NixOS
# # and has the same sshUser, sshKey, systems, etc.
# inherit sshUser sshKey systems supportedFeatures;
#
# # the hostName should be:
# # 1. a hostname that can be resolved by DNS
# # 2. the ip address of the remote builder
# # 3. a host alias defined globally in /etc/ssh/ssh_config
# hostName = "aquamarine";
# # remote builder's max-job
# maxJobs = 3;
# # speedFactor's a signed integer
# # https://github.com/ryan4yin/nix-config/issues/70
# speedFactor = 1;
# }
# {
# inherit sshUser sshKey systems supportedFeatures;
# hostName = "ruby";
# maxJobs = 2;
# speedFactor = 1;
# }
# {
# inherit sshUser sshKey systems supportedFeatures;
# hostName = "kana";
# maxJobs = 2;
# speedFactor = 1;
# }
];
# all available system features are poorly documentd here:
# https://github.com/NixOS/nix/blob/e503ead/src/libstore/globals.hh#L673-L687
supportedFeatures = [
"benchmark"
"big-parallel"
"kvm"
];
in [
# Nix seems always try to build on the machine remotely
# to make use of the local machine's high-performance CPU, do not set remote builder's maxJobs too high.
# {
# # some of my remote builders are running NixOS
# # and has the same sshUser, sshKey, systems, etc.
# inherit sshUser sshKey systems supportedFeatures;
#
# # the hostName should be:
# # 1. a hostname that can be resolved by DNS
# # 2. the ip address of the remote builder
# # 3. a host alias defined globally in /etc/ssh/ssh_config
# hostName = "aquamarine";
# # remote builder's max-job
# maxJobs = 3;
# # speedFactor's a signed integer
# # https://github.com/ryan4yin/nix-config/issues/70
# speedFactor = 1;
# }
# {
# inherit sshUser sshKey systems supportedFeatures;
# hostName = "ruby";
# maxJobs = 2;
# speedFactor = 1;
# }
# {
# inherit sshUser sshKey systems supportedFeatures;
# hostName = "kana";
# maxJobs = 2;
# speedFactor = 1;
# }
];
# optional, useful when the builder has a faster internet connection than yours
nix.extraOptions = ''
builders-use-substitutes = true
+2 -1
View File
@@ -1,4 +1,5 @@
{lib, ...}: {
{ lib, ... }:
{
# Or disable the firewall altogether.
networking.firewall.enable = lib.mkDefault false;
# Enable the OpenSSH daemon.
+9 -8
View File
@@ -2,21 +2,22 @@
myvars,
config,
...
}: {
}:
{
# Don't allow mutation of users outside the config.
users.mutableUsers = false;
users.groups = {
"${myvars.username}" = {};
podman = {};
wireshark = {};
"${myvars.username}" = { };
podman = { };
wireshark = { };
# for android platform tools's udev rules
adbusers = {};
dialout = {};
adbusers = { };
dialout = { };
# for openocd (embedded system development)
plugdev = {};
plugdev = { };
# misc
uinput = {};
uinput = { };
};
users.users."${myvars.username}" = {
+5 -3
View File
@@ -5,9 +5,11 @@
myvars,
...
}:
with lib; let
with lib;
let
cfgWayland = config.modules.desktop.wayland;
in {
in
{
imports = [
./base
../base
@@ -45,7 +47,7 @@ in {
};
# fix https://github.com/ryan4yin/nix-config/issues/10
security.pam.services.hyprlock = {};
security.pam.services.hyprlock = { };
})
];
}
+2 -1
View File
@@ -1,3 +1,4 @@
{mylib, ...}: {
{ mylib, ... }:
{
imports = mylib.scanPaths ./.;
}
+12 -9
View File
@@ -1,4 +1,5 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
# FHS environment, flatpak, appImage, etc.
environment.systemPackages = [
# create a fhs environment by command `fhs`, so we can run non-nixos packages in nixos!
@@ -6,14 +7,16 @@
let
base = pkgs.appimageTools.defaultFhsEnvArgs;
in
pkgs.buildFHSEnv (base
// {
name = "fhs";
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [pkgs.pkg-config];
profile = "export FHS=1";
runScript = "bash";
extraOutputsToInstall = ["dev"];
})
pkgs.buildFHSEnv (
base
// {
name = "fhs";
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [ pkgs.pkg-config ];
profile = "export FHS=1";
runScript = "bash";
extraOutputsToInstall = [ "dev" ];
}
)
)
];
+3 -2
View File
@@ -1,4 +1,5 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
# all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts
fonts = {
# use fonts specified by user rather than default ones
@@ -37,7 +38,7 @@
# 西文
"JetBrainsMono Nerd Font"
];
emoji = ["Noto Color Emoji"];
emoji = [ "Noto Color Emoji" ];
};
antialias = true; # 抗锯齿
hinting.enable = false; # 禁止字体微调 - 高分辨率下没这必要
+2 -1
View File
@@ -4,7 +4,8 @@
pkgs,
pkgs-unstable,
...
}: {
}:
{
boot.loader.timeout = lib.mkForce 10; # wait for x seconds to select the boot entry
# add user's shell into /etc/shells
+2 -1
View File
@@ -1,4 +1,5 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
#============================= Audio(PipeWire) =======================
# List packages installed in system profile. To search, run:
@@ -2,7 +2,8 @@
pkgs,
mylib,
...
}: {
}:
{
imports = mylib.scanPaths ./.;
environment.systemPackages = with pkgs; [
@@ -30,7 +30,7 @@
# =============================================================
{
# make the tailscale command usable to users
environment.systemPackages = [pkgs.tailscale];
environment.systemPackages = [ pkgs.tailscale ];
# enable the tailscale service
services.tailscale = {
+4 -3
View File
@@ -2,7 +2,8 @@
pkgs,
# nur-ataraxiasjel,
...
}: {
}:
{
###################################################################################
#
# Virtualisation - Libvirt(QEMU/KVM) / Docker / LXD / WayDroid
@@ -20,7 +21,7 @@
# boot.kernelModules = ["kvm-intel"];
# boot.extraModprobeConfig = "options kvm_intel nested=1"; # for intel cpu
boot.kernelModules = ["vfio-pci"];
boot.kernelModules = [ "vfio-pci" ];
services.flatpak.enable = true;
@@ -36,7 +37,7 @@
autoPrune = {
enable = true;
dates = "weekly";
flags = ["--all"];
flags = [ "--all" ];
};
};
+17 -16
View File
@@ -1,25 +1,26 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
xdg.terminal-exec = {
enable = true;
package = pkgs.xdg-terminal-exec-mkhl;
settings = let
my_terminal_desktop = [
# NOTE: We have add these packages at user level
"Alacritty.desktop"
"kitty.desktop"
"foot.desktop"
"com.mitchellh.ghostty.desktop"
];
in {
GNOME =
my_terminal_desktop
++ [
settings =
let
my_terminal_desktop = [
# NOTE: We have add these packages at user level
"Alacritty.desktop"
"kitty.desktop"
"foot.desktop"
"com.mitchellh.ghostty.desktop"
];
in
{
GNOME = my_terminal_desktop ++ [
"com.raggesilver.BlackBox.desktop"
"org.gnome.Terminal.desktop"
];
niri = my_terminal_desktop;
default = my_terminal_desktop;
};
niri = my_terminal_desktop;
default = my_terminal_desktop;
};
};
xdg.portal = {
@@ -20,7 +20,7 @@
config = {
# disable backups in the VM
services.btrbk.instances = lib.mkForce {};
services.btrbk.instances = lib.mkForce { };
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
@@ -29,7 +29,7 @@
};
boot.growPartition = true;
boot.kernelParams = ["console=ttyS0"];
boot.kernelParams = [ "console=ttyS0" ];
boot.loader.grub.device = "/dev/vda";
services.qemuGuest.enable = true; # qemu-guest-agent
+2 -1
View File
@@ -2,7 +2,8 @@
lib,
pkgs,
...
}: {
}:
{
imports = [
../base/btrbk.nix
../base/core.nix
+2 -1
View File
@@ -1,4 +1,5 @@
{lib, ...}: {
{ lib, ... }:
{
# =========================================================================
# Base NixOS Configuration
# =========================================================================
+2 -1
View File
@@ -1,4 +1,5 @@
{lib, ...}: {
{ lib, ... }:
{
imports = [
../base
../../base