This commit is contained in:
Akshay 2021-09-10 19:42:30 +05:30
commit 336e97961c
8 changed files with 322 additions and 0 deletions

1
.direnv/flake-profile Symbolic link
View File

@ -0,0 +1 @@
/home/np/code/rust/nix-analyzer/.direnv/flake-profile.30522

1
.direnv/flake-profile.rc Normal file
View File

@ -0,0 +1 @@

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
.envrc

104
Cargo.lock generated Normal file
View File

@ -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"

10
Cargo.toml Normal file
View File

@ -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"

125
flake.lock Normal file
View File

@ -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
}

76
flake.nix Normal file
View File

@ -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;
};
});
}

3
src/main.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}