Skip to content

Commit

Permalink
ci: v0.1.0 Release
Browse files Browse the repository at this point in the history
- expose the builder as a nix function
- `smb` is now disabled by default
  • Loading branch information
fusetim committed Aug 17, 2023
1 parent 9ef6273 commit 8fb3083
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 84 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## Version 0.1.0 - Initial version
Release date: 2023-08-17
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ oo7 = { version = "0.2.1", features = ["tokio", "native_crypto"], default_featur
rand = { version = "0.8.5", optional = true }

[features]
default = ["ftp", "smb", "secrets"]
default = ["ftp", "secrets"]
ftp = ["dep:remotefs-ftp"]
smb = ["dep:remotefs-smb"]
secrets = ["dep:oo7", "dep:rand"]
153 changes: 71 additions & 82 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,20 @@
outputs = { self, nixpkgs, crane, fenix, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
features = [ "smb" "ftp" "secrets" ];
features = [ "ftp" "secrets" ];
toolchain = (fenix.packages.${system}.toolchainOf {
channel = "1.71.0";
sha256 = "sha256-ks0nMEGGXKrHnfv4Fku+vhQ7gx76ruv6Ij4fKZR3l78=";
});
in
let
inherit toolchain features system;
pkgs = import nixpkgs {
inherit system;
};

inherit (pkgs) lib;
inherit toolchain;
inherit features;

craneLib = crane.lib.${system};
src = craneLib.cleanCargoSource (craneLib.path ./.);

# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;

nativeBuildInputs = [pkgs.pkg-config];

buildInputs = [
(toolchain.withComponents [
getBuildInputs = {pkgs, toolchain, features}: [
(toolchain.withComponents [
"cargo"
"rustc"
])
Expand All @@ -62,112 +50,108 @@
pkgs.llvmPackages_latest.libclang
pkgs.rustPlatform.bindgenHook
pkgs.openssl
] ++ lib.optionals (builtins.elem "secrets" features) [
] ++ pkgs.lib.optionals (builtins.elem "secrets" features) [
pkgs.dbus.lib
] ++ lib.optionals (builtins.elem "smb" features) [
] ++ pkgs.lib.optionals (builtins.elem "smb" features) [
pkgs.samba
pkgs.samba.dev
] ++ lib.optionals pkgs.stdenv.isDarwin [
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];

};

craneLibLLvmTools = craneLib.overrideToolchain (toolchain.withComponents [
"cargo"
"llvm-tools"
"rustc"
]);
hostBuild = {pkgs, system, features, toolchain, ...}: rec {
inherit (pkgs) lib;

# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
craneLib = crane.lib.${system};
src = craneLib.cleanCargoSource (craneLib.path ./.);

commonArgs = {
inherit src;
nativeBuildInputs = [pkgs.pkg-config];
buildInputs = (getBuildInputs { inherit pkgs toolchain features; });
};

# Build the actual crate itself, reusing the dependency
# artifacts from above.
my-crate = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
craneLibLLvmTools = craneLib.overrideToolchain (toolchain.withComponents [
"cargo"
"llvm-tools"
"rustc"
]);

nativeBuildInputs = [ pkgs.pkg-config ];
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;

buildInputs = commonArgs.buildInputs ++ [];
# Build the actual crate itself, reusing the dependency
# artifacts from above.
mkube-bin = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;

cargoExtraArgs = "--no-default-features --features ${builtins.concatStringsSep "," features}";
nativeBuildInputs = [ pkgs.pkg-config ];

meta = with lib; {
description = "Minimalist Media Manager (M³) - Rust minimalist TUI to manage your remote mediacenter.";
longDescription = ''
Minimalist Media Manager (M³) - Rust minimalist TUI to manage your remote mediacenter.
'';
homepage = "https://github.com/fusetim/mkube/";
license = licenses.eupl12;
};
});
in
{
checks = {
# Build the crate as part of `nix flake check` for convenience
inherit my-crate;

# Run clippy (and deny all warnings) on the crate source,
# again, resuing the dependency artifacts from above.
#
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
my-crate-clippy = craneLib.cargoClippy (commonArgs // {
buildInputs = commonArgs.buildInputs ++ [];

cargoExtraArgs = "--no-default-features --features ${builtins.concatStringsSep "," features}";

meta = with lib; {
description = "Minimalist Media Manager (M³) - Rust minimalist TUI to manage your remote mediacenter.";
longDescription = ''
Minimalist Media Manager (M³) - Rust minimalist TUI to manage your remote mediacenter.
'';
homepage = "https://github.com/fusetim/mkube/";
license = licenses.eupl12;
};
});

# Run Clippy on mkube
mkube-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});

my-crate-doc = craneLib.cargoDoc (commonArgs // {
# Doc generation
mkube-doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
});

# Check formatting
my-crate-fmt = craneLib.cargoFmt {
mkube-fmt = craneLib.cargoFmt {
inherit src;
};

# Audit dependencies
my-crate-audit = craneLib.cargoAudit {
mkube-audit = craneLib.cargoAudit {
inherit src advisory-db;
};

# Run tests with cargo-nextest
# Consider setting `doCheck = false` on `my-crate` if you do not want
# the tests to run twice
my-crate-nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
});
} // lib.optionalAttrs (system == "x86_64-linux") {
# NB: cargo-tarpaulin only supports x86_64 systems
# Check code coverage (note: this will not upload coverage anywhere)
my-crate-coverage = craneLib.cargoTarpaulin (commonArgs // {
# LLVM coverage
mkube-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // {
inherit cargoArtifacts;
});
};
in {
checks = {
# Build the crate as part of `nix flake check` for convenience
inherit (hostBuild { inherit pkgs system features toolchain; }) mkube-bin mkube-clippy mkube-doc mkube-fmt mkube-audit;
};

packages = {
default = my-crate;
my-crate-llvm-coverage = craneLibLLvmTools.cargoLlvmCov (commonArgs // {
inherit cargoArtifacts;
});
default = (hostBuild { inherit pkgs system features toolchain; }).mkube-bin;
mkube-llvm-coverage = (hostBuild { inherit pkgs system features toolchain; }).mkube-llvm-coverage;
};

apps.default = flake-utils.lib.mkApp {
drv = my-crate;
drv = (hostBuild { inherit pkgs system features toolchain; }).mkube-bin;
};

lib = {
mkube-hostBuild = hostBuild;
};

devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks.${system};

# Additional dev-shell environment variables can be set directly
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";

# Extra inputs can be added here
nativeBuildInputs = with pkgs; [
(toolchain.withComponents [
Expand All @@ -177,7 +161,10 @@
pkg-config
];

buildInputs = commonArgs.buildInputs ++ [ ];
buildInputs = (getBuildInputs {
inherit pkgs toolchain;
features = [ "smb" "ftp" "secrets" ];
});

LIBCLANG_PATH = "${pkgs.llvmPackages_latest.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS =
Expand All @@ -196,5 +183,7 @@
''-I${pkgs.glib.out}/lib/glib-2.0/include/''
];
};
});
}
);
}

3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ I am unsure if Windows will get supported one day, even partially.
MKube currently requires the following dependencies (but it might not be limited to these):
- ffmpeg(-dev)
- openssl
- libsmbclient (`smb` feature, *enabled by default*)
- libdbus (`secrets` feature, *enabled by default*)
- libsmbclient (`smb` feature, *disabled by default*)

Then, just build it: `cargo build --release`

Expand Down

0 comments on commit 8fb3083

Please sign in to comment.