Skip to content

Commit

Permalink
Add nix build for reference
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcyrd committed Oct 14, 2023
1 parent b0dbacc commit a109177
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: NixOS/nix

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 9 * * 1'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix build .
- run: ls -lah result/bin/
- run: sha256sum result/bin/repro-env
- run: result/bin/repro-env --help
- run: ldd result/bin/repro-env
147 changes: 147 additions & 0 deletions flake.lock

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

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
inputs = {
fenix.url = "github:nix-community/fenix";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};

outputs = { self, fenix, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = (import nixpkgs) {
inherit system;
};

toolchain = with fenix.packages.${system};
combine [
stable.rustc
stable.cargo
targets.x86_64-unknown-linux-musl.stable.rust-std
];

naersk' = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};

in rec {
defaultPackage = naersk'.buildPackage {
src = ./.;
nativeBuildInputs = with pkgs; [ pkgsStatic.stdenv.cc ];
CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
};
}
);
}

0 comments on commit a109177

Please sign in to comment.