From 622b1a5b20f342123bc387d4600f87815009c333 Mon Sep 17 00:00:00 2001 From: willemml Date: Sat, 7 Dec 2024 06:23:17 -0800 Subject: [PATCH] lemurs dm --- common/system.nix | 2 +- flake.nix | 6 +- home/default.nix | 3 +- home/linux/default.nix | 2 - home/linux/fonts.nix | 15 +++-- home/linux/hyprland.nix | 37 ++++++----- home/packages.nix | 3 +- home/programs/helix.nix | 4 +- nixos/hosts/glassbox.nix | 2 +- nixos/modules/lemurs.nix | 120 +++++++++++++++++++++++++++++++++++ nixos/profiles/hyprland.nix | 1 + nixos/profiles/nvidiagpu.nix | 9 ++- packages/default.nix | 18 ++++++ packages/lemurs.nix | 20 ++++++ 14 files changed, 202 insertions(+), 40 deletions(-) create mode 100644 nixos/modules/lemurs.nix create mode 100644 packages/lemurs.nix diff --git a/common/system.nix b/common/system.nix index eb93de0..85fac37 100644 --- a/common/system.nix +++ b/common/system.nix @@ -25,7 +25,7 @@ nix = { package = pkgs.nix; - settings.experimental-features = ["nix-command" "flakes" "repl-flake"]; + settings.experimental-features = ["nix-command" "flakes"]; settings.trusted-users = ["root" "willem"]; }; diff --git a/flake.nix b/flake.nix index 0812c60..434d93b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "Willem's Nix configurations"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?rev=7d0d974fc21f02dfeed7ef098d8faf0195162949"; + nixpkgs.url = "github:nixos/nixpkgs"; darwin.url = "github:willemml/nix-darwin?ref=feat/networking.hosts"; #darwin.url = "git+file:///Users/willem/dev/nix-darwin"; @@ -35,10 +35,6 @@ stylix.url = "github:danth/stylix"; stylix.inputs.nixpkgs.follows = "nixpkgs"; - - nixd.url = "github:nix-community/nixd"; - nixd.inputs.nixpkgs.follows = "nixpkgs"; - nixd.inputs.flake-parts.follows = "flake-parts"; }; outputs = { diff --git a/home/default.nix b/home/default.nix index d93d552..d96ddfd 100644 --- a/home/default.nix +++ b/home/default.nix @@ -2,7 +2,6 @@ inputs, globals, config, - pkgs, ... }: { imports = [ @@ -31,7 +30,7 @@ base = globals.language; }; - sessionVariables = rec { + sessionVariables = { DOTDIR = "${config.home.homeDirectory}/.config/dotfiles.nix"; EDITOR = "hx"; VISUAL = "hx"; diff --git a/home/linux/default.nix b/home/linux/default.nix index dbc93df..c6a1b81 100644 --- a/home/linux/default.nix +++ b/home/linux/default.nix @@ -15,8 +15,6 @@ }; home.packages = with pkgs; [ - gcc-arm-embedded - killall ]; home.homeDirectory = "/home/willem"; diff --git a/home/linux/fonts.nix b/home/linux/fonts.nix index 60cf1d3..f892430 100644 --- a/home/linux/fonts.nix +++ b/home/linux/fonts.nix @@ -1,10 +1,11 @@ {pkgs, ...}: { fonts.fontconfig.enable = true; - home.packages = with pkgs; [ - rPackages.fontawesome - nerdfonts - ubuntu_font_family - noto-fonts-cjk-sans - noto-fonts - ]; + home.packages = with pkgs; + [ + rPackages.fontawesome + ubuntu_font_family + noto-fonts-cjk-sans + noto-fonts + ] + ++ builtins.filter lib.attrsets.isDerivation (builtins.attrValues pkgs.nerd-fonts); } diff --git a/home/linux/hyprland.nix b/home/linux/hyprland.nix index fd0a60b..6a0001b 100644 --- a/home/linux/hyprland.nix +++ b/home/linux/hyprland.nix @@ -22,6 +22,7 @@ in { then firefox-wv else firefox ) + yarg polkit-kde-agent lxappearance pipewire @@ -30,6 +31,7 @@ in { qt6ct rofi-wayland xdg-desktop-portal + xdg-desktop-portal-gtk inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland ] ++ ( @@ -45,23 +47,23 @@ in { # size = 24; # }; - # gtk = { - # enable = true; + gtk = { + # enable = true; - # theme = { - # package = pkgs.flat-remix-gtk; - # name = "Flat-Remix-GTK-Grey-Darkest"; - # }; - # iconTheme = { - # package = pkgs.adwaita-icon-theme; - # name = "Adwaita"; - # }; - # font = { - # name = "Sans"; - # size = 12; - # package = pkgs.dejavu_fonts; - # }; - # }; + # theme = { + # package = pkgs.flat-remix-gtk; + # name = "Flat-Remix-GTK-Grey-Darkest"; + # }; + iconTheme = { + package = pkgs.adwaita-icon-theme; + name = "Adwaita"; + }; + # font = { + # name = "Sans"; + # size = 12; + # package = pkgs.dejavu_fonts; + # }; + }; # notifications daemon services.mako.enable = true; @@ -76,7 +78,7 @@ in { rounding = 10; # save battery - drop_shadow = false; + # drop_shadow = false; blur.enabled = false; }; @@ -190,6 +192,7 @@ in { "$mod, right, resizeactive, 10 0" "$mod, up, resizeactive, 0 -10" "$mod, down, resizeactive, 0 10" + "$mod, mouse:272, movewindow" ]; input = { diff --git a/home/packages.nix b/home/packages.nix index 47245a6..839e093 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -12,8 +12,7 @@ latest.toolchain targets.thumbv7em-none-eabihf.latest.rust-std ]); - nixd-upstream = inputs.nixd.packages.${pkgs.system}.default; - extras = [fenix-rust nixd-upstream] ++ node-packages; + extras = [fenix-rust] ++ node-packages; in { home.packages = (with pkgs; [ diff --git a/home/programs/helix.nix b/home/programs/helix.nix index ae6f4df..35bf63a 100644 --- a/home/programs/helix.nix +++ b/home/programs/helix.nix @@ -9,11 +9,11 @@ { name = "nix"; auto-format = true; - language-servers = ["nixd-lsp"]; + # language-servers = ["nixd-lsp"]; formatter = {command = "${pkgs.alejandra}/bin/alejandra";}; } ]; - languages.language-server.nixd-lsp.command = "${inputs.nixd.packages.${pkgs.system}.default}/bin/nixd"; + # languages.language-server.nixd-lsp.command = "${inputs.nixd.packages.${pkgs.system}.default}/bin/nixd"; settings.editor.line-number = "relative"; settings.keys = { normal = { diff --git a/nixos/hosts/glassbox.nix b/nixos/hosts/glassbox.nix index 3d5e170..8848932 100644 --- a/nixos/hosts/glassbox.nix +++ b/nixos/hosts/glassbox.nix @@ -31,7 +31,7 @@ ]; }; - environment.systemPackages = with pkgs; [virt-manager libvirt]; + environment.systemPackages = with pkgs; [virt-manager libvirt virtiofsd]; virtualisation.spiceUSBRedirection.enable = true; diff --git a/nixos/modules/lemurs.nix b/nixos/modules/lemurs.nix new file mode 100644 index 0000000..4ef10c4 --- /dev/null +++ b/nixos/modules/lemurs.nix @@ -0,0 +1,120 @@ +# Thanks https://github.com/auvred/nixos-config/blob/df45668785adb931641a48121e554d3b45c3f7bd/nixos-modules/lemurs/default.nix +{ + config, + inputs, + pkgs, + ... +}: let + virtualTerminalNumber = 2; + pamServiceName = "lemurs"; + hyprpkgs = inputs.hyprland.packages.${pkgs.system}; +in { + systemd.services.lemurs = { + aliases = ["display-manager.service"]; + after = ["systemd-user-sessions.service" "plymouth-quit-wait.service" "getty@tty${toString virtualTerminalNumber}.service"]; + wantedBy = ["multi-user.target"]; + serviceConfig = let + lemursConfig = (pkgs.formats.toml {}).generate "lemurs-config.toml" { + tty = virtualTerminalNumber; + pam_service = pamServiceName; + system_shell = "${pkgs.bash}/bin/bash"; + max_display_length = 15; + + power_controls.base_entries = [ + { + hint = "Shutdown"; + hint_color = "dark gray"; + hint_modifiers = ""; + key = "F1"; + cmd = "${pkgs.systemd}/bin/systemctl poweroff"; + } + { + hint = "Reboot"; + hint_color = "dark gray"; + hint_modifiers = ""; + key = "F2"; + cmd = "${pkgs.systemd}/bin/systemctl reboot"; + } + ]; + wayland = { + wayland_sessions_path = "${hyprpkgs.hyprland}/share/wayland-sessions"; + }; + }; + in { + ExecStart = "${pkgs.lemurs}/bin/lemurs --config ${lemursConfig}"; + StandardInput = "tty"; + TTYPath = "/dev/tty${toString virtualTerminalNumber}"; + TTYReset = "yes"; + TTYVHangup = "yes"; + Type = "idle"; + }; + }; + + security.pam.services = { + ${pamServiceName}.text = '' + auth include login + account include login + session include login + password include login + ''; + # See https://github.com/coastalwhite/lemurs/issues/166 + login = { + setLoginUid = false; + # I want my systemd-logind(8) session to access to seat0 (the default seat + # with all hardware devices). + # At the very least, I want to be able to change backlight without tweaking + # udev rules and directly accessing /sys/class/backlight. + # See systemd-logind(8), sd-login(3), org.freedesktop.login1(5), pam_systemd(8) + # for more details. + # + # ----- + # + # pam_systemd(8) tries to get XDG_SEAT and XDG_VTNR variables from environment. + # https://github.com/systemd/systemd/blob/main/src/login/pam_systemd.c#L967-L968 + # + # It passes seat and vntr to the + # org.freedesktop.login1 + # -> /org/freedesktop/login1 + # -> org.freedesktop.login1.Manager + # -> CreateSession(in s seat_id, in u vtnr, ...) + # + # See org.freedesktop.login1(5) for more details. + # + # AFAIK lemurs doesn't pass either XDG_SEAT or XDG_VTNR to the PAM process. + # See also https://github.com/1wilkens/pam/issues/13. + # + # pam_env(8) PAM module is located before pam_systemd(8) in /etc/pam.d/login. + # So variables set by pam_env are visible to pam_systemd. + rules.session.extra-env = { + args = [ + ("conffile=" + + (pkgs.writeTextFile { + name = "pam-extra-env-conffile"; + text = '' + XDG_SEAT DEFAULT="seat0" + XDG_VTNR DEFAULT="2" + ''; + })) + "readenv=0" + ]; + control = "required"; + enable = true; + modulePath = "${pkgs.pam}/lib/security/pam_env.so"; + order = config.security.pam.services.login.rules.session.env.order + 10; + }; + }; + }; + + # Useful for pam_systemd debugging + # systemd.managerEnvironment = {SYSTEMD_LOG_LEVEL = "debug";}; + # systemd.globalEnvironment = { + # SYSTEMD_LOG_LEVEL = "debug"; + # }; + # systemd.services.systemd-logind.environment = { + # SYSTEMD_LOG_LEVEL = "debug"; + # }; + # security.pam.services.login.rules.session.unix.args = ["debug"]; + # security.pam.services.login.rules.session.systemd.args = ["debug"]; + # security.pam.services.systemd-user.rules.session.unix.args = ["debug"]; + # security.pam.services.systemd-user.rules.session.systemd.args = ["debug"]; +} diff --git a/nixos/profiles/hyprland.nix b/nixos/profiles/hyprland.nix index 23cf903..2aafeb1 100644 --- a/nixos/profiles/hyprland.nix +++ b/nixos/profiles/hyprland.nix @@ -8,6 +8,7 @@ in { imports = [ ./gui.nix ../modules/polkit.nix + ../modules/lemurs.nix ]; programs.hyprland.enable = true; diff --git a/nixos/profiles/nvidiagpu.nix b/nixos/profiles/nvidiagpu.nix index 01d71d5..afe9a13 100644 --- a/nixos/profiles/nvidiagpu.nix +++ b/nixos/profiles/nvidiagpu.nix @@ -1,7 +1,12 @@ -{...}: { +{ + config, + pkgs, + ... +}: { hardware.graphics.enable = true; hardware.nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.beta; modesetting.enable = true; powerManagement.enable = false; powerManagement.finegrained = false; @@ -9,4 +14,6 @@ open = false; nvidiaSettings = true; }; + + services.xserver.videoDrivers = ["nvidia"]; } diff --git a/packages/default.nix b/packages/default.nix index 225ed76..4f46f0b 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -4,4 +4,22 @@ final: prev: { firefox-wv = prev.firefox.override (old: { extraPrefsFiles = ["${final.widevine-installer}/conf/gmpwidevine.js"]; }); + # Thanks https://github.com/auvred/nixos-config/blob/df45668785adb931641a48121e554d3b45c3f7bd/overlays/lemurs/default.nix + # The latest published version (0.3.2) doesn't contain a following patches: + # - https://github.com/coastalwhite/lemurs/commit/ef4b42de1391f3d35d7827130d20bc57d06198f9 + # - https://github.com/coastalwhite/lemurs/commit/849e7cea87f3567be7cec403a2a603b8370e351c + lemurs = prev.lemurs.override { + rustPlatform.buildRustPackage = args: + final.rustPlatform.buildRustPackage (args + // { + patches = []; + src = prev.fetchFromGitHub { + owner = "coastalwhite"; + repo = "lemurs"; + rev = "1d4be7d0c3f528a0c1e9326ac77f1e8a17161c83"; + hash = "sha256-t/riJpgy0bD5CU8Zkzket4Gks2JXXSLRreMlrxlok0c="; + }; + cargoHash = "sha256-hKeJaIGUZpbuca3IPN1Uq4bamgImfYNvCRiVDbriHPA="; + }); + }; } diff --git a/packages/lemurs.nix b/packages/lemurs.nix new file mode 100644 index 0000000..1ea9715 --- /dev/null +++ b/packages/lemurs.nix @@ -0,0 +1,20 @@ +let + lacrosVersion = "120.0.6098.0"; +in + {pkgs, ...}: + pkgs.stdenv.mkDerivation { + name = "widevine"; + version = ""; + buildInputs = with pkgs; [curl widevine-installer]; + + src = pkgs.fetchurl { + urls = ["https://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/chromeos-lacros-arm64-squash-zstd-${lacrosVersion}"]; + hash = "sha256-OKV8w5da9oZ1oSGbADVPCIkP9Y0MVLaQ3PXS3ZBLFXY="; + }; + + unpackPhase = "true"; + installPhase = '' + mkdir -p "$out/" + COPY_CONFIGS=0 INSTALL_BASE="$out" DISTFILES_BASE="file://$src" widevine-installer + ''; + }