symplify nix flake

This commit is contained in:
ant 2026-03-12 19:29:46 +01:00
parent 3d9c53068d
commit 0814fc7a5d
3 changed files with 45 additions and 79 deletions

View file

@ -1,56 +0,0 @@
{ lib
, stdenv
, pkg-config
, fontconfig
, freetype
, libX11
, libXft
, harfbuzz
, gd
, glib
, ncurses
, writeText
, conf ? null
, patches ? []
, extraLibs ? []
, nixosTests
, imlib2
}:
stdenv.mkDerivation rec {
pname = "st";
version = "0.8.5";
src = ./.;
inherit patches;
configFile =
lib.optionalString (conf != null) (writeText "config.def.h" conf);
postPatch = lib.optionalString (conf != null) "cp ${configFile} config.def.h"
+ lib.optionalString stdenv.isDarwin ''
substituteInPlace config.mk --replace "-lrt" ""
'';
strictDeps = true;
makeFlags = [ "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" ];
nativeBuildInputs = [ pkg-config ncurses fontconfig freetype ];
buildInputs = [ libX11 libXft harfbuzz gd glib imlib2 ] ++ extraLibs;
preInstall = ''
export TERMINFO=$out/share/terminfo
'';
installFlags = [ "PREFIX=$(out)" ];
passthru.tests.test = nixosTests.terminal-emulators.st;
meta = with lib; {
description = "st terminal";
license = licenses.mit;
maintainers = with maintainers; [ sioodmy ];
platforms = platforms.unix;
};
}

8
flake.lock generated
View file

@ -20,16 +20,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1736549401, "lastModified": 1773122722,
"narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", "narHash": "sha256-FIqHByVqxCprNjor1NqF80F2QQoiiyqanNNefdlvOg4=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", "rev": "62dc67aa6a52b4364dd75994ec00b51fbf474e50",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-24.11", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View file

@ -1,39 +1,61 @@
{ {
description = "st terminal"; description = "st terminal";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}; let pkgs = nixpkgs.legacyPackages.${system};
in rec { in rec {
packages = flake-utils.lib.flattenTree { packages.st = pkgs.stdenv.mkDerivation {
st = pkgs.callPackage ./default.nix { }; pname = "st";
version = "ant";
src = ./.;
postPatch = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
substituteInPlace config.mk --replace "-lrt" ""
'';
strictDeps = true;
makeFlags = [ "PKG_CONFIG=${pkgs.stdenv.cc.targetPrefix}pkg-config" ];
nativeBuildInputs = with pkgs; [ pkg-config ncurses fontconfig freetype ];
buildInputs = with pkgs; [ libx11 libxft harfbuzz gd glib imlib2 ];
preInstall = ''
export TERMINFO=$out/share/terminfo
'';
installFlags = [ "PREFIX=$(out)" ];
passthru.tests.test = pkgs.nixosTests.terminal-emulators.st;
meta = with pkgs.lib; {
description = "st terminal";
license = licenses.mit;
maintainers = [ "ant" ];
platforms = platforms.unix;
};
}; };
defaultPackage = packages.st;
apps.st = flake-utils.lib.mkApp { apps.st = flake-utils.lib.mkApp {
drv = packages.st; drv = packages.st;
exePath = "/bin/st"; exePath = "/bin/st";
}; };
apps.default = apps.st; apps.default = apps.st;
packages.default = packages.st;
defaultApp = apps.st; defaultApp = apps.st;
devShell = pkgs.mkShell rec {
name = "st"; devShell = pkgs.mkShell {
inputsFrom = [ packages.st ];
hardeningDisable = [ "fortify" ];
packages = with pkgs; [ packages = with pkgs; [
pkg-config bear
xorg.libX11 clang-tools
xorg.libXft gdb
fontconfig
harfbuzz.dev
imlib2
gd
glib
# ccls
# bear
# lldb
# gdb
# valgrind
]; ];
}; };