karnaugh/flake.nix
2026-07-19 21:12:17 +02:00

98 lines
2.4 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
helix.url = "github:helix-editor/helix";
};
outputs =
{
self,
nixpkgs,
flake-utils,
helix,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
in
rec {
packages.syntax =
let
grammars = pkgs.callPackage "${helix}/grammars.nix" { };
in
pkgs.stdenv.mkDerivation {
name = "syntax";
phases = [
"buildPhase"
"installPhase"
];
buildPhase = ''
cp -r ${helix}/runtime/queries/* ./
chmod u+w ./* -R
for so in ${grammars}/*.so; do
name=$(basename "$so" .so)
if [ -d "./$name" ]; then
cp "$so" "./$name/$name.so"
fi
done
'';
installPhase = ''
mkdir -p $out
cp -r ./* $out/
'';
};
packages.themes = pkgs.stdenv.mkDerivation {
name = "themes";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out
cp ${helix}/runtime/themes/*.toml $out/
'';
};
packages.karnaugh = pkgs.rustPlatform.buildRustPackage (final: {
pname = "karnaugh";
version = "0.1.5";
src = self;
cargoLock.lockFile = ./Cargo.lock;
});
packages.container = pkgs.dockerTools.buildImage {
name = "karnaugh";
tag = packages.karnaugh.version;
copyToRoot = pkgs.buildEnv {
name = "karnaugh-root";
paths = [ packages.karnaugh ];
pathsToLink = [ "/bin" ];
};
config = {
Entrypoint = [
"/bin/karnaugh"
"--syntax-root"
"${packages.syntax}"
"--themes-root"
"${packages.themes}"
];
};
};
packages.default = packages.karnaugh;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
cargo
rustc
rustfmt
clippy
cargo-edit
cargo-audit
];
};
}
);
}