nix: rename custom -> packages

This commit is contained in:
Primrose 2024-09-22 13:57:30 +02:00
parent 754882bf0d
commit afc2eea47a
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
24 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,26 @@
[buildPlans.altiosevka]
family = "iosevka"
spacing = "term"
serifs = "sans"
noLigation = true
[buildPlans.altiosevka.variants.design]
capital-z = 'straight-serifless-with-crossbar'
capital-q = 'crossing'
lower-lambda = 'tailed-turn'
seven = 'straight-serifless-crossbar'
number-sign = 'slanted'
ampersand = "et-tailed"
dollar = 'open'
cent = "open"
percent = 'rings-continuous-slash-also-connected'
# explicitly declare with-notch
lig-equal-chain = 'with-notch'
lig-hyphen-chain = 'with-notch'
lig-plus-chain = 'with-notch'
lig-double-arrow-bar = 'with-notch'
lig-single-arrow-bar = 'with-notch'
[buildPlans.altiosevka.variants.italic]
v = "cursive-serifless"
w = "cursive-serifless"

View file

@ -0,0 +1,17 @@
{ iosevka }:
let
pname = "altiosevka";
in
(iosevka.overrideAttrs (_: {
inherit pname;
})).override
{
set = pname;
/*
Guide: https://github.com/be5invis/Iosevka/blob/main/doc/custom-build.md
Use `term` spacing to avoid dashed arrow issue
https://github.com/ryanoasis/nerd-fonts/issues/1018
*/
privateBuildPlan = builtins.readFile ./buildplan.toml;
}

58
nix/packages/default.nix Normal file
View file

@ -0,0 +1,58 @@
{ self, inputs, ... }:
{
flake.lib.mkNerdFont = ./mkNerdFont.nix;
flake.overlays.packages =
final: _:
let
mkNerdFont = final.callPackage self.lib.mkNerdFont { };
in
rec {
# fonts
hiosevka = final.callPackage ./hiosevka { };
hiosevka-nerd-font-mono = mkNerdFont {
font = hiosevka;
extraArgs = [
"--name {/.}-NFM"
"--use-single-width-glyphs"
];
};
hiosevka-nerd-font-propo = mkNerdFont {
font = hiosevka;
extraArgs = [
"--name {/.}-NFP"
"--variable-width-glyphs"
];
};
altiosevka = final.callPackage ./altiosevka { };
logisim-evolution = final.callPackage ./logisim-evolution.nix { };
necrolib = final.callPackage ./necrolib.nix { };
why3 = final.callPackage ./why3.nix { };
isabelle-wrapped = final.callPackage ./isabelle-wrapped.nix { };
maeel = final.callPackage ./maeel.nix { };
tokei = final.callPackage ./tokei { }; # alpha tokei with typst, skel, hledger
typst-mutilate = final.callPackage ./typst-mutilate.nix { };
posy-cursor = final.callPackage ./posy-cursor.nix { };
nd = final.callPackage ./nd { };
xbrightness = final.callPackage ./xbrightness.nix { };
ffgun = final.callPackage ./ffgun.nix { };
# Unmerged packages from nixfinal
# TODO: use upstream when merged
dl-librescore = final.callPackage ./dl-librescore.nix { };
fish-lsp = final.callPackage ./fish-lsp { };
};
perSystem =
{ system, ... }:
let
pkgs-stable = import inputs.nixpkgs-stable { inherit system; };
in
{
packages = self.overlays.packages pkgs-stable pkgs-stable;
};
}

View file

@ -0,0 +1,41 @@
{
lib,
stdenv,
buildNpmPackage,
fetchFromGitHub,
python3,
darwin,
}:
buildNpmPackage rec {
pname = "dl-librescore";
version = "0.35.17";
src = fetchFromGitHub {
owner = "LibreScore";
repo = "dl-librescore";
rev = "v${version}";
hash = "sha256-u09aquwZIT2XxxaqirrMU5Q3PpXbj70bcI3pOflxVAE=";
};
npmDepsHash = "sha256-LZgVQNFXUqFbzXKdXk8wsMDBqApmtXFLRUw6zIKDAqs=";
# see https://github.com/LibreScore/dl-librescore/pull/32
# TODO can be removed with next update
postPatch = ''
substituteInPlace package-lock.json \
--replace 50c7a1508cd9358757c30794e14ba777e6faa8aa b4cb32eb1734a2f73ba2d92743647b1a91c0e2a8
'';
makeCacheWritable = true;
nativeBuildInputs = [ python3 ] ++ lib.optionals stdenv.isDarwin [ darwin.cctools ];
meta = {
description = "Download sheet music";
homepage = "https://github.com/LibreScore/dl-librescore";
license = lib.licenses.mit;
mainProgram = "dl-librescore";
maintainers = with lib.maintainers; [ ];
};
}

