diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-05-09 15:39:29 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-05-09 15:39:29 +0200 |
commit | 8711c0c1900dc9a67a57b32d3a6eb713e0700910 (patch) | |
tree | ee88155284b76f41e109149a7b247b64eba26486 /flake.nix | |
parent | f7e041e35ebe588acf6f796f5bb03640619e1c68 (diff) | |
download | aerogramme-8711c0c1900dc9a67a57b32d3a6eb713e0700910.tar.gz aerogramme-8711c0c1900dc9a67a57b32d3a6eb713e0700910.zip |
static nix build for linux/amd64
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 43 |
1 files changed, 36 insertions, 7 deletions
@@ -8,17 +8,46 @@ 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 }: let - pkgs = import nixpkgs { system = "x86_64-linux"; }; - in { - devShells.x86_64-linux.default = pkgs.mkShell { + 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 ]; }; - packages.x86_64-linux.aerogramme = nixpkgs.legacyPackages.x86_64-linux.hello; - packages.x86_64-linux.default = self.packages.x86_64-linux.aerogramme; - }; + + 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; + }); } |