diff --git a/.gitignore b/.gitignore index 9bae4c38..e869bc1f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ ui/backend/gen sqlite-server.db* .atuin/permissions.*.toml + +# nix + direnv +.direnv/ diff --git a/flake.lock b/flake.lock index 6ad8a659..84ed26df 100644 --- a/flake.lock +++ b/flake.lock @@ -1,113 +1,44 @@ { "nodes": { - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1758609765, - "narHash": "sha256-VIYu7R9Yc/CItjmzLSm21Lr9DgpEsKL5H+JUu8KDTn4=", - "owner": "nix-community", - "repo": "fenix", - "rev": "05545a7f3cd5cd5628b195520758e56e6734b90a", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1747046372, - "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1758446476, - "narHash": "sha256-5rdAi7CTvM/kSs6fHe1bREIva5W3TbImsto+dxG4mBo=", - "owner": "NixOS", + "lastModified": 1784120854, + "narHash": "sha256-KesHgItiZPgGX740axSiQLcIQ8D24MDqNpkKYWIek8k=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "a1f79a1770d05af18111fbbe2a3ab2c42c0f6cd0", + "rev": "753cc8a3a87467296ddd1fa93f0cc3e81120ee46", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", + "owner": "nixos", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "fenix": "fenix", - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" } }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1758556272, - "narHash": "sha256-9amq6LAd0CFF3dLrJUItPiG64MQOG4QPrvjbjpa6NFc=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "d05355db16dc526bb16bd84769ea840668d7015e", - "type": "github" + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" - } - }, - "systems": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1784265529, + "narHash": "sha256-ohQQiPOngux8ofsrSlloHCMDhRMvocXqJiG8uH45Q5k=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "068175006cfb69d5b541a140ed93e361488c9e53", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "oxalica", + "repo": "rust-overlay", "type": "github" } } diff --git a/flake.nix b/flake.nix index 096a4049..5b90e099 100644 --- a/flake.nix +++ b/flake.nix @@ -1,74 +1,39 @@ { + description = "atuin dev shell"; + inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - fenix = { - url = "github:nix-community/fenix"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = - { self - , nixpkgs - , flake-utils - , fenix - , ... - }: - flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = nixpkgs.outputs.legacyPackages.${system}; - in - { - packages.atuin = pkgs.callPackage ./atuin.nix { - rustPlatform = - let - toolchain = - fenix.packages.${system}.fromToolchainFile - { - file = ./rust-toolchain.toml; - sha256 = "sha256-OATSZm98Es5kIFuqaba+UvkQtFsVgJEBMmS+t6od5/U="; - }; - in - pkgs.makeRustPlatform { - cargo = toolchain; - rustc = toolchain; - }; - }; - 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}"; - - shellHook = '' - echo >&2 "Setting development database path" - export ATUIN_DB_PATH="/tmp/atuin_dev.db" - export ATUIN_RECORD_STORE_PATH="/tmp/atuin_records.db" - if [ -e "''${ATUIN_DB_PATH}" ]; then - echo >&2 "''${ATUIN_DB_PATH} already exists, you might want to double-check that" - fi - - if [ -e "''${ATUIN_RECORD_STORE_PATH}" ]; then - echo >&2 "''${ATUIN_RECORD_STORE_PATH} already exists, you might want to double-check that" - fi - ''; - }); - }) - // { - overlays.default = final: prev: { - inherit (self.packages.${final.stdenv.hostPlatform.system}) atuin; + outputs = { + self, + nixpkgs, + rust-overlay, + }: let + supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = system: + import nixpkgs { + inherit system; + overlays = [rust-overlay.overlays.default]; }; - }; + in { + formatter = forAllSystems (system: (pkgsFor system).alejandra); + devShells = forAllSystems (system: let + pkgs = pkgsFor system; + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + in { + default = pkgs.mkShell { + nativeBuildInputs = [ + toolchain + pkgs.rust-analyzer + pkgs.sqlite + ]; + }; + }); + }; }