From 4510ff805071bf0b55d8ae9480400bacbf128927 Mon Sep 17 00:00:00 2001 From: Vegard Bieker Matthey Date: Wed, 11 Mar 2026 02:14:40 +0100 Subject: [PATCH] setup flake.nix with derivation and devShell --- .gitignore | 1 + flake.lock | 27 ++++++++++++++++++++++++ flake.nix | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ package.nix | 27 ++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix diff --git a/.gitignore b/.gitignore index 0dde90e..1d3642b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dwl *-protocol.h .ccls-cache config.h +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7889e5a --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1772963539, + "narHash": "sha256-9jVDGZnvCckTGdYT53d/EfznygLskyLQXYwJLKMPsZs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9dcb002ca1690658be4a04645215baea8b95f31d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b4ab098 --- /dev/null +++ b/flake.nix @@ -0,0 +1,60 @@ +{ + description = "A flake for dwl"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = + { + self, + nixpkgs, + }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + nativeBuildInputs = with pkgs; [ + tinycc + gnumake + pkg-config + wayland-protocols + ]; + buildInputs = with pkgs; [ + wayland-scanner + wlroots + libinput + wayland + libxkbcommon + pixman + ]; + inherit (pkgs) lib; + in + { + devShell.${system} = + with pkgs; + mkShell { + inherit buildInputs nativeBuildInputs; + }; + packages.${system} = + let + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./Makefile + ./client.h + ./config.def.h + ./config.mk + ./dwl.c + ./dwl.1 + ./dwl.desktop + ./protocols + ./util.c + ./util.h + ]; + }; + in + { + default = pkgs.callPackage ./package.nix { inherit src buildInputs nativeBuildInputs; }; + }; + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..2b493ed --- /dev/null +++ b/package.nix @@ -0,0 +1,27 @@ +{ + lib, + src, + stdenv, + buildInputs, + nativeBuildInputs, +}: +stdenv.mkDerivation { + pname = "dwl"; + version = "0.1.0"; + inherit src buildInputs nativeBuildInputs; + + makeFlags = [ + ]; + + meta = { + description = "dwm for Wayland"; + homepage = "https://codeberg.org/dwl/dwl"; + platforms = lib.platforms.linux; + mainProgram = "dwl"; + }; + + installPhase = '' + mkdir -p $out/ + cp dwl $out/ + ''; +}