Add options for aliases

So they can be added from extensions
This commit is contained in:
Geoffrey Frogeye 2023-12-02 18:05:33 +01:00
parent e01c454d68
commit 25011a3353
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
4 changed files with 30 additions and 14 deletions

View file

@ -104,13 +104,6 @@ in
# ll = "ls -l"; # Disabled because would overwrite the colored one # ll = "ls -l"; # Disabled because would overwrite the colored one
# la = "ls -la"; # Eh maybe it's not that bad, but for now let's keep compatibility # la = "ls -la"; # Eh maybe it's not that bad, but for now let's keep compatibility
s = "sudo -s -E"; s = "sudo -s -E";
# n = "$HOME/.config/i3/terminal & disown"; # Not used anymore since alacritty daemon mode doesn't preserve environment variables
x = "startx ${config.xdg.configHome}/xinitrc; logout";
nx = "nvidia-xrun ${config.xdg.configHome}/xinitrc; sudo systemctl start nvidia-xrun-pm; logout";
# TODO Put in display.nix
# Was also thinking of not storing the config in .config and use nix-store instead,
# but maybe it's a bad idea as home-manager switch doesn't replace aliases in running shells
# FIXME Is it still relevant with NixOS?
# Give additional config to those programs, and not have them in my path # Give additional config to those programs, and not have them in my path
@ -141,11 +134,6 @@ in
newestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | tail''; newestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | tail'';
oldestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | head''; oldestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | head'';
tracefiles = ''${pkgs.strace}/bin/strace -f -t -e trace=file''; tracefiles = ''${pkgs.strace}/bin/strace -f -t -e trace=file'';
} // lib.optionalAttrs config.frogeye.desktop.xorg {
noise = ''${pkgs.sox}/bin/play -c 2 -n synth $'' + ''{1}noise'';
beep = ''${pkgs.sox}/bin/play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null'';
# FIXME ALSA lib dlmisc.c:337:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (/nix/store/9b06fxbvm07iy9f9dvi5vk2iy9pk8hyz-alsa-lib-1.2.8/lib/alsa-lib/libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)
} // lib.attrsets.mergeAttrsList (map (p: { "${p}" = "HOME=${config.xdg.cacheHome}/junkhome ${p}"; }) treatsHomeAsJunk); } // lib.attrsets.mergeAttrsList (map (p: { "${p}" = "HOME=${config.xdg.cacheHome}/junkhome ${p}"; }) treatsHomeAsJunk);
# TODO Maybe make nixpkg wrapper instead? So it also works from dmenu # TODO Maybe make nixpkg wrapper instead? So it also works from dmenu
# Could also accept my fate... Home-manager doesn't necessarily make it easy to put things out of the home directory # Could also accept my fate... Home-manager doesn't necessarily make it easy to put things out of the home directory
@ -153,6 +141,7 @@ in
historyFile = "${config.xdg.cacheHome}/shell_history"; historyFile = "${config.xdg.cacheHome}/shell_history";
in in
{ {
home-manager.enable = true; home-manager.enable = true;
bash = { bash = {
enable = true; enable = true;
@ -168,7 +157,7 @@ in
historyFile = historyFile; historyFile = historyFile;
historyFileSize = historySize; historyFileSize = historySize;
historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; historyControl = [ "erasedups" "ignoredups" "ignorespace" ];
shellAliases = commonShellAliases; shellAliases = commonShellAliases // config.frogeye.shellAliases;
}; };
zsh = { zsh = {
enable = true; enable = true;
@ -188,7 +177,7 @@ in
expireDuplicatesFirst = true; expireDuplicatesFirst = true;
}; };
sessionVariables = commonSessionVariables; sessionVariables = commonSessionVariables;
shellAliases = commonShellAliases; shellAliases = commonShellAliases // config.frogeye.shellAliases;
}; };
dircolors = { dircolors = {
enable = true; enable = true;

View file

@ -6,6 +6,7 @@
./desktop.nix ./desktop.nix
./dev.nix ./dev.nix
./extra.nix ./extra.nix
./ssh.nix
./style.nix ./style.nix
./vim.nix ./vim.nix
]; ];

View file

@ -1,6 +1,18 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
{ {
config = lib.mkIf config.frogeye.desktop.xorg { config = lib.mkIf config.frogeye.desktop.xorg {
frogeye.shellAliases = {
noise = ''${pkgs.sox}/bin/play -c 2 -n synth $'' + ''{1}noise'';
beep = ''${pkgs.sox}/bin/play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null'';
# FIXME ALSA lib dlmisc.c:337:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (/nix/store/9b06fxbvm07iy9f9dvi5vk2iy9pk8hyz-alsa-lib-1.2.8/lib/alsa-lib/libasound_module_pcm_pulse.so: cannot open shared object file: No such file or directory)
# n = "$HOME/.config/i3/terminal & disown"; # Not used anymore since alacritty daemon mode doesn't preserve environment variables
x = "startx ${config.xdg.configHome}/xinitrc; logout";
nx = "nvidia-xrun ${config.xdg.configHome}/xinitrc; sudo systemctl start nvidia-xrun-pm; logout";
# Was also thinking of not storing the config in .config and use nix-store instead,
# but maybe it's a bad idea as home-manager switch doesn't replace aliases in running shells
# FIXME Is it still relevant with NixOS?
};
xsession = { xsession = {
enable = true; enable = true;
windowManager = { windowManager = {

View file

@ -18,6 +18,20 @@
fpga = lib.mkEnableOption "FPGA dev stuff"; fpga = lib.mkEnableOption "FPGA dev stuff";
python = lib.mkEnableOption "Python dev stuff"; python = lib.mkEnableOption "Python dev stuff";
}; };
shellAliases = lib.mkOption {
default = { };
example = lib.literalExpression ''
{
ll = "ls -l";
".." = "cd ..";
}
'';
description = ''
An attribute set that maps aliases (the top level attribute names in
this option) to command strings or directly to build outputs.
'';
type = lib.types.attrsOf lib.types.str;
};
}; };
config = { config = {