mirror of
https://github.com/hmemcpy/milewski-ctfp-pdf.git
synced 2024-11-25 07:52:03 +03:00
nix: refactor Nix flake files (#323)
This commit is contained in:
parent
73f788e8e7
commit
1a0dff2289
@ -4,3 +4,4 @@
|
|||||||
/docs/
|
/docs/
|
||||||
/build/
|
/build/
|
||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
|
flake.lock
|
||||||
|
136
flake.lock
136
flake.lock
@ -1,63 +1,79 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-parts": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1680392223,
|
"lastModified": 1696343447,
|
||||||
"narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=",
|
"narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5",
|
"rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "flake-parts",
|
"id": "flake-parts",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1680942619,
|
|
||||||
"narHash": "sha256-kpCW1IegAZfEjCVJW7IPN/hEtRL/9dxaFFYiHS5qVAk=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "6f95dd4fd050daf017cae2dfeb1cea1ec0e4c1a1",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-lib": {
|
|
||||||
"locked": {
|
|
||||||
"dir": "lib",
|
|
||||||
"lastModified": 1680213900,
|
|
||||||
"narHash": "sha256-cIDr5WZIj3EkKyCgj/6j3HBH4Jj1W296z7HTcWj1aMA=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "e3652e0735fbec227f342712f180f4f21f0594f2",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"dir": "lib",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-parts": "flake-parts",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"root": "root",
|
"nixpkgs": {
|
||||||
"version": 7
|
"locked": {
|
||||||
|
"lastModified": 1697915759,
|
||||||
|
"narHash": "sha256-WyMj5jGcecD+KC8gEs+wFth1J1wjisZf8kVZH13f1Zo=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "51d906d2341c9e866e48c2efcaac0f2d70bfd43e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "lib",
|
||||||
|
"lastModified": 1696019113,
|
||||||
|
"narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "lib",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"systems": "systems"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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",
|
||||||
|
"version": 7
|
||||||
}
|
}
|
||||||
|
276
flake.nix
276
flake.nix
@ -2,141 +2,128 @@
|
|||||||
description = "Category Theory for Programmers";
|
description = "Category Theory for Programmers";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
inputs.systems.url = "github:nix-systems/default";
|
||||||
|
|
||||||
outputs = inputs @ {
|
outputs = inputs@{ self, flake-parts, nixpkgs, ... }:
|
||||||
self,
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
flake-parts,
|
systems = import inputs.systems;
|
||||||
nixpkgs,
|
|
||||||
}:
|
|
||||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
|
||||||
systems = [
|
|
||||||
"x86_64-linux"
|
|
||||||
"x86_64-darwin"
|
|
||||||
"aarch64-linux"
|
|
||||||
"aarch64-darwin"
|
|
||||||
];
|
|
||||||
|
|
||||||
perSystem = {
|
perSystem = { config, pkgs, system, lib, ... }:
|
||||||
config,
|
let
|
||||||
pkgs,
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
system,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (nixpkgs) lib;
|
|
||||||
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
########################################################################
|
||||||
|
# LaTeX Font
|
||||||
|
inconsolata-lgc-latex = pkgs.stdenvNoCC.mkDerivation {
|
||||||
|
name = "inconsolata-lgc-latex";
|
||||||
|
pname = "inconsolata-lgc-latex";
|
||||||
|
|
||||||
########################################################################
|
src = pkgs.inconsolata-lgc;
|
||||||
# LaTeX Font
|
|
||||||
inconsolata-lgc-latex = pkgs.stdenvNoCC.mkDerivation {
|
|
||||||
name = "inconsolata-lgc-latex";
|
|
||||||
pname = "inconsolata-lgc-latex";
|
|
||||||
|
|
||||||
src = pkgs.inconsolata-lgc;
|
dontConfigure = true;
|
||||||
|
sourceRoot = ".";
|
||||||
|
|
||||||
dontConfigure = true;
|
installPhase = ''
|
||||||
sourceRoot = ".";
|
runHook preInstall
|
||||||
|
|
||||||
installPhase = ''
|
find $src -name '*.ttf' -exec install -m644 -Dt $out/fonts/truetype/public/inconsolata-lgc/ {} \;
|
||||||
runHook preInstall
|
find $src -name '*.otf' -exec install -m644 -Dt $out/fonts/opentype/public/inconsolata-lgc/ {} \;
|
||||||
|
|
||||||
find $src -name '*.ttf' -exec install -m644 -Dt $out/fonts/truetype/public/inconsolata-lgc/ {} \;
|
runHook postInstall
|
||||||
find $src -name '*.otf' -exec install -m644 -Dt $out/fonts/opentype/public/inconsolata-lgc/ {} \;
|
'';
|
||||||
|
|
||||||
runHook postInstall
|
tlType = "run";
|
||||||
'';
|
|
||||||
|
|
||||||
tlType = "run";
|
|
||||||
};
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# LaTeX Environment
|
|
||||||
texliveEnv = pkgs.texlive.combine {
|
|
||||||
inherit
|
|
||||||
(pkgs.texlive)
|
|
||||||
adjustbox
|
|
||||||
alegreya
|
|
||||||
babel
|
|
||||||
bookcover
|
|
||||||
catchfile
|
|
||||||
chngcntr
|
|
||||||
collectbox
|
|
||||||
currfile
|
|
||||||
emptypage
|
|
||||||
enumitem
|
|
||||||
environ
|
|
||||||
fgruler
|
|
||||||
fontaxes
|
|
||||||
framed
|
|
||||||
fvextra
|
|
||||||
idxlayout
|
|
||||||
ifmtarg
|
|
||||||
ifnextok
|
|
||||||
ifplatform
|
|
||||||
imakeidx
|
|
||||||
import
|
|
||||||
inconsolata
|
|
||||||
l3packages
|
|
||||||
lettrine
|
|
||||||
libertine
|
|
||||||
libertinus-fonts
|
|
||||||
listings
|
|
||||||
mdframed
|
|
||||||
microtype
|
|
||||||
minifp
|
|
||||||
minted
|
|
||||||
mweights
|
|
||||||
needspace
|
|
||||||
newtx
|
|
||||||
noindentafter
|
|
||||||
nowidow
|
|
||||||
scheme-medium
|
|
||||||
subfigure
|
|
||||||
subfiles
|
|
||||||
textpos
|
|
||||||
tcolorbox
|
|
||||||
tikz-cd
|
|
||||||
titlecaps
|
|
||||||
titlesec
|
|
||||||
todonotes
|
|
||||||
trimspaces
|
|
||||||
upquote
|
|
||||||
wrapfig
|
|
||||||
xifthen
|
|
||||||
xpatch
|
|
||||||
xstring
|
|
||||||
zref
|
|
||||||
;
|
|
||||||
|
|
||||||
inconsolata-lgc-latex = {
|
|
||||||
pkgs = [inconsolata-lgc-latex];
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
commonAttrs = {
|
########################################################################
|
||||||
nativeBuildInputs = [
|
# LaTeX Environment
|
||||||
texliveEnv
|
texliveEnv = pkgs.texlive.combine {
|
||||||
(
|
inherit
|
||||||
pkgs.python3.withPackages (p: [p.pygments p.pygments-style-github])
|
(pkgs.texlive)
|
||||||
)
|
adjustbox
|
||||||
pkgs.which
|
alegreya
|
||||||
];
|
babel
|
||||||
};
|
bookcover
|
||||||
|
catchfile
|
||||||
|
chngcntr
|
||||||
|
collectbox
|
||||||
|
currfile
|
||||||
|
emptypage
|
||||||
|
enumitem
|
||||||
|
environ
|
||||||
|
fgruler
|
||||||
|
fontaxes
|
||||||
|
framed
|
||||||
|
fvextra
|
||||||
|
idxlayout
|
||||||
|
ifmtarg
|
||||||
|
ifnextok
|
||||||
|
ifplatform
|
||||||
|
imakeidx
|
||||||
|
import
|
||||||
|
inconsolata
|
||||||
|
l3packages
|
||||||
|
lettrine
|
||||||
|
libertine
|
||||||
|
libertinus-fonts
|
||||||
|
listings
|
||||||
|
mdframed
|
||||||
|
microtype
|
||||||
|
minifp
|
||||||
|
minted
|
||||||
|
mweights
|
||||||
|
needspace
|
||||||
|
newtx
|
||||||
|
noindentafter
|
||||||
|
nowidow
|
||||||
|
scheme-medium
|
||||||
|
subfigure
|
||||||
|
subfiles
|
||||||
|
textpos
|
||||||
|
tcolorbox
|
||||||
|
tikz-cd
|
||||||
|
titlecaps
|
||||||
|
titlesec
|
||||||
|
todonotes
|
||||||
|
trimspaces
|
||||||
|
upquote
|
||||||
|
wrapfig
|
||||||
|
xifthen
|
||||||
|
xpatch
|
||||||
|
xstring
|
||||||
|
zref
|
||||||
|
;
|
||||||
|
|
||||||
mkLatex = variant: edition: let
|
inconsolata-lgc-latex = {
|
||||||
maybeVariant = lib.optionalString (variant != null) "-${variant}";
|
pkgs = [ inconsolata-lgc-latex ];
|
||||||
maybeEdition = lib.optionalString (edition != null) "-${edition}";
|
};
|
||||||
variantStr =
|
};
|
||||||
if variant == null
|
|
||||||
then "reader"
|
commonAttrs = {
|
||||||
else variant;
|
nativeBuildInputs = [
|
||||||
basename = "ctfp-${variantStr}${maybeEdition}";
|
texliveEnv
|
||||||
version = self.shortRev or self.lastModifiedDate;
|
(
|
||||||
suffix = maybeVariant + maybeEdition;
|
pkgs.python3.withPackages (p: [ p.pygments p.pygments-style-github ])
|
||||||
fullname = "ctfp${suffix}";
|
)
|
||||||
in
|
pkgs.which
|
||||||
pkgs.stdenvNoCC.mkDerivation (commonAttrs
|
];
|
||||||
// {
|
};
|
||||||
|
|
||||||
|
mkLatex = variant: edition:
|
||||||
|
let
|
||||||
|
maybeVariant = lib.optionalString (variant != null) "-${variant}";
|
||||||
|
maybeEdition = lib.optionalString (edition != null) "-${edition}";
|
||||||
|
variantStr =
|
||||||
|
if variant == null
|
||||||
|
then "reader"
|
||||||
|
else variant;
|
||||||
|
basename = "ctfp-${variantStr}${maybeEdition}";
|
||||||
|
version = self.shortRev or self.lastModifiedDate;
|
||||||
|
suffix = maybeVariant + maybeEdition;
|
||||||
|
fullname = "ctfp${suffix}";
|
||||||
|
in
|
||||||
|
pkgs.stdenvNoCC.mkDerivation (commonAttrs
|
||||||
|
// {
|
||||||
inherit basename version;
|
inherit basename version;
|
||||||
name = basename;
|
name = basename;
|
||||||
|
|
||||||
@ -161,34 +148,43 @@
|
|||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = "install -m 0644 -vD ctfp.pdf \"$out/${fullname}.pdf\"";
|
installPhase = "
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
install -m 0644 -vD ctfp.pdf \"$out/${fullname}.pdf\"
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
";
|
||||||
|
|
||||||
passthru.packageName = fullname;
|
passthru.packageName = fullname;
|
||||||
});
|
});
|
||||||
|
|
||||||
editions = [null "scala" "ocaml" "reason"];
|
editions = [ null "scala" "ocaml" "reason" ];
|
||||||
variants = [null "print"];
|
variants = [ null "print" ];
|
||||||
in rec {
|
in
|
||||||
formatter = pkgs.alejandra;
|
{
|
||||||
|
formatter = pkgs.nixpkgs-fmt;
|
||||||
|
|
||||||
packages = lib.listToAttrs (lib.concatMap (variant:
|
packages = lib.listToAttrs (lib.concatMap
|
||||||
map (edition: rec {
|
(variant:
|
||||||
name = value.packageName;
|
map
|
||||||
value = mkLatex variant edition;
|
(edition: rec {
|
||||||
})
|
value = mkLatex variant edition;
|
||||||
editions)
|
name = value.packageName;
|
||||||
variants);
|
})
|
||||||
|
editions)
|
||||||
|
variants);
|
||||||
|
|
||||||
# nix develop .
|
# nix develop .
|
||||||
devShells.default = pkgs.mkShellNoCC (commonAttrs
|
devShells.default = pkgs.mkShellNoCC (commonAttrs
|
||||||
// {
|
// {
|
||||||
nativeBuildInputs =
|
nativeBuildInputs =
|
||||||
commonAttrs.nativeBuildInputs
|
commonAttrs.nativeBuildInputs
|
||||||
++ [
|
++ [
|
||||||
pkgs.git
|
pkgs.git
|
||||||
pkgs.gnumake
|
pkgs.gnumake
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user