From 25011a33536c8d1cf061c75efe8b794536c63cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 2 Dec 2023 18:05:33 +0100 Subject: [PATCH] Add options for aliases So they can be added from extensions --- hm/common.nix | 17 +++-------------- hm/default.nix | 1 + hm/desktop.nix | 12 ++++++++++++ options.nix | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/hm/common.nix b/hm/common.nix index f291247..7f3f353 100644 --- a/hm/common.nix +++ b/hm/common.nix @@ -104,13 +104,6 @@ in # 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 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 @@ -141,11 +134,6 @@ in 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''; 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); # 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 @@ -153,6 +141,7 @@ in historyFile = "${config.xdg.cacheHome}/shell_history"; in { + home-manager.enable = true; bash = { enable = true; @@ -168,7 +157,7 @@ in historyFile = historyFile; historyFileSize = historySize; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - shellAliases = commonShellAliases; + shellAliases = commonShellAliases // config.frogeye.shellAliases; }; zsh = { enable = true; @@ -188,7 +177,7 @@ in expireDuplicatesFirst = true; }; sessionVariables = commonSessionVariables; - shellAliases = commonShellAliases; + shellAliases = commonShellAliases // config.frogeye.shellAliases; }; dircolors = { enable = true; diff --git a/hm/default.nix b/hm/default.nix index 4aa7b32..389d559 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -6,6 +6,7 @@ ./desktop.nix ./dev.nix ./extra.nix + ./ssh.nix ./style.nix ./vim.nix ]; diff --git a/hm/desktop.nix b/hm/desktop.nix index e78d47b..0f0a5c7 100644 --- a/hm/desktop.nix +++ b/hm/desktop.nix @@ -1,6 +1,18 @@ { pkgs, config, lib, ... }: { 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 = { enable = true; windowManager = { diff --git a/options.nix b/options.nix index 995cffa..6dc3379 100644 --- a/options.nix +++ b/options.nix @@ -18,6 +18,20 @@ fpga = lib.mkEnableOption "FPGA 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 = {