diff --git a/flake.lock b/flake.lock index 4d5223c..ee342c5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1737753923, @@ -17,7 +37,29 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "gitignore": "gitignore", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737685583, + "narHash": "sha256-p+NVABRpGi+pT+xxf9HcLcFVxG6L+vEEy+NwzB9T0f8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "eb64cbcc8eee0fa87ebded92805280d2ec97415a", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 2b16971..bb5226e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,53 @@ { description = "atproto github"; - inputs.nixpkgs.url = "github:nixos/nixpkgs"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; - outputs = - { self - , nixpkgs - , - }: - let - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); - in - { - defaultPackage = forAllSystems (system: self.packages.${system}.legit); - devShells = forAllSystems (system: - let - pkgs = nixpkgsFor.${system}; - in - { - default = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ - go - air - ]; - }; - }); + gitignore = { + url = "github:hercules-ci/gitignore.nix"; + inputs.nixpkgs.follows = "nixpkgs"; }; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + gitignore, + rust-overlay, + }: let + supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: + import nixpkgs { + inherit system; + overlays = [(import rust-overlay)]; + }); + in { + defaultPackage = forAllSystems (system: self.packages.${system}.legit); + formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra); + devShells = forAllSystems (system: let + pkgs = nixpkgsFor.${system}; + rust-bin = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + in { + default = pkgs.mkShell { + nativeBuildInputs = [ + pkgs.go + pkgs.air + + pkgs.bacon + rust-bin + pkgs.pkg-config + pkgs.openssl + ]; + RUST_LOG = "info"; + RUST_BACKTRACE = 1; + }; + }); + }; } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..9bf4607 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2025-01-20" +components = [ "rustfmt", "rustc", "rust-analyzer", "rust-src", "rust-std", "cargo" ] +profile = "default"