Reformat all the nix files using nixpkgs-fmt

This commit is contained in:
Sameer Rahmani 2024-04-11 20:09:57 +01:00
parent 7659a028f7
commit 38986f37da
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
7 changed files with 556 additions and 536 deletions

View File

@ -13,14 +13,15 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ pkgs, lib, elispDepsFile }:
with builtins;
let
reader = import ./elisp_reader.nix { inherit lib; };
elispAst = reader.fromElisp (builtins.readFile elispDepsFile);
dependsOnForm = filter (x: head x == "depends-on") elispAst;
elispPkgs = if length dependsOnForm == 0
elispPkgs =
if length dependsOnForm == 0
then throw "Can't find the form 'depends-on' on 'deps.el'"
else tail (head dependsOnForm);
in elispPkgs
in
elispPkgs

View File

@ -1,33 +0,0 @@
# Fg42 - Emacs Editor for advance users
#
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ pkgs, fg42, version }:
{
desktop = pkgs.writeText "FG42.desktop" ''
[Desktop Entry]
Encoding=UTF-8
Name=FG42
GenericName=FG42
Comment=Emacs Editor for advance users
MimeType=text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-java;application/x-shellscript;text/x-c;text/x-c++;text/x-ruby;text/x-python;text/x-clojure;text/css;text/html;text/x-javascript;
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=FG42
Exec=${fg42} %F
Icon=fg42
Version=${version}
'';
}

View File

