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

View File

@@ -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:

233
flake.nix
View File

@@ -22,7 +22,7 @@
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
"xddxdd.cachix.org-1:ay1HJyNDYmlSwj5NXQG065C8LfoqqKaTNCyzeixGjf8="
"xddxdd.cachix.org-1:ay1HJyNDYmlSwj5NXQG065C8LfoqqKaTNCyzeixGjf8="
];
};
@@ -37,7 +37,7 @@
# Official NixOS package source, using nixos-unstable branch here
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05";
# for macos
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.05-darwin";
darwin = {
@@ -72,7 +72,7 @@
# use devenv to manage my development environment
devenv.url = "github:cachix/devenv/v0.6.2";
# secrets management, lock with git commit at 2023/5/15
agenix.url = "github:ryantm/agenix/db5637d10f797bb251b94ef9040b237f4702cde3";
@@ -85,128 +85,133 @@
# 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,
...
}: {
nixosConfigurations = {
# By default, NixOS will try to refer the nixosConfiguration with its hostname.
# so the system named `msi-rtx4090` will use this configuration.
# However, the configuration name can also be specified using `sudo nixos-rebuild switch --flake /path/to/flakes/directory#<name>`.
# The `nixpkgs.lib.nixosSystem` function is used to build this configuration, the following attribute set is its parameter.
# Run `sudo nixos-rebuild switch --flake .#msi-rtx4090` in the flake's directory to deploy this configuration on any NixOS system
msi-rtx4090 = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
outputs =
inputs@{ self
, nixpkgs
, darwin
, home-manager
, ...
}: {
nixosConfigurations = {
# By default, NixOS will try to refer the nixosConfiguration with its hostname.
# so the system named `msi-rtx4090` will use this configuration.
# However, the configuration name can also be specified using `sudo nixos-rebuild switch --flake /path/to/flakes/directory#<name>`.
# The `nixpkgs.lib.nixosSystem` function is used to build this configuration, the following attribute set is its parameter.
# Run `sudo nixos-rebuild switch --flake .#msi-rtx4090` in the flake's directory to deploy this configuration on any NixOS system
msi-rtx4090 = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
# The Nix module system can modularize configurations, improving the maintainability of configurations.
#
# Each parameter in the `modules` is a Nix Module, and there is a partial introduction to it in the nixpkgs manual:
# <https://nixos.org/manual/nixpkgs/unstable/#module-system-introduction>
# It is said to be partial because the documentation is not complete, only some simple introductions
# (such is the current state of Nix documentation...)
# A Nix Module can be an attribute set, or a function that returns an attribute set.
# If a Module is a function, according to the Nix Wiki description, this function can have up to four parameters:
#
# config: The configuration of the entire system
# options: All option declarations refined with all definition and declaration references.
# pkgs: The attribute set extracted from the Nix package collection and enhanced with the nixpkgs.config option.
# modulesPath: The location of the module directory of Nix.
#
# Only these four parameters can be passed by default.
# If you need to pass other parameters, you must use `specialArgs` by uncomment the following line
specialArgs = {
pkgs-stable = import inputs.nixpkgs-stable {
system = system; # refer the `system` parameter form outer scope recursively
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
} // inputs;
# The Nix module system can modularize configurations, improving the maintainability of configurations.
#
# Each parameter in the `modules` is a Nix Module, and there is a partial introduction to it in the nixpkgs manual:
# <https://nixos.org/manual/nixpkgs/unstable/#module-system-introduction>
# It is said to be partial because the documentation is not complete, only some simple introductions
# (such is the current state of Nix documentation...)
# A Nix Module can be an attribute set, or a function that returns an attribute set.
# If a Module is a function, according to the Nix Wiki description, this function can have up to four parameters:
#
# config: The configuration of the entire system
# options: All option declarations refined with all definition and declaration references.
# pkgs: The attribute set extracted from the Nix package collection and enhanced with the nixpkgs.config option.
# modulesPath: The location of the module directory of Nix.
#
# Only these four parameters can be passed by default.
# If you need to pass other parameters, you must use `specialArgs` by uncomment the following line
specialArgs = {
pkgs-stable = import inputs.nixpkgs-stable {
system = system; # refer the `system` parameter form outer scope recursively
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
} // inputs;
modules = [
./hosts/msi-rtx4090
# make home-manager as a module of nixos
# so that home-manager configuration will be deployed automatically when executing `nixos-rebuild switch`
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# pass all inputs into home manager's all sub modules
home-manager.extraSpecialArgs = specialArgs;
home-manager.users.ryan = import ./home/linux/x11.nix;
}
];
};
nixos-test = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
pkgs-stable = import inputs.nixpkgs-stable {
system = system;
config.allowUnfree = true;
};
} // inputs;
modules = [
./hosts/nixos-test
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.users.ryan = import ./home/linux/wayland.nix;
}
];
};
};
# configurations for MacOS
darwinConfigurations."harmonica" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = inputs;
modules = [
./hosts/msi-rtx4090
./hosts/harmonica
# make home-manager as a module of nixos
# so that home-manager configuration will be deployed automatically when executing `nixos-rebuild switch`
home-manager.nixosModules.home-manager
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# pass all inputs into home manager's all sub modules
home-manager.extraSpecialArgs = specialArgs;
home-manager.users.ryan = import ./home/linux/x11.nix;
home-manager.extraSpecialArgs = inputs;
home-manager.users.admin = import ./home/darwin;
}
];
};
nixos-test = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
pkgs-stable = import inputs.nixpkgs-stable {
system = system;
config.allowUnfree = true;
};
} // inputs;
modules = [
./hosts/nixos-test
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.users.ryan = import ./home/linux/wayland.nix;
}
];
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 = {
# qcow2 = nixos-generators.nixosGenerate {
# system = "x86_64-linux";
# modules = [
# # you can include your own nixos configuration here, i.e.
# # ./configuration.nix
# ];
# format = "qcow";
# # you can also define your own custom formats
# # customFormats = { "myFormat" = <myFormatModule>; ... };
# # format = "myFormat";
# };
# iso = nixos-generators.nixosGenerate {
# system = "x86_64-linux";
# modules = [
# # you can include your own nixos configuration here, i.e.
# # ./configuration.nix
# ];
# format = "iso";
# };
# };
};
# configurations for MacOS
darwinConfigurations."harmonica" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = inputs;
modules = [
./hosts/harmonica
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = inputs;
home-manager.users.admin = import ./home/darwin;
}
];
};
# generate qcow2 & iso image from nixos configuration
# https://github.com/nix-community/nixos-generators
# packages.x86_64-linux = {
# qcow2 = nixos-generators.nixosGenerate {
# system = "x86_64-linux";
# modules = [
# # you can include your own nixos configuration here, i.e.
# # ./configuration.nix
# ];
# format = "qcow";
# # you can also define your own custom formats
# # customFormats = { "myFormat" = <myFormatModule>; ... };
# # format = "myFormat";
# };
# iso = nixos-generators.nixosGenerate {
# system = "x86_64-linux";
# modules = [
# # you can include your own nixos configuration here, i.e.
# # ./configuration.nix
# ];
# format = "iso";
# };
# };
};
}

