~kris/suckless

st

eb663a1c296d9d91c41b4be4189a4c411f477c5b — sioodmy 4 years ago df114a3
feat: implement nix flake
4 files changed, 116 insertions(+), 5 deletions(-)

A default.nix
A flake.lock
A flake.nix
D shell.nix
A default.nix => default.nix +42 -0
@@ 0,0 1,42 @@
{ lib, stdenv, fetchurl, pkg-config, fontconfig, freetype, libX11, libXft
, harfbuzz, gd, glib, ncurses, writeText, conf ? null, patches ? [ ]
, extraLibs ? [ ], nixosTests }:

stdenv.mkDerivation rec {
  pname = "st-snazzy";
  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 ] ++ extraLibs;

  preInstall = ''
    export TERMINFO=$out/share/terminfo
  '';

  installFlags = [ "PREFIX=$(out)" ];

  passthru.tests.test = nixosTests.terminal-emulators.st;

  meta = with lib; {
    homepage = "https://github.com/siduck/st";
    description = "snazzy terminal (suckless + lightweight)";
    license = licenses.mit;
    maintainers = with maintainers; [ sioodmy ];
    platforms = platforms.unix;
  };
}

A flake.lock => flake.lock +43 -0
@@ 0,0 1,43 @@
{
  "nodes": {
    "flake-utils": {
      "locked": {
        "lastModified": 1656928814,
        "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1658161305,
        "narHash": "sha256-X/nhnMCa1Wx4YapsspyAs6QYz6T/85FofrI6NpdPDHg=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "e4d49de45a3b5dbcb881656b4e3986e666141ea9",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-utils": "flake-utils",
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

A flake.nix => flake.nix +31 -0
@@ 0,0 1,31 @@
{
  description = "Flake utils demo";

  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = nixpkgs.legacyPackages.${system};
      in rec {
        packages = flake-utils.lib.flattenTree {
          st-snazzy = pkgs.callPackage ./default.nix { };
        };
        defaultPackage = packages.st-snazzy;
        apps.st-snazzy = flake-utils.lib.mkApp { drv = packages.st-snazzy; };
        defaultApp = apps.st-snazzy;
        devShell = pkgs.mkShell rec {
          name = "st-snazzy";
          packages = with pkgs; [
            pkgconfig
            xorg.libX11
            xorg.libXft
            fontconfig
            harfbuzz
            gd
            glib
          ];
        };

      });
}

D shell.nix => shell.nix +0 -5
@@ 1,5 0,0 @@
{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  nativeBuildInputs = with pkgs; [ pkgconfig xorg.libX11 xorg.libXft fontconfig harfbuzz ];
}