From eb663a1c296d9d91c41b4be4189a4c411f477c5b Mon Sep 17 00:00:00 2001 From: sioodmy Date: Tue, 19 Jul 2022 20:52:38 +0200 Subject: [PATCH] feat: implement nix flake --- default.nix | 42 ++++++++++++++++++++++++++++++++++++++++++ flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++++++++++++++++++++ shell.nix | 5 ----- 4 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..b547d63e91d9c64b6bf2a81847fb8c527ba918b1 --- /dev/null +++ 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 new file mode 100644 index 0000000000000000000000000000000000000000..34bc900cd9c24f34ead11a0a56a3ab992c00ffba --- /dev/null +++ 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 new file mode 100644 index 0000000000000000000000000000000000000000..98f59108ccef90909865f8eea26b3bd489c4b5a3 --- /dev/null +++ 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 deleted file mode 100644 index 359a7f49c08722b070bac966a25f415dfde5167c..0000000000000000000000000000000000000000 --- a/shell.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - nativeBuildInputs = with pkgs; [ pkgconfig xorg.libX11 xorg.libXft fontconfig harfbuzz ]; -}