diff --git a/.gitignore b/.gitignore index 215776a56c..a2e8d54929 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ ftd/t/js/**.manual.html ftd/t/js/**.script.html +# nix symlink to the build output +result + # Rust stuff target **/*.rs.bk diff --git a/flake.lock b/flake.lock index 57de9e3c0f..49f5c88d53 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,24 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": "nixpkgs" @@ -50,29 +68,29 @@ "type": "indirect" } }, - "nixpkgs-mozilla": { - "flake": false, + "nixpkgs_2": { "locked": { - "lastModified": 1695805681, - "narHash": "sha256-1ElPLD8eFfnuIk0G52HGGpRtQZ4QPCjChRlEOfkZ5ro=", - "owner": "mozilla", - "repo": "nixpkgs-mozilla", - "rev": "6eabade97bc28d707a8b9d82ad13ef143836736e", + "lastModified": 1697660476, + "narHash": "sha256-w5/4HKG6/TPOFUki4rYUbME8zC6+suT6hSunyFD4BlI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "964a525d67348323be4fa100345d37b361ebd36e", "type": "github" }, "original": { - "owner": "mozilla", - "repo": "nixpkgs-mozilla", + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { - "lastModified": 1697660476, - "narHash": "sha256-w5/4HKG6/TPOFUki4rYUbME8zC6+suT6hSunyFD4BlI=", + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "964a525d67348323be4fa100345d37b361ebd36e", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", "type": "github" }, "original": { @@ -87,7 +105,26 @@ "flake-utils": "flake-utils", "naersk": "naersk", "nixpkgs": "nixpkgs_2", - "nixpkgs-mozilla": "nixpkgs-mozilla" + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1697854201, + "narHash": "sha256-H+0Wb20PQx/8N7X/OfwwAVPeN9TbfjcyG0sXbdgsh50=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "6e8e3332433847cd56186b1f6fc8c47603cf5b46", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "systems": { @@ -104,6 +141,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index be326f2781..2889d81bf9 100644 --- a/flake.nix +++ b/flake.nix @@ -4,55 +4,62 @@ naersk.url = "github:nix-community/naersk"; - nixpkgs-mozilla = { - url = "github:mozilla/nixpkgs-mozilla"; - flake = false; - }; + rust-overlay.url = "github:oxalica/rust-overlay"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - }; - outputs = { self, flake-utils, nixpkgs, nixpkgs-mozilla, naersk }: + outputs = { self, flake-utils, nixpkgs, rust-overlay, naersk }: flake-utils.lib.eachDefaultSystem (system: let pkgs = (import nixpkgs) { inherit system; overlays = [ - (import nixpkgs-mozilla) + (import rust-overlay) ]; }; - toolchain = (pkgs.rustChannelOf { - rustToolchain = ./rust-toolchain; - sha256 = "sha256-rLP8+fTxnPHoR96ZJiCa/5Ans1OojI7MLsmSqR2ip8o="; - }).rust; + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain; naersk' = pkgs.callPackage naersk { cargo = toolchain; rustc = toolchain; }; - fastnp = naersk'.buildPackage { + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + + fastn = naersk'.buildPackage { name = "fastn"; - version = "0.3.0"; - src = ./.; + version = cargoToml.workspace.package.version; + src = pkgs.lib.cleanSource ./.; + + nativeBuildInputs = with pkgs; [ + pkg-config + openssl.dev + ] ++ lib.optionals stdenv.isDarwin [ xcbuild ]; - nativeBuildInputs = with pkgs; [ pkg-config openssl.dev ]; + buildInputs = with pkgs; lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.SystemConfiguration + ]; }; in rec { # For `nix build` & `nix run`: - defaultPackage = fastnp; + defaultPackage = fastn; packages = { - fastn = fastnp; + inherit fastn; }; # nix develop devShell = pkgs.mkShell { + name = "fastn-shell"; nativeBuildInputs = [ toolchain pkgs.pkg-config pkgs.openssl.dev ]; + + shellHook = '' + export PATH="$PATH:$HOME/.cargo/bin" + ''; }; formatter = pkgs.nixpkgs-fmt;