diff --git a/elixir/.envrc b/elixir/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/elixir/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/elixir/flake.nix b/elixir/flake.nix new file mode 100644 index 0000000..7c05db8 --- /dev/null +++ b/elixir/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Nix-flake Elixir development environment (adds nodejs and fly.io)"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + inherit (pkgs.lib) optional optionals; + pkgs = import nixpkgs { inherit system; }; + + elixir = pkgs.beam.packages.erlang.elixir; + in + with pkgs; + { + devShell = pkgs.mkShell { + buildInputs = [ + bashInteractive + elixir + elixir_ls + nodejs + glibcLocales + flyctl + ] ++ optional stdenv.isLinux inotify-tools + ++ optional stdenv.isDarwin terminal-notifier + ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + CoreFoundation + CoreServices + ]); + }; + }); +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..57a3b39 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "Ryan's Nix flake templates"; + + outputs = { self }: { + templates = { + python = { + path = ./python; + description = "Python shell flake"; + }; + + elixir = { + path = ./elixir; + description = "Elixir flake"; + }; + + latex = { + path = ./latex; + description = "LaTeX flake"; + }; + + raw = { + path = ./raw; + description = "Raw flake"; + }; + }; + }; +} diff --git a/latex/.envrc b/latex/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/latex/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/latex/.gitignore b/latex/.gitignore new file mode 100644 index 0000000..8a26d65 --- /dev/null +++ b/latex/.gitignore @@ -0,0 +1,306 @@ +/result +/.direnv + +*.pdf + +## Core latex/pdflatex auxiliary files: +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.fmt +*.fot +*.cb +*.cb2 +.*.lb + +## Intermediate documents: +*.dvi +*.xdv +*-converted-to.* +# these rules might exclude image files for figures etc. +# *.ps +# *.eps +# *.pdf + +## Generated if empty string is given at "Please type another file name for output:" +.pdf + +## Bibliography auxiliary files (bibtex/biblatex/biber): +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.run.xml + +## Build tool auxiliary files: +*.fdb_latexmk +*.synctex +*.synctex(busy) +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync + +## Build tool directories for auxiliary files +# latexrun +latex.out/ + +## Auxiliary and intermediate files from other packages: +# algorithms +*.alg +*.loa + +# achemso +acs-*.bib + +# amsthm +*.thm + +# beamer +*.nav +*.pre +*.snm +*.vrb + +# changes +*.soc + +# comment +*.cut + +# cprotect +*.cpt + +# elsarticle (documentclass of Elsevier journals) +*.spl + +# endnotes +*.ent + +# fixme +*.lox + +# feynmf/feynmp +*.mf +*.mp +*.t[1-9] +*.t[1-9][0-9] +*.tfm + +#(r)(e)ledmac/(r)(e)ledpar +*.end +*.?end +*.[1-9] +*.[1-9][0-9] +*.[1-9][0-9][0-9] +*.[1-9]R +*.[1-9][0-9]R +*.[1-9][0-9][0-9]R +*.eledsec[1-9] +*.eledsec[1-9]R +*.eledsec[1-9][0-9] +*.eledsec[1-9][0-9]R +*.eledsec[1-9][0-9][0-9] +*.eledsec[1-9][0-9][0-9]R + +# glossaries +*.acn +*.acr +*.glg +*.glo +*.gls +*.glsdefs +*.lzo +*.lzs +*.slg +*.slo +*.sls + +# uncomment this for glossaries-extra (will ignore makeindex's style files!) +# *.ist + +# gnuplot +*.gnuplot +*.table + +# gnuplottex +*-gnuplottex-* + +# gregoriotex +*.gaux +*.glog +*.gtex + +# htlatex +*.4ct +*.4tc +*.idv +*.lg +*.trc +*.xref + +# hyperref +*.brf + +# knitr +*-concordance.tex +# TODO Uncomment the next line if you use knitr and want to ignore its generated tikz files +# *.tikz +*-tikzDictionary + +# listings +*.lol + +# luatexja-ruby +*.ltjruby + +# makeidx +*.idx +*.ilg +*.ind + +# minitoc +*.maf +*.mlf +*.mlt +*.mtc[0-9]* +*.slf[0-9]* +*.slt[0-9]* +*.stc[0-9]* + +# minted +_minted* +*.pyg + +# morewrites +*.mw + +# newpax +*.newpax + +# nomencl +*.nlg +*.nlo +*.nls + +# pax +*.pax + +# pdfpcnotes +*.pdfpc + +# sagetex +*.sagetex.sage +*.sagetex.py +*.sagetex.scmd + +# scrwfile +*.wrt + +# svg +svg-inkscape/ + +# sympy +*.sout +*.sympy +sympy-plots-for-*.tex/ + +# pdfcomment +*.upa +*.upb + +# pythontex +*.pytxcode +pythontex-files-*/ + +# tcolorbox +*.listing + +# thmtools +*.loe + +# TikZ & PGF +*.dpth +*.md5 +*.auxlock + +# titletoc +*.ptc + +# todonotes +*.tdo + +# vhistory +*.hst +*.ver + +# easy-todo +*.lod + +# xcolor +*.xcp + +# xmpincl +*.xmpi + +# xindy +*.xdy + +# xypic precompiled matrices and outlines +*.xyc +*.xyd + +# endfloat +*.ttt +*.fff + +# Latexian +TSWLatexianTemp* + +## Editors: +# WinEdt +*.bak +*.sav + +# Texpad +.texpadtmp + +# LyX +*.lyx~ + +# Kile +*.backup + +# gummi +.*.swp + +# KBibTeX +*~[0-9]* + +# TeXnicCenter +*.tps + +# auto folder when using emacs and auctex +./auto/* +*.el + +# expex forward references with \gathertags +*-tags.tex + +# standalone packages +*.sta + +# Makeindex log files +*.lpz + +# xwatermark package +*.xwm + +# REVTeX puts footnotes in the bibliography by default, unless the nofootinbib +# option is specified. Footnotes are the stored in a file with suffix Notes.bib. +# Uncomment the next line to have this generated file ignored. +#*Notes.bib \ No newline at end of file diff --git a/latex/document.tex b/latex/document.tex new file mode 100644 index 0000000..89bfb2d --- /dev/null +++ b/latex/document.tex @@ -0,0 +1,7 @@ +% !TEX root = document.txt + +\documentclass[a4paper]{article} + +\begin{document} +Hello, World! +\end{document} \ No newline at end of file diff --git a/latex/flake.nix b/latex/flake.nix new file mode 100644 index 0000000..32f237f --- /dev/null +++ b/latex/flake.nix @@ -0,0 +1,50 @@ +{ + description = "LaTeX flake"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = github:numtide/flake-utils; + }; + outputs = { self, nixpkgs, flake-utils }: + let + rootName = "document"; + in + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + tex = pkgs.texlive.combine { + inherit (pkgs.texlive) scheme-small latex-bin latexmk + metafont + chktex + latexindent + ; + }; + in + rec { + packages = { + document = pkgs.stdenvNoCC.mkDerivation rec { + name = rootName; + src = self; + buildInputs = [ pkgs.coreutils tex ]; + phases = [ "unpackPhase" "buildPhase" "installPhase" ]; + buildPhase = '' + export PATH="${pkgs.lib.makeBinPath buildInputs}"; + mkdir -p .cache/texmf-var + env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \ + latexmk -interaction=nonstopmode -pdf ${rootName}.tex + ''; + installPhase = '' + mkdir -p $out + cp ${rootName}.pdf $out/ + ''; + }; + default = packages.document; + }; + + devShells.default = pkgs.mkShellNoCC { + buildInputs = [ + tex + ]; + }; + }); +} diff --git a/python/.envrc b/python/.envrc new file mode 100644 index 0000000..958a322 --- /dev/null +++ b/python/.envrc @@ -0,0 +1,2 @@ +nix_direnv_watch_file requirements.txt +use flake \ No newline at end of file diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000..2320c2c --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,3 @@ +__pycache__ + +/.direnv \ No newline at end of file diff --git a/python/README.md b/python/README.md new file mode 100644 index 0000000..779158c --- /dev/null +++ b/python/README.md @@ -0,0 +1,45 @@ +# python-shell + +## Using + +- dev shell: `nix develop` +- edit `requirements.txt` for dev shell requirements + +## Jupyter in VSCode + +To use jupyter in VSCode add these requirements: + +``` +ipykernel +nbformat +ipywidgets +``` + +## Updating mach-nix pypi deps db + +Add to inputs: + +```nix +pypi-deps-db = { + url = "github:davhau/pypi-deps-db/0000000000000000000000000000000000000000"; + flake = false; +}; +mach-nix.inputs.pypi-deps-db.follows = "pypi-deps-db"; +``` + +## Adding git dependency + +Add to mkPython ([more info](https://github.com/DavHau/mach-nix/blob/master/examples.md)): + +```nix +packagesExtra = [ + (mach.buildPythonPackage + { + src = builtins.fetchGit { + url = "https://github.com/user/repo"; + ref = "branch"; + rev = "0000000000000000000000000000000000000000"; + }; + }) +]; +``` diff --git a/python/flake.nix b/python/flake.nix new file mode 100644 index 0000000..a2cc896 --- /dev/null +++ b/python/flake.nix @@ -0,0 +1,35 @@ +{ + description = "Python shell flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + mach-nix.url = "github:davhau/mach-nix"; + }; + + outputs = { self, nixpkgs, mach-nix, flake-utils, ... }: + let + pythonVersion = "python39"; + in + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + mach = mach-nix.lib.${system}; + + pythonEnv = mach.mkPython { + python = pythonVersion; + requirements = builtins.readFile ./requirements.txt; + }; + in + { + devShells.default = pkgs.mkShellNoCC { + packages = [ pythonEnv ]; + + shellHook = '' + export PYTHONPATH="${pythonEnv}/bin/python" + ''; + }; + } + ); +} diff --git a/python/main.py b/python/main.py new file mode 100755 index 0000000..dea7809 --- /dev/null +++ b/python/main.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python + +print("Hello world!") \ No newline at end of file diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/raw/.envrc b/raw/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/raw/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/raw/flake.nix b/raw/flake.nix new file mode 100644 index 0000000..6a62dce --- /dev/null +++ b/raw/flake.nix @@ -0,0 +1,32 @@ +{ + description = "Nix-flake development folder, raw"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + inherit (pkgs.lib) optional optionals; + pkgs = import nixpkgs { inherit system; }; + + + in + with pkgs; + { + devShell = pkgs.mkShell { + buildInputs = [ + bashInteractive + glibcLocales + git + emacs-nox + + ] ++ optional stdenv.isLinux inotify-tools + ++ optional stdenv.isDarwin terminal-notifier + ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + CoreFoundation + CoreServices + ]); + }; + }); +}