From 5efaab496eae6f3417e49bafe855b58b9e477e49 Mon Sep 17 00:00:00 2001 From: Juanperias <136520331+Juanperias@users.noreply.github.com> Date: Thu, 2 Jan 2025 14:47:10 -0400 Subject: [PATCH 1/2] feat: add basic nix flake --- flake.lock | 130 ++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++ rust-toolchain.toml | 3 + 3 files changed, 167 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 rust-toolchain.toml diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..350697e --- /dev/null +++ b/flake.lock @@ -0,0 +1,130 @@ +{ + "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": 1735799625, + "narHash": "sha256-lFadwWDvVIub11bwfZhsh2WUByf9LOi6yjsSUMmE0xk=", + "owner": "nix-community", + "repo": "fenix", + "rev": "a9d84a1545814910cb4ab0515ed6921e8b07ee95", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1735471104, + "narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1735648875, + "narHash": "sha256-fQ4k/hyQiH9RRPznztsA9kbcDajvwV1sRm01el6Sr3c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "47e29c20abef74c45322eca25ca1550cdf5c3b50", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1735742096, + "narHash": "sha256-q3a80h8Jf8wfmPURUgRR46nQCB3I5fhZ+/swulTF5HY=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "7e639ee3dda6ed9cecc79d41f6d38235121e483d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8780a75 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "Pixels flake"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + crane.url = "github:ipetkov/crane"; + + flake-utils.url = "github:numtide/flake-utils"; + + fenix.url = "github:nix-community/fenix"; + }; + + outputs = { nixpkgs, flake-utils, fenix, ... }@inputs: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + crane = inputs.crane.mkLib pkgs; + toolchain = fenix.packages.${system}.fromToolchainFile { + file = ./rust-toolchain.toml; + sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM="; + }; + + craneLib = crane.overrideToolchain toolchain; + in + { + devShells.default = craneLib.devShell { + packages = [ + toolchain + ]; + }; + }); +} + diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..6cee101 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +targets = ["wasm32-unknown-unknown", "aarch64-linux-android"] From 6a8d25f74d6c786cdf1349aac009e4f7b4d12ac8 Mon Sep 17 00:00:00 2001 From: Juanperias <136520331+Juanperias@users.noreply.github.com> Date: Fri, 3 Jan 2025 12:30:28 -0400 Subject: [PATCH 2/2] Refactor use fenix minimalToolchain --- flake.nix | 6 ++---- rust-toolchain.toml | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/flake.nix b/flake.nix index 8780a75..62013d2 100644 --- a/flake.nix +++ b/flake.nix @@ -16,10 +16,8 @@ pkgs = nixpkgs.legacyPackages.${system}; crane = inputs.crane.mkLib pkgs; - toolchain = fenix.packages.${system}.fromToolchainFile { - file = ./rust-toolchain.toml; - sha256 = "sha256-s1RPtyvDGJaX/BisLT+ifVfuhDT1nZkZ1NcK8sbwELM="; - }; + + toolchain = fenix.packages.${system}.stable.minimalToolchain; craneLib = crane.overrideToolchain toolchain; in diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 6cee101..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "stable" -targets = ["wasm32-unknown-unknown", "aarch64-linux-android"]