View File

@@ -6,13 +6,13 @@ stdenvNoCC.mkDerivation rec {
src = fetchgit {
url = "https://github.com/archcraft-os/archcraft-packages.git";
rev = "88030ee6d2df80db958541b53bd3673e081720cf"; # git commit id
sparseCheckout = [ "archcraft-fonts/files/icon-fonts/archcraft.ttf" ]; # only fetch the feather.ttf file
rev = "88030ee6d2df80db958541b53bd3673e081720cf"; # git commit id
sparseCheckout = [ "archcraft-fonts/files/icon-fonts/archcraft.ttf" ]; # only fetch the feather.ttf file
# the sha256 is used to verify the integrity of the downloaded source, and alse cache the build result.
# so if you copy other package src's sha256, you will get a cached build result of that package, and all configs in this file will be ignored.
# specify sha256 to empty and build it, then an error will indicate the correct sha256
sha256 = "sha256-DrGN8lN4Yr1RTyCUZhJjzKgCuC0vTnSWjOKovNg3T/U=";
sha256 = "sha256-DrGN8lN4Yr1RTyCUZhJjzKgCuC0vTnSWjOKovNg3T/U=";
};
installPhase = ''
@@ -32,4 +32,4 @@ stdenvNoCC.mkDerivation rec {
maintainers = [ maintainers.ryan4yin ];
platforms = platforms.all;
};
}
}

View File