42
nix/packages/ffgun.nix Normal file
View file

@ -0,0 +1,42 @@
# adapted from https://github.com/neXromancers/hacksaw
{
writeShellApplication,
shotgun,
ffmpeg_5-full,
}:
writeShellApplication {
name = "ffgun";
runtimeInputs = [
shotgun
ffmpeg_5-full
];
text = ''
dir=/tmp
current=$(date +%F_%H-%M-%S)
echo "$dir/$current.mp4"
hacksaw -n | {
IFS=+x read -r w h x y
w=$((w + w % 2))
h=$((h + h % 2))
ffmpeg \
-v 16 \
-r 30 \
-f x11grab \
-s "''${w}x''${h}" \
-i ":0.0+$x,$y" \
-preset slow \
-c:v h264 \
-pix_fmt yuv420p \
-crf 20 \
"$dir/$current.mp4"
}
'';
meta.description = "Shotgun's integration script with ffmpeg from their github";
}

View file

@ -0,0 +1,51 @@
{
mkYarnPackage,
fetchFromGitHub,
fetchYarnDeps,
fish,
fixup-yarn-lock,
nodejs,
yarn,
makeWrapper,
}:
mkYarnPackage rec {
pname = "fish-lsp";
version = "1.0.7";
src = fetchFromGitHub {
owner = "ndonfris";
repo = pname;
rev = "v${version}";
sha256 = "sha256-Np7ELQxHqSnkzVkASYSyO9cTiO1yrakDuK88kkACNAI=";
};
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = "sha256-hmaLWO1Sj+2VujrGD2A+COfVE2D+tCnxyojjq1512K4=";
};
nativeBuildInputs = [
fish
fixup-yarn-lock
nodejs
yarn
makeWrapper
];
buildPhase = ''
runHook preBuild
wasm_file=$(find node_modules -type f -a -name tree-sitter-fish.wasm)
cp -f $wasm_file ./deps/fish-lsp
yarn run sh:build-time
yarn --offline compile
yarn run sh:relink
# yarn run sh:build-completions
runHook postBuild
'';
postInstall = ''
wrapProgram "$out/bin/fish-lsp" \
--set-default fish_lsp_logfile "/tmp/fish_lsp_logs.txt"
'';
}

View file

@ -0,0 +1,43 @@
[buildPlans.hiosevka]
family = "hIosekva"
spacing = "term"
serifs = "sans"
exportGlyphNames = true
[buildPlans.hiosevka.ligations]
inherits = "haskell"
enables = [
"brst", # (* *)
"slash-asterisk", # /* */
# disable <= =< >= completely (no arrows or comparison ligatures)
"lteq-separate",
"eqlt-separate",
"gteq-separate",
]
disables = [
# never enable comparison ligatures
"lteq", # <=
"gteq", # >=
"slasheq", # /=
]
[buildPlans.hiosevka.variants.design]
capital-z = 'straight-serifless-with-crossbar'
capital-q = 'crossing'
lower-lambda = 'tailed-turn'
seven = 'straight-serifless-crossbar'
number-sign = 'slanted'
ampersand = "et-tailed"
dollar = 'open'
cent = "open"
percent = 'rings-continuous-slash-also-connected'
# explicitly declare with-notch
lig-equal-chain = 'with-notch'
lig-hyphen-chain = 'with-notch'
lig-plus-chain = 'with-notch'
lig-double-arrow-bar = 'with-notch'
lig-single-arrow-bar = 'with-notch'
[buildPlans.hiosevka.variants.italic]
v = "cursive-serifless"
w = "cursive-serifless"

View file

@ -0,0 +1,17 @@
{ iosevka }:
let
pname = "hiosevka";
in
(iosevka.overrideAttrs (_: {
inherit pname;
})).override
{
set = pname;
/*
Guide: https://github.com/be5invis/Iosevka/blob/main/doc/custom-build.md
Use `term` spacing to avoid dashed arrow issue
https://github.com/ryanoasis/nerd-fonts/issues/1018
*/
privateBuildPlan = builtins.readFile ./buildplan.toml;
}

View file

@ -0,0 +1,12 @@
{ isabelle, makeWrapper }:
isabelle.overrideAttrs (oa: {
buildInputs = (oa.buildInputs or [ ]) ++ [ makeWrapper ];
postFixup =
(oa.postFixup or "")
+ ''
wrapProgram $out/bin/isabelle \
--set _JAVA_AWT_WM_NONREPARENTING 1
'';
})

