From 10e0de5b055dc2347d80156616656af044cbf4c1 Mon Sep 17 00:00:00 2001 From: Syed Daanish Date: Tue, 7 Jul 2026 12:09:06 +0100 Subject: [PATCH] Add package.nix and cleanup build process --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 9 +++++++-- package.nix | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.sh | 5 ----- 4 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 flake.lock create mode 100644 package.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6b753be --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1783148766, + "narHash": "sha256-uslt2pqShTIXDdAHRHv2QkYLsVdY8Oqwz0EA48/RSM8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a50de1b7d8a586adc18d2395c19de7d6058e6030", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 06e74de..8f2b24a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { description = "kutu wm environment"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; outputs = { self, nixpkgs }: let @@ -12,17 +12,22 @@ in { devShells.${system}.default = pkgs.mkShell { packages = with pkgs; [ - ruby + (ruby.withPackages (ps: [ + ps.ffi + ])) gcc pkg-config xorg.libxcb xorg.xcbutilwm + xorg.xrandr + xorg.xprop ]; shellHook = '' echo "kutu dev shell" ''; }; + packages.${system}.default = pkgs.callPackage ./package.nix {}; }; } diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..de50138 --- /dev/null +++ b/package.nix @@ -0,0 +1,54 @@ +{ stdenv +, ruby +, makeWrapper +, pkg-config +, xorg +, rubyPackages +, gcc +, lib +}: + +stdenv.mkDerivation { + pname = "kutu"; + version = "0.1.0"; + + src = ./.; + + nativeBuildInputs = [ + pkg-config + makeWrapper + gcc + ]; + + buildInputs = [ + (ruby.withPackages (ps: [ + ps.ffi + ])) + xorg.libxcb + xorg.xcbutilwm + xorg.xrandr + xorg.xprop + ]; + + buildPhase = '' + ./setup.sh + ''; + + installPhase = '' + mkdir -p $out/bin + mkdir -p $out/build + mkdir -p $out/src + + cp bin/kutu.rb $out/bin/kutu.rb + cp bin/kutu-run.rb $out/bin/kutu-run.rb + + cp build/X-kutu.so $out/build/ + cp -r src $out/src + + wrapProgram $out/bin/kutu.rb \ + --prefix PATH : ${lib.makeBinPath [ + xorg.xrandr + xorg.xprop + ]} + ''; +} diff --git a/setup.sh b/setup.sh index 64f54e9..82a285c 100755 --- a/setup.sh +++ b/setup.sh @@ -28,9 +28,4 @@ for f in "$DIR/bin/"* "$DIR/src/shell/"*; do } done -if ! command -v kutu.rb >/dev/null 2>&1 || ! command -v kutu-run.rb >/dev/null 2>&1; then - echo "Tip: Add $DIR/bin to your PATH to run 'kutu.rb' and 'kutu-run.rb' from anywhere:" - echo "export PATH=\"\$PATH:$DIR/bin\"" -fi - echo -e "\e[32mAll done! Build successful.\e[0m"