extract sway system config

This commit is contained in:
Leonardo Eugênio 2022-10-18 21:45:20 -03:00
parent f17d07d18b
commit 64e43f4535
9 changed files with 157 additions and 156 deletions

View file

@ -31,12 +31,10 @@
inherit system; inherit system;
config = { allowUnfree = true; }; config = { allowUnfree = true; };
}; };
overlay-unstable = final: prev: {
unstable = nixpkgs-unstable.legacyPackages.${prev.system};
};
lib = nixpkgs.lib; lib = nixpkgs.lib;
common_modules = [ common_modules = [
./system/configuration.nix ./system/configuration.nix
./system/sway.nix
./system/gitlab-runner.nix ./system/gitlab-runner.nix
# nur.nixosModules.nur # nur.nixosModules.nur
inputs.hyprland.nixosModules.default inputs.hyprland.nixosModules.default
@ -44,14 +42,7 @@
programs.hyprland.enable = true; programs.hyprland.enable = true;
# programs.hyprland.package = null; # programs.hyprland.package = null;
} }
(mod-inputs@{ config, pkgs, ... }: { (import ./overlays (inputs // {inherit system;}))
nixpkgs.overlays = [
overlay-unstable
nur.overlay
(import ./scripts mod-inputs)
(import ./overlays (inputs // { inherit system; }))
];
})
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;

View file

@ -1,35 +1,43 @@
inputs@{ system, ... }: (inputs@{ system, ... }: {pkgs, ...}: {
(final: prev: { nixpkgs.overlays = [
uservars = import ../user/variables.nix; inputs.nur.overlay
dhist = inputs.dhist.packages.${system}.dhist; (import ../scripts)
# alacritty = (old-pkgs.alacritty.overrideAttrs (import ./sway.nix)
# (old-alacritty: rec { (final: prev: {
# src = inputs.alacritty-sixel; unstable = inputs.nixpkgs-unstable.legacyPackages.${prev.system};
# cargoDeps = old-alacritty.cargoDeps.overrideAttrs
# (old-pkgs.lib.const { uservars = import ../user/variables.nix;
# inherit src; dhist = inputs.dhist.packages.${system}.dhist;
# outputHash = # alacritty = (old-pkgs.alacritty.overrideAttrs
# "sha256-2hMntoGHqoQT/Oqz261Ljif5xEuV8SnPH0m52bXdd2s="; # (old-alacritty: rec {
# }); # src = inputs.alacritty-sixel;
# })); # cargoDeps = old-alacritty.cargoDeps.overrideAttrs
# ranger = (old-pkgs.ranger.overridePythonAttrs (old-ranger: rec { # (old-pkgs.lib.const {
# src = inputs.ranger-sixel; # inherit src;
# checkInputs = [ ]; # outputHash =
# propagatedBuildInputs = with old-pkgs.python3Packages; # "sha256-2hMntoGHqoQT/Oqz261Ljif5xEuV8SnPH0m52bXdd2s=";
# old-ranger.propagatedBuildInputs ++ [ astroid pylint pytest ]; # });
# })); # }));
material-wifi-icons = final.stdenv.mkDerivation rec { # ranger = (old-pkgs.ranger.overridePythonAttrs (old-ranger: rec {
name = "material-wifi-icons"; # src = inputs.ranger-sixel;
src = inputs.material-wifi-icons; # checkInputs = [ ];
installPhase = let dest = "$out/share/fonts/${name}"; # propagatedBuildInputs = with old-pkgs.python3Packages;
in '' # old-ranger.propagatedBuildInputs ++ [ astroid pylint pytest ];
mkdir -p ${dest} # }));
cp material-wifi.ttf ${dest} material-wifi-icons = final.stdenv.mkDerivation rec {
''; name = "material-wifi-icons";
}; src = inputs.material-wifi-icons;
papirus_red = (final.unstable.papirus-icon-theme.override { color = "red"; }); installPhase = let dest = "$out/share/fonts/${name}";
orchis_theme_compact = in ''
(final.orchis-theme.override { tweaks = [ "compact" "solid" ]; }); mkdir -p ${dest}
nerdfonts_fira_hack = cp material-wifi.ttf ${dest}
(final.nerdfonts.override { fonts = [ "FiraCode" "Hack" ]; }); '';
};
papirus_red = (final.unstable.papirus-icon-theme.override { color = "red"; });
orchis_theme_compact =
(final.orchis-theme.override { tweaks = [ "compact" "solid" ]; });
nerdfonts_fira_hack =
(final.nerdfonts.override { fonts = [ "FiraCode" "Hack" ]; });
})
];
}) })

37
overlays/sway.nix Normal file
View file

@ -0,0 +1,37 @@
(final: pkgs: {
# bash script to let dbus know about important env variables and
# propogate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
# some user services to make sure they have the correct environment variables
dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
'';
};
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
# gsettings set $gnome_schema gtk-theme 'Dracula'
'';
};
})

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { pkgs, ... }:
pkgs.writeShellScriptBin "_gpg-unlock" '' pkgs.writeShellScriptBin "_gpg-unlock" ''
${pkgs.gnupg}/bin/gpg-connect-agent reloadagent /bye ${pkgs.gnupg}/bin/gpg-connect-agent reloadagent /bye