@ -73,7 +73,8 @@ let
matchSymbol =
let
symbolChar = ''([^${notInSymbol}]|\\.)'';
in mkMatcher ''(${symbolChar}+)([${notInSymbol}]|$).*'' symbolMaxLength;
in
mkMatcher ''(${symbolChar}+)([${notInSymbol}]|$).*'' symbolMaxLength;
maxTokenLength = foldl' max 0 [
commentMaxLength
@ -291,7 +292,8 @@ let
}
else
throw "Unrecognized token on line ${toString state.line}: ${rest}";
in (builtins.foldl' readToken { acc = []; pos = 0; skip = 0; line = startLineNumber; mod = 0; } (stringToCharacters elisp)).acc;
in
(builtins.foldl' readToken { acc = [ ]; pos = 0; skip = 0; line = startLineNumber; mod = 0; } (stringToCharacters elisp)).acc;
tokenizeElisp = elisp:
tokenizeElisp' { inherit elisp; };
@ -302,14 +304,15 @@ let
# Convert literal value tokens in a flat list to their
# corresponding nix representation.
parseValues = tokens:
map (token:
map
(token:
if token.type == "string" then
token // {
value = substring 1 (stringLength token.value - 2) token.value;
}
else if token.type == "integer" then
token // {
value = fromJSON (removeStrings ["+" "."] token.value);
value = fromJSON (removeStrings [ "+" "." ] token.value);
}
else if token.type == "symbol" && token.value == "t" then
token // {
@ -319,12 +322,12 @@ let
let
initial = head (match "([+-]?([[:digit:]]*[.])?[[:digit:]]+(e([+-]?[[:digit:]]+|[+](INF|NaN)))?)" token.value);
isSpecial = (match "(.+(e[+](INF|NaN)))" initial) != null;
withoutPlus = removeStrings ["+"] initial;
withoutPlus = removeStrings [ "+" ] initial;
withPrefix =
if substring 0 1 withoutPlus == "." then
"0" + withoutPlus
else if substring 0 2 withoutPlus == "-." then
"-0" + removeStrings ["-"] withoutPlus
"-0" + removeStrings [ "-" ] withoutPlus
else
withoutPlus;
in
@ -336,7 +339,8 @@ let
token
else
token
) tokens;
)
tokens;
# Convert pairs of opening and closing tokens to their
# respective collection types, i.e. lists and vectors. Also,
@ -365,7 +369,7 @@ let
in
if openColl != null then
state // {
acc = [ [] ] ++ seq (head state.acc) state.acc;
acc = [ [ ] ] ++ seq (head state.acc) state.acc;
inColl = [ openColl ] ++ state.inColl;
depth = state.depth + 1;
line = [ token.line ] ++ state.line;
@ -397,7 +401,7 @@ let
emptyList = {
type = "list";
depth = state.depth + 1;
value = [];
value = [ ];
};
in
state // seq currColl { acc = [ (currColl ++ [ emptyList ]) ] ++ rest; }
@ -408,7 +412,7 @@ let
in
state // seq currColl { acc = [ (currColl ++ [ token ]) ] ++ rest; };
in
head (builtins.foldl' parseToken { acc = [ [] ]; inColl = [ null ]; depth = -1; line = []; } tokens).acc;
head (builtins.foldl' parseToken { acc = [ [ ] ]; inColl = [ null ]; depth = -1; line = [ ]; } tokens).acc;
# Handle dotted pair notation, a syntax where the car and cdr
# are represented explicitly. See
@ -434,12 +438,14 @@ let
throw ''"Dotted pair notation"-dot outside list on line ${toString token.line}''
else if isList token.value then
let
collectionContents = foldl' parseToken {
acc = [];
collectionContents = foldl' parseToken
{
acc = [ ];
dotted = false;
inList = token.type == "list";
inherit (state) depthReduction;
} token.value;
}
token.value;
in
state // {
acc = state.acc ++ (
@ -457,10 +463,10 @@ let
}
else
state // {
acc = state.acc ++ [token];
acc = state.acc ++ [ token ];
};
in
(foldl' parseToken { acc = []; dotted = false; inList = false; depthReduction = 0; } tokens).acc;
(foldl' parseToken { acc = [ ]; dotted = false; inList = false; depthReduction = 0; } tokens).acc;
parseQuotes = tokens:
let
@ -469,7 +475,7 @@ let
token =
if isList token'.value then
token' // {
value = (foldl' parseToken { acc = []; quotes = []; } token'.value).acc;
value = (foldl' parseToken { acc = [ ]; quotes = [ ]; } token'.value).acc;
}
else
token';
@ -478,7 +484,7 @@ let
state // {
quotes = [ token ] ++ state.quotes;
}
else if state.quotes != [] then
else if state.quotes != [ ] then
let
quote = value: token:
token // {
@ -488,14 +494,14 @@ let
in
state // {
acc = state.acc ++ [ quotedValue ];
quotes = [];
quotes = [ ];
}
else
state // {
acc = state.acc ++ [ token ];
};
in
(foldl' parseToken { acc = []; quotes = []; } tokens).acc;
(foldl' parseToken { acc = [ ]; quotes = [ ]; } tokens).acc;
in
parseQuotes (parseDots (parseCollections (parseValues tokens)));
@ -508,19 +514,19 @@ let
if isList object.value then
map readObject object.value
else if object.type == "quote" then
["quote" (readObject object.value)]
[ "quote" (readObject object.value) ]
else if object.type == "backquote" then
["`" (readObject object.value)]
[ "`" (readObject object.value) ]
else if object.type == "expand" then
["," (readObject object.value)]
[ "," (readObject object.value) ]
else if object.type == "slice" then
[",@" (readObject object.value)]
[ ",@" (readObject object.value) ]
else if object.type == "function" then
["#'" (readObject object.value)]
[ "#'" (readObject object.value) ]
else if object.type == "byteCode" then
["#"] ++ (readObject object.value)
[ "#" ] ++ (readObject object.value)
else if object.type == "record" then
["#s"] ++ (readObject object.value)
[ "#s" ] ++ (readObject object.value)
else
object.value;
in
@ -630,7 +636,8 @@ let
flags =
(foldl'
parseFlag
{ acc = state.block.flags;
{
acc = state.block.flags;
flag = null;
inherit (state) line;
}
@ -650,7 +657,7 @@ let
block = {
language = null;
body = "";
flags = {};
flags = { };
};
pos = state.pos + 1;
skip = (stringLength endCodeBlock) - 1;
@ -683,7 +690,8 @@ let
in
(foldl'
parseToken
{ acc = [];
{
acc = [ ];
mod = 0;
pos = 0;
skip = 0;
@ -691,7 +699,7 @@ let
block = {
language = null;
body = "";
flags = {};
flags = { };
};
leadingWhitespace = true;
readLanguage = false;
@ -723,7 +731,7 @@ let
inherit (codeBlock) startLineNumber;
})
)
[]
[ ]
codeBlocks;
tokenizeOrgModeBabelElisp =

View File

@ -13,10 +13,15 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ lib, stdenv, emacs29, callPackage, writeShellApplication, noether
, emacsParams ? {},
fg42Params ? {}
} :
{ lib
, stdenv
, emacs29
, callPackage
, writeShellApplication
, noether
, emacsParams ? { }
, fg42Params ? { }
}:
let
lemacs = emacs29.override ({
withTreeSitter = true;
@ -47,4 +52,5 @@ let
DISPLAY=:1 ${fg42}/bin/fg42-wm
'';
};
in { inherit fg42 run-test-wm; }
in
{ inherit fg42 run-test-wm; }

View File

@ -13,21 +13,49 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ lib, stdenv, elispPkgs, srcDir, emacsPackagesFor, ourPackages, direnv
, makeFontsConf, nix, nixpkgs-fmt
, nil, # nix lsp server
{ lib
, stdenv
, elispPkgs
, srcDir
, emacsPackagesFor
, ourPackages
, direnv
, makeFontsConf
, nix
, nixpkgs-fmt
, nil
, # nix lsp server
# python deps
python311, python3Packages,
# This is a set of system tools required for FG42
python311
, python3Packages
, # This is a set of system tools required for FG42
# to work.
pyright, emacs, ripgrep, git, texinfo, vazir-fonts, fira-code, nerdfonts
, fira-mono, noto-fonts, gcc, ltex-ls, bash, tree-sitter, fd
, aspellWithDicts,
supportWM ? true, xorg, slock,
supportPython ? true, supportVerilog ? true, svls, verilator, }:
pyright
, emacs
, ripgrep
, git
, texinfo
, vazir-fonts
, fira-code
, nerdfonts
, fira-mono
, noto-fonts
, gcc
, ltex-ls
, bash
, tree-sitter
, fd
, aspellWithDicts
, supportWM ? true
, xorg
, slock
, supportPython ? true
, supportVerilog ? true
, svls
, verilator
,
}:
with builtins;
let
version = "4.0.0";
@ -43,7 +71,15 @@ let
dicts = aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]);
runtimeBins = [
ripgrep git tree-sitter direnv nix nil dicts fd nixpkgs-fmt
ripgrep
git
tree-sitter
direnv
nix
nil
dicts
fd
nixpkgs-fmt
]
++ (lib.optional (!stdenv.buildPlatform.isRiscV) [
# Not supported on Risc-V
@ -83,7 +119,8 @@ let
];
};
in stdenv.mkDerivation (final: rec {
in
stdenv.mkDerivation (final: rec {
inherit version;
pname = "fg42";
src = srcDir;

View File

@ -22,16 +22,16 @@ let
(x: builtins.typeOf x == "string")
(builtins.split _sep _s);
in {
elispStr
in
{ elispStr
, alwaysEnsure ? false
}:
let
let
inherit (import ./elisp_reader.nix { inherit lib; }) fromElisp;
readFunction = fromElisp;
find = item: list:
if list == [] then [] else
if list == [ ] then [ ] else
if builtins.head list == item then
list
else
@ -41,11 +41,11 @@ in {
let
keywordList = find keyword list;
in
if keywordList != [] then
if keywordList != [ ] then
let
keywordValue = builtins.tail keywordList;
in
if keywordValue != [] then
if keywordValue != [ ] then
builtins.head keywordValue
else
true
@ -56,7 +56,7 @@ in {
let
disabledValue = getKeywordValue ":disabled" item;
in
if disabledValue == [] then
if disabledValue == [ ] then
false
else if builtins.isBool disabledValue then
disabledValue
@ -78,10 +78,10 @@ in {
else if ensureValue == true || (ensureValue == null && alwaysEnsure) then
usePackageName
else
[];
[ ];
recurse = item:
if builtins.isList item && item != [] then
if builtins.isList item && item != [ ] then
let
packageManager = builtins.head item;
in
@ -89,9 +89,10 @@ in {
if !(isDisabled item) then
[ packageManager (getName item) ] ++ map recurse item
else
[]
[ ]
else
map recurse item
else
[];
in lib.flatten (map recurse (readFunction elispStr))
[ ];
in
lib.flatten (map recurse (readFunction elispStr))