View file

@ -0,0 +1,33 @@
{
stdenv,
fetchurl,
jre8,
makeWrapper,
}:
stdenv.mkDerivation {
pname = "logisim-evolution";
version = "2023";
src = fetchurl {
url = "http://www.irisa.fr/cosi/HOMEPAGE/Derrien/logisim/logisim-evolution.jar";
sha256 = "sha256-24uXyTXhxxA1uwc787I+OJn+ZmqMgNIL9RE3zoRrWww=";
};
dontUnpack = true;
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
makeWrapper ${jre8}/bin/java $out/bin/logisim-evolution \
--add-flags "-jar $src" \
--set _JAVA_AWT_WM_NONREPARENTING 1
runHook postInstall
'';
# NOTE: related issue
# https://wiki.archlinux.org/title/java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing
}

22
nix/packages/maeel.nix Normal file
View file

@ -0,0 +1,22 @@
{
stdenv,
fetchFromGitHub,
rustc,
}:
stdenv.mkDerivation {
pname = "maeel";
version = "3.0";
src = fetchFromGitHub {
owner = "Traumatism";
repo = "maeel";
rev = "d8e4261266a181904947ef940b6744a6360c93a6";
hash = "sha256-Ee4/N2Q90xsbyGVtpE/yUFWC/ELt8nBAICkR/FlZQOo=";
};
nativeBuildInputs = [ rustc ];
installPhase = ''
mkdir -p "$out/bin"
cp --reflink=auto ./maeel "$out/bin"
'';
}

View file

