aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock77
-rw-r--r--flake.nix122
-rw-r--r--notes.txt1
3 files changed, 96 insertions, 104 deletions
diff --git a/flake.lock b/flake.lock
index 54aabdc..e8d9eb6 100644
--- a/flake.lock
+++ b/flake.lock
@@ -16,6 +16,21 @@
16 "type": "github" 16 "type": "github"
17 } 17 }
18 }, 18 },
19 "import-cargo": {
20 "locked": {
21 "lastModified": 1594305518,
22 "narHash": "sha256-frtArgN42rSaEcEOYWg8sVPMUK+Zgch3c+wejcpX3DY=",
23 "owner": "edolstra",
24 "repo": "import-cargo",
25 "rev": "25d40be4a73d40a2572e0cc233b83253554f06c5",
26 "type": "github"
27 },
28 "original": {
29 "owner": "edolstra",
30 "repo": "import-cargo",
31 "type": "github"
32 }
33 },
19 "mozillapkgs": { 34 "mozillapkgs": {
20 "flake": false, 35 "flake": false,
21 "locked": { 36 "locked": {
@@ -32,74 +47,28 @@
32 "type": "github" 47 "type": "github"
33 } 48 }
34 }, 49 },
35 "naersk": {
36 "inputs": {
37 "nixpkgs": "nixpkgs"
38 },
39 "locked": {
40 "lastModified": 1631004250,
41 "narHash": "sha256-LGh0CjAZwh13AVkTi9w9lITEC7x6bwSQyFViOZ6HyNo=",
42 "owner": "nmattia",
43 "repo": "naersk",
44 "rev": "08afb3d1dbfe016108b72e05b02ba0f6ecb3c8e1",
45 "type": "github"
46 },
47 "original": {
48 "owner": "nmattia",
49 "repo": "naersk",
50 "type": "github"
51 }
52 },
53 "nixpkgs": { 50 "nixpkgs": {
54 "locked": { 51 "locked": {
55 "lastModified": 1631279684, 52 "lastModified": 1633422745,
56 "narHash": "sha256-IxRRCEW+8crDkbYj+uzwkfjZ8swugtnAmfRpPOpKq6I=", 53 "narHash": "sha256-gA6Ok64nPbkjHk3Oanq4641EeYkjcKhisDF9wBjLxEk=",
57 "owner": "NixOS", 54 "owner": "nixos",
58 "repo": "nixpkgs", 55 "repo": "nixpkgs",
59 "rev": "ded7b6cb1bf3d6d03328b3f592069f2c4956a97f", 56 "rev": "8e1eab9eae4278c9bb1dcae426848a581943db5a",
60 "type": "github" 57 "type": "github"
61 }, 58 },
62 "original": { 59 "original": {
63 "id": "nixpkgs", 60 "owner": "nixos",
64 "type": "indirect" 61 "ref": "nixpkgs-unstable",
65 }
66 },
67 "nixpkgs_2": {
68 "locked": {
69 "lastModified": 1631279684,
70 "narHash": "sha256-IxRRCEW+8crDkbYj+uzwkfjZ8swugtnAmfRpPOpKq6I=",
71 "owner": "NixOS",
72 "repo": "nixpkgs", 62 "repo": "nixpkgs",
73 "rev": "ded7b6cb1bf3d6d03328b3f592069f2c4956a97f",
74 "type": "github" 63 "type": "github"
75 },
76 "original": {
77 "id": "nixpkgs",
78 "type": "indirect"
79 } 64 }
80 }, 65 },
81 "root": { 66 "root": {
82 "inputs": { 67 "inputs": {
83 "flake-compat": "flake-compat", 68 "flake-compat": "flake-compat",
69 "import-cargo": "import-cargo",
84 "mozillapkgs": "mozillapkgs", 70 "mozillapkgs": "mozillapkgs",
85 "naersk": "naersk", 71 "nixpkgs": "nixpkgs"
86 "nixpkgs": "nixpkgs_2",
87 "utils": "utils"
88 }
89 },
90 "utils": {
91 "locked": {
92 "lastModified": 1629481132,
93 "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
94 "owner": "numtide",
95 "repo": "flake-utils",
96 "rev": "997f7efcb746a9c140ce1f13c72263189225f482",
97 "type": "github"
98 },
99 "original": {
100 "owner": "numtide",
101 "repo": "flake-utils",
102 "type": "github"
103 } 72 }
104 } 73 }
105 }, 74 },
diff --git a/flake.nix b/flake.nix
index 82d7a1f..f7f62aa 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,80 +1,102 @@
1{ 1{
2 inputs = { 2 inputs = {
3 utils.url = "github:numtide/flake-utils"; 3
4 naersk.url = "github:nmattia/naersk"; 4 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
5
5 mozillapkgs = { 6 mozillapkgs = {
6 url = "github:mozilla/nixpkgs-mozilla"; 7 url = "github:mozilla/nixpkgs-mozilla";
7 flake = false; 8 flake = false;
8 }; 9 };
10
9 flake-compat = { 11 flake-compat = {
10 url = "github:edolstra/flake-compat"; 12 url = "github:edolstra/flake-compat";
11 flake = false; 13 flake = false;
12 }; 14 };
15
16 import-cargo.url = github:edolstra/import-cargo;
17
13 }; 18 };
14 19
15 outputs = 20 outputs =
16 { self 21 { self
17 , nixpkgs 22 , nixpkgs
18 , utils
19 , naersk
20 , mozillapkgs 23 , mozillapkgs
24 , import-cargo
21 , ... 25 , ...
22 }: 26 }:
23 utils.lib.eachDefaultSystem (system:
24 let 27 let
25 pkgs = nixpkgs.legacyPackages."${system}"; 28 inherit (import-cargo.builders) importCargo;
26 29 supportedSystems = [ "x86_64-linux" ];
27 # Get a specific rust version 30 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
28 mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") { }; 31 nixpkgsFor = forAllSystems (system:
32 import nixpkgs {
33 inherit system;
34 overlays = [ self.overlay ];
35 });
36 mozilla = p: p.callPackage (mozillapkgs + "/package-set.nix") { };
29 chanspec = { 37 chanspec = {
30 date = "2021-03-31"; 38 date = "2021-09-30";
31 channel = "nightly"; 39 channel = "nightly";
32 sha256 = "oK5ebje09MRn988saJMT3Zze/tRE7u9zTeFPV1CEeLc="; # set zeros after modifying channel or date 40 sha256 = "Elqn7GDBDE/QT1XTDyj0EvivbC//uwjWX8d+J3Pi0dY="; # set zeros after modifying channel or date
33 }; 41 };
42 in
43 {
34 44
35 rustChannel = mozilla.rustChannelOf chanspec; 45 overlay = final: prev:
36 rust = rustChannel.rust; 46 let
37 rust-src = rustChannel.rust-src; 47 rustChannel = (mozilla final.pkgs).rustChannelOf chanspec;
48 inherit (rustChannel) rust rustc rust-src;
49 in
50 {
38 51
39 naersk-lib = naersk.lib."${system}".override { 52 statix = with final; pkgs.stdenv.mkDerivation {
40 cargo = rust; 53 pname = "statix";
41 rustc = rust; 54 version = "v0.1.0";
42 }; 55 src = ./.;
56 nativeBuildInputs = [
57 (importCargo { lockFile = ./Cargo.lock; inherit pkgs; }).cargoHome
58 rust
59 cargo
60 ];
61 buildPhase = ''
62 cargo build -p statix --release --offline
63 '';
64 installPhase = ''
65 install -Dm775 ./target/release/statix $out/bin/statix
66 '';
67 };
43 68
44 nativeBuildInputs = with pkgs; [ ]; 69 };
45 70
46 in 71 packages = forAllSystems (system: {
47 rec { 72 inherit (nixpkgsFor."${system}") statix;
48 packages.statix = naersk-lib.buildPackage { 73 });
49 pname = "statix";
50 version = "0.1.0";
51 root = ./.;
52 inherit nativeBuildInputs;
53 };
54 74
55 defaultPackage = packages.statix; 75 defaultPackage =
56 apps.statix = utils.lib.mkApp { 76 forAllSystems (system: self.packages."${system}".statix);
57 drv = packages.statix;
58 };
59 77
60 apps.check = { 78 devShell = forAllSystems (system:
61 type = "app"; 79 let
62 program = "${pkgs.cargo-watch}/bin/cargo-watch"; 80 pkgs = nixpkgsFor.${system};
63 }; 81 rustChannel = (mozilla pkgs).rustChannelOf chanspec;
82 in
83 with pkgs;
84 mkShell rec {
85 buildInputs =
86 (with pkgs; [
87 rust-analyzer
88 rustfmt
89 cargo
90 cargo-watch
91 ]) ++ (with rustChannel; [
92 rust
93 rust-src
94 ]);
95 RUST_SRC_PATH = "${rustChannel.rust-src}/lib/rustlib/src/rust/library";
96 RUST_LOG = "info";
97 RUST_BACKTRACE = 1;
98 });
64 99
65 defaultApp = apps.statix; 100
66 devShell = pkgs.mkShell { 101 };
67 nativeBuildInputs = nativeBuildInputs ++ [
68 rust
69 rust-src
70 pkgs.rust-analyzer
71 pkgs.rustfmt
72 pkgs.cargo
73 pkgs.cargo-watch
74 ];
75 RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library";
76 RUST_LOG = "info";
77 RUST_BACKTRACE = 1;
78 };
79 });
80} 102}
diff --git a/notes.txt b/notes.txt
index d8c2f0a..73d9439 100644
--- a/notes.txt
+++ b/notes.txt
@@ -8,6 +8,7 @@ Interface
8- load files to be read as VFS 8- load files to be read as VFS
9- path interner 9- path interner
10- traits to go from Report to text/errfmt 10- traits to go from Report to text/errfmt
11- offline documentation/explaination for lints
11 12
12Fix 13Fix
13--- 14---