From a1b5572eea537f3a9f16611eb930c04ad0267a44 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Fri, 22 Dec 2023 12:07:37 +0800 Subject: [PATCH] refactor: via statix --- home/base/desktop/helix.nix | 8 +-- home/base/server/btop.nix | 2 +- home/base/server/zellij/default.nix | 2 +- home/linux/desktop/media.nix | 2 +- home/linux/desktop/wallpaper.nix | 2 +- home/linux/fcitx5/default.nix | 19 +++---- home/linux/hyprland/default.nix | 50 ++++++++++--------- .../ai/nixos-installer/configuration.nix | 13 +++-- hosts/idols/ai/nixos-installer/system.nix | 24 +++++---- systems/colmena.nix | 2 +- systems/darwin.nix | 2 +- systems/default.nix | 4 +- systems/nixos.nix | 2 +- 13 files changed, 70 insertions(+), 62 deletions(-) diff --git a/home/base/desktop/helix.nix b/home/base/desktop/helix.nix index 37bbdece..bccfeec9 100644 --- a/home/base/desktop/helix.nix +++ b/home/base/desktop/helix.nix @@ -24,9 +24,11 @@ indent-guides.render = true; }; keys.normal = { - space.space = "file_picker"; - space.w = ":w"; - space.q = ":q"; + space = { + space = "file_picker"; + w = ":w"; + q = ":q"; + }; esc = ["collapse_selection" "keep_primary_selection"]; }; }; diff --git a/home/base/server/btop.nix b/home/base/server/btop.nix index df8fde6d..5f94613f 100644 --- a/home/base/server/btop.nix +++ b/home/base/server/btop.nix @@ -4,7 +4,7 @@ ... }: { # https://github.com/catppuccin/btop/blob/main/themes/catppuccin_mocha.theme - home.file.".config/btop/themes".source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-btop}/themes"; + xdg.configFile."btop/themes".source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-btop}/themes"; # replacement of htop/nmon programs.btop = { diff --git a/home/base/server/zellij/default.nix b/home/base/server/zellij/default.nix index ff57a106..e62aaa80 100644 --- a/home/base/server/zellij/default.nix +++ b/home/base/server/zellij/default.nix @@ -3,5 +3,5 @@ _: { enable = true; }; - home.file.".config/zellij/config.kdl".source = ./config.kdl; + xdg.configFile."zellij/config.kdl".source = ./config.kdl; } diff --git a/home/linux/desktop/media.nix b/home/linux/desktop/media.nix index 87bdffc1..b6573199 100644 --- a/home/linux/desktop/media.nix +++ b/home/linux/desktop/media.nix @@ -24,7 +24,7 @@ ]; # https://github.com/catppuccin/cava - home.file.".config/cava/config".text = + xdg.configFile."cava/config".text = '' # custom cava config '' diff --git a/home/linux/desktop/wallpaper.nix b/home/linux/desktop/wallpaper.nix index 26deb941..523e6578 100644 --- a/home/linux/desktop/wallpaper.nix +++ b/home/linux/desktop/wallpaper.nix @@ -1,6 +1,6 @@ {wallpapers, ...}: { # https://github.com/ryan4yin/wallpapers - home.file.".config/wallpapers".source = wallpapers; + xdg.configFile."wallpapers".source = wallpapers; home.file.".local/bin/wallpaper_random" = { source = "${wallpapers}/wallpaper_random.py"; executable = true; diff --git a/home/linux/fcitx5/default.nix b/home/linux/fcitx5/default.nix index 37622191..6f744e5d 100644 --- a/home/linux/fcitx5/default.nix +++ b/home/linux/fcitx5/default.nix @@ -3,16 +3,17 @@ nur-ryan4yin, ... }: { - home.file.".config/fcitx5/profile" = { - source = ./profile; - # every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile, - # so we need to force replace it in every rebuild to avoid file conflict. - force = true; - }; - - # color schema home.file.".local/share/fcitx5/themes".source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-fcitx5}/src"; - home.file.".config/fcitx5/conf/classicui.conf".source = ./classicui.conf; + + xdg.configFile = { + "fcitx5/profile" = { + source = ./profile; + # every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile, + # so we need to force replace it in every rebuild to avoid file conflict. + force = true; + }; + "fcitx5/conf/classicui.conf".source = ./classicui.conf; + }; i18n.inputMethod = { enabled = "fcitx5"; diff --git a/home/linux/hyprland/default.nix b/home/linux/hyprland/default.nix index 07fd2e46..2d0e5efe 100644 --- a/home/linux/hyprland/default.nix +++ b/home/linux/hyprland/default.nix @@ -23,31 +23,33 @@ }; # hyprland configs, based on https://github.com/notwidow/hyprland - xdg.configFile."hypr/mako" = { - source = ./hypr-conf/mako; - recursive = true; - }; - xdg.configFile."hypr/scripts" = { - source = ./hypr-conf/scripts; - recursive = true; - }; - xdg.configFile."hypr/waybar" = { - source = ./hypr-conf/waybar; - recursive = true; - }; - xdg.configFile."hypr/wlogout" = { - source = ./hypr-conf/wlogout; - recursive = true; - }; - xdg.configFile."hypr/themes" = { - source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-hyprland}/themes"; - recursive = true; - }; + xdg.configFile = { + "hypr/mako" = { + source = ./hypr-conf/mako; + recursive = true; + }; + "hypr/scripts" = { + source = ./hypr-conf/scripts; + recursive = true; + }; + "hypr/waybar" = { + source = ./hypr-conf/waybar; + recursive = true; + }; + "hypr/wlogout" = { + source = ./hypr-conf/wlogout; + recursive = true; + }; + "hypr/themes" = { + source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-hyprland}/themes"; + recursive = true; + }; - # music player - mpd - xdg.configFile."mpd" = { - source = ./mpd; - recursive = true; + # music player - mpd + "mpd" = { + source = ./mpd; + recursive = true; + }; }; # allow fontconfig to discover fonts and configurations installed through home.packages diff --git a/hosts/idols/ai/nixos-installer/configuration.nix b/hosts/idols/ai/nixos-installer/configuration.nix index f6a6122d..3b9db392 100644 --- a/hosts/idols/ai/nixos-installer/configuration.nix +++ b/hosts/idols/ai/nixos-installer/configuration.nix @@ -1,9 +1,8 @@ -{...}: { - networking.hostName = "ai"; - - # Enable networking - networking.networkmanager.enable = true; - networking.defaultGateway = "192.168.5.201"; - +_: { + networking = { + hostName = "ai"; + defaultGateway = "192.168.5.201"; + networkmanager.enable = true; + }; system.stateVersion = "23.11"; } diff --git a/hosts/idols/ai/nixos-installer/system.nix b/hosts/idols/ai/nixos-installer/system.nix index fca0ecd0..8f39eee7 100644 --- a/hosts/idols/ai/nixos-installer/system.nix +++ b/hosts/idols/ai/nixos-installer/system.nix @@ -36,17 +36,21 @@ }; # Don't allow mutation of users outside the config. - users.mutableUsers = false; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.ryan = { - # generated by `mkpasswd -m scrypt` - # we have to use initialHashedPassword here, if your'are using tmpfs for / - initialHashedPassword = "$7$CU..../....Sdl/JRH..9eIvZ6mE/52r.$xeR6lyvTcVVKt28Owcoc/vPOOECcYSiq1xjw/QCz2t0"; - isNormalUser = true; - description = "ryan"; - extraGroups = ["ryan" "networkmanager" "wheel"]; + users = { + mutableUsers = false; + # Define a user account. Don't forget to set a password with ‘passwd’. + users = { + ryan = { + # generated by `mkpasswd -m scrypt` + # we have to use initialHashedPassword here, if your'are using tmpfs for / + initialHashedPassword = "$7$CU..../....Sdl/JRH..9eIvZ6mE/52r.$xeR6lyvTcVVKt28Owcoc/vPOOECcYSiq1xjw/QCz2t0"; + isNormalUser = true; + description = "ryan"; + extraGroups = ["ryan" "networkmanager" "wheel"]; + }; + root.initialHashedPassword = "$7$CU..../....X6uvZYnFD.i1CqqFFNl4./$4vgqzIPyw5XBr0aCDFbY/UIRRJr7h5SMGoQ/ZvX3FP2"; + }; }; - users.users.root.initialHashedPassword = "$7$CU..../....X6uvZYnFD.i1CqqFFNl4./$4vgqzIPyw5XBr0aCDFbY/UIRRJr7h5SMGoQ/ZvX3FP2"; # make ryan a trusted user so he can set custom nix substituters url(cache mirror) to speed up nixos-rebuild. nix.settings.trusted-users = ["ryan"]; diff --git a/systems/colmena.nix b/systems/colmena.nix index e2ef2f84..242127ed 100644 --- a/systems/colmena.nix +++ b/systems/colmena.nix @@ -1,7 +1,7 @@ args: with args; with allSystemAttrs; let - lib = nixpkgs.lib; + inherit (nixpkgs) lib; colmenaSystem = import ../lib/colmenaSystem.nix; # x86_64 related x64_base_args = { diff --git a/systems/darwin.nix b/systems/darwin.nix index 48e726e7..f497810c 100644 --- a/systems/darwin.nix +++ b/systems/darwin.nix @@ -1,7 +1,7 @@ args: with args; with allSystemAttrs; let - lib = nixpkgs.lib; + inherit (nixpkgs) lib; macosSystem = import ../lib/macosSystem.nix; base_args = { inherit nix-darwin home-manager; diff --git a/systems/default.nix b/systems/default.nix index cb995a9e..2c6967a1 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -3,7 +3,7 @@ inputs, constants, }: let - lib = inputs.nixpkgs.lib; + inherit (inputs.nixpkgs) lib; vars = import ./vars.nix; specialArgsForSystem = system: @@ -20,7 +20,7 @@ allSystemSpecialArgs = lib.attrsets.mapAttrs - (name: value: specialArgsForSystem value) + (name: specialArgsForSystem) constants.allSystemAttrs; args = lib.attrsets.mergeAttrsList [ diff --git a/systems/nixos.nix b/systems/nixos.nix index 499853da..026c3beb 100644 --- a/systems/nixos.nix +++ b/systems/nixos.nix @@ -1,7 +1,7 @@ args: with args; with allSystemAttrs; let - lib = nixpkgs.lib; + inherit (nixpkgs) lib; nixosSystem = import ../lib/nixosSystem.nix; base_args = {