Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ add treefmt as module, devShell, check, ci integration #66

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
[workspace]
resolver = "2"

default-members = [
"client",
]
default-members = ["client"]

members = [
"client",
"services/index-git-repositories",
]
members = ["client", "services/index-git-repositories"]

[workspace.package]
version = "0.8.0"
9 changes: 7 additions & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ edition = "2021"
[dependencies]
# general
anyhow = { version = "1.0.78", features = ["backtrace"] }
clap = { version = "4.4.16", features = ["derive",] }
clap = { version = "4.4.16", features = ["derive"] }
log = { version = "0.4.20", features = ["kv_unstable_serde"] }
simple_logger = { version = "4.3.3", features = ["colors", "threads", "timestamps", "stderr"] }
simple_logger = { version = "4.3.3", features = [
"colors",
"threads",
"timestamps",
"stderr",
] }

# application window
iced = { version = "0.10.0", features = ["svg"] }
Expand Down
37 changes: 36 additions & 1 deletion flake.lock

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

121 changes: 47 additions & 74 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,19 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager";
treefmt-nix.url = "github:numtide/treefmt-nix/";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
{
self,
nixpkgs,
crane,
home-manager,
}:
outputs = { self, nixpkgs, crane, treefmt-nix, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };

devInputs = with pkgs; [
rustc
rustfmt
cargo
];
devInputs = with pkgs; [ rustc rustfmt cargo ];

nativeBuildInputs = with pkgs; [
makeWrapper
Expand All @@ -44,38 +35,29 @@

craneLib = crane.lib.${system};
assetFilter = path: _type: builtins.match ".*ttf$" path != null;
assetOrCargo =
path: type: (assetFilter path type) || (craneLib.filterCargoSources path type);
assetOrCargo = path: type:
(assetFilter path type) || (craneLib.filterCargoSources path type);
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = assetOrCargo;
};
inherit
pname
version
buildInputs
nativeBuildInputs
;
inherit pname version buildInputs nativeBuildInputs;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
cargoClippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features";
}
);
cargoClippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features";
});
GIT_DATE = "${builtins.substring 0 4 self.lastModifiedDate}-${
builtins.substring 4 2 self.lastModifiedDate
}-${builtins.substring 6 2 self.lastModifiedDate}";
GIT_REV = self.shortRev or "Not committed yet.";
in
{
treefmt = (treefmt-nix.lib.evalModule pkgs ./formatter.nix).config.build;
in {
devShells.${system}.default = pkgs.mkShell {
inherit nativeBuildInputs buildInputs
GIT_DATE GIT_REV;
packages = devInputs;
inherit nativeBuildInputs buildInputs GIT_DATE GIT_REV;
packages = devInputs ++ [ treefmt.wrapper ];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
Expand All @@ -84,56 +66,47 @@
];
};
packages.${system} = {
default = craneLib.buildPackage (
commonArgs
// {
inherit
cargoArtifacts
nativeBuildInputs
buildInputs
pname
GIT_REV
GIT_DATE
;
postInstall = ''
wrapProgram "$out/bin/${pname}" \
--prefix LD_LIBRARY_PATH : ${
pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
pkgs.vulkan-loader
pkgs.libGL
]
}
'';
meta = with pkgs.lib; {
description = "Your trusty omnibox search.";
homepage = "https://github.com/friedow/centerpiece";
platforms = platforms.linux;
license = licenses.mit;
mainProgram = pname;
maintainers = [ "friedow" ];
};
}
);
index-git-repositories = craneLib.buildPackage (
commonArgs
// rec {
inherit cargoArtifacts;
pname = "index-git-repositories";
cargoExtraArgs = "-p ${pname}";
meta.mainProgram = pname;
}
);
default = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts nativeBuildInputs buildInputs pname GIT_REV
GIT_DATE;
postInstall = ''
wrapProgram "$out/bin/${pname}" \
--prefix LD_LIBRARY_PATH : ${
pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
pkgs.vulkan-loader
pkgs.libGL
]
}
'';
meta = with pkgs.lib; {
description = "Your trusty omnibox search.";
homepage = "https://github.com/friedow/centerpiece";
platforms = platforms.linux;
license = licenses.mit;
mainProgram = pname;
maintainers = [ "friedow" ];
};
});
index-git-repositories = craneLib.buildPackage (commonArgs // rec {
inherit cargoArtifacts;
pname = "index-git-repositories";
cargoExtraArgs = "-p ${pname}";
meta.mainProgram = pname;
});
};
checks.${system} = {
inherit (self.outputs.packages.${system}) default index-git-repositories;
inherit (self.outputs.packages.${system})
default index-git-repositories;
shell = self.outputs.devShells.${system}.default;
treefmt = treefmt.check self;
inherit cargoClippy;
};
hmModules.${system}.default = import ./home-manager-module.nix {
centerpiece = self.outputs.packages.${system}.default;
inherit (self.outputs.packages.${system}) index-git-repositories;
};
formatter.${system} = treefmt.wrapper;
};
}
12 changes: 12 additions & 0 deletions formatter.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
_: {
projectRootFile = "flake.nix";

programs = {
deadnix.enable = true;
nixfmt.enable = true;
rustfmt.enable = true;
statix.enable = true;
taplo.enable = true;
yamlfmt.enable = true;
};
}
7 changes: 6 additions & 1 deletion services/index-git-repositories/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ edition = "2021"

[dependencies]
log = { version = "0.4.20", features = ["kv_unstable_serde"] }
simple_logger = { version = "4.3.3", features = ["colors", "threads", "timestamps", "stderr"] }
simple_logger = { version = "4.3.3", features = [
"colors",
"threads",
"timestamps",
"stderr",
] }

serde_json = "1.0.113"
rust_search = "2.0.0"
Expand Down
Loading