aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock92
-rw-r--r--flake.nix108
2 files changed, 87 insertions, 113 deletions
diff --git a/flake.lock b/flake.lock
index d6c75e8..5e46066 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,70 +1,48 @@
1{ 1{
2 "nodes": { 2 "nodes": {
3 "gitignore": { 3 "fenix": {
4 "inputs": { 4 "inputs": {
5 "nixpkgs": "nixpkgs" 5 "nixpkgs": [
6 "nixpkgs"
7 ],
8 "rust-analyzer-src": "rust-analyzer-src"
6 }, 9 },
7 "locked": { 10 "locked": {
8 "lastModified": 1635165013, 11 "lastModified": 1635661416,
9 "narHash": "sha256-o/BdVjNwcB6jOmzZjOH703BesSkkS5O7ej3xhyO8hAY=", 12 "narHash": "sha256-8Bu1EdrPpGl4w1qlGGxlnEgYdkGkQpT4/4ZTq3z+1as=",
10 "owner": "hercules-ci", 13 "owner": "nix-community",
11 "repo": "gitignore.nix", 14 "repo": "fenix",
12 "rev": "5b9e0ff9d3b551234b4f3eb3983744fa354b17f1", 15 "rev": "1b311df00378e8e9ddc824983220e5ce644a8215",
13 "type": "github" 16 "type": "github"
14 }, 17 },
15 "original": { 18 "original": {
16 "owner": "hercules-ci", 19 "owner": "nix-community",
17 "repo": "gitignore.nix", 20 "repo": "fenix",
18 "type": "github" 21 "type": "github"
19 } 22 }
20 }, 23 },
21 "import-cargo": { 24 "gitignore": {
22 "locked": { 25 "inputs": {
23 "lastModified": 1594305518, 26 "nixpkgs": [
24 "narHash": "sha256-frtArgN42rSaEcEOYWg8sVPMUK+Zgch3c+wejcpX3DY=", 27 "nixpkgs"
25 "owner": "edolstra", 28 ]
26 "repo": "import-cargo",
27 "rev": "25d40be4a73d40a2572e0cc233b83253554f06c5",
28 "type": "github"
29 }, 29 },
30 "original": {
31 "owner": "edolstra",
32 "repo": "import-cargo",
33 "type": "github"
34 }
35 },
36 "mozillapkgs": {
37 "flake": false,
38 "locked": { 30 "locked": {
39 "lastModified": 1629225446, 31 "lastModified": 1635165013,
40 "narHash": "sha256-HJX4Pc5ZUAg4apxB/XHuJ+6ukzvRQqeZMjscOBst2bA=", 32 "narHash": "sha256-o/BdVjNwcB6jOmzZjOH703BesSkkS5O7ej3xhyO8hAY=",
41 "owner": "mozilla", 33 "owner": "hercules-ci",
42 "repo": "nixpkgs-mozilla", 34 "repo": "gitignore.nix",
43 "rev": "0510159186dd2ef46e5464484fbdf119393afa58", 35 "rev": "5b9e0ff9d3b551234b4f3eb3983744fa354b17f1",
44 "type": "github" 36 "type": "github"
45 }, 37 },
46 "original": { 38 "original": {
47 "owner": "mozilla", 39 "owner": "hercules-ci",
48 "repo": "nixpkgs-mozilla", 40 "repo": "gitignore.nix",
49 "type": "github" 41 "type": "github"
50 } 42 }
51 }, 43 },
52 "nixpkgs": { 44 "nixpkgs": {
53 "locked": { 45 "locked": {
54 "lastModified": 1632846328,
55 "narHash": "sha256-sFi6YtlGK30TBB9o6CW7LG9mYHkgtKeWbSLAjjrNTX0=",
56 "owner": "NixOS",
57 "repo": "nixpkgs",
58 "rev": "2b71ddd869ad592510553d09fe89c9709fa26b2b",
59 "type": "github"
60 },
61 "original": {
62 "id": "nixpkgs",
63 "type": "indirect"
64 }
65 },
66 "nixpkgs_2": {
67 "locked": {
68 "lastModified": 1633422745, 46 "lastModified": 1633422745,
69 "narHash": "sha256-gA6Ok64nPbkjHk3Oanq4641EeYkjcKhisDF9wBjLxEk=", 47 "narHash": "sha256-gA6Ok64nPbkjHk3Oanq4641EeYkjcKhisDF9wBjLxEk=",
70 "owner": "nixos", 48 "owner": "nixos",
@@ -81,10 +59,26 @@
81 }, 59 },
82 "root": { 60 "root": {
83 "inputs": { 61 "inputs": {
62 "fenix": "fenix",
84 "gitignore": "gitignore", 63 "gitignore": "gitignore",
85 "import-cargo": "import-cargo", 64 "nixpkgs": "nixpkgs"
86 "mozillapkgs": "mozillapkgs", 65 }
87 "nixpkgs": "nixpkgs_2" 66 },
67 "rust-analyzer-src": {
68 "flake": false,
69 "locked": {
70 "lastModified": 1635274542,
71 "narHash": "sha256-Cew1/WUozM3jalItPuj4cNN8GIFMvCaJ1KXoj6wrHwE=",
72 "owner": "rust-analyzer",
73 "repo": "rust-analyzer",
74 "rev": "dd43f3f2d13a32199828e758ddf13176df1f17f9",
75 "type": "github"
76 },
77 "original": {
78 "owner": "rust-analyzer",
79 "ref": "nightly",
80 "repo": "rust-analyzer",
81 "type": "github"
88 } 82 }
89 } 83 }
90 }, 84 },
diff --git a/flake.nix b/flake.nix
index 702e818..439f076 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,27 +3,25 @@
3 3
4 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 4 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
5 5
6 mozillapkgs = { 6 fenix = {
7 url = "github:mozilla/nixpkgs-mozilla"; 7 url = "github:nix-community/fenix";
8 flake = false; 8 inputs.nixpkgs.follows = "nixpkgs";
9 }; 9 };
10 10
11 import-cargo.url = "github:edolstra/import-cargo"; 11 gitignore = {
12 12 url = "github:hercules-ci/gitignore.nix";
13 gitignore.url = "github:hercules-ci/gitignore.nix"; 13 inputs.nixpkgs.follows = "nixpkgs";
14 };
14 15
15 }; 16 };
16 17
17 outputs = 18 outputs =
18 { self 19 { self
19 , nixpkgs 20 , nixpkgs
20 , mozillapkgs 21 , fenix
21 , import-cargo
22 , gitignore 22 , gitignore
23 , ...
24 }: 23 }:
25 let 24 let
26 inherit (import-cargo.builders) importCargo;
27 inherit (gitignore.lib) gitignoreSource; 25 inherit (gitignore.lib) gitignoreSource;
28 26
29 supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; 27 supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
@@ -34,57 +32,43 @@
34 overlays = [ self.overlay ]; 32 overlays = [ self.overlay ];
35 }); 33 });
36 34
37 mozilla = p: p.callPackage (mozillapkgs + "/package-set.nix") { };
38 chanspec = { 35 chanspec = {
39 date = "2021-09-30"; 36 date = "2021-11-01";
40 channel = "nightly"; 37 channel = "nightly";
41 sha256 = "Elqn7GDBDE/QT1XTDyj0EvivbC//uwjWX8d+J3Pi0dY="; # set zeros after modifying channel or date 38 sha256 = "2BmxGawDNjXHJvnQToxmErMGgEPOfVzUvxhkvuixHYU="; # set zeros after modifying channel or date
42 }; 39 };
43 rustChannel = p: (mozilla p).rustChannelOf chanspec; 40 rustChannel = p: (fenix.overlay p p).fenix.toolchainOf chanspec;
44 41
45 in 42 in
46 { 43 {
47 44
48 overlay = final: prev: 45 overlay = final: prev: {
49 let 46 statix = with final; (makeRustPlatform {
50 inherit (rustChannel final.pkgs) rust rust-src; 47 inherit (rustChannel final) cargo rustc;
51 in 48 }).buildRustPackage rec {
52 { 49 pname = "statix";
53 50 version = (lib.importTOML ./bin/Cargo.toml).package.version;
54 statix = with final; pkgs.stdenv.mkDerivation { 51
55 pname = "statix"; 52 src = gitignoreSource ./.;
56 version = "v0.3.4";
57 src = gitignoreSource ./.;
58 nativeBuildInputs = [
59 (importCargo { lockFile = ./Cargo.lock; inherit pkgs; }).cargoHome
60 rust
61 cargo
62 ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
63 buildPhase = ''
64 cargo build -p statix --all-features --release --offline
65 '';
66 # statix does not have any tests currently
67 doCheck = false;
68 installPhase = ''
69 install -Dm775 ./target/release/statix $out/bin/statix
70 '';
71
72 meta = with pkgs.lib; {
73 description = "Lints and suggestions for the Nix programming language";
74 homepage = "https://git.peppe.rs/languages/statix/about";
75 license = licenses.mit;
76 };
77 };
78 53
79 statix-vim = 54 cargoLock.lockFile = ./Cargo.lock;
80 with final; pkgs.vimUtils.buildVimPlugin {
81 pname = "statix-vim";
82 version = "0.1.0";
83 src = ./vim-plugin;
84 };
85 55
56 meta = with lib; {
57 description = "Lints and suggestions for the Nix programming language";
58 homepage = "https://git.peppe.rs/languages/statix/about";
59 license = licenses.mit;
60 };
86 }; 61 };
87 62
63 statix-vim =
64 with final; vimUtils.buildVimPlugin {
65 pname = "statix-vim";
66 version = "0.1.0";
67 src = ./vim-plugin;
68 };
69
70 };
71
88 packages = forAllSystems (system: { 72 packages = forAllSystems (system: {
89 inherit (nixpkgsFor."${system}") statix statix-vim; 73 inherit (nixpkgsFor."${system}") statix statix-vim;
90 }); 74 });
@@ -92,31 +76,27 @@
92 defaultPackage = 76 defaultPackage =
93 forAllSystems (system: self.packages."${system}".statix); 77 forAllSystems (system: self.packages."${system}".statix);
94 78
95 defaultApp = forAllSystems (system:
96 {
97 type = "app";
98 program = "${self.packages."${system}".statix}/bin/statix";
99 });
100
101 devShell = forAllSystems (system: 79 devShell = forAllSystems (system:
102 let 80 let
103 pkgs = nixpkgsFor."${system}"; 81 pkgs = nixpkgsFor."${system}";
104 inherit (rustChannel pkgs) rust rust-src rust-analysis; 82 toolchain = (rustChannel pkgs).withComponents [
83 "rustc"
84 "cargo"
85 "rust-std"
86 "rustfmt"
87 "clippy"
88 "rust-src"
89 ];
105 in 90 in
106 with pkgs; 91 with pkgs;
107 mkShell rec { 92 mkShell rec {
108 buildInputs = [ 93 nativeBuildInputs = [
109 rustfmt
110 cargo
111 cargo-watch 94 cargo-watch
112 rust 95 toolchain
113 rust-src
114 ]; 96 ];
115 RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library";
116 RUST_LOG = "info"; 97 RUST_LOG = "info";
117 RUST_BACKTRACE = 1; 98 RUST_BACKTRACE = 1;
118 }); 99 });
119 100
120
121 }; 101 };
122} 102}