From 336e97961ce6cf496ca177ab7ae11f3779bad868 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 10 Sep 2021 19:42:30 +0530 Subject: init --- .direnv/flake-profile | 1 + .direnv/flake-profile.rc | 1 + .gitignore | 2 + Cargo.lock | 104 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 10 ++++ flake.lock | 125 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 76 ++++++++++++++++++++++++++++ src/main.rs | 3 ++ 8 files changed, 322 insertions(+) create mode 120000 .direnv/flake-profile create mode 100644 .direnv/flake-profile.rc create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 src/main.rs diff --git a/.direnv/flake-profile b/.direnv/flake-profile new file mode 120000 index 0000000..1f4a10d --- /dev/null +++ b/.direnv/flake-profile @@ -0,0 +1 @@ +/home/np/code/rust/nix-analyzer/.direnv/flake-profile.30522 \ No newline at end of file diff --git a/.direnv/flake-profile.rc b/.direnv/flake-profile.rc new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.direnv/flake-profile.rc @@ -0,0 +1 @@ + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46b5d68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +.envrc diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f09d0c9 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf" + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "cbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29b6ad25ae296159fb0da12b970b2fe179b234584d7cd294c891e2bbb284466b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "countme" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] +name = "nix-analyzer" +version = "0.1.0" +dependencies = [ + "anyhow", + "rnix", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "rnix" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b37f8af07a0354606141df076458660af7e22238e4117a041c21c548080addd" +dependencies = [ + "cbitset", + "rowan", + "smol_str", +] + +[[package]] +name = "rowan" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1b36e449f3702f3b0c821411db1cbdf30fb451726a9456dce5dabcd44420043" +dependencies = [ + "countme", + "hashbrown", + "memoffset", + "rustc-hash", + "text-size", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "smol_str" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b203e79e90905594272c1c97c7af701533d42adaab0beb3859018e477d54a3b0" + +[[package]] +name = "text-size" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "288cb548dbe72b652243ea797201f3d481a0609a967980fcc5b2315ea811560a" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d7f3afa --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "nix-analyzer" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0" +rnix = "0.9.0" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8ba571c --- /dev/null +++ b/flake.lock @@ -0,0 +1,125 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "flake": false, + "locked": { + "lastModified": 1611672876, + "narHash": "sha256-qHu3uZ/o9jBHiA3MEKHJ06k7w4heOhA+4HCSIvflRxo=", + "owner": "hercules-ci", + "repo": "gitignore", + "rev": "211907489e9f198594c0eb0ca9256a1949c9d412", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore", + "type": "github" + } + }, + "mozillapkgs": { + "flake": false, + "locked": { + "lastModified": 1629225446, + "narHash": "sha256-HJX4Pc5ZUAg4apxB/XHuJ+6ukzvRQqeZMjscOBst2bA=", + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "rev": "0510159186dd2ef46e5464484fbdf119393afa58", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1631004250, + "narHash": "sha256-LGh0CjAZwh13AVkTi9w9lITEC7x6bwSQyFViOZ6HyNo=", + "owner": "nmattia", + "repo": "naersk", + "rev": "08afb3d1dbfe016108b72e05b02ba0f6ecb3c8e1", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1631279684, + "narHash": "sha256-IxRRCEW+8crDkbYj+uzwkfjZ8swugtnAmfRpPOpKq6I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ded7b6cb1bf3d6d03328b3f592069f2c4956a97f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1631279684, + "narHash": "sha256-IxRRCEW+8crDkbYj+uzwkfjZ8swugtnAmfRpPOpKq6I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ded7b6cb1bf3d6d03328b3f592069f2c4956a97f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "mozillapkgs": "mozillapkgs", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1629481132, + "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "997f7efcb746a9c140ce1f13c72263189225f482", + "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 0000000..ceccfc8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nmattia/naersk"; + mozillapkgs = { + url = "github:mozilla/nixpkgs-mozilla"; + flake = false; + }; + gitignore = { + url = "github:hercules-ci/gitignore"; + flake = false; + }; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, utils, naersk, mozillapkgs, gitignore, ... }: + utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages."${system}"; + inherit (import gitignore { inherit (pkgs) lib; }) gitignoreSource; + + # Get a specific rust version + mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") { }; + chanspec = { + date = "2021-03-31"; + channel = "nightly"; + sha256 = "oK5ebje09MRn988saJMT3Zze/tRE7u9zTeFPV1CEeLc="; # set zeros after modifying channel or date + }; + + rustChannel = mozilla.rustChannelOf chanspec; + rust = rustChannel.rust; + rust-src = rustChannel.rust-src; + + naersk-lib = naersk.lib."${system}".override { + cargo = rust; + rustc = rust; + }; + + nativeBuildInputs = with pkgs; [ ]; + + in + rec { + packages.nix-analyzer = naersk-lib.buildPackage { + pname = "nix-analyzer"; + version = "0.1.0"; + root = gitignoreSource ./.; + inherit nativeBuildInputs; + }; + defaultPackage = packages.nix-analyzer; + apps.nix-analyzer = utils.lib.mkApp { + drv = packages.nix-analyzer; + }; + apps.check = { + type = "app"; + program = "${pkgs.cargo-watch}/bin/cargo-watch"; + }; + defaultApp = apps.nix-analyzer; + devShell = pkgs.mkShell { + nativeBuildInputs = nativeBuildInputs ++ [ + rust + rust-src + pkgs.rust-analyzer + pkgs.rustfmt + pkgs.cargo + pkgs.cargo-watch + pkgs.cargo-tarpaulin + ]; + RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library"; + RUST_LOG = "info"; + RUST_BACKTRACE = 1; + }; + }); +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} -- cgit v1.2.3