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..4fbb802 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target + +.direnv/ diff --git a/flake.lock b/flake.lock index f1588d5..72e1abc 100644 --- a/flake.lock +++ b/flake.lock @@ -1,39 +1,6 @@ { "nodes": { - "naersk": { - "inputs": { - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1659610603, - "narHash": "sha256-LYgASYSPYo7O71WfeUOaEUzYfzuXm8c8eavJcel+pfI=", - "owner": "nix-community", - "repo": "naersk", - "rev": "c6a45e4277fa58abd524681466d3450f896dc094", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "master", - "repo": "naersk", - "type": "github" - } - }, "nixpkgs": { - "locked": { - "lastModified": 1661008273, - "narHash": "sha256-UpDqsGzUswIHG7FwzeIewjWlElF17UVLNbI2pwlbcBY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "0cc6444e74cd21e8da8d81ef4cd778492e10f843", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1661008273, "narHash": "sha256-UpDqsGzUswIHG7FwzeIewjWlElF17UVLNbI2pwlbcBY=", @@ -51,8 +18,7 @@ }, "root": { "inputs": { - "naersk": "naersk", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "utils": "utils" } }, diff --git a/flake.nix b/flake.nix index e59f72a..d477620 100644 --- a/flake.nix +++ b/flake.nix @@ -1,45 +1,30 @@ { inputs = { - naersk.url = "github:nix-community/naersk/master"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, utils, naersk }: + outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: let - name = "tas"; pkgs = import nixpkgs { inherit system; }; - naersk-lib = pkgs.callPackage naersk { }; + cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml)); in rec { - # Executes by `nix build .#` - packages = { - ${name} = naersk.lib.${system}.buildPackage { - pname = name; - root = ./.; - }; + packages.default = pkgs.rustPlatform.buildRustPackage { + inherit (cargoToml.package) name version; + src = nixpkgs.lib.cleanSource ./.; + doCheck = true; + cargoLock.lockFile = ./Cargo.lock; }; - # Executes by `nix build .` - packages.default = packages.${name}; - # the same but deprecated in Nix 2.7 - defaultPackage = packages.default; - # Executes by `nix run .# -- ` - apps = { - ${name} = utils.lib.mkApp { - inherit name; - drv = packages.${name}; - }; + apps.default = utils.lib.mkApp { + inherit (cargoToml.package) name; + drv = packages.default; }; - # Executes by `nix run . -- ` - apps.default = apps.${name}; - # the same but deprecated in Nix 2.7 - defaultApp = apps.default; - # Used by `nix develop` devShell = with pkgs; mkShell { - buildInputs = [ cargo rustc rustfmt rustPackages.clippy ]; + packages = [ cargo rustc rustfmt clippy rust-analyzer ]; RUST_SRC_PATH = rustPlatform.rustLibSrc; }; });