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 ea8c4bf..6abfe1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c595917 --- /dev/null +++ b/flake.lock @@ -0,0 +1,65 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1716359173, + "narHash": "sha256-pYcjP6Gy7i6jPWrjiWAVV0BCQp+DdmGaI/k65lBb/kM=", + "owner": "nix-community", + "repo": "fenix", + "rev": "b6fc5035b28e36a98370d0eac44f4ef3fd323df6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716451822, + "narHash": "sha256-0lT5RVelqN+dgXWWneXvV5ufSksW0r0TDQi8O6U2+o8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3305b2b25e4ae4baee872346eae133cf6f611783", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1716107283, + "narHash": "sha256-NJgrwLiLGHDrCia5AeIvZUHUY7xYGVryee0/9D3Ir1I=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "21ec8f523812b88418b2bfc64240c62b3dd967bd", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..535e002 --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, fenix }: + let + overlays = [ fenix.overlays.default ]; + + getPkgsFor = (system: import nixpkgs { + inherit system overlays; + }); + + forEachSystem = func: nixpkgs.lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + + "aarch64-darwin" + "x86_64-darwin" + ] (system: func (getPkgsFor system)); + + in { + devShells = forEachSystem (pkgs: { + default = pkgs.callPackage ./shell.nix {}; + }); + }; +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..945e09b --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "stable" +profile = "default" +targets = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..d51b078 --- /dev/null +++ b/shell.nix @@ -0,0 +1,12 @@ +{ mkShell, fenix }: + +let + toolchain = fenix.fromToolchainFile { + file = ./rust-toolchain.toml; + sha256 = "opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU="; + }; +in + +mkShell { + packages = [ toolchain ]; +}