@@ -7,15 +7,15 @@ stdenvNoCC.mkDerivation rec {
# 参考 https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ttf-icomoon-feather
src = fetchgit {
url = "https://github.com/adi1090x/polybar-themes.git";
rev = "47b66337a92a1afd2240ed7094ffcb039cc686cf"; # git commit id
sparseCheckout = [ "fonts/feather.ttf" ]; # only fetch the feather.ttf file
rev = "47b66337a92a1afd2240ed7094ffcb039cc686cf"; # git commit id
sparseCheckout = [ "fonts/feather.ttf" ]; # only fetch the feather.ttf file
# the sha256 is used to verify the integrity of the downloaded source, and alse cache the build result.
# so if you copy other package src's sha256, you will get a cached build result of that package, and all configs in this file will be ignored.
# specify sha256 to empty and build it, then an error will indicate the correct sha256
sha256 = "sha256-R+UpUFkXDrxKcX7ljLara+1B1rOMdKGZiLQq1/ojgP4=";
sha256 = "sha256-R+UpUFkXDrxKcX7ljLara+1B1rOMdKGZiLQq1/ojgP4=";
};
installPhase = ''
runHook preInstall
@@ -36,4 +36,4 @@ stdenvNoCC.mkDerivation rec {
maintainers = [ maintainers.ryan4yin ];
platforms = platforms.all;
};
}
}

View File

@@ -1,4 +1,4 @@
{...}: {
{ ... }: {
programs.bash = {
enable = true;
enableCompletion = true;
@@ -15,4 +15,4 @@
httpproxy = "export https_proxy=http://127.0.0.1:7890; export http_proxy=http://127.0.0.1:7890;";
};
};
}
}

View File

@@ -1,9 +1,9 @@
{config, pkgs, ...}:
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
neofetch
nnn # terminal file manager
nnn # terminal file manager
# archives
zip
@@ -12,19 +12,19 @@
p7zip
# utils
ripgrep # recursively searches directories for a regex pattern
jq # A lightweight and flexible command-line JSON processor
yq-go # yaml processer https://github.com/mikefarah/yq
exa # A modern replacement for ls
fzf # A command-line fuzzy finder
ripgrep # recursively searches directories for a regex pattern
jq # A lightweight and flexible command-line JSON processor
yq-go # yaml processer https://github.com/mikefarah/yq
exa # A modern replacement for ls
fzf # A command-line fuzzy finder
# networking tools
mtr # A network diagnostic tool
mtr # A network diagnostic tool
iperf3
ldns # replacement of dig, it provide the command `drill`
ldns # replacement of dig, it provide the command `drill`
aria2 # A lightweight multi-protocol & multi-source command-line download utility
socat # replacement of openbsd-netcat
nmap # A utility for network discovery and security auditing
nmap # A utility for network discovery and security auditing
# misc
cowsay
@@ -45,8 +45,8 @@
nix-output-monitor
# productivity
hugo # static site generator
glow # markdown previewer in terminal
hugo # static site generator
glow # markdown previewer in terminal
];
programs = {
@@ -77,4 +77,4 @@
enableBashIntegration = true;
};
};
}
}

View File

@@ -1,4 +1,4 @@
{config, pkgs, ...}:
{ config, pkgs, ... }:
{
imports = [
./nushell
@@ -11,4 +11,4 @@
./starship.nix
];
}
}

View File

@@ -1,8 +1,8 @@
{config, pkgs, nil, ...}:
{ config, pkgs, nil, ... }:
{
home.packages = with pkgs; [
nil.packages."${pkgs.system}".default # nix language server
nil.packages."${pkgs.system}".default # nix language server
# IDE
jetbrains.pycharm-community
@@ -11,7 +11,7 @@
# cloud native
skopeo
docker-compose
dive # explore docker layers
dive # explore docker layers
kubectl
kubernetes-helm
terraform
@@ -27,7 +27,7 @@
eksctl
# DO NOT install build tools for C/C++, set it per project by devShell instead
gnumake # used by this repo, to simplify the deployment
gnumake # used by this repo, to simplify the deployment
clang-tools
clang-analyzer
# lldb
@@ -62,7 +62,7 @@
rustup
# python
(python310.withPackages(ps: with ps; [
(python310.withPackages (ps: with ps; [
ipython
pandas
requests
@@ -89,9 +89,9 @@
# adoptopenjdk-openj9-bin-17
# other tools
k6 # load testing tool
mitmproxy # http/https proxy tool
protobuf # protocol buffer compiler
k6 # load testing tool
mitmproxy # http/https proxy tool
protobuf # protocol buffer compiler
];
programs = {
@@ -104,9 +104,9 @@
};
direnv = {
enable = true;
nix-direnv.enable = true;
enableZshIntegration = true;
enable = true;
nix-direnv.enable = true;
enableZshIntegration = true;
};
};
@@ -114,4 +114,4 @@
programs.gh = {
enable = true;
};
}
}

View File

@@ -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
'';
@@ -58,4 +57,4 @@
};
};
};
}
}

View File

@@ -1,7 +1,6 @@
{
pkgs,
config,
...
{ pkgs
, config
, ...
}:
# processing audio/video
{
@@ -9,8 +8,8 @@
ffmpeg-full
# images
viu # terminal image viewer
viu # terminal image viewer
imagemagick
graphviz
];
}
}

