{ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; helix.url = "github:helix-editor/helix"; helix.inputs.nixpkgs.follows = "nixpkgs"; }; 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"; nativeBuildInputs = [ pkgs.patchelf ]; phases = [ "buildPhase" "installPhase" ]; buildPhase = '' mkdir -p build cp -r ${helix}/runtime/queries/* ./build/ chmod u+w ./build -R for so in ${grammars}/*.so; do name=$(basename "$so" .so) if [ -d "./build/$name" ]; then cp "$so" "./build/$name/$name.so" chmod u+w "./build/$name/$name.so" patchelf --shrink-rpath "./build/$name/$name.so" fi done ''; installPhase = '' mkdir -p $out cp -r ./build/* $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 = pkgs.lib.fileset.toSource { root = ./.; fileset = pkgs.lib.fileset.unions [ ./Cargo.toml ./Cargo.lock ./src ]; }; 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 ]; }; } ); }