diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 108 |
1 files changed, 44 insertions, 64 deletions
@@ -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 | } |