From d7a9dc5bc8e0866b6fa10ada6e568211d6ca284a Mon Sep 17 00:00:00 2001 From: FelipeArce Date: Mon, 30 Dec 2024 09:47:19 -0300 Subject: [PATCH 1/2] fix: correct typographical error --- src/ch01-03-hello-cargo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch01-03-hello-cargo.md b/src/ch01-03-hello-cargo.md index 17e494f6..70e0b045 100644 --- a/src/ch01-03-hello-cargo.md +++ b/src/ch01-03-hello-cargo.md @@ -106,7 +106,7 @@ fn main() { ``` ¡Cargo ha generado un programa “Hello, world!”/“¡Hola, mundo!” para ti, -¡igual que el que escribimos enl Listado 1-1! Hasta ahora, las diferencias +¡igual que el que escribimos en el Listado 1-1! Hasta ahora, las diferencias entre nuestro proyecto y el proyecto generado por Cargo son que Cargo colocó el código en el directorio *src* y tenemos un archivo de configuración *Cargo.toml* en el directorio superior. From aca5cb5c11bedb15c40b4648c97bb600e9f87232 Mon Sep 17 00:00:00 2001 From: Juanperias <136520331+Juanperias@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:59:10 -0400 Subject: [PATCH 2/2] feat: add nix flake --- flake.lock | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 40 ++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..7f1547f5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,92 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1734808813, + "narHash": "sha256-3aH/0Y6ajIlfy7j52FGZ+s4icVX0oHhqBzRdlOeztqg=", + "owner": "ipetkov", + "repo": "crane", + "rev": "72e2d02dbac80c8c86bf6bf3e785536acf8ee926", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1735540357, + "narHash": "sha256-XbIfjxEOM6JmLCILozlFEUrfCpXvQNo9l+VAU7FCahI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "92bb57bf88e4b8e6b4fe4e79fbfff2fc3f04df88", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735291276, + "narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "634fd46801442d760e09493a794c4f15db2d0cbb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 0, + "narHash": "sha256-OZiZ3m8SCMfh3B6bfGC/Bm4x3qc1m2SVEAlkV6iY7Yg=", + "path": "/nix/store/hfz1qqd0z8amlgn8qwich1dvkmldik36-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1735485512, + "narHash": "sha256-B9tZfdCnZF7Qo/Ys/LgKtUlzIr38c9fDYgo/XcS8Gtc=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "59bc7b49d0ad319de8c477c63da552cbc8a05e4c", + "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 00000000..eb1e3db6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + description = "RustBookEs flake"; + + inputs = { + crane.url = "github:ipetkov/crane"; + fenix.url = "github:nix-community/fenix"; + }; + + outputs = { nixpkgs, fenix, ... }@inputs: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + lib = pkgs.lib; + crane = inputs.crane.mkLib pkgs; + + toolchain = fenix.packages.${system}.fromToolchainFile { + file = ./rust-toolchain; + sha256 = "sha256-opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU="; + }; + + craneLib = crane.overrideToolchain toolchain; + + commonArgs = { + doCheck = false; + src = lib.cleanSourceWith { + src = craneLib.path ./..; + }; + }; + + + book = craneLib.buildPackage (commonArgs // { + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + }); + in + { + devShells.${system}.default = craneLib.devShell { + packages = with pkgs; [ toolchain mdbook ]; + }; + }; +}