aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix96
1 files changed, 96 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..5e833d3
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,96 @@
1{
2 inputs = {
3 utils.url = "github:numtide/flake-utils";
4 naersk.url = "github:nmattia/naersk";
5 mozillapkgs = {
6 url = "github:andersk/nixpkgs-mozilla/stdenv.lib";
7 flake = false;
8 };
9 gitignore = {
10 url = "github:hercules-ci/gitignore";
11 flake = false;
12 };
13 flake-compat = {
14 url = "github:edolstra/flake-compat";
15 flake = false;
16 };
17 };
18
19 outputs = { self, nixpkgs, utils, naersk, mozillapkgs, gitignore, ... }:
20 utils.lib.eachDefaultSystem (system:
21 let
22 pkgs = nixpkgs.legacyPackages."${system}";
23 lib = pkgs.lib;
24 stdenv = pkgs.stdenv;
25 darwin = pkgs.darwin;
26 inherit (import gitignore { inherit (pkgs) lib; }) gitignoreSource;
27
28 # Get a specific rust version
29 mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") { };
30 chanspec = {
31 date = "2021-03-31";
32 channel = "nightly";
33 sha256 = "oK5ebje09MRn988saJMT3Zze/tRE7u9zTeFPV1CEeLc="; # set zeros after modifying channel or date
34 };
35
36 rustChannel = mozilla.rustChannelOf chanspec;
37 rust = rustChannel.rust.override {
38 targets = [ "wasm32-unknown-unknown" ];
39 extensions = [ ];
40 };
41 rust-src = rustChannel.rust-src;
42
43 naersk-lib = naersk.lib."${system}".override {
44 cargo = rust;
45 rustc = rust;
46 };
47
48 nativeBuildInputs = with pkgs; [
49 nixUnstable
50 ];
51
52 buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
53 darwin.apple_sdk.frameworks.Security
54 darwin.libiconv
55 ];
56
57 in
58 rec {
59 packages.cstea = naersk-lib.buildPackage {
60 pname = "cstea";
61 version = "0.1.0";
62 root = gitignoreSource ./.;
63 inherit nativeBuildInputs buildInputs;
64 };
65 defaultPackage = packages.cstea;
66 apps.cstea = utils.lib.mkApp {
67 drv = packages.cstea;
68 };
69 apps.check = {
70 type = "app";
71 program = "${pkgs.cargo-watch}/bin/cargo-watch";
72 };
73 defaultApp = apps.cstea;
74 devShell = pkgs.mkShell {
75 nativeBuildInputs = nativeBuildInputs ++ [
76 rust
77 rust-src
78 ] ++ (with pkgs; [
79 rust-analyzer
80 rustfmt
81 cargo
82 cargo-watch
83
84 miniserve
85 wasm-pack
86 cargo-generate
87 nodePackages.npm
88 nodejs
89 ]);
90 inherit buildInputs;
91 RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library";
92 RUST_LOG = "info";
93 RUST_BACKTRACE = 1;
94 };
95 });
96}