View File

@@ -1,4 +1,4 @@
{...}: {
{ ... }: {
programs.nushell = {
enable = true;
configFile.source = ./config.nu;
@@ -18,4 +18,4 @@
httpproxy = "let-env https_proxy = http://127.0.0.1:7890; let-env http_proxy = http://127.0.0.1:7890;";
};
};
}
}

View File

@@ -1,10 +1,10 @@
{config, ...}: {
{ config, ... }: {
programs.starship = {
enable = true;
enableBashIntegration = true;
enableNushellIntegration = true;
settings = {
character = {
success_symbol = "[](bold green)";
@@ -12,4 +12,4 @@
};
};
};
}
}

View File

@@ -7,4 +7,4 @@
xdg.configFile."alacritty/alacritty.yml".source = ./alacritty.yml;
xdg.configFile."alacritty/theme_github_dark.yml".source = ./theme_github_dark.yml;
}
}

View File

@@ -8,7 +8,7 @@
# google-cloud-sdk telegram wireshark
{pkgs, ...}:
{ pkgs, ... }:
{
# MacOS specific configuration
home.packages = with pkgs; [

View File

@@ -3,13 +3,13 @@
{
imports = [
../base/nushell
../base/core.nix
../base/git.nix
../base/development.nix
../base/media.nix
../base/starship.nix
./alacritty
./core.nix
];
@@ -34,4 +34,4 @@
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}
}

View File

@@ -7,4 +7,4 @@
xdg.configFile."alacritty/alacritty.yml".source = ./alacritty.yml;
xdg.configFile."alacritty/theme_github_dark.yml".source = ./theme_github_dark.yml;
}
}

View File

@@ -1,11 +1,11 @@
{config, pkgs, nil, ...}:
{ config, pkgs, nil, ... }:
{
home.packages = with pkgs; [
nil.packages."${pkgs.system}".default # nix language server
nil.packages."${pkgs.system}".default # nix language server
# GUI IDE
insomnia # REST client
insomnia # REST client
# need to run `conda-install` before using it
# need to run `conda-shell` before using command `conda`
@@ -33,4 +33,4 @@
programs.gh = {
enable = true;
};
}
}

View File

@@ -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 ~
@@ -29,4 +30,4 @@ in rec {
};
home.sessionVariables = systemd.user.sessionVariables;
}
}

View File

@@ -1,6 +1,5 @@
{
pkgs,
...
{ pkgs
, ...
}: {
programs.ssh = {
enable = true;
@@ -36,4 +35,4 @@
# check imported keys by `ssh-add -l`
# TODO `ssh-add` can only add keys temporary, use gnome-keyring to unlock all keys after login.
};
}
}

View File

@@ -1,31 +1,31 @@
{pkgs, config, ...}:
{ pkgs, config, ... }:
{
# Linux Only Packages, not available on Darwin
home.packages = with pkgs; [
btop # replacement of htop/nmon
btop # replacement of htop/nmon
htop
iotop
nmon
## networking tools
wireguard-tools # manage wireguard vpn manually, via wg-quick
wireguard-tools # manage wireguard vpn manually, via wg-quick
iftop
# misc
libnotify
# system call monitoring
strace # system call monitoring
ltrace # library call monitoring
lsof # list open files
strace # system call monitoring
ltrace # library call monitoring
lsof # list open files
# system tools
ethtool
sysstat
lm_sensors # for `sensors` command
cifs-utils # for mounting windows shares
lm_sensors # for `sensors` command
cifs-utils # for mounting windows shares
];
# auto mount usb drives

View File

@@ -2,10 +2,10 @@
# 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`
xdg-utils # provides cli tools such as `xdg-mime` `xdg-open`
xdg-user-dirs
];
@@ -22,13 +22,13 @@
# ls /etc/profiles/per-user/ryan/share/applications/
mimeApps = {
enable = true;
defaultApplications =
defaultApplications =
let
browser = ["firefox.desktop"];
browser = [ "firefox.desktop" ];
in
{
"application/json" = browser;
"application/pdf" = browser; # TODO: pdf viewer
"application/pdf" = browser; # TODO: pdf viewer
"text/html" = browser;
"text/xml" = browser;
@@ -48,18 +48,18 @@
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/unknown" = browser;
"x-scheme-handler/discord" = ["discord.desktop"];
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
"audio/*" = ["mpv.desktop"];
"video/*" = ["mpv.dekstop"];
"image/*" = ["imv.desktop"];
"x-scheme-handler/discord" = [ "discord.desktop" ];
"x-scheme-handler/tg" = [ "telegramdesktop.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;

View File

@@ -1,17 +1,16 @@
{
pkgs,
config,
...
{ pkgs
, config
, ...
}:
{
home.packages = with pkgs; [
# creative
# blender # 3d modeling
# gimp # image editing, I prefer using figma in browser instead of this one
inkscape # vector graphics
krita # digital painting
inkscape # vector graphics
krita # digital painting
musescore # music notation
reaper # audio production
reaper # audio production
# this app consumes a lot of storage, so do not install it currently
# kicad # 3d printing, eletrical engineering
@@ -21,4 +20,4 @@
# live streaming
obs-studio.enable = true;
};
}
}

View File

@@ -16,13 +16,13 @@
# instant messaging
telegram-desktop
discord
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
# remote desktop(rdp connect)
remmina
freerdp # required by remmina
freerdp # required by remmina
# misc
flameshot
];
}
}

