reformat everything with alejandra

pull/58/head
Tudor Roman 2024-01-28 15:51:55 +01:00
parent 7b8952679b
commit 3237085311
Signed by: tudor
SSH Key Fingerprint: SHA256:3CwS9plgXBecpXImPGxDIaSktUXBejbV/zerZMqzzBk
57 changed files with 1475 additions and 1303 deletions

View File

@ -3,11 +3,12 @@
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).defaultNix
})
.defaultNix

107
flake.nix
View File

@ -65,30 +65,32 @@
attic.url = "github:zhaofengli/attic";
};
outputs = inputs@{ self
, haumea
, pre-commit-hooks
, nixpkgs
, deploy-rs
, flake-parts
, home-manager
, ... }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
outputs = inputs @ {
self,
haumea,
pre-commit-hooks,
nixpkgs,
deploy-rs,
flake-parts,
home-manager,
...
}: let
systems = ["x86_64-linux" "aarch64-linux"];
vars = {
stateVersion = "23.11";
vars = {
stateVersion = "23.11";
};
specialArgs = {
inherit vars;
flake = {
inherit self inputs;
};
};
specialArgs = {
inherit vars;
flake = {
inherit self inputs;
};
};
deployPkgs = with nixpkgs.lib; listToAttrs (map (system: nameValuePair system (self.lib.deploy.mkPkgs system)) systems);
in flake-parts.lib.mkFlake { inherit inputs; } {
deployPkgs = with nixpkgs.lib; listToAttrs (map (system: nameValuePair system (self.lib.deploy.mkPkgs system)) systems);
in
flake-parts.lib.mkFlake {inherit inputs;} {
inherit systems;
flake = {
@ -104,7 +106,7 @@
modules = [
inputs.agenix.nixosModules.default
{
environment.systemPackages = [ inputs.agenix.packages.${system}.default ];
environment.systemPackages = [inputs.agenix.packages.${system}.default];
# enable ssh host key generation
services.openssh.enable = true;
}
@ -120,10 +122,11 @@
}
./hosts/${name}
];
in nixpkgs.lib.nixosSystem {
pkgs = self.lib.nixpkgs.mkPkgs { inherit system; };
inherit system modules specialArgs;
};
in
nixpkgs.lib.nixosSystem {
pkgs = self.lib.nixpkgs.mkPkgs {inherit system;};
inherit system modules specialArgs;
};
in {
"ceres" = mkNixOSSystem "ceres" "x86_64-linux";
"wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
@ -131,28 +134,31 @@
homeConfigurations = let
mkHomeConfiguration = name: user: system: let
pkgs = self.lib.nixpkgs.mkPkgs { inherit system; };
in inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
pkgs = self.lib.nixpkgs.mkPkgs {inherit system;};
in
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs;
modules = self.lib.hm-modules ++ [
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
};
extraSpecialArgs = specialArgs;
modules =
self.lib.hm-modules
++ [
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
};
programs.bash.profileExtra = ''
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
'';
}
(./users + "/${name}")
];
};
programs.bash.profileExtra = ''
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
'';
}
(./users + "/${name}")
];
};
in {
"tudor" = mkHomeConfiguration "tudor" "tudor" "x86_64-linux";
"tudor@pepper-penguin" = mkHomeConfiguration "tudor@pepper-penguin" "tudor" "x86_64-linux";
@ -171,7 +177,12 @@
checks."x86_64-linux" = deployPkgs."x86_64-linux".deploy-rs.lib.deployChecks self.deploy;
};
perSystem = { pkgs, system, self', ... }: {
perSystem = {
pkgs,
system,
self',
...
}: {
packages.default = pkgs.nix;
packages.nixos-rebuild = pkgs.nixos-rebuild;
@ -212,7 +223,7 @@
src = ./.;
dontBuild = true;
doCheck = true;
buildInputs = with pkgs; [ ansible-lint git ];
buildInputs = with pkgs; [ansible-lint git];
checkPhase = ''
cd ./ansible
env "HOME=$TMPDIR" ansible-lint --offline

View File

@ -1,6 +1,8 @@
{ flake, vars, ... }:
{
flake,
vars,
...
}: {
imports = [
../../modules/nixos
];

View File

@ -1,6 +1,5 @@
{ config, ...}:
{
imports = [ ../_all ./hardware.nix ];
{config, ...}: {
imports = [../_all ./hardware.nix];
systemModules.basePackages.enable = true;
systemModules.services = {
@ -32,7 +31,7 @@
i18n.defaultLocale = "en_US.UTF-8";
time.timeZone = "Europe/Bucharest";
boot.supportedFilesystems = [ "zfs" ];
boot.supportedFilesystems = ["zfs"];
boot.loader.grub = {
enable = true;
@ -62,7 +61,7 @@
users.users.tudor = {
isNormalUser = true;
extraGroups = [ "wheel" ];
extraGroups = ["wheel"];
uid = 1000;
home = "/home/tudor";
hashedPasswordFile = config.age.secrets.tudor-password.path;

View File

@ -1,32 +1,35 @@
{ pkgs, lib, ...}:
{
boot.initrd.availableKernelModules = [ "ata_generic" "uhci_hcd" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
pkgs,
lib,
...
}: {
boot.initrd.availableKernelModules = ["ata_generic" "uhci_hcd" "ehci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" "sr_mod"];
boot.initrd.kernelModules = [];
boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [];
fileSystems."/" =
{ device = "rpool/root/nixos";
fsType = "zfs";
};
fileSystems."/" = {
device = "rpool/root/nixos";
fsType = "zfs";
};
fileSystems."/nix" =
{ device = "rpool/nix";
fsType = "zfs";
neededForBoot = true;
};
fileSystems."/nix" = {
device = "rpool/nix";
fsType = "zfs";
neededForBoot = true;
};
fileSystems."/home" =
{ device = "rpool/home";
fsType = "zfs";
};
fileSystems."/home" = {
device = "rpool/home";
fsType = "zfs";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/8d11e1ec-50db-4aa3-a920-788e7f88b68e";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/8d11e1ec-50db-4aa3-a920-788e7f88b68e";
fsType = "ext4";
};
swapDevices = [ ];
swapDevices = [];
# High-DPI console
console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";

View File

@ -1,8 +1,11 @@
{ config, flake, ... }:
let
{
config,
flake,
...
}: let
username = "tudor";
in {
imports = [ ../_all flake.inputs.nixos-wsl.nixosModules.wsl ];
imports = [../_all flake.inputs.nixos-wsl.nixosModules.wsl];
systemModules = {
basePackages.enable = true;
@ -30,7 +33,7 @@ in {
users.users."${username}" = {
isNormalUser = true;
extraGroups = [ "wheel" ];
extraGroups = ["wheel"];
uid = 1000;
home = "/home/${username}";
hashedPasswordFile = config.age.secrets.tudor-password.path;

View File

@ -1,16 +1,17 @@
{ inputs, ... }: let
{inputs, ...}: let
inherit (inputs) nixpkgs deploy-rs;
in {
mkPkgs = system: import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(_self: super: {
deploy-rs = {
inherit (nixpkgs.legacyPackages."${system}") deploy-rs;
inherit (super.deploy-rs) lib;
};
})
];
};
in {
mkPkgs = system:
import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(_self: super: {
deploy-rs = {
inherit (nixpkgs.legacyPackages."${system}") deploy-rs;
inherit (super.deploy-rs) lib;
};
})
];
};
}

View File

@ -1,7 +1,8 @@
{ ... }:
serviceConfig: serviceConfig // {
CapabilityBoundingSet = [ "" ];
DeviceAllow = [ "" ];
{...}: serviceConfig:
serviceConfig
// {
CapabilityBoundingSet = [""];
DeviceAllow = [""];
LockPersonality = true;
MemoryDenyWriteExecute = true;
PrivateDevices = true;
@ -15,11 +16,11 @@ serviceConfig: serviceConfig // {
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
RestrictAddressFamilies = ["AF_INET" "AF_INET6" "AF_UNIX"];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" ];
SystemCallFilter = ["@system-service" "~@privileged"];
UMask = "0077";
}

View File

@ -1,3 +1,3 @@
{ inputs }: [
{inputs}: [
inputs.agenix.homeManagerModules.default
]

View File

@ -1,10 +1,13 @@
{ self, inputs, ... }:
{
self,
inputs,
...
}: {
defaultConfig = {
allowUnfree = true;
};
mkDefaultOverlays = { system }: [
mkDefaultOverlays = {system}: [
(final: _prev: {
unstable = import inputs.unstable {
inherit system;
@ -13,9 +16,10 @@
})
];
mkPkgs = { system }: import inputs.nixpkgs {
inherit system;
config = self.defaultConfig;
overlays = self.mkDefaultOverlays { inherit system; };
};
mkPkgs = {system}:
import inputs.nixpkgs {
inherit system;
config = self.defaultConfig;
overlays = self.mkDefaultOverlays {inherit system;};
};
}

View File

@ -1,5 +1,4 @@
{ ... }:
{
{...}: {
imports = [
./desktop
./shell

View File

@ -1,4 +1,4 @@
{ ... }: {
{...}: {
imports = [
./disable-animations.nix
./fonts.nix

View File

@ -1,27 +1,31 @@
{ config, lib, ... }: let
{
config,
lib,
...
}: let
cfg = config.homeModules.desktop.disableAnimations;
in
with lib; {
options = {
homeModules.desktop.disableAnimations = {
enable = mkEnableOption "Enable disabling of animations";
};
};
config = mkIf cfg.enable {
gtk = let
extraConfig.gtk-enable-animations = false;
in {
enable = true;
gtk3 = { inherit extraConfig; };
gtk4 = { inherit extraConfig; };
};
dconf = {
enable = true;
settings = {
"org/gnome/desktop/interface".enable-animations = false;
with lib; {
options = {
homeModules.desktop.disableAnimations = {
enable = mkEnableOption "Enable disabling of animations";
};
};
};
}
config = mkIf cfg.enable {
gtk = let
extraConfig.gtk-enable-animations = false;
in {
enable = true;
gtk3 = {inherit extraConfig;};
gtk4 = {inherit extraConfig;};
};
dconf = {
enable = true;
settings = {
"org/gnome/desktop/interface".enable-animations = false;
};
};
};
}

View File

@ -1,77 +1,81 @@
{ config, lib, pkgs, ... }:
let
{
config,
lib,
pkgs,
...
}: let
cfg = config.homeModules.desktop.fonts;
in
with lib; {
options = {
homeModules.desktop.fonts = {
enable = mkEnableOption "Enable fonts";
themeFont = mkOption {
default = {};
type = types.submodule ({ ... }: {
options = {
family = mkOption {
type = types.str;
default = "monospace";
example = "Fira Mono";
with lib; {
options = {
homeModules.desktop.fonts = {
enable = mkEnableOption "Enable fonts";
themeFont = mkOption {
default = {};
type = types.submodule ({...}: {
options = {
family = mkOption {
type = types.str;
default = "monospace";
example = "Fira Mono";
};
style = mkOption {
type = types.str;
default = "";
example = "Bold Semi-Condensed";
};
size = mkOption {
type = types.float;
default = 12.0;
};
};
style = mkOption {
type = types.str;
default = "";
example = "Bold Semi-Condensed";
};
size = mkOption {
type = types.float;
default = 12.0;
};
};
});
});
};
};
};
};
config = mkIf cfg.enable {
fonts.fontconfig.enable = true;
config = mkIf cfg.enable {
fonts.fontconfig.enable = true;
home.packages = with pkgs; [
noto-fonts
noto-fonts-emoji
];
home.packages = with pkgs; [
noto-fonts
noto-fonts-emoji
];
# credits: https://github.com/androlabs/emoji-archlinux
xdg.configFile."fontconfig/conf.d/20-noto-emoji.conf".text = ''
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Sans</family>
</prefer>
</alias>
# credits: https://github.com/androlabs/emoji-archlinux
xdg.configFile."fontconfig/conf.d/20-noto-emoji.conf".text = ''
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>sans-serif</family>
<prefer>
<family>Noto Sans</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Sans</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Serif</family>
</prefer>
</alias>
<alias>
<family>serif</family>
<prefer>
<family>Noto Serif</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
<family>DejaVu Serif</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Noto Sans Mono</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
</fontconfig>
'';
};
}
<alias>
<family>monospace</family>
<prefer>
<family>Noto Sans Mono</family>
<family>Noto Color Emoji</family>
<family>Noto Emoji</family>
</prefer>
</alias>
</fontconfig>
'';
};
}

View File

@ -1,49 +1,53 @@
{ config, lib, pkgs, ... }:
let
{
config,
lib,
pkgs,
...
}: let
cfg = config.homeModules.desktop.foot;
inherit (config.homeModules.desktop.fonts) themeFont;
in
with lib; {
options = {
homeModules.desktop.foot = {
enable = mkEnableOption "Enable foot";
with lib; {
options = {
homeModules.desktop.foot = {
enable = mkEnableOption "Enable foot";
};
};
};
config = mkIf cfg.enable {
programs.foot = {
enable = true;
package = pkgs.foot;
settings = {
main = {
pad = "20x20";
# idk how foot does font sizes but it's not as
# small as you might think
font = "${themeFont.family}:size=${builtins.toString (builtins.floor themeFont.size)}";
dpi-aware = "no";
};
colors = {
# https://codeberg.org/dnkl/foot/src/branch/master/themes/gruvbox-light
background = "fbf1c7";
foreground = "3c3836";
regular0 = "fbf1c7";
regular1 = "cc241d";
regular2 = "98971a";
regular3 = "d79921";
regular4 = "458588";
regular5 = "b16286";
regular6 = "689d6a";
regular7 = "7c6f64";
bright0 = "928374";
bright1 = "9d0006";
bright2 = "79740e";
bright3 = "b57614";
bright4 = "076678";
bright5 = "8f3f71";
bright6 = "427b58";
bright7 = "3c3836";
config = mkIf cfg.enable {
programs.foot = {
enable = true;
package = pkgs.foot;
settings = {
main = {
pad = "20x20";
# idk how foot does font sizes but it's not as
# small as you might think
font = "${themeFont.family}:size=${builtins.toString (builtins.floor themeFont.size)}";
dpi-aware = "no";
};
colors = {
# https://codeberg.org/dnkl/foot/src/branch/master/themes/gruvbox-light
background = "fbf1c7";
foreground = "3c3836";
regular0 = "fbf1c7";
regular1 = "cc241d";
regular2 = "98971a";
regular3 = "d79921";
regular4 = "458588";
regular5 = "b16286";
regular6 = "689d6a";
regular7 = "7c6f64";
bright0 = "928374";
bright1 = "9d0006";
bright2 = "79740e";
bright3 = "b57614";
bright4 = "076678";
bright5 = "8f3f71";
bright6 = "427b58";
bright7 = "3c3836";
};
};
};
};
};
}
}

View File

@ -1,285 +1,308 @@
{ config, flake, lib, pkgs, ... }:
let
{
config,
flake,
lib,
pkgs,
...
}: let
cfg = config.homeModules.desktop.sway;
inherit (config.homeModules.desktop.fonts) themeFont;
in
with lib; {
options = {
homeModules.desktop.sway = {
enable = mkEnableOption "Enable sway";
nixGLPackage = mkOption {
type = types.nullOr types.package;
default = null;
description = ''
Start sway with a nixGL variant. Useful for Non-NixOS systems.
If null (default), sway will be started normally.
'';
};
with lib; {
options = {
homeModules.desktop.sway = {
enable = mkEnableOption "Enable sway";
nixGLPackage = mkOption {
type = types.nullOr types.package;
default = null;
description = ''
Start sway with a nixGL variant. Useful for Non-NixOS systems.
If null (default), sway will be started normally.
'';
};
wallpaperPath = mkOption {
description = "Path to wallpaper to apply";
type = types.path;
# https://unsplash.com/photos/ZlzWbHC86B8
default = ./wallpaper.jpg;
};
wallpaperPath = mkOption {
description = "Path to wallpaper to apply";
type = types.path;
# https://unsplash.com/photos/ZlzWbHC86B8
default = ./wallpaper.jpg;
};
terminal = mkOption {
description = "Terminal emulator to use: foot or wezterm";
type = types.str;
default = "wezterm";
terminal = mkOption {
description = "Terminal emulator to use: foot or wezterm";
type = types.str;
default = "wezterm";
};
};
};
};
config = mkIf cfg.enable {
nixpkgs.overlays = [
flake.inputs.hypr-contrib.overlays.default
];
config = mkIf cfg.enable {
nixpkgs.overlays = [
flake.inputs.hypr-contrib.overlays.default
];
homeModules.desktop = {
# terminal emulator
wezterm.enable = cfg.terminal == "wezterm";
fonts.enable = cfg.terminal == "foot";
# status bar
waybar = {
homeModules.desktop = {
# terminal emulator
wezterm.enable = cfg.terminal == "wezterm";
fonts.enable = cfg.terminal == "foot";
# status bar
waybar = {
enable = true;
systemdTarget = "sway-session.target";
};
};
home.packages = with pkgs; [
wl-clipboard
];
# notification daemon
services.mako.enable = true;
# dynamic display configuration.
# to be enabled by each config inidividually,
# this key is set here only to make it start when sway starts.
services.kanshi.systemdTarget = "sway-session.target";
# clipboard manager. keeps the contents once the original program quits.
services.copyq = {
enable = true;
systemdTarget = "sway-session.target";
};
};
home.packages = with pkgs; [
wl-clipboard
];
# notification daemon
services.mako.enable = true;
# dynamic display configuration.
# to be enabled by each config inidividually,
# this key is set here only to make it start when sway starts.
services.kanshi.systemdTarget = "sway-session.target";
# clipboard manager. keeps the contents once the original program quits.
services.copyq = {
enable = true;
systemdTarget = "sway-session.target";
};
# blue light remover. adjusts the red tint based on the time of day.
services.gammastep = {
enable = true;
provider = "manual";
# https://maps.app.goo.gl/wrftdjP96bKDu5FW7
latitude = "52.36308";
longitude = "4.88372";
tray = true;
};
# does things if the computer is left untouched for a while
services.swayidle = let
swaymsg = "${config.wayland.windowManager.sway.package}/bin/swaymsg";
# if running nixos: make sure swaylock is enabled system-wide in the system config!
# if not: make sure you either have swaylock installed via the system package manager,
# or you have a valid PAM config for it.
# otherwise, it will not be able to unlock the screen!
swaylock = "/usr/bin/env swaylock";
swaylockCmd = "${swaylock} -c 000000 -fF";
in {
enable = true;
systemdTarget = "sway-session.target";
events = [
# make sure the screen is locked before going to sleep
{ event = "before-sleep"; command = swaylockCmd; }
{ event = "lock"; command = swaylockCmd; }
# stop the screen locker if loginctl says it's time to unlock
# (you can test by running loginctl unlock-session).
# regarding the sigusr1 thing, see swaylock(1).
{ event = "unlock"; command = "pkill -USR1 swaylock"; }
];
timeouts = [
{
timeout = 600;
command = "${swaymsg} \"output * power off\"";
resumeCommand = "${swaymsg} \"output * power on\"";
}
# TODO: suspend after a longer while
];
};
systemd.user.services.swayidle = {
Service = {
# hack to make calling swaylock with /usr/bin/env work
# for both NixOS and non-NixOS
# See: https://github.com/nix-community/home-manager/blob/05649393ac1f34980a5cf6a6e89de77626c9182b/modules/services/swayidle.nix#L124-L125
Environment = mkForce [
"PATH=${makeBinPath [ pkgs.bash ]}:/usr/bin"
];
};
};
# fuzzy-finding application launcher
programs.fuzzel = {
enable = true;
settings = {
main = {
# in case you don't see it: that's the eyes emoji,
# followed by the U+FE0F "Variation selector-6" character.
# That magic character tells the text rendering system to use
# the colour version of the emoji, instead of the outline version.
# You can also force the outline version with U+FE0E "Variation selector-5".
prompt = "\"👀 \"";
font = "${themeFont.family}:size=${builtins.toString (builtins.floor themeFont.size)},Noto Color Emoji,Noto Emoji";
};
};
};
# the belly of the beast
wayland.windowManager.sway = {
enable = true;
package = let
origPkg = pkgs.sway;
nixGL = cfg.nixGLPackage;
in if nixGL != null then (pkgs.runCommand "sway-nixgl-wrapper" {} ''
mkdir $out
ln -s ${origPkg}/* $out
rm $out/bin
mkdir $out/bin
ln -s ${origPkg}/bin/* $out/bin/
rm $out/bin/sway
cat > $out/bin/sway <<EOF
. "\$HOME/.profile"
exec ${lib.getExe nixGL} ${origPkg}/bin/sway \$@
EOF
chmod +x $out/bin/sway
'') else origPkg;
systemd = {
# blue light remover. adjusts the red tint based on the time of day.
services.gammastep = {
enable = true;
xdgAutostart = true;
provider = "manual";
# https://maps.app.goo.gl/wrftdjP96bKDu5FW7
latitude = "52.36308";
longitude = "4.88372";
tray = true;
};
# starts a systemd-session.target systemd target in the config,
# so we can easily make various other programs (see above) start
# when sway starts
wrapperFeatures.gtk = true;
config = {
# the super key
modifier = "Mod4";
input."*" = {
# also called "Romanian (Programmers)" on Windows.
# it's the us keyboard + various stuff accessible with AltGr
# https://learn.microsoft.com/en-us/globalization/keyboards/kbdropr
xkb_layout = "ro";
};
input."type:touchpad" = {
tap = "enabled";
natural_scroll = "enabled";
};
output = {
"*" = {
bg = "${cfg.wallpaperPath} fill";
adaptive_sync = "on";
};
};
workspaceAutoBackAndForth = true;
startup = [
{ command = "/usr/libexec/polkit-gnome-authentication-agent-1"; }
{ command = lib.getExe' config.services.mako.package "mako"; }
{ command = "1password --silent"; }
{ command = lib.getExe' pkgs.emote "emote"; }
{ command = "systemctl --user restart waybar.service kanshi.service"; always = true; }
# does things if the computer is left untouched for a while
services.swayidle = let
swaymsg = "${config.wayland.windowManager.sway.package}/bin/swaymsg";
# if running nixos: make sure swaylock is enabled system-wide in the system config!
# if not: make sure you either have swaylock installed via the system package manager,
# or you have a valid PAM config for it.
# otherwise, it will not be able to unlock the screen!
swaylock = "/usr/bin/env swaylock";
swaylockCmd = "${swaylock} -c 000000 -fF";
in {
enable = true;
systemdTarget = "sway-session.target";
events = [
# make sure the screen is locked before going to sleep
{
event = "before-sleep";
command = swaylockCmd;
}
{
event = "lock";
command = swaylockCmd;
}
# stop the screen locker if loginctl says it's time to unlock
# (you can test by running loginctl unlock-session).
# regarding the sigusr1 thing, see swaylock(1).
{
event = "unlock";
command = "pkill -USR1 swaylock";
}
];
fonts = {
inherit (themeFont) style size;
names = [ themeFont.family ];
timeouts = [
{
timeout = 600;
command = "${swaymsg} \"output * power off\"";
resumeCommand = "${swaymsg} \"output * power on\"";
}
# TODO: suspend after a longer while
];
};
systemd.user.services.swayidle = {
Service = {
# hack to make calling swaylock with /usr/bin/env work
# for both NixOS and non-NixOS
# See: https://github.com/nix-community/home-manager/blob/05649393ac1f34980a5cf6a6e89de77626c9182b/modules/services/swayidle.nix#L124-L125
Environment = mkForce [
"PATH=${makeBinPath [pkgs.bash]}:/usr/bin"
];
};
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
};
# application menu
fuzzel = lib.getExe config.programs.fuzzel.package;
# control the currently playing media player
playerctl = lib.getExe pkgs.playerctl;
# control the volume
pamixer = lib.getExe pkgs.pamixer;
# control the brightness of the laptop's screen
brightnessctl = lib.getExe pkgs.brightnessctl;
# take screenshots and show notifications when they're taken
grimblast = lib.getExe pkgs.grimblast;
# emoji picker
emote = lib.getExe' pkgs.emote "emote";
foot = lib.getExe config.programs.foot.package;
wezterm = lib.getExe config.programs.wezterm.package;
volStep = toString 5;
brightStep = toString 5;
in lib.mkOptionDefault {
"${mod}+Return" = if cfg.terminal == "wezterm"
then "exec ${wezterm}"
else "exec ${foot}";
# fuzzel is enabled above, should be in path
"${mod}+d" = "exec ${fuzzel}";
"${mod}+ctrl+l" = "exec loginctl lock-session";
"XF86AudioPlay" = "exec ${playerctl} play-pause";
"XF86AudioPrev" = "exec ${playerctl} previous";
"XF86AudioNext" = "exec ${playerctl} next";
"XF86AudioStop" = "exec ${playerctl} stop";
"XF86AudioRaiseVolume" = "exec ${pamixer} --increase ${volStep}";
"XF86AudioLowerVolume" = "exec ${pamixer} --decrease ${volStep}";
"XF86AudioMute" = "exec ${pamixer} --toggle-mute";
"XF86AudioMicMute" = "exec ${pamixer} --default-source --toggle-mute";
"XF86MonBrightnessUp" = "exec ${brightnessctl} set ${brightStep}%+";
"XF86MonBrightnessDown" = "exec ${brightnessctl} set ${brightStep}%-";
"Print" = "exec ${grimblast} --notify copy screen";
"shift+Print" = "exec ${grimblast} --notify copy area";
"alt+Print" = "exec ${grimblast} --notify copy active";
"${mod}+comma" = "exec ${emote}";
};
bars = [];
window = {
titlebar = true;
border = 2;
};
colors = let
main = "#000000";
mainBorder = "#404040";
primary = "#ffffff";
primaryBorder = "#bababa";
secondary = "#00ff00";
in {
focused = {
background = primary;
border = primaryBorder;
childBorder = primaryBorder;
text = main;
indicator = primary;
};
unfocused = {
background = main;
border = mainBorder;
childBorder = mainBorder;
text = primary;
indicator = primary;
};
focusedInactive = {
background = main;
border = mainBorder;
childBorder = mainBorder;
text = secondary;
indicator = primary;
# fuzzy-finding application launcher
programs.fuzzel = {
enable = true;
settings = {
main = {
# in case you don't see it: that's the eyes emoji,
# followed by the U+FE0F "Variation selector-6" character.
# That magic character tells the text rendering system to use
# the colour version of the emoji, instead of the outline version.
# You can also force the outline version with U+FE0E "Variation selector-5".
prompt = "\"👀 \"";
font = "${themeFont.family}:size=${builtins.toString (builtins.floor themeFont.size)},Noto Color Emoji,Noto Emoji";
};
};
};
extraConfig = ''
title_align center
'';
# the belly of the beast
wayland.windowManager.sway = {
enable = true;
package = let
origPkg = pkgs.sway;
nixGL = cfg.nixGLPackage;
in
if nixGL != null
then
(pkgs.runCommand "sway-nixgl-wrapper" {} ''
mkdir $out
ln -s ${origPkg}/* $out
rm $out/bin
mkdir $out/bin
ln -s ${origPkg}/bin/* $out/bin/
rm $out/bin/sway
cat > $out/bin/sway <<EOF
. "\$HOME/.profile"
exec ${lib.getExe nixGL} ${origPkg}/bin/sway \$@
EOF
chmod +x $out/bin/sway
'')
else origPkg;
systemd = {
enable = true;
xdgAutostart = true;
};
# starts a systemd-session.target systemd target in the config,
# so we can easily make various other programs (see above) start
# when sway starts
wrapperFeatures.gtk = true;
config = {
# the super key
modifier = "Mod4";
input."*" = {
# also called "Romanian (Programmers)" on Windows.
# it's the us keyboard + various stuff accessible with AltGr
# https://learn.microsoft.com/en-us/globalization/keyboards/kbdropr
xkb_layout = "ro";
};
input."type:touchpad" = {
tap = "enabled";
natural_scroll = "enabled";
};
output = {
"*" = {
bg = "${cfg.wallpaperPath} fill";
adaptive_sync = "on";
};
};
workspaceAutoBackAndForth = true;
startup = [
{command = "/usr/libexec/polkit-gnome-authentication-agent-1";}
{command = lib.getExe' config.services.mako.package "mako";}
{command = "1password --silent";}
{command = lib.getExe' pkgs.emote "emote";}
{
command = "systemctl --user restart waybar.service kanshi.service";
always = true;
}
];
fonts = {
inherit (themeFont) style size;
names = [themeFont.family];
};
keybindings = let
mod = config.wayland.windowManager.sway.config.modifier;
# application menu
fuzzel = lib.getExe config.programs.fuzzel.package;
# control the currently playing media player
playerctl = lib.getExe pkgs.playerctl;
# control the volume
pamixer = lib.getExe pkgs.pamixer;
# control the brightness of the laptop's screen
brightnessctl = lib.getExe pkgs.brightnessctl;
# take screenshots and show notifications when they're taken
grimblast = lib.getExe pkgs.grimblast;
# emoji picker
emote = lib.getExe' pkgs.emote "emote";
foot = lib.getExe config.programs.foot.package;
wezterm = lib.getExe config.programs.wezterm.package;
volStep = toString 5;
brightStep = toString 5;
in
lib.mkOptionDefault {
"${mod}+Return" =
if cfg.terminal == "wezterm"
then "exec ${wezterm}"
else "exec ${foot}";
# fuzzel is enabled above, should be in path
"${mod}+d" = "exec ${fuzzel}";
"${mod}+ctrl+l" = "exec loginctl lock-session";
"XF86AudioPlay" = "exec ${playerctl} play-pause";
"XF86AudioPrev" = "exec ${playerctl} previous";
"XF86AudioNext" = "exec ${playerctl} next";
"XF86AudioStop" = "exec ${playerctl} stop";
"XF86AudioRaiseVolume" = "exec ${pamixer} --increase ${volStep}";
"XF86AudioLowerVolume" = "exec ${pamixer} --decrease ${volStep}";
"XF86AudioMute" = "exec ${pamixer} --toggle-mute";
"XF86AudioMicMute" = "exec ${pamixer} --default-source --toggle-mute";
"XF86MonBrightnessUp" = "exec ${brightnessctl} set ${brightStep}%+";
"XF86MonBrightnessDown" = "exec ${brightnessctl} set ${brightStep}%-";
"Print" = "exec ${grimblast} --notify copy screen";
"shift+Print" = "exec ${grimblast} --notify copy area";
"alt+Print" = "exec ${grimblast} --notify copy active";
"${mod}+comma" = "exec ${emote}";
};
bars = [];
window = {
titlebar = true;
border = 2;
};
colors = let
main = "#000000";
mainBorder = "#404040";
primary = "#ffffff";
primaryBorder = "#bababa";
secondary = "#00ff00";
in {
focused = {
background = primary;
border = primaryBorder;
childBorder = primaryBorder;
text = main;
indicator = primary;
};
unfocused = {
background = main;
border = mainBorder;
childBorder = mainBorder;
text = primary;
indicator = primary;
};
focusedInactive = {
background = main;
border = mainBorder;
childBorder = mainBorder;
text = secondary;
indicator = primary;
};
};
};
extraConfig = ''
title_align center
'';
};
};
};
}
}

View File

@ -1,63 +1,67 @@
{ config, pkgs, lib, ... }:
let
{
config,
pkgs,
lib,
...
}: let
cfg = config.homeModules.desktop.waybar;
inherit (config.homeModules.desktop.fonts) themeFont;
in
with lib; {
options = {
homeModules.desktop.waybar = {
enable = mkEnableOption "Enable Waybar";
systemdTarget = mkOption {
type = types.str;
description = "Enable Waybar as part of a systemd target";
example = "sway-session.target";