diff --git a/flake.lock b/flake.lock index 7850fd70..23f03cad 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,32 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1750605355, - "narHash": "sha256-xT8cPLTxlktxI9vSdoBlAVK7dXgd8IK59j7ZwzkkhnI=", + "lastModified": 1750865895, + "narHash": "sha256-p2dWAQcLVzquy9LxYCZPwyUdugw78Qv3ChvnX755qHA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "3078b9a9e75f1790e6d6ef9955fdc6a2d1740cc6", + "rev": "61c0f513911459945e2cb8bf333dc849f1b976ff", "type": "github" }, "original": { @@ -18,22 +38,28 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "scenefx": "scenefx" + "scenefx": "scenefx", + "systems": "systems_2" } }, "scenefx": { "inputs": { + "flake-utils": [ + "flake-utils" + ], "nixpkgs": [ "nixpkgs" - ] + ], + "systems": "systems" }, "locked": { - "lastModified": 1749449355, - "narHash": "sha256-GMMmxM/z7KKEs5PXB0TJFMg7qcwqbQ3/nI2906sZbxM=", + "lastModified": 1750992888, + "narHash": "sha256-P1MSTJrLBBaBVfZ0mD6wOIxNueW31ImXtECQTEX/YD0=", "owner": "wlrfx", "repo": "scenefx", - "rev": "b92dcb43bcf0da17ba8bfbdd7385dce75383628c", + "rev": "5a8d954abae9eeac3e46e1d9ac3c1443188b9c8a", "type": "github" }, "original": { @@ -41,6 +67,36 @@ "repo": "scenefx", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8584449f..54bacf7f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,110 +1,86 @@ { description = "Swayfx development environment"; + inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + systems.url = "github:nix-systems/default-linux"; + + flake-utils = { + url = "github:numtide/flake-utils"; + inputs.systems.follows = "systems"; + }; + scenefx = { url = "github:wlrfx/scenefx"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; }; }; - outputs = - { - self, - nixpkgs, - scenefx, - ... - }: - let - mkPackage = pkgs: { - swayfx-unwrapped = - (pkgs.swayfx-unwrapped.override { - # This override block is currently empty, you might remove it - # unless you intend to override function arguments later. - }).overrideAttrs - (old: { - version = "0.5.2-git"; - src = pkgs.lib.cleanSource ./.; - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.cmake ]; - # Add wlroots_0_19 here - buildInputs = old.buildInputs ++ [ - pkgs.scenefx - pkgs.wlroots_0_19 # <-- Added this line - ]; - providedSessions = [ pkgs.swayfx-unwrapped.meta.mainProgram ]; - patches = []; ## Consider if you need patches from the original derivation - mesonFlags = let - inherit (pkgs.lib.strings) mesonEnable mesonOption; - in - [ - (mesonOption "sd-bus-provider" "libsystemd") - (mesonEnable "tray" true) - # You might need to explicitly enable fx if the default changed - # (mesonEnable "fx" true) # <-- Potentially add this if needed - ]; - }); - }; - targetSystems = [ - "aarch64-linux" - "x86_64-linux" - ]; - pkgsFor = - system: - import nixpkgs { - inherit system; - overlays = [ scenefx.overlays.insert ]; + outputs = { self, nixpkgs, flake-utils, scenefx, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + scenefx-git = scenefx.packages.${system}.scenefx-git; + + in { + packages = rec { + swayfx-unwrapped-git = pkgs.swayfx-unwrapped.overrideAttrs(old: { + version = "git"; + src = pkgs.lib.cleanSource ./.; + nativeBuildInputs = with pkgs; [ + meson + ninja + pkg-config + wayland-scanner + scdoc + ]; + buildInputs = with pkgs; [ + libGL + wayland + libxkbcommon + pcre2 + json_c + libevdev + pango + cairo + libinput + gdk-pixbuf + librsvg + wayland-protocols + libdrm + xorg.xcbutilwm + wlroots_0_19 + ] ++ [ scenefx-git ]; + }); + + default = swayfx-unwrapped-git; }; - forEachSystem = f: nixpkgs.lib.genAttrs targetSystems (system: f (pkgsFor system)); - in - { - overlays = rec { - default = insert; - # Insert using the locked nixpkgs. Can be used with any nixpkgs version. - insert = _: prev: mkPackage (pkgsFor prev.system); - # Override onto the input nixpkgs. Users *MUST* have a scenefx overlay - # used before this overlay, otherwise pkgs.scenefx will be unavailable - override = _: prev: mkPackage prev; - }; - packages = forEachSystem ( - pkgs: (mkPackage pkgs // { default = self.packages.${pkgs.system}.swayfx-unwrapped; }) - ); - - devShells = forEachSystem (pkgs: { - default = pkgs.mkShell { + devShells.default = pkgs.mkShell { name = "swayfx-shell"; - # inputsFrom propagates buildInputs, nativeBuildInputs etc. from the listed derivations - # Adding wlroots and scenefx explicitly here is fine, but they are also included via inputsFrom inputsFrom = [ - self.packages.${pkgs.system}.swayfx-unwrapped - # pkgs.wlroots_0_19 # Included via swayfx-unwrapped buildInputs now - # pkgs.scenefx # Included via swayfx-unwrapped buildInputs now - ]; - # You still might want wlroots/scenefx here if you need tools/headers directly in the shell - # outside of what swayfx uses. - buildInputs = [ - pkgs.wlroots_0_19 - pkgs.scenefx - ]; - packages = with pkgs; [ - gdb # for debugging + self.packages.${system}.swayfx-unwrapped-git + scenefx-git ]; + packages = [ pkgs.gdb ]; # add debugging packages shellHook = '' ( # Copy the nix version of wlroots and scenefx into the project # This is useful if you want meson to use them as subprojects during manual dev/testing - echo "Copying wlroots and scenefx sources to ./subprojects for dev environment..." mkdir -p "$PWD/subprojects" && cd "$PWD/subprojects" - rm -rf wlroots scenefx # Clean previous copies if they exist - cp -R --no-preserve=mode,ownership ${pkgs.wlroots_0_19.src} wlroots - cp -R --no-preserve=mode,ownership ${pkgs.scenefx.src} scenefx - echo "Done copying sources." + if [ ! -d scenefx ]; then + echo "Copying scenefx to ./subprojects..." + cp -R --no-preserve=mode,ownership ${scenefx-git.src} scenefx + fi cd "$OLDPWD" ) || echo "Failed to copy subproject sources." ''; }; - }); - formatter = forEachSystem (pkgs: pkgs.nixfmt-rfc-style); - }; + formatter = pkgs.nixfmt-rfc-style; + } + ); } +