├── .github └── workflows │ ├── flake-update.yml │ ├── nix.yml │ └── publish.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── examples ├── cross-compile-aarch64 │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ ├── rust-toolchain.toml │ └── src │ │ └── main.rs ├── cross-compile-wasm │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ ├── index.html │ ├── index.scss │ ├── rust-toolchain.toml │ └── src │ │ ├── app.rs │ │ └── main.rs ├── cross-compile-windows │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ └── src │ │ └── main.rs ├── customize-devshell │ └── flake.nix ├── customize-profiles │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ └── src │ │ └── main.rs ├── customize-stdenv │ ├── Cargo.lock │ ├── Cargo.toml │ ├── flake.nix │ └── src │ │ └── main.rs ├── numtide-devshell │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ └── src │ │ └── main.rs ├── simple-crate │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ └── src │ │ └── main.rs ├── simple-workspace │ ├── Cargo.lock │ ├── Cargo.toml │ ├── crates.nix │ ├── flake.nix │ ├── my-other-workspace-crate │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── my-workspace-crate │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs └── simple │ ├── crates.nix │ └── flake.nix ├── flake.lock ├── flake.nix └── src ├── default.nix ├── functions ├── combineDocsPackages.nix ├── filterDevshellIllegalVars.nix ├── findRustToolchain.nix ├── getModuleDefaults.nix ├── getProjectCrates.nix ├── mkCheckOnlyPackage.nix ├── mkClippyOnlyPackage.nix ├── mkDevshellFromRaw.nix ├── mkDocsOnlyPackage.nix ├── mkGenerateLockfilesApp.nix ├── mkPackagesFromRaw.nix ├── mkRawshellFromDrvs.nix └── warnIfNoLock.nix ├── implementation.nix ├── interface.nix ├── modules ├── crate.nix ├── output.nix ├── profile.nix ├── project.nix └── target.nix └── options ├── drvConfig.nix └── numtideDevshell.nix /.github/workflows/flake-update.yml: -------------------------------------------------------------------------------- 1 | name: "Update Flake Deps" 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: '0 6 * * *' 6 | 7 | jobs: 8 | update-flake-deps: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout repo 12 | uses: actions/checkout@v3 13 | with: 14 | token: ${{ secrets.PAT }} 15 | - name: Install nix 16 | uses: cachix/install-nix-action@v20 17 | with: 18 | extra_nix_config: | 19 | experimental-features = nix-command flakes 20 | nix_path: nixpkgs=channel:nixos-unstable 21 | - name: Update flake deps 22 | run: nix flake update 23 | - name: Commit 24 | uses: stefanzweifel/git-auto-commit-action@v4 25 | with: 26 | commit_message: "chore(deps): update flake deps" 27 | branch: master 28 | -------------------------------------------------------------------------------- /.github/workflows/nix.yml: -------------------------------------------------------------------------------- 1 | name: "Nix" 2 | on: 3 | workflow_dispatch: 4 | pull_request: 5 | branches: [ master ] 6 | push: 7 | branches: [ master ] 8 | jobs: 9 | tests: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout repo 13 | uses: actions/checkout@v4 14 | - name: Install nix 15 | uses: cachix/install-nix-action@v30 16 | with: 17 | extra_nix_config: | 18 | experimental-features = nix-command flakes 19 | nix_path: nixpkgs=channel:nixos-unstable 20 | - name: Setup cachix 21 | uses: cachix/cachix-action@v15 22 | with: 23 | name: nix-cargo-integration 24 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 25 | - name: Test checks 26 | run: nix flake check -L --show-trace 27 | - name: Test numtide devshell integration 28 | run: | 29 | sed -i 's|github:yusdacra/nix-cargo-integration|path:../..|g' examples/numtide-devshell/flake.nix 30 | nix develop -L --show-trace ./examples/numtide-devshell#default -c env 31 | - name: Test wasm cross compile 32 | run: | 33 | sed -i 's|github:yusdacra/nix-cargo-integration|path:../..|g' examples/cross-compile-wasm/flake.nix 34 | nix build -L --show-trace ./examples/cross-compile-wasm 35 | - name: Test aarch64 cross compile 36 | run: | 37 | sed -i 's|github:yusdacra/nix-cargo-integration|path:../..|g' examples/cross-compile-aarch64/flake.nix 38 | nix build -L --show-trace ./examples/cross-compile-aarch64 39 | - name: Test windows cross compile 40 | run: | 41 | sed -i 's|github:yusdacra/nix-cargo-integration|path:../..|g' examples/cross-compile-windows/flake.nix 42 | nix build -L --show-trace ./examples/cross-compile-windows 43 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: "Publish a flake to flakestry" 2 | on: 3 | push: 4 | tags: 5 | - "v?[0-9]+.[0-9]+.[0-9]+" 6 | - "v?[0-9]+.[0-9]+" 7 | workflow_dispatch: 8 | inputs: 9 | tag: 10 | description: "The existing tag to publish" 11 | type: "string" 12 | required: true 13 | jobs: 14 | publish-flake: 15 | runs-on: ubuntu-latest 16 | permissions: 17 | id-token: "write" 18 | contents: "read" 19 | steps: 20 | - uses: flakestry/flakestry-publish@main 21 | with: 22 | version: "${{ inputs.tag || github.ref_name }}" 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | examples/**/target 2 | examples/**/flake.lock 3 | examples/**/result 4 | /result* 5 | .direnv 6 | cli/target 7 | /shell.nix 8 | .vscode 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Recent important changes 2 | 3 | This is a list of important (mostly breaking) changes. The dates are from 4 | most recent to least recent. 5 | 6 | `nix:` means that the change was related to the Nix library part of `nci`. 7 | ~~`cargo-toml:` means that the change was related to the `Cargo.toml` attribute part of `nci`.~~ 8 | 9 | ## 15-11-2024 10 | 11 | - nix: `toolchains.` attributes were removed and replaced with `toolchains.mkBuild` and `toolchains.mkShell` respectively. 12 | - these take functions that take a nixpkgs instance and should output a rust toolchain package. 13 | 14 | ## 03-10-2023 15 | 16 | - nix: new `nci.outputs..check` and `nci.crates..checkProfile` options 17 | - the new `check` output is a package that *only* runs `cargo test` 18 | using the package generated for the profile specified in `checkProfile`. 19 | 20 | ## 27-09-2023 21 | 22 | - nix: new `nci.projects..targets` and `nci.crates..targets` options 23 | - These allow you to generate separate packages for separate targets, and configure each target separately 24 | - Please check the option's documentation for more info, and the `cross-compile-wasm` example. 25 | 26 | ## 26-09-2023 27 | 28 | - nix: `drvConfig` and `depsDrvConfig` options were changed to resemble `dream2nix` more 29 | - `mkDerivation` options now must be defined under `drvConfig.mkDerivation` and `depsDrvConfig.mkDerivation` respectively 30 | - nix: implemented `drvConfig` and `depsDrvConfig` under `nci.crates..profiles.` option 31 | - This means that now every profile package can be customized separately. 32 | - nix: added a [new example](./examples/customize-profiles) showcasing how to customize profiles 33 | 34 | ## 19-09-2023 35 | 36 | - nix: update internals to use dream2nix v1 API. 37 | - nix: remove `overrides` and `depsOverrides` options from project and crate settings. 38 | - These are now replaced by `drvConfig` and `depsDrvConfig` respectively. Please check out the updated examples. 39 | - nix: replace project `relPath` setting with `path` setting. 40 | - nix: change default value of `export` in project settings to `true`. 41 | - This means that all packages and development shells will be exported by default now. 42 | - You can set `nci.projects."project-name".export = false` to return to old behaviour. 43 | - nix: added new option `nci.toolchainConfig` 44 | - This allows you to set the toolchain configuration manually. 45 | - It can point to a `rust-toolchain.toml` or legacy `rust-toolchain` file, or 46 | - it can point to an attrset containing what the `toolchain` section in a `rust-toolchain.toml` file would contain 47 | - (so options such as `channel`, `components` and `targets`) 48 | 49 | ## 19-02-2023 50 | 51 | - nix: rewrite in flake-parts! Please look at the readme for new documentation link. 52 | If you have any questions on how to migrate, please ask them here on GitHub Discussions. 53 | 54 | ## 04-11-2022 55 | 56 | - nix: the outputs prefixed with `-debug` are now named with the `-dev` prefix. @ 57 | - This was done to have more consistency with Cargo profiles (eg. `profiles.dev` == `-dev` prefix). 58 | 59 | ## 24-09-2022 60 | 61 | - nix and cargo-toml: the whole interface was changed! Please refer to the documentation and the example flake. 62 | 63 | ## 20-06-2022 64 | 65 | - nix: the `rustOverlay` input was changed to `rust-overlay` @ e3b4e564fc689c8e32d4b5e76f3cbbd055cb9830 66 | - nix: `common.pkgsWithRust` is removed, you can now access the Rust toolchain via `common.rustToolchain` @ e3b4e564fc689c8e32d4b5e76f3cbbd055cb9830 67 | 68 | ## 19-05-2022 69 | 70 | - nix: `overrides.pkgsOverlays` and `overrides.systems` were moved to `pkgsOverlays` and `systems` arguments to `makeOutputs` @ 3e733afea5b5533fc57d10bbd1c2d6b14d6ee304 71 | - nix: `systems` now just take a list of strings instead of a function taking default systems @ 3e733afea5b5533fc57d10bbd1c2d6b14d6ee304 72 | 73 | ## 12-03-2022 74 | 75 | - cargo-toml: `library` option in `package.metadata.nix` is removed and will no longer be used @ 11f26a1aa9aeddfb2ca32b3441091d4d8dc4cf0c 76 | - nix: `overrides.crateOverrides` was renamed to `overrides.crates` @ 11f26a1aa9aeddfb2ca32b3441091d4d8dc4cf0c 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Yusuf Bera Ertan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nix-cargo-integration 2 | 3 | Easily and effortlessly integrate Cargo projects with Nix. 4 | 5 | - Uses [dream2nix](https://github.com/nix-community/dream2nix) to build Cargo packages and provide a development shell (dream2nix default, also supports numtide devshell, check examples). 6 | - It's a [flake-parts](https://github.com/hercules-ci/flake-parts) module, so you can easily include it in existing Nix code that also use `flake-parts`. 7 | - Has sensible defaults, and strives to be compatible with Cargo. 8 | - Aims to offload work from the user; comes with useful configuration options. 9 | 10 | ## Documentation 11 | 12 | Documentation for `master` branch is on [flake-parts website](https://flake.parts/options/nix-cargo-integration.html) 13 | (alternatively, read options directly in [`src/interface.nix`](./src/interface.nix) and [`src/modules`](./src/modules)). 14 | 15 | Examples can be found at [`examples`](./examples) directory. 16 | Also see the [discussions](https://github.com/yusdacra/nix-cargo-integration/discussions) for answers to possible questions. 17 | 18 | Important (mostly breaking) changes can be found in [`CHANGELOG.md`](./CHANGELOG.md). 19 | 20 | ## Installation 21 | 22 | Run `nix flake init -t github:yusdacra/nix-cargo-integration` to initialize a simple `flake.nix`. 23 | 24 | You can also run `nix flake init -t github:yusdacra/nix-cargo-integration#simple-crate` to initialize a Cargo crate alongside the `flake.nix`, 25 | or `nix flake init -t github:yusdacra/nix-cargo-integration#simple-workspace` for a Cargo workspace with a `flake.nix`. 26 | 27 | If you already have a `flake.nix` with `flake-parts` setup, just add NCI to inputs: 28 | 29 | ```nix 30 | { 31 | # ... 32 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 33 | # ... 34 | } 35 | ``` 36 | 37 | and then inside the `mkFlake`: 38 | 39 | ```nix 40 | { 41 | imports = [ 42 | inputs.nci.flakeModule 43 | ]; 44 | } 45 | ``` 46 | 47 | ## Tips and tricks 48 | 49 | ### Ignoring `Cargo.lock` in Rust libraries 50 | 51 | The [official recommendation](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html) 52 | for Rust libraries *used to* say to add `Cargo.lock` to the `.gitignore`. 53 | [This is now no longer the case](https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html), 54 | however older projects may still do this, which will cause conflicts 55 | with the way paths are evaluated when using a `flake.nix`. Only files tracked 56 | by the version control system (i.e. git) can be accessed during evaluation. 57 | This will manifest in the following warning: 58 | 59 | ```console 60 | $ nix build 61 | trace: Cargo.lock not found for project at path path/to/project. 62 | Please ensure the lockfile exists for your project. 63 | If you are using a VCS, ensure the lockfile is added to the VCS and not ignored (eg. run `git add path/to/project/Cargo.lock` for git). 64 | 65 | This project will be skipped and won't have any outputs generated. 66 | Run `nix run .#generate-lockfiles` to generate lockfiles for projects that don't have one. 67 | ``` 68 | 69 | A neat fix for that is to track the path to `Cargo.lock` without staging it 70 | ([thanks to @bew](https://github.com/yusdacra/nix-cargo-integration/issues/46#issuecomment-962589582)). 71 | 72 | ```console 73 | $ git add --intent-to-add Cargo.lock 74 | ``` 75 | 76 | Add `--force` if your `Cargo.lock` is listed in `.gitignore`. 77 | -------------------------------------------------------------------------------- /examples/cross-compile-aarch64/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "cc" 7 | version = "1.2.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" 10 | dependencies = [ 11 | "shlex", 12 | ] 13 | 14 | [[package]] 15 | name = "cross-compile-aarch64" 16 | version = "0.1.0" 17 | dependencies = [ 18 | "openssl-sys", 19 | ] 20 | 21 | [[package]] 22 | name = "libc" 23 | version = "0.2.162" 24 | source = "registry+https://github.com/rust-lang/crates.io-index" 25 | checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" 26 | 27 | [[package]] 28 | name = "openssl-sys" 29 | version = "0.9.104" 30 | source = "registry+https://github.com/rust-lang/crates.io-index" 31 | checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" 32 | dependencies = [ 33 | "cc", 34 | "libc", 35 | "pkg-config", 36 | "vcpkg", 37 | ] 38 | 39 | [[package]] 40 | name = "pkg-config" 41 | version = "0.3.31" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" 44 | 45 | [[package]] 46 | name = "shlex" 47 | version = "1.3.0" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 50 | 51 | [[package]] 52 | name = "vcpkg" 53 | version = "0.2.15" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 56 | -------------------------------------------------------------------------------- /examples/cross-compile-aarch64/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cross-compile-aarch64" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | openssl-sys = "*" 8 | -------------------------------------------------------------------------------- /examples/cross-compile-aarch64/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = { 3 | pkgs, 4 | config, 5 | lib, 6 | ... 7 | }: let 8 | crateName = "cross-compile-aarch64"; 9 | in { 10 | # declare projects 11 | nci.projects.${crateName}.path = ./.; 12 | # configure crates 13 | nci.crates.${crateName} = { 14 | targets."aarch64-unknown-linux-gnu" = let 15 | targetPkgs = pkgs.pkgsCross.aarch64-multiplatform; 16 | targetCC = targetPkgs.stdenv.cc; 17 | targetCargoEnvVarTarget = targetPkgs.hostPlatform.rust.cargoEnvVarTarget; 18 | in rec { 19 | default = true; 20 | depsDrvConfig.mkDerivation = { 21 | nativeBuildInputs = [targetCC pkgs.pkg-config pkgs.qemu]; 22 | buildInputs = [targetPkgs.openssl]; 23 | }; 24 | depsDrvConfig.env = rec { 25 | TARGET_CC = "${targetCC.targetPrefix}cc"; 26 | "CARGO_TARGET_${targetCargoEnvVarTarget}_LINKER" = TARGET_CC; 27 | "CARGO_TARGET_${targetCargoEnvVarTarget}_RUNNER" = "qemu-aarch64"; 28 | }; 29 | drvConfig = depsDrvConfig; 30 | }; 31 | }; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /examples/cross-compile-aarch64/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [ 16 | nci.flakeModule 17 | ./crates.nix 18 | ]; 19 | perSystem = { 20 | pkgs, 21 | config, 22 | ... 23 | }: let 24 | # shorthand for accessing this crate's outputs 25 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 26 | crateOutputs = config.nci.outputs."cross-compile-aarch64"; 27 | in { 28 | # export the crate devshell as the default devshell 29 | devShells.default = crateOutputs.devShell; 30 | # export the release package of the crate as default package 31 | packages.default = crateOutputs.packages.release; 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /examples/cross-compile-aarch64/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "stable" 3 | targets = ["aarch64-unknown-linux-gnu"] 4 | -------------------------------------------------------------------------------- /examples/cross-compile-aarch64/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello world!") 3 | } 4 | 5 | #[cfg(test)] 6 | #[test] 7 | fn test_dummy() { 8 | assert!(true); 9 | } 10 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.24.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler2" 16 | version = "2.0.0" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" 19 | 20 | [[package]] 21 | name = "anymap2" 22 | version = "0.13.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" 25 | 26 | [[package]] 27 | name = "autocfg" 28 | version = "1.4.0" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 31 | 32 | [[package]] 33 | name = "backtrace" 34 | version = "0.3.74" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" 37 | dependencies = [ 38 | "addr2line", 39 | "cfg-if", 40 | "libc", 41 | "miniz_oxide", 42 | "object", 43 | "rustc-demangle", 44 | "windows-targets", 45 | ] 46 | 47 | [[package]] 48 | name = "bincode" 49 | version = "1.3.3" 50 | source = "registry+https://github.com/rust-lang/crates.io-index" 51 | checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" 52 | dependencies = [ 53 | "serde", 54 | ] 55 | 56 | [[package]] 57 | name = "boolinator" 58 | version = "2.4.0" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9" 61 | 62 | [[package]] 63 | name = "bumpalo" 64 | version = "3.16.0" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" 67 | 68 | [[package]] 69 | name = "bytes" 70 | version = "1.9.0" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" 73 | 74 | [[package]] 75 | name = "cfg-if" 76 | version = "1.0.0" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 79 | 80 | [[package]] 81 | name = "console_error_panic_hook" 82 | version = "0.1.7" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 85 | dependencies = [ 86 | "cfg-if", 87 | "wasm-bindgen", 88 | ] 89 | 90 | [[package]] 91 | name = "cross-compile" 92 | version = "0.1.0" 93 | dependencies = [ 94 | "yew", 95 | ] 96 | 97 | [[package]] 98 | name = "equivalent" 99 | version = "1.0.1" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 102 | 103 | [[package]] 104 | name = "fnv" 105 | version = "1.0.7" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 108 | 109 | [[package]] 110 | name = "form_urlencoded" 111 | version = "1.2.1" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 114 | dependencies = [ 115 | "percent-encoding", 116 | ] 117 | 118 | [[package]] 119 | name = "futures" 120 | version = "0.3.31" 121 | source = "registry+https://github.com/rust-lang/crates.io-index" 122 | checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" 123 | dependencies = [ 124 | "futures-channel", 125 | "futures-core", 126 | "futures-io", 127 | "futures-sink", 128 | "futures-task", 129 | "futures-util", 130 | ] 131 | 132 | [[package]] 133 | name = "futures-channel" 134 | version = "0.3.31" 135 | source = "registry+https://github.com/rust-lang/crates.io-index" 136 | checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" 137 | dependencies = [ 138 | "futures-core", 139 | "futures-sink", 140 | ] 141 | 142 | [[package]] 143 | name = "futures-core" 144 | version = "0.3.31" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" 147 | 148 | [[package]] 149 | name = "futures-io" 150 | version = "0.3.31" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" 153 | 154 | [[package]] 155 | name = "futures-macro" 156 | version = "0.3.31" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" 159 | dependencies = [ 160 | "proc-macro2", 161 | "quote", 162 | "syn 2.0.96", 163 | ] 164 | 165 | [[package]] 166 | name = "futures-sink" 167 | version = "0.3.31" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" 170 | 171 | [[package]] 172 | name = "futures-task" 173 | version = "0.3.31" 174 | source = "registry+https://github.com/rust-lang/crates.io-index" 175 | checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" 176 | 177 | [[package]] 178 | name = "futures-util" 179 | version = "0.3.31" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" 182 | dependencies = [ 183 | "futures-channel", 184 | "futures-core", 185 | "futures-io", 186 | "futures-macro", 187 | "futures-sink", 188 | "futures-task", 189 | "memchr", 190 | "pin-project-lite", 191 | "pin-utils", 192 | "slab", 193 | ] 194 | 195 | [[package]] 196 | name = "getrandom" 197 | version = "0.2.15" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 200 | dependencies = [ 201 | "cfg-if", 202 | "js-sys", 203 | "libc", 204 | "wasi", 205 | "wasm-bindgen", 206 | ] 207 | 208 | [[package]] 209 | name = "gimli" 210 | version = "0.31.1" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" 213 | 214 | [[package]] 215 | name = "gloo" 216 | version = "0.8.1" 217 | source = "registry+https://github.com/rust-lang/crates.io-index" 218 | checksum = "28999cda5ef6916ffd33fb4a7b87e1de633c47c0dc6d97905fee1cdaa142b94d" 219 | dependencies = [ 220 | "gloo-console 0.2.3", 221 | "gloo-dialogs 0.1.1", 222 | "gloo-events 0.1.2", 223 | "gloo-file 0.2.3", 224 | "gloo-history 0.1.5", 225 | "gloo-net 0.3.1", 226 | "gloo-render 0.1.1", 227 | "gloo-storage 0.2.2", 228 | "gloo-timers 0.2.6", 229 | "gloo-utils 0.1.7", 230 | "gloo-worker 0.2.1", 231 | ] 232 | 233 | [[package]] 234 | name = "gloo" 235 | version = "0.10.0" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "cd35526c28cc55c1db77aed6296de58677dbab863b118483a27845631d870249" 238 | dependencies = [ 239 | "gloo-console 0.3.0", 240 | "gloo-dialogs 0.2.0", 241 | "gloo-events 0.2.0", 242 | "gloo-file 0.3.0", 243 | "gloo-history 0.2.2", 244 | "gloo-net 0.4.0", 245 | "gloo-render 0.2.0", 246 | "gloo-storage 0.3.0", 247 | "gloo-timers 0.3.0", 248 | "gloo-utils 0.2.0", 249 | "gloo-worker 0.4.0", 250 | ] 251 | 252 | [[package]] 253 | name = "gloo-console" 254 | version = "0.2.3" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "82b7ce3c05debe147233596904981848862b068862e9ec3e34be446077190d3f" 257 | dependencies = [ 258 | "gloo-utils 0.1.7", 259 | "js-sys", 260 | "serde", 261 | "wasm-bindgen", 262 | "web-sys", 263 | ] 264 | 265 | [[package]] 266 | name = "gloo-console" 267 | version = "0.3.0" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | checksum = "2a17868f56b4a24f677b17c8cb69958385102fa879418052d60b50bc1727e261" 270 | dependencies = [ 271 | "gloo-utils 0.2.0", 272 | "js-sys", 273 | "serde", 274 | "wasm-bindgen", 275 | "web-sys", 276 | ] 277 | 278 | [[package]] 279 | name = "gloo-dialogs" 280 | version = "0.1.1" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | checksum = "67062364ac72d27f08445a46cab428188e2e224ec9e37efdba48ae8c289002e6" 283 | dependencies = [ 284 | "wasm-bindgen", 285 | "web-sys", 286 | ] 287 | 288 | [[package]] 289 | name = "gloo-dialogs" 290 | version = "0.2.0" 291 | source = "registry+https://github.com/rust-lang/crates.io-index" 292 | checksum = "bf4748e10122b01435750ff530095b1217cf6546173459448b83913ebe7815df" 293 | dependencies = [ 294 | "wasm-bindgen", 295 | "web-sys", 296 | ] 297 | 298 | [[package]] 299 | name = "gloo-events" 300 | version = "0.1.2" 301 | source = "registry+https://github.com/rust-lang/crates.io-index" 302 | checksum = "68b107f8abed8105e4182de63845afcc7b69c098b7852a813ea7462a320992fc" 303 | dependencies = [ 304 | "wasm-bindgen", 305 | "web-sys", 306 | ] 307 | 308 | [[package]] 309 | name = "gloo-events" 310 | version = "0.2.0" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "27c26fb45f7c385ba980f5fa87ac677e363949e065a083722697ef1b2cc91e41" 313 | dependencies = [ 314 | "wasm-bindgen", 315 | "web-sys", 316 | ] 317 | 318 | [[package]] 319 | name = "gloo-file" 320 | version = "0.2.3" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "a8d5564e570a38b43d78bdc063374a0c3098c4f0d64005b12f9bbe87e869b6d7" 323 | dependencies = [ 324 | "gloo-events 0.1.2", 325 | "js-sys", 326 | "wasm-bindgen", 327 | "web-sys", 328 | ] 329 | 330 | [[package]] 331 | name = "gloo-file" 332 | version = "0.3.0" 333 | source = "registry+https://github.com/rust-lang/crates.io-index" 334 | checksum = "97563d71863fb2824b2e974e754a81d19c4a7ec47b09ced8a0e6656b6d54bd1f" 335 | dependencies = [ 336 | "gloo-events 0.2.0", 337 | "js-sys", 338 | "wasm-bindgen", 339 | "web-sys", 340 | ] 341 | 342 | [[package]] 343 | name = "gloo-history" 344 | version = "0.1.5" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "85725d90bf0ed47063b3930ef28e863658a7905989e9929a8708aab74a1d5e7f" 347 | dependencies = [ 348 | "gloo-events 0.1.2", 349 | "gloo-utils 0.1.7", 350 | "serde", 351 | "serde-wasm-bindgen 0.5.0", 352 | "serde_urlencoded", 353 | "thiserror", 354 | "wasm-bindgen", 355 | "web-sys", 356 | ] 357 | 358 | [[package]] 359 | name = "gloo-history" 360 | version = "0.2.2" 361 | source = "registry+https://github.com/rust-lang/crates.io-index" 362 | checksum = "903f432be5ba34427eac5e16048ef65604a82061fe93789f2212afc73d8617d6" 363 | dependencies = [ 364 | "getrandom", 365 | "gloo-events 0.2.0", 366 | "gloo-utils 0.2.0", 367 | "serde", 368 | "serde-wasm-bindgen 0.6.5", 369 | "serde_urlencoded", 370 | "thiserror", 371 | "wasm-bindgen", 372 | "web-sys", 373 | ] 374 | 375 | [[package]] 376 | name = "gloo-net" 377 | version = "0.3.1" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "a66b4e3c7d9ed8d315fd6b97c8b1f74a7c6ecbbc2320e65ae7ed38b7068cc620" 380 | dependencies = [ 381 | "futures-channel", 382 | "futures-core", 383 | "futures-sink", 384 | "gloo-utils 0.1.7", 385 | "http", 386 | "js-sys", 387 | "pin-project", 388 | "serde", 389 | "serde_json", 390 | "thiserror", 391 | "wasm-bindgen", 392 | "wasm-bindgen-futures", 393 | "web-sys", 394 | ] 395 | 396 | [[package]] 397 | name = "gloo-net" 398 | version = "0.4.0" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" 401 | dependencies = [ 402 | "futures-channel", 403 | "futures-core", 404 | "futures-sink", 405 | "gloo-utils 0.2.0", 406 | "http", 407 | "js-sys", 408 | "pin-project", 409 | "serde", 410 | "serde_json", 411 | "thiserror", 412 | "wasm-bindgen", 413 | "wasm-bindgen-futures", 414 | "web-sys", 415 | ] 416 | 417 | [[package]] 418 | name = "gloo-render" 419 | version = "0.1.1" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "2fd9306aef67cfd4449823aadcd14e3958e0800aa2183955a309112a84ec7764" 422 | dependencies = [ 423 | "wasm-bindgen", 424 | "web-sys", 425 | ] 426 | 427 | [[package]] 428 | name = "gloo-render" 429 | version = "0.2.0" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "56008b6744713a8e8d98ac3dcb7d06543d5662358c9c805b4ce2167ad4649833" 432 | dependencies = [ 433 | "wasm-bindgen", 434 | "web-sys", 435 | ] 436 | 437 | [[package]] 438 | name = "gloo-storage" 439 | version = "0.2.2" 440 | source = "registry+https://github.com/rust-lang/crates.io-index" 441 | checksum = "5d6ab60bf5dbfd6f0ed1f7843da31b41010515c745735c970e821945ca91e480" 442 | dependencies = [ 443 | "gloo-utils 0.1.7", 444 | "js-sys", 445 | "serde", 446 | "serde_json", 447 | "thiserror", 448 | "wasm-bindgen", 449 | "web-sys", 450 | ] 451 | 452 | [[package]] 453 | name = "gloo-storage" 454 | version = "0.3.0" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "fbc8031e8c92758af912f9bc08fbbadd3c6f3cfcbf6b64cdf3d6a81f0139277a" 457 | dependencies = [ 458 | "gloo-utils 0.2.0", 459 | "js-sys", 460 | "serde", 461 | "serde_json", 462 | "thiserror", 463 | "wasm-bindgen", 464 | "web-sys", 465 | ] 466 | 467 | [[package]] 468 | name = "gloo-timers" 469 | version = "0.2.6" 470 | source = "registry+https://github.com/rust-lang/crates.io-index" 471 | checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" 472 | dependencies = [ 473 | "js-sys", 474 | "wasm-bindgen", 475 | ] 476 | 477 | [[package]] 478 | name = "gloo-timers" 479 | version = "0.3.0" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" 482 | dependencies = [ 483 | "js-sys", 484 | "wasm-bindgen", 485 | ] 486 | 487 | [[package]] 488 | name = "gloo-utils" 489 | version = "0.1.7" 490 | source = "registry+https://github.com/rust-lang/crates.io-index" 491 | checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e" 492 | dependencies = [ 493 | "js-sys", 494 | "serde", 495 | "serde_json", 496 | "wasm-bindgen", 497 | "web-sys", 498 | ] 499 | 500 | [[package]] 501 | name = "gloo-utils" 502 | version = "0.2.0" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" 505 | dependencies = [ 506 | "js-sys", 507 | "serde", 508 | "serde_json", 509 | "wasm-bindgen", 510 | "web-sys", 511 | ] 512 | 513 | [[package]] 514 | name = "gloo-worker" 515 | version = "0.2.1" 516 | source = "registry+https://github.com/rust-lang/crates.io-index" 517 | checksum = "13471584da78061a28306d1359dd0178d8d6fc1c7c80e5e35d27260346e0516a" 518 | dependencies = [ 519 | "anymap2", 520 | "bincode", 521 | "gloo-console 0.2.3", 522 | "gloo-utils 0.1.7", 523 | "js-sys", 524 | "serde", 525 | "wasm-bindgen", 526 | "wasm-bindgen-futures", 527 | "web-sys", 528 | ] 529 | 530 | [[package]] 531 | name = "gloo-worker" 532 | version = "0.4.0" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "76495d3dd87de51da268fa3a593da118ab43eb7f8809e17eb38d3319b424e400" 535 | dependencies = [ 536 | "bincode", 537 | "futures", 538 | "gloo-utils 0.2.0", 539 | "gloo-worker-macros", 540 | "js-sys", 541 | "pinned", 542 | "serde", 543 | "thiserror", 544 | "wasm-bindgen", 545 | "wasm-bindgen-futures", 546 | "web-sys", 547 | ] 548 | 549 | [[package]] 550 | name = "gloo-worker-macros" 551 | version = "0.1.0" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "956caa58d4857bc9941749d55e4bd3000032d8212762586fa5705632967140e7" 554 | dependencies = [ 555 | "proc-macro-crate", 556 | "proc-macro2", 557 | "quote", 558 | "syn 2.0.96", 559 | ] 560 | 561 | [[package]] 562 | name = "hashbrown" 563 | version = "0.15.2" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 566 | 567 | [[package]] 568 | name = "hermit-abi" 569 | version = "0.3.9" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" 572 | 573 | [[package]] 574 | name = "http" 575 | version = "0.2.12" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" 578 | dependencies = [ 579 | "bytes", 580 | "fnv", 581 | "itoa", 582 | ] 583 | 584 | [[package]] 585 | name = "implicit-clone" 586 | version = "0.4.9" 587 | source = "registry+https://github.com/rust-lang/crates.io-index" 588 | checksum = "f8a9aa791c7b5a71b636b7a68207fdebf171ddfc593d9c8506ec4cbc527b6a84" 589 | dependencies = [ 590 | "implicit-clone-derive", 591 | "indexmap", 592 | ] 593 | 594 | [[package]] 595 | name = "implicit-clone-derive" 596 | version = "0.1.1" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "9311685eb9a34808bbb0608ad2fcab9ae216266beca5848613e95553ac914e3b" 599 | dependencies = [ 600 | "quote", 601 | "syn 2.0.96", 602 | ] 603 | 604 | [[package]] 605 | name = "indexmap" 606 | version = "2.7.1" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" 609 | dependencies = [ 610 | "equivalent", 611 | "hashbrown", 612 | ] 613 | 614 | [[package]] 615 | name = "itoa" 616 | version = "1.0.14" 617 | source = "registry+https://github.com/rust-lang/crates.io-index" 618 | checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" 619 | 620 | [[package]] 621 | name = "js-sys" 622 | version = "0.3.77" 623 | source = "registry+https://github.com/rust-lang/crates.io-index" 624 | checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" 625 | dependencies = [ 626 | "once_cell", 627 | "wasm-bindgen", 628 | ] 629 | 630 | [[package]] 631 | name = "libc" 632 | version = "0.2.169" 633 | source = "registry+https://github.com/rust-lang/crates.io-index" 634 | checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" 635 | 636 | [[package]] 637 | name = "log" 638 | version = "0.4.25" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" 641 | 642 | [[package]] 643 | name = "memchr" 644 | version = "2.7.4" 645 | source = "registry+https://github.com/rust-lang/crates.io-index" 646 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 647 | 648 | [[package]] 649 | name = "miniz_oxide" 650 | version = "0.8.3" 651 | source = "registry+https://github.com/rust-lang/crates.io-index" 652 | checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" 653 | dependencies = [ 654 | "adler2", 655 | ] 656 | 657 | [[package]] 658 | name = "num_cpus" 659 | version = "1.16.0" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" 662 | dependencies = [ 663 | "hermit-abi", 664 | "libc", 665 | ] 666 | 667 | [[package]] 668 | name = "object" 669 | version = "0.36.7" 670 | source = "registry+https://github.com/rust-lang/crates.io-index" 671 | checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" 672 | dependencies = [ 673 | "memchr", 674 | ] 675 | 676 | [[package]] 677 | name = "once_cell" 678 | version = "1.20.2" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" 681 | 682 | [[package]] 683 | name = "percent-encoding" 684 | version = "2.3.1" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 687 | 688 | [[package]] 689 | name = "pin-project" 690 | version = "1.1.8" 691 | source = "registry+https://github.com/rust-lang/crates.io-index" 692 | checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" 693 | dependencies = [ 694 | "pin-project-internal", 695 | ] 696 | 697 | [[package]] 698 | name = "pin-project-internal" 699 | version = "1.1.8" 700 | source = "registry+https://github.com/rust-lang/crates.io-index" 701 | checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" 702 | dependencies = [ 703 | "proc-macro2", 704 | "quote", 705 | "syn 2.0.96", 706 | ] 707 | 708 | [[package]] 709 | name = "pin-project-lite" 710 | version = "0.2.16" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" 713 | 714 | [[package]] 715 | name = "pin-utils" 716 | version = "0.1.0" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 719 | 720 | [[package]] 721 | name = "pinned" 722 | version = "0.1.0" 723 | source = "registry+https://github.com/rust-lang/crates.io-index" 724 | checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b" 725 | dependencies = [ 726 | "futures", 727 | "rustversion", 728 | "thiserror", 729 | ] 730 | 731 | [[package]] 732 | name = "prettyplease" 733 | version = "0.2.29" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" 736 | dependencies = [ 737 | "proc-macro2", 738 | "syn 2.0.96", 739 | ] 740 | 741 | [[package]] 742 | name = "proc-macro-crate" 743 | version = "1.3.1" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" 746 | dependencies = [ 747 | "once_cell", 748 | "toml_edit", 749 | ] 750 | 751 | [[package]] 752 | name = "proc-macro-error" 753 | version = "1.0.4" 754 | source = "registry+https://github.com/rust-lang/crates.io-index" 755 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 756 | dependencies = [ 757 | "proc-macro-error-attr", 758 | "proc-macro2", 759 | "quote", 760 | "syn 1.0.109", 761 | "version_check", 762 | ] 763 | 764 | [[package]] 765 | name = "proc-macro-error-attr" 766 | version = "1.0.4" 767 | source = "registry+https://github.com/rust-lang/crates.io-index" 768 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 769 | dependencies = [ 770 | "proc-macro2", 771 | "quote", 772 | "version_check", 773 | ] 774 | 775 | [[package]] 776 | name = "proc-macro2" 777 | version = "1.0.93" 778 | source = "registry+https://github.com/rust-lang/crates.io-index" 779 | checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" 780 | dependencies = [ 781 | "unicode-ident", 782 | ] 783 | 784 | [[package]] 785 | name = "prokio" 786 | version = "0.1.0" 787 | source = "registry+https://github.com/rust-lang/crates.io-index" 788 | checksum = "03b55e106e5791fa5a13abd13c85d6127312e8e09098059ca2bc9b03ca4cf488" 789 | dependencies = [ 790 | "futures", 791 | "gloo 0.8.1", 792 | "num_cpus", 793 | "once_cell", 794 | "pin-project", 795 | "pinned", 796 | "tokio", 797 | "tokio-stream", 798 | "wasm-bindgen-futures", 799 | ] 800 | 801 | [[package]] 802 | name = "quote" 803 | version = "1.0.38" 804 | source = "registry+https://github.com/rust-lang/crates.io-index" 805 | checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" 806 | dependencies = [ 807 | "proc-macro2", 808 | ] 809 | 810 | [[package]] 811 | name = "rustc-demangle" 812 | version = "0.1.24" 813 | source = "registry+https://github.com/rust-lang/crates.io-index" 814 | checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" 815 | 816 | [[package]] 817 | name = "rustversion" 818 | version = "1.0.19" 819 | source = "registry+https://github.com/rust-lang/crates.io-index" 820 | checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" 821 | 822 | [[package]] 823 | name = "ryu" 824 | version = "1.0.18" 825 | source = "registry+https://github.com/rust-lang/crates.io-index" 826 | checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" 827 | 828 | [[package]] 829 | name = "serde" 830 | version = "1.0.217" 831 | source = "registry+https://github.com/rust-lang/crates.io-index" 832 | checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" 833 | dependencies = [ 834 | "serde_derive", 835 | ] 836 | 837 | [[package]] 838 | name = "serde-wasm-bindgen" 839 | version = "0.5.0" 840 | source = "registry+https://github.com/rust-lang/crates.io-index" 841 | checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" 842 | dependencies = [ 843 | "js-sys", 844 | "serde", 845 | "wasm-bindgen", 846 | ] 847 | 848 | [[package]] 849 | name = "serde-wasm-bindgen" 850 | version = "0.6.5" 851 | source = "registry+https://github.com/rust-lang/crates.io-index" 852 | checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" 853 | dependencies = [ 854 | "js-sys", 855 | "serde", 856 | "wasm-bindgen", 857 | ] 858 | 859 | [[package]] 860 | name = "serde_derive" 861 | version = "1.0.217" 862 | source = "registry+https://github.com/rust-lang/crates.io-index" 863 | checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" 864 | dependencies = [ 865 | "proc-macro2", 866 | "quote", 867 | "syn 2.0.96", 868 | ] 869 | 870 | [[package]] 871 | name = "serde_json" 872 | version = "1.0.137" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" 875 | dependencies = [ 876 | "itoa", 877 | "memchr", 878 | "ryu", 879 | "serde", 880 | ] 881 | 882 | [[package]] 883 | name = "serde_urlencoded" 884 | version = "0.7.1" 885 | source = "registry+https://github.com/rust-lang/crates.io-index" 886 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 887 | dependencies = [ 888 | "form_urlencoded", 889 | "itoa", 890 | "ryu", 891 | "serde", 892 | ] 893 | 894 | [[package]] 895 | name = "slab" 896 | version = "0.4.9" 897 | source = "registry+https://github.com/rust-lang/crates.io-index" 898 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" 899 | dependencies = [ 900 | "autocfg", 901 | ] 902 | 903 | [[package]] 904 | name = "syn" 905 | version = "1.0.109" 906 | source = "registry+https://github.com/rust-lang/crates.io-index" 907 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 908 | dependencies = [ 909 | "proc-macro2", 910 | "unicode-ident", 911 | ] 912 | 913 | [[package]] 914 | name = "syn" 915 | version = "2.0.96" 916 | source = "registry+https://github.com/rust-lang/crates.io-index" 917 | checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" 918 | dependencies = [ 919 | "proc-macro2", 920 | "quote", 921 | "unicode-ident", 922 | ] 923 | 924 | [[package]] 925 | name = "thiserror" 926 | version = "1.0.69" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" 929 | dependencies = [ 930 | "thiserror-impl", 931 | ] 932 | 933 | [[package]] 934 | name = "thiserror-impl" 935 | version = "1.0.69" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" 938 | dependencies = [ 939 | "proc-macro2", 940 | "quote", 941 | "syn 2.0.96", 942 | ] 943 | 944 | [[package]] 945 | name = "tokio" 946 | version = "1.43.0" 947 | source = "registry+https://github.com/rust-lang/crates.io-index" 948 | checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" 949 | dependencies = [ 950 | "backtrace", 951 | "pin-project-lite", 952 | ] 953 | 954 | [[package]] 955 | name = "tokio-stream" 956 | version = "0.1.17" 957 | source = "registry+https://github.com/rust-lang/crates.io-index" 958 | checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" 959 | dependencies = [ 960 | "futures-core", 961 | "pin-project-lite", 962 | "tokio", 963 | ] 964 | 965 | [[package]] 966 | name = "toml_datetime" 967 | version = "0.6.8" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 970 | 971 | [[package]] 972 | name = "toml_edit" 973 | version = "0.19.15" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" 976 | dependencies = [ 977 | "indexmap", 978 | "toml_datetime", 979 | "winnow", 980 | ] 981 | 982 | [[package]] 983 | name = "tracing" 984 | version = "0.1.41" 985 | source = "registry+https://github.com/rust-lang/crates.io-index" 986 | checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" 987 | dependencies = [ 988 | "pin-project-lite", 989 | "tracing-attributes", 990 | "tracing-core", 991 | ] 992 | 993 | [[package]] 994 | name = "tracing-attributes" 995 | version = "0.1.28" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" 998 | dependencies = [ 999 | "proc-macro2", 1000 | "quote", 1001 | "syn 2.0.96", 1002 | ] 1003 | 1004 | [[package]] 1005 | name = "tracing-core" 1006 | version = "0.1.33" 1007 | source = "registry+https://github.com/rust-lang/crates.io-index" 1008 | checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" 1009 | dependencies = [ 1010 | "once_cell", 1011 | ] 1012 | 1013 | [[package]] 1014 | name = "unicode-ident" 1015 | version = "1.0.14" 1016 | source = "registry+https://github.com/rust-lang/crates.io-index" 1017 | checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" 1018 | 1019 | [[package]] 1020 | name = "version_check" 1021 | version = "0.9.5" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 1024 | 1025 | [[package]] 1026 | name = "wasi" 1027 | version = "0.11.0+wasi-snapshot-preview1" 1028 | source = "registry+https://github.com/rust-lang/crates.io-index" 1029 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1030 | 1031 | [[package]] 1032 | name = "wasm-bindgen" 1033 | version = "0.2.100" 1034 | source = "registry+https://github.com/rust-lang/crates.io-index" 1035 | checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" 1036 | dependencies = [ 1037 | "cfg-if", 1038 | "once_cell", 1039 | "rustversion", 1040 | "wasm-bindgen-macro", 1041 | ] 1042 | 1043 | [[package]] 1044 | name = "wasm-bindgen-backend" 1045 | version = "0.2.100" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" 1048 | dependencies = [ 1049 | "bumpalo", 1050 | "log", 1051 | "proc-macro2", 1052 | "quote", 1053 | "syn 2.0.96", 1054 | "wasm-bindgen-shared", 1055 | ] 1056 | 1057 | [[package]] 1058 | name = "wasm-bindgen-futures" 1059 | version = "0.4.50" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" 1062 | dependencies = [ 1063 | "cfg-if", 1064 | "js-sys", 1065 | "once_cell", 1066 | "wasm-bindgen", 1067 | "web-sys", 1068 | ] 1069 | 1070 | [[package]] 1071 | name = "wasm-bindgen-macro" 1072 | version = "0.2.100" 1073 | source = "registry+https://github.com/rust-lang/crates.io-index" 1074 | checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" 1075 | dependencies = [ 1076 | "quote", 1077 | "wasm-bindgen-macro-support", 1078 | ] 1079 | 1080 | [[package]] 1081 | name = "wasm-bindgen-macro-support" 1082 | version = "0.2.100" 1083 | source = "registry+https://github.com/rust-lang/crates.io-index" 1084 | checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" 1085 | dependencies = [ 1086 | "proc-macro2", 1087 | "quote", 1088 | "syn 2.0.96", 1089 | "wasm-bindgen-backend", 1090 | "wasm-bindgen-shared", 1091 | ] 1092 | 1093 | [[package]] 1094 | name = "wasm-bindgen-shared" 1095 | version = "0.2.100" 1096 | source = "registry+https://github.com/rust-lang/crates.io-index" 1097 | checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" 1098 | dependencies = [ 1099 | "unicode-ident", 1100 | ] 1101 | 1102 | [[package]] 1103 | name = "web-sys" 1104 | version = "0.3.77" 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" 1106 | checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" 1107 | dependencies = [ 1108 | "js-sys", 1109 | "wasm-bindgen", 1110 | ] 1111 | 1112 | [[package]] 1113 | name = "windows-targets" 1114 | version = "0.52.6" 1115 | source = "registry+https://github.com/rust-lang/crates.io-index" 1116 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1117 | dependencies = [ 1118 | "windows_aarch64_gnullvm", 1119 | "windows_aarch64_msvc", 1120 | "windows_i686_gnu", 1121 | "windows_i686_gnullvm", 1122 | "windows_i686_msvc", 1123 | "windows_x86_64_gnu", 1124 | "windows_x86_64_gnullvm", 1125 | "windows_x86_64_msvc", 1126 | ] 1127 | 1128 | [[package]] 1129 | name = "windows_aarch64_gnullvm" 1130 | version = "0.52.6" 1131 | source = "registry+https://github.com/rust-lang/crates.io-index" 1132 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1133 | 1134 | [[package]] 1135 | name = "windows_aarch64_msvc" 1136 | version = "0.52.6" 1137 | source = "registry+https://github.com/rust-lang/crates.io-index" 1138 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1139 | 1140 | [[package]] 1141 | name = "windows_i686_gnu" 1142 | version = "0.52.6" 1143 | source = "registry+https://github.com/rust-lang/crates.io-index" 1144 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1145 | 1146 | [[package]] 1147 | name = "windows_i686_gnullvm" 1148 | version = "0.52.6" 1149 | source = "registry+https://github.com/rust-lang/crates.io-index" 1150 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1151 | 1152 | [[package]] 1153 | name = "windows_i686_msvc" 1154 | version = "0.52.6" 1155 | source = "registry+https://github.com/rust-lang/crates.io-index" 1156 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1157 | 1158 | [[package]] 1159 | name = "windows_x86_64_gnu" 1160 | version = "0.52.6" 1161 | source = "registry+https://github.com/rust-lang/crates.io-index" 1162 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1163 | 1164 | [[package]] 1165 | name = "windows_x86_64_gnullvm" 1166 | version = "0.52.6" 1167 | source = "registry+https://github.com/rust-lang/crates.io-index" 1168 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1169 | 1170 | [[package]] 1171 | name = "windows_x86_64_msvc" 1172 | version = "0.52.6" 1173 | source = "registry+https://github.com/rust-lang/crates.io-index" 1174 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1175 | 1176 | [[package]] 1177 | name = "winnow" 1178 | version = "0.5.40" 1179 | source = "registry+https://github.com/rust-lang/crates.io-index" 1180 | checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" 1181 | dependencies = [ 1182 | "memchr", 1183 | ] 1184 | 1185 | [[package]] 1186 | name = "yew" 1187 | version = "0.21.0" 1188 | source = "registry+https://github.com/rust-lang/crates.io-index" 1189 | checksum = "5f1a03f255c70c7aa3e9c62e15292f142ede0564123543c1cc0c7a4f31660cac" 1190 | dependencies = [ 1191 | "console_error_panic_hook", 1192 | "futures", 1193 | "gloo 0.10.0", 1194 | "implicit-clone", 1195 | "indexmap", 1196 | "js-sys", 1197 | "prokio", 1198 | "rustversion", 1199 | "serde", 1200 | "slab", 1201 | "thiserror", 1202 | "tokio", 1203 | "tracing", 1204 | "wasm-bindgen", 1205 | "wasm-bindgen-futures", 1206 | "web-sys", 1207 | "yew-macro", 1208 | ] 1209 | 1210 | [[package]] 1211 | name = "yew-macro" 1212 | version = "0.21.0" 1213 | source = "registry+https://github.com/rust-lang/crates.io-index" 1214 | checksum = "02fd8ca5166d69e59f796500a2ce432ff751edecbbb308ca59fd3fe4d0343de2" 1215 | dependencies = [ 1216 | "boolinator", 1217 | "once_cell", 1218 | "prettyplease", 1219 | "proc-macro-error", 1220 | "proc-macro2", 1221 | "quote", 1222 | "syn 2.0.96", 1223 | ] 1224 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cross-compile" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | yew = { version="0.21", features=["csr"] } 8 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = { 3 | pkgs, 4 | config, 5 | lib, 6 | ... 7 | }: let 8 | crateName = "cross-compile"; 9 | in { 10 | # declare projects 11 | nci.projects.${crateName}.path = ./.; 12 | # configure crates 13 | nci.crates.${crateName} = { 14 | targets."wasm32-unknown-unknown" = { 15 | default = true; 16 | drvConfig.env = { 17 | TRUNK_TOOLS_SASS = pkgs.nodePackages.sass.version; 18 | TRUNK_TOOLS_WASM_BINDGEN = pkgs.wasm-bindgen-cli.version; 19 | TRUNK_TOOLS_WASM_OPT = "version_${lib.removeSuffix "_b" pkgs.binaryen.version}"; 20 | TRUNK_SKIP_VERSION_CHECK = "true"; 21 | }; 22 | drvConfig.mkDerivation = { 23 | # add trunk and other dependencies 24 | nativeBuildInputs = with pkgs; [trunk nodePackages.sass wasm-bindgen-cli binaryen]; 25 | # override build phase to build with trunk instead 26 | buildPhase = '' 27 | echo sass is version $TRUNK_TOOLS_SASS 28 | echo wasm bindgen is version $TRUNK_TOOLS_WASM_BINDGEN 29 | HOME=$TMPDIR \ 30 | trunk -v build \ 31 | --dist $out \ 32 | --release \ 33 | ''${cargoBuildFlags:-} 34 | ''; 35 | # disable install phase because trunk will directly output to $out 36 | dontInstall = true; 37 | }; 38 | }; 39 | # we can't run WASM tests on native, so disable tests 40 | profiles.release.runTests = false; 41 | }; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [ 16 | nci.flakeModule 17 | ./crates.nix 18 | ]; 19 | perSystem = { 20 | pkgs, 21 | config, 22 | ... 23 | }: let 24 | # shorthand for accessing this crate's outputs 25 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 26 | crateOutputs = config.nci.outputs."cross-compile"; 27 | in { 28 | # export the crate devshell as the default devshell 29 | devShells.default = crateOutputs.devShell; 30 | # export the release package of the crate as default package 31 | packages.default = crateOutputs.packages.release; 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Trunk Template 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/index.scss: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | margin: 0; 5 | } 6 | 7 | body { 8 | align-items: center; 9 | display: flex; 10 | justify-content: center; 11 | 12 | background: linear-gradient(to bottom right, #444444, #009a5b); 13 | font-size: 1.5rem; 14 | } 15 | 16 | main { 17 | color: #fff6d5; 18 | font-family: sans-serif; 19 | text-align: center; 20 | } 21 | 22 | .logo { 23 | height: 20em; 24 | } 25 | 26 | .heart:after { 27 | content: "❤️"; 28 | 29 | font-size: 1.75em; 30 | } 31 | 32 | h1 + .subtitle { 33 | display: block; 34 | margin-top: -1em; 35 | } -------------------------------------------------------------------------------- /examples/cross-compile-wasm/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "stable" 3 | targets = ["wasm32-unknown-unknown"] 4 | -------------------------------------------------------------------------------- /examples/cross-compile-wasm/src/app.rs: -------------------------------------------------------------------------------- 1 | use yew::prelude::*; 2 | 3 | #[function_component(App)] 4 | pub fn app() -> Html { 5 | html! { 6 |
7 | 8 |

