From 85ee3198c75bbc5d853ee16b664691b32935251a Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Thu, 22 Feb 2024 21:10:36 +0900 Subject: [PATCH 1/3] atuin: Allow setting database.uri to null When a password is required to connect to postgres using services.atuin.database.uri directly would make the password be written in the nix store, which is suboptimal. Instead we can have the password in a file accessible only to root by having systemd read an EnvironmentFile directly, but we must ensure that this file has priority over the environment set. Not setting the variable in this case is more straightforward. --- nixos/modules/services/misc/atuin.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/atuin.nix b/nixos/modules/services/misc/atuin.nix index 2d6ffc510ce5..2c06f62c5a6e 100644 --- a/nixos/modules/services/misc/atuin.nix +++ b/nixos/modules/services/misc/atuin.nix @@ -52,10 +52,13 @@ in }; uri = mkOption { - type = types.str; + type = types.nullOr types.str; default = "postgresql:///atuin?host=/run/postgresql"; example = "postgresql://atuin@localhost:5432/atuin"; - description = mdDoc "URI to the database"; + description = mdDoc '' + URI to the database. + Can be set to null in which case ATUIN_DB_URI should be set through an EnvironmentFile + ''; }; }; }; @@ -132,9 +135,10 @@ in ATUIN_PORT = toString cfg.port; ATUIN_MAX_HISTORY_LENGTH = toString cfg.maxHistoryLength; ATUIN_OPEN_REGISTRATION = lib.boolToString cfg.openRegistration; - ATUIN_DB_URI = cfg.database.uri; ATUIN_PATH = cfg.path; ATUIN_CONFIG_DIR = "/run/atuin"; # required to start, but not used as configuration is via environment variables + } // lib.optionalAttrs (cfg.database.uri != null) { + ATUIN_DB_URI = cfg.database.uri; }; }; From 5ede2692b7c7afde638e64f9e0263b3796415e36 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 23 Feb 2024 06:23:42 +0900 Subject: [PATCH 2/3] atuin: disable check-updates feature --- pkgs/by-name/at/atuin/package.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/by-name/at/atuin/package.nix b/pkgs/by-name/at/atuin/package.nix index db9bc233cb9a..e196974a5a22 100644 --- a/pkgs/by-name/at/atuin/package.nix +++ b/pkgs/by-name/at/atuin/package.nix @@ -25,6 +25,13 @@ rustPlatform.buildRustPackage rec { then "sha256-lHWgsVnjSeBmd7O4Fn0pUtTn4XbkBOAouaRHRozil50=" else "sha256-LxfpllzvgUu7ZuD97n3W+el3bdOt5QGXzJbDQ0w8seo="; + # atuin's default features include 'check-updates', which do not make sense + # for distribution builds. List all other default features. + buildNoDefaultFeatures = true; + buildFeatures = [ + "client" "sync" "server" "clipboard" + ]; + nativeBuildInputs = [ installShellFiles ]; buildInputs = lib.optionals stdenv.isDarwin [ From c74bfa05e22bc8ac255a3ed1e04eeab9407d9671 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 23 Feb 2024 06:40:13 +0900 Subject: [PATCH 3/3] atuin: backport fix for bash-preexec --- pkgs/by-name/at/atuin/package.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/by-name/at/atuin/package.nix b/pkgs/by-name/at/atuin/package.nix index e196974a5a22..88e9609075fe 100644 --- a/pkgs/by-name/at/atuin/package.nix +++ b/pkgs/by-name/at/atuin/package.nix @@ -1,6 +1,7 @@ { lib , stdenv , fetchFromGitHub +, fetchpatch , installShellFiles , rustPlatform , libiconv @@ -19,6 +20,15 @@ rustPlatform.buildRustPackage rec { hash = "sha256-fuVSn1vhKn2+Tw5f6zBYHFW3QSL4eisZ6d5pxsj5hh4="; }; + patches = [ + # atuin with bash-preexec wasn't recording history properly after searching, + # backport recent fix until next release + (fetchpatch { + url = "https://github.com/atuinsh/atuin/commit/cb11af25afddbad552d337a9c82e74ac4302feca.patch"; + sha256 = "sha256-cG99aLKs5msatT7vXiX9Rn5xur2WUjQ/U33nOxuon7I="; + }) + ]; + # TODO: unify this to one hash because updater do not support this cargoHash = if stdenv.isLinux