Archived
Template
1
0

add nix flake and related files

This commit is contained in:
surtur 2022-11-12 23:05:58 +01:00
parent fb5545489b
commit 36ad5c4a39
Signed by: wanderer
SSH Key Fingerprint: SHA256:MdCZyJ2sHLltrLBp0xQO0O1qTW9BT/xl5nXkDvhlMCI
7 changed files with 175 additions and 0 deletions

7
.envrc Normal file

@ -0,0 +1,7 @@
use flake
# ref: https://github.com/direnv/direnv/wiki/Vim
# comment out if not planning to use this
#add_extra_vimrc
# vim: ff=unix ft=sh

1
.gitignore vendored

@ -1,3 +1,4 @@
.direnv
# backup files # backup files
*.tex\~ *.tex\~
# vim swap files # vim swap files

@ -11,6 +11,10 @@ prerequisities:
* `make` * `make`
* [`distrobox`](https://github.com/89luca89/distrobox) * [`distrobox`](https://github.com/89luca89/distrobox)
alternatively, when using [Nix](https://builtwithnix.org/), just run `direnv
allow`, `nix develop` (with [flakes](https://nixos.wiki/wiki/Flakes) enabled)
or `nix shell` (when using nix without flakes).
### instructions: ### instructions:
* clone this repo and cd into it * clone this repo and cd into it
```sh ```sh

16
default.nix Normal file

@ -0,0 +1,16 @@
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}
)
.defaultNix

26
flake.lock Normal file

@ -0,0 +1,26 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1668288759,
"narHash": "sha256-olmFmG3er2sYTnwcZSjfxf/SiZo9mNgfGVA/O05DIIg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "eda76eb80e5a98f1cfdfe925032aae251f812eef",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

105
flake.nix Normal file

@ -0,0 +1,105 @@
{
# check out https://git.dotya.ml/mirre-mt/thesis-tmpl/
description = "Thesis tmpl";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
};
outputs = {
self,
nixpkgs,
...
}: let
# to work with older version of flakes
lastModifiedDate =
self.lastModifiedDate or self.lastModified or "19700101";
supportedSystems = ["aarch64-linux" "x86_64-linux" "x86_64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
thesisType = ""; # ms, bc
throw "Set thesis type!"
documentName = "thesis";
pname = thesisType + "_" + documentName;
version = "0.0.1";
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
nixpkgsFor = forAllSystems (
system:
import nixpkgs {
inherit system;
overlays = [self.overlay];
}
);
in rec {
formatter = forAllSystems (
system:
nixpkgsFor.${system}.alejandra
);
overlay = with pkgs;
final: prev: {
watcher = with final;
writeScriptBin "watch" ''
out=".latexmkout"
mkdir "$out"
latexmk \
-pvc \
-outdir="$out" \
-pdf \
-pdflatex="pdflatex -synctex=1 -file-line-error -interaction=nonstopmode" \
-use-make ${documentName}.tex
rm -r "$out"
'';
};
packages = with pkgs;
forAllSystems (system: {
inherit (nixpkgsFor.${system}) watcher;
});
defaultPackage =
forAllSystems (system: self.packages."${system}".watcher);
apps = forAllSystems (system: rec {
watch = {
type = "app";
program = "${self.packages."${system}".watcher}/bin/watch";
};
default = watch;
});
devShells = with pkgs;
forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [self.overlay];
};
watcher = pkgs.writeShellScriptBin "watcher" ''
out=".latexmkout"
mkdir "$out"
latexmk \
-pvc \
-outdir="$out" \
-pdf \
-pdflatex="pdflatex -synctex=1 -file-line-error -interaction=nonstopmode" \
-use-make ${documentName}.tex
rm -r "$out"
'';
in {
default = nixpkgsFor.${system}.mkShell {
name = "${pname}-" + version;
shellHook = ''
echo " -- in ${pname} dev shell..."
'';
packages = with nixpkgsFor.${system}; [
watcher
gnumake
alejandra
distrobox
podman
];
};
});
};
}

16
shell.nix Normal file

@ -0,0 +1,16 @@
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}
)
.shellNix