From fa6164f8fb067498de8d97cbd41646b8d0e37635 Mon Sep 17 00:00:00 2001 From: Gokul Swaminathan <33443763+JavaCafe01@users.noreply.github.com> Date: Tue, 15 Nov 2022 19:47:04 -0800 Subject: [PATCH] Improve Nix Flake (#48) * Improve nix flake * Go back to unstable * Update flake * Update README.md --- README.md | 16 +++++++- flake.lock | 32 ++++++++-------- flake.nix | 106 ++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 111 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 0223fc39..ab342980 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,21 @@ Sway is an incredible window manager, and certainly one of the most well establi ## Installation -### Compiling from Source +### Nix -This project contains a nix flake for those who have the nix package manager installed. This flake handles installing the below dependencies when `nix develop` is ran inside of the project root. Otherwise, the below dependencies must be installed prior to building and running this project. +If you have Nix installed, you can run SwayFX with a single command: + +``` +nix run github:WillPower3309/swayfx +``` + +You can also bring up a development shell and follow the build instructions below, without installing all of the dependencies manually: + +``` +nix develop +``` + +### Compiling from Source Install dependencies: diff --git a/flake.lock b/flake.lock index 08638ca0..8cbc0c49 100644 --- a/flake.lock +++ b/flake.lock @@ -1,38 +1,40 @@ { "nodes": { - "flake-utils": { + "flake-compat": { + "flake": false, "locked": { - "lastModified": 1649676176, - "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "edolstra", + "repo": "flake-compat", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1651024496, - "narHash": "sha256-uKSrrw/neSkxX6TXPSaMyfu7iKzFrK7F6HOt6vQefGY=", - "owner": "NixOS", + "lastModified": 1668531822, + "narHash": "sha256-rNt2SphDCQTbAgWBX9ZCMIn5ISxeb0l6b6kRLvzbFVo=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "d9e593ed5889f3906dc72811c45bf684be8865cf", + "rev": "97b8d9459f7922ce0e666113a1e8e6071424ae16", "type": "github" }, "original": { - "id": "nixpkgs", + "owner": "nixos", "ref": "nixpkgs-unstable", - "type": "indirect" + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", + "flake-compat": "flake-compat", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 29fe7727..c0d745fb 100644 --- a/flake.nix +++ b/flake.nix @@ -2,33 +2,87 @@ description = "swaywm development environment"; inputs = { - nixpkgs.url = "nixpkgs/nixpkgs-unstable"; - flake-utils = { url = "github:numtide/flake-utils"; }; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; }; - outputs = {self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - - in { - devShell = pkgs.mkShell { - depsBuildBuild = with pkgs; [ - pkg-config - ]; - - nativeBuildInputs = with pkgs; [ - cmake meson ninja pkg-config wayland-scanner scdoc - ]; - - buildInputs = with pkgs; [ - wayland libxkbcommon pcre json_c libevdev pango cairo libinput libcap pam gdk-pixbuf librsvg - wayland-protocols libdrm wlroots dbus xwayland - # wlroots - libGL pixman xorg.xcbutilwm xorg.libX11 libcap xorg.xcbutilimage xorg.xcbutilerrors mesa - libpng ffmpeg xorg.xcbutilrenderutil seatd - ]; + outputs = { self, nixpkgs, flake-compat, ... }: + let + pkgsFor = system: + import nixpkgs { + inherit system; + overlays = [ ]; }; - } - ); + + targetSystems = [ "aarch64-linux" "x86_64-linux" ]; + in { + overlays.default = final: prev: { + swayfx = prev.sway.overrideAttrs (old: { + version = "999-master"; + src = builtins.path { + name = "swayfx"; + path = prev.lib.cleanSource ./.; + }; + }); + }; + + packages = nixpkgs.lib.genAttrs targetSystems (system: + let pkgs = pkgsFor system; + in (self.overlays.default pkgs pkgs) // { + default = self.packages.${system}.swayfx; + }); + + devShells = nixpkgs.lib.genAttrs targetSystems (system: + let pkgs = pkgsFor system; + in { + default = pkgs.mkShell { + depsBuildBuild = with pkgs; [ pkg-config ]; + + nativeBuildInputs = with pkgs; [ + cmake + meson + ninja + pkg-config + wayland-scanner + scdoc + ]; + + buildInputs = with pkgs; [ + wayland + libxkbcommon + pcre + json_c + libevdev + pango + cairo + libinput + libcap + pam + gdk-pixbuf + librsvg + wayland-protocols + libdrm + wlroots + dbus + xwayland + libGL + pixman + xorg.xcbutilwm + xorg.libX11 + libcap + xorg.xcbutilimage + xorg.xcbutilerrors + mesa + libpng + ffmpeg + xorg.xcbutilrenderutil + seatd + ]; + }; + }); + }; }