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

View file

@ -1,35 +1,43 @@
inputs@{ system, ... }:
(final: prev: {
uservars = import ../user/variables.nix;
dhist = inputs.dhist.packages.${system}.dhist;
# alacritty = (old-pkgs.alacritty.overrideAttrs
# (old-alacritty: rec {
# src = inputs.alacritty-sixel;
# cargoDeps = old-alacritty.cargoDeps.overrideAttrs
# (old-pkgs.lib.const {
# inherit src;
# outputHash =
# "sha256-2hMntoGHqoQT/Oqz261Ljif5xEuV8SnPH0m52bXdd2s=";
# });
# }));
# ranger = (old-pkgs.ranger.overridePythonAttrs (old-ranger: rec {
# src = inputs.ranger-sixel;
# checkInputs = [ ];
# propagatedBuildInputs = with old-pkgs.python3Packages;
# old-ranger.propagatedBuildInputs ++ [ astroid pylint pytest ];
# }));
material-wifi-icons = final.stdenv.mkDerivation rec {
name = "material-wifi-icons";
src = inputs.material-wifi-icons;
installPhase = let dest = "$out/share/fonts/${name}";
in ''
mkdir -p ${dest}
cp material-wifi.ttf ${dest}
'';
};
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" ]; });
(inputs@{ system, ... }: {pkgs, ...}: {
nixpkgs.overlays = [
inputs.nur.overlay
(import ../scripts)
(import ./sway.nix)
(final: prev: {
unstable = inputs.nixpkgs-unstable.legacyPackages.${prev.system};
uservars = import ../user/variables.nix;
dhist = inputs.dhist.packages.${system}.dhist;
# alacritty = (old-pkgs.alacritty.overrideAttrs
# (old-alacritty: rec {
# src = inputs.alacritty-sixel;
# cargoDeps = old-alacritty.cargoDeps.overrideAttrs
# (old-pkgs.lib.const {
# inherit src;
# outputHash =
# "sha256-2hMntoGHqoQT/Oqz261Ljif5xEuV8SnPH0m52bXdd2s=";
# });
# }));
# ranger = (old-pkgs.ranger.overridePythonAttrs (old-ranger: rec {
# src = inputs.ranger-sixel;
# checkInputs = [ ];
# propagatedBuildInputs = with old-pkgs.python3Packages;
# old-ranger.propagatedBuildInputs ++ [ astroid pylint pytest ];
# }));
material-wifi-icons = final.stdenv.mkDerivation rec {
name = "material-wifi-icons";
src = inputs.material-wifi-icons;
installPhase = let dest = "$out/share/fonts/${name}";
in ''
mkdir -p ${dest}
cp material-wifi.ttf ${dest}
'';
};
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.gnupg}/bin/gpg-connect-agent reloadagent /bye

View file

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

View file

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

View file

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

View file

@ -1,44 +1,7 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ 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 {
{ config, pkgs, ... }: {
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@ -67,42 +30,6 @@ in {
# services.xserver.displayManager.gdm.enable = true;
# services.xserver.desktopManager.gnome.enable = true;
# 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
services.xserver = {
layout = "us";
@ -111,16 +38,9 @@ in {
console.keyMap = "colemak";
# Enable CUPS to print documents.
# 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;
virtualisation.docker.enable = true;
security.rtkit.enable = true;
services.sshd.enable = true;
@ -137,6 +57,7 @@ in {
# Enable touchpad support (enabled default in most desktopManager).
services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.lelgenio = {
isNormalUser = true;
@ -171,23 +92,12 @@ in {
tdesktop
# recomended by nixwiki
alacritty # gpu accelerated terminal
sway
dbus-sway-environment
pkgs.xdg-desktop-portal
pkgs.xdg-desktop-portal-wlr
configure-gtk
wayland
glib # gsettings
usbutils
# dracula-theme # gtk theme
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
pulseaudio
@ -208,11 +118,7 @@ in {
sqlx-cli
nodePackages.sass
];
# enable sway window manager
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
services.geoclue2.enable = true;
# programs.qt5ct.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
];
}