Skip to content

Commit

Permalink
chore(homeProfiels): add hyprland tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Oct 12, 2023
1 parent 83ece62 commit 6db0674
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 63 deletions.
8 changes: 8 additions & 0 deletions docs/org/yubikey.org
Original file line number Diff line number Diff line change
@@ -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
107 changes: 62 additions & 45 deletions nixos/homeModules/wayland/windowManager/hyprland/config.nix
Original file line number Diff line number Diff line change
@@ -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
;
})
];
})
]
);
}
9 changes: 8 additions & 1 deletion nixos/homeModules/wayland/windowManager/hyprland/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions nixos/homeProfiles/presets/hyprland/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}
11 changes: 11 additions & 0 deletions tests/_snapshots/nixos
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@
};
};
customModuleBootTimeOut = 10;
hyprland = {
autoLogin = {
enable = true;
shell = "zsh";
};
nvidia = true;
swww = {
enable = true;
runtimeEnv = { };
};
};
}
1 change: 0 additions & 1 deletion tests/nixos/__fixture/layouts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/nixos/__fixture/pops/homeProfiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
} ];
}
Expand Down
26 changes: 19 additions & 7 deletions tests/nixos/expr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,37 @@
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
nixosConfiguration = out.nixosConfiguration [
out.exporter.nixosProfiles.default.presets.boot
];
}

0 comments on commit 6db0674

Please sign in to comment.