@ -0,0 +1,63 @@
{
nerd-font-patcher,
parallel,
stdenvNoCC,
}:
{
font,
extraArgs ? [ ],
useDefaultsArgs ? true,
}:
stdenvNoCC.mkDerivation {
/*
Credits:
https://github.com/NixOS/nixpkgs/issues/44329#issuecomment-1231189572
https://github.com/NixOS/nixpkgs/issues/44329#issuecomment-1544597422
long font names is not problematic:
https://github.com/ryanoasis/nerd-fonts/issues/1018#issuecomment-1953555781
*/
name = "${font.name}-NerdFont";
src = font;
nativeBuildInputs = [
nerd-font-patcher
parallel
];
buildPhase =
let
args = builtins.concatStringsSep " " extraArgs;
defArgs =
if useDefaultsArgs then
builtins.concatStringsSep " " [
"--careful"
"--complete"
"--quiet"
"--no-progressbars"
]
else
"";
in
''
mkdir -p nerd-font
find \( -name \*.ttf -o -name \*.otf \) | parallel nerd-font-patcher {} \
--outputdir nerd-font ${defArgs} ${args}
'';
installPhase = ''
exists() { [ -e "$1" ]; }
truetype="$out/share/fonts/truetype"
opentype="$out/share/fonts/opentype"
if exists nerd-font/*.ttf ; then
mkdir -p "$truetype"
cp nerd-font/*.ttf "$truetype"
fi
if exists nerd-font/*.otf ; then
mkdir -p "$opentype"
cp nerd-font/*.otf "$opentype"
fi
'';
}

View file

@ -0,0 +1,15 @@
{
writeShellApplication,
nix-output-monitor,
nvd,
}:
writeShellApplication {
name = "nd";
runtimeInputs = [
nix-output-monitor
nvd
];
text = builtins.readFile ./nd.sh;
}

52
nix/packages/nd/nd.sh Executable file
View file

@ -0,0 +1,52 @@
bold=$(tput bold)
normal=$(tput sgr0)
while [ $# -gt 0 ]; do
case "$1" in
--clean*)
shopt -s nullglob
for link in nix-diff*; do
set -x
unlink "$link"
set +x
done
exit 0
;;
--last*)
if [[ "$1" != *=* ]]; then shift; fi
_last_hash="${1#*=}"
;;
--hostname*)
if [[ "$1" != *=* ]]; then shift; fi
_hostname="${1#*=}"
;;
*)
printf "Error: unknown argument"
exit 1
;;
esac
shift
done
echo "Comparing ${bold}$_hostname${normal}'s configuration of ${bold}HEAD${normal} and ${bold}$_last_hash${normal}"
last_ref=".?ref=${_last_hash}#nixosConfigurations.${_hostname}.config.system.build.toplevel"
last_link="nix-diff-${_last_hash:0:7}"
if [ -L "$last_link" ]; then
echo "Found link ${bold}$last_link${normal}"
else
echo "Starting configuration build at ${bold}$_last_hash${normal}"
nix build "$last_ref" --out-link "$last_link" >/dev/null 2>&1 &
fi
echo "Starting configuration build at ${bold}HEAD${normal}"
this_ref=".#nixosConfigurations.${_hostname}.config.system.build.toplevel"
this_link="nix-diff-HEAD"
nix build "$this_ref" --out-link "$this_link" --log-format internal-json --verbose |& nom --json
echo "Waiting for all builds to complete..."
wait
echo "Completed."
echo "Diffing..."
nvd diff "$last_link" "$this_link"

32
nix/packages/necrolib.nix Normal file
View file

@ -0,0 +1,32 @@
{
lib,
fetchFromGitLab,
ocaml-ng,
ocamlPackages ? ocaml-ng.ocamlPackages_4_14,
}:
let
rev = "4690dd27717e687b8eba449e44127a53fabe7a2d";
in
ocamlPackages.buildDunePackage {
pname = "necrolib";
version = lib.substring 0 7 rev;
minimalOCamlVersion = "4.14.1";
src = fetchFromGitLab {
domain = "gitlab.inria.fr";
owner = "skeletons";
repo = "necro";
inherit rev;
hash = "sha256-FYeVuSUmA6as0oI80uC3wW8l1/AazOPAtiNsnZyUahU=";
};
duneVersion = "3";
nativeBuildInputs = [ ocamlPackages.menhir ];
buildInputs = [
ocamlPackages.ocamlgraph
ocamlPackages.dune-build-info
];
}

View file

@ -0,0 +1,26 @@
{
lib,
stdenv,
fetchFromGitHub,
}:
let
rev = "bd2bac08bf01e25846a6643dd30e2acffa9517d4";
in
stdenv.mkDerivation {
pname = "posy-cursor";
version = lib.substring 0 7 rev;
src = fetchFromGitHub {
owner = "leana8959";
repo = "posy-improved-cursor-linux";
inherit rev;
hash = "sha256-ndxz0KEU18ZKbPK2vTtEWUkOB/KqA362ipJMjVEgzYQ=";
};
installPhase = ''
install -dm 0755 $out/share/icons
cp -r Posy_Cursor* $out/share/icons
'';
}

View file

@ -0,0 +1,43 @@
{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
libiconv,
darwin,
zlib,
}:
let
rev = "6392516c47d4573d16886b9fe5f79592b1c70d49";
in
rustPlatform.buildRustPackage {
pname = "tokei";
version = lib.substring 0 7 rev;
src = fetchFromGitHub {
owner = "XAMPPRocky";
repo = "tokei";
inherit rev;
hash = "sha256-EYr4K1Bt+74jb85UQ3So0efrOcYAq71/4++kMCSPi1E=";
};
cargoSha256 = "sha256-fdAJwQNJczRqy0KQqse8QRx5+1gZTCBw+kkwgn6UGKU=";
patches = [
./hledger.patch
./skel.patch
./why3.patch
];
buildInputs = lib.optionals stdenv.isDarwin [
libiconv
darwin.Security
];
checkInputs = lib.optionals stdenv.isDarwin [ zlib ];
# enable all output formats
buildFeatures = [ "all" ];
}

View file

@ -0,0 +1,42 @@
diff --git a/languages.json b/languages.json
index ac548b9..b2899f1 100644
--- a/languages.json
+++ b/languages.json
@@ -846,6 +846,13 @@
"nested": true,
"extensions": ["lean", "hlean"]
},
+ "Hledger": {
+ "name": "hledger",
+ "line_comment": [";", "#"],
+ "multi_line_comments": [["comment", "end comment"]],
+ "nested": false,
+ "extensions": ["hledger"]
+ },
"Less": {
"name": "LESS",
"line_comment": ["//"],
diff --git a/tests/data/hledger.hledger b/tests/data/hledger.hledger
new file mode 100644
index 0000000..df7259d
--- /dev/null
+++ b/tests/data/hledger.hledger
@@ -0,0 +1,18 @@
+# 18 lines 6 code 10 comments 2 blanks
+# a comment
+; another comment
+
+; ^ a blank line
+comment
+account assets ; Declare valid account names and display order.
+a block comment
+end comment
+
+account assets:savings ; A subaccount. This one represents a bank account.
+account assets:checking ; Another. Note, 2+ spaces after the account name.
+account assets:receivable ; Accounting type is inferred from english names,
+account passifs ; or declared with a "type" tag, type:L
+account expenses ; type:X
+ ; A follow-on comment line, indented.
+account expenses:rent ; Expense and revenue categories are also accounts.
+ ; Subaccounts inherit their parent's type.

View file

@ -0,0 +1,32 @@
diff --git a/languages.json b/languages.json
index b2899f1..dfeff47 100644
--- a/languages.json
+++ b/languages.json
@@ -1406,6 +1406,10 @@
"quotes": [["\\\"", "\\\""]],
"extensions": ["shader", "cginc"]
},
+ "Skel": {
+ "multi_line_comments": [["(*", "*)"]],
+ "extensions": ["skel", "sk"]
+ },
"Slang": {
"name": "Slang",
"line_comment": ["//"],
diff --git a/tests/data/skel.sk b/tests/data/skel.sk
new file mode 100644
index 0000000..c6e8a68
--- /dev/null
+++ b/tests/data/skel.sk
@@ -0,0 +1,11 @@
+(* 11 lines 5 code 5 comments 1 blanks *)
+
+(* ^ a blank line, a comment *)
+(*
+a multiline comment
+*)
+type ident
+type term =
+| Var ident
+| Lam (ident, term)
+| App (term, term)

View file

@ -0,0 +1,30 @@
diff --git a/languages.json b/languages.json
index dfeff47..0baedb7 100644
--- a/languages.json
+++ b/languages.json
@@ -1742,6 +1742,12 @@
"line_comment": ["//"],
"extensions": ["wgsl"]
},
+ "Why3": {
+ "name": "Why3",
+ "quotes": [["\\\"", "\\\""]],
+ "multi_line_comments": [["(*", "*)"]],
+ "extensions": ["mlw"]
+ },
"Wolfram": {
"quotes": [["\\\"", "\\\""]],
"multi_line_comments": [["(*", "*)"]],
diff --git a/tests/data/why3.mlw b/tests/data/why3.mlw
new file mode 100644
index 0000000..0d07bb2
--- /dev/null
+++ b/tests/data/why3.mlw
@@ -0,0 +1,7 @@
+(* 7 lines 3 code 3 comments 1 blanks *)
+module Exercice3
+ (* ^ ligne vide *)
+
+ val foo (bar) : baz
+ (* commentaire *)
+end

View file

@ -0,0 +1,27 @@
{
rustPlatform,
fetchFromGitHub,
fetchpatch,
}:
rustPlatform.buildRustPackage {
pname = "typst-mutilate";
version = "0.0";
src = fetchFromGitHub {
owner = "frozolotl";
repo = "typst-mutilate";
rev = "9bf5ed1f8a2f91055a91077f0a8545ff1f229933";
hash = "sha256-r4fkFv1np8xhff3m8yev1rU1vfKRz8zQMIKIc+fOjew=";
};
cargoSha256 = "sha256-QEOXPf/k+fCMNQxKGsW3FDsgH5XXUKob0XOef3DiB0s=";
patches = [
(fetchpatch {
name = "raw-block-fix";
url = "https://github.com/frozolotl/typst-mutilate/pull/2/commits/223bc31abb2d5fef4e743a1582bb126a2ef47a45.patch";
hash = "sha256-+6DMQo4cjVASgkX4gcYrEkwQ/uxttV/61fDnXBqbNcg=";
})
];
}

44
nix/packages/why3.nix Normal file
View file

@ -0,0 +1,44 @@
{
symlinkJoin,
makeWrapper,
why3,
cvc4,
z3_4_12,
fetchFromGitHub,
system,
}:
let
provers = [
alt-ergo
cvc4
z3_4_12
];
inherit
(import
(fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "1b95daa381fa4a0963217a5d386433c20008208a";
hash = "sha256-vwEtkxIEQjymeTk89Ty1MGfRVSWL1/3j1wt5xB5ua88=";
})
{
inherit system;
config.allowUnfree = true;
}
)
alt-ergo
;
in
symlinkJoin {
name = "why3";
# Generate configuration in the store, and wrap why3 with the corresponding option
paths = [ (why3.override { version = "1.6.0"; }) ];
buildInputs = provers;
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
$out/bin/why3 config detect --config=$out/why3.conf
wrapProgram $out/bin/why3 --add-flags "--config=$out/why3.conf"
'';
}

View file

@ -0,0 +1,16 @@
{
writeShellApplication,
bc,
}:
writeShellApplication {
name = "xbrightness";
runtimeInputs = [ bc ];
text = ''
device=$1
rel=$2
brightness=$(xrandr --verbose | grep Brightness | cut -d':' -f 2)
xrandr --output "$device" --brightness "$(echo "$brightness $rel" | bc -l)"
'';
}