From df915a11371db4a919e006e8efb50afe41b8662e Mon Sep 17 00:00:00 2001 From: Justin Restivo Date: Tue, 14 May 2024 15:00:22 -0400 Subject: [PATCH] feat: working flake --- flake.lock | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 59 +++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..e8f1936223 --- /dev/null +++ b/flake.lock @@ -0,0 +1,183 @@ +{ + "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" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "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" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1715542476, + "narHash": "sha256-FF593AtlzQqa8JpzrXyRws4CeKbc5W86o8tHt4nRfIg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "44072e24566c5bcc0b7aa9178a0104f4cfffab19", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "oxalica": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1715652909, + "narHash": "sha256-aCLEDvzL1j51Rf2mCFOqK1mieMO3pAn5ItCIdr5h2LA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "1d8fcbbfcfd3476c2665384a46ee9d07ef2b4dd9", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "nixpkgs": "nixpkgs_2", + "oxalica": "oxalica", + "utils": "utils" + } + }, + "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" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..2d6118a936 --- /dev/null +++ b/flake.nix @@ -0,0 +1,59 @@ +{ + description = "Flake for c2rust"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + utils.url = "github:numtide/flake-utils"; + fenix = { + url = "github:nix-community/fenix"; + }; + oxalica = { + url = "github:oxalica/rust-overlay"; + }; + }; + + outputs = inputs@{ self, nixpkgs, utils, fenix, oxalica}: + utils.lib.eachDefaultSystem (system: + let + fenixStable = fenix.packages.${system}.fromToolchainFile { + file = ./rust-toolchain.toml; + sha256 = "sha256-r/8YBFuFa4hpwgE3FnME7nQA2Uc1uqj0eCE1NWmI1u0"; + }; + pkgs = import nixpkgs { + inherit system; + overlays = [ + (import oxalica) + ]; + config = { + allowUnfree = true; + }; + }; + in { + defaultPackage = self.devShell.${system}; + devShell = pkgs.mkShell.override { } { + + LIBCLANG_PATH = "${pkgs.llvmPackages_14.libclang.lib}/lib"; + CMAKE_LLVM_DIR = "${pkgs.llvmPackages_14.libllvm.dev}/lib/cmake/llvm"; + CMAKE_CLANG_DIR = "${pkgs.llvmPackages_14.libclang.dev}/lib/cmake/clang"; + shellHook = '' + export CARGO_TARGET_DIR="$(git rev-parse --show-toplevel)/target_dirs/nix_rustc"; + ''; + RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; + buildInputs = + with pkgs; [ + clangStdenv.cc + llvmPackages_14.libclang + pkg-config + fenix.packages.${system}.rust-analyzer + llvmPackages_14.clang + cmake + llvmPackages_14.llvm + llvmPackages_14.libllvm + openssl + python3 + zlib + (rust-bin.fromRustupToolchainFile ./rust-toolchain.toml) + ]; + }; + }); +}