feat: add comments, format all nix files

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