Change how overlay is used and remove devshell from template

This commit is contained in:
Tim Schubert 2023-12-03 10:28:34 +01:00
parent 095a81b8c1
commit 62e5b34e5d
Signed by: dadada
SSH key fingerprint: SHA256:bFAjFH3hR8zRBaJjzQDjc3o4jqoq5EZ87l+KXEjxIz0
6 changed files with 92 additions and 133 deletions

31
flake.lock generated
View file

@ -1,12 +1,15 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1667077288, "lastModified": 1694529238,
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,9 +20,10 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 0, "lastModified": 1701389149,
"narHash": "sha256-3nD7iQXd/J6KjkT8IjozTuA5p8qjiLKTxvOUmH+AzNM=", "narHash": "sha256-rU1suTIEd5DGCaAXKW6yHoCfR1mnYjOXQFOaH7M23js=",
"path": "/nix/store/ig0dn500x8lm7mjq8sp3s2k1hpji0xxj-source", "path": "/nix/store/gjd1iiwgwv7x29b21ng2dpysbgjp6kxr-source",
"rev": "5de0b32be6e85dc1a9404c75131316e4ffbc634c",
"type": "path" "type": "path"
}, },
"original": { "original": {
@ -32,6 +36,21 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -1,5 +1,5 @@
{ {
description = "tubslatex"; description = "tubslatex-nix";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
@ -7,23 +7,30 @@
flake-utils.lib.eachDefaultSystem flake-utils.lib.eachDefaultSystem
(system: (system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs { inherit system; };
inherit system;
overlays = [ self.overlays.default ];
};
in in
{ {
packages = rec { packages = rec {
default = tubslatex; default = tubslatex;
tubslatex = pkgs.tubslatex; tubslatex = pkgs.callPackage ./tubslatex.nix { };
}; };
checks = { checks = {
format = pkgs.runCommand "format" { buildInputs = [ pkgs.nixpkgs-fmt ]; } "nixpkgs-fmt --check ${./.} && touch $out"; format = pkgs.runCommand "format" { buildInputs = [ pkgs.nixpkgs-fmt ]; } "nixpkgs-fmt --check ${./.} && touch $out";
testOverlay = pkgs.mkShell { testOverlay =
buildInputs = [ pkgs.texliveWithTubslatex ]; let
shellHook = ''Shell created''; pkgs = import nixpkgs {
}; inherit system;
config.allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [
"tubslatex"
];
overlays = [ self.overlays.default ];
};
in
pkgs.mkShell {
buildInputs = [ pkgs.texliveWithTubslatex ];
shellHook = ''Shell created'';
};
}; };
formatter = pkgs.nixpkgs-fmt; formatter = pkgs.nixpkgs-fmt;
@ -54,7 +61,7 @@
default = thesis; default = thesis;
thesis = { thesis = {
path = ./template; path = ./template;
description = "Thesis template"; description = "tubslatex-nix thesis template";
}; };
}; };
}; };

View file

@ -9,7 +9,4 @@ thesis.pdf: thesis.tex
latexmk -interaction=batchmode -pdf thesis.tex latexmk -interaction=batchmode -pdf thesis.tex
watch: watch:
while true; do \ latexmk -pvc -pdf thesis.tex
inotifywait -qr -e modify -e create -e delete -e move *tex; \
$(MAKE); \
done

View file

@ -1,46 +0,0 @@
imports = [ "git/hooks" ]
packages = [ "texliveWithTubslatex", "inotify-tools" ]
[devshell]
name = "thesis"
[[commands]]
name = "format"
command = "nix fmt"
help = "Formats the nix files"
category = "development"
[[commands]]
name = "update"
command = "nix flake update --commit-lock-file"
help = "Updates the dependencies"
category = "development"
[[commands]]
name = "check"
command = "nix flake check"
help = "Checks if this flake is valid"
category = "development"
[[commands]]
name = "build-thesis"
command = "make thesis.pdf"
category = "outputs"
help = "Builds the thesis"
[[commands]]
name = "clean"
command = "make clean"
category = "outputs"
help = "Cleans the build directory"
[git.hooks]
enable = true
[git.hooks.pre-commit]
text = """
FILES=$(git diff --cached --name-only --diff-filter=ACMR -- *.nix| sed -e 's| |\\ |g')
[ -z "$FILES" ] && exit 0
echo $FILES | xargs nix fmt
echo $FILES | xargs git add
exit 0"""

80
template/flake.lock generated
View file

@ -2,30 +2,31 @@
"nodes": { "nodes": {
"devshell": { "devshell": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1678957337, "lastModified": 1698410321,
"narHash": "sha256-Gw4nVbuKRdTwPngeOZQOzH/IFowmz4LryMPDiJN/ah4=", "narHash": "sha256-MphuSlgpmKwtJncGMohryHiK55J1n6WzVQ/OAfmfoMc=",
"owner": "numtide", "path": "/nix/store/nc201gqv1qiz6nw4ldh9xrz4k41dvkg5-source",
"repo": "devshell", "rev": "1aed986e3c81a4f6698e85a7452cbfcc4b31a36e",
"rev": "3e0e60ab37cd0bf7ab59888f5c32499d851edb47", "type": "path"
"type": "github"
}, },
"original": { "original": {
"owner": "numtide", "id": "devshell",
"repo": "devshell", "type": "indirect"
"type": "github"
} }
}, },
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems_2"
},
"locked": { "locked": {
"lastModified": 1642700792, "lastModified": 1694529238,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -35,24 +36,6 @@
} }
}, },
"flake-utils_2": { "flake-utils_2": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": { "locked": {
"lastModified": 1667077288, "lastModified": 1667077288,
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
@ -85,10 +68,10 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1681269223, "lastModified": 1701389149,
"narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=", "narHash": "sha256-rU1suTIEd5DGCaAXKW6yHoCfR1mnYjOXQFOaH7M23js=",
"path": "/nix/store/dnj69agbi6dz7985gvcbmv40wk1skvmy-source", "path": "/nix/store/gjd1iiwgwv7x29b21ng2dpysbgjp6kxr-source",
"rev": "87edbd74246ccdfa64503f334ed86fa04010bab9", "rev": "5de0b32be6e85dc1a9404c75131316e4ffbc634c",
"type": "path" "type": "path"
}, },
"original": { "original": {
@ -111,7 +94,7 @@
"root": { "root": {
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"tubslatex": "tubslatex" "tubslatex": "tubslatex"
} }
@ -131,17 +114,32 @@
"type": "github" "type": "github"
} }
}, },
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tubslatex": { "tubslatex": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_3", "flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1681570146, "lastModified": 1681572214,
"narHash": "sha256-+x5huf47ecM+FCjOWB7hka/DNHg81gxjL85qaTLUE/s=", "narHash": "sha256-YMbwKED+0PKsGP9XcGw392MG5OT0k/NsWKthn7xVvYQ=",
"owner": "dadada", "owner": "dadada",
"repo": "tubslatex-nix", "repo": "tubslatex-nix",
"rev": "f1b9082f4eddffdf579f5f0c61973b6aa21844d7", "rev": "095a81b8c163afd01cfa2af87920e1a4114dbde5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,41 +1,26 @@
{ {
description = "Thesis"; description = "Thesis";
inputs.flake-utils.url = github:numtide/flake-utils; inputs.flake-utils.url = github:numtide/flake-utils;
inputs.devshell.url = github:numtide/devshell;
inputs.tubslatex.url = "github:dadada/tubslatex-nix"; inputs.tubslatex.url = "github:dadada/tubslatex-nix";
outputs = { self, flake-utils, nixpkgs, devshell, tubslatex }@inputs: outputs = { self, flake-utils, nixpkgs, devshell, tubslatex }@inputs:
flake-utils.lib.eachDefaultSystem flake-utils.lib.eachDefaultSystem
(system: (system:
let let
tubslatexOverlay = tubslatex.overlays.default;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ tubslatexOverlay ]; # Allow use of tubslatex although it is under an unfree license
config.allowUnfree = true;
overlays = [ tubslatex.overlays.default ];
}; };
in in
{ {
devShells.default = devShells.default = pkgs.mkShell {
let packages = [ pkgs.texliveWithTubslatex ];
pkgs = import nixpkgs { shellHook = ''
inherit system; echo 'Run `make` to build the thesis.pdf or `make watch` to continuously watch for changes.'
config.allowUnfree = true; '';
overlays = [
devshell.overlays.default
tubslatexOverlay
];
};
in
pkgs.devshell.mkShell {
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
};
checks = {
format = pkgs.runCommand "format" { buildInputs = [ pkgs.nixpkgs-fmt ]; } "nixpkgs-fmt --check ${./.} && touch $out";
}; };
formatter = pkgs.nixpkgs-fmt;
packages.default = pkgs.callPackage packages.default = pkgs.callPackage
({ lib, texliveWithTubslatex, stdenvNoCC, ... }: stdenvNoCC.mkDerivation { ({ lib, texliveWithTubslatex, stdenvNoCC, ... }: stdenvNoCC.mkDerivation {
pname = "thesis"; pname = "thesis";
@ -48,8 +33,7 @@
cp thesis.pdf $out cp thesis.pdf $out
''; '';
meta = with lib; { meta = with lib; {
description = "Master thesis proposal"; description = "Master thesis";
maintainers = [ "dadada" ];
platforms = platforms.all; platforms = platforms.all;
license = licenses.proprietary; license = licenses.proprietary;
}; };