{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; crane.url = "github:ipetkov/crane"; crane.inputs.nixpkgs.follows = "nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; }; }; }; outputs = { self, nixpkgs, crane, rust-overlay, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) ]; pkgs = import nixpkgs { inherit system overlays; }; craneLib = crane.lib.${system}; src = ./gdo-runner; nbuild = [ pkgs.rust-bin.stable.latest.default pkgs.libiconv ]; cargoArtifacts = craneLib.buildDepsOnly { inherit src; nativeBuildInputs = nbuild; }; gdo-runner-clippy = craneLib.cargoClippy { inherit cargoArtifacts src; nativeBuildInputs = nbuild; cargoClippyExtraArgs = "-- --deny warnings"; }; gdo-runner-pkg = craneLib.buildPackage { inherit cargoArtifacts src; nativeBuildInputs = nbuild; }; dockerArchitectures = { "x86_64" = pkgs.pkgsCross.gnu64; "aarch64" = pkgs.pkgsCross.aarch64-multiplatform; }; docker-image = pkgs.dockerTools.buildImage { name = "gdo-runner"; config = { Cmd = [ "${gdo-runner-pkg}/bin/gdo-runner" ]; Env = [ ''NIX_DOCKER_MULTIARCH="true"'' ]; }; }; in rec { # given this, `nix build` will produce `./result/bin/gdo-runner` even if the system does not have dependencies packages = { gdo-runner = gdo-runner-pkg; docker = docker-image; default = gdo-runner-pkg; }; # with this, `nix develop` will start a terminal with all dependencies in PATH devShells = { default = with pkgs; mkShell { buildInputs = [ rust-bin.stable.latest.default libiconv wabt nixpkgs-fmt ]; shellHook = '' export DEBUG=1 ''; }; }; # By defining this, user could spin up runner via: `nix run github:grafana/grafana-do` without even cloning the repo apps = rec { gdo-runner = { type = "app"; program = "${packages.default}/bin/gdo-runner"; }; default = gdo-runner; }; # `nix flake check` will check strict lint rules for the whole project checks = { inherit gdo-runner-pkg gdo-runner-clippy; }; }); }