cli/flake.nix
Nebula 0cfb79da46
Migrate to CLI v3 (#304)
* delete everything

* migrate to v3

* basic logout command

* remove pre-release text

* additional error handling in rlwy domain

* fixed backwards logic on rlwy domain

* accept environment id in rlwy run

* default environment on rlwy link if there's only 1

* dont print plugins and services if there are none

* skip serializing nones

* remove entities file

* rename ServiceDomains

* link to project upon init

* remove description prompt

* fully remove description prompt

* remove dead code

* refactor some of the commands

* update repo target

* fix broken render_config

* cleanup unused vars

* remove muts

* bump cargo version to 3.0.0

* change repo on Cargo.toml

---------

Co-authored-by: Angelo <asara019@fiu.edu>
2023-03-03 21:44:32 -05:00

122 lines
3.3 KiB
Nix

{
description = "Interact with Railway via CLI";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/22.11";
rust-overlay.url = "github:oxalica/rust-overlay";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = { self, rust-overlay, nixpkgs, crane, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs {
inherit system overlays;
};
toolchain = pkgs.rust-bin.stable.latest.default;
inherit (pkgs) lib;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
src =
let
# Only keeps graphql files
markdownFilter = path: _type: builtins.match ".*graphql$" path != null;
markdownOrCargo = path: type:
(markdownFilter path type) || (craneLib.filterCargoSources path type);
in
lib.cleanSourceWith {
src = ./.;
filter = markdownOrCargo;
};
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
pname = "railway";
buildInputs = [
# Add additional build inputs here
] ++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual crate itself, reusing the dependency
# artifacts from above.
railway = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
audit = craneLib.cargoAudit (commonArgs // {
inherit advisory-db;
});
fmt = craneLib.cargoFmt (commonArgs // { });
test = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
});
in
{
checks = { };
packages = {
default = railway;
inherit clippy audit fmt test;
};
apps = {
default = flake-utils.lib.mkApp {
drv = railway;
};
clippy = flake-utils.lib.mkApp {
drv = clippy;
};
audit = flake-utils.lib.mkApp {
drv = audit;
};
fmt = flake-utils.lib.mkApp {
drv = fmt;
};
test = flake-utils.lib.mkApp {
drv = test;
};
};
devShells.default =
import ./shell.nix {
inherit pkgs;
};
});
}