{ "Hello World!" }

9 | { "from Yew with " } 10 |
11 | } 12 | } -------------------------------------------------------------------------------- /examples/cross-compile-wasm/src/main.rs: -------------------------------------------------------------------------------- 1 | mod app; 2 | 3 | use app::App; 4 | 5 | fn main() { 6 | yew::Renderer::::new().render(); 7 | } -------------------------------------------------------------------------------- /examples/cross-compile-windows/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "cc" 7 | version = "1.2.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" 10 | dependencies = [ 11 | "shlex", 12 | ] 13 | 14 | [[package]] 15 | name = "cross-compile-windows" 16 | version = "0.1.0" 17 | dependencies = [ 18 | "openssl-sys", 19 | ] 20 | 21 | [[package]] 22 | name = "libc" 23 | version = "0.2.162" 24 | source = "registry+https://github.com/rust-lang/crates.io-index" 25 | checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" 26 | 27 | [[package]] 28 | name = "openssl-sys" 29 | version = "0.9.104" 30 | source = "registry+https://github.com/rust-lang/crates.io-index" 31 | checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" 32 | dependencies = [ 33 | "cc", 34 | "libc", 35 | "pkg-config", 36 | "vcpkg", 37 | ] 38 | 39 | [[package]] 40 | name = "pkg-config" 41 | version = "0.3.31" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" 44 | 45 | [[package]] 46 | name = "shlex" 47 | version = "1.3.0" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 50 | 51 | [[package]] 52 | name = "vcpkg" 53 | version = "0.2.15" 54 | source = "registry+https://github.com/rust-lang/crates.io-index" 55 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 56 | -------------------------------------------------------------------------------- /examples/cross-compile-windows/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cross-compile-windows" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | openssl-sys = "*" 8 | -------------------------------------------------------------------------------- /examples/cross-compile-windows/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = { 3 | pkgs, 4 | config, 5 | lib, 6 | inputs', 7 | ... 8 | }: let 9 | crateName = "cross-compile-windows"; 10 | in { 11 | # declare projects 12 | nci.projects.${crateName}.path = ./.; 13 | # TODO: fenix works, rust-overlay doesn't, why? 14 | nci.toolchains.mkBuild = _: 15 | with inputs'.fenix.packages; 16 | combine [ 17 | minimal.rustc 18 | minimal.cargo 19 | targets.x86_64-pc-windows-gnu.latest.rust-std 20 | ]; 21 | # configure crates 22 | nci.crates.${crateName} = { 23 | targets."x86_64-pc-windows-gnu" = let 24 | targetPkgs = pkgs.pkgsCross.mingwW64; 25 | targetCC = targetPkgs.stdenv.cc; 26 | targetCargoEnvVarTarget = targetPkgs.hostPlatform.rust.cargoEnvVarTarget; 27 | # we have to wrap wine so that HOME is set to somewhere that exists 28 | wineWrapped = pkgs.writeScript "wine.sh" '' 29 | #!${pkgs.stdenv.shell} 30 | HOME=$TEMPDIR ${pkgs.wineWow64Packages.minimal}/bin/wine $@ 31 | ''; 32 | in rec { 33 | default = true; 34 | depsDrvConfig.mkDerivation = { 35 | nativeBuildInputs = [targetCC pkgs.pkg-config pkgs.wineWow64Packages.minimal]; 36 | buildInputs = with targetPkgs; [openssl windows.pthreads]; 37 | }; 38 | depsDrvConfig.env = rec { 39 | TARGET_CC = "${targetCC.targetPrefix}cc"; 40 | "CARGO_TARGET_${targetCargoEnvVarTarget}_LINKER" = TARGET_CC; 41 | "CARGO_TARGET_${targetCargoEnvVarTarget}_RUNNER" = wineWrapped; 42 | }; 43 | drvConfig = depsDrvConfig; 44 | }; 45 | }; 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /examples/cross-compile-windows/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "path:../.."; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | inputs.fenix = { 8 | url = "github:nix-community/fenix"; 9 | inputs.nixpkgs.follows = "nixpkgs"; 10 | }; 11 | 12 | outputs = inputs @ { 13 | parts, 14 | nci, 15 | ... 16 | }: 17 | parts.lib.mkFlake {inherit inputs;} { 18 | systems = ["x86_64-linux"]; 19 | imports = [ 20 | nci.flakeModule 21 | ./crates.nix 22 | ]; 23 | perSystem = { 24 | pkgs, 25 | config, 26 | ... 27 | }: let 28 | # shorthand for accessing this crate's outputs 29 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 30 | crateOutputs = config.nci.outputs."cross-compile-windows"; 31 | in { 32 | # export the crate devshell as the default devshell 33 | devShells.default = crateOutputs.devShell; 34 | # export the release package of the crate as default package 35 | packages.default = crateOutputs.packages.release; 36 | }; 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /examples/cross-compile-windows/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello world!") 3 | } 4 | 5 | #[cfg(test)] 6 | #[test] 7 | fn test_dummy() { 8 | assert!(true); 9 | } 10 | -------------------------------------------------------------------------------- /examples/customize-devshell/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [nci.flakeModule]; 16 | perSystem = { 17 | config, 18 | pkgs, 19 | ... 20 | }: { 21 | # declare projects 22 | nci.projects."example-crate".path = ./.; 23 | # nci devshells are just regular `nixpkgs.mkShell` 24 | # alternatively you can not use NCI's own devshells and use numtide devshell or devenv etc. 25 | devShells.default = config.nci.outputs."example-crate".devShell.overrideAttrs (old: { 26 | packages = (old.packages or []) ++ [pkgs.hello]; 27 | shellHook = '' 28 | ${old.shellHook or ""} 29 | echo "Hello world!" 30 | ''; 31 | }); 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /examples/customize-profiles/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "customize-profiles" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /examples/customize-profiles/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "customize-profiles" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [features] 7 | default = [] 8 | -------------------------------------------------------------------------------- /examples/customize-profiles/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = { 3 | pkgs, 4 | config, 5 | ... 6 | }: { 7 | # declare projects 8 | nci.projects."profiles".path = ./.; 9 | # configure crates 10 | nci.crates."customize-profiles" = { 11 | profiles.release = { 12 | # configure features 13 | features = ["default"]; 14 | # set whether to run tests or not 15 | runTests = true; 16 | # configure the main derivation for this profile's package 17 | drvConfig = { 18 | mkDerivation.preBuild = "echo starting build"; 19 | env.CARGO_TERM_VERBOSE = "true"; 20 | }; 21 | # configure the dependencies derivation for this profile's package 22 | depsDrvConfig = {}; 23 | }; 24 | }; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /examples/customize-profiles/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [ 16 | nci.flakeModule 17 | ./crates.nix 18 | ]; 19 | perSystem = { 20 | pkgs, 21 | config, 22 | ... 23 | }: let 24 | # shorthand for accessing this crate's outputs 25 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 26 | crateOutputs = config.nci.outputs."customize-profiles"; 27 | in { 28 | # export the crate devshell as the default devshell 29 | devShells.default = crateOutputs.devShell; 30 | # export the release package of the crate as default package 31 | packages.default = crateOutputs.packages.release; 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /examples/customize-profiles/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /examples/customize-stdenv/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "my-crate" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /examples/customize-stdenv/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "my-crate" 3 | version = "0.1.0" 4 | edition = "2018" 5 | -------------------------------------------------------------------------------- /examples/customize-stdenv/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [nci.flakeModule]; 16 | perSystem = { 17 | pkgs, 18 | config, 19 | ... 20 | }: let 21 | crateName = "my-crate"; 22 | in { 23 | # declare projects 24 | nci.projects.${crateName}.path = ./.; 25 | # configure crates 26 | nci.crates.${crateName} = { 27 | ### override stdenv for both dependencies and main derivation ### 28 | depsDrvConfig = { 29 | deps.stdenv = pkgs.clangStdenv; 30 | }; 31 | drvConfig = { 32 | deps.stdenv = pkgs.clangStdenv; 33 | }; 34 | # note: for overriding stdenv for *all* packages in a project 35 | # you can use `drvConfig` and `depsDrvConfig` under `nci.projects.` 36 | # instead. 37 | }; 38 | }; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /examples/customize-stdenv/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /examples/numtide-devshell/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "my-crate" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /examples/numtide-devshell/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "my-crate" 3 | version = "0.1.0" 4 | edition = "2018" 5 | -------------------------------------------------------------------------------- /examples/numtide-devshell/crates.nix: -------------------------------------------------------------------------------- 1 | { 2 | perSystem = {pkgs, ...}: { 3 | # declare projects 4 | nci.projects."my-project" = { 5 | path = ./.; 6 | # Configure the numtide devshell to which all packages 7 | # required for this project and its crates should be added 8 | numtideDevshell = "default"; 9 | }; 10 | 11 | # configure crates 12 | nci.crates."my-crate" = { 13 | # If you only want to add requirements for a specific 14 | # crate to your numtide devshell: 15 | #numtideDevshell = "default"; 16 | drvConfig.mkDerivation.buildInputs = [pkgs.hello]; 17 | drvConfig.env.FOO = "BAR"; 18 | }; 19 | 20 | # Conveniently configure additional things in your devshell 21 | devshells.default.env = [ 22 | { 23 | name = "SOME_EXTRA_ENV_VARIABLE"; 24 | value = "true"; 25 | } 26 | ]; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /examples/numtide-devshell/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | inputs.devshell.url = "github:numtide/devshell"; 8 | inputs.devshell.inputs.nixpkgs.follows = "nixpkgs"; 9 | 10 | outputs = inputs: 11 | inputs.parts.lib.mkFlake {inherit inputs;} { 12 | systems = ["x86_64-linux"]; 13 | imports = [ 14 | inputs.nci.flakeModule 15 | inputs.devshell.flakeModule 16 | ./crates.nix 17 | ]; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /examples/numtide-devshell/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /examples/simple-crate/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "my-crate" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /examples/simple-crate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "my-crate" 3 | version = "0.1.0" 4 | edition = "2018" 5 | -------------------------------------------------------------------------------- /examples/simple-crate/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = { 3 | pkgs, 4 | config, 5 | ... 6 | }: let 7 | # TODO: change this to your crate's name 8 | crateName = "my-crate"; 9 | in { 10 | # declare projects 11 | nci.projects."simple".path = ./.; 12 | # configure crates 13 | nci.crates.${crateName} = { 14 | drvConfig = { 15 | env.HELLO_WORLD = true; 16 | mkDerivation.buildInputs = [pkgs.hello]; 17 | }; 18 | }; 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /examples/simple-crate/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [ 16 | nci.flakeModule 17 | ./crates.nix 18 | ]; 19 | perSystem = { 20 | pkgs, 21 | config, 22 | ... 23 | }: let 24 | # shorthand for accessing this crate's outputs 25 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 26 | crateOutputs = config.nci.outputs."my-crate"; 27 | in { 28 | # export the crate devshell as the default devshell 29 | devShells.default = crateOutputs.devShell; 30 | # export the release package of the crate as default package 31 | packages.default = crateOutputs.packages.release; 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /examples/simple-crate/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /examples/simple-workspace/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "my-workspace-crate" 7 | version = "0.1.0" 8 | 9 | [[package]] 10 | name = "my-other-workspace-crate" 11 | version = "0.1.0" 12 | -------------------------------------------------------------------------------- /examples/simple-workspace/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["my-workspace-crate", "./my-other-workspace-crate"] 3 | [workspace.package] 4 | version = "0.1.0" 5 | edition = "2021" 6 | authors = ["Some Author ", "Another Author "] 7 | license = "MIT" 8 | repository = "https://github.com/yusdacra/nix-cargo-integration/tree/master/examples/simple-workspace" 9 | homepage = "https://github.com/yusdacra/nix-cargo-integration/tree/master/examples/simple-workspace" 10 | -------------------------------------------------------------------------------- /examples/simple-workspace/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = {pkgs, ...}: { 3 | # declare projects 4 | # TODO: change this to your workspace's path 5 | nci.projects."my-project" = { 6 | path = ./.; 7 | # export all crates (packages and devshell) in flake outputs 8 | # alternatively you can access the outputs and export them yourself 9 | export = true; 10 | }; 11 | # configure crates 12 | nci.crates = { 13 | "my-workspace-crate" = { 14 | drvConfig = { 15 | env.HELLO_WORLD = true; 16 | }; 17 | # look at documentation for more options 18 | }; 19 | "my-other-workspace-crate" = { 20 | drvConfig = { 21 | mkDerivation.buildInputs = [pkgs.hello]; 22 | }; 23 | # look at documentation for more options 24 | }; 25 | }; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /examples/simple-workspace/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [nci.flakeModule ./crates.nix]; 16 | perSystem = {config, ...}: let 17 | # shorthand for accessing outputs 18 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 19 | outputs = config.nci.outputs; 20 | in { 21 | # export the project devshell as the default devshell 22 | devShells.default = outputs."my-project".devShell; 23 | # export the release package of one crate as default package 24 | packages.default = outputs."my-workspace-crate".packages.release; 25 | }; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /examples/simple-workspace/my-other-workspace-crate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "my-other-workspace-crate" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | homepage.workspace = true 9 | -------------------------------------------------------------------------------- /examples/simple-workspace/my-other-workspace-crate/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub fn add(left: usize, right: usize) -> usize { 2 | left + right 3 | } 4 | 5 | #[cfg(test)] 6 | mod tests { 7 | use super::*; 8 | 9 | #[test] 10 | fn it_works() { 11 | let result = add(2, 2); 12 | assert_eq!(result, 4); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/simple-workspace/my-workspace-crate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "my-workspace-crate" 3 | version.workspace = true 4 | authors.workspace = true 5 | edition.workspace = true 6 | license.workspace = true 7 | repository.workspace = true 8 | homepage.workspace = true 9 | -------------------------------------------------------------------------------- /examples/simple-workspace/my-workspace-crate/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /examples/simple/crates.nix: -------------------------------------------------------------------------------- 1 | {...}: { 2 | perSystem = { 3 | pkgs, 4 | config, 5 | ... 6 | }: let 7 | # TODO: change this to your crate's name 8 | crateName = "my-crate"; 9 | in { 10 | # declare projects 11 | # TODO: change this to your crate's path 12 | nci.projects.${crateName}.path = ./.; 13 | # configure crates 14 | nci.crates.${crateName} = {}; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /examples/simple/flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; 3 | inputs.nci.url = "github:yusdacra/nix-cargo-integration"; 4 | inputs.nci.inputs.nixpkgs.follows = "nixpkgs"; 5 | inputs.parts.url = "github:hercules-ci/flake-parts"; 6 | inputs.parts.inputs.nixpkgs-lib.follows = "nixpkgs"; 7 | 8 | outputs = inputs @ { 9 | parts, 10 | nci, 11 | ... 12 | }: 13 | parts.lib.mkFlake {inherit inputs;} { 14 | systems = ["x86_64-linux"]; 15 | imports = [ 16 | nci.flakeModule 17 | ./crates.nix 18 | ]; 19 | perSystem = { 20 | pkgs, 21 | config, 22 | ... 23 | }: let 24 | # shorthand for accessing this crate's outputs 25 | # you can access crate outputs under `config.nci.outputs.` (see documentation) 26 | crateOutputs = config.nci.outputs."my-crate"; 27 | in { 28 | # export the crate devshell as the default devshell 29 | devShells.default = crateOutputs.devShell; 30 | # export the release package of the crate as default package 31 | packages.default = crateOutputs.packages.release; 32 | }; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "crane": { 4 | "flake": false, 5 | "locked": { 6 | "lastModified": 1727316705, 7 | "narHash": "sha256-/mumx8AQ5xFuCJqxCIOFCHTVlxHkMT21idpbgbm/TIE=", 8 | "owner": "ipetkov", 9 | "repo": "crane", 10 | "rev": "5b03654ce046b5167e7b0bccbd8244cb56c16f0e", 11 | "type": "github" 12 | }, 13 | "original": { 14 | "owner": "ipetkov", 15 | "ref": "v0.19.0", 16 | "repo": "crane", 17 | "type": "github" 18 | } 19 | }, 20 | "dream2nix": { 21 | "inputs": { 22 | "nixpkgs": [ 23 | "nixpkgs" 24 | ], 25 | "purescript-overlay": "purescript-overlay", 26 | "pyproject-nix": "pyproject-nix" 27 | }, 28 | "locked": { 29 | "lastModified": 1748838242, 30 | "narHash": "sha256-wORL3vLIJdBF8hz73yuD7DVsrbOvFgtH96hQIetXhfg=", 31 | "owner": "nix-community", 32 | "repo": "dream2nix", 33 | "rev": "e92dacdc57acaa6b2ae79592c1a62c2340931410", 34 | "type": "github" 35 | }, 36 | "original": { 37 | "owner": "nix-community", 38 | "repo": "dream2nix", 39 | "type": "github" 40 | } 41 | }, 42 | "flake-compat": { 43 | "flake": false, 44 | "locked": { 45 | "lastModified": 1696426674, 46 | "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", 47 | "owner": "edolstra", 48 | "repo": "flake-compat", 49 | "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", 50 | "type": "github" 51 | }, 52 | "original": { 53 | "owner": "edolstra", 54 | "repo": "flake-compat", 55 | "type": "github" 56 | } 57 | }, 58 | "mk-naked-shell": { 59 | "flake": false, 60 | "locked": { 61 | "lastModified": 1681286841, 62 | "narHash": "sha256-3XlJrwlR0nBiREnuogoa5i1b4+w/XPe0z8bbrJASw0g=", 63 | "owner": "yusdacra", 64 | "repo": "mk-naked-shell", 65 | "rev": "7612f828dd6f22b7fb332cc69440e839d7ffe6bd", 66 | "type": "github" 67 | }, 68 | "original": { 69 | "owner": "yusdacra", 70 | "repo": "mk-naked-shell", 71 | "type": "github" 72 | } 73 | }, 74 | "nixpkgs": { 75 | "locked": { 76 | "lastModified": 1748929857, 77 | "narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=", 78 | "owner": "NixOS", 79 | "repo": "nixpkgs", 80 | "rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4", 81 | "type": "github" 82 | }, 83 | "original": { 84 | "owner": "NixOS", 85 | "ref": "nixos-unstable", 86 | "repo": "nixpkgs", 87 | "type": "github" 88 | } 89 | }, 90 | "parts": { 91 | "inputs": { 92 | "nixpkgs-lib": [ 93 | "nixpkgs" 94 | ] 95 | }, 96 | "locked": { 97 | "lastModified": 1748821116, 98 | "narHash": "sha256-F82+gS044J1APL0n4hH50GYdPRv/5JWm34oCJYmVKdE=", 99 | "owner": "hercules-ci", 100 | "repo": "flake-parts", 101 | "rev": "49f0870db23e8c1ca0b5259734a02cd9e1e371a1", 102 | "type": "github" 103 | }, 104 | "original": { 105 | "owner": "hercules-ci", 106 | "repo": "flake-parts", 107 | "type": "github" 108 | } 109 | }, 110 | "purescript-overlay": { 111 | "inputs": { 112 | "flake-compat": "flake-compat", 113 | "nixpkgs": [ 114 | "dream2nix", 115 | "nixpkgs" 116 | ], 117 | "slimlock": "slimlock" 118 | }, 119 | "locked": { 120 | "lastModified": 1728546539, 121 | "narHash": "sha256-Sws7w0tlnjD+Bjck1nv29NjC5DbL6nH5auL9Ex9Iz2A=", 122 | "owner": "thomashoneyman", 123 | "repo": "purescript-overlay", 124 | "rev": "4ad4c15d07bd899d7346b331f377606631eb0ee4", 125 | "type": "github" 126 | }, 127 | "original": { 128 | "owner": "thomashoneyman", 129 | "repo": "purescript-overlay", 130 | "type": "github" 131 | } 132 | }, 133 | "pyproject-nix": { 134 | "flake": false, 135 | "locked": { 136 | "lastModified": 1702448246, 137 | "narHash": "sha256-hFg5s/hoJFv7tDpiGvEvXP0UfFvFEDgTdyHIjDVHu1I=", 138 | "owner": "davhau", 139 | "repo": "pyproject.nix", 140 | "rev": "5a06a2697b228c04dd2f35659b4b659ca74f7aeb", 141 | "type": "github" 142 | }, 143 | "original": { 144 | "owner": "davhau", 145 | "ref": "dream2nix", 146 | "repo": "pyproject.nix", 147 | "type": "github" 148 | } 149 | }, 150 | "root": { 151 | "inputs": { 152 | "crane": "crane", 153 | "dream2nix": "dream2nix", 154 | "mk-naked-shell": "mk-naked-shell", 155 | "nixpkgs": "nixpkgs", 156 | "parts": "parts", 157 | "rust-overlay": "rust-overlay", 158 | "treefmt": "treefmt" 159 | } 160 | }, 161 | "rust-overlay": { 162 | "inputs": { 163 | "nixpkgs": [ 164 | "nixpkgs" 165 | ] 166 | }, 167 | "locked": { 168 | "lastModified": 1749004659, 169 | "narHash": "sha256-zaZrcC5UwHPGkgfnhTPx5sZfSSnUJdvYHhgex10RadQ=", 170 | "owner": "oxalica", 171 | "repo": "rust-overlay", 172 | "rev": "c52e346aedfa745564599558a096e88f9a5557f9", 173 | "type": "github" 174 | }, 175 | "original": { 176 | "owner": "oxalica", 177 | "repo": "rust-overlay", 178 | "type": "github" 179 | } 180 | }, 181 | "slimlock": { 182 | "inputs": { 183 | "nixpkgs": [ 184 | "dream2nix", 185 | "purescript-overlay", 186 | "nixpkgs" 187 | ] 188 | }, 189 | "locked": { 190 | "lastModified": 1688756706, 191 | "narHash": "sha256-xzkkMv3neJJJ89zo3o2ojp7nFeaZc2G0fYwNXNJRFlo=", 192 | "owner": "thomashoneyman", 193 | "repo": "slimlock", 194 | "rev": "cf72723f59e2340d24881fd7bf61cb113b4c407c", 195 | "type": "github" 196 | }, 197 | "original": { 198 | "owner": "thomashoneyman", 199 | "repo": "slimlock", 200 | "type": "github" 201 | } 202 | }, 203 | "treefmt": { 204 | "inputs": { 205 | "nixpkgs": [ 206 | "nixpkgs" 207 | ] 208 | }, 209 | "locked": { 210 | "lastModified": 1748243702, 211 | "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", 212 | "owner": "numtide", 213 | "repo": "treefmt-nix", 214 | "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", 215 | "type": "github" 216 | }, 217 | "original": { 218 | "owner": "numtide", 219 | "repo": "treefmt-nix", 220 | "type": "github" 221 | } 222 | } 223 | }, 224 | "root": "root", 225 | "version": 7 226 | } 227 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | inputs = { 3 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 4 | 5 | rust-overlay = { 6 | url = "github:oxalica/rust-overlay"; 7 | inputs.nixpkgs.follows = "nixpkgs"; 8 | }; 9 | 10 | parts = { 11 | url = "github:hercules-ci/flake-parts"; 12 | inputs.nixpkgs-lib.follows = "nixpkgs"; 13 | }; 14 | 15 | mk-naked-shell = { 16 | url = "github:yusdacra/mk-naked-shell"; 17 | flake = false; 18 | }; 19 | 20 | treefmt = { 21 | url = "github:numtide/treefmt-nix"; 22 | inputs.nixpkgs.follows = "nixpkgs"; 23 | }; 24 | 25 | crane = { 26 | url = "github:ipetkov/crane/v0.19.0"; 27 | flake = false; 28 | }; 29 | 30 | dream2nix = { 31 | url = "github:nix-community/dream2nix"; 32 | inputs.nixpkgs.follows = "nixpkgs"; 33 | }; 34 | }; 35 | 36 | outputs = {parts, ...} @ inp: let 37 | l = inp.nixpkgs.lib // builtins; 38 | 39 | flakeModule = { 40 | imports = [./src/default.nix]; 41 | config = { 42 | nci._inputs = { 43 | inherit (inp) crane dream2nix rust-overlay; 44 | }; 45 | }; 46 | }; 47 | in 48 | parts.lib.mkFlake {inputs = inp;} { 49 | imports = [ 50 | inp.treefmt.flakeModule 51 | flakeModule 52 | ./examples/simple-crate/crates.nix 53 | ./examples/customize-profiles/crates.nix 54 | ./examples/simple-workspace/crates.nix 55 | ]; 56 | systems = ["x86_64-linux"]; 57 | 58 | flake = { 59 | inherit flakeModule; 60 | templates = { 61 | default = inp.self.templates.simple; 62 | simple = { 63 | description = "A simple flake.nix template for getting started"; 64 | path = ./examples/simple; 65 | welcomeText = '' 66 | To get started: 67 | 68 | 1. edit the project `path` in `flake.nix` to point to your project. 69 | 2. change `my-crate` crate name to your own crate name. 70 | 3. (optionally) add any other crate (or project) you want to configure. 71 | 72 | You're set! 73 | ''; 74 | }; 75 | simple-crate = { 76 | description = "A simple template with a Cargo crate pre-initialized"; 77 | path = ./examples/simple-crate; 78 | welcomeText = '' 79 | To get started, edit crate name in `flake.nix` and `Cargo.toml` to your liking. 80 | And you should be good to go! 81 | ''; 82 | }; 83 | simple-workspace = { 84 | description = "A simple template with a Cargo workspace pre-initialized"; 85 | path = ./examples/simple-workspace; 86 | welcomeText = '' 87 | To get started: 88 | 89 | 1. edit crate names in `flake.nix` and `Cargo.toml`s to your liking, 90 | 2. edit project name in `flake.nix` 91 | 92 | You're set! 93 | ''; 94 | }; 95 | cross-compile-wasm = { 96 | description = "An example showcasing WASM cross-compilation"; 97 | path = ./examples/cross-compile-wasm; 98 | }; 99 | cross-compile-aarch64 = { 100 | description = "An example showcasing aarch64 cross-compilation"; 101 | path = ./examples/cross-compile-aarch64; 102 | }; 103 | cross-compile-windows = { 104 | description = "An example showcasing windows cross-compilation"; 105 | path = ./examples/cross-compile-windows; 106 | }; 107 | numtide-devshell = { 108 | description = "Example showcasing using a numtide devshell instead of NCI's own"; 109 | path = ./examples/numtide-devshell; 110 | }; 111 | }; 112 | }; 113 | perSystem = {config, ...}: let 114 | profilesOut = config.nci.outputs."customize-profiles"; 115 | simpleOut = config.nci.outputs."my-crate"; 116 | workspaceOut = config.nci.outputs."my-project"; 117 | workspaceCrateOut = config.nci.outputs."my-workspace-crate"; 118 | otherWorkspaceCrateOut = config.nci.outputs."my-other-workspace-crate"; 119 | in { 120 | treefmt = { 121 | projectRootFile = "flake.nix"; 122 | programs.alejandra.enable = true; 123 | }; 124 | 125 | nci.projects."simple".export = false; 126 | nci.projects."profiles".export = false; 127 | nci.projects."my-project".export = l.mkForce false; 128 | 129 | checks."simple-test" = simpleOut.check; 130 | checks."simple-clippy" = simpleOut.clippy; 131 | checks."simple-docs" = simpleOut.docs; 132 | checks."simple-devshell" = simpleOut.devShell; 133 | checks."simple-workspace-test" = workspaceCrateOut.check; 134 | checks."simple-workspace-test-other" = otherWorkspaceCrateOut.check; 135 | checks."simple-workspace-crate-docs" = workspaceCrateOut.docs; 136 | checks."simple-workspace-docs" = workspaceOut.docs; 137 | checks."simple-workspace-devshell" = workspaceOut.devShell; 138 | checks."profiles-test" = profilesOut.packages.release; 139 | }; 140 | }; 141 | } 142 | -------------------------------------------------------------------------------- /src/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | imports = [ 3 | ./interface.nix 4 | ./implementation.nix 5 | ]; 6 | } 7 | -------------------------------------------------------------------------------- /src/functions/combineDocsPackages.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | fetchFromGitHub, 4 | runCommand, 5 | docsPackages, 6 | derivationName, 7 | indexCrateName, 8 | buildCrate, 9 | }: let 10 | docmerge = buildCrate { 11 | src = fetchFromGitHub { 12 | owner = "yusdacra"; 13 | repo = "doc-merge"; 14 | rev = "3c8d7b21e23b36ec4854d599d423e83614447f98"; 15 | hash = "sha256-8uVjGWuw485z2cu3UEDlp6UccbB7jCcRvA0J1cJnQ10="; 16 | }; 17 | }; 18 | getCrateName = docs: lib.replaceStrings ["-"] ["_"] (lib.removeSuffix "-docs" docs.name); 19 | mkCopyCrate = docs: "cp -Lrv --no-preserve=mode,ownership ${docs} crates/${getCrateName docs}"; 20 | mkMergeSrcArg = docs: "--src crates/${getCrateName docs}"; 21 | derivationAttrs = { 22 | passthru.docsPackages = docsPackages; 23 | }; 24 | in 25 | runCommand derivationName derivationAttrs '' 26 | mkdir -p $out 27 | mkdir crates 28 | ${lib.concatMapStringsSep "\n" mkCopyCrate docsPackages} 29 | ${docmerge}/bin/doc-merge \ 30 | ${ 31 | if indexCrateName != null 32 | then "--index-crate ${indexCrateName}" 33 | else "" 34 | } \ 35 | ${lib.concatMapStringsSep " " mkMergeSrcArg docsPackages} \ 36 | --dest $out 37 | '' 38 | -------------------------------------------------------------------------------- /src/functions/filterDevshellIllegalVars.nix: -------------------------------------------------------------------------------- 1 | {lib}: let 2 | l = lib // builtins; 3 | # illegal env names to be removed and not be added to the devshell 4 | illegalEnvNames = [ 5 | # cargo artifact and vendoring derivations 6 | # we don't need these in the devshell 7 | "cargoArtifacts" 8 | "dream2nixVendorDir" 9 | "cargoVendorDir" 10 | ]; 11 | isIllegalEnv = name: l.elem name illegalEnvNames; 12 | filterIllegal = cfg: 13 | # filter out attrsets, functions and illegal environment vars 14 | l.filterAttrs 15 | (name: env: (env != null) && (! isIllegalEnv name)) 16 | cfg; 17 | in 18 | filterIllegal 19 | -------------------------------------------------------------------------------- /src/functions/findRustToolchain.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | pkgs, 4 | rust-overlay, 5 | toolchainConfig, 6 | path, 7 | }: let 8 | l = lib // builtins; 9 | rust-bin = rust-overlay.lib.mkRustBin {} pkgs; 10 | toolchainFile = 11 | if builtins.isPath toolchainConfig 12 | then toolchainConfig 13 | else if toolchainConfig == null 14 | then let 15 | # test if toolchain files exist 16 | legacyFilePath = "${path}/rust-toolchain"; 17 | filePath = "${path}/rust-toolchain.toml"; 18 | file = 19 | if l.pathExists filePath 20 | then filePath 21 | else if l.pathExists legacyFilePath 22 | then legacyFilePath 23 | else null; 24 | in 25 | file 26 | else null; 27 | toolchainAttrs = 28 | if builtins.isAttrs toolchainConfig 29 | then toolchainConfig 30 | else null; 31 | # Create the base Rust toolchain that we will override to add other components. 32 | toolchain = 33 | if toolchainFile != null 34 | then rust-bin.fromRustupToolchainFile toolchainFile 35 | else if toolchainAttrs != null 36 | then rust-bin.fromRustupToolchain toolchainAttrs 37 | else rust-bin.stable.latest.default; 38 | in { 39 | build = toolchain; 40 | shell = toolchain; 41 | } 42 | -------------------------------------------------------------------------------- /src/functions/getModuleDefaults.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | ... 5 | }: module: 6 | (lib.evalModules { 7 | specialArgs = {inherit pkgs;}; 8 | modules = [module]; 9 | }) 10 | .config 11 | -------------------------------------------------------------------------------- /src/functions/getProjectCrates.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | path, 4 | }: let 5 | l = lib // builtins; 6 | virtualManifestPath = "${path}/Cargo.toml"; 7 | manifest = l.fromTOML (l.readFile virtualManifestPath); 8 | projectRoot = l.dirOf virtualManifestPath; 9 | # get all workspace members 10 | workspaceMembers = 11 | l.flatten 12 | ( 13 | l.map 14 | ( 15 | memberName: let 16 | _components = l.splitString "/" memberName; 17 | components = l.filter (c: c != ".") _components; 18 | in 19 | # Resolve globs if there are any 20 | if l.last components == "*" 21 | then let 22 | parentDirRel = l.concatStringsSep "/" (l.init components); 23 | dirs = l.readDir "${projectRoot}/${parentDirRel}"; 24 | in 25 | l.mapAttrsToList 26 | (name: _: "${parentDirRel}/${name}") 27 | (l.filterAttrs (_: t: t == "directory") dirs) 28 | else l.concatStringsSep "/" components 29 | ) 30 | (manifest.workspace.members or []) 31 | ); 32 | getAttribute = package: attr: 33 | if package.${attr}.workspace or null == true 34 | then manifest.workspace.package.${attr} 35 | else package.${attr}; 36 | allPackages = 37 | ( 38 | l.optional 39 | (manifest ? package) 40 | { 41 | inherit (manifest.package) name; 42 | version = getAttribute manifest.package "version"; 43 | path = ""; 44 | } 45 | ) 46 | ++ ( 47 | l.map 48 | (relPath: let 49 | manifestPath = "${projectRoot}/${relPath}/Cargo.toml"; 50 | manifest = l.fromTOML (l.readFile manifestPath); 51 | in { 52 | inherit (manifest.package) name; 53 | version = getAttribute manifest.package "version"; 54 | path = relPath; 55 | }) 56 | workspaceMembers 57 | ); 58 | in 59 | l.unique allPackages 60 | -------------------------------------------------------------------------------- /src/functions/mkCheckOnlyPackage.nix: -------------------------------------------------------------------------------- 1 | pkg: let 2 | cfg = {lib, ...}: { 3 | rust-crane.runTests = lib.mkForce true; 4 | mkDerivation.buildPhase = ":"; 5 | mkDerivation.installPhase = "env > $out"; 6 | }; 7 | in 8 | (pkg.extendModules {modules = [cfg];}).config.public 9 | -------------------------------------------------------------------------------- /src/functions/mkClippyOnlyPackage.nix: -------------------------------------------------------------------------------- 1 | pkg: let 2 | cfg = { 3 | config, 4 | lib, 5 | ... 6 | }: { 7 | mkDerivation.buildPhase = '' 8 | cargo clippy --all-targets --all-features $cargoBuildFlags --profile $cargoBuildProfile --package ${config.name} 9 | ''; 10 | mkDerivation.checkPhase = ":"; 11 | mkDerivation.installPhase = "env > $out"; 12 | }; 13 | in 14 | (pkg.extendModules {modules = [cfg];}).config.public 15 | -------------------------------------------------------------------------------- /src/functions/mkDevshellFromRaw.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | rawShell, 4 | shellToolchain, 5 | runtimeLibs, 6 | }: let 7 | l = lib // builtins; 8 | inputsNames = ["buildInputs" "nativeBuildInputs" "propagatedBuildInputs" "propagatedNativeBuildInputs"]; 9 | runtimeLibsEnv = l.optionalAttrs (l.length runtimeLibs > 0) { 10 | LD_LIBRARY_PATH = "${l.makeLibraryPath runtimeLibs}"; 11 | }; 12 | base = rawShell.overrideAttrs (old: 13 | runtimeLibsEnv 14 | // { 15 | nativeBuildInputs = 16 | [(lib.hiPrio shellToolchain)] 17 | ++ (old.nativeBuildInputs or []); 18 | }); 19 | overrideAttrs = shell: f: let 20 | new = base.overrideAttrs ( 21 | old: let 22 | attrs = f old; 23 | _newAttrs = 24 | attrs 25 | // { 26 | nativeBuildInputs = 27 | (attrs.packages or []) 28 | ++ (attrs.nativeBuildInputs or []) 29 | ++ (old.nativeBuildInputs or []); 30 | }; 31 | newAttrs = 32 | _newAttrs 33 | // { 34 | env = l.filterAttrs (name: _: l.any (oname: name != oname) inputsNames) (_newAttrs.env or {}); 35 | packages = l.unique ((_newAttrs.packages or []) ++ (l.flatten (l.map (name: _newAttrs.${name} or []) inputsNames))); 36 | }; 37 | in 38 | newAttrs 39 | ); 40 | in 41 | new 42 | // { 43 | overrideAttrs = overrideAttrs new; 44 | }; 45 | in 46 | overrideAttrs base (_: {}) 47 | -------------------------------------------------------------------------------- /src/functions/mkDocsOnlyPackage.nix: -------------------------------------------------------------------------------- 1 | pkg: let 2 | cfg = { 3 | config, 4 | lib, 5 | ... 6 | }: { 7 | mkDerivation = { 8 | buildPhase = lib.mkForce '' 9 | cargo doc $cargoBuildFlags --no-deps --profile $cargoBuildProfile --package ${config.name} 10 | ''; 11 | checkPhase = lib.mkForce ":"; 12 | installPhase = lib.mkForce "mv target/$CARGO_BUILD_TARGET/doc $out"; 13 | }; 14 | }; 15 | in 16 | (pkg.extendModules {modules = [cfg];}).config.public 17 | -------------------------------------------------------------------------------- /src/functions/mkGenerateLockfilesApp.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | lib, 4 | projects, 5 | buildToolchain, 6 | source, 7 | }: let 8 | l = lib // builtins; 9 | in 10 | pkgs.writers.writeBash "generate-lockfiles" '' 11 | function addToGit () { 12 | if [ -d ".git" ]; then 13 | git add $1 14 | fi 15 | } 16 | ${ 17 | l.concatMapStringsSep 18 | "\n" 19 | ( 20 | project: let 21 | relPath = l.removePrefix (toString source) (toString project.path); 22 | trimSlashes = str: l.removePrefix "/" (l.removeSuffix "/" str); 23 | cargoTomlPath = trimSlashes "${relPath}/Cargo.toml"; 24 | cargoLockPath = trimSlashes "${relPath}/Cargo.lock"; 25 | in '' 26 | ${buildToolchain}/bin/cargo generate-lockfile --manifest-path ${cargoTomlPath} 27 | addToGit ${cargoLockPath} 28 | '' 29 | ) 30 | (l.attrValues projects) 31 | } 32 | '' 33 | -------------------------------------------------------------------------------- /src/functions/mkPackagesFromRaw.nix: -------------------------------------------------------------------------------- 1 | { 2 | rawPkg, 3 | targets, 4 | profiles, 5 | runtimeLibs, 6 | pkgs, 7 | }: let 8 | l = pkgs.lib // builtins; 9 | makePackage = target: targetConf: 10 | l.mapAttrs 11 | ( 12 | profile: profileConf: 13 | _makePackage profile profileConf target targetConf 14 | ) 15 | ( 16 | if targetConf.profiles != null 17 | then 18 | ( 19 | l.filterAttrs 20 | (profile: _: l.any (op: profile == op) targetConf.profiles) 21 | profiles 22 | ) 23 | else profiles 24 | ); 25 | _makePackage = profile: profileConf: target: targetConf: let 26 | flags = 27 | if profileConf.features == null 28 | then [] 29 | else if l.length profileConf.features > 0 30 | then [ 31 | "--no-default-features" 32 | "--features" 33 | "${l.concatStringsSep "," profileConf.features}" 34 | ] 35 | else ["--no-default-features"]; 36 | pkg = 37 | (rawPkg.extendModules { 38 | modules = [ 39 | profileConf.drvConfig 40 | targetConf.drvConfig 41 | { 42 | env.CARGO_BUILD_TARGET = target; 43 | rust-crane = { 44 | buildProfile = profile; 45 | buildFlags = flags; 46 | testProfile = profile; 47 | testFlags = flags; 48 | runTests = profileConf.runTests; 49 | depsDrv = l.mkMerge [ 50 | profileConf.depsDrvConfig 51 | targetConf.depsDrvConfig 52 | {env.CARGO_BUILD_TARGET = target;} 53 | ]; 54 | }; 55 | } 56 | ]; 57 | }) 58 | .config 59 | .public; 60 | in 61 | if l.length runtimeLibs > 0 62 | then 63 | pkgs.runCommand 64 | pkg.name 65 | { 66 | inherit (pkg) name version; 67 | meta = pkg.meta or {}; 68 | passthru = 69 | (pkg.passthru or {}) 70 | // { 71 | unwrapped = pkg; 72 | }; 73 | } 74 | '' 75 | mkdir -p $out 76 | cp -r --no-preserve=mode,ownership ${pkg}/* $out/ 77 | for bin in $out/bin/*; do 78 | chmod +x "$bin" 79 | ${pkgs.patchelf}/bin/patchelf --set-rpath "${l.makeLibraryPath runtimeLibs}" "$bin" 80 | done 81 | '' 82 | else pkg; 83 | in 84 | l.mapAttrs makePackage targets 85 | -------------------------------------------------------------------------------- /src/functions/mkRawshellFromDrvs.nix: -------------------------------------------------------------------------------- 1 | { 2 | # args 3 | name, 4 | drvs, 5 | # nixpkgs 6 | lib, 7 | mkShell, 8 | ... 9 | }: let 10 | l = lib // builtins; 11 | 12 | filterIllegal = import ./filterDevshellIllegalVars.nix {inherit lib;}; 13 | inputsNames = ["buildInputs" "nativeBuildInputs" "propagatedBuildInputs" "propagatedNativeBuildInputs"]; 14 | getEnvs = drv: [ 15 | (filterIllegal drv.config.env) 16 | (filterIllegal drv.config.rust-crane.depsDrv.env) 17 | ]; 18 | getMkDerivations = drv: [ 19 | (filterIllegal drv.config.mkDerivation) 20 | (filterIllegal drv.config.rust-crane.depsDrv.mkDerivation) 21 | ]; 22 | combine = envs: 23 | l.foldl' 24 | ( 25 | all: el: let 26 | mergeList = name: l.unique ((all.${name} or []) ++ (el.${name} or [])); 27 | in 28 | all 29 | // el 30 | // ( 31 | l.mapAttrs (name: _: mergeList name) (l.filterAttrs (_: l.isList) el) 32 | ) 33 | ) 34 | {} 35 | envs; 36 | _shellEnv = combine (l.flatten (l.map getEnvs drvs)); 37 | _shellInputs = combine (l.flatten (l.map getMkDerivations drvs)); 38 | shellAttrs = 39 | _shellEnv 40 | // _shellInputs 41 | // { 42 | inherit name; 43 | passthru.env = _shellEnv; 44 | passthru.packages = l.unique (l.flatten (l.map (name: _shellInputs.${name} or []) inputsNames)); 45 | }; 46 | final = (mkShell.override {stdenv = (lib.head drvs).out.stdenv;}) shellAttrs; 47 | in 48 | final 49 | -------------------------------------------------------------------------------- /src/functions/warnIfNoLock.nix: -------------------------------------------------------------------------------- 1 | { 2 | source, 3 | project, 4 | lib, 5 | }: let 6 | _relPath = lib.removePrefix (toString source) (toString project.path); 7 | relPath = lib.removePrefix "/" _relPath; 8 | in 9 | if builtins.pathExists "${project.path}/Cargo.lock" 10 | then { 11 | inherit project; 12 | hasLock = true; 13 | } 14 | else 15 | builtins.trace 16 | '' 17 | Cargo.lock not found for project at path ${relPath}. 18 | Please ensure the lockfile exists for your project. 19 | If you are using a VCS, ensure the lockfile is added to the VCS and not ignored (eg. run `git add ${relPath}/Cargo.lock` for git). 20 | 21 | This project will be skipped and won't have any outputs generated. 22 | Run `nix run .#generate-lockfiles` to generate lockfiles for projects that don't have one. 23 | '' 24 | { 25 | inherit project; 26 | hasLock = false; 27 | } 28 | -------------------------------------------------------------------------------- /src/implementation.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | flake-parts-lib, 4 | ... 5 | } @ args: let 6 | l = lib // builtins; 7 | systemlessNci = args.config.nci; 8 | inp = systemlessNci._inputs; 9 | in { 10 | # Make sure the top-level option devshells exists 11 | # even when the numtide devshell is not included. 12 | # We don't want to depend on adding the numtide devshell 13 | # module and this doesn't interfere with it when it is added. 14 | options = { 15 | perSystem = flake-parts-lib.mkPerSystemOption { 16 | options.devshells = l.mkOption { 17 | type = l.types.lazyAttrsOf (l.types.submoduleWith {modules = [];}); 18 | }; 19 | }; 20 | }; 21 | 22 | config = { 23 | perSystem = { 24 | config, 25 | pkgs, 26 | ... 27 | }: let 28 | getModuleDefaults = import ./functions/getModuleDefaults.nix {inherit lib pkgs;}; 29 | moduleDefaults = { 30 | crate = getModuleDefaults ./modules/crate.nix; 31 | project = getModuleDefaults ./modules/project.nix; 32 | }; 33 | # gets crate option, if null or is not defined then returns the project wide option, if also does not exist then returns module default 34 | _getCrateOption = crateName: optName: merge: let 35 | crate = nci.crates.${crateName} or moduleDefaults.crate; 36 | project = nci.projects.${cratesToProjects.${crateName} or crateName} or moduleDefaults.project; 37 | in 38 | if crate.${optName} == null 39 | then project.${optName} or null 40 | else if merge && l.isList crate.${optName} 41 | then project.${optName} ++ crate.${optName} 42 | else if merge && l.isAttrs crate.${optName} 43 | then project.${optName} // crate.${optName} 44 | else crate.${optName}; 45 | getCrateOption = crateName: optName: _getCrateOption crateName optName true; 46 | getUnmergedCrateOption = crateName: optName: _getCrateOption crateName optName false; 47 | 48 | nci = config.nci; 49 | 50 | # project name -> nci crate cfg 51 | projectsToCrates = 52 | l.mapAttrs 53 | ( 54 | name: project: 55 | import ./functions/getProjectCrates.nix { 56 | inherit lib; 57 | inherit (project) path; 58 | } 59 | ) 60 | nci.projects; 61 | # crate name -> project name 62 | cratesToProjects = l.listToAttrs (l.flatten ( 63 | l.mapAttrsToList 64 | ( 65 | project: crates: 66 | l.map (crate: l.nameValuePair crate.name project) crates 67 | ) 68 | projectsToCrates 69 | )); 70 | getCrateName = currentName: let 71 | newName = getCrateOption currentName "renameTo"; 72 | in 73 | if newName != null 74 | then newName 75 | else currentName; 76 | 77 | outputsToExport = 78 | l.filterAttrs 79 | (name: out: getCrateOption name "export") 80 | nci.outputs; 81 | 82 | projectsChecked = 83 | l.mapAttrs 84 | (name: project: 85 | import ./functions/warnIfNoLock.nix { 86 | source = systemlessNci.source; 87 | inherit project lib; 88 | }) 89 | nci.projects; 90 | projectsWithLock = 91 | l.mapAttrs 92 | (name: value: value.project) 93 | ( 94 | l.filterAttrs 95 | (name: value: value.hasLock) 96 | projectsChecked 97 | ); 98 | projectsWithoutLock = 99 | l.mapAttrs 100 | (name: value: value.project) 101 | ( 102 | l.filterAttrs 103 | (name: value: !value.hasLock) 104 | projectsChecked 105 | ); 106 | 107 | # get the toolchains we will use 108 | toolchainsFn = pkgs: 109 | import ./functions/findRustToolchain.nix { 110 | inherit lib pkgs; 111 | inherit (inp) rust-overlay; 112 | inherit (nci) toolchainConfig; 113 | path = toString systemlessNci.source; 114 | }; 115 | 116 | _evalCrate = modules: 117 | inp.dream2nix.lib.evalModules { 118 | packageSets.nixpkgs = pkgs; 119 | modules = 120 | [ 121 | inp.dream2nix.modules.dream2nix.rust-cargo-lock 122 | inp.dream2nix.modules.dream2nix.rust-cargo-vendor 123 | inp.dream2nix.modules.dream2nix.rust-crane 124 | ] 125 | ++ modules; 126 | }; 127 | 128 | nci-lib = { 129 | buildCrate = { 130 | src, 131 | drvConfig ? {}, 132 | depsDrvConfig ? {}, 133 | cratePath ? "", 134 | mkRustToolchain ? nci.toolchains.mkBuild, 135 | }: let 136 | cargoToml = l.fromTOML (l.readFile ( 137 | if cratePath == "" 138 | then "${src}/Cargo.toml" 139 | else "${src}/${cratePath}/Cargo.toml" 140 | )); 141 | in (_evalCrate [ 142 | { 143 | paths.projectRoot = src; 144 | paths.projectRootFile = "Cargo.lock"; 145 | paths.package = "/${cratePath}"; 146 | } 147 | drvConfig 148 | { 149 | deps.craneSource = inp.crane; 150 | deps.mkRustToolchain = mkRustToolchain; 151 | 152 | name = l.mkForce cargoToml.package.name; 153 | version = l.mkForce cargoToml.package.version; 154 | 155 | mkDerivation.src = l.mkForce src; 156 | 157 | rust-crane.depsDrv = depsDrvConfig; 158 | } 159 | ]); 160 | }; 161 | 162 | evalCrate = project: crate: let 163 | crateCfg = nci.crates.${crate.name} or moduleDefaults.crate; 164 | in 165 | _evalCrate [ 166 | { 167 | paths.projectRoot = project.path; 168 | paths.projectRootFile = "flake.nix"; 169 | paths.package = "/${crate.path}"; 170 | } 171 | project.drvConfig 172 | crateCfg.drvConfig 173 | { 174 | deps.craneSource = inp.crane; 175 | deps.mkRustToolchain = nci.toolchains.mkBuild; 176 | 177 | name = l.mkForce crate.name; 178 | version = l.mkForce crate.version; 179 | 180 | mkDerivation.src = l.mkForce project.path; 181 | 182 | rust-crane.depsDrv = l.mkMerge [ 183 | project.depsDrvConfig 184 | crateCfg.depsDrvConfig 185 | ]; 186 | } 187 | ]; 188 | # eval all crates with d2n 189 | d2nOutputs = l.listToAttrs (l.flatten ( 190 | l.mapAttrsToList 191 | ( 192 | projName: project: 193 | l.map 194 | (crate: { 195 | name = crate.name; 196 | value = evalCrate project crate; 197 | }) 198 | projectsToCrates.${projName} 199 | ) 200 | projectsWithLock 201 | )); 202 | 203 | # make crate outputs 204 | crateOutputs = 205 | l.mapAttrs 206 | ( 207 | name: package: let 208 | runtimeLibs = getCrateOption name "runtimeLibs"; 209 | profiles = getCrateOption name "profiles"; 210 | targets = getUnmergedCrateOption name "targets"; 211 | clippyProfile = getCrateOption name "clippyProfile"; 212 | checkProfile = getCrateOption name "checkProfile"; 213 | docsProfile = getCrateOption name "docsProfile"; 214 | allTargets = import ./functions/mkPackagesFromRaw.nix { 215 | inherit pkgs runtimeLibs profiles targets; 216 | rawPkg = package; 217 | }; 218 | _defaultTargets = l.attrNames (l.filterAttrs (_: v: v.default) targets); 219 | defaultTarget = 220 | if l.length _defaultTargets > 1 221 | then throw "there can't be more than one default target: ${l.concatStringsSep ", " _defaultTargets}" 222 | else if l.length _defaultTargets < 1 223 | then throw "there is no default target defined" 224 | else l.head _defaultTargets; 225 | packages = allTargets.${defaultTarget}; 226 | in { 227 | inherit packages; 228 | allTargets = l.mapAttrs (_: packages: {inherit packages;}) allTargets; 229 | devShell = import ./functions/mkDevshellFromRaw.nix { 230 | inherit lib runtimeLibs; 231 | rawShell = import ./functions/mkRawshellFromDrvs.nix { 232 | inherit lib; 233 | inherit (pkgs) mkShell; 234 | name = "${name}-devshell"; 235 | drvs = [(packages.dev.unwrapped or packages.dev)]; 236 | }; 237 | shellToolchain = nci.toolchains.mkShell pkgs; 238 | }; 239 | check = import ./functions/mkCheckOnlyPackage.nix packages.${checkProfile}; 240 | clippy = import ./functions/mkClippyOnlyPackage.nix packages.${clippyProfile}; 241 | docs = import ./functions/mkDocsOnlyPackage.nix packages.${docsProfile}; 242 | } 243 | ) 244 | d2nOutputs; 245 | 246 | # make project outputs 247 | projectsOutputs = 248 | l.mapAttrs 249 | (name: project: let 250 | allCrateNames = l.map (crate: crate.name) projectsToCrates.${name}; 251 | rawShell = import ./functions/mkRawshellFromDrvs.nix { 252 | inherit lib; 253 | inherit (pkgs) mkShell; 254 | name = "${name}-devshell"; 255 | drvs = l.map (name: crateOutputs.${name}.packages.dev.unwrapped or crateOutputs.${name}.packages.dev) allCrateNames; 256 | }; 257 | docs = pkgs.callPackage ./functions/combineDocsPackages.nix { 258 | inherit (nci-lib) buildCrate; 259 | derivationName = "${name}-docs"; 260 | indexCrateName = project.docsIndexCrate; 261 | docsPackages = 262 | l.map 263 | (crateName: crateOutputs.${crateName}.docs) 264 | ( 265 | l.filter 266 | ( 267 | crateName: 268 | getCrateOption crateName "includeInProjectDocs" 269 | ) 270 | allCrateNames 271 | ); 272 | }; 273 | runtimeLibs = 274 | project.runtimeLibs 275 | ++ ( 276 | l.flatten ( 277 | l.map 278 | (name: getCrateOption name "runtimeLibs") 279 | allCrateNames 280 | ) 281 | ); 282 | in { 283 | packages = {}; 284 | devShell = import ./functions/mkDevshellFromRaw.nix { 285 | inherit lib runtimeLibs rawShell; 286 | shellToolchain = nci.toolchains.mkShell pkgs; 287 | }; 288 | inherit docs; 289 | }) 290 | projectsWithLock; 291 | in { 292 | nci.toolchains = { 293 | mkBuild = l.mkDefault (pkgs: (toolchainsFn pkgs).build); 294 | mkShell = l.mkDefault (pkgs: (toolchainsFn pkgs).shell); 295 | }; 296 | 297 | nci.outputs = 298 | # crates will override project outputs if they have the same names 299 | # TODO: should probably warn the user here if that's the case 300 | projectsOutputs // (l.filterAttrs (name: attrs: attrs != null) crateOutputs); 301 | 302 | nci.lib = nci-lib; 303 | 304 | apps = 305 | l.optionalAttrs 306 | (l.length (l.attrNames projectsWithoutLock) > 0) 307 | { 308 | generate-lockfiles.program = toString (import ./functions/mkGenerateLockfilesApp.nix { 309 | inherit pkgs lib; 310 | projects = projectsWithoutLock; 311 | buildToolchain = nci.toolchains.mkBuild pkgs; 312 | source = systemlessNci.source; 313 | }); 314 | }; 315 | 316 | # export checks, packages and devshells for crates that have `export` set to `true` 317 | checks = l.filterAttrs (_: out: out != null) (l.listToAttrs (l.flatten ( 318 | l.mapAttrsToList 319 | ( 320 | name: out: 321 | if l.hasAttr name projectsWithLock 322 | then 323 | # skip this since projects don't define check outputs 324 | l.nameValuePair 325 | (getCrateName name) 326 | null 327 | else [ 328 | ( 329 | l.nameValuePair 330 | "${getCrateName name}-tests" 331 | (l.mkDefault out.check) 332 | ) 333 | ( 334 | l.nameValuePair 335 | "${getCrateName name}-clippy" 336 | (l.mkDefault out.clippy) 337 | ) 338 | ] 339 | ) 340 | outputsToExport 341 | ))); 342 | packages = l.listToAttrs (l.flatten ( 343 | l.mapAttrsToList 344 | ( 345 | name: out: 346 | l.mapAttrsToList 347 | ( 348 | profile: package: 349 | l.nameValuePair 350 | "${getCrateName name}-${profile}" 351 | (l.mkDefault package) 352 | ) 353 | out.packages 354 | ) 355 | outputsToExport 356 | )); 357 | devShells = 358 | l.mapAttrs' 359 | ( 360 | name: out: 361 | l.nameValuePair 362 | (getCrateName name) 363 | (l.mkDefault out.devShell) 364 | ) 365 | outputsToExport; 366 | 367 | # numtide devshell integration 368 | devshells = let 369 | addDevOutputs = xs: lib.concatLists (map (p: [(l.getDev p) p]) xs); 370 | collectEnv = devShell: 371 | [ 372 | { 373 | name = "PKG_CONFIG_PATH"; 374 | prefix = "$DEVSHELL_DIR/lib/pkgconfig"; 375 | } 376 | { 377 | name = "LD_LIBRARY_PATH"; 378 | prefix = "$DEVSHELL_DIR/lib"; 379 | } 380 | ] 381 | ++ (l.mapAttrsToList (k: v: { 382 | name = k; 383 | value = v; 384 | }) (devShell.env or [])); 385 | shellToolchain = config.nci.toolchains.mkShell pkgs; 386 | numtideDevshellFor = outputs: name: cfg: 387 | l.optional (cfg.numtideDevshell != null) { 388 | ${cfg.numtideDevshell} = { 389 | packagesFrom = [shellToolchain]; 390 | packages = 391 | [shellToolchain] 392 | ++ addDevOutputs (outputs.${name}.devShell.packages or []); 393 | env = collectEnv outputs.${name}.devShell; 394 | }; 395 | }; 396 | in 397 | l.mkMerge ( 398 | l.concatLists ( 399 | l.mapAttrsToList (numtideDevshellFor projectsOutputs) config.nci.projects 400 | ++ l.mapAttrsToList (numtideDevshellFor crateOutputs) config.nci.crates 401 | ) 402 | ); 403 | }; 404 | }; 405 | } 406 | -------------------------------------------------------------------------------- /src/interface.nix: -------------------------------------------------------------------------------- 1 | { 2 | self, 3 | lib, 4 | flake-parts-lib, 5 | ... 6 | } @ args: let 7 | l = lib // builtins; 8 | t = l.types; 9 | inputs = args.config.nci._inputs; 10 | in { 11 | options = { 12 | nci._inputs = l.mkOption { 13 | type = t.raw; 14 | internal = true; 15 | }; 16 | nci.source = l.mkOption { 17 | type = t.path; 18 | default = self; 19 | defaultText = "self"; 20 | description = '' 21 | The source path that will be used as the 'flake root'. 22 | By default this points to the directory 'flake.nix' is in. 23 | ''; 24 | }; 25 | perSystem = 26 | flake-parts-lib.mkPerSystemOption 27 | ({pkgs, ...}: { 28 | options = { 29 | nci.toolchainConfig = l.mkOption { 30 | type = t.nullOr (t.either t.path t.attrs); 31 | default = null; 32 | description = "The toolchain configuration that will be used"; 33 | example = l.literalExpression "./rust-subproject/rust-toolchain.toml"; 34 | }; 35 | nci.toolchains = { 36 | mkBuild = l.mkOption { 37 | type = t.functionTo t.package; 38 | description = "The function to (given a nixpkgs instance) generate a toolchain that will be used when building derivations"; 39 | }; 40 | mkShell = l.mkOption { 41 | type = t.functionTo t.package; 42 | description = "The function to (given a nixpkgs instance) generate a toolchain that will be used in the development shell"; 43 | }; 44 | }; 45 | nci.projects = l.mkOption { 46 | type = t.lazyAttrsOf (t.submoduleWith { 47 | modules = [./modules/project.nix]; 48 | specialArgs = { 49 | defaultRustcTarget = pkgs.stdenv.hostPlatform.rust.rustcTarget; 50 | }; 51 | }); 52 | default = {}; 53 | example = l.literalExpression '' 54 | { 55 | # define the absolute path to the project 56 | my-project.path = ./.; 57 | } 58 | ''; 59 | description = "Projects (workspaces / crates) to generate outputs for"; 60 | }; 61 | nci.crates = l.mkOption { 62 | type = t.lazyAttrsOf (t.submoduleWith { 63 | modules = [./modules/crate.nix]; 64 | specialArgs = {inherit pkgs inputs;}; 65 | }); 66 | default = {}; 67 | example = l.literalExpression '' 68 | { 69 | my-crate = { 70 | export = true; 71 | }; 72 | } 73 | ''; 74 | description = "Crate configurations"; 75 | }; 76 | nci.outputs = l.mkOption { 77 | type = t.lazyAttrsOf (t.submoduleWith { 78 | modules = [./modules/output.nix]; 79 | }); 80 | readOnly = true; 81 | description = "Each crate's (or project's) outputs"; 82 | }; 83 | nci.lib = { 84 | buildCrate = l.mkOption { 85 | type = t.functionTo t.package; 86 | readOnly = true; 87 | description = '' 88 | A function to build a crate from a provided source (and crate path if workspace) automagically 89 | 90 | The arguments are: 91 | - `src`: the source for the project (or crate if it's just a crate) 92 | - `cratePath`: relative path to the provided `src`, used to find the crate if it's a workspace 93 | - `mkRustToolchain`: function that outputs a rust toolchain package (like `nci.toolchains.mkBuild`, which is also the default), will be used when building 94 | - `drvConfig` and `depsDrvConfig`: see `nci.crates..` in this documentation (optional) 95 | ''; 96 | }; 97 | }; 98 | }; 99 | }); 100 | }; 101 | } 102 | -------------------------------------------------------------------------------- /src/modules/crate.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | lib, 4 | pkgs, 5 | ... 6 | }: let 7 | l = lib // builtins; 8 | t = l.types; 9 | in { 10 | imports = [ 11 | ../options/drvConfig.nix 12 | ../options/numtideDevshell.nix 13 | ]; 14 | options = { 15 | export = l.mkOption { 16 | type = t.nullOr t.bool; 17 | default = null; 18 | example = true; 19 | description = "Whether to export this all of this crate's outputs (if set will override project-wide setting)"; 20 | }; 21 | 22 | checkProfile = l.mkOption { 23 | type = t.nullOr t.str; 24 | default = null; 25 | example = "custom-profile"; 26 | description = "Profile to use for the tests only package"; 27 | }; 28 | clippyProfile = l.mkOption { 29 | type = t.nullOr t.bool; 30 | default = null; 31 | example = "custom-profile"; 32 | description = '' 33 | Profile to use for clippy only package 34 | Note that you will need to add 'clippy' as a component to the rust toolchain you are using yourself 35 | ''; 36 | }; 37 | docsProfile = l.mkOption { 38 | type = t.nullOr t.str; 39 | default = null; 40 | example = "custom-profile"; 41 | description = "Profile to use for the docs only package"; 42 | }; 43 | includeInProjectDocs = l.mkOption { 44 | type = t.nullOr t.bool; 45 | default = null; 46 | example = false; 47 | description = "Whether to include this crate's docs in the project docs package"; 48 | }; 49 | 50 | profiles = l.mkOption { 51 | type = t.nullOr ( 52 | t.attrsOf (t.submoduleWith { 53 | modules = [./profile.nix]; 54 | }) 55 | ); 56 | default = null; 57 | example = l.literalExpression '' 58 | { 59 | dev = {}; 60 | release.runTests = true; 61 | custom-profile.features = ["some" "features"]; 62 | } 63 | ''; 64 | description = "Profiles to generate packages for this crate (if set will override project-wide setting)"; 65 | }; 66 | targets = l.mkOption { 67 | type = t.nullOr ( 68 | t.attrsOf (t.submoduleWith { 69 | modules = [./target.nix]; 70 | }) 71 | ); 72 | default = null; 73 | example = l.literalExpression '' 74 | { 75 | wasm32-unknown-unknown.profiles = ["release"]; 76 | x86_64-unknown-linux-gnu.default = true; 77 | } 78 | ''; 79 | description = "Targets to generate packages for this crate (if set will override project-wide setting)"; 80 | }; 81 | 82 | runtimeLibs = l.mkOption { 83 | type = t.listOf t.package; 84 | default = []; 85 | example = l.literalExpression '' 86 | [pkgs.alsa-lib pkgs.libxkbcommon] 87 | ''; 88 | description = '' 89 | Runtime libraries that will be: 90 | - patched into the binary at build time, 91 | - present in `LD_LIBRARY_PATH` environment variable in development shell. 92 | 93 | Note that when it's patched in at build time, a separate derivation will 94 | be created that "wraps" the original derivation to not cause the whole 95 | crate to recompile when you only change `runtimeLibs`. The original 96 | derivation can be accessed via `.passthru.unwrapped` attribute. 97 | ''; 98 | }; 99 | 100 | renameTo = l.mkOption { 101 | type = t.nullOr t.str; 102 | default = null; 103 | description = "What to rename this crate's outputs to in `nix flake show`"; 104 | }; 105 | }; 106 | } 107 | -------------------------------------------------------------------------------- /src/modules/output.nix: -------------------------------------------------------------------------------- 1 | {lib, ...}: let 2 | l = lib // builtins; 3 | t = l.types; 4 | opts = { 5 | packages = l.mkOption { 6 | type = t.lazyAttrsOf t.package; 7 | readOnly = true; 8 | description = "Packages of this crate mapped to profiles"; 9 | }; 10 | devShell = l.mkOption { 11 | type = t.package; 12 | readOnly = true; 13 | description = "The development shell for this crate"; 14 | }; 15 | check = l.mkOption { 16 | type = t.package; 17 | readOnly = true; 18 | description = "Tests only package for this crate"; 19 | }; 20 | clippy = l.mkOption { 21 | type = t.package; 22 | readOnly = true; 23 | description = "Clippy only package for this crate"; 24 | }; 25 | docs = l.mkOption { 26 | type = t.package; 27 | readOnly = true; 28 | description = "Docs only package for this crate"; 29 | }; 30 | }; 31 | in { 32 | options = 33 | opts 34 | // { 35 | allTargets = l.mkOption { 36 | type = t.lazyAttrsOf (t.submoduleWith { 37 | modules = [{options = {inherit (opts) packages;};}]; 38 | }); 39 | readOnly = true; 40 | description = "All packages for all targets"; 41 | }; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /src/modules/profile.nix: -------------------------------------------------------------------------------- 1 | {lib, ...}: let 2 | l = lib // builtins; 3 | t = l.types; 4 | in { 5 | imports = [../options/drvConfig.nix]; 6 | options = { 7 | features = l.mkOption { 8 | type = t.nullOr (t.listOf t.str); 9 | default = null; 10 | defaultText = ''["default"]''; 11 | example = l.literalExpression '' 12 | ["tracing" "publish"] 13 | ''; 14 | description = '' 15 | Features to enable for this profile. Set to 'null' to enable default features only (this is the default). 16 | If set to a list of features then '--no-default-features' will be passed to Cargo. 17 | If you want to also enable default features you can add 'default' feature to the list of features. 18 | ''; 19 | }; 20 | runTests = l.mkOption { 21 | type = t.bool; 22 | default = false; 23 | example = true; 24 | description = "Whether to run tests for this profile"; 25 | }; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /src/modules/project.nix: -------------------------------------------------------------------------------- 1 | { 2 | lib, 3 | defaultRustcTarget, 4 | ... 5 | }: let 6 | l = lib // builtins; 7 | t = l.types; 8 | mkOpt = name: attrs: 9 | l.mkOption (attrs 10 | // { 11 | description = '' 12 | `${name}` option that will affect all packages in this project. 13 | For more information refer to `nci.crates..${name}` option. 14 | ''; 15 | }); 16 | in { 17 | imports = [ 18 | ../options/drvConfig.nix 19 | ../options/numtideDevshell.nix 20 | ]; 21 | options = { 22 | path = l.mkOption { 23 | type = t.path; 24 | example = lib.literalExpression "./path/to/project"; 25 | description = "The absolute path of this project"; 26 | }; 27 | 28 | export = mkOpt "export" { 29 | type = t.bool; 30 | default = true; 31 | example = false; 32 | }; 33 | 34 | clippyProfile = mkOpt "clippyProfile" { 35 | type = t.str; 36 | default = "dev"; 37 | example = "custom-profile"; 38 | }; 39 | checkProfile = mkOpt "checkProfile" { 40 | type = t.str; 41 | default = "release"; 42 | example = "custom-profile"; 43 | }; 44 | docsProfile = mkOpt "docsProfile" { 45 | type = t.str; 46 | default = "release"; 47 | example = "custom-profile"; 48 | }; 49 | includeInProjectDocs = mkOpt "includeInProjectDocs" { 50 | type = t.bool; 51 | default = true; 52 | example = false; 53 | }; 54 | docsIndexCrate = l.mkOption { 55 | type = t.nullOr t.str; 56 | default = null; 57 | example = "my-crate"; 58 | description = '' 59 | The crate to link it's index.html when building project docs. 60 | 61 | The default will be not symlinking any index.html. 62 | ''; 63 | }; 64 | 65 | profiles = mkOpt "profiles" { 66 | type = t.attrsOf (t.submoduleWith { 67 | modules = [./profile.nix]; 68 | }); 69 | default = { 70 | dev = {}; 71 | release = { 72 | runTests = true; 73 | }; 74 | }; 75 | example = l.literalExpression '' 76 | { 77 | dev = {}; 78 | release.runTests = true; 79 | custom-profile.features = ["some" "features"]; 80 | } 81 | ''; 82 | }; 83 | targets = mkOpt "targets" { 84 | type = t.attrsOf (t.submoduleWith { 85 | modules = [./target.nix]; 86 | }); 87 | default = { 88 | ${defaultRustcTarget}.default = true; 89 | }; 90 | defaultText = '' 91 | { 92 | .default = true; 93 | } 94 | ''; 95 | example = l.literalExpression '' 96 | { 97 | wasm32-unknown-unknown.profiles = ["release"]; 98 | x86_64-unknown-linux-gnu.default = true; 99 | } 100 | ''; 101 | }; 102 | 103 | runtimeLibs = mkOpt "runtimeLibs" { 104 | type = t.listOf t.package; 105 | default = []; 106 | example = l.literalExpression '' 107 | [pkgs.alsa-lib pkgs.libxkbcommon] 108 | ''; 109 | }; 110 | }; 111 | } 112 | -------------------------------------------------------------------------------- /src/modules/target.nix: -------------------------------------------------------------------------------- 1 | {lib, ...}: let 2 | l = lib // builtins; 3 | t = l.types; 4 | in { 5 | imports = [../options/drvConfig.nix]; 6 | options = { 7 | default = l.mkOption { 8 | type = t.bool; 9 | default = false; 10 | example = true; 11 | description = "Whether or not this target is the default target"; 12 | }; 13 | profiles = l.mkOption { 14 | type = t.nullOr (t.listOf t.str); 15 | default = null; 16 | defaultText = "all profiles"; 17 | example = l.literalExpression '' 18 | ["dev" "release" "custom-profile"] 19 | ''; 20 | description = '' 21 | The profiles to generate packages for this target. 22 | ''; 23 | }; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /src/options/drvConfig.nix: -------------------------------------------------------------------------------- 1 | {lib, ...}: let 2 | l = lib // builtins; 3 | t = l.types; 4 | mkDrvConfig = desc: 5 | l.mkOption { 6 | type = t.attrsOf t.anything; 7 | default = {}; 8 | description = '' 9 | ${desc} 10 | `mkDerivation` options must be defined under the `mkDerivation` attribute. 11 | Environment variables and non-mkDerivation options must be defined under the `env` attribute. 12 | This is passed to `dream2nix` as is, so you could also define any other dream2nix module options here (eg. `rust-crane`). 13 | ''; 14 | example = l.literalExpression '' 15 | { 16 | mkDerivation = { 17 | # inputs and most other stuff will automatically merge 18 | buildInputs = [pkgs.hello]; 19 | }; 20 | # define env variables and options not defined in standard mkDerivation interface like this 21 | env = { 22 | CARGO_TERM_VERBOSE = "true"; 23 | someOtherEnvVar = 1; 24 | }; 25 | } 26 | ''; 27 | }; 28 | in { 29 | options = { 30 | drvConfig = mkDrvConfig "Change main derivation configuration"; 31 | depsDrvConfig = mkDrvConfig "Change dependencies derivation configuration"; 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /src/options/numtideDevshell.nix: -------------------------------------------------------------------------------- 1 | {lib, ...}: let 2 | l = lib // builtins; 3 | in { 4 | options = { 5 | numtideDevshell = l.mkOption { 6 | type = l.types.nullOr l.types.str; 7 | default = null; 8 | description = '' 9 | If set, the given numtide devshell `devshells.` will be populated with 10 | the required packages and environment variables to build this crate. 11 | ''; 12 | }; 13 | }; 14 | } 15 | --------------------------------------------------------------------------------