From f971ec030d5dd5f936c16e9a8b2fc4cd7238197a Mon Sep 17 00:00:00 2001 From: ryan4yin Date: Fri, 26 May 2023 19:25:44 +0800 Subject: [PATCH] feat: redesign the project structure --- flake.lock | 18 +- flake.nix | 87 +++++---- .../terminals.nix => common/alacritty.nix} | 0 home/common/core.nix | 117 ++++++++++++ home/common/default.nix | 17 ++ home/common/development.nix | 97 ++++++++++ home/common/git.nix | 30 ++++ home/common/media.nix | 17 ++ home/{shell => common}/nushell/config.nu | 0 home/{shell => common}/nushell/default.nix | 0 home/{shell => common}/nushell/env.nu | 0 home/{shell => common}/starship.nix | 0 home/darwin/core.nix | 44 +++++ home/darwin/default.nix | 37 +++- home/home-darwin.nix | 28 --- .../git.nix => linux/common/ssh.nix} | 34 ---- home/linux/common/system-tools.nix | 39 ++++ home/{programs => linux/common}/xdg.nix | 9 + home/linux/desktop/creative.nix | 21 +++ home/linux/desktop/default.nix | 21 +++ home/linux/desktop/media.nix | 32 ++++ home/{ => linux}/fcitx5/default.nix | 1 - home/{ => linux}/fcitx5/profile | 0 home/{ => linux}/hyprland/default.nix | 0 .../{ => linux}/hyprland/gtk-3.0/settings.ini | 0 home/{ => linux}/hyprland/gtkrc-2.0 | 0 .../hyprland/hypr-conf/hyprland.conf | 0 .../hyprland/hypr-conf/mako/config | 0 .../hypr-conf/mako/icons/brightness-100.png | Bin .../hypr-conf/mako/icons/brightness-20.png | Bin .../hypr-conf/mako/icons/brightness-40.png | Bin .../hypr-conf/mako/icons/brightness-60.png | Bin .../hypr-conf/mako/icons/brightness-80.png | Bin .../hyprland/hypr-conf/mako/icons/dropper.png | Bin .../hypr-conf/mako/icons/microphone-mute.png | Bin .../hypr-conf/mako/icons/microphone.png | Bin .../hyprland/hypr-conf/mako/icons/music.png | Bin .../hyprland/hypr-conf/mako/icons/palette.png | Bin .../hyprland/hypr-conf/mako/icons/picture.png | Bin .../hyprland/hypr-conf/mako/icons/timer.png | Bin .../hypr-conf/mako/icons/volume-high.png | Bin .../hypr-conf/mako/icons/volume-low.png | Bin .../hypr-conf/mako/icons/volume-mid.png | Bin .../hypr-conf/mako/icons/volume-mute.png | Bin .../hyprland/hypr-conf/scripts/brightness | 0 .../hyprland/hypr-conf/scripts/colorpicker | 0 .../hyprland/hypr-conf/scripts/lockscreen | 0 .../hyprland/hypr-conf/scripts/menu | 0 .../hyprland/hypr-conf/scripts/notifications | 0 .../hyprland/hypr-conf/scripts/screenshot | 0 .../hyprland/hypr-conf/scripts/startup | 0 .../hyprland/hypr-conf/scripts/statusbar | 0 .../hyprland/hypr-conf/scripts/volume | 0 .../hyprland/hypr-conf/scripts/weather | 0 .../hyprland/hypr-conf/scripts/wlogout | 0 .../hyprland/hypr-conf/waybar/config | 0 .../hyprland/hypr-conf/waybar/style.css | 0 .../hypr-conf/wlogout/icons/hibernate.png | Bin .../hyprland/hypr-conf/wlogout/icons/lock.png | Bin .../hypr-conf/wlogout/icons/logout.png | Bin .../hypr-conf/wlogout/icons/reboot.png | Bin .../hypr-conf/wlogout/icons/shutdown.png | Bin .../hypr-conf/wlogout/icons/suspend.png | Bin .../hyprland/hypr-conf/wlogout/layout | 0 .../hyprland/hypr-conf/wlogout/style.css | 0 .../hyprland/hypr-conf/wofi/colors | 0 .../hyprland/hypr-conf/wofi/config | 0 .../hyprland/hypr-conf/wofi/style.css | 0 home/{ => linux}/hyprland/wayland-apps.nix | 0 home/{ => linux}/i3/config | 0 home/{ => linux}/i3/default.nix | 7 + home/{ => linux}/i3/i3blocks.conf | 0 home/{ => linux}/i3/keybindings | 0 .../i3/rofi-conf}/arc_dark_colors.rasi | 0 .../arc_dark_transparent_colors.rasi | 0 .../i3/rofi-conf}/power-profiles.rasi | 0 .../i3/rofi-conf}/powermenu.rasi | 0 .../i3/rofi-conf}/rofidmenu.rasi | 0 .../i3/rofi-conf}/rofikeyhint.rasi | 0 home/{ => linux}/i3/scripts/bandwidth2 | 0 .../i3/scripts/battery-pinebook-pro | 0 home/{ => linux}/i3/scripts/battery1 | 0 home/{ => linux}/i3/scripts/battery2 | 0 home/{ => linux}/i3/scripts/blur-lock | 0 home/{ => linux}/i3/scripts/cpu_usage | 0 home/{ => linux}/i3/scripts/disk | 0 home/{ => linux}/i3/scripts/empty_workspace | 0 home/{ => linux}/i3/scripts/keyboard-layout | 0 home/{ => linux}/i3/scripts/keyhint | 0 home/{ => linux}/i3/scripts/keyhint-2 | 0 home/{ => linux}/i3/scripts/memory | 0 home/{ => linux}/i3/scripts/openweather | 0 home/{ => linux}/i3/scripts/openweather-city | 0 home/{ => linux}/i3/scripts/openweather.conf | 0 home/{ => linux}/i3/scripts/power-profiles | 0 home/{ => linux}/i3/scripts/powermenu | 0 home/{ => linux}/i3/scripts/ppd-status | 0 home/{ => linux}/i3/scripts/temperature | 0 home/{ => linux}/i3/scripts/volume | 0 home/{ => linux}/i3/scripts/vpn | 0 home/{ => linux}/i3/x11-apps.nix | 0 home/{ => linux}/wallpapers/convert_to_png.nu | 0 home/{ => linux}/wallpapers/wallpaper-2.png | Bin home/{ => linux}/wallpapers/wallpaper.png | Bin home/{home-wayland.nix => linux/wayland.nix} | 12 +- home/{home-x11.nix => linux/x11.nix} | 13 +- home/programs/common.nix | 167 ------------------ home/programs/default.nix | 12 -- home/programs/media.nix | 49 ----- home/rofi/default.nix | 18 -- home/shell/common.nix | 18 -- home/shell/default.nix | 48 ----- hosts/harmonica/default.nix | 25 +-- hosts/msi-rtx4090/default.nix | 12 +- hosts/nixos-test/default.nix | 12 +- modules/darwin/{common.nix => core.nix} | 25 ++- .../{system.nix => nixos/core-desktop.nix} | 69 +------- modules/nixos/core-server.nix | 96 ++++++++++ modules/{ => nixos}/fhs-fonts.nix | 5 +- .../{nur-packages.nix => nixos/gui-apps.nix} | 2 + modules/{ => nixos}/hyprland.nix | 2 + modules/{ => nixos}/i3.nix | 3 + modules/{ => nixos}/user_group.nix | 0 scripts/darwin_set_proxy.py | 7 +- 124 files changed, 711 insertions(+), 540 deletions(-) rename home/{shell/terminals.nix => common/alacritty.nix} (100%) create mode 100644 home/common/core.nix create mode 100644 home/common/default.nix create mode 100644 home/common/development.nix create mode 100644 home/common/git.nix create mode 100644 home/common/media.nix rename home/{shell => common}/nushell/config.nu (100%) rename home/{shell => common}/nushell/default.nix (100%) rename home/{shell => common}/nushell/env.nu (100%) rename home/{shell => common}/starship.nix (100%) create mode 100644 home/darwin/core.nix delete mode 100644 home/home-darwin.nix rename home/{programs/git.nix => linux/common/ssh.nix} (76%) create mode 100644 home/linux/common/system-tools.nix rename home/{programs => linux/common}/xdg.nix (77%) create mode 100644 home/linux/desktop/creative.nix create mode 100644 home/linux/desktop/default.nix create mode 100644 home/linux/desktop/media.nix rename home/{ => linux}/fcitx5/default.nix (99%) rename home/{ => linux}/fcitx5/profile (100%) rename home/{ => linux}/hyprland/default.nix (100%) rename home/{ => linux}/hyprland/gtk-3.0/settings.ini (100%) rename home/{ => linux}/hyprland/gtkrc-2.0 (100%) rename home/{ => linux}/hyprland/hypr-conf/hyprland.conf (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/config (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/brightness-100.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/brightness-20.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/brightness-40.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/brightness-60.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/brightness-80.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/dropper.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/microphone-mute.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/microphone.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/music.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/palette.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/picture.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/timer.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/volume-high.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/volume-low.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/volume-mid.png (100%) rename home/{ => linux}/hyprland/hypr-conf/mako/icons/volume-mute.png (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/brightness (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/colorpicker (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/lockscreen (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/menu (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/notifications (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/screenshot (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/startup (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/statusbar (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/volume (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/weather (100%) rename home/{ => linux}/hyprland/hypr-conf/scripts/wlogout (100%) rename home/{ => linux}/hyprland/hypr-conf/waybar/config (100%) rename home/{ => linux}/hyprland/hypr-conf/waybar/style.css (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/icons/hibernate.png (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/icons/lock.png (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/icons/logout.png (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/icons/reboot.png (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/icons/shutdown.png (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/icons/suspend.png (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/layout (100%) rename home/{ => linux}/hyprland/hypr-conf/wlogout/style.css (100%) rename home/{ => linux}/hyprland/hypr-conf/wofi/colors (100%) rename home/{ => linux}/hyprland/hypr-conf/wofi/config (100%) rename home/{ => linux}/hyprland/hypr-conf/wofi/style.css (100%) rename home/{ => linux}/hyprland/wayland-apps.nix (100%) rename home/{ => linux}/i3/config (100%) rename home/{ => linux}/i3/default.nix (87%) rename home/{ => linux}/i3/i3blocks.conf (100%) rename home/{ => linux}/i3/keybindings (100%) rename home/{rofi/configs => linux/i3/rofi-conf}/arc_dark_colors.rasi (100%) rename home/{rofi/configs => linux/i3/rofi-conf}/arc_dark_transparent_colors.rasi (100%) rename home/{rofi/configs => linux/i3/rofi-conf}/power-profiles.rasi (100%) rename home/{rofi/configs => linux/i3/rofi-conf}/powermenu.rasi (100%) rename home/{rofi/configs => linux/i3/rofi-conf}/rofidmenu.rasi (100%) rename home/{rofi/configs => linux/i3/rofi-conf}/rofikeyhint.rasi (100%) rename home/{ => linux}/i3/scripts/bandwidth2 (100%) rename home/{ => linux}/i3/scripts/battery-pinebook-pro (100%) rename home/{ => linux}/i3/scripts/battery1 (100%) rename home/{ => linux}/i3/scripts/battery2 (100%) rename home/{ => linux}/i3/scripts/blur-lock (100%) rename home/{ => linux}/i3/scripts/cpu_usage (100%) rename home/{ => linux}/i3/scripts/disk (100%) rename home/{ => linux}/i3/scripts/empty_workspace (100%) rename home/{ => linux}/i3/scripts/keyboard-layout (100%) rename home/{ => linux}/i3/scripts/keyhint (100%) rename home/{ => linux}/i3/scripts/keyhint-2 (100%) rename home/{ => linux}/i3/scripts/memory (100%) rename home/{ => linux}/i3/scripts/openweather (100%) rename home/{ => linux}/i3/scripts/openweather-city (100%) rename home/{ => linux}/i3/scripts/openweather.conf (100%) rename home/{ => linux}/i3/scripts/power-profiles (100%) rename home/{ => linux}/i3/scripts/powermenu (100%) rename home/{ => linux}/i3/scripts/ppd-status (100%) rename home/{ => linux}/i3/scripts/temperature (100%) rename home/{ => linux}/i3/scripts/volume (100%) rename home/{ => linux}/i3/scripts/vpn (100%) rename home/{ => linux}/i3/x11-apps.nix (100%) rename home/{ => linux}/wallpapers/convert_to_png.nu (100%) rename home/{ => linux}/wallpapers/wallpaper-2.png (100%) rename home/{ => linux}/wallpapers/wallpaper.png (100%) rename home/{home-wayland.nix => linux/wayland.nix} (87%) rename home/{home-x11.nix => linux/x11.nix} (87%) delete mode 100644 home/programs/common.nix delete mode 100644 home/programs/default.nix delete mode 100644 home/programs/media.nix delete mode 100644 home/rofi/default.nix delete mode 100644 home/shell/common.nix delete mode 100644 home/shell/default.nix rename modules/darwin/{common.nix => core.nix} (71%) rename modules/{system.nix => nixos/core-desktop.nix} (79%) create mode 100644 modules/nixos/core-server.nix rename modules/{ => nixos}/fhs-fonts.nix (84%) rename modules/{nur-packages.nix => nixos/gui-apps.nix} (83%) rename modules/{ => nixos}/hyprland.nix (98%) rename modules/{ => nixos}/i3.nix (92%) rename modules/{ => nixos}/user_group.nix (100%) diff --git a/flake.lock b/flake.lock index f8194718..41e73708 100644 --- a/flake.lock +++ b/flake.lock @@ -240,11 +240,11 @@ ] }, "locked": { - "lastModified": 1685019994, - "narHash": "sha256-81o6SKZPALvib21hIOMx2lIhFSs0mRy0PfPvg0zsfTk=", + "lastModified": 1684596126, + "narHash": "sha256-4RZZmygeEXpuBqEXGs38ZAcWjWKGwu13Iqbxub6wuJk=", "owner": "nix-community", "repo": "home-manager", - "rev": "d1f04b0f365a34896a37d9015637796537ec88a3", + "rev": "27ef11f0218d9018ebb2948d40133df2b1de622d", "type": "github" }, "original": { @@ -534,11 +534,11 @@ "nixpkgs": "nixpkgs_7" }, "locked": { - "lastModified": 1685045766, - "narHash": "sha256-MK128KJnrf0PqfdnL40KN57ZSpHPtru19TH+Ok0A0TU=", + "lastModified": 1685121294, + "narHash": "sha256-ddWsZ2JGWgD/xfE2XZhfVibRTacU0hWYVrAovNZNb2M=", "owner": "nix-community", "repo": "nixpkgs-wayland", - "rev": "38c86d9ff0a4cff1e229214031f7eaaab34e10f1", + "rev": "e49f4358e371c5f6486a95e90dfb1754817acdae", "type": "github" }, "original": { @@ -645,11 +645,11 @@ }, "nur": { "locked": { - "lastModified": 1685061478, - "narHash": "sha256-fNCFmOOfTmtWCV4WEoAnwwyjjB4NRAzucTKdt0w5zvg=", + "lastModified": 1685156120, + "narHash": "sha256-XnfGRNvRgqdNyiTm1B2VvzeuLFcENOXIir2jIE7BQ3A=", "owner": "nix-community", "repo": "NUR", - "rev": "82f3aa5c5a85a9f2a1e72eaf0eec30c8ab8fdf2c", + "rev": "d71033acca2e80c8a2341a6dcd81fc9a677b1c4f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index ee8abf8c..71c21d17 100644 --- a/flake.nix +++ b/flake.nix @@ -1,12 +1,6 @@ { description = "NixOS configuration of Ryan Yin"; - # flake 为了确保够纯,它不依赖系统自身的 /etc/nix/nix.conf,而是在 flake.nix 中通过 nixConfig 设置 - # 但是为了确保安全性,flake 默认仅允许直接设置少数 nixConfig 参数,其他参数都需要在执行 nix 命令时指定 `--accept-flake-config`,否则会被忽略 - # - # 如果有些包国内镜像下载不到,它仍然会走国外,这时候就得靠旁路由来解决了。 - # 临时修改默认网关为旁路由: sudo ip route add default via 192.168.5.201 - # sudo ip route del default via 192.168.5.201 nixConfig = { experimental-features = [ "nix-command" "flakes" ]; @@ -31,13 +25,17 @@ ]; }; - # 这是 flake.nix 的标准格式,inputs 是 flake 的依赖,outputs 是 flake 的输出 - # inputs 中的每一项都被拉取、构建后,被作为参数传递给 outputs 函数 - inputs = { - # flake inputs 有很多种引用方式,应用最广泛的是 github 的引用方式 - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # 使用 nixos-unstable 分支 for nix flakes - nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05"; # unstable branch may be broken sometimes, use stable branch when necessary + # This is the standard format for flake.nix. `inputs` are the dependencies of the flake, + # and `outputs` function will return all the build results of the flake. + # Each item in `inputs` will be passed as a parameter to the `outputs` function after being pulled and built. + inputs = { + # There are many ways to reference flake inputs. The most widely used is github:owner/name/reference, + # which represents the GitHub repository URL + branch/commit-id/tag. + + # 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"; @@ -51,10 +49,14 @@ # e.g. wechat-uos/qqmusic/dingtalk nur.url = "github:nix-community/NUR"; - home-manager.url = "github:nix-community/home-manager"; - # follows 是 inputs 中的继承语法 - # 这里使 home-manager 的 nixpkgs 这个 inputs 与当前 flake 的 inputs.nixpkgs 保持一致,避免依赖的 nixpkgs 版本不一致导致问题 - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + # home-manager, used for managing user configuration + home-manager = { + url = "github:nix-community/home-manager"; + # The `follows` keyword in inputs is used for inheritance. + # Here, `inputs.nixpkgs` of home-manager is kept consistent with the `inputs.nixpkgs` of the current flake, + # to avoid problems caused by different versions of nixpkgs dependencies. + inputs.nixpkgs.follows = "nixpkgs"; + }; # modern window compositor hyprland.url = "github:hyprwm/Hyprland/v0.25.0"; @@ -77,9 +79,11 @@ nil.url = "github:oxalica/nil/2023-05-09"; }; - # outputs 的参数都是 inputs 中定义的依赖项,可以通过它们的名称来引用。 - # 不过 self 是个例外,这个特殊参数指向 outputs 自身(自引用),以及 flake 根目录 - # 这里的 @ 语法将函数的参数 attribute set 取了个别名,方便在内部使用 + # `outputs` are all the build result of the flake. + # A flake can have many use cases and different types of outputs. + # 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, @@ -88,49 +92,67 @@ ... }: { 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#`. + # 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 { system = "x86_64-linux"; - specialArgs = 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: + # + # 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 = inputs; # pass all inputs into all sub modules. modules = [ ./hosts/msi-rtx4090 - # home-manager 作为 nixos 的一个 module - # 这样在 nixos-rebuild switch 时,home-manager 也会被自动部署,不需要额外执行 home-manager switch 命令 + # 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; - # 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数 + # pass all inputs into home manager's all sub modules home-manager.extraSpecialArgs = inputs; - home-manager.users.ryan = import ./home/home-x11.nix; + home-manager.users.ryan = import ./home/linux/x11.nix; } ]; }; - nixos-test = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = inputs; modules = [ ./hosts/nixos-test - # home-manager 作为 nixos 的一个 module - # 这样在 nixos-rebuild switch 时,home-manager 也会被自动部署,不需要额外执行 home-manager switch 命令 home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - # 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数 home-manager.extraSpecialArgs = inputs; - home-manager.users.ryan = import ./home/home-wayland.nix; + home-manager.users.ryan = import ./home/linux/wayland.nix; } ]; }; }; + # configurations for MacOS darwinConfigurations."harmonica" = darwin.lib.darwinSystem { system = "x86_64-darwin"; @@ -138,16 +160,13 @@ modules = [ ./hosts/harmonica - # home-manager 作为 nixos 的一个 module - # 这样在 nixos-rebuild switch 时,home-manager 也会被自动部署,不需要额外执行 home-manager switch 命令 home-manager.darwinModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - - # 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数 + home-manager.extraSpecialArgs = inputs; - home-manager.users.admin = import ./home/home-darwin.nix; + home-manager.users.admin = import ./home/darwin; } ]; }; diff --git a/home/shell/terminals.nix b/home/common/alacritty.nix similarity index 100% rename from home/shell/terminals.nix rename to home/common/alacritty.nix diff --git a/home/common/core.nix b/home/common/core.nix new file mode 100644 index 00000000..264c26de --- /dev/null +++ b/home/common/core.nix @@ -0,0 +1,117 @@ +{config, pkgs, ...}: let + d = config.xdg.dataHome; + c = config.xdg.configHome; + cache = config.xdg.cacheHome; +in rec { + home.packages = with pkgs; [ + neofetch + nnn # terminal file manager + + # archives + zip + xz + unzip + 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’ + + # networking tools + mtr # A network diagnostic tool + iperf3 + nmap + socat + 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 + + # misc + file + which + tree + gnused + gnutar + gawk + p7zip + xz + zstd + + # productivity + hugo + ]; + + programs = { + # A terminal multiplexer + tmux = { + enable = true; + }; + + # a cat(1) clone with syntax highlighting and Git integration. + bat = { + enable = true; + config = { + pager = "less -FR"; + theme = "Catppuccin-mocha"; + }; + themes = { + Catppuccin-mocha = builtins.readFile (pkgs.fetchurl { + url = "https://raw.githubusercontent.com/catppuccin/bat/main/Catppuccin-mocha.tmTheme"; + hash = "sha256-qMQNJGZImmjrqzy7IiEkY5IhvPAMZpq0W6skLLsng/w="; + }); + }; + }; + + # skim provides a single executable: sk. + # Basically anywhere you would want to use grep, try sk instead. + skim = { + enable = true; + enableBashIntegration = true; + }; + }; + + services = { + # syncthing.enable = true; + }; + + programs.bash = { + enable = true; + enableCompletion = true; + bashrcExtra = '' + export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin" + ''; + }; + + # add environment variables + systemd.user.sessionVariables = { + # clean up ~ + LESSHISTFILE = cache + "/less/history"; + LESSKEY = c + "/less/lesskey"; + WINEPREFIX = d + "/wine"; + + # set this variable make i3 failed to start + # related issue: + # https://github.com/sddm/sddm/issues/871 + # XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority"; + + # set default applications + BROWSER = "firefox"; + TERMINAL = "alacritty"; + + # enable scrolling in git diff + DELTA_PAGER = "less -R"; + + MANPAGER = "sh -c 'col -bx | bat -l man -p'"; + }; + + home.sessionVariables = systemd.user.sessionVariables; + + home.shellAliases = { + k = "kubectl"; + + urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'"; + urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'"; + }; +} \ No newline at end of file diff --git a/home/common/default.nix b/home/common/default.nix new file mode 100644 index 00000000..b4fa4be4 --- /dev/null +++ b/home/common/default.nix @@ -0,0 +1,17 @@ +{config, pkgs, ...}: let + d = config.xdg.dataHome; + c = config.xdg.configHome; + cache = config.xdg.cacheHome; +in rec { + imports = [ + ./nushell + + ./alacritty.nix + ./core.nix + ./development.nix + ./git.nix + ./media.nix + ./starship.nix + ]; + +} \ No newline at end of file diff --git a/home/common/development.nix b/home/common/development.nix new file mode 100644 index 00000000..6f039e7f --- /dev/null +++ b/home/common/development.nix @@ -0,0 +1,97 @@ +{config, pkgs, nil, ...}: + +{ + home.packages = with pkgs; [ + nil.packages."${pkgs.system}".default # nix language server + + # IDE + insomnia + jetbrains.pycharm-community + # jetbrains.idea-community + + # cloud native + docker-compose + kubectl + kubernetes-helm + terraform + pulumi + + # cloud provider + awscli + + # DO NOT install build tools for C/C++, set it per project by devShell instead + gnumake # used by this repo, to simplify the deployment + clang-tools + clang-analyzer + # lldb + # cmake + # autoconf + # automake + # bison + # cppcheck + # fakeroot + # flex + # gettext + # groff + # libtool + # m4 + # patch + # pkgconf + # texinfo + # binutils + + # Golang + delve + go + go-outline + go-tools + go2nix + gomodifytags + gopls + gotests + impl + + # Rust + rustup + + # python + (python3.withPackages(ps: with ps; [ + ipython + pandas + requests + pyquery + ])) + # need to run `conda-install` before using it + # need to run `conda-shell` before using command `conda` + conda + + # db related + dbeaver + mycli + pgcli + + # embedded development + minicom + ]; + + programs = { + # modern vim + neovim = { + enable = true; + extraConfig = '' + set number relativenumber + ''; + }; + + direnv = { + enable = true; + nix-direnv.enable = true; + enableZshIntegration = true; + }; + }; + + # GitHub CLI tool + programs.gh = { + enable = true; + }; +} \ No newline at end of file diff --git a/home/common/git.nix b/home/common/git.nix new file mode 100644 index 00000000..8cd63414 --- /dev/null +++ b/home/common/git.nix @@ -0,0 +1,30 @@ +{ + pkgs, + ... +}: { + programs.git = { + enable = true; + lfs.enable = true; + + userName = "Ryan Yin"; + userEmail = "xiaoyin_c@qq.com"; + + extraConfig = { + pull = { + rebase = true; + }; + }; + + # signing = { + # key = "xxx"; + # signByDefault = true; + # }; + + delta = { + enable = true; + options = { + features = "side-by-side"; + }; + }; + }; +} \ No newline at end of file diff --git a/home/common/media.nix b/home/common/media.nix new file mode 100644 index 00000000..9ba7d752 --- /dev/null +++ b/home/common/media.nix @@ -0,0 +1,17 @@ +{ + pkgs, + config, + ... +}: +# processing audio/video +{ + home.packages = with pkgs; [ + ffmpeg-full + + # images + viu # terminal image viewer + imv # simple image viewer + imagemagick + graphviz + ]; +} \ No newline at end of file diff --git a/home/shell/nushell/config.nu b/home/common/nushell/config.nu similarity index 100% rename from home/shell/nushell/config.nu rename to home/common/nushell/config.nu diff --git a/home/shell/nushell/default.nix b/home/common/nushell/default.nix similarity index 100% rename from home/shell/nushell/default.nix rename to home/common/nushell/default.nix diff --git a/home/shell/nushell/env.nu b/home/common/nushell/env.nu similarity index 100% rename from home/shell/nushell/env.nu rename to home/common/nushell/env.nu diff --git a/home/shell/starship.nix b/home/common/starship.nix similarity index 100% rename from home/shell/starship.nix rename to home/common/starship.nix diff --git a/home/darwin/core.nix b/home/darwin/core.nix new file mode 100644 index 00000000..8b139797 --- /dev/null +++ b/home/darwin/core.nix @@ -0,0 +1,44 @@ + +{pkgs, ...}: +{ + # MacOS specific configuration + home.packages = with pkgs; [ + + ]; + + programs.ssh = { + enable = true; + + # all my ssh private key are generated by `ssh-keygen -t ed25519 -C "ryan@nickname"` + # the config's format: + # Host — given the pattern used to match against the host name given on the command line. + # HostName — specify nickname or abbreviation for host + # IdentityFile — the location of your SSH key authentication file for the account. + # format in details: + # https://www.ssh.com/academy/ssh/config + extraConfig = '' + Host 192.168.* + # allow to securely use local SSH agent to authenticate on the remote machine. + # It has the same effect as adding cli option `ssh -A user@host` + ForwardAgent yes + # romantic holds my homelab~ + IdentityFile ~/.ssh/romantic + # Specifies that ssh should only use the identity file explicitly configured above + # required to prevent sending default identity files first. + IdentitiesOnly yes + + Host github.com + Hostname github.com + # github is controlled by gluttony~ + IdentityFile ~/.ssh/harmonica + # Specifies that ssh should only use the identity file explicitly configured above + # required to prevent sending default identity files first. + IdentitiesOnly yes + ''; + + # use ssh-agent so we only need to input passphrase once + # run `ssh-add /path/to/key` for every identity file + # check imported keys by `ssh-add -l` + # TODO `ssh-add` can only add keys temporary, use gnome-keyring to unlock all keys after login. + }; +} diff --git a/home/darwin/default.nix b/home/darwin/default.nix index 8bb65890..b468522e 100644 --- a/home/darwin/default.nix +++ b/home/darwin/default.nix @@ -1,10 +1,33 @@ -{pkgs, ...}: +{ pkgs, ... }: + { - home.packages = with pkgs; [ - docker-compose - kubectl - kubernetes-helm - terraform - pulumi + imports = [ + ../common/core.nix + ../common/alacritty.nix + ../common/git.nix + ../common/starship.nix + + ./core.nix ]; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home = { + username = "admin"; + # set homeDirectory make build fail + # homeDirectory = "/Users/admin"; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + stateVersion = "22.11"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; } \ No newline at end of file diff --git a/home/home-darwin.nix b/home/home-darwin.nix deleted file mode 100644 index d0f28242..00000000 --- a/home/home-darwin.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, ... }: - -{ - imports = [ - ./darwin - ]; - - # Home Manager needs a bit of information about you and the - # paths it should manage. - home = { - username = "admin"; - # set homeDirectory make build fail - # homeDirectory = "/Users/admin"; - - # This value determines the Home Manager release that your - # configuration is compatible with. This helps avoid breakage - # when a new Home Manager release introduces backwards - # incompatible changes. - # - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - stateVersion = "22.11"; - }; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; -} diff --git a/home/programs/git.nix b/home/linux/common/ssh.nix similarity index 76% rename from home/programs/git.nix rename to home/linux/common/ssh.nix index 7acd24aa..9c3edfcc 100644 --- a/home/programs/git.nix +++ b/home/linux/common/ssh.nix @@ -2,9 +2,6 @@ pkgs, ... }: { - # home.packages = [ - # ]; - programs.ssh = { enable = true; @@ -39,35 +36,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. }; - - programs.git = { - enable = true; - lfs.enable = true; - - userName = "Ryan Yin"; - userEmail = "xiaoyin_c@qq.com"; - - extraConfig = { - pull = { - rebase = true; - }; - }; - - # signing = { - # key = "xxx"; - # signByDefault = true; - # }; - - delta = { - enable = true; - options = { - features = "side-by-side"; - }; - }; - }; - - # GitHub CLI tool - programs.gh = { - enable = true; - }; } \ No newline at end of file diff --git a/home/linux/common/system-tools.nix b/home/linux/common/system-tools.nix new file mode 100644 index 00000000..4faffde3 --- /dev/null +++ b/home/linux/common/system-tools.nix @@ -0,0 +1,39 @@ +{pkgs, config, ...}: + + +{ + # Linux Only Packages, not available on Darwin + home.packages = with pkgs; [ + btop # replacement of htop/nmon + htop + iotop + nmon + + ## networking tools + wireguard-tools # manage wireguard vpn manually, via wg-quick + iftop + + # misc + libnotify + + # system call monitoring + strace + ltrace # library call monitoring + lsof + + # system tools + ethtool + sysstat + lm_sensors # for `sensors` command + cifs-utils # for mounting windows shares + ]; + + # auto mount usb drives + services = { + udiskie.enable = true; + }; + + services = { + playerctld.enable = true; + }; +} diff --git a/home/programs/xdg.nix b/home/linux/common/xdg.nix similarity index 77% rename from home/programs/xdg.nix rename to home/linux/common/xdg.nix index 251d38d0..65703149 100644 --- a/home/programs/xdg.nix +++ b/home/linux/common/xdg.nix @@ -1,3 +1,7 @@ +# XDG stands for "Cross-Desktop Group", with X used to mean "cross". +# 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, ...}: let browser = ["firefox.desktop"]; @@ -25,6 +29,11 @@ "x-scheme-handler/tg" = ["telegramdesktop.desktop"]; }; in { + home.packages = with pkgs; [ + xdg-utils + xdg-user-dirs + ]; + xdg = { enable = true; cacheHome = config.home.homeDirectory + "/.local/cache"; diff --git a/home/linux/desktop/creative.nix b/home/linux/desktop/creative.nix new file mode 100644 index 00000000..77de5927 --- /dev/null +++ b/home/linux/desktop/creative.nix @@ -0,0 +1,21 @@ +{ + 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 + kicad # 3d printing, eletrical engineering + musescore # music notation + reaper # audio production + ]; + + programs = { + obs-studio.enable = true; + }; +} \ No newline at end of file diff --git a/home/linux/desktop/default.nix b/home/linux/desktop/default.nix new file mode 100644 index 00000000..43948cc9 --- /dev/null +++ b/home/linux/desktop/default.nix @@ -0,0 +1,21 @@ +{ pkgs, ... }: +{ + imports = [ + ./creative.nix + ./media.nix + ]; + + home.packages = with pkgs; [ + # networking + wireshark + + # instant messaging + telegram-desktop + discord + qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq + + # remote desktop(rdp connect) + remmina + freerdp # required by remmina + ]; +} \ No newline at end of file diff --git a/home/linux/desktop/media.nix b/home/linux/desktop/media.nix new file mode 100644 index 00000000..5de474ca --- /dev/null +++ b/home/linux/desktop/media.nix @@ -0,0 +1,32 @@ +{ + pkgs, + config, + ... +}: +# media - control and enjoy audio/video +{ + home.packages = with pkgs; [ + # audio control + pavucontrol + playerctl + pulsemixer + + nvtop + + # video/audio tools + libva-utils + vdpauinfo + vulkan-tools + glxinfo + ]; + + programs = { + mpv = { + enable = true; + defaultProfiles = ["gpu-hq"]; + scripts = [pkgs.mpvScripts.mpris]; + }; + + obs-studio.enable = true; + }; +} \ No newline at end of file diff --git a/home/fcitx5/default.nix b/home/linux/fcitx5/default.nix similarity index 99% rename from home/fcitx5/default.nix rename to home/linux/fcitx5/default.nix index 67fefadf..45cc8313 100644 --- a/home/fcitx5/default.nix +++ b/home/linux/fcitx5/default.nix @@ -29,6 +29,5 @@ XMODIFIERS = "@im=fcitx"; INPUT_METHOD = "fcitx"; IMSETTINGS_MODULE = "fcitx"; - }; } \ No newline at end of file diff --git a/home/fcitx5/profile b/home/linux/fcitx5/profile similarity index 100% rename from home/fcitx5/profile rename to home/linux/fcitx5/profile diff --git a/home/hyprland/default.nix b/home/linux/hyprland/default.nix similarity index 100% rename from home/hyprland/default.nix rename to home/linux/hyprland/default.nix diff --git a/home/hyprland/gtk-3.0/settings.ini b/home/linux/hyprland/gtk-3.0/settings.ini similarity index 100% rename from home/hyprland/gtk-3.0/settings.ini rename to home/linux/hyprland/gtk-3.0/settings.ini diff --git a/home/hyprland/gtkrc-2.0 b/home/linux/hyprland/gtkrc-2.0 similarity index 100% rename from home/hyprland/gtkrc-2.0 rename to home/linux/hyprland/gtkrc-2.0 diff --git a/home/hyprland/hypr-conf/hyprland.conf b/home/linux/hyprland/hypr-conf/hyprland.conf similarity index 100% rename from home/hyprland/hypr-conf/hyprland.conf rename to home/linux/hyprland/hypr-conf/hyprland.conf diff --git a/home/hyprland/hypr-conf/mako/config b/home/linux/hyprland/hypr-conf/mako/config similarity index 100% rename from home/hyprland/hypr-conf/mako/config rename to home/linux/hyprland/hypr-conf/mako/config diff --git a/home/hyprland/hypr-conf/mako/icons/brightness-100.png b/home/linux/hyprland/hypr-conf/mako/icons/brightness-100.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/brightness-100.png rename to home/linux/hyprland/hypr-conf/mako/icons/brightness-100.png diff --git a/home/hyprland/hypr-conf/mako/icons/brightness-20.png b/home/linux/hyprland/hypr-conf/mako/icons/brightness-20.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/brightness-20.png rename to home/linux/hyprland/hypr-conf/mako/icons/brightness-20.png diff --git a/home/hyprland/hypr-conf/mako/icons/brightness-40.png b/home/linux/hyprland/hypr-conf/mako/icons/brightness-40.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/brightness-40.png rename to home/linux/hyprland/hypr-conf/mako/icons/brightness-40.png diff --git a/home/hyprland/hypr-conf/mako/icons/brightness-60.png b/home/linux/hyprland/hypr-conf/mako/icons/brightness-60.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/brightness-60.png rename to home/linux/hyprland/hypr-conf/mako/icons/brightness-60.png diff --git a/home/hyprland/hypr-conf/mako/icons/brightness-80.png b/home/linux/hyprland/hypr-conf/mako/icons/brightness-80.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/brightness-80.png rename to home/linux/hyprland/hypr-conf/mako/icons/brightness-80.png diff --git a/home/hyprland/hypr-conf/mako/icons/dropper.png b/home/linux/hyprland/hypr-conf/mako/icons/dropper.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/dropper.png rename to home/linux/hyprland/hypr-conf/mako/icons/dropper.png diff --git a/home/hyprland/hypr-conf/mako/icons/microphone-mute.png b/home/linux/hyprland/hypr-conf/mako/icons/microphone-mute.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/microphone-mute.png rename to home/linux/hyprland/hypr-conf/mako/icons/microphone-mute.png diff --git a/home/hyprland/hypr-conf/mako/icons/microphone.png b/home/linux/hyprland/hypr-conf/mako/icons/microphone.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/microphone.png rename to home/linux/hyprland/hypr-conf/mako/icons/microphone.png diff --git a/home/hyprland/hypr-conf/mako/icons/music.png b/home/linux/hyprland/hypr-conf/mako/icons/music.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/music.png rename to home/linux/hyprland/hypr-conf/mako/icons/music.png diff --git a/home/hyprland/hypr-conf/mako/icons/palette.png b/home/linux/hyprland/hypr-conf/mako/icons/palette.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/palette.png rename to home/linux/hyprland/hypr-conf/mako/icons/palette.png diff --git a/home/hyprland/hypr-conf/mako/icons/picture.png b/home/linux/hyprland/hypr-conf/mako/icons/picture.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/picture.png rename to home/linux/hyprland/hypr-conf/mako/icons/picture.png diff --git a/home/hyprland/hypr-conf/mako/icons/timer.png b/home/linux/hyprland/hypr-conf/mako/icons/timer.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/timer.png rename to home/linux/hyprland/hypr-conf/mako/icons/timer.png diff --git a/home/hyprland/hypr-conf/mako/icons/volume-high.png b/home/linux/hyprland/hypr-conf/mako/icons/volume-high.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/volume-high.png rename to home/linux/hyprland/hypr-conf/mako/icons/volume-high.png diff --git a/home/hyprland/hypr-conf/mako/icons/volume-low.png b/home/linux/hyprland/hypr-conf/mako/icons/volume-low.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/volume-low.png rename to home/linux/hyprland/hypr-conf/mako/icons/volume-low.png diff --git a/home/hyprland/hypr-conf/mako/icons/volume-mid.png b/home/linux/hyprland/hypr-conf/mako/icons/volume-mid.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/volume-mid.png rename to home/linux/hyprland/hypr-conf/mako/icons/volume-mid.png diff --git a/home/hyprland/hypr-conf/mako/icons/volume-mute.png b/home/linux/hyprland/hypr-conf/mako/icons/volume-mute.png similarity index 100% rename from home/hyprland/hypr-conf/mako/icons/volume-mute.png rename to home/linux/hyprland/hypr-conf/mako/icons/volume-mute.png diff --git a/home/hyprland/hypr-conf/scripts/brightness b/home/linux/hyprland/hypr-conf/scripts/brightness similarity index 100% rename from home/hyprland/hypr-conf/scripts/brightness rename to home/linux/hyprland/hypr-conf/scripts/brightness diff --git a/home/hyprland/hypr-conf/scripts/colorpicker b/home/linux/hyprland/hypr-conf/scripts/colorpicker similarity index 100% rename from home/hyprland/hypr-conf/scripts/colorpicker rename to home/linux/hyprland/hypr-conf/scripts/colorpicker diff --git a/home/hyprland/hypr-conf/scripts/lockscreen b/home/linux/hyprland/hypr-conf/scripts/lockscreen similarity index 100% rename from home/hyprland/hypr-conf/scripts/lockscreen rename to home/linux/hyprland/hypr-conf/scripts/lockscreen diff --git a/home/hyprland/hypr-conf/scripts/menu b/home/linux/hyprland/hypr-conf/scripts/menu similarity index 100% rename from home/hyprland/hypr-conf/scripts/menu rename to home/linux/hyprland/hypr-conf/scripts/menu diff --git a/home/hyprland/hypr-conf/scripts/notifications b/home/linux/hyprland/hypr-conf/scripts/notifications similarity index 100% rename from home/hyprland/hypr-conf/scripts/notifications rename to home/linux/hyprland/hypr-conf/scripts/notifications diff --git a/home/hyprland/hypr-conf/scripts/screenshot b/home/linux/hyprland/hypr-conf/scripts/screenshot similarity index 100% rename from home/hyprland/hypr-conf/scripts/screenshot rename to home/linux/hyprland/hypr-conf/scripts/screenshot diff --git a/home/hyprland/hypr-conf/scripts/startup b/home/linux/hyprland/hypr-conf/scripts/startup similarity index 100% rename from home/hyprland/hypr-conf/scripts/startup rename to home/linux/hyprland/hypr-conf/scripts/startup diff --git a/home/hyprland/hypr-conf/scripts/statusbar b/home/linux/hyprland/hypr-conf/scripts/statusbar similarity index 100% rename from home/hyprland/hypr-conf/scripts/statusbar rename to home/linux/hyprland/hypr-conf/scripts/statusbar diff --git a/home/hyprland/hypr-conf/scripts/volume b/home/linux/hyprland/hypr-conf/scripts/volume similarity index 100% rename from home/hyprland/hypr-conf/scripts/volume rename to home/linux/hyprland/hypr-conf/scripts/volume diff --git a/home/hyprland/hypr-conf/scripts/weather b/home/linux/hyprland/hypr-conf/scripts/weather similarity index 100% rename from home/hyprland/hypr-conf/scripts/weather rename to home/linux/hyprland/hypr-conf/scripts/weather diff --git a/home/hyprland/hypr-conf/scripts/wlogout b/home/linux/hyprland/hypr-conf/scripts/wlogout similarity index 100% rename from home/hyprland/hypr-conf/scripts/wlogout rename to home/linux/hyprland/hypr-conf/scripts/wlogout diff --git a/home/hyprland/hypr-conf/waybar/config b/home/linux/hyprland/hypr-conf/waybar/config similarity index 100% rename from home/hyprland/hypr-conf/waybar/config rename to home/linux/hyprland/hypr-conf/waybar/config diff --git a/home/hyprland/hypr-conf/waybar/style.css b/home/linux/hyprland/hypr-conf/waybar/style.css similarity index 100% rename from home/hyprland/hypr-conf/waybar/style.css rename to home/linux/hyprland/hypr-conf/waybar/style.css diff --git a/home/hyprland/hypr-conf/wlogout/icons/hibernate.png b/home/linux/hyprland/hypr-conf/wlogout/icons/hibernate.png similarity index 100% rename from home/hyprland/hypr-conf/wlogout/icons/hibernate.png rename to home/linux/hyprland/hypr-conf/wlogout/icons/hibernate.png diff --git a/home/hyprland/hypr-conf/wlogout/icons/lock.png b/home/linux/hyprland/hypr-conf/wlogout/icons/lock.png similarity index 100% rename from home/hyprland/hypr-conf/wlogout/icons/lock.png rename to home/linux/hyprland/hypr-conf/wlogout/icons/lock.png diff --git a/home/hyprland/hypr-conf/wlogout/icons/logout.png b/home/linux/hyprland/hypr-conf/wlogout/icons/logout.png similarity index 100% rename from home/hyprland/hypr-conf/wlogout/icons/logout.png rename to home/linux/hyprland/hypr-conf/wlogout/icons/logout.png diff --git a/home/hyprland/hypr-conf/wlogout/icons/reboot.png b/home/linux/hyprland/hypr-conf/wlogout/icons/reboot.png similarity index 100% rename from home/hyprland/hypr-conf/wlogout/icons/reboot.png rename to home/linux/hyprland/hypr-conf/wlogout/icons/reboot.png diff --git a/home/hyprland/hypr-conf/wlogout/icons/shutdown.png b/home/linux/hyprland/hypr-conf/wlogout/icons/shutdown.png similarity index 100% rename from home/hyprland/hypr-conf/wlogout/icons/shutdown.png rename to home/linux/hyprland/hypr-conf/wlogout/icons/shutdown.png diff --git a/home/hyprland/hypr-conf/wlogout/icons/suspend.png b/home/linux/hyprland/hypr-conf/wlogout/icons/suspend.png similarity index 100% rename from home/hyprland/hypr-conf/wlogout/icons/suspend.png rename to home/linux/hyprland/hypr-conf/wlogout/icons/suspend.png diff --git a/home/hyprland/hypr-conf/wlogout/layout b/home/linux/hyprland/hypr-conf/wlogout/layout similarity index 100% rename from home/hyprland/hypr-conf/wlogout/layout rename to home/linux/hyprland/hypr-conf/wlogout/layout diff --git a/home/hyprland/hypr-conf/wlogout/style.css b/home/linux/hyprland/hypr-conf/wlogout/style.css similarity index 100% rename from home/hyprland/hypr-conf/wlogout/style.css rename to home/linux/hyprland/hypr-conf/wlogout/style.css diff --git a/home/hyprland/hypr-conf/wofi/colors b/home/linux/hyprland/hypr-conf/wofi/colors similarity index 100% rename from home/hyprland/hypr-conf/wofi/colors rename to home/linux/hyprland/hypr-conf/wofi/colors diff --git a/home/hyprland/hypr-conf/wofi/config b/home/linux/hyprland/hypr-conf/wofi/config similarity index 100% rename from home/hyprland/hypr-conf/wofi/config rename to home/linux/hyprland/hypr-conf/wofi/config diff --git a/home/hyprland/hypr-conf/wofi/style.css b/home/linux/hyprland/hypr-conf/wofi/style.css similarity index 100% rename from home/hyprland/hypr-conf/wofi/style.css rename to home/linux/hyprland/hypr-conf/wofi/style.css diff --git a/home/hyprland/wayland-apps.nix b/home/linux/hyprland/wayland-apps.nix similarity index 100% rename from home/hyprland/wayland-apps.nix rename to home/linux/hyprland/wayland-apps.nix diff --git a/home/i3/config b/home/linux/i3/config similarity index 100% rename from home/i3/config rename to home/linux/i3/config diff --git a/home/i3/default.nix b/home/linux/i3/default.nix similarity index 87% rename from home/i3/default.nix rename to home/linux/i3/default.nix index 70eb1831..33dec8a0 100644 --- a/home/i3/default.nix +++ b/home/linux/i3/default.nix @@ -23,6 +23,13 @@ executable = true; # make all scripts executable }; + # rofi is a application launcher and dmenu replacement + home.file.".config/rofi" = { + source = ./rofi-conf; + # copy the scripts directory recursively + recursive = true; + }; + # allow fontconfig to discover fonts and configurations installed through home.packages fonts.fontconfig.enable = true; diff --git a/home/i3/i3blocks.conf b/home/linux/i3/i3blocks.conf similarity index 100% rename from home/i3/i3blocks.conf rename to home/linux/i3/i3blocks.conf diff --git a/home/i3/keybindings b/home/linux/i3/keybindings similarity index 100% rename from home/i3/keybindings rename to home/linux/i3/keybindings diff --git a/home/rofi/configs/arc_dark_colors.rasi b/home/linux/i3/rofi-conf/arc_dark_colors.rasi similarity index 100% rename from home/rofi/configs/arc_dark_colors.rasi rename to home/linux/i3/rofi-conf/arc_dark_colors.rasi diff --git a/home/rofi/configs/arc_dark_transparent_colors.rasi b/home/linux/i3/rofi-conf/arc_dark_transparent_colors.rasi similarity index 100% rename from home/rofi/configs/arc_dark_transparent_colors.rasi rename to home/linux/i3/rofi-conf/arc_dark_transparent_colors.rasi diff --git a/home/rofi/configs/power-profiles.rasi b/home/linux/i3/rofi-conf/power-profiles.rasi similarity index 100% rename from home/rofi/configs/power-profiles.rasi rename to home/linux/i3/rofi-conf/power-profiles.rasi diff --git a/home/rofi/configs/powermenu.rasi b/home/linux/i3/rofi-conf/powermenu.rasi similarity index 100% rename from home/rofi/configs/powermenu.rasi rename to home/linux/i3/rofi-conf/powermenu.rasi diff --git a/home/rofi/configs/rofidmenu.rasi b/home/linux/i3/rofi-conf/rofidmenu.rasi similarity index 100% rename from home/rofi/configs/rofidmenu.rasi rename to home/linux/i3/rofi-conf/rofidmenu.rasi diff --git a/home/rofi/configs/rofikeyhint.rasi b/home/linux/i3/rofi-conf/rofikeyhint.rasi similarity index 100% rename from home/rofi/configs/rofikeyhint.rasi rename to home/linux/i3/rofi-conf/rofikeyhint.rasi diff --git a/home/i3/scripts/bandwidth2 b/home/linux/i3/scripts/bandwidth2 similarity index 100% rename from home/i3/scripts/bandwidth2 rename to home/linux/i3/scripts/bandwidth2 diff --git a/home/i3/scripts/battery-pinebook-pro b/home/linux/i3/scripts/battery-pinebook-pro similarity index 100% rename from home/i3/scripts/battery-pinebook-pro rename to home/linux/i3/scripts/battery-pinebook-pro diff --git a/home/i3/scripts/battery1 b/home/linux/i3/scripts/battery1 similarity index 100% rename from home/i3/scripts/battery1 rename to home/linux/i3/scripts/battery1 diff --git a/home/i3/scripts/battery2 b/home/linux/i3/scripts/battery2 similarity index 100% rename from home/i3/scripts/battery2 rename to home/linux/i3/scripts/battery2 diff --git a/home/i3/scripts/blur-lock b/home/linux/i3/scripts/blur-lock similarity index 100% rename from home/i3/scripts/blur-lock rename to home/linux/i3/scripts/blur-lock diff --git a/home/i3/scripts/cpu_usage b/home/linux/i3/scripts/cpu_usage similarity index 100% rename from home/i3/scripts/cpu_usage rename to home/linux/i3/scripts/cpu_usage diff --git a/home/i3/scripts/disk b/home/linux/i3/scripts/disk similarity index 100% rename from home/i3/scripts/disk rename to home/linux/i3/scripts/disk diff --git a/home/i3/scripts/empty_workspace b/home/linux/i3/scripts/empty_workspace similarity index 100% rename from home/i3/scripts/empty_workspace rename to home/linux/i3/scripts/empty_workspace diff --git a/home/i3/scripts/keyboard-layout b/home/linux/i3/scripts/keyboard-layout similarity index 100% rename from home/i3/scripts/keyboard-layout rename to home/linux/i3/scripts/keyboard-layout diff --git a/home/i3/scripts/keyhint b/home/linux/i3/scripts/keyhint similarity index 100% rename from home/i3/scripts/keyhint rename to home/linux/i3/scripts/keyhint diff --git a/home/i3/scripts/keyhint-2 b/home/linux/i3/scripts/keyhint-2 similarity index 100% rename from home/i3/scripts/keyhint-2 rename to home/linux/i3/scripts/keyhint-2 diff --git a/home/i3/scripts/memory b/home/linux/i3/scripts/memory similarity index 100% rename from home/i3/scripts/memory rename to home/linux/i3/scripts/memory diff --git a/home/i3/scripts/openweather b/home/linux/i3/scripts/openweather similarity index 100% rename from home/i3/scripts/openweather rename to home/linux/i3/scripts/openweather diff --git a/home/i3/scripts/openweather-city b/home/linux/i3/scripts/openweather-city similarity index 100% rename from home/i3/scripts/openweather-city rename to home/linux/i3/scripts/openweather-city diff --git a/home/i3/scripts/openweather.conf b/home/linux/i3/scripts/openweather.conf similarity index 100% rename from home/i3/scripts/openweather.conf rename to home/linux/i3/scripts/openweather.conf diff --git a/home/i3/scripts/power-profiles b/home/linux/i3/scripts/power-profiles similarity index 100% rename from home/i3/scripts/power-profiles rename to home/linux/i3/scripts/power-profiles diff --git a/home/i3/scripts/powermenu b/home/linux/i3/scripts/powermenu similarity index 100% rename from home/i3/scripts/powermenu rename to home/linux/i3/scripts/powermenu diff --git a/home/i3/scripts/ppd-status b/home/linux/i3/scripts/ppd-status similarity index 100% rename from home/i3/scripts/ppd-status rename to home/linux/i3/scripts/ppd-status diff --git a/home/i3/scripts/temperature b/home/linux/i3/scripts/temperature similarity index 100% rename from home/i3/scripts/temperature rename to home/linux/i3/scripts/temperature diff --git a/home/i3/scripts/volume b/home/linux/i3/scripts/volume similarity index 100% rename from home/i3/scripts/volume rename to home/linux/i3/scripts/volume diff --git a/home/i3/scripts/vpn b/home/linux/i3/scripts/vpn similarity index 100% rename from home/i3/scripts/vpn rename to home/linux/i3/scripts/vpn diff --git a/home/i3/x11-apps.nix b/home/linux/i3/x11-apps.nix similarity index 100% rename from home/i3/x11-apps.nix rename to home/linux/i3/x11-apps.nix diff --git a/home/wallpapers/convert_to_png.nu b/home/linux/wallpapers/convert_to_png.nu similarity index 100% rename from home/wallpapers/convert_to_png.nu rename to home/linux/wallpapers/convert_to_png.nu diff --git a/home/wallpapers/wallpaper-2.png b/home/linux/wallpapers/wallpaper-2.png similarity index 100% rename from home/wallpapers/wallpaper-2.png rename to home/linux/wallpapers/wallpaper-2.png diff --git a/home/wallpapers/wallpaper.png b/home/linux/wallpapers/wallpaper.png similarity index 100% rename from home/wallpapers/wallpaper.png rename to home/linux/wallpapers/wallpaper.png diff --git a/home/home-wayland.nix b/home/linux/wayland.nix similarity index 87% rename from home/home-wayland.nix rename to home/linux/wayland.nix index efa1dfac..9b6be550 100644 --- a/home/home-wayland.nix +++ b/home/linux/wayland.nix @@ -2,10 +2,16 @@ { imports = [ - ./fcitx5 + ../common + ./hyprland - ./programs - ./shell + + ./fcitx5 + ./desktop + + ./common/ssh.nix + ./common/system-tools.nix + ./common/xdg.nix ]; # Home Manager needs a bit of information about you and the diff --git a/home/home-x11.nix b/home/linux/x11.nix similarity index 87% rename from home/home-x11.nix rename to home/linux/x11.nix index 281b12cb..6bc5ea1c 100644 --- a/home/home-x11.nix +++ b/home/linux/x11.nix @@ -2,11 +2,16 @@ { imports = [ - ./fcitx5 + ../common + ./i3 - ./programs - ./rofi - ./shell + + ./fcitx5 + ./desktop + + ./common/ssh.nix + ./common/system-tools.nix + ./common/xdg.nix ]; # Home Manager needs a bit of information about you and the diff --git a/home/programs/common.nix b/home/programs/common.nix deleted file mode 100644 index a2feb64b..00000000 --- a/home/programs/common.nix +++ /dev/null @@ -1,167 +0,0 @@ -{pkgs, config, nil, ...}: - - -{ - home.packages = with pkgs; [ - # archives - zip - unzip - p7zip - - # utils - ripgrep - yq-go # https://github.com/mikefarah/yq - htop - iotop - iftop - nmon - - ## networking tools - wireshark - wireguard-tools # manage wireguard vpn manually, via wg-quick - - # misc - libnotify - xdg-utils - - # productivity - obsidian - hugo - - nil.packages."${pkgs.system}".default # nix language server - - # IDE - insomnia - jetbrains.pycharm-community - # jetbrains.idea-community - - # cloud native - docker-compose - kubectl - kubernetes-helm - terraform - pulumi - - # cloud provider - awscli - - # C - clang-tools - clang-analyzer - lldb - gnumake - cmake - autoconf - automake - bison - cppcheck - fakeroot - flex - gettext - groff - libtool - m4 - patch - pkgconf - texinfo - binutils - - - # Golang - delve - go - go-outline - go-tools - go2nix - gomodifytags - gopls - gotests - impl - - # Rust - rustup - - # nodejs - nodejs - nodePackages.npm - nodePackages.pnpm - yarn - - # db related - dbeaver - mycli - pgcli - - # instant messaging - telegram-desktop - discord - qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq - - # music - musescore - - # system call monitoring - strace - ltrace # library call monitoring - lsof - mtr - - # A tool to create bootable live USB drives from ISO images - unetbootin - ]; - - programs = { - # A terminal multiplexer - tmux = { - enable = true; - }; - - # modern vim - neovim = { - enable = true; - defaultEditor = true; # set nvim as default editor - extraConfig = '' - set number relativenumber - ''; - }; - - # a cat(1) clone with syntax highlighting and Git integration. - bat = { - enable = true; - config = { - pager = "less -FR"; - theme = "Catppuccin-mocha"; - }; - themes = { - Catppuccin-mocha = builtins.readFile (pkgs.fetchurl { - url = "https://raw.githubusercontent.com/catppuccin/bat/main/Catppuccin-mocha.tmTheme"; - hash = "sha256-qMQNJGZImmjrqzy7IiEkY5IhvPAMZpq0W6skLLsng/w="; - }); - }; - }; - - btop.enable = true; # replacement of htop/nmon - exa.enable = true; # A modern replacement for ‘ls’ - jq.enable = true; # A lightweight and flexible command-line JSON processor - aria2.enable = true; # a - - # skim provides a single executable: sk. - # Basically anywhere you would want to use grep, try sk instead. - skim = { - enable = true; - enableBashIntegration = true; - }; - - direnv = { - enable = true; - nix-direnv.enable = true; - }; - }; - - services = { - # syncthing.enable = true; - - # auto mount usb drives - udiskie.enable = true; - }; -} diff --git a/home/programs/default.nix b/home/programs/default.nix deleted file mode 100644 index 74ecdb1e..00000000 --- a/home/programs/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - config, - pkgs, - ... -}: { - imports = [ - ./common.nix - ./git.nix - ./media.nix - ./xdg.nix - ]; -} \ No newline at end of file diff --git a/home/programs/media.nix b/home/programs/media.nix deleted file mode 100644 index b3c277bf..00000000 --- a/home/programs/media.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - pkgs, - config, - ... -}: -# media - control and enjoy audio/video -{ - # imports = [ - # ]; - - home.packages = with pkgs; [ - # audio control - pavucontrol - playerctl - pulsemixer - - ffmpeg-full - - # images - viu # terminal image viewer - imv # simple image viewer - imagemagick - graphviz - - # creative - blender # 3d modeling - gimp # image editing - inkscape # vector graphics - krita # digital painting - - # 3d printing, eletrical engineering - kicad - - ]; - - programs = { - mpv = { - enable = true; - defaultProfiles = ["gpu-hq"]; - scripts = [pkgs.mpvScripts.mpris]; - }; - - obs-studio.enable = true; - }; - - services = { - playerctld.enable = true; - }; -} \ No newline at end of file diff --git a/home/rofi/default.nix b/home/rofi/default.nix deleted file mode 100644 index 80eab078..00000000 --- a/home/rofi/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - pkgs, - config, - ... -}: { - # 基于 https://github.com/endeavouros-team/endeavouros-i3wm-setup - # 直接从当前文件夹中读取配置文件作为配置内容 - home.file.".config/rofi" = { - source = ./configs; - # copy the scripts directory recursively - recursive = true; - }; - - # 直接以 text 的方式,在 nix 配置文件中硬编码文件内容 - # home.file.".xxx".text = '' - # xxx - # ''; -} \ No newline at end of file diff --git a/home/shell/common.nix b/home/shell/common.nix deleted file mode 100644 index 7b1441b6..00000000 --- a/home/shell/common.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - pkgs, - ... -}: -# nix tooling -{ - home.packages = with pkgs; [ - alejandra - deadnix - statix - ]; - - programs.direnv = { - enable = true; - nix-direnv.enable = true; - enableZshIntegration = true; - }; -} \ No newline at end of file diff --git a/home/shell/default.nix b/home/shell/default.nix deleted file mode 100644 index b2c8792d..00000000 --- a/home/shell/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -{config, ...}: let - d = config.xdg.dataHome; - c = config.xdg.configHome; - cache = config.xdg.cacheHome; -in rec { - imports = [ - ./nushell - ./common.nix - ./starship.nix - ./terminals.nix - ]; - - programs.bash = { - enable = true; - enableCompletion = true; - bashrcExtra = '' - export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin" - ''; - }; - - # add environment variables - systemd.user.sessionVariables = { - # clean up ~ - LESSHISTFILE = cache + "/less/history"; - LESSKEY = c + "/less/lesskey"; - WINEPREFIX = d + "/wine"; - - # set this variable make i3 failed to start - # related issue: - # https://github.com/sddm/sddm/issues/871 - # XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority"; - - # set default applications - BROWSER = "firefox"; - TERMINAL = "alacritty"; - - # enable scrolling in git diff - DELTA_PAGER = "less -R"; - - MANPAGER = "sh -c 'col -bx | bat -l man -p'"; - }; - - home.sessionVariables = systemd.user.sessionVariables; - - home.shellAliases = { - k = "kubectl"; - }; -} \ No newline at end of file diff --git a/hosts/harmonica/default.nix b/hosts/harmonica/default.nix index 491dd9e4..c04ee813 100644 --- a/hosts/harmonica/default.nix +++ b/hosts/harmonica/default.nix @@ -3,31 +3,8 @@ { imports = [ - ../../modules/darwin/common.nix + ../../modules/darwin/core.nix ]; - - # # enable flakes globally - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - # Auto upgrade nix package and the daemon service. - services.nix-daemon.enable = true; - # Use this instead of services.nix-daemon.enable if you - # don't wan't the daemon service to be managed for you. - # nix.useDaemon = true; - - nix.package = pkgs.nix; - - programs.nix-index.enable = true; - - # Add ability to used TouchID for sudo authentication - security.pam.enableSudoTouchIdAuth = true; - - # Keyboard - system.keyboard.enableKeyMapping = true; - system.keyboard.remapCapsLockToEscape = true; - - # Set your time zone. - time.timeZone = "Asia/Shanghai"; } diff --git a/hosts/msi-rtx4090/default.nix b/hosts/msi-rtx4090/default.nix index 8315c33b..a2842ea3 100644 --- a/hosts/msi-rtx4090/default.nix +++ b/hosts/msi-rtx4090/default.nix @@ -15,12 +15,12 @@ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../modules/fhs-fonts.nix - # ../../modules/hyprland.nix - ../../modules/i3.nix - ../../modules/nur-packages.nix - ../../modules/system.nix - ../../modules/user_group.nix + ../../modules/nixos/fhs-fonts.nix + # ../../modules/nixos/hyprland.nix + ../../modules/nixos/i3.nix + ../../modules/nixos/gui-apps.nix + ../../modules/nixos/core-desktop.nix + ../../modules/nixos/user_group.nix ../../secrets ]; diff --git a/hosts/nixos-test/default.nix b/hosts/nixos-test/default.nix index 3f2320b6..0cdafa3f 100644 --- a/hosts/nixos-test/default.nix +++ b/hosts/nixos-test/default.nix @@ -13,12 +13,12 @@ # Include the results of the hardware scan. ./hardware-configuration.nix - ../../modules/fhs-fonts.nix - ../../modules/hyprland.nix - #../../modules/i3.nix - ../../modules/nur-packages.nix - ../../modules/system.nix - ../../modules/user_group.nix + ../../modules/nixos/fhs-fonts.nix + ../../modules/nixos/hyprland.nix + # ../../modules/nixos/i3.nix + ../../modules/nixos/gui-apps.nix + ../../modules/moxps/core-desktop.nix + ../../modules/nixos/user_group.nix ../../secrets ]; diff --git a/modules/darwin/common.nix b/modules/darwin/core.nix similarity index 71% rename from modules/darwin/common.nix rename to modules/darwin/core.nix index c5669979..83cc2e43 100644 --- a/modules/darwin/common.nix +++ b/modules/darwin/core.nix @@ -1,5 +1,27 @@ { pkgs, lib, ... }: { + # # enable flakes globally + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Auto upgrade nix package and the daemon service. + services.nix-daemon.enable = true; + # Use this instead of services.nix-daemon.enable if you + # don't wan't the daemon service to be managed for you. + # nix.useDaemon = true; + + nix.package = pkgs.nix; + + programs.nix-index.enable = true; + + # Add ability to used TouchID for sudo authentication + security.pam.enableSudoTouchIdAuth = true; + + # Keyboard + system.keyboard.enableKeyMapping = true; + system.keyboard.remapCapsLockToEscape = true; + + # Set your time zone. + time.timeZone = "Asia/Shanghai"; # Create /etc/zshrc that loads the nix-darwin environment. programs.zsh.enable = true; @@ -8,9 +30,6 @@ # `home-manager` currently has issues adding them to `~/Applications` # Issue: https://github.com/nix-community/home-manager/issues/1341 environment.systemPackages = with pkgs; [ - alacritty - jq - bat ]; # Fonts diff --git a/modules/system.nix b/modules/nixos/core-desktop.nix similarity index 79% rename from modules/system.nix rename to modules/nixos/core-desktop.nix index 71953f6d..29aac0dd 100644 --- a/modules/system.nix +++ b/modules/nixos/core-desktop.nix @@ -58,10 +58,10 @@ "Iosevka" ];}) - (pkgs.callPackage ../fonts/icomoon-feather-icon-font.nix { }) + (pkgs.callPackage ../../fonts/icomoon-feather-icon-font.nix { }) # arch linux icon, used temporarily in waybar - (pkgs.callPackage ../fonts/archcraft-icon-font.nix { }) + (pkgs.callPackage ../../fonts/archcraft-icon-font.nix { }) ]; @@ -105,76 +105,17 @@ # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ - vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + 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 - # networking tools - ethtool - iperf3 - nmap - socat - ldns # replacement of dig, it provide the command `drill` - - # system tools - sysstat - lm_sensors # for `sensors` command - - # misc - findutils - file - which - tree - gnused - gnutar - gawk - p7zip - xz - zstd - cifs-utils # for mounting windows shares - - (python3.withPackages(ps: with ps; [ - ipython - pandas - requests - pyquery - ])) - - # need to run `conda-install` before using it - # need to run `conda-shell` before using command `conda` - conda - - # video/audio tools - libva-utils - nvtop - vdpauinfo - vulkan-tools - glxinfo - glmark2 - - # minimal screen capture tool, used by i3 blur lock to take a screenshot - # print screen key is also bound to this tool in i3 config - scrot - - neofetch - xfce.thunar # xfce4's file manager - nnn # terminal file manager - xdg-user-dirs - - # embedded development - minicom - - # remote desktop(rdp connect) - remmina - freerdp # required by remmina - devenv.packages."${pkgs.system}".devenv ]; - # replace default editor with vim - environment.variables.EDITOR = "vim"; + # replace default editor with neovim + environment.variables.EDITOR = "nvim"; # Enable sound with pipewire. sound.enable = true; diff --git a/modules/nixos/core-server.nix b/modules/nixos/core-server.nix new file mode 100644 index 00000000..daad9b58 --- /dev/null +++ b/modules/nixos/core-server.nix @@ -0,0 +1,96 @@ +{ config, pkgs, devenv, ... }: + +{ + # enable flakes globally + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Set your time zone. + time.timeZone = "Asia/Shanghai"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "zh_CN.UTF-8"; + LC_IDENTIFICATION = "zh_CN.UTF-8"; + LC_MEASUREMENT = "zh_CN.UTF-8"; + LC_MONETARY = "zh_CN.UTF-8"; + LC_NAME = "zh_CN.UTF-8"; + LC_NUMERIC = "zh_CN.UTF-8"; + LC_PAPER = "zh_CN.UTF-8"; + LC_TELEPHONE = "zh_CN.UTF-8"; + LC_TIME = "zh_CN.UTF-8"; + }; + + # all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts + fonts = { + # use fonts specified by user rather than default ones + enableDefaultFonts = false; + fontDir.enable = true; + + fonts = with pkgs; [ + # icon fonts + material-design-icons + font-awesome + + # 思源系列字体是 Adobe 主导的。其中汉字部分被称为「思源黑体」和「思源宋体」,是由 Adobe + Google 共同开发的 + source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro,以及带字重的变体,加上 Source Sans 3 VF + source-han-sans # 思源黑体 + + # nerdfonts + (nerdfonts.override { fonts = [ + "FiraCode" + "JetBrainsMono" + "Iosevka" + ];}) + ]; + + # user defined fonts + # the reason there's Noto Color Emoji everywhere is to override DejaVu's + # B&W emojis that would sometimes show instead of some Color emojis + fontconfig.defaultFonts = { + sansSerif = [ "Noto Sans" "Noto Color Emoji" ]; + monospace = [ "JetBrainsMono Nerd Font" "Noto Color Emoji" ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = false; + + # Enable the OpenSSH daemon. + services.openssh = { + enable = true; + settings = { + X11Forwarding = true; + PermitRootLogin = "no"; # disable root login + PasswordAuthentication = false; # disable password login + }; + openFirewall = true; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + curl + aria2 + git # used by nix flakes + git-lfs # used by huggingface models + ]; + + # replace default editor with neovim + environment.variables.EDITOR = "nvim"; + + # for power management + services.power-profiles-daemon = { + enable = true; + }; + services.upower.enable = true; +} \ No newline at end of file diff --git a/modules/fhs-fonts.nix b/modules/nixos/fhs-fonts.nix similarity index 84% rename from modules/fhs-fonts.nix rename to modules/nixos/fhs-fonts.nix index f7fcb3e5..bb0937b2 100644 --- a/modules/fhs-fonts.nix +++ b/modules/nixos/fhs-fonts.nix @@ -1,7 +1,8 @@ # copy from https://github.com/NixOS/nixpkgs/issues/119433#issuecomment-1326957279 # mainly for flatpak -# bindfs resolves all symlink, allowing all fonts to be accessed at /usr/share/fonts, without letting /nix into the sandbox. - +# bindfs resolves all symlink, +# allowing all fonts to be accessed at `/usr/share/fonts` +# without letting /nix into the sandbox. { config, pkgs, ... }: { diff --git a/modules/nur-packages.nix b/modules/nixos/gui-apps.nix similarity index 83% rename from modules/nur-packages.nix rename to modules/nixos/gui-apps.nix index d233f4d7..a01af6dc 100644 --- a/modules/nur-packages.nix +++ b/modules/nixos/gui-apps.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: { + # this params has problem with home-manager, + # so defined as NixOS Module here. nixpkgs.config.permittedInsecurePackages = [ "electron-19.0.7" # required by wechat-uos, and it's already EOL "openssl-1.1.1t" # OpenSSL 1.1 is reaching its end of life on 2023/09/11 diff --git a/modules/hyprland.nix b/modules/nixos/hyprland.nix similarity index 98% rename from modules/hyprland.nix rename to modules/nixos/hyprland.nix index 61e81830..41b6636b 100644 --- a/modules/hyprland.nix +++ b/modules/nixos/hyprland.nix @@ -70,5 +70,7 @@ 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 ]; } diff --git a/modules/i3.nix b/modules/nixos/i3.nix similarity index 92% rename from modules/i3.nix rename to modules/nixos/i3.nix index 90b99814..f75e4217 100644 --- a/modules/i3.nix +++ b/modules/nixos/i3.nix @@ -36,7 +36,10 @@ 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 ]; }; diff --git a/modules/user_group.nix b/modules/nixos/user_group.nix similarity index 100% rename from modules/user_group.nix rename to modules/nixos/user_group.nix diff --git a/scripts/darwin_set_proxy.py b/scripts/darwin_set_proxy.py index fd946126..f8efa698 100644 --- a/scripts/darwin_set_proxy.py +++ b/scripts/darwin_set_proxy.py @@ -26,8 +26,9 @@ os.chmod(NIX_DAEMON_PLIST, 0o444) # reload the plist for cmd in ( - f"launchctl unload {NIX_DAEMON_NAME}", - f"launchctl load {NIX_DAEMON_NAME}", + f"launchctl unload {NIX_DAEMON_PLIST}", + f"launchctl load {NIX_DAEMON_PLIST}", ): - subprocess.run(shlex.split(cmd)) + print(cmd) + subprocess.run(shlex.split(cmd), capture_output=False)