diff --git a/default-gui.nix b/default-gui.nix new file mode 100644 index 0000000..9011df3 --- /dev/null +++ b/default-gui.nix @@ -0,0 +1,49 @@ +{ + lib, + stdenv, + cmake, + libGL, + SDL2, + xorg.libX11 + installShellFiles, + ... +}: +let + cmakeContent = builtins.readFile ./CMakeLists.txt; + cmakeLines = lib.splitString "\n" cmakeContent; + versionLine = lib.findFirst (l: builtins.match ".*set\\(KE_VERSION \".+\"\\).*" l + version = builtins.head (builtins.match ".*set\\(KE_VERSION \"(.+)\"\\).*" versio +in +pkgs.stdenv.mkDerivation { + pname = "kte"; + inherit version; + + src = ./.; + + nativeBuildInputs = [ pkgs.cmake pkgs.pkg-config ]; + buildInputs = with pkgs; [ + ncurses + SDL2 + libGL + xorg.libX11 + ]; + + cmakeFlags = [ + "-DBUILD_GUI=ON" + "-DCURSES_NEED_NCURSES=TRUE" + "-DCURSES_NEED_WIDE=TRUE" + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp kte $out/bin/ + cp kge $out/bin/ + + installManPage ../docs/kte.1 + installManPage ../docs/kte.1 + + runHook postInstall + ''; +} diff --git a/default.nix b/default.nix index 1c6928c..b6c2132 100644 --- a/default.nix +++ b/default.nix @@ -1,10 +1,19 @@ -# default.nix +{ + lib, + stdenv, + cmake, + installShellFiles, + ... +}: let - pkgs = import {}; + cmakeContent = builtins.readFile ./CMakeLists.txt; + cmakeLines = lib.splitString "\n" cmakeContent; + versionLine = lib.findFirst (l: builtins.match ".*set\\(KE_VERSION \".+\"\\).*" l + version = builtins.head (builtins.match ".*set\\(KE_VERSION \"(.+)\"\\).*" versio in pkgs.stdenv.mkDerivation { pname = "kte"; - version = "0.1.0"; + inherit version; src = ./.; @@ -17,8 +26,19 @@ pkgs.stdenv.mkDerivation { ]; cmakeFlags = [ - "-DBUILD_GUI=ON" + "-DKTE_USE_PIECE_TABLE=ON" "-DCURSES_NEED_NCURSES=TRUE" "-DCURSES_NEED_WIDE=TRUE" ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp kte $out/bin/ + + installManPage ../docs/kte.1 + + runHook postInstall + ''; } diff --git a/flake-gui.nix b/flake-gui.nix new file mode 100644 index 0000000..159322f --- /dev/null +++ b/flake-gui.nix @@ -0,0 +1,55 @@ +# flake.nix +{ + description = "kte ImGui/SDL2 text editor"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in { + packages.default = pkgs.stdenv.mkDerivation { + pname = "kte"; + version = "0.1.0"; + src = ./.; + + nativeBuildInputs = [ pkgs.cmake pkgs.pkg-config ]; + buildInputs = with pkgs; [ + ncurses + SDL2 + libGL + xorg.libX11 + ]; + + cmakeFlags = [ + "-DBUILD_GUI=ON" + "-DCURSES_NEED_NCURSES=TRUE" + "-DCURSES_NEED_WIDE=TRUE" + ]; + + # Alternative (even stronger): completely hide the broken module + preConfigure = '' + # If the project ships its own FindSDL2.cmake in cmake/, hide it + if [ -f cmake/FindSDL2.cmake ]; then + mv cmake/FindSDL2.cmake cmake/FindSDL2.cmake.disabled + echo "Disabled bundled FindSDL2.cmake" + fi + ''; + + meta = with pkgs.lib; { + description = "kte ImGui/SDL2 GUI editor"; + mainProgram = "kte"; + platforms = platforms.linux; + }; + }; + + devShells.default = pkgs.mkShell { + inputsFrom = [ self.packages.${system}.default ]; + packages = with pkgs; [ gdb clang-tools ]; + }; + }); +} \ No newline at end of file diff --git a/flake.nix b/flake.nix index 159322f..cea4eeb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,55 +1,18 @@ -# flake.nix { - description = "kte ImGui/SDL2 text editor"; + description = "Kyle's Text Editor"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in { - packages.default = pkgs.stdenv.mkDerivation { - pname = "kte"; - version = "0.1.0"; - src = ./.; - - nativeBuildInputs = [ pkgs.cmake pkgs.pkg-config ]; - buildInputs = with pkgs; [ - ncurses - SDL2 - libGL - xorg.libX11 - ]; - - cmakeFlags = [ - "-DBUILD_GUI=ON" - "-DCURSES_NEED_NCURSES=TRUE" - "-DCURSES_NEED_WIDE=TRUE" - ]; - - # Alternative (even stronger): completely hide the broken module - preConfigure = '' - # If the project ships its own FindSDL2.cmake in cmake/, hide it - if [ -f cmake/FindSDL2.cmake ]; then - mv cmake/FindSDL2.cmake cmake/FindSDL2.cmake.disabled - echo "Disabled bundled FindSDL2.cmake" - fi - ''; - - meta = with pkgs.lib; { - description = "kte ImGui/SDL2 GUI editor"; - mainProgram = "kte"; - platforms = platforms.linux; - }; - }; - - devShells.default = pkgs.mkShell { - inputsFrom = [ self.packages.${system}.default ]; - packages = with pkgs; [ gdb clang-tools ]; - }; - }); -} \ No newline at end of file + outputs = + { self, nixpkgs }: + let + pkgs = import nixpkgs { system = "x86_64-linux"; }; + in + { + packages.x86_64-linux = { + default = pkgs.callPackage ./default.nix { }; + }; + }; +}