Packages build!

This commit is contained in:
2024-09-07 00:24:08 +03:00
parent 4d29cc73b2
commit f8a16189f0
30 changed files with 1584 additions and 446 deletions
@@ -0,0 +1,20 @@
#https://xeiaso.net/talks/asg-2023-nixos/ example
{ lib, config, pkgs, options, azos-utils, ... }:
{
options.azos.suites.base.enable = (azos-utils.mkSuiteEnableOption {});
imports = [
./emacs
./python
./gpg-agent
./git
./name.nix
];
options.azos.name = lib.mkOption{
default = "YOUR NAME HERE";
type = lib.types.str;
description = "Your full name.";
};
}
@@ -0,0 +1,51 @@
{ lib, config, pkgs, azos-utils, outputs, ... }:
let
isEnabled =
config.azos.emacs.enable && config.azos.suites.base.enable;
emacspkgs = config.azos.emacs.emacspkg.pkgs;
localPkgName = "azos-emacs-base";
in
{
options.azos.emacs.enable = (azos-utils.mkFeatureEnableOption {
description = "Enables EMACS installation.";});
options.azos.emacs.emacspkg = lib.mkOption{
type = lib.types.package;
default = pkgs.emacs;
description = "The base package to use for Emacs.";
};
options.azos.emacs.pkgs = lib.mkOption{
default = [];
description = "List of packages for Emacs.";
};
options.azos.emacs.enabledSuites = lib.mkOption{
default = [];
description = "List of enabled suite names for Emacs. Used to enable the " +
"custom packages in init.el.";
};
#Set config
config = lib.mkIf isEnabled {
#Base emacs suite definition
azos.emacs.pkgs = [pkgs.azos.emacs.base];
azos.emacs.enabledSuites = [localPkgName];
#Global instantiation of Emacs
programs.emacs = {
enable = true;
package =
((pkgs.emacsPackagesFor config.azos.emacs.emacspkg).emacsWithPackages (
config.azos.emacs.pkgs
));
extraConfig = lib.strings.concatStringsSep "\n"
(builtins.map (s : "(require '" + s + ")\n")
config.azos.emacs.enabledSuites);
};
};
# imports = [./vterm.nix];
}
@@ -0,0 +1,20 @@
#+title: Aner's Emacs Vterm Configuration
#+property: header-args :results silent
* Vterm
#+begin_src emacs-lisp
(require 'azos-emacs-base)
(use-package vterm
:if (member system-type '(gnu gnu/linux))
:config
(add-hook 'vterm-mode-hook
(lambda () (setq-local global-hl-line-mode nil)))
(evil-collection-define-key 'normal 'vterm-mode-map
(kbd "p") 'vterm-yank)
(setq vterm-timer-delay 0.01
vterm-term-environment-variable "xterm-256color"))
#+end_src
@@ -0,0 +1,29 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.emacs.enable && config.azos.suites.editor.enable &&
config.azos.emacs.vterm.enable;
emacspkgs = config.azos.emacs.emacspkg.pkgs;
localPkgName = "azos-emacs-vterm";
in
{
options.azos.emacs.vterm.enable = (azos-utils.mkFeatureEnableOption {
description = "Enables Emacs VTERM installation.";});
#Set config
config = lib.mkIf isEnabled {
#Base emacs suite definition
azos.emacs.pkgs = [(emacspkgs.trivialBuild (azos-utils.trivialFromOrg {
pname = localPkgName;
version = "0.1.6";
src = ./el/azos-emacs-vterm.org;
packageRequires = with emacspkgs; [
vterm
];
}))];
azos.emacs.enabledSuites = [localPkgName];
};
}
@@ -0,0 +1,13 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.git.enable &&
config.azos.suites.base.enable;
in
{
options.azos.git.enable = (azos-utils.mkFeatureEnableOption {});
config = lib.mkIf isEnabled {
programs.git.enable = true;
};
}
@@ -0,0 +1,14 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.gpgagent.enable &&
config.azos.suites.base.enable;
in
{
options.azos.gpgagent.enable = (azos-utils.mkFeatureEnableOption {});
config = lib.mkIf isEnabled {
home.packages = [ pkgs.gnupg ];
home.file.".gnupg/gpg-agent.conf".source = ./gpg-agent.conf;
};
}
@@ -0,0 +1,6 @@
grab
pinentry-program /usr/bin/pinentry
default-cache-ttl 86400
max-cache-ttl 86400
enable-ssh-support
@@ -0,0 +1,4 @@
#https://xeiaso.net/talks/asg-2023-nixos/ example
{ lib, config, pkgs, ... }:{
home.file."name.txt".text = ''${config.azos.name}'';
}
@@ -0,0 +1,29 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.python.enable && config.azos.suites.base.enable;
pythonpkgs = config.azos.python.pythonpkg.pkgs;
in
{
options.azos.python.enable = (azos-utils.mkFeatureEnableOption {});
options.azos.python.pythonpkg = lib.mkOption{
type = lib.types.package;
default = pkgs.python3;
};
options.azos.python.pkgs = lib.mkOption{
default = [];
description = "List of packages for python.";
};
config = lib.mkIf isEnabled {
home.packages = with pkgs;
[(config.azos.python.pythonpkg.withPackages (python-pkgs: config.azos.python.pkgs))
];
};
imports = [
];
}
+12
View File
@@ -0,0 +1,12 @@
#https://xeiaso.net/talks/asg-2023-nixos/ example
{ lib, config, pkgs, options, azos-utils, ... }:
{
_module.args.azos-utils = import ./utils.nix { lib = lib; };
imports = [
./base
./station
./dev
./editor
];
}
@@ -0,0 +1,9 @@
#https://xeiaso.net/talks/asg-2023-nixos/ example
{ lib, config, pkgs, options, azos-utils, ... }:
{
options.azos.suites.dev.enable = (azos-utils.mkSuiteEnableOption {});
imports = [
./emacs
];
}
@@ -0,0 +1,31 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.emacs.enable && config.azos.suites.dev.enable;
emacspkgs = config.azos.emacs.emacspkg.pkgs;
localPkgName = "azos-emacs-dev";
in
{
#Set config
config = lib.mkIf isEnabled {
#Base emacs suite definition
azos.emacs.pkgs = [(emacspkgs.trivialBuild (azos-utils.trivialFromOrg {
pname = localPkgName;
version = "0.1.6";
src = ./el/azos-emacs-dev.org;
packageRequires = with emacspkgs; [
flycheck
cmake-mode
yaml
nix-mode
python
rust-mode
ein
];
}))];
azos.emacs.enabledSuites = [localPkgName];
};
}
@@ -0,0 +1,128 @@
#+title: Aner's Emacs Development Configuration
#+property: header-args :results silent
* Base dev
** Require
#+begin_src emacs-lisp
(require 'azos-emacs-base)
#+end_src
** Flycheck
Flycheck is for syntax checking. Mode-specific configs in their relevant sections.
#+begin_src emacs-lisp
(use-package flycheck
:config
(global-flycheck-mode 1)
)
#+end_src
* Dev modes
** Irony-mode
Must work on this. While it does work, can get slow and for weird projects can
show errors.
Namespace indent disabling based on:
https://stackoverflow.com/questions/13825188/suppress-c-namespace-indentation-in-emacs
#+begin_src emacs-lisp
;; == irony-mode ==
(use-package irony
:ensure t
:defer t
:init
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
:config
;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun azos/irony-mode-hook ()
(define-key irony-mode-map [remap completion-at-point]
'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
'irony-completion-at-point-async))
(add-hook 'irony-mode-hook 'azos/irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(defconst azos/cc-style
'("gnu"
(c-offsets-alist . ((innamespace . [0])))
(c-basic-offset . 4)))
(c-add-style "azos/cc-style" azos/cc-style)
(add-hook 'irony-mode-hook (lambda () (c-set-style "azos/cc-style")))
)
#+end_src
Integration with flycheck
#+begin_src emacs-lisp
(use-package flycheck-irony
:after flycheck irony
:config
(add-hook 'flycheck-mode-hook #'flycheck-irony-setup)
(add-hook 'c++-mode-hook (lambda () (setq flycheck-checker 'irony)))
)
#+end_src
** CMake
#+begin_src emacs-lisp
(use-package cmake-mode)
#+end_src
** YAML
#+begin_src emacs-lisp
(use-package yaml-mode)
#+end_src
** Nix
#+begin_src emacs-lisp
(use-package nix-mode)
#+end_src
** Python
#+begin_src emacs-lisp
(setq
;; python-shell-interpreter "python3"
python-shell-completion-native-enable nil)
(defun anerenv/python/set-fringes () "Sets fringes for python"
(setq left-fringe-width 10 right-fringe-width 0))
(add-hook 'python-mode-hook 'anerenv/python/set-fringes)
(use-package elpy
:ensure t
:defer t)
;; :init
;; (elpy-enable))
(define-key anerenv/global-minor-mode/open-keymap
(kbd "r p") 'run-python)
#+end_src
** Rust
#+begin_src emacs-lisp
(use-package rust-mode)
#+end_src
** Jupyter (ein)
#+begin_src emacs-lisp
(use-package ein
:config
(setq ein:output-area-inlined-images t)
(add-hook 'ein:notebook-mode-hook (lambda () (progn
;; (elpy-mode -1)
(define-key ein:notebook-mode-map (kbd "C-c C-k") nil)))))
#+end_src
@@ -0,0 +1,9 @@
#https://xeiaso.net/talks/asg-2023-nixos/ example
{ lib, config, pkgs, options, azos-utils, ... }:
{
options.azos.suites.editor.enable = (azos-utils.mkSuiteEnableOption {});
imports = [
./emacs
];
}
@@ -0,0 +1,29 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.emacs.enable && config.azos.suites.dev.enable;
emacspkgs = config.azos.emacs.emacspkg.pkgs;
pythonpkgs = config.azos.python.pythonpkg.pkgs;
localPkgName = "azos-emacs-editor";
in
{
#Set config
config = lib.mkIf isEnabled {
#Base emacs suite definition
azos.emacs.pkgs = [(emacspkgs.trivialBuild (azos-utils.trivialFromOrg {
pname = localPkgName;
version = "0.1.6";
src = ./el/azos-emacs-editor.org;
packageRequires = with emacspkgs; [
graphviz-dot-mode
markdown-mode
];
}))];
azos.emacs.enabledSuites = [localPkgName];
azos.python.pkgs = with pythonpkgs; [ graphviz pygments ];
};
}
@@ -0,0 +1,176 @@
#+title: Aner's Emacs Editor Configuration
#+property: header-args :results silent
* Base dev
** Require
#+begin_src emacs-lisp
(require 'azos-emacs-base)
#+end_src
* Editor modes
** Pandoc
Pandoc mode lets us export different formats to PDF.
Added for use with markdown.
Binding to startup is 'C-c /'
#+begin_src emacs-lisp
(use-package pandoc-mode
:hook
(markdown-mode . pandoc-mode))
#+end_src
** Graphviz
#+begin_src emacs-lisp
(use-package graphviz-dot)
#+end_src
** Markdown
Based on [[https://www.reddit.com/r/emacs/comments/u5owr4/how_to_enable_variablepitchmode_for_markdownmode/][this]] post
detailing variable pitch.
We default to github-flavored markdown and show it as variable pitch.
#+begin_src emacs-lisp
(use-package markdown-mode
:mode (("\\.md$" . gfm-mode)
("\\.mkd$" . gfm-mode))
:hook (gfm-mode . variable-pitch-mode)
:diminish markdown-live-preview-mode
:config
(when (bound-and-true-p lsp-mode)
(variable-pitch-mode -1))
(set-face-attribute 'markdown-pre-face nil
:background "LemonChiffon1" :extend t)
)
#+end_src
Let's add a TOC
#+begin_src emacs-lisp
(use-package markdown-toc)
#+end_src
* ORG
** PDF exporting
#+begin_src emacs-lisp
(setq org-latex-listings 'minted
org-export-babel-evaluate nil
org-latex-pdf-process
(list (concat "latexmk -xelatex -shell-escape -interaction=nonstopmode "
"-output-directory=%o %f ; latexmk -c %f")))
(require 'ox-latex)
(unless (boundp 'org-latex-classes)
(setq org-latex-classes nil))
#+end_src
This code removes unecessary files after each export
#+begin_src emacs-lisp
(add-to-list 'org-latex-logfiles-extensions "tex")
#+end_src
Creating classes
#+begin_src emacs-lisp
(defvar anerenv/latex-class-common-header
"[DEFAULT-PACKAGES]
\\usepackage{polyglossia}
\\usepackage{tabularx}
\\usepackage[cache=false]{minted}
\\usepackage{xcolor}
\\usepackage{indentfirst}
\\usepackage{amsfonts}
\\usepackage{transparent}
\\usepackage{amsmath}
\\usepackage{braket}
\\usepackage{dsfont}
\\definecolor{codebg}{rgb}{0.95,0.95,0.95}
\\setdefaultlanguage{english}
\\setlength{\\parindent}{0in}
\\DeclareMathOperator*{\\argmax}{arg\\,max}
\\DeclareMathOperator*{\\argmin}{arg\\,min}
\\newfontfamily\\hebrewfont{LiberationSans}[Script=Hebrew]
\\newfontfamily\\hebrewfonttt{LiberationSans}[Script=Hebrew]
\\newfontfamily\\hebrewfontsf{LiberationSans}[Script=Hebrew]
\\setotherlanguage{hebrew}
" "Default common class header")
(setq org-latex-classes
(list (list "article"
(concat "\\documentclass{article}
" anerenv/latex-class-common-header
"\\setminted{
bgcolor=codebg,
breaklines=true,
mathescape,
fontsize=\\scriptsize,
linenos=false,
}
")
'("\\section{%s}" . "\\section*{%s}")
'("\\subsection{%s}" . "\\subsection*{%s}")
'("\\subsubsection{%s}" . "\\subsubsection*{%s}")
'("\\paragraph{%s}" . "\\paragraph*{%s}")
'("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
(list "beamer"
(concat "\\documentclass{beamer}
" anerenv/latex-class-common-header
"\\setminted{
bgcolor={},
breaklines=true,
mathescape,
fontsize=\\scriptsize,
linenos=false,
}
")
'("\\section{%s}" . "\\section*{%s}")
'("\\subsection{%s}" . "\\subsection*{%s}")
'("\\subsubsection{%s}" . "\\subsubsection*{%s}")
'("\\paragraph{%s}" . "\\paragraph*{%s}")
'("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
)
#+end_src
This should render Hebrew text.
#+begin_export latex
\begin{hebrew}
#+end_export
זה אמור לעבוד
#+begin_export latex
\end{hebrew}
#+end_export
** DOCX exporting
Taken from https://www.reddit.com/r/emacs/comments/zjv1gj/org_files_to_docx/
#+begin_src emacs-lisp
(defun anerenv/org/export-docx-with-pandoc ()
"Use Pandoc to convert .org to .docx.
Comments:
- The `-N' flag numbers the headers lines.
- Use the `--from org' flag to have this function work on files
that are in Org syntax but do not have a .org extension"
(interactive)
(message "exporting .org to .docx")
(shell-command
(concat "pandoc -N --from org " (buffer-file-name)
" -o "
(file-name-sans-extension (buffer-file-name))
(format-time-string "-%Y-%m-%d-%H%M%S") ".docx")))
#+end_src
@@ -0,0 +1,40 @@
{ lib, config, pkgs, azos-utils, ... }:
let
isEnabled =
config.azos.tex.enable && config.azos.suites.editor.enable;
in
{
options.azos.tex.enable = (azos-utils.mkFeatureEnableOption {});
options.azos.tex.pkgs = lib.mkOption{
default = [];
description = "List of packages for tex.";
};
config = lib.mkIf isEnabled {
azos.tex.pkgs = with pkgs.texlive; [
combined.scheme-basic
dvisvgm
dvipng
wrapfig
amsmath
ulem
hyperref
capt-of
polyglossia
xcolor
amsmath
amsfonts
braket
hebrew-fonts
];
home.packages = with pkgs; [(texlive.combine azos.tex.pkgs)];
};
imports = [
];
}
@@ -0,0 +1,10 @@
{ lib, config, pkgs, options, azos-utils, ... }:
let
cfg = config.azos.suites.base;
in
{
options.azos.suites.station.enable = azos-utils.mkSuiteEnableOption {};
config = lib.mkIf cfg.enable {
};
}
+49
View File
@@ -0,0 +1,49 @@
{ lib, ... }:
{
mkFeatureEnableOption = { ... } @ attrs :
lib.mkOption (lib.mergeAttrs attrs {
default = true;
example = true;
type = lib.types.bool;
});
mkSuiteEnableOption = { ... } @ attrs :
lib.mkOption (lib.mergeAttrs attrs {
default = false;
example = true;
type = lib.types.bool;
});
trivialFromOrg = { ... } @ attrs : (
lib.mergeAttrs attrs {
preBuild = ''
for file in ./*.org
do
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"$file\" (concat (file-name-sans-extension \"$file\") \".el\") \"emacs-lisp\")"
done
'';
unpackCmd = ''
case "$curSrc" in
*.el)
# keep original source filename without the hash
local filename=$(basename "$curSrc")
filename="''${filename:33}"
cp $curSrc $filename
chmod +w $filename
sourceRoot="."
;;
*.org)
# keep original source filename without the hash
local filename=$(basename "$curSrc")
filename="''${filename:33}"
cp $curSrc $filename
chmod +w $filename
sourceRoot="."
;;
*)
_defaultUnpack "$curSrc"
;;
esac
'';
});
}