diff --git a/docs/org/yubikey.org b/docs/org/yubikey.org new file mode 100644 index 0000000..25ed5fc --- /dev/null +++ b/docs/org/yubikey.org @@ -0,0 +1,8 @@ +#+TITLE: yubikey +#+AUTHOR: GuangTao Zhang +#+EMAIL: gtrunsec@hardenedlinux.org +#+DATE: 2023-10-11 Wed 14:37 + + +* discussions +- https://discourse.nixos.org/t/yubikey-udev-rules-and-group-permissions/34034/2 diff --git a/nixos/homeModules/wayland/windowManager/hyprland/config.nix b/nixos/homeModules/wayland/windowManager/hyprland/config.nix index 5b9aeed..ec6e868 100644 --- a/nixos/homeModules/wayland/windowManager/hyprland/config.nix +++ b/nixos/homeModules/wayland/windowManager/hyprland/config.nix @@ -1,46 +1,63 @@ -with lib; { - config = mkIf cfg.enable ( - mkMerge [ - { - home.sessionVariables = { - QT_QPA_PLATFORM = "wayland"; - SDL_VIDEODRIVER = "wayland"; - GDK_BACKEND = "wayland"; - _JAVA_AWT_WM_NONREPARENTING = 1; - MOZ_ENABLE_WAYLAND = "1"; - XDG_CURRENT_DESKTOP = "Hyprland"; - XDG_SESSION_DESKTOP = "Hyprland"; - XDG_SESSION_TYPE = "wayland"; - }; - } - (mkIf cfg.__profiles__.nvidia { - wayland.windowManager.hyprland.enableNvidiaPatches = true; - home.sessionVariables = { - LIBVA_DRIVER_NAME = "nvidia"; - GBM_BACKEND = "nvidia-drm"; - __GLX_VENDOR_LIBRARY_NAME = "nvidia"; - }; - }) - (mkIf cfg.__profiles__.autoLogin.enable { - programs.${cfg.__profiles__.autoLogin.shell} = { - loginExtra = '' - # If running from tty1 start hyprland - if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then - Hyprland - fi - ''; - }; - }) - (mkIf cfg.__profiles__.swww { - home.packages = [ - pkgs.swww - (pkgs.writeShellApplication { - name = "swww-random"; - runtimeInputs = [ pkgs.swww ]; - text = lib.fileContents ./swww_randomize.sh; - }) - ]; - }) - ] - ); +{ + config = + with lib; + mkIf cfg.enable ( + mkMerge [ + { + home.sessionVariables = { + QT_QPA_PLATFORM = "wayland"; + SDL_VIDEODRIVER = "wayland"; + GDK_BACKEND = "wayland"; + _JAVA_AWT_WM_NONREPARENTING = 1; + MOZ_ENABLE_WAYLAND = "1"; + XDG_CURRENT_DESKTOP = "Hyprland"; + XDG_SESSION_DESKTOP = "Hyprland"; + XDG_SESSION_TYPE = "wayland"; + }; + } + (mkIf cfg.__profiles__.nvidia { + wayland.windowManager.hyprland.enableNvidiaPatches = true; + home.sessionVariables = { + LIBVA_DRIVER_NAME = "nvidia"; + GBM_BACKEND = "nvidia-drm"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + }; + }) + (mkIf cfg.__profiles__.autoLogin.enable { + programs.${cfg.__profiles__.autoLogin.shell} = { + loginExtra = '' + # If running from tty1 start hyprland + if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then + Hyprland + fi + ''; + }; + }) + (mkIf cfg.__profiles__.swww.enable { + home.packages = [ + pkgs.swww + (pkgs.writeShellApplication { + name = "swww-random"; + runtimeInputs = [ pkgs.swww ]; + text = + '' + ${l.concatStringsSep "\n" ( + l.mapAttrsToList (n: v: "export ${n}=${''"$''}{${n}:-${toString v}}${''"''}") ( + { + # Edit bellow to control the images transition + SWWW_TRANSITION_FPS = 60; + SWWW_TRANSITION_STEP = 2; + INTERVAL = 3000; + } + // cfg.__profiles__.swww.runtimeEnv + ) + )} + '' + + lib.fileContents ./swww_randomize.sh + ; + }) + ]; + }) + ] + ); } diff --git a/nixos/homeModules/wayland/windowManager/hyprland/default.nix b/nixos/homeModules/wayland/windowManager/hyprland/default.nix index dd29bc0..8538351 100644 --- a/nixos/homeModules/wayland/windowManager/hyprland/default.nix +++ b/nixos/homeModules/wayland/windowManager/hyprland/default.nix @@ -7,7 +7,14 @@ default = { }; type = types.submodule { options = { - swww = mkEnableOption (lib.mdDoc "Whether to enable swww wallpaper profile"); + swww = { + enable = mkEnableOption (lib.mdDoc "Whether to enable swww wallpaper profile"); + runtimeEnv = mkOption { + type = types.attrs; + default = { }; + description = "The runtime environment to use for swww"; + }; + }; nvidia = mkEnableOption (lib.mdDoc "Whether to enable nvidia profile"); autoLogin = { enable = mkEnableOption (lib.mdDoc "Whether to enable auto login"); diff --git a/nixos/homeModules/wayland/windowManager/hyprland/swww_randomize.sh b/nixos/homeModules/wayland/windowManager/hyprland/swww_randomize.sh index 4d81bc4..bf67505 100644 --- a/nixos/homeModules/wayland/windowManager/hyprland/swww_randomize.sh +++ b/nixos/homeModules/wayland/windowManager/hyprland/swww_randomize.sh @@ -13,11 +13,11 @@ if [[ $# -lt 1 ]] || [[ ! -d $1 ]]; then fi # Edit bellow to control the images transition -export SWWW_TRANSITION_FPS=60 -export SWWW_TRANSITION_STEP=2 +# export SWWW_TRANSITION_FPS=60 +# export SWWW_TRANSITION_STEP=2 # This controls (in seconds) when to switch to the next image -INTERVAL=3000 +# INTERVAL=3000 if swww query; then swww kill diff --git a/nixos/homeProfiles/presets/hyprland/default.nix b/nixos/homeProfiles/presets/hyprland/default.nix index 5e61588..794cb5e 100644 --- a/nixos/homeProfiles/presets/hyprland/default.nix +++ b/nixos/homeProfiles/presets/hyprland/default.nix @@ -2,18 +2,21 @@ imports = [ omnibus.homeModules.wayland.windowManager.hyprland ]; wayland.windowManager.hyprland = { enable = true; - systemdIntegration = true; + systemdIntegration = lib.mkDefault true; # extraConfig = builtins.readFile "${src}/hyprland.conf"; xwayland = { enable = true; }; __profiles__ = { - nvidia = false; + nvidia = lib.mkDefault false; autoLogin = { - enable = true; - shell = "zsh"; + enable = lib.mkDefault true; + shell = lib.mkDefault "zsh"; + }; + swww = { + enable = lib.mkDefault true; + runtimeEnv = { }; }; - swww = true; }; }; } diff --git a/tests/_snapshots/nixos b/tests/_snapshots/nixos index 7795c18..91ceab2 100644 --- a/tests/_snapshots/nixos +++ b/tests/_snapshots/nixos @@ -10,4 +10,15 @@ }; }; customModuleBootTimeOut = 10; + hyprland = { + autoLogin = { + enable = true; + shell = "zsh"; + }; + nvidia = true; + swww = { + enable = true; + runtimeEnv = { }; + }; + }; } \ No newline at end of file diff --git a/tests/nixos/__fixture/layouts.nix b/tests/nixos/__fixture/layouts.nix index 8ecdaa4..b5bb55d 100644 --- a/tests/nixos/__fixture/layouts.nix +++ b/tests/nixos/__fixture/layouts.nix @@ -37,7 +37,6 @@ in ]; homeSuites = [ - exporter.homeProfiles.customProfiles.presets.hyprland exporter.homeProfiles.default.presets.bat # # The parent directory of "presets" is categorized as a list type of "suites" (exporter.homeProfiles.default.shell { }).default diff --git a/tests/nixos/__fixture/pops/homeProfiles.nix b/tests/nixos/__fixture/pops/homeProfiles.nix index 3698499..ffb24e8 100644 --- a/tests/nixos/__fixture/pops/homeProfiles.nix +++ b/tests/nixos/__fixture/pops/homeProfiles.nix @@ -14,17 +14,19 @@ in exports.customProfiles = self.outputs [ { value = { selfModule' }: + with dmerge; selfModule' ( m: dmerge m { wayland.windowManager.hyprland.__profiles__ = { - nvidia = true; + nvidia.content = true; }; } ); path = [ "presets" "hyprland" + "default" ]; } ]; } diff --git a/tests/nixos/expr.nix b/tests/nixos/expr.nix index a3a9bcb..8fffcdc 100644 --- a/tests/nixos/expr.nix +++ b/tests/nixos/expr.nix @@ -4,25 +4,38 @@ lib, }: let - exporter = super.pops.layouts.default; + out = super.pops.layouts.default.layouts; + extraHomeModule = m: { + home-manager.users.admin = { + imports = lib.flatten m; + }; + }; in { bootProfile = - (exporter.layouts.nixosConfiguration [ - exporter.layouts.exporter.nixosProfiles.customProfiles.presets.boot + (out.nixosConfiguration [ + out.exporter.nixosProfiles.customProfiles.presets.boot ]).config.boot.__profiles__; customModuleBootTimeOut = - (exporter.layouts.nixosConfiguration [ - exporter.layouts.exporter.nixosModules.customModules.boot + (out.nixosConfiguration [ + out.exporter.nixosModules.customModules.boot { config.boot.__profiles__.speedup = true; config.boot.__profiles__.systemd-boot.enable = true; } ]).config.boot.loader.timeout; + + hyprland = + (out.nixosConfiguration [ + out.exporter.nixosModules.customModules.boot + (extraHomeModule [ out.exporter.homeProfiles.customProfiles.presets.hyprland ]) + ]) + .config.home-manager.users.admin.wayland.windowManager.hyprland.__profiles__; } // lib.optionalAttrs trace { - nixosConfiguration = exporter.layouts.nixosConfiguration [ - exporter.layouts.exporter.nixosProfiles.default.presets.boot + a = lib.mkDefault true; + nixosConfiguration = out.nixosConfiguration [ + out.exporter.nixosProfiles.default.presets.boot ]; }