Skip to content
Open
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
34 changes: 34 additions & 0 deletions flake.lock

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

281 changes: 145 additions & 136 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,166 +11,175 @@
home-manager.url = "github:nix-community/home-manager";
treefmt-nix.url = "github:numtide/treefmt-nix/";
crane.url = "github:ipetkov/crane";
flake-parts.url = "github:hercules-ci/flake-parts";
};

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

devInputs = with pkgs; [
rustc
rustfmt
cargo
clippy
];
systems = [ "x86_64-linux" "aarch64-linux" ];
in
(flake-parts.lib.mkFlake { inherit inputs; } {
inherit systems;
perSystem = { pkgs, system, ... } :
let
devInputs = with pkgs; [
rustc
rustfmt
cargo
clippy
];

nativeBuildInputs = with pkgs; [
makeWrapper
# wifi plugin
# cargo networkmanager dependency
pkgconf
dbus
];
nativeBuildInputs = with pkgs; [
makeWrapper
# wifi plugin
# cargo networkmanager dependency
pkgconf
dbus
];

buildInputs = with pkgs; [ dbus ];
buildInputs = with pkgs; [ dbus ];

cargoTOML = builtins.fromTOML (builtins.readFile (./. + "/Cargo.toml"));
cargoTOML = builtins.fromTOML (builtins.readFile (./. + "/Cargo.toml"));

inherit (cargoTOML.workspace.package) version;
pname = "centerpiece";
inherit (cargoTOML.workspace.package) version;
pname = "centerpiece";

craneLib = crane.mkLib nixpkgs.legacyPackages.${system};
fontFilter = path: _type: builtins.match ".*ttf$" path != null;
configFilter = path: _type: builtins.match ".*config.yml$" path != null;
assetOrCargo =
path: type:
(configFilter path type) || (fontFilter path type) || (craneLib.filterCargoSources path type);
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = assetOrCargo;
};
inherit
pname
version
buildInputs
nativeBuildInputs
;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
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.";
treefmt = (treefmt-nix.lib.evalModule pkgs ./formatter.nix).config.build;
libPath = pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
pkgs.vulkan-loader
pkgs.libGL
];
craneLib = crane.mkLib nixpkgs.legacyPackages.${system};
fontFilter = path: _type: builtins.match ".*ttf$" path != null;
configFilter = path: _type: builtins.match ".*config.yml$" path != null;
assetOrCargo =
path: type:
(configFilter path type) || (fontFilter path type) || (craneLib.filterCargoSources path type);
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = assetOrCargo;
};
inherit
pname
version
buildInputs
nativeBuildInputs
;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
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.";
treefmt = (treefmt-nix.lib.evalModule pkgs ./formatter.nix).config.build;
libPath = pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
pkgs.vulkan-loader
pkgs.libGL
];

in
{
devShells.${system}.default = pkgs.mkShell {
inherit
nativeBuildInputs
buildInputs
GIT_DATE
GIT_REV
;
packages = devInputs ++ [ treefmt.wrapper ];
LD_LIBRARY_PATH = libPath;
};
packages.${system} = {
default = craneLib.buildPackage (
commonArgs
// {
in
{
devShells.default = pkgs.mkShell {
inherit
cargoArtifacts
nativeBuildInputs
buildInputs
pname
GIT_REV
GIT_DATE
GIT_REV
;
postFixup = pkgs.lib.optional pkgs.stdenv.isLinux ''
rpath=$(patchelf --print-rpath $out/bin/${pname})
patchelf --set-rpath "$rpath:${libPath}" $out/bin/${pname}
'';
packages = devInputs ++ [ treefmt.wrapper ];
LD_LIBRARY_PATH = libPath;
};
packages = {
default = craneLib.buildPackage (
commonArgs
// {
inherit
cargoArtifacts
nativeBuildInputs
buildInputs
pname
GIT_REV
GIT_DATE
;
postFixup = pkgs.lib.optional pkgs.stdenv.isLinux ''
rpath=$(patchelf --print-rpath $out/bin/${pname})
patchelf --set-rpath "$rpath:${libPath}" $out/bin/${pname}
'';

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;
shell = self.outputs.devShells.${system}.default;
treefmt = treefmt.check self;
inherit cargoClippy;
hmModule =
(nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
{
home-manager.users.alice = {
imports = [ self.outputs.hmModules."x86_64-linux".default ];
programs.centerpiece = {
enable = true;
config.plugin.git_repositories.commands = [ [ "alacritty" ] ];
services.index-git-repositories = {
enable = true;
interval = "3hours";
};
};
home.stateVersion = "23.11";
};
users.users.alice = {
isNormalUser = true;
uid = 1000;
home = "/home/alice";
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" ];
};
}
];
}).config.system.build.vm;
};
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;
);
index-git-repositories = craneLib.buildPackage (
commonArgs
// rec {
inherit cargoArtifacts;
pname = "index-git-repositories";
cargoExtraArgs = "-p ${pname}";
meta.mainProgram = pname;
}
);
};
checks = {
inherit (self.outputs.packages.${system}) default index-git-repositories;
shell = self.outputs.devShells.${system}.default;
treefmt = treefmt.check self;
inherit cargoClippy;
hmModule =
(nixpkgs.lib.nixosSystem {
inherit system;
modules = [
home-manager.nixosModules.home-manager
{
home-manager.users.alice = {
imports = [ self.outputs.hmModules.${system}.default ];
programs.centerpiece = {
enable = true;
config.plugin.git_repositories.commands = [ [ "alacritty" ] ];
services.index-git-repositories = {
enable = true;
interval = "3hours";
};
};
home.stateVersion = "23.11";
};
users.users.alice = {
isNormalUser = true;
uid = 1000;
home = "/home/alice";
};
}
];
}).config.system.build.vm;
};
formatter = treefmt.wrapper;
};
}) // {
hmModules = (nixpkgs.lib.attrsets.genAttrs systems (system: {
default = import ./home-manager-module.nix {
centerpiece = self.outputs.packages.${system}.default;
inherit (self.outputs.packages.${system}) index-git-repositories;
};
}));
};
}