Files
nix-config/modules/nixos/base/misc.nix
2024-02-17 04:36:41 +08:00

133 lines
4.0 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
lib,
pkgs,
...
}: {
###################################################################################
#
# NixOS's core configuration suitable for all my machines
#
###################################################################################
# to install chrome, you need to enable unfree packages
nixpkgs.config.allowUnfree = lib.mkForce true;
boot.loader.systemd-boot = {
# we use Git for version control, so we don't need to keep too many generations.
configurationLimit = lib.mkDefault 10;
# pick the highest resolution for systemd-boot's console.
consoleMode = lib.mkDefault "max";
};
# do garbage collection weekly to keep disk usage low
nix.gc = {
automatic = lib.mkDefault true;
dates = lib.mkDefault "weekly";
options = lib.mkDefault "--delete-older-than 7d";
};
# Manual optimise storage: nix-store --optimise
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
nix.settings.auto-optimise-store = true;
# Enable in-memory compressed devices and swap space provided by the zram kernel module.
# By enable this, we can store more data in memory instead of fallback to disk-based swap devices directly,
# and thus improve I/O performance when we have a lot of memory.
#
# https://www.kernel.org/doc/Documentation/blockdev/zram.txt
zramSwap = {
enable = true;
# one of "lzo", "lz4", "zstd"
algorithm = "zstd";
# Priority of the zram swap devices.
# It should be a number higher than the priority of your disk-based swap devices
# (so that the system will fill the zram swap devices before falling back to disk swap).
priority = 5;
# Maximum total amount of memory that can be stored in the zram swap devices (as a percentage of your total memory).
# Defaults to 1/2 of your total RAM. Run zramctl to check how good memory is compressed.
# This doesnt define how much memory will be used by the zram swap devices.
memoryPercent = 50;
};
# for power management
services = {
power-profiles-daemon = {
enable = true;
};
upower.enable = true;
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
neofetch
neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
git # used by nix flakes
git-lfs # used by huggingface models
# archives
zip
xz
zstd
unzip
p7zip
# Text Processing
# Docs: https://github.com/learnbyexample/Command-line-text-processing
gnugrep # GNU grep, provides `grep`/`egrep`/`fgrep`
gnused # GNU sed, very powerful(mainly for replacing text in files)
gawk # GNU awk, a pattern scanning and processing language
jq # A lightweight and flexible command-line JSON processor
# system call monitoring
strace # system call monitoring
ltrace # library call monitoring
bpftrace # powerful tracing tool
tcpdump # network sniffer
lsof # list open files
# system monitoring
sysstat
iotop
iftop
btop
nmon
# system tools
psmisc # killall/pstree/prtstat/fuser/...
lm_sensors # for `sensors` command
ethtool
pciutils # lspci
usbutils # lsusb
hdparm # for disk performance, command
dmidecode # a tool that reads information about your system's hardware from the BIOS according to the SMBIOS/DMI standard
parted
# misc
file
findutils
which
tree
gnutar
rsync
# create a fhs environment by command `fhs`, so we can run non-nixos packages in nixos!
(
let
base = pkgs.appimageTools.defaultFhsEnvArgs;
in
pkgs.buildFHSUserEnv (base
// {
name = "fhs";
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [pkgs.pkg-config];
profile = "export FHS=1";
runScript = "bash";
extraOutputsToInstall = ["dev"];
})
)
];
# replace default editor with neovim
environment.variables.EDITOR = "nvim";
}