diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 2f7896d..5895861 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target/ +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..436d232 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1780749050, + "narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a799d3e3886da994fa307f817a6bc705ae538eeb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1780888890, + "narHash": "sha256-MUQPFiskEENaJ2N82TRIqpKlHXGXJJkPfKH6W788oQo=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "7d5f8d75fc195a236b46633d7679139698aeb35f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1047a64 --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + self, + nixpkgs, + rust-overlay, + }: + let + forAllSystems = + fn: + let + systems = [ + "x86_64-linux" + "aarch64-darwin" + ]; + overlays = [ (import rust-overlay) ]; + in + nixpkgs.lib.genAttrs systems ( + system: + fn ( + import nixpkgs { + inherit system overlays; + } + ) + ); + in + { + devShells = forAllSystems (pkgs: + { + default = pkgs.mkShell { + buildInputs = [ + pkgs.bacon + pkgs.rust-analyzer + pkgs.rust-bin.stable.latest.default + ]; + }; + }); + + formatter = forAllSystems ( + pkgs: + pkgs.treefmt.withConfig { + runtimeInputs = [ pkgs.nixfmt ]; + settings = { + on-unmatched = "info"; + formatter.nixfmt = { + command = "nixfmt"; + includes = [ "*.nix" ]; + }; + }; + } + ); + }; +}