From a2e3441e6937f1769fed3e16a5f7f7135482cf97 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 19 Sep 2021 09:45:06 +0530 Subject: init --- flake.nix | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5e833d3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,96 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nmattia/naersk"; + mozillapkgs = { + url = "github:andersk/nixpkgs-mozilla/stdenv.lib"; + 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}"; + lib = pkgs.lib; + stdenv = pkgs.stdenv; + darwin = pkgs.darwin; + 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.override { + targets = [ "wasm32-unknown-unknown" ]; + extensions = [ ]; + }; + rust-src = rustChannel.rust-src; + + naersk-lib = naersk.lib."${system}".override { + cargo = rust; + rustc = rust; + }; + + nativeBuildInputs = with pkgs; [ + nixUnstable + ]; + + buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + darwin.libiconv + ]; + + in + rec { + packages.cstea = naersk-lib.buildPackage { + pname = "cstea"; + version = "0.1.0"; + root = gitignoreSource ./.; + inherit nativeBuildInputs buildInputs; + }; + defaultPackage = packages.cstea; + apps.cstea = utils.lib.mkApp { + drv = packages.cstea; + }; + apps.check = { + type = "app"; + program = "${pkgs.cargo-watch}/bin/cargo-watch"; + }; + defaultApp = apps.cstea; + devShell = pkgs.mkShell { + nativeBuildInputs = nativeBuildInputs ++ [ + rust + rust-src + ] ++ (with pkgs; [ + rust-analyzer + rustfmt + cargo + cargo-watch + + miniserve + wasm-pack + cargo-generate + nodePackages.npm + nodejs + ]); + inherit buildInputs; + RUST_SRC_PATH = "${rust-src}/lib/rustlib/src/rust/library"; + RUST_LOG = "info"; + RUST_BACKTRACE = 1; + }; + }); +} -- cgit v1.2.3