From 902c0794139ff02c13e93ecb2a19acfe4b3c5a0d Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 14 Oct 2023 13:53:54 +0800 Subject: [PATCH 1/7] flake: import flakes in {machine,user}-specific configs --- flake.nix | 22 ++-------- .../machine-1/default.nix | 7 +++- .../machine-1/partition.nix | 41 ------------------- users/guanranwang/darwin.nix | 6 ++- users/guanranwang/nixos.nix | 21 ++++++---- 5 files changed, 26 insertions(+), 71 deletions(-) delete mode 100644 machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix diff --git a/flake.nix b/flake.nix index 6c7d641..e4738b4 100755 --- a/flake.nix +++ b/flake.nix @@ -69,7 +69,7 @@ ./machines/darwin/imac-2017 # Hardware-specific configurations # Machine-specific configurations (does such stuff even exist on nix-darwin) ./users/guanranwang/darwin.nix # User-specific configurations - ./flakes/darwin/home-manager.nix # Flakes + # Flakes { networking.hostName = "iMac-macOS"; } ]; @@ -85,21 +85,10 @@ modules = [ ./nixos # Entrypoint ./machines/nixos/81fw-lenovo-legion-y7000 # Hardware-specific configurations - #./machines/nixos/81fw-lenovo-legion-y7000/machine-1 # Machine-specific configurations + ./machines/nixos/81fw-lenovo-legion-y7000/machine-1 # Machine-specific configurations ./users/guanranwang/nixos.nix # User-specific configurations - ./flakes/nixos/berberman.nix # Flakes - ./flakes/nixos/home-manager.nix - ./flakes/nixos/hosts.nix - ./flakes/nixos/lanzaboote.nix - ./flakes/nixos/sops-nix.nix - ./flakes/nixos/impermanence.nix - ./flakes/nixos/disko.nix - { - _module.args.disks = [ "/dev/nvme0n1" ]; # Disko - boot.initrd.systemd.enable = true; # LUKS TPM unlocking - networking.hostName = "81fw-nixos"; - } + { networking.hostName = "81fw-nixos"; } ]; }; @@ -112,11 +101,6 @@ ./machines/nixos/imac-2017 ./machines/nixos/imac-2017/machine-1 ./users/guanranwang/nixos.nix - ./flakes/nixos/berberman.nix - ./flakes/nixos/home-manager.nix - ./flakes/nixos/hosts.nix - ./flakes/nixos/lanzaboote.nix - ./flakes/nixos/sops-nix.nix { networking.hostName = "imac-nixos"; } ]; diff --git a/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix index 1e181dc..758ace3 100644 --- a/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix +++ b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/default.nix @@ -2,6 +2,11 @@ { imports = [ - ./partition.nix + ../../../../flakes/nixos/lanzaboote.nix + ../../../../flakes/nixos/impermanence.nix + ../../../../flakes/nixos/disko.nix ]; + + _module.args.disks = [ "/dev/nvme0n1" ]; # Disko + boot.initrd.systemd.enable = true; # LUKS TPM unlocking } \ No newline at end of file diff --git a/machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix b/machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix deleted file mode 100644 index d6fa846..0000000 --- a/machines/nixos/81fw-lenovo-legion-y7000/machine-1/partition.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ ... }: - -{ - fileSystems = { - "/" = { - device = "/dev/disk/by-uuid/6288ce7a-a153-4302-a4de-5dc71f58da79"; - fsType = "btrfs"; - options = [ "compress=zstd" "subvol=@" ]; # nested subvol - }; - #"/" = { - # device = "none"; - # fsType = "tmpfs"; - # options = [ "size=3G" "mode=755" ]; # mode=755 so only root can write to those files - #}; - - "/home" = { - device = "/dev/disk/by-uuid/6288ce7a-a153-4302-a4de-5dc71f58da79"; - fsType = "btrfs"; - options = [ "compress=zstd" "subvol=@home" ]; - }; - - #"/var/lib/flatpak" = { - # device = "/dev/disk/by-uuid/6288ce7a-a153-4302-a4de-5dc71f58da79"; - # fsType = "btrfs"; - # options = [ "compress=zstd" "subvol=@flatpak" ]; - #}; - - "/btrfs" = { - device = "/dev/disk/by-uuid/6288ce7a-a153-4302-a4de-5dc71f58da79"; - fsType = "btrfs"; - options = [ "compress=zstd" ]; - }; - - "/boot" = { - device = "/dev/disk/by-uuid/C44A-313A"; - fsType = "vfat"; - }; - }; - - swapDevices = [ { device = "/dev/disk/by-uuid/0ba792d3-571d-44bb-8696-82126611784d"; } ]; -} \ No newline at end of file diff --git a/users/guanranwang/darwin.nix b/users/guanranwang/darwin.nix index eeae0c5..05d54c5 100644 --- a/users/guanranwang/darwin.nix +++ b/users/guanranwang/darwin.nix @@ -12,6 +12,10 @@ }; }; - # Flakes. + # Flakes + imports = [ + ../../flakes/darwin/home-manager.nix + ]; + ### home-manager home-manager.users.guanranwang = import ./home-manager/darwin; # NOTE: using flakes } \ No newline at end of file diff --git a/users/guanranwang/nixos.nix b/users/guanranwang/nixos.nix index 50c8e86..eb25e81 100644 --- a/users/guanranwang/nixos.nix +++ b/users/guanranwang/nixos.nix @@ -12,27 +12,30 @@ - # Flakes. + # Flakes + imports = [ + ../../flakes/nixos/home-manager.nix + ../../flakes/nixos/sops-nix.nix + ../../flakes/nixos/hosts.nix + ../../flakes/nixos/berberman.nix + ]; + ### home-manager home-manager.users.guanranwang = import ./home-manager/nixos; - + ### sops-nix sops = { defaultSopsFile = ./secrets/secrets.yaml; age.sshKeyPaths = [ "/nix/persist/system/etc/ssh/ssh_host_ed25519_key" ]; gnupg.sshKeyPaths = []; secrets = { - "clash-config" = { + "hashed-passwd".neededForUsers = true; # Hashed user password + "wireless/home".path = "/var/lib/iwd/wangxiaobo.psk"; # Home wifi password + "clash-config" = { # Clash.Meta configuration #mode = "0444"; # readable owner = config.users.users."clash-meta".name; group = config.users.users."clash-meta".group; restartUnits = [ "clash-meta.service" ]; path = "/etc/clash-meta/config.yaml"; }; - "hashed-passwd".neededForUsers = true; - "wireless/home" = {}; }; }; - - systemd.tmpfiles.rules = [ - "C /var/lib/iwd/wangxiaobo.psk - - - - ${config.sops.secrets."wireless/home".path}" - ]; } \ No newline at end of file From 8d3acf6838a4267be3d75b7d9b31b6edb7362a58 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 14 Oct 2023 15:53:25 +0800 Subject: [PATCH 2/7] repo: git submodules -> flake inputs --- .gitmodules | 29 ------- flake.lock | 37 ++++++++- flake.nix | 19 +++++ nixos/networking/proxy.nix | 14 +++- .../dotfiles/config/alacritty/catppuccin | 1 - .../alacritty/tokyonight/tokyonight_day.yml | 32 -------- .../alacritty/tokyonight/tokyonight_moon.yml | 32 -------- .../alacritty/tokyonight/tokyonight_night.yml | 32 -------- .../alacritty/tokyonight/tokyonight_storm.yml | 32 -------- .../common/dotfiles/config/clash/metacubexd | 1 - .../common/dotfiles/config/kitty/dracula.conf | 66 --------------- .../common/dotfiles/config/kitty/frappe.conf | 80 ------------------- .../common/dotfiles/config/kitty/kitty.conf | 14 ---- .../common/dotfiles/config/kitty/latte.conf | 80 ------------------- .../dotfiles/config/kitty/macchiato.conf | 80 ------------------- .../common/dotfiles/config/kitty/mocha.conf | 80 ------------------- .../dotfiles/config/kitty/tokyonight_day.conf | 50 ------------ .../config/kitty/tokyonight_moon.conf | 50 ------------ .../config/kitty/tokyonight_night.conf | 50 ------------ .../config/kitty/tokyonight_storm.conf | 50 ------------ .../config/zsh/fast-syntax-highlighting | 1 - .../common/dotfiles/config/zsh/fzf-tab | 1 - .../common/dotfiles/config/zsh/powerlevel10k | 1 - .../dotfiles/config/zsh/zsh-autosuggestions | 1 - .../config/zsh/zsh-history-substring-search | 1 - .../config/zsh/zsh-syntax-highlighting | 1 - .../guanranwang/home-manager/common/home.nix | 36 +++++++-- .../home-manager/darwin/dotfiles.nix | 12 --- .../home-manager/nixos/dotfiles.nix | 12 --- 29 files changed, 95 insertions(+), 800 deletions(-) delete mode 100644 .gitmodules delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/alacritty/catppuccin delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_day.yml delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_moon.yml delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_night.yml delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_storm.yml delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/dracula.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/frappe.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/kitty.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/latte.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/macchiato.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/mocha.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_day.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_moon.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_night.conf delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_storm.conf delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/zsh/fast-syntax-highlighting delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/zsh/fzf-tab delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/zsh/powerlevel10k delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-autosuggestions delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-history-substring-search delete mode 160000 users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-syntax-highlighting diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8c715d4..0000000 --- a/.gitmodules +++ /dev/null @@ -1,29 +0,0 @@ -[submodule "users/guanranwang/home-manager/common/dotfiles/config/alacritty/catppuccin"] - path = users/guanranwang/home-manager/common/dotfiles/config/alacritty/catppuccin - url = https://github.com/catppuccin/catppuccin.git -[submodule "users/guanranwang/home-manager/common/dotfiles/config/clash/yacd"] - path = users/guanranwang/home-manager/common/dotfiles/config/clash/yacd - url = https://github.com/haishanh/yacd.git - branch = gh-pages -[submodule "users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd"] - path = users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd - url = https://github.com/MetaCubeX/metacubexd.git - branch = gh-pages -[submodule "users/guanranwang/home-manager/common/dotfiles/config/zsh/fast-syntax-highlighting"] - path = users/guanranwang/home-manager/common/dotfiles/config/zsh/fast-syntax-highlighting - url = https://github.com/zdharma-continuum/fast-syntax-highlighting.git -[submodule "users/guanranwang/home-manager/common/dotfiles/config/zsh/fzf-tab"] - path = users/guanranwang/home-manager/common/dotfiles/config/zsh/fzf-tab - url = https://github.com/Aloxaf/fzf-tab.git -[submodule "users/guanranwang/home-manager/common/dotfiles/config/zsh/powerlevel10k"] - path = users/guanranwang/home-manager/common/dotfiles/config/zsh/powerlevel10k - url = https://github.com/romkatv/powerlevel10k.git -[submodule "users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-autosuggestions"] - path = users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-autosuggestions - url = https://github.com/zsh-users/zsh-autosuggestions.git -[submodule "users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-history-substring-search"] - path = users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-history-substring-search - url = https://github.com/zsh-users/zsh-history-substring-search.git -[submodule "users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-syntax-highlighting"] - path = users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-syntax-highlighting - url = https://github.com/zsh-users/zsh-syntax-highlighting.git diff --git a/flake.lock b/flake.lock index 068baf9..0361ddd 100755 --- a/flake.lock +++ b/flake.lock @@ -315,6 +315,23 @@ "type": "github" } }, + "metacubexd": { + "flake": false, + "locked": { + "lastModified": 1696853927, + "narHash": "sha256-HzbU/TWXfRJytSwIpdJRMdeOUXE1pMxtKtmjhkWTXzk=", + "owner": "MetaCubeX", + "repo": "metacubexd", + "rev": "0ff85616c7b9156e9d5eaee62eb811da5872a71d", + "type": "github" + }, + "original": { + "owner": "MetaCubeX", + "ref": "gh-pages", + "repo": "metacubexd", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -446,9 +463,11 @@ "hyprland": "hyprland", "impermanence": "impermanence", "lanzaboote": "lanzaboote", + "metacubexd": "metacubexd", "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs", - "sops-nix": "sops-nix" + "sops-nix": "sops-nix", + "tokyonight": "tokyonight" } }, "rust-overlay": { @@ -542,6 +561,22 @@ "type": "github" } }, + "tokyonight": { + "flake": false, + "locked": { + "lastModified": 1697104289, + "narHash": "sha256-OJGgBcSTiIEnmGpYlNBmb3CzOmxb8W1Wjl7Fz0FhpbE=", + "owner": "folke", + "repo": "tokyonight.nvim", + "rev": "dce0ab49ae751f4f3617ab42d6f20c72369c7cb1", + "type": "github" + }, + "original": { + "owner": "folke", + "repo": "tokyonight.nvim", + "type": "github" + } + }, "wlroots": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index e4738b4..f17c5dc 100755 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,10 @@ { inputs = { + # Flake inputs + ## Nixpkgs nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + ## Flakes berberman = { url = "github:berberman/flakes"; inputs.nixpkgs.follows = "nixpkgs"; @@ -44,6 +48,19 @@ impermanence = { url = "github:nix-community/impermanence"; }; + + ## Non-Flake + ### Color scheme files + tokyonight = { + # TODO: base16.nix/Stylix when? + url = "github:folke/tokyonight.nvim"; + flake = false; + }; + ### Clash WebUI + metacubexd = { + url = "github:MetaCubeX/metacubexd/gh-pages"; + flake = false; + }; }; outputs = { self, @@ -57,6 +74,8 @@ sops-nix, disko, impermanence, + tokyonight, + metacubexd, ... } @ inputs: { # nix-darwin (macOS) diff --git a/nixos/networking/proxy.nix b/nixos/networking/proxy.nix index 23bbc42..fd06445 100644 --- a/nixos/networking/proxy.nix +++ b/nixos/networking/proxy.nix @@ -1,4 +1,4 @@ -{ pkgs, config, ... }: +{ pkgs, config, inputs, ... }: { networking.proxy.default = "http://127.0.0.1:7890/"; @@ -27,5 +27,15 @@ }; }; - environment.etc."clash-meta/metacubexd".source = ../../users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd; + ### Local Clash WebUI + # You can also use the following website, just in case: + # - metacubexd: + # - GH Pages Custom Domain: http://d.metacubex.one + # - GH Pages: https://metacubex.github.io/metacubexd + # - Cloudflare Pages: https://metacubexd.pages.dev + # - yacd (Yet Another Clash Dashboard): + # - https://yacd.haishan.me + # - clash-dashboard (buggy): + # - https://clash.razord.top + environment.etc."clash-meta/metacubexd".source = inputs.metacubexd; } \ No newline at end of file diff --git a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/catppuccin b/users/guanranwang/home-manager/common/dotfiles/config/alacritty/catppuccin deleted file mode 160000 index aa608f1..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/catppuccin +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aa608f17a525eccbf6f60ab29e46839b26c3eb0e diff --git a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_day.yml b/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_day.yml deleted file mode 100644 index 11362fe..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_day.yml +++ /dev/null @@ -1,32 +0,0 @@ -# TokyoNight Alacritty Colors -colors: - # Default colors - primary: - background: '0xe1e2e7' - foreground: '0x3760bf' - - # Normal colors - normal: - black: '0xe9e9ed' - red: '0xf52a65' - green: '0x587539' - yellow: '0x8c6c3e' - blue: '0x2e7de9' - magenta: '0x9854f1' - cyan: '0x007197' - white: '0x6172b0' - - # Bright colors - bright: - black: '0xa1a6c5' - red: '0xf52a65' - green: '0x587539' - yellow: '0x8c6c3e' - blue: '0x2e7de9' - magenta: '0x9854f1' - cyan: '0x007197' - white: '0x3760bf' - - indexed_colors: - - { index: 16, color: '0xb15c00' } - - { index: 17, color: '0xc64343' } \ No newline at end of file diff --git a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_moon.yml b/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_moon.yml deleted file mode 100644 index f144df8..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_moon.yml +++ /dev/null @@ -1,32 +0,0 @@ -# TokyoNight Alacritty Colors -colors: - # Default colors - primary: - background: '0x222436' - foreground: '0xc8d3f5' - - # Normal colors - normal: - black: '0x1b1d2b' - red: '0xff757f' - green: '0xc3e88d' - yellow: '0xffc777' - blue: '0x82aaff' - magenta: '0xc099ff' - cyan: '0x86e1fc' - white: '0x828bb8' - - # Bright colors - bright: - black: '0x444a73' - red: '0xff757f' - green: '0xc3e88d' - yellow: '0xffc777' - blue: '0x82aaff' - magenta: '0xc099ff' - cyan: '0x86e1fc' - white: '0xc8d3f5' - - indexed_colors: - - { index: 16, color: '0xff966c' } - - { index: 17, color: '0xc53b53' } \ No newline at end of file diff --git a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_night.yml b/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_night.yml deleted file mode 100644 index 1d1609f..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_night.yml +++ /dev/null @@ -1,32 +0,0 @@ -# TokyoNight Alacritty Colors -colors: - # Default colors - primary: - background: '0x1a1b26' - foreground: '0xc0caf5' - - # Normal colors - normal: - black: '0x15161e' - red: '0xf7768e' - green: '0x9ece6a' - yellow: '0xe0af68' - blue: '0x7aa2f7' - magenta: '0xbb9af7' - cyan: '0x7dcfff' - white: '0xa9b1d6' - - # Bright colors - bright: - black: '0x414868' - red: '0xf7768e' - green: '0x9ece6a' - yellow: '0xe0af68' - blue: '0x7aa2f7' - magenta: '0xbb9af7' - cyan: '0x7dcfff' - white: '0xc0caf5' - - indexed_colors: - - { index: 16, color: '0xff9e64' } - - { index: 17, color: '0xdb4b4b' } \ No newline at end of file diff --git a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_storm.yml b/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_storm.yml deleted file mode 100644 index 903bf50..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/alacritty/tokyonight/tokyonight_storm.yml +++ /dev/null @@ -1,32 +0,0 @@ -# TokyoNight Alacritty Colors -colors: - # Default colors - primary: - background: '0x24283b' - foreground: '0xc0caf5' - - # Normal colors - normal: - black: '0x1d202f' - red: '0xf7768e' - green: '0x9ece6a' - yellow: '0xe0af68' - blue: '0x7aa2f7' - magenta: '0xbb9af7' - cyan: '0x7dcfff' - white: '0xa9b1d6' - - # Bright colors - bright: - black: '0x414868' - red: '0xf7768e' - green: '0x9ece6a' - yellow: '0xe0af68' - blue: '0x7aa2f7' - magenta: '0xbb9af7' - cyan: '0x7dcfff' - white: '0xc0caf5' - - indexed_colors: - - { index: 16, color: '0xff9e64' } - - { index: 17, color: '0xdb4b4b' } \ No newline at end of file diff --git a/users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd b/users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd deleted file mode 160000 index d1b0fb7..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/clash/metacubexd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d1b0fb780966303aa4c7867c3da830291c62d902 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/dracula.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/dracula.conf deleted file mode 100644 index 8f05c52..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/dracula.conf +++ /dev/null @@ -1,66 +0,0 @@ -# https://draculatheme.com/kitty -# -# Installation instructions: -# -# cp dracula.conf ~/.config/kitty/ -# echo "include dracula.conf" >> ~/.config/kitty/kitty.conf -# -# Then reload kitty for the config to take affect. -# Alternatively copy paste below directly into kitty.conf - -foreground #f8f8f2 -background #282a36 -selection_foreground #ffffff -selection_background #44475a - -url_color #8be9fd - -# black -color0 #21222c -color8 #6272a4 - -# red -color1 #ff5555 -color9 #ff6e6e - -# green -color2 #50fa7b -color10 #69ff94 - -# yellow -color3 #f1fa8c -color11 #ffffa5 - -# blue -color4 #bd93f9 -color12 #d6acff - -# magenta -color5 #ff79c6 -color13 #ff92df - -# cyan -color6 #8be9fd -color14 #a4ffff - -# white -color7 #f8f8f2 -color15 #ffffff - -# Cursor colors -cursor #f8f8f2 -cursor_text_color background - -# Tab bar colors -active_tab_foreground #282a36 -active_tab_background #f8f8f2 -inactive_tab_foreground #282a36 -inactive_tab_background #6272a4 - -# Marks -mark1_foreground #282a36 -mark1_background #ff5555 - -# Splits/Windows -active_border_color #f8f8f2 -inactive_border_color #6272a4 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/frappe.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/frappe.conf deleted file mode 100644 index a5959a9..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/frappe.conf +++ /dev/null @@ -1,80 +0,0 @@ -# vim:ft=kitty - -## name: Catppuccin Kitty Frappe -## author: Catppuccin Org -## license: MIT -## upstream: https://github.com/catppuccin/kitty/blob/main/frappe.conf -## blurb: Soothing pastel theme for the high-spirited! - - - -# The basic colors -foreground #C6D0F5 -background #303446 -selection_foreground #303446 -selection_background #F2D5CF - -# Cursor colors -cursor #F2D5CF -cursor_text_color #303446 - -# URL underline color when hovering with mouse -url_color #F2D5CF - -# Kitty window border colors -active_border_color #BABBF1 -inactive_border_color #737994 -bell_border_color #E5C890 - -# OS Window titlebar colors -wayland_titlebar_color system -macos_titlebar_color system - -# Tab bar colors -active_tab_foreground #232634 -active_tab_background #CA9EE6 -inactive_tab_foreground #C6D0F5 -inactive_tab_background #292C3C -tab_bar_background #232634 - -# Colors for marks (marked text in the terminal) -mark1_foreground #303446 -mark1_background #BABBF1 -mark2_foreground #303446 -mark2_background #CA9EE6 -mark3_foreground #303446 -mark3_background #85C1DC - -# The 16 terminal colors - -# black -color0 #51576D -color8 #626880 - -# red -color1 #E78284 -color9 #E78284 - -# green -color2 #A6D189 -color10 #A6D189 - -# yellow -color3 #E5C890 -color11 #E5C890 - -# blue -color4 #8CAAEE -color12 #8CAAEE - -# magenta -color5 #F4B8E4 -color13 #F4B8E4 - -# cyan -color6 #81C8BE -color14 #81C8BE - -# white -color7 #B5BFE2 -color15 #A5ADCE diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/kitty.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/kitty.conf deleted file mode 100644 index ace157f..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/kitty.conf +++ /dev/null @@ -1,14 +0,0 @@ -# -# Kitty config -# ~/.config/kitty/kitty.conf -# - -include tokyonight_night.conf -#font_family JetBrainsMono Nerd Font -font_family monospace -font_size 12 -confirm_os_window_close 0 -window_padding_width 12 -adjust_line_height 0 -#background_opacity 0.9 -#shell fish diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/latte.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/latte.conf deleted file mode 100644 index 2e34c7a..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/latte.conf +++ /dev/null @@ -1,80 +0,0 @@ -# vim:ft=kitty - -## name: Catppuccin Kitty Latte -## author: Catppuccin Org -## license: MIT -## upstream: https://github.com/catppuccin/kitty/blob/main/latte.conf -## blurb: Soothing pastel theme for the high-spirited! - - - -# The basic colors -foreground #4C4F69 -background #EFF1F5 -selection_foreground #EFF1F5 -selection_background #DC8A78 - -# Cursor colors -cursor #DC8A78 -cursor_text_color #EFF1F5 - -# URL underline color when hovering with mouse -url_color #DC8A78 - -# Kitty window border colors -active_border_color #7287FD -inactive_border_color #9CA0B0 -bell_border_color #DF8E1D - -# OS Window titlebar colors -wayland_titlebar_color system -macos_titlebar_color system - -# Tab bar colors -active_tab_foreground #EFF1F5 -active_tab_background #8839EF -inactive_tab_foreground #4C4F69 -inactive_tab_background #9CA0B0 -tab_bar_background #BCC0CC - -# Colors for marks (marked text in the terminal) -mark1_foreground #EFF1F5 -mark1_background #7287fD -mark2_foreground #EFF1F5 -mark2_background #8839EF -mark3_foreground #EFF1F5 -mark3_background #209FB5 - -# The 16 terminal colors - -# black -color0 #5C5F77 -color8 #6C6F85 - -# red -color1 #D20F39 -color9 #D20F39 - -# green -color2 #40A02B -color10 #40A02B - -# yellow -color3 #DF8E1D -color11 #DF8E1D - -# blue -color4 #1E66F5 -color12 #1E66F5 - -# magenta -color5 #EA76CB -color13 #EA76CB - -# cyan -color6 #179299 -color14 #179299 - -# white -color7 #ACB0BE -color15 #BCC0CC diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/macchiato.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/macchiato.conf deleted file mode 100644 index 4a95930..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/macchiato.conf +++ /dev/null @@ -1,80 +0,0 @@ -# vim:ft=kitty - -## name: Catppuccin Kitty Macchiato -## author: Catppuccin Org -## license: MIT -## upstream: https://github.com/catppuccin/kitty/blob/main/macchiato.conf -## blurb: Soothing pastel theme for the high-spirited! - - - -# The basic colors -foreground #CAD3F5 -background #24273A -selection_foreground #24273A -selection_background #F4DBD6 - -# Cursor colors -cursor #F4DBD6 -cursor_text_color #24273A - -# URL underline color when hovering with mouse -url_color #F4DBD6 - -# Kitty window border colors -active_border_color #B7BDF8 -inactive_border_color #6E738D -bell_border_color #EED49F - -# OS Window titlebar colors -wayland_titlebar_color system -macos_titlebar_color system - -# Tab bar colors -active_tab_foreground #181926 -active_tab_background #C6A0F6 -inactive_tab_foreground #CAD3F5 -inactive_tab_background #1E2030 -tab_bar_background #181926 - -# Colors for marks (marked text in the terminal) -mark1_foreground #24273A -mark1_background #B7BDF8 -mark2_foreground #24273A -mark2_background #C6A0F6 -mark3_foreground #24273A -mark3_background #7DC4E4 - -# The 16 terminal colors - -# black -color0 #494D64 -color8 #5B6078 - -# red -color1 #ED8796 -color9 #ED8796 - -# green -color2 #A6DA95 -color10 #A6DA95 - -# yellow -color3 #EED49F -color11 #EED49F - -# blue -color4 #8AADF4 -color12 #8AADF4 - -# magenta -color5 #F5BDE6 -color13 #F5BDE6 - -# cyan -color6 #8BD5CA -color14 #8BD5CA - -# white -color7 #B8C0E0 -color15 #A5ADCB diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/mocha.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/mocha.conf deleted file mode 100644 index 3f48800..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/mocha.conf +++ /dev/null @@ -1,80 +0,0 @@ -# vim:ft=kitty - -## name: Catppuccin Kitty Mocha -## author: Catppuccin Org -## license: MIT -## upstream: https://github.com/catppuccin/kitty/blob/main/mocha.conf -## blurb: Soothing pastel theme for the high-spirited! - - - -# The basic colors -foreground #CDD6F4 -background #1E1E2E -selection_foreground #1E1E2E -selection_background #F5E0DC - -# Cursor colors -cursor #F5E0DC -cursor_text_color #1E1E2E - -# URL underline color when hovering with mouse -url_color #F5E0DC - -# Kitty window border colors -active_border_color #B4BEFE -inactive_border_color #6C7086 -bell_border_color #F9E2AF - -# OS Window titlebar colors -wayland_titlebar_color system -macos_titlebar_color system - -# Tab bar colors -active_tab_foreground #11111B -active_tab_background #CBA6F7 -inactive_tab_foreground #CDD6F4 -inactive_tab_background #181825 -tab_bar_background #11111B - -# Colors for marks (marked text in the terminal) -mark1_foreground #1E1E2E -mark1_background #B4BEFE -mark2_foreground #1E1E2E -mark2_background #CBA6F7 -mark3_foreground #1E1E2E -mark3_background #74C7EC - -# The 16 terminal colors - -# black -color0 #45475A -color8 #585B70 - -# red -color1 #F38BA8 -color9 #F38BA8 - -# green -color2 #A6E3A1 -color10 #A6E3A1 - -# yellow -color3 #F9E2AF -color11 #F9E2AF - -# blue -color4 #89B4FA -color12 #89B4FA - -# magenta -color5 #F5C2E7 -color13 #F5C2E7 - -# cyan -color6 #94E2D5 -color14 #94E2D5 - -# white -color7 #BAC2DE -color15 #A6ADC8 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_day.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_day.conf deleted file mode 100644 index 75f6029..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_day.conf +++ /dev/null @@ -1,50 +0,0 @@ -# vim:ft=kitty - -## name: Tokyo Night Day -## license: MIT -## author: Folke Lemaitre -## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_day.conf - - -background #e1e2e7 -foreground #3760bf -selection_background #b6bfe2 -selection_foreground #3760bf -url_color #387068 -cursor #3760bf -cursor_text_color #e1e2e7 - -# Tabs -active_tab_background #2e7de9 -active_tab_foreground #e9e9ec -inactive_tab_background #c4c8da -inactive_tab_foreground #8990b3 -#tab_bar_background #e9e9ed - -# Windows -active_border_color #2e7de9 -inactive_border_color #c4c8da - -# normal -color0 #e9e9ed -color1 #f52a65 -color2 #587539 -color3 #8c6c3e -color4 #2e7de9 -color5 #9854f1 -color6 #007197 -color7 #6172b0 - -# bright -color8 #a1a6c5 -color9 #f52a65 -color10 #587539 -color11 #8c6c3e -color12 #2e7de9 -color13 #9854f1 -color14 #007197 -color15 #3760bf - -# extended colors -color16 #b15c00 -color17 #c64343 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_moon.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_moon.conf deleted file mode 100644 index 014901b..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_moon.conf +++ /dev/null @@ -1,50 +0,0 @@ -# vim:ft=kitty - -## name: Tokyo Night Moon -## license: MIT -## author: Folke Lemaitre -## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_moon.conf - - -background #222436 -foreground #c8d3f5 -selection_background #2d3f76 -selection_foreground #c8d3f5 -url_color #4fd6be -cursor #c8d3f5 -cursor_text_color #222436 - -# Tabs -active_tab_background #82aaff -active_tab_foreground #1e2030 -inactive_tab_background #2f334d -inactive_tab_foreground #545c7e -#tab_bar_background #1b1d2b - -# Windows -active_border_color #82aaff -inactive_border_color #2f334d - -# normal -color0 #1b1d2b -color1 #ff757f -color2 #c3e88d -color3 #ffc777 -color4 #82aaff -color5 #c099ff -color6 #86e1fc -color7 #828bb8 - -# bright -color8 #444a73 -color9 #ff757f -color10 #c3e88d -color11 #ffc777 -color12 #82aaff -color13 #c099ff -color14 #86e1fc -color15 #c8d3f5 - -# extended colors -color16 #ff966c -color17 #c53b53 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_night.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_night.conf deleted file mode 100644 index f2d9728..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_night.conf +++ /dev/null @@ -1,50 +0,0 @@ -# vim:ft=kitty - -## name: Tokyo Night -## license: MIT -## author: Folke Lemaitre -## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_night.conf - - -background #1a1b26 -foreground #c0caf5 -selection_background #283457 -selection_foreground #c0caf5 -url_color #73daca -cursor #c0caf5 -cursor_text_color #1a1b26 - -# Tabs -active_tab_background #7aa2f7 -active_tab_foreground #16161e -inactive_tab_background #292e42 -inactive_tab_foreground #545c7e -#tab_bar_background #15161e - -# Windows -active_border_color #7aa2f7 -inactive_border_color #292e42 - -# normal -color0 #15161e -color1 #f7768e -color2 #9ece6a -color3 #e0af68 -color4 #7aa2f7 -color5 #bb9af7 -color6 #7dcfff -color7 #a9b1d6 - -# bright -color8 #414868 -color9 #f7768e -color10 #9ece6a -color11 #e0af68 -color12 #7aa2f7 -color13 #bb9af7 -color14 #7dcfff -color15 #c0caf5 - -# extended colors -color16 #ff9e64 -color17 #db4b4b diff --git a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_storm.conf b/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_storm.conf deleted file mode 100644 index 20e6fca..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/kitty/tokyonight_storm.conf +++ /dev/null @@ -1,50 +0,0 @@ -# vim:ft=kitty - -## name: Tokyo Night Storm -## license: MIT -## author: Folke Lemaitre -## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_storm.conf - - -background #24283b -foreground #c0caf5 -selection_background #2e3c64 -selection_foreground #c0caf5 -url_color #73daca -cursor #c0caf5 -cursor_text_color #24283b - -# Tabs -active_tab_background #7aa2f7 -active_tab_foreground #1f2335 -inactive_tab_background #292e42 -inactive_tab_foreground #545c7e -#tab_bar_background #1d202f - -# Windows -active_border_color #7aa2f7 -inactive_border_color #292e42 - -# normal -color0 #1d202f -color1 #f7768e -color2 #9ece6a -color3 #e0af68 -color4 #7aa2f7 -color5 #bb9af7 -color6 #7dcfff -color7 #a9b1d6 - -# bright -color8 #414868 -color9 #f7768e -color10 #9ece6a -color11 #e0af68 -color12 #7aa2f7 -color13 #bb9af7 -color14 #7dcfff -color15 #c0caf5 - -# extended colors -color16 #ff9e64 -color17 #db4b4b diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/fast-syntax-highlighting b/users/guanranwang/home-manager/common/dotfiles/config/zsh/fast-syntax-highlighting deleted file mode 160000 index cf318e0..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/fast-syntax-highlighting +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cf318e06a9b7c9f2219d78f41b46fa6e06011fd9 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/fzf-tab b/users/guanranwang/home-manager/common/dotfiles/config/zsh/fzf-tab deleted file mode 160000 index c2b4aa5..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/fzf-tab +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c2b4aa5ad2532cca91f23908ac7f00efb7ff09c9 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/powerlevel10k b/users/guanranwang/home-manager/common/dotfiles/config/zsh/powerlevel10k deleted file mode 160000 index 873c4ff..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/powerlevel10k +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 873c4ff09c559a507d33e528df7e27a8a48705d7 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-autosuggestions b/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-autosuggestions deleted file mode 160000 index c3d4e57..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-autosuggestions +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c3d4e576c9c86eac62884bd47c01f6faed043fc5 diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-history-substring-search b/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-history-substring-search deleted file mode 160000 index 400e58a..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-history-substring-search +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 400e58a87f72ecec14f783fbd29bc6be4ff1641c diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-syntax-highlighting b/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-syntax-highlighting deleted file mode 160000 index 143b25e..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/zsh-syntax-highlighting +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 143b25eb98aa3227af63bd7f04413e1b3e7888ec diff --git a/users/guanranwang/home-manager/common/home.nix b/users/guanranwang/home-manager/common/home.nix index c6f5b28..3d2ef57 100644 --- a/users/guanranwang/home-manager/common/home.nix +++ b/users/guanranwang/home-manager/common/home.nix @@ -1,4 +1,4 @@ -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, inputs, ... }: { home = { @@ -55,15 +55,24 @@ }; zsh = { enable = true; + ### XDG + dotDir = ".config/zsh"; + ### Plugins syntaxHighlighting.enable = true; historySubstringSearch.enable = true; enableAutosuggestions = true; - dotDir = ".config/zsh"; - initExtra = '' - source ${config.xdg.configHome}/zsh/plugins/sudo/sudo.plugin.zsh - source ${config.xdg.configHome}/zsh/plugins/fzf-tab/fzf-tab.plugin.zsh - zstyle ':fzf-tab:*' fzf-command sk - ''; + plugins = [ + { + name = "fzf-tab"; + src = pkgs.zsh-fzf-tab; + } + { + name = "sudo"; + src = ./dotfiles/config/zsh/sudo; + } + ]; + initExtra = "zstyle ':fzf-tab:*' fzf-command sk"; + ### History history = { path = "${config.xdg.configHome}/zsh/.zsh_history"; save = 1000000; @@ -106,7 +115,7 @@ alacritty = { enable = true; settings = { - import = [ "${config.xdg.configHome}/alacritty/tokyonight/tokyonight_night.yml" ]; + import = [ "${inputs.tokyonight}/extras/alacritty/tokyonight_night.yml" ]; cursor.style = "beam"; env.WINIT_X11_SCALE_FACTOR = "1"; window = { @@ -138,6 +147,17 @@ }; }; + kitty = { + enable = true; + settings = { + include = "${inputs.tokyonight}/extras/kitty/tokyonight_night.conf"; + font_size = 12; + confirm_os_window_close = 0; + window_padding_width = 6; + adjust_line_height = 0; + }; + }; + # Editors ### VSCode vscode = { diff --git a/users/guanranwang/home-manager/darwin/dotfiles.nix b/users/guanranwang/home-manager/darwin/dotfiles.nix index 3ef5996..b121188 100644 --- a/users/guanranwang/home-manager/darwin/dotfiles.nix +++ b/users/guanranwang/home-manager/darwin/dotfiles.nix @@ -7,21 +7,9 @@ let in { xdg.configFile = { - "clash-meta" = { - source = "${configPath}/clash"; - recursive = true; - }; - "alacritty" = { - source = "${configPath}/alacritty"; - recursive = true; - }; "fish" = { source = "${configPath}/fish"; recursive = true; }; - "zsh/plugins" = { - source = "${configPath}/zsh"; - recursive = true; - }; }; } \ No newline at end of file diff --git a/users/guanranwang/home-manager/nixos/dotfiles.nix b/users/guanranwang/home-manager/nixos/dotfiles.nix index df36024..cfa4a7a 100644 --- a/users/guanranwang/home-manager/nixos/dotfiles.nix +++ b/users/guanranwang/home-manager/nixos/dotfiles.nix @@ -8,18 +8,10 @@ let in { xdg.configFile = { - "alacritty" = { - source = "${configPath}/alacritty"; - recursive = true; - }; "foot" = { source = "${configPath}/foot"; recursive = true; }; - "kitty" = { - source = "${configPath}/kitty"; - recursive = true; - }; "fish" = { source = "${configPath}/fish"; recursive = true; @@ -40,10 +32,6 @@ in source = "${configPath}/rofi"; recursive = true; }; - "zsh/plugins" = { - source = "${configPath}/zsh"; - recursive = true; - }; "mpv" = { source = "${configPath}/mpv"; recursive = true; From 0a23fd605c92b0f1ba8a4ab8f95f2d6f02ec5098 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 14 Oct 2023 17:39:45 +0800 Subject: [PATCH 3/7] home,zsh,sudo: use fetchers --- .../dotfiles/config/zsh/sudo/sudo.plugin.zsh | 109 ------------------ .../guanranwang/home-manager/common/home.nix | 11 +- 2 files changed, 10 insertions(+), 110 deletions(-) delete mode 100644 users/guanranwang/home-manager/common/dotfiles/config/zsh/sudo/sudo.plugin.zsh diff --git a/users/guanranwang/home-manager/common/dotfiles/config/zsh/sudo/sudo.plugin.zsh b/users/guanranwang/home-manager/common/dotfiles/config/zsh/sudo/sudo.plugin.zsh deleted file mode 100644 index d36426b..0000000 --- a/users/guanranwang/home-manager/common/dotfiles/config/zsh/sudo/sudo.plugin.zsh +++ /dev/null @@ -1,109 +0,0 @@ -# ------------------------------------------------------------------------------ -# Description -# ----------- -# -# sudo or sudo -e (replacement for sudoedit) will be inserted before the command -# -# ------------------------------------------------------------------------------ -# Authors -# ------- -# -# * Dongweiming -# * Subhaditya Nath -# * Marc Cornellà -# * Carlo Sala -# -# ------------------------------------------------------------------------------ - -__sudo-replace-buffer() { - local old=$1 new=$2 space=${2:+ } - - # if the cursor is positioned in the $old part of the text, make - # the substitution and leave the cursor after the $new text - if [[ $CURSOR -le ${#old} ]]; then - BUFFER="${new}${space}${BUFFER#$old }" - CURSOR=${#new} - # otherwise just replace $old with $new in the text before the cursor - else - LBUFFER="${new}${space}${LBUFFER#$old }" - fi -} - -sudo-command-line() { - # If line is empty, get the last run command from history - [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" - - # Save beginning space - local WHITESPACE="" - if [[ ${LBUFFER:0:1} = " " ]]; then - WHITESPACE=" " - LBUFFER="${LBUFFER:1}" - fi - - { - # If $SUDO_EDITOR or $VISUAL are defined, then use that as $EDITOR - # Else use the default $EDITOR - local EDITOR=${SUDO_EDITOR:-${VISUAL:-$EDITOR}} - - # If $EDITOR is not set, just toggle the sudo prefix on and off - if [[ -z "$EDITOR" ]]; then - case "$BUFFER" in - sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "" ;; - sudo\ *) __sudo-replace-buffer "sudo" "" ;; - *) LBUFFER="sudo $LBUFFER" ;; - esac - return - fi - - # Check if the typed command is really an alias to $EDITOR - - # Get the first part of the typed command - local cmd="${${(Az)BUFFER}[1]}" - # Get the first part of the alias of the same name as $cmd, or $cmd if no alias matches - local realcmd="${${(Az)aliases[$cmd]}[1]:-$cmd}" - # Get the first part of the $EDITOR command ($EDITOR may have arguments after it) - local editorcmd="${${(Az)EDITOR}[1]}" - - # Note: ${var:c} makes a $PATH search and expands $var to the full path - # The if condition is met when: - # - $realcmd is '$EDITOR' - # - $realcmd is "cmd" and $EDITOR is "cmd" - # - $realcmd is "cmd" and $EDITOR is "cmd --with --arguments" - # - $realcmd is "/path/to/cmd" and $EDITOR is "cmd" - # - $realcmd is "/path/to/cmd" and $EDITOR is "/path/to/cmd" - # or - # - $realcmd is "cmd" and $EDITOR is "cmd" - # - $realcmd is "cmd" and $EDITOR is "/path/to/cmd" - # or - # - $realcmd is "cmd" and $EDITOR is /alternative/path/to/cmd that appears in $PATH - if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \ - || "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \ - || builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then - __sudo-replace-buffer "$cmd" "sudo -e" - return - fi - - # Check for editor commands in the typed command and replace accordingly - case "$BUFFER" in - $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudo -e" ;; - \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudo -e" ;; - sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "$EDITOR" ;; - sudo\ *) __sudo-replace-buffer "sudo" "" ;; - *) LBUFFER="sudo $LBUFFER" ;; - esac - } always { - # Preserve beginning space - LBUFFER="${WHITESPACE}${LBUFFER}" - - # Redisplay edit buffer (compatibility with zsh-syntax-highlighting) - zle && zle redisplay # only run redisplay if zle is enabled - } -} - -zle -N sudo-command-line - -# Defined shortcut keys: [Esc] [Esc] -bindkey -M emacs '\e\e' sudo-command-line -bindkey -M vicmd '\e\e' sudo-command-line -bindkey -M viins '\e\e' sudo-command-line - diff --git a/users/guanranwang/home-manager/common/home.nix b/users/guanranwang/home-manager/common/home.nix index 3d2ef57..c109a8a 100644 --- a/users/guanranwang/home-manager/common/home.nix +++ b/users/guanranwang/home-manager/common/home.nix @@ -67,8 +67,17 @@ src = pkgs.zsh-fzf-tab; } { + # should I use flake inputs / fetchurl? name = "sudo"; - src = ./dotfiles/config/zsh/sudo; + src = (pkgs.fetchFromGitHub { + owner = "ohmyzsh"; + repo = "ohmyzsh"; + rev = "f8bf8f0029a475831ebfba0799975ede20e08742"; + hash = "sha256-9cJQQycahO+vo/YcAHjF+PVhsWxu7pa4MsK8Dgr69k0="; + sparseCheckout = [ + "plugins/sudo" + ]; + } + "/plugins/sudo"); } ]; initExtra = "zstyle ':fzf-tab:*' fzf-command sk"; From e179a6bc060ce62b4901a164b36ae8631b8ed3da Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 14 Oct 2023 17:40:12 +0800 Subject: [PATCH 4/7] users: remove system-user.nix --- nixos/networking/proxy.nix | 10 +++++++++- nixos/users/default.nix | 1 - nixos/users/system-users.nix | 9 --------- 3 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 nixos/users/system-users.nix diff --git a/nixos/networking/proxy.nix b/nixos/networking/proxy.nix index fd06445..7546a77 100644 --- a/nixos/networking/proxy.nix +++ b/nixos/networking/proxy.nix @@ -1,9 +1,17 @@ { pkgs, config, inputs, ... }: { + ### System proxy settings networking.proxy.default = "http://127.0.0.1:7890/"; - #environment.systemPackages = with pkgs; [ clash-meta ]; + ### User running proxy service + users.groups."clash-meta" = {}; + users.users."clash-meta" = { + isSystemUser = true; + group = config.users.groups."clash-meta".name; + }; + + ### Proxy service systemd.services."clash-meta" = { wantedBy = [ "multi-user.target" ]; after = [ "network-online.target" ]; diff --git a/nixos/users/default.nix b/nixos/users/default.nix index d5afd53..29159c8 100644 --- a/nixos/users/default.nix +++ b/nixos/users/default.nix @@ -3,6 +3,5 @@ { imports = [ ./users.nix - ./system-users.nix ]; } \ No newline at end of file diff --git a/nixos/users/system-users.nix b/nixos/users/system-users.nix deleted file mode 100644 index 87e96d5..0000000 --- a/nixos/users/system-users.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: - -{ - users.users."clash-meta" = { - isSystemUser = true; - group = "clash-meta"; - }; - users.groups.clash-meta = {}; -} \ No newline at end of file From c98e7e62bb5429998798fc9387ace04ba5711ec8 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 14 Oct 2023 17:40:41 +0800 Subject: [PATCH 5/7] home,zsh: fix plugin path --- users/guanranwang/home-manager/common/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/users/guanranwang/home-manager/common/home.nix b/users/guanranwang/home-manager/common/home.nix index c109a8a..cba76b0 100644 --- a/users/guanranwang/home-manager/common/home.nix +++ b/users/guanranwang/home-manager/common/home.nix @@ -64,7 +64,7 @@ plugins = [ { name = "fzf-tab"; - src = pkgs.zsh-fzf-tab; + src = "${pkgs.zsh-fzf-tab}/share/fzf-tab"; } { # should I use flake inputs / fetchurl? From 4b52ac15d210d651be0cdd2aed7de7467a5191e6 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sun, 15 Oct 2023 08:51:56 +0800 Subject: [PATCH 6/7] repo: declutter --- flake.nix | 106 +++++++++--------- flakes/nixos/disko.nix | 2 +- flakes/nixos/lanzaboote.nix | 4 +- .../81fw-lenovo-legion-y7000/default.nix | 1 + .../81fw-lenovo-legion-y7000/hardware.nix | 1 + .../nixos/hardware/misc}/tpm.nix | 0 machines/nixos/imac-2017/hardware.nix | 8 +- nixos/boot/boot.nix | 4 +- nixos/boot/default.nix | 2 + nixos/boot/kernel.nix | 7 +- nixos/boot/plymouth.nix | 5 + nixos/{security => boot}/sysctl.nix | 0 nixos/default.nix | 1 - nixos/i18n/i18n.nix | 6 +- nixos/networking/default.nix | 1 - nixos/networking/dns/default.nix | 2 +- nixos/networking/dns/systemd-resolved.nix | 2 +- nixos/nix/flake.nix | 8 +- nixos/nix/gc.nix | 4 +- nixos/nix/nix.nix | 6 +- nixos/packages/default.nix | 3 +- nixos/packages/graphical/default.nix | 2 + .../graphical/display-server/input.nix | 3 +- .../graphical/display-server/wayland.nix | 6 +- nixos/packages/graphical/fonts.nix | 2 +- nixos/packages/graphical/gnome-keyring.nix | 12 ++ nixos/packages/graphical/graphical.nix | 7 -- .../graphical}/polkit.nix | 1 + nixos/packages/hardware.nix | 3 - nixos/packages/server.nix | 1 - nixos/packages/unfree/unfree.nix | 10 +- nixos/power-management/default.nix | 2 +- nixos/{packages => presets}/core.nix | 21 +++- nixos/presets/desktop.nix | 8 ++ nixos/presets/server.nix | 9 ++ nixos/security/default.nix | 13 --- nixos/security/gnome-keyring.nix | 11 -- nixos/security/machine-id.nix | 6 - nixos/security/security.nix | 15 --- nixos/users/users.nix | 2 +- .../dotfiles/config/hyprland/plugins.conf | 36 +++--- 41 files changed, 174 insertions(+), 169 deletions(-) rename {nixos/security => machines/nixos/hardware/misc}/tpm.nix (100%) create mode 100644 nixos/boot/plymouth.nix rename nixos/{security => boot}/sysctl.nix (100%) create mode 100644 nixos/packages/graphical/gnome-keyring.nix rename nixos/{security => packages/graphical}/polkit.nix (95%) delete mode 100755 nixos/packages/server.nix rename nixos/{packages => presets}/core.nix (68%) create mode 100644 nixos/presets/desktop.nix create mode 100755 nixos/presets/server.nix delete mode 100644 nixos/security/default.nix delete mode 100644 nixos/security/gnome-keyring.nix delete mode 100644 nixos/security/machine-id.nix delete mode 100755 nixos/security/security.nix diff --git a/flake.nix b/flake.nix index f17c5dc..9a4e1fa 100755 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,10 @@ url = "github:berberman/flakes"; inputs.nixpkgs.follows = "nixpkgs"; }; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -21,6 +25,9 @@ url = "github:hyprwm/Hyprland"; inputs.nixpkgs.follows = "nixpkgs"; # MESA/OpenGL HW workaround }; + impermanence = { + url = "github:nix-community/impermanence"; + }; lanzaboote = { url = "github:nix-community/lanzaboote"; inputs.nixpkgs.follows = "nixpkgs"; @@ -29,6 +36,12 @@ url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; }; + sops-nix = { + url = "github:Mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # TODO: Unused #nixos-hardware = { # url = "github:NixOS/nixos-hardware/master"; # #inputs.nixpkgs.follows = "nixpkgs"; @@ -37,17 +50,6 @@ # url = "github:nixpak/nixpak"; # inputs.nixpkgs.follows = "nixpkgs"; #}; - sops-nix = { - url = "github:Mic92/sops-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - disko = { - url = "github:nix-community/disko"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - impermanence = { - url = "github:nix-community/impermanence"; - }; ## Non-Flake ### Color scheme files @@ -66,29 +68,61 @@ outputs = { self, nixpkgs, berberman, + disko, home-manager, hosts, hyprland, lanzaboote, nix-darwin, sops-nix, - disko, impermanence, tokyonight, metacubexd, ... } @ inputs: { - # nix-darwin (macOS) + ### NixOS + nixosConfigurations = { + "81FW-NixOS" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./nixos # Entrypoint + ./machines/nixos/81fw-lenovo-legion-y7000 # Hardware-specific configurations + ./machines/nixos/81fw-lenovo-legion-y7000/machine-1 # Machine-specific configurations + + ./users/guanranwang/nixos.nix # Home Manager entrypoint (user-specific) + + { networking.hostName = "81FW-NixOS"; } # Hostname + ]; + }; + + ## Currently un-used. + "iMac-NixOS" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./nixos + ./machines/nixos/imac-2017 + ./machines/nixos/imac-2017/machine-1 + + ./users/guanranwang/nixos.nix + + { networking.hostName = "iMac-NixOS"; } + ]; + }; + }; + + + ### nix-darwin (macOS) darwinConfigurations = { "iMac-macOS" = nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; specialArgs = { inherit inputs; }; modules = [ - ./darwin # Entrypoint - ./machines/darwin/imac-2017 # Hardware-specific configurations - # Machine-specific configurations (does such stuff even exist on nix-darwin) - ./users/guanranwang/darwin.nix # User-specific configurations - # Flakes + ./darwin + ./machines/darwin/imac-2017 + + ./users/guanranwang/darwin.nix { networking.hostName = "iMac-macOS"; } ]; @@ -96,45 +130,14 @@ }; - # NixOS - nixosConfigurations = { - "81fw-nixos" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ - ./nixos # Entrypoint - ./machines/nixos/81fw-lenovo-legion-y7000 # Hardware-specific configurations - ./machines/nixos/81fw-lenovo-legion-y7000/machine-1 # Machine-specific configurations - ./users/guanranwang/nixos.nix # User-specific configurations - - { networking.hostName = "81fw-nixos"; } - ]; - }; - - ## Currently un-used. - "imac-nixos" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { inherit inputs; }; - modules = [ - ./nixos - ./machines/nixos/imac-2017 - ./machines/nixos/imac-2017/machine-1 - ./users/guanranwang/nixos.nix - - { networking.hostName = "imac-nixos"; } - ]; - }; - }; - - - # Home-Manager + ### Home-Manager + # TODO: Actually figure out how this works homeConfigurations = { "guanranwang@81fw-nixos" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.x86_64-linux; extraSpecialArgs = { inherit inputs; }; modules = [ sops-nix.homeManagerModules.sops - hyprland.homeManagerModules.default { wayland.windowManager.hyprland = { @@ -153,7 +156,6 @@ extraSpecialArgs = { inherit inputs; }; modules = [ sops-nix.homeManagerModules.sops - hyprland.homeManagerModules.default { wayland.windowManager.hyprland = { diff --git a/flakes/nixos/disko.nix b/flakes/nixos/disko.nix index 452c8af..580078d 100644 --- a/flakes/nixos/disko.nix +++ b/flakes/nixos/disko.nix @@ -1,4 +1,4 @@ -{ disks ? [ "/dev/vdb" ], inputs, ... }: +{ inputs, disks ? [ "/dev/vdb" ], ... }: { imports = [ inputs.disko.nixosModules.disko ]; diff --git a/flakes/nixos/lanzaboote.nix b/flakes/nixos/lanzaboote.nix index e6ce0dd..8268684 100644 --- a/flakes/nixos/lanzaboote.nix +++ b/flakes/nixos/lanzaboote.nix @@ -1,10 +1,10 @@ -{ pkgs, lib, inputs, ... }: +{ inputs, pkgs, ... }: { imports = [ inputs.lanzaboote.nixosModules.lanzaboote ]; environment.systemPackages = with pkgs; [ sbctl ]; - boot.loader.systemd-boot.enable = lib.mkForce false; + boot.loader.systemd-boot.enable = false; boot.lanzaboote = { enable = true; pkiBundle = "/etc/secureboot"; diff --git a/machines/nixos/81fw-lenovo-legion-y7000/default.nix b/machines/nixos/81fw-lenovo-legion-y7000/default.nix index 08c9b06..64abac4 100644 --- a/machines/nixos/81fw-lenovo-legion-y7000/default.nix +++ b/machines/nixos/81fw-lenovo-legion-y7000/default.nix @@ -3,5 +3,6 @@ { imports = [ ./hardware.nix + ../../../nixos/presets/desktop.nix ]; } \ No newline at end of file diff --git a/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix b/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix index ba2251e..0246e02 100755 --- a/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix +++ b/machines/nixos/81fw-lenovo-legion-y7000/hardware.nix @@ -5,6 +5,7 @@ ../hardware/misc/audio.nix ../hardware/misc/bluetooth.nix ../hardware/misc/opengl.nix + ../hardware/misc/tpm.nix ../hardware/cpu/intel.nix ../hardware/gpu/intel.nix ../hardware/gpu/nvidia.nix diff --git a/nixos/security/tpm.nix b/machines/nixos/hardware/misc/tpm.nix similarity index 100% rename from nixos/security/tpm.nix rename to machines/nixos/hardware/misc/tpm.nix diff --git a/machines/nixos/imac-2017/hardware.nix b/machines/nixos/imac-2017/hardware.nix index 906a3e3..d32bc96 100755 --- a/machines/nixos/imac-2017/hardware.nix +++ b/machines/nixos/imac-2017/hardware.nix @@ -11,12 +11,12 @@ (modulesPath + "/installer/scan/not-detected.nix") # what is this ]; - # from nixos-hardware - boot.kernelParams = [ "hid_apple.iso_layout=0" ]; - hardware.facetimehd.enable = true; # cam already works before adding this, not sure what is the point - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" ]; + # Options from github:NixOS/nixos-hardware + boot.kernelParams = [ "hid_apple.iso_layout=0" ]; + hardware.facetimehd.enable = true; # TODO: Camera already works before adding this, not sure what is the point... + # 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 # still possible to use this option, but it's recommended to use it in conjunction diff --git a/nixos/boot/boot.nix b/nixos/boot/boot.nix index 0746182..40c31f8 100755 --- a/nixos/boot/boot.nix +++ b/nixos/boot/boot.nix @@ -7,7 +7,9 @@ loader = { efi.canTouchEfiVariables = true; systemd-boot = { - enable = lib.mkDefault true; # use lanzaboote instead for secureboot + enable = lib.mkDefault true; # mkDefault for Lanzaboote + editor = false; # Disabled for security + ### Utilities #netbootxyz.enable = true; #memtest86.enable = true; }; diff --git a/nixos/boot/default.nix b/nixos/boot/default.nix index b926494..d9a3ad0 100644 --- a/nixos/boot/default.nix +++ b/nixos/boot/default.nix @@ -4,5 +4,7 @@ imports = [ ./boot.nix ./kernel.nix + ./plymouth.nix + ./sysctl.nix ]; } \ No newline at end of file diff --git a/nixos/boot/kernel.nix b/nixos/boot/kernel.nix index 0a6c7ef..9eb2f0b 100644 --- a/nixos/boot/kernel.nix +++ b/nixos/boot/kernel.nix @@ -1,10 +1,9 @@ { pkgs, ... }: { - # NOTE: secureboot enabled in flake.nix boot = { - #kernelPackages = pkgs.linuxPackages_latest; # latest kernel - kernelPackages = pkgs.linuxPackages_zen; # zen kernel, often outdated - #kernelPackages = pkgs.linuxKernel.Packages.linux_6_1; + #kernelPackages = pkgs.linuxPackages_latest; # latest linux kernel + kernelPackages = pkgs.linuxPackages_zen; # latest linux-zen kernel + #kernelPackages = pkgs.linuxKernel.Packages.linux_6_1; # linux 6.1 LTS kernel }; } diff --git a/nixos/boot/plymouth.nix b/nixos/boot/plymouth.nix new file mode 100644 index 0000000..eb4d448 --- /dev/null +++ b/nixos/boot/plymouth.nix @@ -0,0 +1,5 @@ +{ lib, ... }: + +{ + boot.plymouth.enable = lib.mkDefault true; # mkDefault for headless devices, check out server.nix +} \ No newline at end of file diff --git a/nixos/security/sysctl.nix b/nixos/boot/sysctl.nix similarity index 100% rename from nixos/security/sysctl.nix rename to nixos/boot/sysctl.nix diff --git a/nixos/default.nix b/nixos/default.nix index 4f2958f..cd33a53 100755 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -8,7 +8,6 @@ ./nix ./packages ./power-management - ./security #./specialisation # dont actually use this ./users ]; diff --git a/nixos/i18n/i18n.nix b/nixos/i18n/i18n.nix index 56cc1ae..4cf4d62 100755 --- a/nixos/i18n/i18n.nix +++ b/nixos/i18n/i18n.nix @@ -1,7 +1,7 @@ { ... }: -# Internationalisation settings -# IME settings are at /etc/nixos/modules/graphical/input.nix +# Internationalisation configurations +# Use Home Manager for IME configurations { i18n = { defaultLocale = "en_US.UTF-8"; @@ -27,4 +27,6 @@ # keyMap = "us"; # useXkbConfig = true; # use xkbOptions in tty. # }; + + services.xserver.layout = "us"; # keymap in x11 } \ No newline at end of file diff --git a/nixos/networking/default.nix b/nixos/networking/default.nix index 8c74baa..cfdd816 100755 --- a/nixos/networking/default.nix +++ b/nixos/networking/default.nix @@ -6,7 +6,6 @@ ./network-manager ./dhcp.nix - ./dns ./firewall.nix ./proxy.nix ./timezone.nix diff --git a/nixos/networking/dns/default.nix b/nixos/networking/dns/default.nix index 4b651c8..06e1f2a 100644 --- a/nixos/networking/dns/default.nix +++ b/nixos/networking/dns/default.nix @@ -3,6 +3,6 @@ { imports = [ ./dns.nix - #./systemd-resolved.nix + #./systemd-resolved.nix # Returns NXDOMAIN in China Mainland, will investegate... ]; } \ No newline at end of file diff --git a/nixos/networking/dns/systemd-resolved.nix b/nixos/networking/dns/systemd-resolved.nix index b8a3d40..f2c4455 100644 --- a/nixos/networking/dns/systemd-resolved.nix +++ b/nixos/networking/dns/systemd-resolved.nix @@ -7,6 +7,6 @@ dnssec = "true"; domains = [ "~." ]; fallbackDns = [ "8.8.8.8#dns.google" "8.8.4.4#dns.google" "2001:4860:4860::8888#dns.google" "2001:4860:4860::8844#dns.google" ]; - #extraConfig = "DNSOverTLS=yes"; # broken as well + extraConfig = "DNSOverTLS=yes"; }; } \ No newline at end of file diff --git a/nixos/nix/flake.nix b/nixos/nix/flake.nix index 3e43041..22841dd 100755 --- a/nixos/nix/flake.nix +++ b/nixos/nix/flake.nix @@ -1,6 +1,10 @@ { ... }: { - nix.settings.experimental-features = [ "nix-command" "flakes" ]; # enable flakes - programs.command-not-found.enable = false; # Unavailable in Flakes build + # Enable Flakes + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Does not work with Flake based configurations + system.copySystemConfiguration = false; + programs.command-not-found.enable = false; } diff --git a/nixos/nix/gc.nix b/nixos/nix/gc.nix index dbdb2ee..a154e75 100755 --- a/nixos/nix/gc.nix +++ b/nixos/nix/gc.nix @@ -2,10 +2,10 @@ { nix = { - # hard linking + ### Auto hard linking settings.auto-optimise-store = true; - # auto delete older NixOS builds + ### Automatically delete older NixOS builds gc = { automatic = true; dates = "weekly"; diff --git a/nixos/nix/nix.nix b/nixos/nix/nix.nix index 5651e21..3f4904d 100755 --- a/nixos/nix/nix.nix +++ b/nixos/nix/nix.nix @@ -1,4 +1,4 @@ -{ ... }: +{ lib, ... }: { nix.settings = { @@ -29,15 +29,13 @@ nixos.enable = false; }; - #nix.useSandbox = false; - system = { # Copy the NixOS configuration file and link it from the resulting system # (/run/current-system/configuration.nix). This is useful in case you # accidentally delete configuration.nix. # Does not work with flake based configurations - #copySystemConfiguration = true; + copySystemConfiguration = lib.mkDefault true; # This value determines the NixOS release from which the default diff --git a/nixos/packages/default.nix b/nixos/packages/default.nix index c081eef..20420dc 100755 --- a/nixos/packages/default.nix +++ b/nixos/packages/default.nix @@ -2,9 +2,8 @@ { imports = [ - ./core.nix ./hardware.nix - ./graphical + ./overlays ./unfree ]; diff --git a/nixos/packages/graphical/default.nix b/nixos/packages/graphical/default.nix index 080a3d6..da18b40 100755 --- a/nixos/packages/graphical/default.nix +++ b/nixos/packages/graphical/default.nix @@ -6,7 +6,9 @@ #./flatpak.nix ./fonts.nix + ./gnome-keyring.nix ./graphical.nix + ./polkit.nix ./xdg.nix ]; } diff --git a/nixos/packages/graphical/display-server/input.nix b/nixos/packages/graphical/display-server/input.nix index 7bc36e9..610829c 100755 --- a/nixos/packages/graphical/display-server/input.nix +++ b/nixos/packages/graphical/display-server/input.nix @@ -2,7 +2,6 @@ { services.xserver = { - layout = "us"; # keymap in x11 libinput = { enable = true; touchpad = { @@ -18,7 +17,7 @@ }; }; - # Removes debounce time + ### Removes debounce time # https://www.reddit.com/r/linux_gaming/comments/ku6gth environment.etc."libinput/local-overrides.quirks".text = '' [Never Debounce] diff --git a/nixos/packages/graphical/display-server/wayland.nix b/nixos/packages/graphical/display-server/wayland.nix index f0ccd72..5730bba 100755 --- a/nixos/packages/graphical/display-server/wayland.nix +++ b/nixos/packages/graphical/display-server/wayland.nix @@ -1,9 +1,9 @@ { ... }: { - programs.xwayland.enable = true; - hardware.nvidia.nvidiaSettings = false; # nvidia settings menu, wont do anything on wayland + programs.xwayland.enable = true; # enable XWayland + hardware.nvidia.nvidiaSettings = false; # NVIDIA settings menu, wont do anything on wayland environment.sessionVariables = { - "NIXOS_OZONE_WL" = "1"; # let electron applications use wayland + "NIXOS_OZONE_WL" = "1"; # let electron applications use wayland }; } \ No newline at end of file diff --git a/nixos/packages/graphical/fonts.nix b/nixos/packages/graphical/fonts.nix index 8fb8ea3..f1b1607 100755 --- a/nixos/packages/graphical/fonts.nix +++ b/nixos/packages/graphical/fonts.nix @@ -29,6 +29,6 @@ monospace = [ "JetBrainsMono Nerd Font" "JetBrains Mono" "FiraCode Nerd Font" "Fira Code" "Noto Sans Mono" ]; }; }; - # fontconfig is too limited here, use `$HOME/.config/fontconfig/fonts.conf` instead + # fontconfig is too limited here, and appling it globally is **bad**, use Home Manager instead }; } diff --git a/nixos/packages/graphical/gnome-keyring.nix b/nixos/packages/graphical/gnome-keyring.nix new file mode 100644 index 0000000..120e936 --- /dev/null +++ b/nixos/packages/graphical/gnome-keyring.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +{ + # gnome keyring + services.gnome.gnome-keyring.enable = true; + programs.seahorse.enable = true; + security.pam.services."gnome-keyring".text = '' + auth optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so + session optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so auto_start + password optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so + ''; +} \ No newline at end of file diff --git a/nixos/packages/graphical/graphical.nix b/nixos/packages/graphical/graphical.nix index 38ce4bd..bffa889 100644 --- a/nixos/packages/graphical/graphical.nix +++ b/nixos/packages/graphical/graphical.nix @@ -1,8 +1,6 @@ { pkgs, ... }: { - boot.plymouth.enable = true; - security.polkit.enable = true; services = { # GNOME applications gvfs.enable = true; # nautilus @@ -25,10 +23,5 @@ end = "${pkgs.libnotify}/bin/notify-send 'GameMode Deactivated' 'GameMode Deactivated. Back to normal mode. ⏹️'"; }; }; - clash-verge = { - #enable = true; - autoStart = true; # not working at all, edit: works on gnome - tunMode = true; - }; }; } \ No newline at end of file diff --git a/nixos/security/polkit.nix b/nixos/packages/graphical/polkit.nix similarity index 95% rename from nixos/security/polkit.nix rename to nixos/packages/graphical/polkit.nix index 6631cdb..a7fbfdb 100644 --- a/nixos/security/polkit.nix +++ b/nixos/packages/graphical/polkit.nix @@ -1,6 +1,7 @@ { pkgs, ... }: { + security.polkit.enable = true; environment.systemPackages = with pkgs; [ polkit_gnome ]; # polkit_gnome autostart for wms diff --git a/nixos/packages/hardware.nix b/nixos/packages/hardware.nix index ff6c9aa..7f0213e 100644 --- a/nixos/packages/hardware.nix +++ b/nixos/packages/hardware.nix @@ -2,10 +2,7 @@ { hardware = { - # Enable redistriutable firmware enableRedistributableFirmware = true; - - # Enable all firmware #enableAllFirmware = true; }; diff --git a/nixos/packages/server.nix b/nixos/packages/server.nix deleted file mode 100755 index c864340..0000000 --- a/nixos/packages/server.nix +++ /dev/null @@ -1 +0,0 @@ -# no i dont actually own a server \ No newline at end of file diff --git a/nixos/packages/unfree/unfree.nix b/nixos/packages/unfree/unfree.nix index 43faed6..7b95f4f 100755 --- a/nixos/packages/unfree/unfree.nix +++ b/nixos/packages/unfree/unfree.nix @@ -10,15 +10,15 @@ "facetimehd-firmware" # ../hardware/hardwares/imac-2017.nix # flatpak-able - "discord" - "google-chrome" - "lunar-client" "osu-lazer-bin" "osu-lazer-bin-2023.1008.0" # what? "spotify" "steam" "steam-original" - "microsoft-edge-stable" - "qq" + #"discord" + #"google-chrome" + #"lunar-client" + #"microsoft-edge-stable" + #"qq" ]; } diff --git a/nixos/power-management/default.nix b/nixos/power-management/default.nix index 84f8975..0a382fd 100644 --- a/nixos/power-management/default.nix +++ b/nixos/power-management/default.nix @@ -4,7 +4,7 @@ imports = [ ./cpu-governor.nix ./system76-scheduler.nix - #./tlp.nix # ] conflicts + #./tlp.nix # ] Conflicts with each other, only choose one ./power-profiles-daemon.nix # ] ]; } \ No newline at end of file diff --git a/nixos/packages/core.nix b/nixos/presets/core.nix similarity index 68% rename from nixos/packages/core.nix rename to nixos/presets/core.nix index a60331f..f4a06cc 100755 --- a/nixos/packages/core.nix +++ b/nixos/presets/core.nix @@ -1,9 +1,17 @@ { config, ... }: +# Imported by default, check out ./desktop.nix or ./server.nix { # Installed packages (System wide) environment = { - defaultPackages = []; + #defaultPackages = []; + }; + + users.mutableUsers = false; + environment.etc.machine-id.text = "b08dfa6083e7567a1921a715000001fb"; # whonix id + security = { + apparmor.enable = true; + sudo.execWheelOnly = true; }; # Programs @@ -25,9 +33,18 @@ NixOS ${config.system.nixos.label} ${config.system.nixos.codeName} (\m) - \l --my-next-gpu-wont-be-nvidia ''; + + openssh = { + enable = true; + settings = { + PermitRootLogin = "no"; + PasswordAuthentication = false; + }; + }; + #cron.enable = true; #dbus.enable = true; - openssh.enable = true; + # BTRFS De-Dupe # bruh how to make it not a background job # i want to run it manually diff --git a/nixos/presets/desktop.nix b/nixos/presets/desktop.nix new file mode 100644 index 0000000..1dbddfc --- /dev/null +++ b/nixos/presets/desktop.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + imports = [ + ./core.nix + ../packages/graphical + ]; +} \ No newline at end of file diff --git a/nixos/presets/server.nix b/nixos/presets/server.nix new file mode 100755 index 0000000..3ff7449 --- /dev/null +++ b/nixos/presets/server.nix @@ -0,0 +1,9 @@ +{ ... }: + +# no i dont actually own a server +{ + imports = [ + ./core.nix + ]; + boot.plymouth.enable = false; +} \ No newline at end of file diff --git a/nixos/security/default.nix b/nixos/security/default.nix deleted file mode 100644 index 27670d2..0000000 --- a/nixos/security/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ ... }: - -{ - imports = [ - ./security.nix - - ./gnome-keyring.nix - ./machine-id.nix - ./polkit.nix - ./sysctl.nix - ./tpm.nix - ]; -} \ No newline at end of file diff --git a/nixos/security/gnome-keyring.nix b/nixos/security/gnome-keyring.nix deleted file mode 100644 index 2b99e61..0000000 --- a/nixos/security/gnome-keyring.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, ... }: - -{ - # gnome keyring - services.gnome.gnome-keyring.enable = true; - security.pam.services."gnome-keyring".text = '' - auth optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so - session optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so auto_start - password optional ${pkgs.gnome.gnome-keyring}/lib/security/pam_gnome_keyring.so - ''; -} \ No newline at end of file diff --git a/nixos/security/machine-id.nix b/nixos/security/machine-id.nix deleted file mode 100644 index 64e49b5..0000000 --- a/nixos/security/machine-id.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ ... }: - -{ - # whonix id - environment.etc.machine-id.text = "b08dfa6083e7567a1921a715000001fb"; -} \ No newline at end of file diff --git a/nixos/security/security.nix b/nixos/security/security.nix deleted file mode 100755 index 682ef10..0000000 --- a/nixos/security/security.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ ... }: - -{ - security = { - apparmor.enable = true; - sudo.execWheelOnly = true; - }; - - boot.loader.systemd-boot.editor = false; - - services.openssh.settings = { - PermitRootLogin = "no"; - PasswordAuthentication = false; - }; -} diff --git a/nixos/users/users.nix b/nixos/users/users.nix index 8e2ffd8..b4ca478 100755 --- a/nixos/users/users.nix +++ b/nixos/users/users.nix @@ -1,5 +1,5 @@ { ... }: { - users.mutableUsers = false; + } \ No newline at end of file diff --git a/users/guanranwang/home-manager/common/dotfiles/config/hyprland/plugins.conf b/users/guanranwang/home-manager/common/dotfiles/config/hyprland/plugins.conf index af0ca5a..d424469 100644 --- a/users/guanranwang/home-manager/common/dotfiles/config/hyprland/plugins.conf +++ b/users/guanranwang/home-manager/common/dotfiles/config/hyprland/plugins.conf @@ -4,9 +4,9 @@ plugin = $HOME/.config/hypr/plugins/hyprfocus.so plugin { csgo-vulkan-fix { - res_w = 1440 - res_h = 1080 - } + res_w = 1440 + res_h = 1080 + } hyprfocus { enabled = false @@ -16,25 +16,25 @@ plugin { bezier = bezIn, 0.5,0.0,1.0,0.5 bezier = bezOut, 0.0,0.5,0.5,1.0 - } + } - flash { - flash_opacity = 0.7 + flash { + flash_opacity = 0.7 - in_bezier = bezIn - in_speed = 0.5 + in_bezier = bezIn + in_speed = 0.5 - out_bezier = bezOut - out_speed = 3 - } + out_bezier = bezOut + out_speed = 3 + } - shrink { - shrink_percentage = 0.99 + shrink { + shrink_percentage = 0.99 - in_bezier = bezIn - in_speed = 0.5 + in_bezier = bezIn + in_speed = 0.5 - out_bezier = bezOut - out_speed = 3 - } + out_bezier = bezOut + out_speed = 3 + } } From 669e34d9b64b6e0da9949728e2520f54f03f5ef8 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sun, 15 Oct 2023 08:52:03 +0800 Subject: [PATCH 7/7] home,i18n: `fcitx5-chinese-addons` -> `fcitx5-rime` --- users/guanranwang/home-manager/nixos/i18n.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/users/guanranwang/home-manager/nixos/i18n.nix b/users/guanranwang/home-manager/nixos/i18n.nix index 29d2c23..32e316c 100644 --- a/users/guanranwang/home-manager/nixos/i18n.nix +++ b/users/guanranwang/home-manager/nixos/i18n.nix @@ -5,9 +5,11 @@ i18n.inputMethod = { enabled = "fcitx5"; fcitx5.addons = with pkgs; [ - fcitx5-chinese-addons - fcitx5-pinyin-moegirl # flakes - fcitx5-pinyin-zhwiki + #fcitx5-chinese-addons + #fcitx5-pinyin-moegirl # Using Berberman's FLake overlay + #fcitx5-pinyin-zhwiki + + fcitx5-rime ]; }; @@ -18,4 +20,11 @@ #QT_IM_MODULE = "fcitx"; #XMODIFIERS = "@im=fcitx"; }; + + xdg.dataFile."fcitx5/rime/terra_pinyin.custom.yaml".text = '' + patch: + switches: + - name: simplification + reset: 1 + ''; } \ No newline at end of file