diff --git a/.gitignore b/.gitignore index 02edf337..17c0b070 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .env .idea/ .vscode/ +result diff --git a/README.md b/README.md index 17bd2e7e..da3649df 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,21 @@ sudo port install atuin And then follow [the shell setup](#shell-plugin) +### Nix + +This repository is a flake, and can be installed using `nix profile`: + +``` +nix profile install "github:ellie/atuin" +``` + +Atuin is also available in [nixpkgs](https://github.com/NixOS/nixpkgs): + +``` +nix-env -f '' -iA atuin +``` + +And then follow [the shell setup](#shell-plugin) ### Pacman Atuin is available in the Arch Linux [community repository](https://archlinux.org/packages/community/x86_64/atuin/): diff --git a/atuin.nix b/atuin.nix new file mode 100644 index 00000000..606e6875 --- /dev/null +++ b/atuin.nix @@ -0,0 +1,34 @@ +{ + lib, + stdenv, + fetchFromGitHub, + installShellFiles, + rustPlatform, + libiconv, + Security, + SystemConfiguration, +}: +rustPlatform.buildRustPackage rec { + name = "atuin"; + + src = lib.cleanSource ./.; + + cargoLock.lockFile = ./Cargo.lock; + + nativeBuildInputs = [installShellFiles]; + + buildInputs = lib.optionals stdenv.isDarwin [libiconv Security SystemConfiguration]; + + postInstall = '' + installShellCompletion --cmd atuin \ + --bash <($out/bin/atuin gen-completions -s bash) \ + --fish <($out/bin/atuin gen-completions -s fish) \ + --zsh <($out/bin/atuin gen-completions -s zsh) + ''; + + meta = with lib; { + description = "Replacement for a shell history which records additional commands context with optional encrypted synchronization between machines"; + homepage = "https://github.com/ellie/atuin"; + license = licenses.mit; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..4e55e3d4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1667379994, + "narHash": "sha256-PFOg8WHqfKXsIGZtEC0aB+rl8SB1cXvA01ytIudnRh8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a704b9029586266f63807f64a6718f1a65b0f83b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..8a1f2a14 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = { + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.outputs.legacyPackages.${system}; + in { + packages.atuin = pkgs.callPackage ./atuin.nix { + inherit (pkgs.darwin.apple_sdk.frameworks) Security SystemConfiguration; + }; + packages.default = self.outputs.packages.${system}.atuin; + + devShells.default = self.packages.${system}.default.overrideAttrs (super: { + nativeBuildInputs = with pkgs; + super.nativeBuildInputs + ++ [ + cargo-edit + clippy + rustfmt + ]; + RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; + }); + }); +}