commit eb663a1c296d9d91c41b4be4189a4c411f477c5b
parent df114a3730140548cc7c9e76bc96a450e0897caa
Author: sioodmy <sioodmy@tuta.io>
Date: Tue, 19 Jul 2022 20:52:38 +0200
feat: implement nix flake
Diffstat:
4 files changed, 116 insertions(+), 5 deletions(-)
diff --git a/default.nix b/default.nix
@@ -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;
+ };
+}
diff --git a/flake.lock b/flake.lock
@@ -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
+}
diff --git a/flake.nix b/flake.nix
@@ -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
+ ];
+ };
+
+ });
+}
diff --git a/shell.nix b/shell.nix
@@ -1,5 +0,0 @@
-{ pkgs ? import <nixpkgs> {} }:
-
-pkgs.mkShell {
- nativeBuildInputs = with pkgs; [ pkgconfig xorg.libX11 xorg.libXft fontconfig harfbuzz ];
-}