diff --git a/hm/common.nix b/hm/common.nix index 5108f09..d4000b8 100644 --- a/hm/common.nix +++ b/hm/common.nix @@ -1,22 +1,4 @@ { pkgs, config, lib, ... }: -let - direnv = { - # Environment variables making programs stay out of $HOME, but also needing we create a directory for them - CARGOHOME = "${config.xdg.cacheHome}/cargo"; # There are config in there that we can version if one want - CCACHE_DIR = "${config.xdg.cacheHome}/ccache"; # The config file alone seems to be not enough - DASHT_DOCSETS_DIR = "${config.xdg.cacheHome}/dash_docsets"; - GOPATH = "${config.xdg.cacheHome}/go"; - GRADLE_USER_HOME = "${config.xdg.cacheHome}/gradle"; - MIX_ARCHIVES = "${config.xdg.cacheHome}/mix/archives"; - MONO_GAC_PREFIX = "${config.xdg.cacheHome}/mono"; - npm_config_cache = "${config.xdg.cacheHome}/npm"; - PARALLEL_HOME = "${config.xdg.cacheHome}/parallel"; - TERMINFO = "${config.xdg.configHome}/terminfo"; - WINEPREFIX = "${config.xdg.stateHome}/wineprefix/default"; - YARN_CACHE_FOLDER = "${config.xdg.cacheHome}/yarn"; - # TODO Some of that stuff is not really relavant any more - }; -in { nixpkgs.config.allowUnfree = true; @@ -30,7 +12,6 @@ in programs = let - commonRc = lib.strings.concatLines (map (d: "mkdir -p ${d}") (builtins.attrValues direnv)); # TODO Those directory creations should probably done on home-manager activation commonSessionVariables = { TIME_STYLE = "+%Y-%m-%d %H:%M:%S"; @@ -46,22 +27,6 @@ in # Fzf FZF_COMPLETION_OPTS = "${lib.strings.concatStringsSep " " config.programs.fzf.fileWidgetOptions}"; }; - treatsHomeAsJunk = [ - # Programs that think $HOME is a reasonable place to put their junk - # and don't allow the user to change those questionable choices - "adb" - "audacity" - "binwalk" # Should use .config according to the GitHub code though - "cabal" # TODO May have options but last time I tried it it crashed - "cmake" - "ddd" - "ghidra" - "itch" - "simplescreenrecorder" # Easy fix https://github.com/MaartenBaert/ssr/blob/1556ae456e833992fb6d39d40f7c7d7c337a4160/src/Main.cpp#L252 - "vd" - "wpa_cli" - # TODO Maybe we can do something about node-gyp - ]; commonShellAliases = { # Replacement commands ls = "lsd"; @@ -96,7 +61,6 @@ in # Give additional config to those programs, and not have them in my path bower = "bower --config.storage.packages=${config.xdg.cacheHome}/bower/packages --config.storage.registry=${config.xdg.cacheHome}/bower/registry --config.storage.links=${config.xdg.cacheHome}/bower/links"; - gdb = "gdb -x ${config.xdg.configHome}/gdbinit"; iftop = "iftop -c ${config.xdg.configHome}/iftoprc"; lmms = "lmms --config ${config.xdg.configHome}/lmmsrc.xml"; @@ -122,9 +86,7 @@ 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.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 + }; historySize = 100000; historyFile = "${config.xdg.stateHome}/shell_history"; in @@ -133,13 +95,10 @@ in home-manager.enable = true; bash = { enable = true; - bashrcExtra = lib.strings.concatLines [ - commonRc - '' - shopt -s expand_aliases - shopt -s histappend - '' - ]; + bashrcExtra = '' + shopt -s expand_aliases + shopt -s histappend + ''; sessionVariables = commonSessionVariables; historySize = historySize; historyFile = historyFile; @@ -153,10 +112,7 @@ in enableCompletion = true; syntaxHighlighting.enable = true; historySubstringSearch.enable = true; - initExtra = lib.strings.concatLines [ - commonRc - (builtins.readFile ./zshrc.sh) - ]; + initExtra = builtins.readFile ./zshrc.sh; defaultKeymap = "viins"; history = { size = historySize; @@ -179,7 +135,8 @@ in settings = { size = "short"; }; - colors = { # Base16 only, so it reuses the current theme. + colors = { + # Base16 only, so it reuses the current theme. date = { day-old = 4; hour-old = 6; older = 5; }; git-status = { conflicted = 14; default = 13; deleted = 1; ignored = 13; modified = 3; new-in-index = 2; new-in-workdir = 2; renamed = 4; typechange = 3; unmodified = 13; }; group = 6; @@ -264,16 +221,6 @@ in }; xdg = { configFile = { - "ccache.conf" = { - text = "ccache_dir = ${config.xdg.cacheHome}/ccache"; - }; - "gdbinit" = { - text = '' - define hook-quit - set confirm off - end - ''; - }; "iftoprc" = { text = '' port-resolution: no @@ -390,7 +337,7 @@ in # Extra config RXVT_SOCKET = "${config.xdg.stateHome}/urxvtd"; # Used to want -$HOME suffix, hopefullt this isn't needed # XAUTHORITY = "${config.xdg.configHome}/Xauthority"; # Disabled as this causes lock-ups with DMs - } // direnv; + }; # TODO Session variables only get reloaded on login I think. sessionPath = [ "${config.home.homeDirectory}/.local/bin" diff --git a/hm/default.nix b/hm/default.nix index b3cd5c2..d346340 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -4,11 +4,12 @@ ../options.nix ./common.nix ./desktop - ./dev.nix + ./dev ./extra.nix ./gaming ./git ./gpg + ./homealone.nix ./rebuild ./ssh.nix ./style.nix diff --git a/hm/dev.nix b/hm/dev.nix deleted file mode 100644 index 8d64a90..0000000 --- a/hm/dev.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ pkgs, config, ... }: { - # TODO Maybe should be per-directory dotenv - # Or not, for neovim - - # Always on - home.packages = with pkgs; [ - # Common - perf-tools - jq - yq - universal-ctags - highlight - - # Network - socat - dig - whois - nmap - tcpdump - - # nix - nix - - # Always on (graphical) - ] ++ lib.optionals config.frogeye.desktop.xorg [ - # Common - zeal-qt6 # Offline documentation - - # Network - wireshark-qt - - # Ansible - ] ++ lib.optionals config.frogeye.dev.ansible [ - ansible - ansible-lint - - # C/C++ - ] ++ lib.optionals config.frogeye.dev.c [ - cmake - clang - ccache - gdb - - # Docker - ] ++ lib.optionals config.frogeye.dev.docker [ - docker - docker-compose - - # FPGA - ] ++ lib.optionals config.frogeye.dev.fpga [ - verilog - - ] ++ lib.optionals (config.frogeye.dev.fpga && pkgs.stdenv.isx86_64) [ - ghdl - - # FPGA (graphical) - ] ++ lib.optionals (config.frogeye.desktop.xorg && config.frogeye.dev.fpga) [ - yosys - gtkwave - - # Python - ] ++ lib.optionals config.frogeye.dev.python [ - python3Packages.ipython - - ]; - -} diff --git a/hm/dev/c.nix b/hm/dev/c.nix new file mode 100644 index 0000000..a8dba5e --- /dev/null +++ b/hm/dev/c.nix @@ -0,0 +1,40 @@ +{ pkgs, lib, config, ... }: +{ + config = lib.mkIf config.frogeye.dev.c { + frogeye = { + direnv = { + CCACHE_DIR = "${config.xdg.cacheHome}/ccache"; # The config file alone seems to be not enough + }; + junkhome = [ + "binwalk" # Should use .config according to the GitHub code though + "cmake" + "ddd" + "ghidra" + ]; + shellAliases = { + gdb = "gdb -x ${config.xdg.configHome}/gdbinit"; + }; + }; + home.packages = with pkgs; [ + binwalk + ccache + clang + cmake + ddd + gdb + ]; + programs.nixvim.extraPlugins = [ pkgs.vimPlugins.nvim-dap ]; # Debug Adapter Protocol client + xdg.configFile = { + "ccache.conf" = { + text = "ccache_dir = ${config.xdg.cacheHome}/ccache"; + }; + gdbinit = { + text = '' + define hook-quit + set confirm off + end + ''; + }; + }; + }; +} diff --git a/hm/dev/common.nix b/hm/dev/common.nix new file mode 100644 index 0000000..df39d53 --- /dev/null +++ b/hm/dev/common.nix @@ -0,0 +1,60 @@ +{ pkgs, config, ... }: { + # TODO Maybe should be per-directory dotenv + # Or not, for neovim + config = { + # Always on + home.packages = with pkgs; [ + # Common + perf-tools + jq + yq + universal-ctags + highlight + + # Network + socat + dig + whois + nmap + tcpdump + + # nix + nix + + # Always on (graphical) + ] ++ lib.optionals config.frogeye.desktop.xorg [ + # Common + zeal-qt6 # Offline documentation + + # Network + wireshark-qt + + # Ansible + ] ++ lib.optionals config.frogeye.dev.ansible [ + ansible + ansible-lint + + # Docker + ] ++ lib.optionals config.frogeye.dev.docker [ + docker + docker-compose + + # FPGA + ] ++ lib.optionals config.frogeye.dev.fpga [ + verilog + + ] ++ lib.optionals (config.frogeye.dev.fpga && pkgs.stdenv.isx86_64) [ + ghdl + + # FPGA (graphical) + ] ++ lib.optionals (config.frogeye.desktop.xorg && config.frogeye.dev.fpga) [ + yosys + gtkwave + + # Python + ] ++ lib.optionals config.frogeye.dev.python [ + python3Packages.ipython + + ]; + }; +} diff --git a/hm/dev/default.nix b/hm/dev/default.nix new file mode 100644 index 0000000..cbbc18b --- /dev/null +++ b/hm/dev/default.nix @@ -0,0 +1,6 @@ +{ pkgs, config, ... }: { + imports = [ + ./c.nix + ./common.nix + ]; +} diff --git a/hm/gpg/default.nix b/hm/gpg/default.nix index 2b0d53a..e299d01 100644 --- a/hm/gpg/default.nix +++ b/hm/gpg/default.nix @@ -36,5 +36,4 @@ enableZshIntegration = true; }; }; - } diff --git a/hm/homealone.nix b/hm/homealone.nix new file mode 100644 index 0000000..5dcb184 --- /dev/null +++ b/hm/homealone.nix @@ -0,0 +1,64 @@ +{ lib, config, ... }: +{ + config = { + frogeye = { + # TODO Move to relevant config file. Rest can probably removed. + direnv = { + CARGOHOME = "${config.xdg.cacheHome}/cargo"; # There are config in there that we can version if one want + DASHT_DOCSETS_DIR = "${config.xdg.cacheHome}/dash_docsets"; + GOPATH = "${config.xdg.cacheHome}/go"; + GRADLE_USER_HOME = "${config.xdg.cacheHome}/gradle"; + MIX_ARCHIVES = "${config.xdg.cacheHome}/mix/archives"; + MONO_GAC_PREFIX = "${config.xdg.cacheHome}/mono"; + npm_config_cache = "${config.xdg.cacheHome}/npm"; + PARALLEL_HOME = "${config.xdg.cacheHome}/parallel"; + TERMINFO = "${config.xdg.configHome}/terminfo"; + WINEPREFIX = "${config.xdg.stateHome}/wineprefix/default"; + YARN_CACHE_FOLDER = "${config.xdg.cacheHome}/yarn"; + }; + junkhome = [ + "adb" + "audacity" + "cabal" # TODO May have options but last time I tried it it crashed + "itch" + "simplescreenrecorder" # Easy fix https://github.com/MaartenBaert/ssr/blob/1556ae456e833992fb6d39d40f7c7d7c337a4160/src/Main.cpp#L252 + "vd" + "wpa_cli" + # TODO Maybe we can do something about node-gyp + ]; + shellAliases = lib.attrsets.mergeAttrsList (map (p: { "${p}" = "HOME=${config.xdg.cacheHome}/junkhome ${p}"; }) config.frogeye.junkhome); + }; + home = { + activation.createDirenvFolders = lib.hm.dag.entryAfter [ "writeBoundary" ] + (lib.strings.concatLines (map (d: "mkdir -p ${d}") ( + (builtins.attrValues config.frogeye.direnv) ++ [ "${config.xdg.cacheHome}/junkhome" ] + ))); + + sessionVariables = config.frogeye.direnv; + }; + }; + options.frogeye = { + direnv = lib.mkOption { + default = { }; + example = lib.literalExpression '' + { + DASHT_DOCSETS_DIR = "''${config.xdg.cacheHome}/dash_docsets"; + } + ''; + description = '' + Environment variables for which the value is a folder that will be automatically created. + Useful for keeping programs data out of $HOME for programs that won't create the directory themselves. + ''; + type = lib.types.attrsOf lib.types.str; + }; + junkhome = lib.mkOption { + default = [ ]; + description = '' + Program names that will be run with a different HOME so they don't clutter the real one. + Useful for programs that don't follow the XDG specification and tend to advertise themselves. + ''; + type = lib.types.listOf lib.types.str; + }; + # TODO Should make a nix package wrapper instead, so it also works from dmenu + }; +} diff --git a/hm/vim.nix b/hm/vim.nix index cb3aa11..1ad4b0c 100644 --- a/hm/vim.nix +++ b/hm/vim.nix @@ -283,8 +283,6 @@ in ] ++ lib.optionals config.programs.pandoc.enable [ vim-pandoc # Pandoc-specific stuff because there's no LSP for it vim-pandoc-syntax - ] ++ lib.optionals config.frogeye.dev.c [ - nvim-dap # Debug Adapter Protocol client ] ++ lib.optionals config.frogeye.dev.ansible [ ansible-vim # TODO Doesn't have snippets ]; diff --git a/options.nix b/options.nix index 57c02ce..c8871c4 100644 --- a/options.nix +++ b/options.nix @@ -40,7 +40,7 @@ php = lib.mkEnableOption "PHP dev stuff"; python = lib.mkEnableOption "Python dev stuff"; }; - shellAliases = lib.mkOption { + shellAliases = lib.mkOption { # TODO Just use bash option and copy it for zsh default = { }; example = lib.literalExpression '' {