Skip to content

Commit

Permalink
Improve Nix flake by adding checks, auto-updating version, and fixing…
Browse files Browse the repository at this point in the history
… build (railwayapp#843)

This will allow the flake to be built using Hydra.
  • Loading branch information
piperswe authored Mar 25, 2023
1 parent 7d57ea3 commit e5a1f08
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 91 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,22 @@ jobs:
with:
command: test
args: --package nixpacks --lib --test generate_plan_tests

flake:
name: Nix Flake
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '(cargo-release)')"
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout sources
uses: actions/checkout@v3

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Run nix flake check
run: nix flake check
67 changes: 8 additions & 59 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 21 additions & 32 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = inputs@{ self, utils, rust-overlay, ... }:
outputs = inputs@{ self, utils, ... }:
utils.lib.mkFlake rec {
inherit self inputs;

Expand All @@ -17,49 +16,39 @@
"x86_64-linux"
];

sharedOverlays = [ (import rust-overlay) ];

outputsBuilder = channels: with channels; {
packages = with nixpkgs; {
inherit (nixpkgs) package-from-overlays;

nixpacks = rustPlatform.buildRustPackage {
outputsBuilder = channels: with channels;
let
package = with nixpkgs; rustPlatform.buildRustPackage {
pname = "nixpacks";
version = "v0.3.0";
doCheck = true;
version = "1.5.1";
src = ./.;
checkInputs = [ rustfmt clippy ];
# skip `cargo test` due tests FHS dependency
checkPhase = ''
runHook preCheck
cargo check
rustfmt --check src/**/*.rs
cargo clippy
runHook postCheck
'';
cargoLock = {
lockFile = ./Cargo.lock;
};
# For tooling like rust-analyzer
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
doCheck = false;
meta = with nixpkgs.lib; {
description = "App source + Nix packages + Docker = Image";
homepage = "https://github.com/railwayapp/nixpacks";
license = licenses.mit;
maintainers = [ maintainers.zoedsoupe ];
};
};
};
in {
packages = {
nixpacks = package;
default = package;
};

devShell = nixpkgs.mkShell {
name = "nixpacks";
devShells = {
nixpacks = package;
default = package;
};

buildInputs = with nixpkgs; [
# rust overlay already comes with complete toolchains
# see more at https://github.com/oxalica/rust-overlay
rust-bin.stable.latest.complete docker
];
checks = {
nixpacks = package;
};
};
};
};
}
4 changes: 4 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Automatically update version in flake.nix on `cargo release`
pre-release-replacements = [
{ file="flake.nix", search="version = \".*\";", replace="version = \"{{version}}\";" },
]

0 comments on commit e5a1f08

Please sign in to comment.