I was using Fedora previously where GNOME Keyring would be automatically unlocked if the LUKS passphrase is same as user’s login password. This is not happening with NixOS. I have following setting applied in configuration.nix
services.gnome.gnome-keyring.enable = true;
security.pam.services.gdm.enableGnomeKeyring = true;
Any way I can achieve this in NixOS?
Thanks.
1 Like
Thanks. I wish it would be merged soon. I hate typing my password thrice. Once for BIOS, another for LUKS and one more for GNOME.
I can see that the PR mentioned in the above thread have been merged:
master ← dawidd6:gdm-autologin-unlocks-keyring
opened 12:08PM - 20 Jan 24 UTC
## Description of changes
This change causes the default login keyring to aut… omatically unlock in situation where user has the same LUKS password as the keyring/user password.
With this we can enable autologin in GNOME the NixOS-way, switch to the new configuration, boot the system up, input LUKS password to decrypt drive and be dropped straight into desktop without annoying "Authentication required" popup for keyring unlocking (if keyring password matches LUKS password).
This is actually mimicking the configuration of PAM added in this commit upstream https://github.com/GNOME/gdm/commit/31ed6f2b3f1ab45ae07aad41c13a51ba91fd159d and in my opinion brings an UX improvement to NixOS on par with Fedora for example.
Note that I don't have much knowledge about PAM. I've just put some pieces together, tested if it works and made a PR.
Any suggestions are most welcomed, I would really like to get this _fix_ into nixpkgs.
## Things done
- Built on platform(s)
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [x] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [x] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [x] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.05 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) (or backporting [23.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2305.section.md) and [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
What would I need to add to my configuration in order to get it to work?
AIUI you need to set security.pam.services.login.enableGnomeKeyring. To skip the user login, use services.xserver.displayManager.gdm.autoLogin.
Hmm, doesn’t seem to work:
This is what I added since it said that some of the “paths” had changed:
services.displayManager.autoLogin = {
enable = true;
user = "myuser";
};
services.gnome.gnome-keyring.enable = true;
security.pam.services.login.enableGnomeKeyring = true;
For context: dotfiles/configuration.nix at 1d564385d4f142057d40eed023f843effc650953 · morten-b/dotfiles · GitHub
2 Likes
@morten-b any luck getting this to work? This post has a config, but it goes to tty for me - has all the login info, but I have to type Hyprland to get it go start and it doesn’t seem to unlock my keyring.
Its been unstable, sometimes i logs in as expexted, sometimes it goes to the tty, then opening the login screen. Don’t now why, so ended up just disable autologin.
Good to hear it’s not just me. It’d be nice if this was in a wiki or if there was another confirmation/example of a working config.
I just found another config listed here: nixos/gdm: autologin unlocks keyring when possible by dawidd6 · Pull Request #282317 · NixOS/nixpkgs · GitHub
And updated the package names for NixOS 25.05, as follows:
{ config, lib, pkgs, ... }:
{
# Auto login will attempt to unlock gnome keyring using LUKS passphrase.
# See https://github.com/NixOS/nixpkgs/pull/282317
boot.initrd.systemd.enable = lib.mkForce true;
security.pam.services.gdm-autologin.text = lib.mkForce ''
auth requisite pam_nologin.so
auth required pam_succeed_if.so uid >= 1000 quiet
${lib.optionalString config.security.pam.services.login.enableGnomeKeyring ''
auth [success=ok default=1] ${pkgs.gdm}/lib/security/pam_gdm.so
auth optional ${pkgs.gnome-keyring}/lib/security/pam_gnome_keyring.so
''}
auth required pam_permit.so
account sufficient pam_unix.so
password requisite pam_unix.so nullok yescrypt
session optional pam_keyinit.so revoke
session include login
'';
}
But it’s going to a tty login where I have to enter my username, password, and launch Hyprland manually. If I add getty.autologinUser = "guttermonk"; it fills out the username and password, but I still have to launch Hyprland manually. If anyone has a working config for 25.05, please share.