diff --git a/flake.lock b/flake.lock index bf3844e..1d1813c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,35 +1,47 @@ { "nodes": { - "fenix": { - "inputs": { - "nixpkgs": "nixpkgs", - "rust-analyzer-src": "rust-analyzer-src" - }, + "crate2nix": { + "flake": false, "locked": { - "lastModified": 1670566996, - "narHash": "sha256-M+KsSE2D8ByDf3HZhnvLRpytg8aXScoWhg+NrdHjeeE=", - "owner": "nix-community", - "repo": "fenix", - "rev": "ab24d0ad17a733624b99f5d6466e71b8c239a001", + "lastModified": 1668031227, + "narHash": "sha256-WSiooiJ2gtQGkZE0JBJkkqVz5wi3SETwygU4NuBHdgw=", + "owner": "kolloch", + "repo": "crate2nix", + "rev": "ad27c9f88eca7fcbaaa25194d51787715041ec30", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "fenix", + "owner": "kolloch", + "repo": "crate2nix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1670332253, - "narHash": "sha256-O5SmhlIUt1s+vK4NXeGYqwcBIMwbBPAEZ3GHE3XT28c=", - "owner": "nixos", + "lastModified": 1667991831, + "narHash": "sha256-DHgEsLZI044B9T4AjA3K6+yB9/DqLr4dyA7OIx0FG7o=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "1c9ffcf70786f0966982ce0fc76ec05df2e1dec2", + "rev": "872fceeed60ae6b7766cc0a4cd5bf5901b9098ec", "type": "github" }, "original": { - "owner": "nixos", + "owner": "NixOS", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" @@ -37,41 +49,44 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1670507980, - "narHash": "sha256-riNZa0xzM1it3pzxciwALeMs+0CsBMWIW2FqulzK8vM=", + "lastModified": 1665296151, + "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2787fc7d1e51404678614bf0fe92fc296746eec0", + "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "fenix": "fenix", - "nixpkgs": "nixpkgs_2", + "crate2nix": "crate2nix", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "utils": "utils" } }, - "rust-analyzer-src": { - "flake": false, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, "locked": { - "lastModified": 1670426523, - "narHash": "sha256-Zh+pAuj4PmBmISXCz+54yVSwSXZwbn+ZELgM85xVUE0=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "6e8a54d0f68702cf7981c8299357838eb0f4d5b2", + "lastModified": 1668048396, + "narHash": "sha256-SUWQlSa/H5XKPeuF9XmWzmwIJrgK42Lak6/1jBAwyd0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "859fefb532bb957f51a9b5e8e3ba2e48394c9353", "type": "github" }, "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", + "owner": "oxalica", + "repo": "rust-overlay", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 8cf65b0..0ff9977 100644 --- a/flake.nix +++ b/flake.nix @@ -4,10 +4,14 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; utils.url = "github:numtide/flake-utils"; - fenix.url = "github:nix-community/fenix"; + rust-overlay.url = "github:oxalica/rust-overlay"; + crate2nix = { + url = "github:kolloch/crate2nix"; + flake = false; + }; }; - outputs = { self, nixpkgs, utils, fenix }: let + outputs = { self, nixpkgs, utils, rust-overlay, crate2nix }: let name = "transbeam"; in utils.lib.eachDefaultSystem @@ -15,13 +19,22 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ fenix.overlays.default ]; - }; - fenixStable = fenix.packages.${system}.stable; - fenixPlatform = pkgs.makeRustPlatform { - cargo = fenixStable.toolchain; - rustc = fenixStable.toolchain; + overlays = [ + rust-overlay.overlays.default + (final: prev: { + rustc = final.rust-bin.stable.latest.default; + cargo = final.rust-bin.stable.latest.default; + }) + ]; }; + inherit (import "${crate2nix}/tools.nix" { inherit pkgs; }) + generatedCargoNix; + project = import + (generatedCargoNix { + inherit name; + src = ./.; + }) + { inherit pkgs; }; in rec { packages.${name} = pkgs.symlinkJoin { inherit name; @@ -36,14 +49,7 @@ defaultPackage = packages.${name}; - packages."${name}-unwrapped" = let - cargoTOML = builtins.fromTOML (builtins.readFile ./Cargo.toml); - in fenixPlatform.buildRustPackage { - pname = name; - inherit (cargoTOML.package) version; - src = ./.; - cargoLock.lockFile = ./Cargo.lock; - }; + packages."${name}-unwrapped" = project.rootCrate.build; packages."${name}-cli" = with pkgs.python3Packages; buildPythonApplication { pname = "${name}-cli"; @@ -55,18 +61,11 @@ src = ./cli; }; - devShell = with pkgs; let - fenixWith = fenixStable.withComponents [ - "cargo" - "clippy" - "rust-src" - "rustc" - "rustfmt" - ]; - in mkShell { - nativeBuildInputs = [ + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ stdenv.cc - fenixWith + rustc + cargo cargo-audit cargo-flamegraph (python3.withPackages (p: with p; [ @@ -74,6 +73,7 @@ websockets ])) ]; + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; }; } ); diff --git a/src/zip.rs b/src/zip.rs index d130eb4..e2772aa 100644 --- a/src/zip.rs +++ b/src/zip.rs @@ -395,7 +395,7 @@ mod tests { let mut zipgen = ZipGenerator::new( FileSet { files: vec![], - directory_name: Some("test".to_owned()), + directory_name: "test".to_owned(), }, Box::new(std::io::Cursor::new(&mut output)), );