Skip to content

Commit 50a34a4

Browse files
authored
use nix for Linux workflow (#69)
1 parent 7223d8f commit 50a34a4

File tree

7 files changed

+174
-73
lines changed

7 files changed

+174
-73
lines changed

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ insert_final_newline = true
88
[*.yml]
99
indent_style = space
1010
indent_size = 2
11+
12+
[*.nix]
13+
indent_style = space
14+
indent_size = 2

.github/workflows/docs.yml

-56
This file was deleted.

.github/workflows/linux.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Linux
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Cache Nix store
16+
uses: actions/cache@v3
17+
id: nix-cache
18+
with:
19+
path: /tmp/nix-cache
20+
key: nix-cache-${{ hashFiles('flake.nix') }}-${{ hashFiles('flake.lock') }}
21+
22+
- name: Install Nix
23+
uses: cachix/install-nix-action@v20
24+
with:
25+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: "Import Nix store"
28+
if: "steps.nix-cache.outputs.cache-hit == 'true'"
29+
run: "nix-store --import < /tmp/nix-cache"
30+
31+
- name: Build
32+
run: nix build --accept-flake-config
33+
34+
- name: "Export Nix store"
35+
if: "steps.nix-cache.outputs.cache-hit != 'true'"
36+
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nix-cache"
37+
38+
- name: Upload artifacts
39+
uses: actions/upload-artifact@v2
40+
with:
41+
path: |
42+
result/lib/libauxcov.so
43+
result/lib/libauxtest.so
44+
result/lib/libdebug_server.so

.github/workflows/rust.yml .github/workflows/windows.yml

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Rust
1+
name: Windows
22

33
on:
44
push:
@@ -15,12 +15,8 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [ubuntu-latest, windows-latest]
18+
os: [windows-latest]
1919
include:
20-
- os: ubuntu-latest
21-
TOOLCHAIN: stable-i686-unknown-linux-gnu
22-
TARGET: i686-unknown-linux-gnu
23-
2420
- os: windows-latest
2521
TOOLCHAIN: stable-i686-pc-windows-msvc
2622
TARGET: i686-pc-windows-msvc
@@ -39,17 +35,6 @@ jobs:
3935
restore-keys: |
4036
${{ runner.os }}-cargo-
4137
42-
- name: Install Ubuntu Deps
43-
if: matrix.os == 'ubuntu-latest'
44-
run: |
45-
sudo dpkg --add-architecture i386
46-
sudo apt-get update
47-
sudo apt install libc6-i386
48-
sudo apt install libstdc++6:i386
49-
sudo apt install build-essential g++-multilib
50-
sudo apt install libssl-dev:i386
51-
sudo apt install zlib1g-dev:i386
52-
5338
- uses: actions-rs/toolchain@v1
5439
with:
5540
profile: minimal

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
/result
23
/.vscode
34
*.o
45
*.dmb

flake.lock

+87
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
nixConfig.extra-substituters = [
3+
"https://nix-community.cachix.org"
4+
];
5+
6+
nixConfig.extra-trusted-public-keys = [
7+
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
8+
];
9+
10+
inputs = {
11+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
12+
fenix.url = "github:nix-community/fenix";
13+
fenix.inputs.nixpkgs.follows = "nixpkgs";
14+
naersk.url = "github:nix-community/naersk";
15+
naersk.inputs.nixpkgs.follows = "nixpkgs";
16+
};
17+
18+
outputs = { self, nixpkgs, fenix, naersk }:
19+
let
20+
toolchain = fenix.packages.i686-linux.stable.toolchain;
21+
pkgs = nixpkgs.legacyPackages.x86_64-linux.pkgsi686Linux;
22+
in
23+
{
24+
packages.x86_64-linux.default = (naersk.lib.x86_64-linux.override {
25+
cargo = toolchain;
26+
rustc = toolchain;
27+
}).buildPackage {
28+
src = ./.;
29+
doCheck = true;
30+
copyLibs = true;
31+
nativeBuildInputs = [ pkgs.stdenv.cc pkgs.openssl_1_1 pkgs.pkg-config ];
32+
CARGO_BUILD_TARGET = "i686-unknown-linux-gnu";
33+
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.stdenv.cc}/bin/${pkgs.stdenv.cc.targetPrefix}cc";
34+
};
35+
};
36+
}

0 commit comments

Comments
 (0)