View File

@@ -1,7 +1,6 @@
{
pkgs,
config,
...
{ pkgs
, config
, ...
}:
# media - control and enjoy audio/video
{
@@ -10,7 +9,7 @@
pavucontrol
playerctl
pulsemixer
imv # simple image viewer
imv # simple image viewer
nvtop
@@ -24,12 +23,12 @@
programs = {
mpv = {
enable = true;
defaultProfiles = ["gpu-hq"];
scripts = [pkgs.mpvScripts.mpris];
defaultProfiles = [ "gpu-hq" ];
scripts = [ pkgs.mpvScripts.mpris ];
};
};
services = {
playerctld.enable = true;
};
}
}

View File

@@ -1,24 +1,24 @@
{pkgs, config, lib, ... }: {
{ pkgs, config, lib, ... }: {
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 管理的配置被覆盖
# 解决方法是通过如下内置,每次 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"
'';
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5.addons = with pkgs; [
# for flypy chinese input method
fcitx5-rime
# needed enable rime using configtool after installed
fcitx5-configtool
fcitx5-chinese-addons
# fcitx5-mozc # japanese input method
fcitx5-gtk # gtk im module
];
# for flypy chinese input method
fcitx5-rime
# needed enable rime using configtool after installed
fcitx5-configtool
fcitx5-chinese-addons
# fcitx5-mozc # japanese input method
fcitx5-gtk # gtk im module
];
};
systemd.user.sessionVariables = {
@@ -28,6 +28,6 @@
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
INPUT_METHOD = "fcitx";
IMSETTINGS_MODULE = "fcitx";
IMSETTINGS_MODULE = "fcitx";
};
}
}

View File

