mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-26 01:48:27 +02:00
feat: add comments, format all nix files
This commit is contained in:
3
Makefile
3
Makefile
@@ -31,6 +31,9 @@ darwin-debug: darwin-set-proxy
|
||||
--extra-experimental-features 'nix-command flakes'
|
||||
./result/sw/bin/darwin-rebuild switch --flake . --show-trace --verbose
|
||||
|
||||
fmt:
|
||||
# format the nix files in this repo
|
||||
nix fmt
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
||||
17
flake.nix
17
flake.nix
@@ -85,12 +85,12 @@
|
||||
# parameters in `outputs` are defined in `inputs` and can be referenced by their names.
|
||||
# However, `self` is an exception, This special parameter points to the `outputs` itself (self-reference)
|
||||
# The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function.
|
||||
outputs = inputs@{
|
||||
self,
|
||||
nixpkgs,
|
||||
darwin,
|
||||
home-manager,
|
||||
...
|
||||
outputs =
|
||||
inputs@{ self
|
||||
, nixpkgs
|
||||
, darwin
|
||||
, home-manager
|
||||
, ...
|
||||
}: {
|
||||
nixosConfigurations = {
|
||||
# By default, NixOS will try to refer the nixosConfiguration with its hostname.
|
||||
@@ -183,6 +183,11 @@
|
||||
];
|
||||
};
|
||||
|
||||
formatter = {
|
||||
x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
|
||||
x86_64-darwin = nixpkgs.legacyPackages.x86_64-darwin.nixpkgs-fmt;
|
||||
};
|
||||
|
||||
# generate qcow2 & iso image from nixos configuration
|
||||
# https://github.com/nix-community/nixos-generators
|
||||
# packages.x86_64-linux = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{...}: {
|
||||
{ ... }: {
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{config, pkgs, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{config, pkgs, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./nushell
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{config, pkgs, nil, ...}:
|
||||
{ config, pkgs, nil, ... }:
|
||||
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
@@ -62,7 +62,7 @@
|
||||
rustup
|
||||
|
||||
# python
|
||||
(python310.withPackages(ps: with ps; [
|
||||
(python310.withPackages (ps: with ps; [
|
||||
ipython
|
||||
pandas
|
||||
requests
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}: {
|
||||
# `programs.git` will generate the config file: ~/.config/git/config
|
||||
# to make git use this config file, `~/.gitconfig` should not exist!
|
||||
#
|
||||
# https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
|
||||
home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
|
||||
home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore [ "checkLinkTargets" ] ''
|
||||
rm -f ~/.gitconfig
|
||||
'';
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
{ pkgs
|
||||
, config
|
||||
, ...
|
||||
}:
|
||||
# processing audio/video
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{...}: {
|
||||
{ ... }: {
|
||||
programs.nushell = {
|
||||
enable = true;
|
||||
configFile.source = ./config.nu;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{config, ...}: {
|
||||
{ config, ... }: {
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# google-cloud-sdk telegram wireshark
|
||||
|
||||
|
||||
{pkgs, ...}:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# MacOS specific configuration
|
||||
home.packages = with pkgs; [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{config, pkgs, nil, ...}:
|
||||
{ config, pkgs, nil, ... }:
|
||||
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
{config, ...}:
|
||||
{ config, ... }:
|
||||
|
||||
let
|
||||
d = config.xdg.dataHome;
|
||||
c = config.xdg.configHome;
|
||||
cache = config.xdg.cacheHome;
|
||||
in rec {
|
||||
in
|
||||
rec {
|
||||
# add environment variables
|
||||
systemd.user.sessionVariables = {
|
||||
# clean up ~
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
{ pkgs
|
||||
, ...
|
||||
}: {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{pkgs, config, ...}:
|
||||
{ pkgs, config, ... }:
|
||||
|
||||
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
|
||||
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
|
||||
# https://www.freedesktop.org/wiki/Specifications/
|
||||
{config, pkgs, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
xdg-utils # provides cli tools such as `xdg-mime` `xdg-open`
|
||||
@@ -24,7 +24,7 @@
|
||||
enable = true;
|
||||
defaultApplications =
|
||||
let
|
||||
browser = ["firefox.desktop"];
|
||||
browser = [ "firefox.desktop" ];
|
||||
in
|
||||
{
|
||||
"application/json" = browser;
|
||||
@@ -49,17 +49,17 @@
|
||||
"x-scheme-handler/https" = browser;
|
||||
"x-scheme-handler/unknown" = browser;
|
||||
|
||||
"x-scheme-handler/discord" = ["discord.desktop"];
|
||||
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
|
||||
"x-scheme-handler/discord" = [ "discord.desktop" ];
|
||||
"x-scheme-handler/tg" = [ "telegramdesktop.desktop" ];
|
||||
|
||||
"audio/*" = ["mpv.desktop"];
|
||||
"video/*" = ["mpv.dekstop"];
|
||||
"image/*" = ["imv.desktop"];
|
||||
"audio/*" = [ "mpv.desktop" ];
|
||||
"video/*" = [ "mpv.dekstop" ];
|
||||
"image/*" = [ "imv.desktop" ];
|
||||
};
|
||||
|
||||
associations.removed =
|
||||
let
|
||||
browser = ["google-chrome.desktop"];
|
||||
browser = [ "google-chrome.desktop" ];
|
||||
in
|
||||
{
|
||||
"text/html" = browser;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
{ pkgs
|
||||
, config
|
||||
, ...
|
||||
}:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
{ pkgs
|
||||
, config
|
||||
, ...
|
||||
}:
|
||||
# media - control and enjoy audio/video
|
||||
{
|
||||
@@ -24,8 +23,8 @@
|
||||
programs = {
|
||||
mpv = {
|
||||
enable = true;
|
||||
defaultProfiles = ["gpu-hq"];
|
||||
scripts = [pkgs.mpvScripts.mpris];
|
||||
defaultProfiles = [ "gpu-hq" ];
|
||||
scripts = [ pkgs.mpvScripts.mpris ];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{pkgs, config, lib, ... }: {
|
||||
{ pkgs, config, lib, ... }: {
|
||||
|
||||
home.file.".config/fcitx5/profile".source = ./profile;
|
||||
home.file.".config/fcitx5/profile-bak".source = ./profile; # used for backup
|
||||
# fcitx5 每次切换输入法,就会修改 ~/.config/fcitx5/profile 文件,导致我用 hm 管理的配置被覆盖
|
||||
# 解决方法是通过如下内置,每次 rebuild 前都先删除下 profile 文件
|
||||
home.activation.removeExistingFcitx5Profile = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
|
||||
home.activation.removeExistingFcitx5Profile = lib.hm.dag.entryBefore [ "checkLinkTargets" ] ''
|
||||
rm -f "${config.xdg.configHome}/fcitx5/profile"
|
||||
'';
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
{ pkgs
|
||||
, config
|
||||
, lib
|
||||
, ...
|
||||
}: {
|
||||
imports = [
|
||||
./wayland-apps.nix
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
pkgs,
|
||||
pkgs-stable,
|
||||
...
|
||||
{ pkgs
|
||||
, pkgs-stable
|
||||
, ...
|
||||
}:
|
||||
|
||||
{
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
{ pkgs
|
||||
, config
|
||||
, lib
|
||||
, ...
|
||||
}: {
|
||||
# i3 配置,基于 https://github.com/endeavouros-team/endeavouros-i3wm-setup
|
||||
# 直接从当前文件夹中读取配置文件作为配置内容
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
{ pkgs
|
||||
, ...
|
||||
}: {
|
||||
home.packages = with pkgs; [
|
||||
firefox
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
"xfs"
|
||||
#"zfs"
|
||||
"ntfs"
|
||||
"fat" "vfat" "exfat"
|
||||
"fat"
|
||||
"vfat"
|
||||
"exfat"
|
||||
"cifs" # mount windows share
|
||||
];
|
||||
|
||||
@@ -62,10 +64,10 @@
|
||||
enableIPv6 = false; # disable ipv6
|
||||
interfaces.enp5s0 = {
|
||||
useDHCP = false;
|
||||
ipv4.addresses = [ {
|
||||
ipv4.addresses = [{
|
||||
address = "192.168.5.66";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
}];
|
||||
};
|
||||
defaultGateway = "192.168.5.201";
|
||||
nameservers = [
|
||||
@@ -77,7 +79,7 @@
|
||||
|
||||
# for Nvidia GPU
|
||||
|
||||
services.xserver.videoDrivers = ["nvidia"]; # will install nvidia-vaapi-driver by default
|
||||
services.xserver.videoDrivers = [ "nvidia" ]; # will install nvidia-vaapi-driver by default
|
||||
hardware.nvidia = {
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
modesetting.enable = true;
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
{
|
||||
imports =
|
||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||
[
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
|
||||
@@ -14,19 +15,20 @@
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/disk/by-uuid/231466f6-cdf3-40e1-b9d2-6b4e8d10a4d3";
|
||||
{
|
||||
device = "/dev/disk/by-uuid/231466f6-cdf3-40e1-b9d2-6b4e8d10a4d3";
|
||||
fsType = "btrfs";
|
||||
options = [ "subvol=@" ];
|
||||
};
|
||||
|
||||
fileSystems."/boot/efi" =
|
||||
{ device = "/dev/disk/by-uuid/87ED-8B2E";
|
||||
{
|
||||
device = "/dev/disk/by-uuid/87ED-8B2E";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
swapDevices =
|
||||
[ { device = "/dev/disk/by-uuid/17391ca0-8cdb-4598-a40b-fd9548fd9b37"; }
|
||||
];
|
||||
[{ device = "/dev/disk/by-uuid/17391ca0-8cdb-4598-a40b-fd9548fd9b37"; }];
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
"xfs"
|
||||
#"zfs"
|
||||
"ntfs"
|
||||
"fat" "vfat" "exfat"
|
||||
"fat"
|
||||
"vfat"
|
||||
"exfat"
|
||||
"cifs" # mount windows share
|
||||
];
|
||||
|
||||
@@ -59,10 +61,10 @@
|
||||
networkmanager.enable = true;
|
||||
interfaces.ens18 = {
|
||||
useDHCP = false;
|
||||
ipv4.addresses = [ {
|
||||
ipv4.addresses = [{
|
||||
address = "192.168.5.48";
|
||||
prefixLength = 24;
|
||||
} ];
|
||||
}];
|
||||
};
|
||||
defaultGateway = "192.168.5.201";
|
||||
nameservers = [
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
{
|
||||
imports =
|
||||
[ (modulesPath + "/profiles/qemu-guest.nix")
|
||||
[
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ];
|
||||
@@ -14,7 +15,8 @@
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/disk/by-uuid/b779eb19-e43d-4f07-a91f-eb08bd8e1202";
|
||||
{
|
||||
device = "/dev/disk/by-uuid/b779eb19-e43d-4f07-a91f-eb08bd8e1202";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
|
||||
@@ -50,11 +50,13 @@
|
||||
font-awesome
|
||||
|
||||
# nerdfonts
|
||||
(nerdfonts.override { fonts = [
|
||||
(nerdfonts.override {
|
||||
fonts = [
|
||||
"FiraCode"
|
||||
"JetBrainsMono"
|
||||
"Iosevka"
|
||||
];})
|
||||
];
|
||||
})
|
||||
|
||||
];
|
||||
};
|
||||
|
||||
@@ -69,11 +69,13 @@
|
||||
source-han-serif # 思源宋体
|
||||
|
||||
# nerdfonts
|
||||
(nerdfonts.override { fonts = [
|
||||
(nerdfonts.override {
|
||||
fonts = [
|
||||
"FiraCode"
|
||||
"JetBrainsMono"
|
||||
"Iosevka"
|
||||
];})
|
||||
];
|
||||
})
|
||||
|
||||
(pkgs.callPackage ../../fonts/icomoon-feather-icon-font.nix { })
|
||||
|
||||
@@ -143,14 +145,16 @@
|
||||
}))
|
||||
|
||||
# create a fhs environment by command `fhs`, so we can run non-nixos packages in nixos!
|
||||
(let base = pkgs.appimageTools.defaultFhsEnvArgs; in
|
||||
(
|
||||
let base = pkgs.appimageTools.defaultFhsEnvArgs; in
|
||||
pkgs.buildFHSUserEnv (base // {
|
||||
name = "fhs";
|
||||
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [pkgs.pkg-config];
|
||||
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [ pkgs.pkg-config ];
|
||||
profile = "export FHS=1";
|
||||
runScript = "bash";
|
||||
extraOutputsToInstall = ["dev"];
|
||||
}))
|
||||
extraOutputsToInstall = [ "dev" ];
|
||||
})
|
||||
)
|
||||
];
|
||||
|
||||
# replace default editor with neovim
|
||||
|
||||
@@ -55,11 +55,13 @@
|
||||
source-han-sans # 思源黑体
|
||||
|
||||
# nerdfonts
|
||||
(nerdfonts.override { fonts = [
|
||||
(nerdfonts.override {
|
||||
fonts = [
|
||||
"FiraCode"
|
||||
"JetBrainsMono"
|
||||
"Iosevka"
|
||||
];})
|
||||
];
|
||||
})
|
||||
];
|
||||
|
||||
# user defined fonts
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
{
|
||||
system.fsPackages = [ pkgs.bindfs ];
|
||||
fileSystems = let
|
||||
fileSystems =
|
||||
let
|
||||
mkRoSymBind = path: {
|
||||
device = path;
|
||||
fsType = "fuse.bindfs";
|
||||
@@ -18,7 +19,8 @@
|
||||
paths = config.fonts.fonts;
|
||||
pathsToLink = [ "/share/fonts" ];
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Create an FHS mount to support flatpak host icons/fonts
|
||||
"/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons");
|
||||
"/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{pkgs, ...}:
|
||||
{ pkgs, ... }:
|
||||
|
||||
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{pkgs, ...}:
|
||||
{ pkgs, ... }:
|
||||
|
||||
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{config, pkgs, ...}:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
users.groups = {
|
||||
ryan = {};
|
||||
docker = {};
|
||||
wireshark = {};
|
||||
ryan = { };
|
||||
docker = { };
|
||||
wireshark = { };
|
||||
};
|
||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||
users.users.ryan = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
args:
|
||||
# execute and import all overlay files in the current directory with the given args
|
||||
builtins.map
|
||||
# execute and import all overlay files in the current directory with the given args
|
||||
builtins.map
|
||||
(f: (import (./. + "/${f}") args)) # execute and import the overlay file
|
||||
(builtins.filter # find all overlay files in the current directory
|
||||
(f: f != "default.nix")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 为了不使用默认的 rime-data,改用我自定义的小鹤音形数据,这里需要 override
|
||||
# 参考 https://github.com/NixOS/nixpkgs/blob/e4246ae1e7f78b7087dce9c9da10d28d3725025f/pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix
|
||||
{...}:
|
||||
{ ... }:
|
||||
|
||||
(self: super: {
|
||||
# 小鹤音形配置,配置来自 flypy.com 官方网盘的鼠须管配置压缩包「小鹤音形“鼠须管”for macOS.zip」
|
||||
|
||||
Reference in New Issue
Block a user