Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
feat(flake): add nix-pre-commit checks with typos
Browse files Browse the repository at this point in the history
  • Loading branch information
storopoli committed Nov 27, 2023
1 parent 3981c74 commit a5ef597
Show file tree
Hide file tree
Showing 13 changed files with 458 additions and 30 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/build-slides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
env:
working-directory: ./slides
defaults:
run:
working-directory: ${{ env.working-directory }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -31,6 +25,9 @@ jobs:
- name: Cache Nix artifacts
uses: DeterminateSystems/magic-nix-cache-action@v2

- name: Nix Flake Check
run: nix flake check -L

- name: Build Slides
run: nix build -L

Expand All @@ -41,5 +38,5 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: output
path: ./slides/slides.pdf
path: ./slides.pdf
if-no-files-found: error
11 changes: 4 additions & 7 deletions .github/workflows/release-slides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
env:
working-directory: ./slides
defaults:
run:
working-directory: ${{ env.working-directory }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -27,6 +21,9 @@ jobs:
- name: Cache Nix artifacts
uses: DeterminateSystems/magic-nix-cache-action@v2

- name: Nix Flake Check
run: nix flake check -L

- name: Build Slides
run: nix build -L

Expand All @@ -37,4 +34,4 @@ jobs:
uses: ncipollo/release-action@v1
id: release
with:
artifacts: ./slides/slides.pdf
artifacts: ./slides.pdf
21 changes: 21 additions & 0 deletions .github/workflows/update_flake_lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update Flake Lock File
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00

jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v7
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v20
with:
pr-title: "fix: update flake.lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR
dependencies
automated
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,4 @@ TSWLatexianTemp*

# glossaries
*.glstex
.pre-commit-config.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ These were tested with `Turing.jl` version 0.21.9 and Julia 1.7.3.
to a safe public or private well in the nearby area
and the survey was conducted several years later to
learn which of the affected residents had switched wells.
Souce: Gelman and Hill (2007).
Source: Gelman and Hill (2007).
- `esoph` (ordinal regression): data from a case-control study of (o)esophageal cancer in Ille-et-Vilaine, France.
Source: Breslow and Day (1980).
- `roaches` (Poisson regression): data on the efficacy of a pest management system at reducing the number of roaches in urban apartments.
Expand Down Expand Up @@ -280,6 +280,6 @@ Or in BibTeX format (LaTeX):

## License

This content is licensed under [Creative Commons Attribution-ShareAlike 4.0 Internacional](http://creativecommons.org/licenses/by-sa/4.0/).
This content is licensed under [Creative Commons Attribution-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).

[![CC BY-SA 4.0](https://licensebuttons.net/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
23 changes: 23 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[default]
extend-ignore-re = [
# citation keys
"textcite\\{.*\\}",
]

[default.extend-words]
# code stuff
lik = "lik"
# surnames
Yau = "Yau"

[type.bib]
extend-glob = ["*.bib"]
check-file = false

[type.sty]
extend-glob = ["*.sty"]
check-file = false

[type.gitignore]
extend-glob = [".gitignore"]
check-file = false
186 changes: 186 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";

outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
tex = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-small;
inherit (pkgs.texlive) latexmk pgf pgfplots tikzsymbols biblatex beamer;
inherit (pkgs.texlive) silence appendixnumberbeamer fira fontaxes mwe;
inherit (pkgs.texlive) noto csquotes babel helvetic transparent;
inherit (pkgs.texlive) xpatch hyphenat wasysym algorithm2e listings;
inherit (pkgs.texlive) lstbayes ulem subfigure ifoddpage relsize;
inherit (pkgs.texlive) adjustbox media9 ocgx2 biblatex-apa wasy;
};
julia = pkgs.julia-bin.overrideDerivation (oldAttrs: { doInstallCheck = false; });

in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
typos.enable = true;
};
};
};

devShells.default = pkgs.mkShell {
packages = with pkgs;[
bashInteractive
# pdfpc # FIXME: broken on darwin
typos
cmdstan
julia
];

inherit (self.checks.${system}.pre-commit-check) shellHook;
};
packages.default = pkgs.stdenvNoCC.mkDerivation rec {
name = "slides";
src = self;
buildInputs = with pkgs; [
coreutils
tex
gnuplot
biber
];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
export PATH="${pkgs.lib.makeBinPath buildInputs}";
export HOME=$(pwd)
latexmk -pdflatex -shell-escape slides/slides.tex
'';
installPhase = ''
mkdir -p $out
cp slides.pdf $out/
'';
};
});
}
2 changes: 1 addition & 1 deletion slides/02-Statistical_Distributions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ \subsubsection{Log-Normal}
\subsubsection{Exponential}
\begin{frame}{Exponential}
The exponential distribution is the probability distribution of the time
between events that occurs in a continuos manner, are independent,
between events that occurs in a continuous manner, are independent,
and have constant mean rate of occurrence.
\vfill
The exponential distribution has one parameter and its notation is
Expand Down
4 changes: 2 additions & 2 deletions slides/10-Hierarchical_Models.tex
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ \subsection{Hyperprior}
$$
Here $\mathbf{y}$ is a variable of interest that belongs to distinct groups.
$\boldsymbol{\theta}$, a prior for $\mathbf{y}$,
is a vector of group-leve parameters with their own prior
(which becomes a hiperprior) $\phi$.
is a vector of group-level parameters with their own prior
(which becomes a hyperprior) $\phi$.
\end{frame}

\subsection{Frequentist versus Bayesian Approaches}
Expand Down
Loading

0 comments on commit a5ef597

Please sign in to comment.