@@ -1,8 +1,7 @@
{
pkgs,
config,
lib,
...
{ pkgs
, config
, lib
, ...
}: {
imports = [
./wayland-apps.nix
@@ -25,8 +24,8 @@
fonts.fontconfig.enable = true;
systemd.user.sessionVariables = {
"NIXOS_OZONE_WL" = "1"; # for any ozone-based browser & electron apps to run on wayland
"MOZ_ENABLE_WAYLAND" = "1"; # for firefox to run on wayland
"NIXOS_OZONE_WL" = "1"; # for any ozone-based browser & electron apps to run on wayland
"MOZ_ENABLE_WAYLAND" = "1"; # for firefox to run on wayland
"MOZ_WEBRENDER" = "1";
# for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/

View File

@@ -1,8 +1,7 @@
{
pkgs,
pkgs-stable,
...
}:
{ pkgs
, pkgs-stable
, ...
}:
{
# TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it.
@@ -31,7 +30,7 @@
firefox = {
enable = true;
enableGnomeExtensions = false;
package = pkgs-stable.firefox-wayland; # firefox with wayland support
package = pkgs-stable.firefox-wayland; # firefox with wayland support
};
vscode = {

View File

@@ -1,8 +1,7 @@
{
pkgs,
config,
lib,
...
{ pkgs
, config
, lib
, ...
}: {
# i3 配置,基于 https://github.com/endeavouros-team/endeavouros-i3wm-setup
# 直接从当前文件夹中读取配置文件作为配置内容
@@ -20,7 +19,7 @@
source = ./scripts;
# copy the scripts directory recursively
recursive = true;
executable = true; # make all scripts executable
executable = true; # make all scripts executable
};
# rofi is a application launcher and dmenu replacement
@@ -56,4 +55,4 @@
package = pkgs.qogir-theme;
size = 64;
};
}
}

View File

@@ -1,6 +1,5 @@
{
pkgs,
...
{ pkgs
, ...
}: {
home.packages = with pkgs; [
firefox

View File

@@ -3,6 +3,6 @@
{
imports = [
../../modules/darwin/core.nix
../../modules/darwin/core.nix
];
}

View File

@@ -3,11 +3,11 @@
{
# mount a smb/cifs share
fileSystems."/home/ryan/SMB-Downloads" = {
device = "//192.168.5.194/Downloads";
fsType = "cifs";
options = [
"vers=3.0,uid=1000,gid=100,dir_mode=0755,file_mode=0755,mfsymlinks,credentials=${config.age.secrets.smb-credentials.path},nofail"
];
device = "//192.168.5.194/Downloads";
fsType = "cifs";
options = [
"vers=3.0,uid=1000,gid=100,dir_mode=0755,file_mode=0755,mfsymlinks,credentials=${config.age.secrets.smb-credentials.path},nofail"
];
};
}

View File

@@ -30,13 +30,15 @@
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
# supported fil systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [
boot.supportedFilesystems = [
"ext4"
"btrfs"
"xfs"
#"zfs"
"ntfs"
"fat" "vfat" "exfat"
"fat"
"vfat"
"exfat"
"cifs" # mount windows share
];
@@ -51,7 +53,7 @@
networking = {
hostName = "msi-rtx4090"; # Define your hostname.
wireless.enable = false; # Enables wireless support via wpa_supplicant.
wireless.enable = false; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# proxy.default = "http://user:password@proxy:port/";
@@ -59,25 +61,25 @@
networkmanager.enable = true;
enableIPv6 = false; # disable ipv6
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 = [
"119.29.29.29" # DNSPod
"223.5.5.5" # AliDNS
"119.29.29.29" # DNSPod
"223.5.5.5" # AliDNS
];
};
# 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;

View File

@@ -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

View File

@@ -27,13 +27,15 @@
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
# supported fil systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [
boot.supportedFilesystems = [
"ext4"
"btrfs"
"xfs"
#"zfs"
"ntfs"
"fat" "vfat" "exfat"
"fat"
"vfat"
"exfat"
"cifs" # mount windows share
];
@@ -41,7 +43,7 @@
boot.loader = {
grub = {
enable = true;
device = "/dev/sda"; # "nodev"
device = "/dev/sda"; # "nodev"
efiSupport = false;
useOSProber = true;
#efiInstallAsRemovable = true; # in case canTouchEfiVariables doesn't work for your system
@@ -50,7 +52,7 @@
networking = {
hostName = "nixos-test"; # Define your hostname.
wireless.enable = false; # Enables wireless support via wpa_supplicant.
wireless.enable = false; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# proxy.default = "http://user:password@proxy:port/";
@@ -59,15 +61,15 @@
networkmanager.enable = true;
interfaces.ens18 = {
useDHCP = false;
ipv4.addresses = [ {
ipv4.addresses = [{
address = "192.168.5.48";
prefixLength = 24;
} ];
}];
};
defaultGateway = "192.168.5.201";
nameservers = [
"119.29.29.29" # DNSPod
"223.5.5.5" # AliDNS
"119.29.29.29" # DNSPod
"223.5.5.5" # AliDNS
];
};

View File

@@ -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";
};

View File

@@ -50,11 +50,13 @@
font-awesome
# nerdfonts
(nerdfonts.override { fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];})
(nerdfonts.override {
fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];
})
];
};
@@ -64,4 +66,4 @@
home = "/Users/admin";
description = "admin";
};
}
}

View File

@@ -57,23 +57,25 @@
# Noto 系列字体是 Google 主导的名字的含义是「没有豆腐」no tofu因为缺字时显示的方框或者方框被叫作 tofu
# Noto 系列字族名只支持英文,命名规则是 Noto + Sans 或 Serif + 文字名称。
# 其中汉字部分叫 Noto Sans/Serif CJK SC/TC/HK/JP/KR最后一个词是地区变种。
noto-fonts # 大部分文字的常见样式,不包含汉字
noto-fonts-cjk # 汉字部分
noto-fonts-emoji # 彩色的表情符号字体
noto-fonts-extra # 提供额外的字重和宽度变种
noto-fonts # 大部分文字的常见样式,不包含汉字
noto-fonts-cjk # 汉字部分
noto-fonts-emoji # 彩色的表情符号字体
noto-fonts-extra # 提供额外的字重和宽度变种
# 思源系列字体是 Adobe 主导的。其中汉字部分被称为「思源黑体」和「思源宋体」,是由 Adobe + Google 共同开发的
source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro以及带字重的变体加上 Source Sans 3 VF
source-serif # 衬线字体,不含汉字。字族名叫 Source Code Pro以及带字重的变体
source-han-sans # 思源黑体
source-han-serif # 思源宋体
source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro以及带字重的变体加上 Source Sans 3 VF
source-serif # 衬线字体,不含汉字。字族名叫 Source Code Pro以及带字重的变体
source-han-sans # 思源黑体
source-han-serif # 思源宋体
# nerdfonts
(nerdfonts.override { fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];})
(nerdfonts.override {
fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];
})
(pkgs.callPackage ../../fonts/icomoon-feather-icon-font.nix { })
@@ -105,7 +107,7 @@
enable = true;
settings = {
X11Forwarding = true;
PermitRootLogin = "no"; # disable root login
PermitRootLogin = "no"; # disable root login
PasswordAuthentication = false; # disable password login
};
openFirewall = true;
@@ -122,8 +124,8 @@
neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
curl
git # used by nix flakes
git-lfs # used by huggingface models
git # used by nix flakes
git-lfs # used by huggingface models
devenv.packages."${pkgs.system}".devenv
@@ -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
pkgs.buildFHSUserEnv (base // {
name = "fhs";
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [pkgs.pkg-config];
profile = "export FHS=1";
runScript = "bash";
extraOutputsToInstall = ["dev"];
}))
(
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
@@ -182,16 +186,16 @@
# enable bluetooth & gui paring tools - blueman
# or you can use cli:
# $ bluetoothctl
# [bluetooth] # power on
# [bluetooth] # agent on
# [bluetooth] # default-agent
# [bluetooth] # scan on
# ...put device in pairing mode and wait [hex-address] to appear here...
# [bluetooth] # pair [hex-address]
# [bluetooth] # connect [hex-address]
# Bluetooth devices automatically connect with bluetoothctl as well:
# [bluetooth] # trust [hex-address]
# $ bluetoothctl
# [bluetooth] # power on
# [bluetooth] # agent on
# [bluetooth] # default-agent
# [bluetooth] # scan on
# ...put device in pairing mode and wait [hex-address] to appear here...
# [bluetooth] # pair [hex-address]
# [bluetooth] # connect [hex-address]
# Bluetooth devices automatically connect with bluetoothctl as well:
# [bluetooth] # trust [hex-address]
hardware.bluetooth.enable = true;
services.blueman.enable = true;
@@ -212,9 +216,9 @@
geoclue2.enable = true;
udev.packages = with pkgs; [
udev.packages = with pkgs; [
gnome.gnome-settings-daemon
platformio # udev rules for platformio
platformio # udev rules for platformio
android-udev-rules
];
};
@@ -235,8 +239,8 @@
# and vscode has open like `External Uri Openers`
xdgOpenUsePortal = false;
extraPortals = with pkgs; [
xdg-desktop-portal-wlr # for wlroots based compositors(hyprland/sway)
xdg-desktop-portal-gtk # for gtk
xdg-desktop-portal-wlr # for wlroots based compositors(hyprland/sway)
xdg-desktop-portal-gtk # for gtk
# xdg-desktop-portal-kde # for kde
];
};
@@ -251,4 +255,4 @@
# for power management
services.upower.enable = true;
}
}