View file

@ -1,8 +1,7 @@
{ config, lib, ... }: (final: prev:
(pkgs: _: with prev;
with pkgs;
let let
import_script = (_: path: import (path) { inherit config pkgs lib; }); import_script = (_: path: import (path) { inherit pkgs lib; });
create_script = (name: text: runtimeInputs: create_script = (name: text: runtimeInputs:
let let
script_body = pkgs.writeTextFile { script_body = pkgs.writeTextFile {
@ -21,13 +20,13 @@
lib.mapAttrs (name: deps: create_script name ./${name} deps); lib.mapAttrs (name: deps: create_script name ./${name} deps);
in create_scripts { in create_scripts {
br = [ ]; br = [ ];
bmenu = [ bemenu dhist fish j4-dmenu-desktop jq sway ]; bmenu = [ bemenu final.dhist fish j4-dmenu-desktop jq sway ];
_diffr = [ diffr ]; _diffr = [ diffr ];
kak-pager = [ fish _diffr ]; kak-pager = [ fish final._diffr ];
terminal = [ alacritty ]; terminal = [ alacritty ];
wpass = [ bmenu fd pass sd wl-clipboard wtype ]; wpass = [ final.bmenu fd pass sd wl-clipboard wtype ];
screenshotsh = screenshotsh =
[ capitaine-cursors grim jq sway wl-clipboard xdg-user-dirs ]; [ capitaine-cursors grim slurp jq sway wl-clipboard xdg-user-dirs ];
volumesh = [ pulseaudio libnotify ]; volumesh = [ pulseaudio libnotify ];
} // lib.mapAttrs import_script { } // lib.mapAttrs import_script {
wdmenu = ./wdmenu.nix; wdmenu = ./wdmenu.nix;

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { pkgs, ... }:
let let
inherit (pkgs.uservars) dmenu; inherit (pkgs.uservars) dmenu;
available_menus = { available_menus = {

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { pkgs, ... }:
let let
inherit (pkgs.uservars) dmenu; inherit (pkgs.uservars) dmenu;
available_menus = { available_menus = {

View file

@ -1,44 +1,7 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }: { config, pkgs, ... }: {
let
# bash script to let dbus know about important env variables and
# propogate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
# some user services to make sure they have the correct environment variables
dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
'';
};
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
# gsettings set $gnome_schema gtk-theme 'Dracula'
'';
};
in {
# Bootloader. # Bootloader.
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
@ -67,42 +30,6 @@ in {
# services.xserver.displayManager.gdm.enable = true; # services.xserver.displayManager.gdm.enable = true;
# services.xserver.desktopManager.gnome.enable = true; # services.xserver.desktopManager.gnome.enable = true;
# services.xserver.displayManager.autologin.user = "lelgenio"; # services.xserver.displayManager.autologin.user = "lelgenio";
services.greetd = let
greetd_main_script = pkgs.writeShellScriptBin "main" ''
${dbus-sway-environment}/bin/dbus-sway-environment
${configure-gtk}/bin/configure-gtk
export XDG_CURRENT_DESKTOP=sway GTK_THEME=Orchis-Red-Dark-Compact
${pkgs.greetd.gtkgreet}/bin/gtkgreet -l -c sway
swaymsg exit
'';
swayConfig = pkgs.writeText "greetd-sway-config" ''
# `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet.
exec "${greetd_main_script}/bin/main"
bindsym Mod4+shift+e exec swaynag \
-t warning \
-m 'What do you want to do?' \
-b 'Poweroff' 'systemctl poweroff' \
-b 'Reboot' 'systemctl reboot'
input "*" {
repeat_delay 200
repeat_rate 30
xkb_layout us(colemak)
xkb_numlock enabled
xkb_options lv3:lsgt_switch,grp:shifts_toggle
}
'';
in {
enable = true;
settings = {
initial_session = {
command = "${pkgs.sway}/bin/sway";
user = "lelgenio";
};
default_session = {
command = "${pkgs.sway}/bin/sway --config ${swayConfig}";
};
};
};
# Configure keymap in X11 # Configure keymap in X11
services.xserver = { services.xserver = {
layout = "us"; layout = "us";
@ -111,16 +38,9 @@ in {
console.keyMap = "colemak"; console.keyMap = "colemak";
# Enable CUPS to print documents. # Enable CUPS to print documents.
# services.printing.enable = true; # services.printing.enable = true;
services.dbus.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
# gtk portal needed to make gtk apps happy
# extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
# gtkUsePortal = false;
};
services.flatpak.enable = true; services.flatpak.enable = true;
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
security.rtkit.enable = true; security.rtkit.enable = true;
services.sshd.enable = true; services.sshd.enable = true;
@ -137,6 +57,7 @@ in {
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
services.xserver.libinput.enable = true; services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.lelgenio = { users.users.lelgenio = {
isNormalUser = true; isNormalUser = true;
@ -171,23 +92,12 @@ in {
tdesktop tdesktop
# recomended by nixwiki # recomended by nixwiki
alacritty # gpu accelerated terminal alacritty # gpu accelerated terminal
sway
dbus-sway-environment
pkgs.xdg-desktop-portal
pkgs.xdg-desktop-portal-wlr
configure-gtk
wayland
glib # gsettings glib # gsettings
usbutils usbutils
# dracula-theme # gtk theme # dracula-theme # gtk theme
gnome3.adwaita-icon-theme # default gnome cursors gnome3.adwaita-icon-theme # default gnome cursors
swaylock
swayidle
grim # screenshot functionality
slurp # screenshot functionality
wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout
bemenu # wayland clone of dmenu
mako # notification system developed by swaywm maintainer
orchis_theme_compact orchis_theme_compact
pulseaudio pulseaudio
@ -208,11 +118,7 @@ in {
sqlx-cli sqlx-cli
nodePackages.sass nodePackages.sass
]; ];
# enable sway window manager
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
services.geoclue2.enable = true; services.geoclue2.enable = true;
# programs.qt5ct.enable = true; # programs.qt5ct.enable = true;
programs.steam.enable = true; programs.steam.enable = true;

60
system/sway.nix Normal file
View file

@ -0,0 +1,60 @@
{ pkgs, ... }: {
# enable sway window manager
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
services.dbus.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
# gtk portal needed to make gtk apps happy
# extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
# gtkUsePortal = false;
};
services.greetd = let
greetd_main_script = pkgs.writeShellScriptBin "main" ''
${pkgs.dbus-sway-environment}/bin/dbus-sway-environment
${pkgs.configure-gtk}/bin/configure-gtk
export XDG_CURRENT_DESKTOP=sway GTK_THEME=Orchis-Red-Dark-Compact
${pkgs.greetd.gtkgreet}/bin/gtkgreet -l -c sway
swaymsg exit
'';
swayConfig = pkgs.writeText "greetd-sway-config" ''
# `-l` activates layer-shell mode. Notice that `swaymsg exit` will run after gtkgreet.
exec "${greetd_main_script}/bin/main"
bindsym Mod4+shift+e exec swaynag \
-t warning \
-m 'What do you want to do?' \
-b 'Poweroff' 'systemctl poweroff' \
-b 'Reboot' 'systemctl reboot'
input "*" {
repeat_delay 200
repeat_rate 30
xkb_layout us(colemak)
xkb_numlock enabled
xkb_options lv3:lsgt_switch,grp:shifts_toggle
}
'';
in {
enable = true;
settings = {
initial_session = {
command = "${pkgs.sway}/bin/sway";
user = "lelgenio";
};
default_session = {
command = "${pkgs.sway}/bin/sway --config ${swayConfig}";
};
};
};
environment.systemPackages = with pkgs; [
sway
swaylock
swayidle
wayland
pkgs.xdg-desktop-portal
pkgs.xdg-desktop-portal-wlr
];
}