Framework and NixOS - Day Two
2024-6-12 13:23:18 Author: 0xda.de(查看原文) 阅读量:17 收藏

In order to start making better use of my laptop, I need to get a little more moved in. This means things like 1Password, Tailscale, fixing my display resolution, and customizing my Hyprland config to remove that annoying warning message.

Installing Tailscale

While 1Password and Obsidian are a little more clearly user-space packages, I want Tailscale at the system level, because I’d ideally like it to start when the device starts, regardless of if the user has logged in yet or not. This is because there may be times where I want to remotely access my laptop via ssh, perhaps from another laptop, and I may want/need to reboot my laptop remotely, so I want it to come back up after reboot.

Installing Tailscale as a system package is pretty easy, I just added tailscale to my environment.systemPackages in ~/nixcfg/hosts/serenity/configuration.nix. Unfortunately I can’t actually login and get my device connected to my Tailnet yet, because I don’t know my google password, and I prefer to keep it that way.

Installing 1Password

1Password is much more clearly a user-space program, as I said previously, so I’m going to install it in my home manager configuration, ~/nixcfg/home.nix.

But when I added _1password-gui to my list of packages and tried to rebuild, I was met with an error about unfree packages. Apparently home-manager doesn’t share the allowUnfree setting from my system configuration, which I had set to true from the initial device setup.

This error caused me to think to myself about how much I want to allow unfree software into my system. I love 1Password, it has easily been the best password manager experience I’ve had, and I’ve used Keepass, Lastpass, and Bitwarden before switching to 1Password. So I don’t think I’m going to abandon my preferred password manager just because it isn’t free.

But to avoid accidentally including a bunch of unexpected unfree software in the future, I want to be very explicit about which unfree packages I’m going to allow. So in the top of my ~/nixcfg/home.nix file, I added the following:

{
  nixpkgs = {
    config = {
      allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
        "1password"
      ];
    };
  };
  ...
}

Now I have 1password installed, and have a pattern for explicitly including other unfree software. I opened up the app (by running 1password in my terminal) and used the “Scan setup code” option to get the device setup.

The resolution of this app is all sorts of messed up, though, so I’ll probably have to figure out how to improve that.

Removing that annoying Hyprland autogenerated config warning

Up until now, my desktop has had a yellow warning bar across the top, indicating that I’m using the autogenerated configuration. Removing this is as simple as managing my hyprland config and changing a setting. But instead of just changing the file in my home directory, which would result in system state change, I am going to copy .config/hypr/hyprland.conf into my home-manager configuration.

It’s in my repository as ~/nixcfg/home/dade/.config/hypr/hyprland.conf and I use home.file inside my home.nix file to set it up, like so:

home.file = {
  ".config/hypr/hyprland.conf".source = home/dade/.config/hypr/hyprland.conf
};

Once this is setup, you have to do a nixos-rebuild switch --flake to update your hyprland config. Make sure you commit the hyprland.conf file into your repository, otherwise the rebuild will ignore it and error out.

Now I can modify the ~/nixcfg/home/dade/.config/hypr/hyprland.conf file and remove the autogenerated=1 line, which will remove the warning. Time to do another rebuild.

Setting up an application launcher

The default hyprland experience has me just running commands in my terminal, but I want a way to launch graphical applications that doesn’t just leave the terminal window open as well. Enter the application launcher.

There are some existing resources on this, including the Hyprland documentation as well as this Vimjoyer video about Nixos and Hyprland.

It defaults to wofi but I’m switching to rofi which is a wayland native app launcher. The default $menu variable in hyprland.conf can be changed to rofi -show drun -show-icons after adding rofi to your environment. Make sure to note that rofi uses single dashes for argument names, not double dashes.

I added rofi-wayland to my ~/nixcfg/hosts/serenity/configuration.nix environment.systemPackages, though I think it would probably work fine as a package in my home-manager config as well. It just seems like the sort of thing that is more specific to my particular usage of Hyprland on this host, and not something that I’d necessarily want in all of my home configurations across all devices. I’m sure I can setup some variables for this later, but I am trying not to overwhelm myself too much in my pursuit of getting a functional system.

Setting up a status bar