View File

@@ -51,15 +51,17 @@
font-awesome
# 思源系列字体是 Adobe 主导的。其中汉字部分被称为「思源黑体」和「思源宋体」,是由 Adobe + Google 共同开发的
source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro以及带字重的变体加上 Source Sans 3 VF
source-han-sans # 思源黑体
source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro以及带字重的变体加上 Source Sans 3 VF
source-han-sans # 思源黑体
# nerdfonts
(nerdfonts.override { fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];})
(nerdfonts.override {
fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];
})
];
# user defined fonts
@@ -82,7 +84,7 @@
enable = true;
settings = {
X11Forwarding = true;
PermitRootLogin = "no"; # disable root login
PermitRootLogin = "no"; # disable root login
PasswordAuthentication = false; # disable password login
};
openFirewall = true;
@@ -95,8 +97,8 @@
wget
curl
aria2
git # used by nix flakes
git-lfs # used by huggingface models
git # used by nix flakes
git-lfs # used by huggingface models
];
# replace default editor with neovim
@@ -107,4 +109,4 @@
enable = true;
};
services.upower.enable = true;
}
}

View File

@@ -7,20 +7,22 @@
{
system.fsPackages = [ pkgs.bindfs ];
fileSystems = let
mkRoSymBind = path: {
device = path;
fsType = "fuse.bindfs";
options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
fileSystems =
let
mkRoSymBind = path: {
device = path;
fsType = "fuse.bindfs";
options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.fonts;
pathsToLink = [ "/share/fonts" ];
};
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");
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.fonts;
pathsToLink = [ "/share/fonts" ];
};
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");
};
}
}

View File

