-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Refactor Flake, add legacy Nix support and CI
Signed-off-by: Dom Rodriguez <[email protected]>
- Loading branch information
Showing
7 changed files
with
125 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
name: CI tests (Nix) | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
run-tests: | ||
name: Nix CI tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v25 | ||
- name: Build Nix package | ||
run: nix build | ||
- name: Check Flake formatting | ||
run: nix run nixpkgs#nixpkgs-fmt -- --check ./ | ||
- name: Check Flake with Nix | ||
run: nix flake check | ||
- name: Check Flake with Statix | ||
run: nix run nixpkgs#statix -- check ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ lib | ||
, pkgs ? import <nixpkgs> | ||
, rustPlatform | ||
, | ||
}: | ||
rustPlatform.buildRustPackage { | ||
name = "codid"; | ||
|
||
src = lib.cleanSource ./.; | ||
|
||
cargoLock = { | ||
lockFile = ./Cargo.lock; | ||
allowBuiltinFetchGit = true; | ||
}; | ||
|
||
nativeBuildInputs = with pkgs; [ pkg-config ]; | ||
buildInputs = with pkgs; [ systemd.dev ]; | ||
|
||
meta = with lib; { | ||
description = ""; | ||
homepage = "https://github.com/Cosmo-CoDiOS/codid"; | ||
license = licenses.mit; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,40 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
naersk.url = "github:nix-community/naersk"; | ||
|
||
nixpkgs-mozilla = { | ||
url = "github:mozilla/nixpkgs-mozilla"; | ||
flake-compat = { | ||
url = "github:edolstra/flake-compat"; | ||
flake = false; | ||
}; | ||
}; | ||
|
||
outputs = { self, flake-utils, naersk, nixpkgs, nixpkgs-mozilla }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
outputs = | ||
{ self | ||
, nixpkgs | ||
, flake-utils | ||
, ... | ||
}: | ||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = (import nixpkgs) { | ||
inherit system; | ||
|
||
overlays = [ | ||
(import nixpkgs-mozilla) | ||
]; | ||
}; | ||
|
||
toolchain = (pkgs.rustChannelOf { | ||
rustToolchain = ./rust-toolchain; | ||
sha256 = "sha256-e4mlaJehWBymYxJGgnbuCObVlqMlQSilZ8FljG9zPHY="; | ||
}).rust; | ||
|
||
naersk' = pkgs.callPackage naersk { | ||
cargo = toolchain; | ||
rustc = toolchain; | ||
}; | ||
|
||
pkgs = nixpkgs.outputs.legacyPackages.${system}; | ||
in | ||
{ | ||
# For `nix build` & `nix run`: | ||
packages.codid = naersk'.buildPackage { | ||
src = ./.; | ||
nativeBuildInputs = with pkgs; [ pkg-config cmake ]; | ||
buildInputs = with pkgs; [ systemd.dev dbus.dev protobuf protobufc ]; | ||
}; | ||
|
||
packages.codid = pkgs.callPackage ./codid.nix { }; | ||
packages.default = self.outputs.packages.${system}.codid; | ||
|
||
# For `nix develop` (optional, can be skipped): | ||
devShells.default = pkgs.mkShell { | ||
nativeBuildInputs = [ toolchain ] ++ (with pkgs; [ rustc cargo pkg-config cmake ]); | ||
buildInputs = with pkgs; [ systemd.dev dbus.dev protobuf protobufc ]; | ||
}; | ||
}) // { | ||
overlays.default = final: prev: { | ||
inherit (self.packages.${final.system}) codid; | ||
}; | ||
devShells.default = self.packages.${system}.default.overrideAttrs (super: { | ||
nativeBuildInputs = with pkgs; | ||
super.nativeBuildInputs | ||
++ [ | ||
clippy | ||
rustfmt | ||
]; | ||
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; | ||
}); | ||
}) | ||
// { | ||
overlays.default = final: prev: { | ||
inherit (self.packages.${final.system}) codid; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).shellNix |