diff --git a/README.md b/README.md index cc987bd8..db369e94 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ This repository is home to the nix code that builds my systems. ## TODO +- fix wayland related problems + - fcitx5 input method - currently not work in vscode, and failed to add flypy input method +- status bar and other hyprland scripts + - some of them do not work - [sops-nix](https://github.com/Mic92/sops-nix): secret management - [devShell](https://github.com/numtide/devshell): manage development environments diff --git a/flake.lock b/flake.lock index 189f5679..9eff74b9 100644 --- a/flake.lock +++ b/flake.lock @@ -222,6 +222,22 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1683207485, + "narHash": "sha256-gs+PHt/y/XQB7S8+YyBLAM8LjgYpPZUVFQBwpFSmJro=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cc45a3f8c98e1c33ca996e3504adefbf660a72d1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-wayland": { "inputs": { "flake-compat": "flake-compat", @@ -297,6 +313,7 @@ "hyprland": "hyprland", "nixos-cn": "nixos-cn", "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-wayland": "nixpkgs-wayland" } }, diff --git a/flake.nix b/flake.nix index adfa7d0c..435c8d35 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,9 @@ inputs = { # flake inputs 有很多种引用方式,应用最广泛的是 github 的引用方式 - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # 使用 nixos-unstable 分支 + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # 使用 nixos-unstable 分支 for nix flakes + nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-22.11"; # unstable branch may be broken sometimes, use stable branch when necessary + home-manager.url = "github:nix-community/home-manager"; # follows 是 inputs 中的继承语法 # 这里使 home-manager 的 nixpkgs 这个 inputs 与当前 flake 的 inputs.nixpkgs 保持一致,避免依赖的 nixpkgs 版本不一致导致问题 @@ -43,7 +45,7 @@ # modern window compositor hyprland.url = "github:hyprwm/Hyprland"; # community wayland nixpkgs - nixpkgs-wayland = { url = "github:nix-community/nixpkgs-wayland"; }; + nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland"; # nixos-cn 提供了一些国内常用的程序包,如 qq wechat dingtalk 等 nixos-cn = { @@ -59,6 +61,7 @@ outputs = inputs@{ self, nixpkgs, + nixpkgs-stable, home-manager, nixos-cn, ... @@ -84,7 +87,10 @@ # # nix flake 的 modules 系统可将配置模块化,提升配置的可维护性 # 默认只能传上面这四个参数,如果需要传其他参数,必须使用 specialArgs - specialArgs = {inherit inputs;}; + specialArgs = { + inherit nixos-cn; + inherit nixpkgs-stable; + }; modules = [ ./hosts/nixos-test @@ -114,7 +120,10 @@ msi-rtx4090 = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - specialArgs = {inherit inputs;}; + specialArgs = { + inherit nixos-cn; + inherit nixpkgs-stable; + }; modules = [ ./hosts/msi-rtx4090 @@ -129,13 +138,6 @@ home-manager.extraSpecialArgs = inputs; home-manager.users.ryan = import ./home; } - - # 将 nixos-cn flake 提供的 registry 添加到全局 registry 列表中 - # 可在`nixos-rebuild switch`之后通过`nix registry list`查看 - nixos-cn.nixosModules.nixos-cn-registries - - # 引入nixos-cn flake提供的NixOS模块 - nixos-cn.nixosModules.nixos-cn ]; }; diff --git a/home/fcitx5/README.md b/home/fcitx5/README.md new file mode 100644 index 00000000..a4f96010 --- /dev/null +++ b/home/fcitx5/README.md @@ -0,0 +1,4 @@ +# Fcitx5-Rime + Flypy + + + diff --git a/home/fcitx5/default.nix b/home/fcitx5/default.nix index 9da1d3f3..c72a531b 100644 --- a/home/fcitx5/default.nix +++ b/home/fcitx5/default.nix @@ -16,9 +16,12 @@ }; in with pkgs; [ + # for flypy chinese input method fcitx5-rime fcitx5-configtool fcitx5-chinese-addons + fcitx5-mozc # japanese input method + fcitx5-gtk # gtk im module ]; }; } diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index aafe431c..0fc58dd0 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -47,10 +47,9 @@ ncmpcpp # a mpd client with a UI ]; - # if use vscode in wayland, uncomment those line systemd.user.sessionVariables = { - "NIXOS_OZONE_WL" = "1"; # for vscode - "MOZ_ENABLE_WAYLAND" = "1"; + "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 # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/ "LIBVA_DRIVER_NAME" = "nvidia"; diff --git a/home/programs/browsers.nix b/home/programs/browsers.nix index 6166bd2b..23b6cda4 100644 --- a/home/programs/browsers.nix +++ b/home/programs/browsers.nix @@ -1,23 +1,24 @@ { pkgs, + nixpkgs-stable, config, ... }: { - home.packages = with pkgs; [ - # use wayland version of firefox - firefox-wayland - ]; + home.packages = + let + pkgs-stable = import nixpkgs-stable { + system = pkgs.system; + config.allowUnfree = true; + }; + in + with pkgs-stable; [ + firefox-wayland - programs = - let commandLineArgs = [ "--enable-wayland-ime" "--ozone-platform=wayland" ]; - in { - chromium = { - enable = true; - inherit commandLineArgs; - }; - google-chrome = { - enable = true; - inherit commandLineArgs; - }; - }; + # chrome wayland support was broken on nixos-unstable branch, so fallback to stable branch for now + # https://github.com/swaywm/sway/issues/7562 + google-chrome + ]; + + # programs = { + # }; } diff --git a/home/programs/common.nix b/home/programs/common.nix index b50fd4d1..b22f5daf 100644 --- a/home/programs/common.nix +++ b/home/programs/common.nix @@ -9,7 +9,6 @@ ripgrep yq-go # https://github.com/mikefarah/yq htop - nvtop ## networking tools wireshark diff --git a/home/programs/default.nix b/home/programs/default.nix index 5ad0c01e..a1684e21 100644 --- a/home/programs/default.nix +++ b/home/programs/default.nix @@ -8,6 +8,7 @@ ./common.nix ./git.nix ./media.nix + ./nixos-cn.nix ./vscode.nix ./xdg.nix ]; diff --git a/home/programs/nixos-cn.nix b/home/programs/nixos-cn.nix index 185814cf..f42ca70f 100644 --- a/home/programs/nixos-cn.nix +++ b/home/programs/nixos-cn.nix @@ -5,24 +5,19 @@ ... }: { + imports = [ + # 将 nixos-cn flake 提供的 registry 添加到全局 registry 列表中 + # 可在`nixos-rebuild switch`之后通过`nix registry list`查看 + nixos-cn.nixosModules.nixos-cn-registries - home.packages = with nixos-cn; [ - qq - wechat-uos - netease-cloud-music + # 引入nixos-cn flake提供的NixOS模块 + nixos-cn.nixosModules.nixos-cn ]; - programs = { - mpv = { - enable = true; - defaultProfiles = ["gpu-hq"]; - scripts = [pkgs.mpvScripts.mpris]; - }; - - obs-studio.enable = true; - }; - - services = { - playerctld.enable = true; - }; + # # 使用 nixos-cn flake 提供的包 + home.packages = with nixos-cn.legacyPackages.${pkgs.system}; [ + # qq + # wechat-uos # TODO failed to install + netease-cloud-music # TODO chinese font missing + ]; } \ No newline at end of file diff --git a/home/programs/xdg.nix b/home/programs/xdg.nix index e9962228..c8a5b6f8 100644 --- a/home/programs/xdg.nix +++ b/home/programs/xdg.nix @@ -21,8 +21,8 @@ "video/*" = ["mpv.dekstop"]; "image/*" = ["imv.desktop"]; "application/json" = browser; - "application/pdf" = ["org.pwmt.zathura.desktop.desktop"]; - "x-scheme-handler/discord" = ["discordcanary.desktop"]; + "application/pdf" = ["org.pwmt.zathura.desktop.desktop"]; # TODO: pdf viewer + "x-scheme-handler/discord" = ["discord.desktop"]; "x-scheme-handler/spotify" = ["spotify.desktop"]; "x-scheme-handler/tg" = ["telegramdesktop.desktop"]; }; @@ -43,6 +43,5 @@ in { XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots"; }; }; - }; } diff --git a/hosts/msi-rtx4090/default.nix b/hosts/msi-rtx4090/default.nix index a528985e..25164021 100644 --- a/hosts/msi-rtx4090/default.nix +++ b/hosts/msi-rtx4090/default.nix @@ -9,7 +9,6 @@ [ ../../modules/system.nix ../../modules/hyprland.nix - ../../modules/nixpkgs-wayland.nix # Include the results of the hardware scan. ./hardware-configuration.nix @@ -51,14 +50,22 @@ # for Nvidia GPU - services.xserver.videoDrivers = ["nvidia"]; - hardware.opengl.enable = true; + + services.xserver.videoDrivers = ["nvidia"]; # will install nvidia-vaapi-driver by default hardware.nvidia = { package = config.boot.kernelPackages.nvidiaPackages.stable; modesetting.enable = true; + powerManagement.enable = true; + }; + + hardware.opengl = { + enable = true; + # if hardware.opengl.driSupport is enabled, mesa is installed and provides Vulkan for supported hardware. + driSupport = true; + # needed by nvidia-docker + driSupport32Bit = true; }; - hardware.opengl.driSupport32Bit = true; virtualisation.docker = { enable = true; enableNvidia = true; diff --git a/hosts/nixos-test/default.nix b/hosts/nixos-test/default.nix index b4876a8f..059f6d98 100644 --- a/hosts/nixos-test/default.nix +++ b/hosts/nixos-test/default.nix @@ -9,7 +9,6 @@ [ ../../modules/system.nix ../../modules/hyprland.nix - ../../modules/nixpkgs-wayland.nix # Include the results of the hardware scan. ./hardware-configuration.nix diff --git a/modules/hyprland.nix b/modules/hyprland.nix index 858796c7..f4c2913c 100644 --- a/modules/hyprland.nix +++ b/modules/hyprland.nix @@ -15,9 +15,12 @@ }; displayManager = { - defaultSession = "hyprland"; - lightdm.enable = false; - gdm.enable = true; + defaultSession = "hyprland"; + lightdm.enable = false; + gdm = { + enable = true; + wayland = true; + }; }; }; @@ -42,4 +45,18 @@ services.tumbler.enable = true; # Thumbnail support for images + xdg.portal = { + enable = true; + wlr.enable = true; + xdgOpenUsePortal = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr # for wlroots based compositors + # xdg-desktop-portal-kde # for kde + # xdg-desktop-portal-gtk # for gtk + ]; + }; + + # for power management + services.upower.enable = true; + } diff --git a/modules/i3.nix b/modules/i3.nix index 20a6df3d..2bab3c2d 100644 --- a/modules/i3.nix +++ b/modules/i3.nix @@ -13,9 +13,9 @@ }; displayManager = { - defaultSession = "none+i3"; - lightdm.enable = false; - gdm.enable = true; + defaultSession = "none+i3"; + lightdm.enable = false; + gdm.enable = true; }; windowManager.i3 = { diff --git a/modules/nixpkgs-wayland.nix b/modules/nixpkgs-wayland.nix deleted file mode 100644 index 2647e740..00000000 --- a/modules/nixpkgs-wayland.nix +++ /dev/null @@ -1,2 +0,0 @@ -{pkgs, config, ... }: { -} \ No newline at end of file diff --git a/modules/system.nix b/modules/system.nix index e76eb4b2..a8c5fe31 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -114,6 +114,11 @@ # 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