From 56ed66420489a157d4ccc065d32d5b5e6eac81a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Tveit?= Date: Wed, 25 Dec 2024 15:37:49 +0100 Subject: [PATCH] flake.nix: init --- .envrc | 1 + flake.lock | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix 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/flake.lock b/flake.lock new file mode 100644 index 0000000..b4aef05 --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1715581585, + "narHash": "sha256-/JjvIn1NXW3yOaDcD8Me987/QcXjo+rhg+uThasPAnI=", + "owner": "nix-community", + "repo": "fenix", + "rev": "2c4905096782e8e908205e7fa54ef987fba62793", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1715534503, + "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2057814051972fa1453ddfb0d98badbea9b83c06", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1715255944, + "narHash": "sha256-vLLgYpdtKBaGYTamNLg1rbRo1bPXp4Jgded/gnprPVw=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "5bf2f85c8054d80424899fa581db1b192230efb5", + "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..5d70659 --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, fenix }@inputs: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let + toolchain = fenix.packages.${system}.complete; + pkgs = import nixpkgs { + inherit system; + overlays = [ + (_: super: let pkgs = fenix.inputs.nixpkgs.legacyPackages.${system}; in fenix.overlays.default pkgs pkgs) + ]; + }; + in f system pkgs toolchain); + in { + devShell = forAllSystems (system: pkgs: toolchain: pkgs.mkShell { + packages = [ + (toolchain.withComponents [ + "cargo" "rustc" "rustfmt" "clippy" + ]) + ]; + RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library"; + }); + }; +}