#| file: modules/nixos/shell.nix
{
lib,
config,
pkgs,
...
}:
let
cfg = config.mjm.shell;
in
{
imports = [ ../common/shell.nix ];
config =
lib.mkIf cfg.enable
<| lib.mkMerge [
{
<<basic-config>>
}
(lib.mkIf cfg.full.enable {
<<full-config>>
})
];
_class = "nixos";
}This module extends my common shell module for NixOS and nix-darwin with configuration that only works on NixOS.
Config in this section is enabled on all NixOS machines, including microVMs.
programs.fish.shellAliases.r = "run0"; programs.fish.interactiveShellInit = '' bind alt-s 'fish_commandline_prepend run0' '';
On NixOS systems, I use run0 rather than sudo. I have an alias "r" to make it even easier. I also override the Alt-S shortcut that normally prepends "sudo " at the front of the command so that it prepends "run0 " instead.
systemd.services =
let
cmd = "tide configure --auto --style=Classic --prompt_colors='16 colors' --show_time='24-hour format' --classic_prompt_separators=Angled --powerline_prompt_heads=Sharp --powerline_prompt_tails=Round --powerline_prompt_style='Two lines, character' --prompt_connection=Solid --powerline_right_prompt_frame=No --prompt_spacing=Compact --icons='Few icons' --transient=Yes";
in
{
"tide-configure@" = {
description = "Configure Tide Prompt for '%i'";
script = ''
${config.programs.fish.package}/bin/fish --command "${cmd}"
'';
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
User = "%i";
};
};
"tide-configure@root" = {
overrideStrategy = "asDropin";
enableDefaultPath = false;
wantedBy = [ "multi-user.target" ];
};
"tide-configure@mjm" = {
overrideStrategy = "asDropin";
enableDefaultPath = false;
wantedBy = [ "multi-user.target" ];
};
};I use a systemd service to configure my shell prompt for both the root and mjm users. This ensures they stay in sync and also that the shell gets configured even on machines like microVMs where I don't run home-manager. I may regret doing it this way if it causes too much churn on those VMs though, as this introduces a thing that can change and cause every single VM to need to restart for something pretty inconsequential.
environment.variables.SYSTEMD_RUN_SHELL_PROMPT_PREFIX = "";
I couldn't find a way for the Tide prompt to not look weird with the little rocket ship prefix that run0 puts in front of the prompt, so I'm just disabling that.
Config in this section is not enabled in microVMs.
environment.systemPackages = lib.attrValues {
inherit (pkgs)
file
pciutils
usbutils
;
};These are utilities that I like to have installed by default on NixOS machines.
programs.zoxide.enable = true;
zoxide provides a nice "z" shell command to jump to recent directories based on a fuzzy match of the path. For instance, I usually run "z conf" to cd to my nix-config checkout, or "z pkgs" to cd to my nixpkgs checkout.
programs.yazi.enable = true;
programs.yazi.flavors.dracula = "${pkgs.sources.yazi-flavors}/dracula.yazi";
programs.yazi.settings.theme.flavor = {
light = "dracula";
dark = "dracula";
};yazi is a pretty nice TUI file manager. I'll use it sometimes to move a bunch of files around or explore the built contents of a Nix derivation.
text/gemini;lang=en-USThis content has been proxied by September (UNKNO).