aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: 18eacbfc964eb48ef5898c8bb138cab294644c81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nci.url = "github:yusdacra/nix-cargo-integration";
    nci.inputs.nixpkgs.follows = "nixpkgs";
    parts.url = "github:hercules-ci/flake-parts";
    parts.inputs.nixpkgs-lib.follows = "nixpkgs";
  };

  outputs = inputs@{ parts, nci, ... }:
    parts.lib.mkFlake { inherit inputs; } {
      systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
      imports = [ nci.flakeModule ];
      perSystem = { pkgs, config, lib, ... }:
        let
          # shorthand for accessing this crate's outputs
          # you can access crate outputs under `config.nci.outputs.<crate name>` (see documentation)
          crateOutputs = config.nci.outputs."gtree";
        in
        {
          nci = {
            projects."gtree".path = ./.;
            crates.gtree =
              let mkDerivation = {
                # inputs and most other stuff will automatically merge
                buildInputs = lib.optional pkgs.stdenv.isDarwin [
                  pkgs.darwin.libiconv
                  pkgs.darwin.apple_sdk.frameworks.Security
                  pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
                ];
              };
              in
              {
                drvConfig = { inherit mkDerivation; };
                depsDrvConfig = { inherit mkDerivation; };
              };

            toolchainConfig = {
              channel = "stable";
              components = [ "rustfmt" "rust-src" ];
            };
          };


          devShells.default = crateOutputs.devShell;
          packages.default = crateOutputs.packages.release;
        };
    };
}