setup flake.nix with derivation and devShell

This commit is contained in:
2026-03-11 02:14:40 +01:00
parent a2d03cf618
commit 4510ff8050
4 changed files with 115 additions and 0 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ dwl
*-protocol.h
.ccls-cache
config.h
result

27
flake.lock generated Normal file
View File

@@ -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
}

60
flake.nix Normal file
View File

@@ -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; };
};
};
}

27
package.nix Normal file
View File

@@ -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/
'';
}