create shared niri config, refactor generic feature modules
This commit is contained in:
23 files changed
+353
-410
No files matched your search
@@ -1,88 +1,66 @@
|
||||
{ inputs, self, ... }: {
|
||||
imports = [ ./niri.nix ];
|
||||
|
||||
flake.nixosModules.graphics = { config, pkgs, lib, ... }: {
|
||||
# override niri source to use https://github.com/barrulus/biri
|
||||
config = lib.mkIf (builtins.elem "biri" config.components.windowManagers) {
|
||||
environment.systemPackages = with pkgs; [
|
||||
xdg-desktop-portal-gnome
|
||||
wl-clipboard
|
||||
libsecret
|
||||
cage
|
||||
wev
|
||||
qalculate-qt
|
||||
];
|
||||
|
||||
features.applications.gui.nautilus.enable = true;
|
||||
|
||||
services.upower.enable = true;
|
||||
|
||||
services.udisks2.enable = true;
|
||||
|
||||
programs.niri = {
|
||||
enable = true;
|
||||
useNautilus = true;
|
||||
# override niri source to use https://github.com/barrulus/biri
|
||||
package = self.packages.${pkgs.stdenv.hostPlatform.system}.biri;
|
||||
};
|
||||
programs.niri.package = self.packages.${pkgs.stdenv.hostPlatform.system}.biri;
|
||||
|
||||
home-manager.users.${config.info.userName} = lib.mkIf (config.features.nixos.home-manager.enable) {
|
||||
components.windowManagers = [ "niri" ];
|
||||
components.windowManagers = [ "biri" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeModules.graphics = { config, pkgs, lib, inputs, ... }: {
|
||||
home = lib.mkIf ((config.components.windowManagers == "biri")||(builtins.elem "biri" config.components.windowManagers)) {
|
||||
activation.linkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript {
|
||||
target = "${config.xdg.configHome}/niri/config.kdl";
|
||||
source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/niri.kdl";
|
||||
});
|
||||
};
|
||||
|
||||
features.applications.shellScripts = {
|
||||
niri-scratch-workspace-toggle = ''
|
||||
if niri msg --json workspaces-with-hidden | jq -e '.[] | select(.name=="x") | .is_hidden' >/dev/null; then
|
||||
niri msg action unhide-workspace --focus=false "x"
|
||||
OUTPUT=$(niri msg --json focused-output | jq '.name' | sed 's/"//g')
|
||||
niri msg action move-workspace-to-monitor --reference "x" "$OUTPUT"
|
||||
niri msg action focus-workspace "x"
|
||||
else
|
||||
niri msg action hide-workspace "x"
|
||||
fi
|
||||
'';
|
||||
|
||||
niri-listen-for-scratch-workspace-change = ''
|
||||
niri msg --json event-stream | while read -r event; do
|
||||
if echo $event | jq -e '.WorkspaceActivated.focused' >/dev/null; then
|
||||
if niri msg --json workspaces | jq -e '.[] | select(.name=="x") | .is_active==false' >/dev/null; then
|
||||
niri msg action hide-workspace "x"
|
||||
fi
|
||||
elif echo $event | jq -e '.WorkspacesChanged.workspaces.[] | select(.name=="x") | .is_active==false' >/dev/null; then
|
||||
config = lib.mkIf (builtins.elem "biri" config.components.windowManagers) {
|
||||
features.applications.shellScripts = {
|
||||
niri-scratch-workspace-toggle = ''
|
||||
if niri msg --json workspaces-with-hidden | jq -e '.[] | select(.name=="x") | .is_hidden' >/dev/null; then
|
||||
niri msg action unhide-workspace --focus=false "x"
|
||||
OUTPUT=$(niri msg --json focused-output | jq '.name' | sed 's/"//g')
|
||||
niri msg action move-workspace-to-monitor --reference "x" "$OUTPUT"
|
||||
niri msg action focus-workspace "x"
|
||||
else
|
||||
niri msg action hide-workspace "x"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
'';
|
||||
|
||||
niri-toggle-dwt = ''
|
||||
niri msg action toggle-dwt
|
||||
cd ${config.xdg.stateHome}
|
||||
if [ -f ./niri.json ]; then
|
||||
if jq -e '.dwt' niri.json >/dev/null; then
|
||||
NEW_JSON=$(jq '.dwt = false' niri.json)
|
||||
echo "$NEW_JSON" > niri.json
|
||||
niri-listen-for-scratch-workspace-change = ''
|
||||
niri msg --json event-stream | while read -r event; do
|
||||
if echo $event | jq -e '.WorkspaceActivated.focused' >/dev/null; then
|
||||
if niri msg --json workspaces | jq -e '.[] | select(.name=="x") | .is_active==false' >/dev/null; then
|
||||
niri msg action hide-workspace "x"
|
||||
fi
|
||||
elif echo $event | jq -e '.WorkspacesChanged.workspaces.[] | select(.name=="x") | .is_active==false' >/dev/null; then
|
||||
niri msg action hide-workspace "x"
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
||||
niri-toggle-dwt = ''
|
||||
niri msg action toggle-dwt
|
||||
cd ${config.xdg.stateHome}
|
||||
if [ -f ./niri.json ]; then
|
||||
if jq -e '.dwt' niri.json >/dev/null; then
|
||||
NEW_JSON=$(jq '.dwt = false' niri.json)
|
||||
echo "$NEW_JSON" > niri.json
|
||||
else
|
||||
NEW_JSON=$(jq '.dwt = true' niri.json)
|
||||
echo "$NEW_JSON" > niri.json
|
||||
fi
|
||||
else
|
||||
NEW_JSON=$(jq '.dwt = true' niri.json)
|
||||
echo "$NEW_JSON" > niri.json
|
||||
echo '{"dwt": false}' | jq '.' > niri.json
|
||||
fi
|
||||
else
|
||||
echo '{"dwt": false}' | jq '.' > niri.json
|
||||
fi
|
||||
NEW_STATE=$(jq '.dwt' niri.json)
|
||||
noctalia msg notification-show "Touchpad DWT toggled $NEW_STATE"
|
||||
'';
|
||||
PRETTY_STATE=$(if jq -e '.dwt' niri.json >/dev/null; then echo "on"; else echo "off"; fi)
|
||||
notify-send -e -a "niri-toggle-dwt script" "Toggled DWT $PRETTY_STATE"
|
||||
'';
|
||||
|
||||
niri-clear-state = ''
|
||||
cd ${config.xdg.stateHome}
|
||||
rm niri.json
|
||||
'';
|
||||
niri-clear-state = ''
|
||||
cd ${config.xdg.stateHome}
|
||||
rm niri.json
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{ inputs, self, ... }: {
|
||||
flake.nixosModules.graphics = { config, pkgs, lib, ... }: {
|
||||
config = lib.mkIf (builtins.elem "niri" config.components.windowManagers) {
|
||||
config = lib.mkIf (builtins.elem "niri" config.components.windowManagers || builtins.elem "biri" config.components.windowManagers) {
|
||||
environment.systemPackages = with pkgs; [
|
||||
xdg-desktop-portal-gnome
|
||||
wl-clipboard
|
||||
@@ -10,8 +10,6 @@
|
||||
qalculate-qt
|
||||
];
|
||||
|
||||
features.applications.gui.nautilus.enable = true;
|
||||
|
||||
services.upower.enable = true;
|
||||
|
||||
services.udisks2.enable = true;
|
||||
@@ -19,20 +17,6 @@
|
||||
programs.niri = {
|
||||
enable = true;
|
||||
useNautilus = true;
|
||||
# override niri source to use https://github.com/niri-wm/niri/pull/3642
|
||||
package = (pkgs.niri.overrideAttrs (finalAttrs: prevAttrs: {
|
||||
cargoHash = "sha256-HypBB3PL4nVFMNH2+jEK0+dG9dJ920nHi8GwRoeH/v4=";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "niri-wm";
|
||||
repo = "niri";
|
||||
rev = "cb41d54703eef73883bb2be58e19bcf3715d777c";
|
||||
sha256 = "sha256-cLzTeMcCdQJ+kHGcOposjeheFyEG/tGOA1jFAORMHjI=";
|
||||
};
|
||||
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
|
||||
inherit (finalAttrs) pname src version;
|
||||
hash = finalAttrs.cargoHash;
|
||||
};
|
||||
}));
|
||||
};
|
||||
|
||||
home-manager.users.${config.info.userName} = lib.mkIf (config.features.nixos.home-manager.enable) {
|
||||
@@ -42,11 +26,18 @@
|
||||
};
|
||||
|
||||
flake.homeModules.graphics = { config, pkgs, lib, inputs, ... }: {
|
||||
home = lib.mkIf ((config.components.windowManagers == "niri")||(builtins.elem "niri" config.components.windowManagers)) {
|
||||
activation.linkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript {
|
||||
target = "${config.xdg.configHome}/niri/config.kdl";
|
||||
source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/niri.kdl";
|
||||
});
|
||||
home = lib.mkIf (builtins.elem "niri" config.components.windowManagers || builtins.elem "biri" config.components.windowManagers) {
|
||||
activation = {
|
||||
linkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript {
|
||||
target = "${config.xdg.configHome}/niri/config.kdl";
|
||||
source = "${config.info.rootPath}/dotfiles/${config.info.hostName}/niri.kdl";
|
||||
});
|
||||
|
||||
linkSharedConfig = lib.hm.dag.entryAfter ["writeBoundary"] (inputs.helpers.mkSymlinkActivationScript {
|
||||
target = "${config.xdg.configHome}/niri/shared.kdl";
|
||||
source = "${config.info.rootPath}/dotfiles/shared/niri-shared.kdl";
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user