@@ -14,4 +14,4 @@
];
# flatpack is recommended to install other apps such as netease-cloud-music/qqmusic/...
}
}

View File

@@ -1,4 +1,4 @@
{pkgs, ...}:
{ pkgs, ... }:
{
@@ -34,7 +34,7 @@
nvidiaPatches = true;
};
programs.light.enable = true; # monitor backlight control
programs.light.enable = true; # monitor backlight control
# thunar file manager(part of xfce) related options
@@ -48,29 +48,29 @@
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
waybar # the status bar
swaybg # the wallpaper
swayidle # the idle timeout
swaylock # locking the screen
wlogout # logout menu
wl-clipboard # copying and pasting
waybar # the status bar
swaybg # the wallpaper
swayidle # the idle timeout
swaylock # locking the screen
wlogout # logout menu
wl-clipboard # copying and pasting
wf-recorder # creen recording
grim # taking screenshots
slurp # selecting a region to screenshot
wf-recorder # creen recording
grim # taking screenshots
slurp # selecting a region to screenshot
# TODO replace by `flameshot gui --raw | wl-copy`
wofi # A rofi inspired launcher for wlroots compositors such as sway/hyprland
mako # the notification daemon, the same as dunst
wofi # A rofi inspired launcher for wlroots compositors such as sway/hyprland
mako # the notification daemon, the same as dunst
yad # a fork of zenity, for creating dialogs
yad # a fork of zenity, for creating dialogs
# 用于播放系统音效
mpd # for playing system sounds
mpc-cli # command-line mpd client
ncmpcpp # a mpd client with a UI
networkmanagerapplet # provide GUI app: nm-connection-editor
mpd # for playing system sounds
mpc-cli # command-line mpd client
ncmpcpp # a mpd client with a UI
networkmanagerapplet # provide GUI app: nm-connection-editor
xfce.thunar # xfce4's file manager
xfce.thunar # xfce4's file manager
];
}

View File

@@ -1,4 +1,4 @@
{pkgs, ...}:
{ pkgs, ... }:
{
@@ -21,26 +21,26 @@
windowManager.i3 = {
enable = true;
extraPackages = with pkgs; [
rofi # application launcher, the same as dmenu
dunst # notification daemon
i3blocks # status bar
i3lock # default i3 screen locker
xautolock # lock screen after some time
i3status # provide information to i3bar
i3-gaps # i3 with gaps
picom # transparency and shadows
feh # set wallpaper
acpi # battery information
arandr # screen layout manager
dex # autostart applications
xbindkeys # bind keys to commands
xorg.xbacklight # control screen brightness, the same as light
xorg.xdpyinfo # get screen information
scrot # minimal screen capture tool, used by i3 blur lock to take a screenshot
sysstat # get system information
rofi # application launcher, the same as dmenu
dunst # notification daemon
i3blocks # status bar
i3lock # default i3 screen locker
xautolock # lock screen after some time
i3status # provide information to i3bar
i3-gaps # i3 with gaps
picom # transparency and shadows
feh # set wallpaper
acpi # battery information
arandr # screen layout manager
dex # autostart applications
xbindkeys # bind keys to commands
xorg.xbacklight # control screen brightness, the same as light
xorg.xdpyinfo # get screen information
scrot # minimal screen capture tool, used by i3 blur lock to take a screenshot
sysstat # get system information
xfce.thunar # xfce4's file manager
];
xfce.thunar # xfce4's file manager
];
};
# Configure keymap in X11
@@ -55,4 +55,4 @@
];
services.gvfs.enable = true; # Mount, trash, and other functionalities
services.tumbler.enable = true; # Thumbnail support for images
}
}

View File

@@ -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 = {
@@ -13,7 +13,7 @@
description = "ryan";
extraGroups = [ "ryan" "users" "networkmanager" "wheel" "docker" "wireshark" "adbusers" ];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj"
];
};
}
}

View File

@@ -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")

View File

@@ -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」

View File

@@ -2,11 +2,11 @@
{
imports = [
agenix.nixosModules.default
agenix.nixosModules.default
];
environment.systemPackages = [
agenix.packages."${pkgs.system}".default
agenix.packages."${pkgs.system}".default
];
# if you changed this key, you need to regenerate all encrypt files from the decrypt contents!
@@ -32,4 +32,4 @@
# encrypted file path
file = ./encrypt/smb-credentials.age;
};
}
}

View File

@@ -17,4 +17,4 @@ in
"./encrypt/wg-business.conf.age".publicKeys = users ++ systems;
"./encrypt/smb-credentials.age".publicKeys = users ++ systems;
# "./encrypt/secret123.age".publicKeys = [ user1 system1 ];
}
}