personal fork of atuin without AI stuff, sync stuff, script management stuff
0

Configure Feed

Select the types of activity you want to include in your feed.

nix: write builds and home-manager module

inline atuin.nix into flake and inline home-manager module

hatchling has fewer options, no daemon etc, so we need to rm those
options

Signed-off-by: oppiliappan <me@oppi.li>

author
oppiliappan
date (Jul 23, 2026, 2:43 PM +0100) commit 7cdd9b33 parent 2257c271 change-id unvkuuut
+267 -45
-44
atuin.nix
··· 1 - # Atuin package definition 2 - # 3 - # This file will be similar to the package definition in nixpkgs: 4 - # https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/at/atuin/package.nix 5 - # 6 - # Helpful documentation: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md 7 - { 8 - lib, 9 - stdenv, 10 - installShellFiles, 11 - rustPlatform, 12 - libiconv, 13 - }: 14 - rustPlatform.buildRustPackage { 15 - name = "atuin"; 16 - 17 - src = lib.cleanSource ./.; 18 - 19 - cargoLock = { 20 - lockFile = ./Cargo.lock; 21 - # Allow dependencies to be fetched from git and avoid having to set the outputHashes manually 22 - allowBuiltinFetchGit = true; 23 - }; 24 - 25 - nativeBuildInputs = [installShellFiles]; 26 - 27 - buildInputs = lib.optionals stdenv.isDarwin [libiconv]; 28 - 29 - postInstall = '' 30 - installShellCompletion --cmd atuin \ 31 - --bash <($out/bin/atuin gen-completions -s bash) \ 32 - --fish <($out/bin/atuin gen-completions -s fish) \ 33 - --zsh <($out/bin/atuin gen-completions -s zsh) 34 - ''; 35 - 36 - doCheck = false; 37 - 38 - meta = with lib; { 39 - description = "Replacement for a shell history which records additional commands context with optional encrypted synchronization between machines"; 40 - homepage = "https://github.com/atuinsh/atuin"; 41 - license = licenses.mit; 42 - mainProgram = "atuin"; 43 - }; 44 - }
+267 -1
flake.nix
··· 1 1 { 2 - description = "atuin dev shell"; 2 + description = "Replacement for a shell history which records additional command context"; 3 3 4 4 inputs = { 5 5 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; ··· 21 21 inherit system; 22 22 overlays = [rust-overlay.overlays.default]; 23 23 }; 24 + 25 + atuinPackage = { 26 + lib, 27 + stdenv, 28 + installShellFiles, 29 + rustPlatform, 30 + libiconv, 31 + }: 32 + rustPlatform.buildRustPackage { 33 + pname = "atuin"; 34 + version = (nixpkgs.lib.importTOML ./Cargo.toml).workspace.package.version; 35 + 36 + src = lib.cleanSource ./.; 37 + 38 + cargoLock = { 39 + lockFile = ./Cargo.lock; 40 + # avoid having to set outputHashes manually 41 + allowBuiltinFetchGit = true; 42 + }; 43 + 44 + nativeBuildInputs = [installShellFiles]; 45 + 46 + buildInputs = lib.optionals stdenv.isDarwin [libiconv]; 47 + 48 + postInstall = '' 49 + installShellCompletion --cmd atuin \ 50 + --bash <($out/bin/atuin gen-completions -s bash) \ 51 + --fish <($out/bin/atuin gen-completions -s fish) \ 52 + --zsh <($out/bin/atuin gen-completions -s zsh) 53 + ''; 54 + 55 + doCheck = false; 56 + 57 + meta = { 58 + description = "Replacement for a shell history which records additional command context"; 59 + homepage = "https://github.com/atuinsh/atuin"; 60 + license = lib.licenses.mit; 61 + mainProgram = "atuin"; 62 + }; 63 + }; 64 + 65 + rustPlatformFor = pkgs: let 66 + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; 67 + in 68 + pkgs.makeRustPlatform { 69 + cargo = toolchain; 70 + rustc = toolchain; 71 + }; 24 72 in { 25 73 formatter = forAllSystems (system: (pkgsFor system).alejandra); 74 + 75 + packages = forAllSystems (system: let 76 + pkgs = pkgsFor system; 77 + in rec { 78 + atuin = pkgs.callPackage atuinPackage { 79 + rustPlatform = rustPlatformFor pkgs; 80 + }; 81 + default = atuin; 82 + }); 83 + 84 + overlays.default = final: _prev: { 85 + atuin = final.callPackage atuinPackage { 86 + rustPlatform = rustPlatformFor final; 87 + }; 88 + }; 89 + 90 + # cloned from home-manager's atuin.nix file 91 + homeManagerModules.atuin = { 92 + config, 93 + lib, 94 + pkgs, 95 + ... 96 + }: let 97 + cfg = config.programs.atuin; 98 + tomlFormat = pkgs.formats.toml {}; 99 + 100 + inherit (lib) mkIf mkOption types; 101 + in { 102 + options.programs.atuin = { 103 + enable = lib.mkEnableOption "atuin, a magical shell history"; 104 + 105 + package = mkOption { 106 + type = types.package; 107 + default = self.packages.${pkgs.stdenv.hostPlatform.system}.default; 108 + defaultText = lib.literalExpression "atuin.packages.\${system}.default"; 109 + description = "The atuin package to use."; 110 + }; 111 + 112 + enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { 113 + inherit config; 114 + extraDescription = "If enabled, this will bind `ctrl-r` to open the Atuin history."; 115 + }; 116 + 117 + enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { 118 + inherit config; 119 + extraDescription = "If enabled, this will bind the up-arrow key to open the Atuin history."; 120 + }; 121 + 122 + enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption {inherit config;}; 123 + 124 + enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { 125 + inherit config; 126 + extraDescription = '' 127 + If enabled, this will bind `ctrl-r` and the up-arrow key to open the 128 + Atuin history. 129 + ''; 130 + }; 131 + 132 + flags = mkOption { 133 + default = []; 134 + type = types.listOf types.str; 135 + example = ["--disable-up-arrow" "--disable-ctrl-r"]; 136 + description = "Flags to append to the shell hook."; 137 + }; 138 + 139 + settings = mkOption { 140 + type = with types; let 141 + prim = oneOf [bool int str]; 142 + primOrPrimAttrs = either prim (attrsOf prim); 143 + entry = either prim (listOf primOrPrimAttrs); 144 + entryOrAttrsOf = t: either entry (attrsOf t); 145 + entries = entryOrAttrsOf (entryOrAttrsOf entry); 146 + in 147 + attrsOf entries // {description = "Atuin configuration";}; 148 + default = {}; 149 + example = lib.literalExpression '' 150 + { 151 + search_mode = "prefix"; 152 + style = "compact"; 153 + } 154 + ''; 155 + description = '' 156 + Configuration written to 157 + {file}`$XDG_CONFIG_HOME/atuin/config.toml`. 158 + 159 + See <https://docs.atuin.sh/configuration/config/> for the full list 160 + of options. 161 + ''; 162 + }; 163 + 164 + forceOverwriteSettings = mkOption { 165 + type = types.bool; 166 + default = false; 167 + description = '' 168 + When enabled, force overwriting of the Atuin configuration file 169 + ({file}`$XDG_CONFIG_HOME/atuin/config.toml`). 170 + Any existing Atuin configuration will be lost. 171 + 172 + Enabling this is useful when adding settings for the first time 173 + because Atuin writes its default config file after every single 174 + shell command, which can make it difficult to manually remove. 175 + ''; 176 + }; 177 + 178 + themes = mkOption { 179 + type = types.attrsOf (types.oneOf [ 180 + tomlFormat.type 181 + types.path 182 + types.lines 183 + ]); 184 + default = {}; 185 + example = lib.literalExpression '' 186 + { 187 + "my-theme" = { 188 + theme.name = "My Theme"; 189 + colors = { 190 + Base = "#000000"; 191 + Title = "#FFFFFF"; 192 + }; 193 + }; 194 + } 195 + ''; 196 + description = '' 197 + Each theme is written to 198 + {file}`$XDG_CONFIG_HOME/atuin/themes/theme-name.toml` 199 + where the name of each attribute is the theme-name. 200 + 201 + See <https://docs.atuin.sh/guide/theming/> for the full list 202 + of options. 203 + ''; 204 + }; 205 + }; 206 + 207 + config = let 208 + flagsStr = lib.escapeShellArgs cfg.flags; 209 + atuinFishConfig = 210 + pkgs.runCommand "atuin-fish-config.fish" 211 + {nativeBuildInputs = [pkgs.writableTmpDirAsHomeHook];} 212 + '' 213 + ${lib.getExe cfg.package} init fish ${flagsStr} > "$out" 214 + ''; 215 + in 216 + mkIf cfg.enable (lib.mkMerge [ 217 + { 218 + home.packages = [cfg.package]; 219 + 220 + xdg.configFile = lib.mkMerge [ 221 + (mkIf (cfg.settings != {}) { 222 + "atuin/config.toml" = { 223 + source = tomlFormat.generate "atuin-config" cfg.settings; 224 + force = cfg.forceOverwriteSettings; 225 + }; 226 + }) 227 + 228 + (mkIf (cfg.themes != {}) (lib.mapAttrs' ( 229 + name: theme: 230 + lib.nameValuePair "atuin/themes/${name}.toml" { 231 + source = 232 + if lib.isString theme 233 + then pkgs.writeText "atuin-theme-${name}" theme 234 + else if builtins.isPath theme || lib.isStorePath theme 235 + then theme 236 + else tomlFormat.generate "atuin-theme-${name}" theme; 237 + } 238 + ) 239 + cfg.themes)) 240 + ]; 241 + 242 + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' 243 + if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then 244 + source "${pkgs.bash-preexec}/share/bash/bash-preexec.sh" 245 + eval "$(${lib.getExe cfg.package} init bash ${flagsStr})" 246 + fi 247 + ''; 248 + 249 + programs.zsh.initContent = mkIf cfg.enableZshIntegration '' 250 + if [[ $options[zle] = on ]]; then 251 + eval "$(${lib.getExe cfg.package} init zsh ${flagsStr})" 252 + fi 253 + ''; 254 + 255 + programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' 256 + source ${atuinFishConfig} 257 + ''; 258 + 259 + programs.nushell = mkIf cfg.enableNushellIntegration { 260 + extraConfig = lib.mkOrder 2000 '' 261 + source ${ 262 + pkgs.runCommand "atuin-nushell-config.nu" 263 + {nativeBuildInputs = [pkgs.writableTmpDirAsHomeHook];} 264 + '' 265 + ${lib.getExe cfg.package} init nu ${flagsStr} >> "$out" 266 + '' 267 + } 268 + ''; 269 + }; 270 + } 271 + 272 + (mkIf config.home.preferXdgDirectories { 273 + programs.atuin.settings.logs = { 274 + dir = lib.mkDefault "${config.xdg.stateHome}/atuin/logs"; 275 + }; 276 + }) 277 + ]); 278 + }; 279 + homeManagerModules.default = self.homeManagerModules.atuin; 280 + 26 281 devShells = forAllSystems (system: let 27 282 pkgs = pkgsFor system; 28 283 toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; ··· 33 288 pkgs.rust-analyzer 34 289 pkgs.sqlite 35 290 ]; 291 + 292 + RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; 293 + 294 + shellHook = '' 295 + echo >&2 "Setting development database path" 296 + export ATUIN_DB_PATH="/tmp/atuin_dev.db" 297 + 298 + if [ -e "''${ATUIN_DB_PATH}" ]; then 299 + echo >&2 "''${ATUIN_DB_PATH} already exists, you might want to double-check that" 300 + fi 301 + ''; 36 302 }; 37 303 }); 38 304 };