aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: fc1780dc6cd1a16a7a9cb1059c851418ffa002ac (plain) (blame)
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
50
51
52
53
{
  description = "Aerogramme";

  inputs = {
    cargo2nix = {
      type = "github";
      owner = "Alexis211";
      repo = "cargo2nix";
      ref = "custom_unstable";
    };
    nixpkgs.url = "github:NixOS/nixpkgs/master";
    #cargo2nix.url = "github:cargo2nix/cargo2nix/release-0.11.0";
    fenix.url = "github:nix-community/fenix/monthly";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, cargo2nix, flake-utils, fenix }: 
    flake-utils.lib.eachSystem [
      "x86_64-unknown-linux-musl"
      "aarch64-unknown-linux-musl"
      "armv6l-unknown-linux-musleabihf"
    ] (targetHost: let
    pkgs = import nixpkgs { 
      system = "x86_64-linux"; # hardcoded as we will cross compile
      crossSystem = {
        config = targetHost; # here we cross compile
        isStatic = true;
      };
      overlays = [cargo2nix.overlays.default];
    };

    shell = pkgs.mkShell {
      buildInputs = [
        cargo2nix.packages.x86_64-linux.default
      ];
    };
    
    rustPkgs = pkgs.rustBuilder.makePackageSet({
      rustToolchain = with fenix.packages.x86_64-linux; combine [
        minimal.cargo
        minimal.rustc
        targets.${targetHost}.latest.rust-std
      ];

      packageFun = import ./Cargo.nix;
    });

    in {
      devShells.default = shell;
      packages.aerogramme =  (rustPkgs.workspace.aerogramme {}).bin;
      packages.default = self.packages.${targetHost}.aerogramme;
    });
}