For a menu/status bar across the screen, I’m going to use waybar – another wayland native package. It’s the first status bar in the Hyprland documentation, and it seems pretty easy to get working. It’s already referenced in a commented out block of my hyprland.conf file, so I just need to make sure it’s installed and then replicate an autostart command in my conf file for when hyprland starts.

Add waybar to ~/nixcfg/hosts/serenity/configuration.nix environment.systemPackages. This, like rofi, seems like something that is probably fine to have in my home-manager configuration instead of my host configuration, but I’m okay with blurring the lines a bit right now.

After adding waybar to my system packages, I also need to update ~/nixcfg/home/dade/.config/hypr/hyprland.conf and add the following line – I added it under the AUTOSTART section header, but technically you should just be able to add it anywhere.

exec-once = waybar

There’s already a commented out line that starts waybar in this section, but it also starts hyprpaper and firefox, and I don’t want firefox to start every time I login to my desktop.

I am curious about hyprpaper, though. But first, my waybar looks terrible, all the icons are broken. What’s going on with that.

Fixing my Waybar Fonts

A bit of searching around turned up a reddit thread where someone is complaining about a similar problem, and someone mentions that otf-font-awesome is the default font used by waybar. In Nixpkgs, this appears to be the font-awesome package. So let’s give that a try.

Fonts are a little different than packages like waybar and rofi, though. I could see myself wanting font-awesome icons available across many machines, regardless if I am using waybar or not. So I am going to install it into my ~/nixcfg/home.nix config instead of my host config. Inside home.packages, I added the following:

home.packages = with pkgs; [
  ...
  font-awesome
];

After rebuilding my config, I exited Hyprland with SUPER+m, and then logged back in. When I logged back in, waybar started automatically and had the correct fonts. Or at least, mostly. There’s one more icon that doesn’t show up, and it’s next to a 100% indicator. Hovering it does not tell me what it is, and while trying to figure it out, I just learned that my mute and volume control fn keys don’t work, nor does my screen brightness utility. Add those to the things left to fix. Eventually I’ll come back and read about the waybar configuration, which will help me figure out what the modules are that I don’t recognize.

A new (display) resolution

When I launch an application like 1Password, the resolution is really bad. My terminal looks fine, but anything with finer detail looks bad. This is surely just a Hyprland setting, since it didn’t happen with graphical windows in Budgie. After a bit of googling, I found a reddit post of someone who had a similar problem with their display resolution on r/hyprland. I followed the top comment and modified my monitor configuration in ~/nixcfg/home/dade/.config/hypr/hyprland.conf, like so.

Before

monitor=,preffered,auto,auto

After

monitor=,highres,auto,1

After rebuilding my configuration, I closed hyprland and launched it again, then used rofi (via SUPER+r) to launch 1Password, and now it looks like a normal resolution that I’d expect. Perfect.

Fixing the reboot/shutdown issue

Apparently I picked a bad time to do my install, the kernel version that was installed is what was causing my inability to use the reboot and shutdown commands. As a reminder, the shutdown and reboot commands have been completing the operating system shutdown, but not correctly signaling the hardware to actually power off or restart.

Thankfully, someone replied to my post on mastodon sharing yesterday’s endeavors, and theyrecommended updating to the latest kernel version, which should fix the reboot/shutdown problem. So I gave it a shot this evening and it worked. I modified ~/nixcfg/hosts/serenity/configuration.nix and added this line towards the top, under the other boot settings.

boot.kernelPackages = pkgs.linuxPackages_latest;

I rebuilt my config and typed reboot. Nothing happened. Of course nothing happened. I’m not using the new kernel yet. I hard powered off my device, then powered back up. I logged in and typed “reboot” into my terminal, and sure enough, it rebooted correctly. Finally. I did the same process and made sure shutdown worked, and now I’m good to go.

Not a very satisfying result, to be honest. “Just update to the latest kernel” means it was a kernel regression or something, which is silly.

That’s a wrap

I’m going to go ahead and close this post up at the end of day 2 with my laptop. There’s still a lot left to do, but I am in a much more comfortably usable position now for the short term. It’ll probably be a few weeks until my next update in this series, as I’m pretty busy the next week and a half or so and won’t have time to work on it.


文章来源: https://0xda.de/blog/2024/06/framework-and-nixos-day-two/
如有侵权请联系:admin#unsafe.sh