Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devshell: githooks example #3

Open
wants to merge 18 commits into
base: da/devhsell
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions devshell.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
imports = [ "git.hooks" ]

[devshell]
name = "nixpkgs"
packages = [
"fd",
"nixpkgs-fmt",
"editorconfig-checker",
]

[[commands]]
package = "editorconfig-checker"
category = "linters"

[[commands]]
name = "fmt"
help = "Check Nix formatting"
category = "folder tree checks"
command = "nixpkgs-fmt ${@} ."

[[commands]]
name = "evalnix"
help = "Check Nix parsing"
category = "folder tree checks"
command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null"

[git.hooks]
enable = true
pre-commit.text = """
#!/usr/bin/env bash
set -eou pipefail
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(${git}/bin/git hash-object -t tree /dev/null)
fi

diff="git diff-index --name-only --cached $against --diff-filter d"

nix_files=($($diff -- '*.nix'))
all_files=($($diff))

# Format staged nix files.
if [[ -n "${nix_files[@]}" ]]; then
nixpkgs-fmt "${nix_files[@]}"
git add "${nix_files[@]}"
fi

# check editorconfig
if ! editorconfig-checker -- "${all_files[@]}"; then
echo -e "\nCode is not aligned with .editorconfig
Review the output and commit your fixes" >&2
exit 1
fi
"""
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
});

checks.x86_64-linux.tarball = jobs.tarball;
devShell = {
x86_64-linux = import ./shell.nix { system = "x86_64-linux"; };
x86_64-darwin = import ./shell.nix { system = "x86_64-darwin"; };
aarch64-linux = import ./shell.nix { system = "aarch64-linux"; };
};

htmlDocs = {
nixpkgsManual = jobs.manual;
Expand Down
16 changes: 16 additions & 0 deletions nixos/modules/hardware/keyboard/teck.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ config, lib, pkgs, ... }:

with lib;
let
cfg = config.hardware.keyboard.teck;
in
{
options.hardware.keyboard.teck = {
enable = mkEnableOption "non-root access to the firmware of TECK keyboards";
};

config = mkIf cfg.enable {
services.udev.packages = [ pkgs.teck-udev-rules ];
};
}

1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
./hardware/i2c.nix
./hardware/sensor/hddtemp.nix
./hardware/sensor/iio.nix
./hardware/keyboard/teck.nix
./hardware/keyboard/zsa.nix
./hardware/ksm.nix
./hardware/ledger.nix
Expand Down
14 changes: 8 additions & 6 deletions pkgs/applications/editors/featherpad/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{ lib, mkDerivation, pkg-config, qmake, qttools, qtbase, qtsvg, qtx11extras, fetchFromGitHub }:
{ lib, mkDerivation, cmake, hunspell, pkg-config, qttools, qtbase, qtsvg, qtx11extras
, fetchFromGitHub }:

mkDerivation rec {
pname = "featherpad";
version = "0.10.0";
version = "0.18.0";

src = fetchFromGitHub {
owner = "tsujan";
repo = "FeatherPad";
rev = "V${version}";
sha256 = "1wrbs6kni9s3x39cckm9kzpglryxn5vyarilvh9pafbzpc6rc57p";
sha256 = "0av96yx9ir1ap5adn2cvr6n5y7qjrspk73and21m65dmpwlfdiqb";
};

nativeBuildInputs = [ qmake pkg-config qttools ];
buildInputs = [ qtbase qtsvg qtx11extras ];
nativeBuildInputs = [ cmake pkg-config qttools ];
buildInputs = [ hunspell qtbase qtsvg qtx11extras ];

meta = with lib; {
description = "Lightweight Qt5 Plain-Text Editor for Linux";
homepage = "https://github.com/tsujan/FeatherPad";
platforms = platforms.linux;
maintainers = [ maintainers.flosse ];
license = licenses.gpl3;
license = licenses.gpl3Plus;
};
}
52 changes: 13 additions & 39 deletions pkgs/applications/editors/jetbrains/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{ lib, stdenv, callPackage, fetchurl
, jdk, cmake, libxml2, zlib, python3, ncurses5
, dotnet-sdk_3
, autoPatchelfHook
, glib
, libdbusmenu
, vmopts ? null
}:

Expand All @@ -25,52 +28,23 @@ let
platforms = platforms.linux;
};
}).overrideAttrs (attrs: {
nativeBuildInputs = (attrs.nativeBuildInputs or []) ++ optionals (stdenv.isLinux) [
autoPatchelfHook
];
buildInputs = (attrs.buildInputs or []) ++ optionals (stdenv.isLinux) [
python3
stdenv.cc.cc
libdbusmenu
];
dontAutoPatchelf = true;
postFixup = (attrs.postFixup or "") + optionalString (stdenv.isLinux) ''
(
cd $out/clion-${version}
# bundled cmake does not find libc
rm -rf bin/cmake/linux
ln -s ${cmake} bin/cmake/linux

lldbLibPath=$out/clion-${version}/bin/lldb/linux/lib
interp="$(cat $NIX_CC/nix-support/dynamic-linker)"
ln -s ${ncurses5.out}/lib/libtinfo.so.5 $lldbLibPath/libtinfo.so.5

patchelf --set-interpreter $interp \
--set-rpath "${lib.makeLibraryPath [ libxml2 zlib stdenv.cc.cc.lib ]}:$lldbLibPath" \
bin/lldb/linux/bin/lldb-server

for i in LLDBFrontend lldb lldb-argdumper; do
patchelf --set-interpreter $interp \
--set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}:$lldbLibPath" \
"bin/lldb/linux/bin/$i"
done

patchelf \
--set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}:$lldbLibPath" \
bin/lldb/linux/lib/python3.*/lib-dynload/zlib.cpython-*-x86_64-linux-gnu.so

patchelf \
--set-rpath "${lib.makeLibraryPath [ libxml2 zlib stdenv.cc.cc.lib python3 ]}:$lldbLibPath" \
bin/lldb/linux/lib/liblldb.so

gdbLibPath=$out/clion-${version}/bin/gdb/linux/lib
patchelf \
--set-rpath "$gdbLibPath" \
bin/gdb/linux/lib/python3.*/lib-dynload/zlib.cpython-*-x86_64-linux-gnu.so
patchelf --set-interpreter $interp \
--set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib zlib ]}:$gdbLibPath" \
bin/gdb/linux/bin/gdb
patchelf --set-interpreter $interp \
--set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}:$gdbLibPath" \
bin/gdb/linux/bin/gdbserver

patchelf --set-interpreter $interp \
--set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib zlib ]}" \
bin/clang/linux/clangd
patchelf --set-interpreter $interp \
--set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib zlib ]}" \
bin/clang/linux/clang-tidy
autoPatchelf $PWD/bin

wrapProgram $out/bin/clion \
--set CL_JDK "${jdk}"
Expand Down
37 changes: 37 additions & 0 deletions pkgs/applications/video/srt-live-server/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ lib
, fetchFromGitHub
, stdenv
, srt
, zlib
}:

stdenv.mkDerivation rec {
pname = "srt-live-server";
version = "1.4.8";

src = fetchFromGitHub {
owner = "Edward-Wu";
repo = "srt-live-server";
rev = "V${version}";
sha256 = "0x48sxpgxznb1ymx8shw437pcgk76ka5rx0zhn9b3cyi9jlq1yld";
};

patches = [
# https://github.com/Edward-Wu/srt-live-server/pull/94
./fix-insecure-printfs.patch
];

buildInputs = [ srt zlib ];

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

meta = with lib; {
description = "srt live server for low latency";
license = licenses.mit;
homepage = "https://github.com/Edward-Wu/srt-live-server";
maintainers = with maintainers; [ shamilton ];
platforms = platforms.linux;
};
}
61 changes: 61 additions & 0 deletions pkgs/applications/video/srt-live-server/fix-insecure-printfs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
diff --color -ur a/Makefile b/Makefile
--- a/Makefile 2021-04-16 13:02:41.416453040 +0200
+++ b/Makefile 2021-04-16 13:21:23.020089623 +0200
@@ -1,3 +1,4 @@
+PREFIX = /usr/local
SHELL = /bin/sh
MAIN_NAME=sls
CLIENT_NAME=slc
@@ -64,3 +65,16 @@
rm -f $(OUTPUT_PATH)/*.o
rm -rf $(BIN_PATH)/*

+install: all
+ @echo installing executable files to ${DESTDIR}${PREFIX}/bin
+ @mkdir -p "${DESTDIR}${PREFIX}/bin"
+ @cp -f ${BIN_PATH}/${MAIN_NAME} "${DESTDIR}${PREFIX}/bin"
+ @chmod 755 "${DESTDIR}${PREFIX}/bin/${MAIN_NAME}"
+ @cp -f ${BIN_PATH}/${CLIENT_NAME} "${DESTDIR}${PREFIX}/bin"
+ @chmod 755 "${DESTDIR}${PREFIX}/bin/${CLIENT_NAME}"
+
+uninstall:
+ @echo removing executable files from ${DESTDIR}${PREFIX}/bin
+ @rm -f "${DESTDIR}${PREFIX}/bin/${MAIN_NAME}"
+ @rm -f "${DESTDIR}${PREFIX}/bin/${CLIENT_NAME}"
+
diff --color -ur a/slscore/HttpClient.cpp b/slscore/HttpClient.cpp
--- a/slscore/HttpClient.cpp 2021-04-16 13:02:41.416453040 +0200
+++ b/slscore/HttpClient.cpp 2021-04-16 13:11:40.343866698 +0200
@@ -90,7 +90,7 @@
goto FUNC_END;
}
if (NULL != method && strlen(method) > 0) {
- sprintf(m_http_method, method);
+ strcpy(m_http_method, method);
}

m_interval = interval;
diff --color -ur a/slscore/SLSLog.cpp b/slscore/SLSLog.cpp
--- a/slscore/SLSLog.cpp 2021-04-16 13:02:41.416453040 +0200
+++ b/slscore/SLSLog.cpp 2021-04-16 13:08:16.836119519 +0200
@@ -85,7 +85,7 @@
vsnprintf (buf , 4095 , fmt , vl);
//sprintf(buf_info, "%s %s: %s\n" , cur_time, LOG_LEVEL_NAME[level], buf);
sprintf(buf_info, "%s:%03d %s %s: %s\n" , cur_time, cur_time_msec, APP_NAME, LOG_LEVEL_NAME[level], buf);
- printf(buf_info);
+ puts(buf_info);

if (m_log_file) {
fwrite(buf_info, strlen(buf_info), 1, m_log_file);
diff --color -ur a/slscore/SLSSrt.cpp b/slscore/SLSSrt.cpp
--- a/slscore/SLSSrt.cpp 2021-04-16 13:02:41.417452995 +0200
+++ b/slscore/SLSSrt.cpp 2021-04-16 13:10:11.004957820 +0200
@@ -124,7 +124,7 @@
std::map<int, std::string>::iterator it;
for(it=map_error.begin(); it!=map_error.end(); ++it) {
sprintf(szBuf, "%d: %s\n", it->first, it->second.c_str());
- printf(szBuf);
+ puts(szBuf);
}
printf("----------end------------\n");
map_error.clear();
5 changes: 3 additions & 2 deletions pkgs/desktops/gnome-3/extensions/unite/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{ lib, stdenv, gnome3, fetchFromGitHub, xprop, glib }:

stdenv.mkDerivation rec {
pname = "gnome-shell-extension-unite";
version = "51";
version = "52";

src = fetchFromGitHub {
owner = "hardpixel";
repo = "unite-shell";
rev = "v${version}";
sha256 = "0mic7h5l19ly79l02inm33992ffkxsh618d6zbr39gvn4405g6wk";
sha256 = "1zahng79m2gw27fb2sw8zyk2n07qc0hbn02g5mfqzhwk62g97v4y";
};

uuid = "[email protected]";
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/node-packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ let
'';
};

teck-programmer = super.teck-programmer.override {
buildInputs = [ pkgs.libusb ];
};

vega-cli = super.vega-cli.override {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/node-packages/node-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
, "svgo"
, "swagger"
, {"tedicross": "git+https://github.com/TediCross/TediCross.git#v0.8.7"}
, "teck-programmer"
, "tern"
, "textlint"
, "textlint-plugin-latex"
Expand Down
Loading