mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
nix ci
This commit is contained in:
parent
d4ac27389e
commit
2f4766ad8a
6 changed files with 231 additions and 117 deletions
107
.github/workflows/ci.yaml
vendored
107
.github/workflows/ci.yaml
vendored
|
|
@ -1,60 +1,73 @@
|
||||||
on: [push, pull_request]
|
name: "Build"
|
||||||
|
on:
|
||||||
name: CI
|
pull_request:
|
||||||
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Check
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: cachix/install-nix-action@v20
|
||||||
|
- uses: icewind1991/attic-action@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
name: ci
|
||||||
toolchain: stable
|
instance: https://cache.icewind.me
|
||||||
override: true
|
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||||
- uses: Swatinem/rust-cache@v1
|
- run: nix build .#check
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: check
|
|
||||||
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: check
|
||||||
steps:
|
steps:
|
||||||
- name: musl-tools
|
- uses: actions/checkout@v3
|
||||||
run: |
|
- uses: cachix/install-nix-action@v20
|
||||||
sudo apt-get install musl-tools
|
- uses: icewind1991/attic-action@v1
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
name: ci
|
||||||
toolchain: stable
|
instance: https://cache.icewind.me
|
||||||
override: true
|
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||||
target: x86_64-unknown-linux-musl
|
- run: nix build .#clippy
|
||||||
- uses: Swatinem/rust-cache@v1
|
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: build
|
|
||||||
args: --release --target x86_64-unknown-linux-musl
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: haze
|
|
||||||
path: target/x86_64-unknown-linux-musl/release/haze
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Tests
|
runs-on: ubuntu-latest
|
||||||
runs-on: ubuntu-20.04
|
needs: check
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: cachix/install-nix-action@v20
|
||||||
|
- uses: icewind1991/attic-action@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
name: ci
|
||||||
toolchain: stable
|
instance: https://cache.icewind.me
|
||||||
override: true
|
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||||
- uses: Swatinem/rust-cache@v1
|
- run: nix build .#test
|
||||||
- uses: actions-rs/cargo@v1
|
|
||||||
|
matrix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: cachix/install-nix-action@v20
|
||||||
|
- id: set-matrix
|
||||||
|
run: echo "matrix={\"target\":$(nix eval --json ".#targets.x86_64-linux")}" | tee $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [check, matrix]
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: cachix/install-nix-action@v20
|
||||||
|
- uses: icewind1991/attic-action@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
name: ci
|
||||||
|
instance: https://cache.icewind.me
|
||||||
|
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||||
|
- run: nix build .#${{ matrix.target }}
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: haze-${{ matrix.target }}
|
||||||
|
path: result/bin/*
|
||||||
49
.github/workflows/release.yaml
vendored
49
.github/workflows/release.yaml
vendored
|
|
@ -5,37 +5,34 @@ on:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
matrix:
|
||||||
name: Build Static Linux Binaries
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- name: musl-tools
|
|
||||||
run: |
|
|
||||||
sudo apt-get install musl-tools
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: cachix/install-nix-action@v20
|
||||||
|
- id: set-matrix
|
||||||
|
run: echo "matrix=$(nix eval --json ".#releaseMatrix.x86_64-linux")" | tee $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: matrix
|
||||||
|
strategy:
|
||||||
|
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: cachix/install-nix-action@v20
|
||||||
|
- uses: icewind1991/attic-action@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
name: ci
|
||||||
target: x86_64-unknown-linux-musl
|
instance: https://cache.icewind.me
|
||||||
- uses: Swatinem/rust-cache@v1
|
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||||
- uses: actions-rs/cargo@v1
|
- run: nix build .#${{ matrix.target }}
|
||||||
with:
|
- name: Upload binary to release
|
||||||
command: build
|
|
||||||
args: --release --all --target x86_64-unknown-linux-musl
|
|
||||||
- name: Upload binary
|
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: target/x86_64-unknown-linux-musl/release/haze
|
file: result/bin/${{ matrix.artifact_name }}
|
||||||
asset_name: haze
|
asset_name: ${{ matrix.asset_name }}
|
||||||
tag: ${{ github.ref }}
|
|
||||||
- name: Create archive
|
|
||||||
run: tar -czvf haze.tgz -C target/x86_64-unknown-linux-musl/release haze
|
|
||||||
- name: Upload archive
|
|
||||||
uses: svenstaro/upload-release-action@v2
|
|
||||||
with:
|
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
file: haze.tgz
|
|
||||||
asset_name: haze.tgz
|
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
111
flake.lock
generated
111
flake.lock
generated
|
|
@ -1,12 +1,38 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"cross-naersk": {
|
||||||
|
"inputs": {
|
||||||
|
"naersk": [
|
||||||
|
"naersk"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1667395993,
|
"lastModified": 1686502198,
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
"narHash": "sha256-Ti8l6OOa/vpawiCJqiidE3vfsvVDfTQW4ls2PMSfoJE=",
|
||||||
|
"owner": "icewind1991",
|
||||||
|
"repo": "cross-naersk",
|
||||||
|
"rev": "2c2b9aae13700e4c3593aeef609dddb788fe5ae0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "icewind1991",
|
||||||
|
"repo": "cross-naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1685518550,
|
||||||
|
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -17,14 +43,16 @@
|
||||||
},
|
},
|
||||||
"naersk": {
|
"naersk": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1671096816,
|
"lastModified": 1686572087,
|
||||||
"narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=",
|
"narHash": "sha256-jXTut7ZSYqLEgm/nTk7TuVL2ExahTip605bLINklAnQ=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "naersk",
|
"repo": "naersk",
|
||||||
"rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114",
|
"rev": "8507af04eb40c5520bd35d9ce6f9d2342cea5ad1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -35,35 +63,64 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1674407282,
|
"lastModified": 1686736559,
|
||||||
"narHash": "sha256-2qwc8mrPINSFdWffPK+ji6nQ9aGnnZyHSItVcYDZDlk=",
|
"narHash": "sha256-YyUSVoOKIDAscTx7IZhF9x3qgZ9dPNF19fKk+4c5irc=",
|
||||||
"path": "/nix/store/47v7isgz6w8zgb1224d46lwvwkdd69bm-source",
|
"owner": "NixOS",
|
||||||
"rev": "ab1254087f4cdf4af74b552d7fc95175d9bdbb49",
|
"repo": "nixpkgs",
|
||||||
"type": "path"
|
"rev": "ddf4688dc7aeb14e8a3c549cb6aa6337f187a884",
|
||||||
},
|
"type": "github"
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1674407282,
|
|
||||||
"narHash": "sha256-2qwc8mrPINSFdWffPK+ji6nQ9aGnnZyHSItVcYDZDlk=",
|
|
||||||
"path": "/nix/store/47v7isgz6w8zgb1224d46lwvwkdd69bm-source",
|
|
||||||
"rev": "ab1254087f4cdf4af74b552d7fc95175d9bdbb49",
|
|
||||||
"type": "path"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-23.05",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"cross-naersk": "cross-naersk",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"naersk": "naersk",
|
"naersk": "naersk",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": [
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1686795910,
|
||||||
|
"narHash": "sha256-jDa40qRZ0GRQtP9EMZdf+uCbvzuLnJglTUI2JoHfWDc=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "5c2b97c0a9bc5217fc3dfb1555aae0fb756d99f9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
72
flake.nix
72
flake.nix
|
|
@ -1,28 +1,80 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-23.05";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
naersk.url = "github:nix-community/naersk";
|
naersk.url = "github:nix-community/naersk";
|
||||||
|
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
||||||
|
cross-naersk.url = "github:icewind1991/cross-naersk";
|
||||||
|
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
cross-naersk.inputs.naersk.follows = "naersk";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, naersk }:
|
outputs = { self, nixpkgs, flake-utils, naersk, rust-overlay, cross-naersk }:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
flake-utils.lib.eachDefaultSystem (
|
||||||
system: let
|
system: let
|
||||||
pkgs = nixpkgs.legacyPackages."${system}";
|
overlays = [ (import rust-overlay) ];
|
||||||
naersk-lib = naersk.lib."${system}";
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
};
|
||||||
|
lib = pkgs.lib;
|
||||||
|
|
||||||
|
hostTarget = pkgs.hostPlatform.config;
|
||||||
|
targets = [
|
||||||
|
hostTarget
|
||||||
|
"x86_64-unknown-linux-musl"
|
||||||
|
];
|
||||||
|
releaseTargets = lib.lists.remove hostTarget targets;
|
||||||
|
|
||||||
|
execSufficForTarget = target: if lib.strings.hasInfix "windows" target then ".exe" else "";
|
||||||
|
artifactForTarget = target: "palantir${execSufficForTarget target}";
|
||||||
|
assetNameForTarget = target: "palantir-${builtins.replaceStrings ["-unknown" "-gnu" "-musl" "abihf" "-pc"] ["" "" "" "" ""] target}${execSufficForTarget target}";
|
||||||
|
|
||||||
|
toolchain = (pkgs.rust-bin.stable.latest.default.override { inherit targets; });
|
||||||
|
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
|
||||||
|
|
||||||
|
src = lib.sources.sourceByRegex (lib.cleanSource ./.) ["Cargo.*" "(src)(/.*)?"];
|
||||||
|
|
||||||
|
nearskOpt = {
|
||||||
|
pname = "haze";
|
||||||
|
root = src;
|
||||||
|
};
|
||||||
|
buildTarget = target: (cross-naersk' target).buildPackage nearskOpt;
|
||||||
|
hostNaersk = (cross-naersk' hostTarget);
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
# `nix build`
|
# `nix build`
|
||||||
packages.haze = naersk-lib.buildPackage {
|
packages = lib.attrsets.genAttrs targets buildTarget // rec {
|
||||||
pname = "haze";
|
haze = packages.${hostTarget};
|
||||||
root = ./.;
|
check = hostNaersk.buildPackage (nearskOpt // {
|
||||||
|
mode = "check";
|
||||||
|
});
|
||||||
|
test = hostNaersk.buildPackage (nearskOpt // {
|
||||||
|
mode = "test";
|
||||||
|
});
|
||||||
|
clippy = hostNaersk.buildPackage (nearskOpt // {
|
||||||
|
mode = "clippy";
|
||||||
|
});
|
||||||
|
default = haze;
|
||||||
};
|
};
|
||||||
defaultPackage = packages.haze;
|
|
||||||
defaultApp = packages.haze;
|
|
||||||
|
|
||||||
# `nix develop`
|
inherit targets;
|
||||||
devShell = pkgs.mkShell {
|
releaseMatrix = {
|
||||||
|
include = builtins.map (target: {
|
||||||
|
inherit target;
|
||||||
|
artifact_name = artifactForTarget target;
|
||||||
|
asset_name = assetNameForTarget target;
|
||||||
|
}) releaseTargets;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells = {
|
||||||
|
default = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [ rustc cargo bacon cargo-edit cargo-outdated clippy ];
|
nativeBuildInputs = with pkgs; [ rustc cargo bacon cargo-edit cargo-outdated clippy ];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
) // {
|
) // {
|
||||||
homeManagerModule = {
|
homeManagerModule = {
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,10 @@ impl DatabaseFamily {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq, Default)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub enum Database {
|
pub enum Database {
|
||||||
|
#[default]
|
||||||
Sqlite,
|
Sqlite,
|
||||||
Mysql,
|
Mysql,
|
||||||
Mysql80,
|
Mysql80,
|
||||||
|
|
@ -56,12 +57,6 @@ pub enum Database {
|
||||||
Oracle,
|
Oracle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Database {
|
|
||||||
fn default() -> Self {
|
|
||||||
Database::Sqlite
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Database {
|
impl FromStr for Database {
|
||||||
type Err = Report;
|
type Err = Report;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,8 @@ async fn serve(instances: ActiveInstances, listen: String, base_address: String)
|
||||||
let listen: PathBuf = listen.into();
|
let listen: PathBuf = listen.into();
|
||||||
if let Some(parent) = listen.parent() {
|
if let Some(parent) = listen.parent() {
|
||||||
if !parent.exists() {
|
if !parent.exists() {
|
||||||
create_dir_all(&parent).into_diagnostic()?;
|
create_dir_all(parent).into_diagnostic()?;
|
||||||
set_permissions(&parent, PermissionsExt::from_mode(0o755)).into_diagnostic()?;
|
set_permissions(parent, PermissionsExt::from_mode(0o755)).into_diagnostic()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remove_file(&listen).ok();
|
remove_file(&listen).ok();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue