-
Notifications
You must be signed in to change notification settings - Fork 10
/
flake.nix
105 lines (91 loc) · 2.79 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = nixpkgs.lib;
export = "(progn (require 'ox) (require 'ox-hugo) (setq org-src-preserve-indentation t) (org-hugo-export-wim-to-md :all-subtrees nil t))";
in
{
packages = rec {
readme = pkgs.stdenv.mkDerivation {
name = "cpprb-readme";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./README.org
./LICENSE
];
};
nativeBuildInputs = [
pkgs.emacs
];
buildPhase = ''
emacs --batch README.org --eval "(org-md-export-to-markdown)"
'';
installPhase = ''
mkdir -p $out
cp ./README.md $out/README.md
'';
};
python-311 = pkgs.callPackage ./cpprb.nix {
inherit pkgs;
inherit lib;
ps = pkgs.python311Packages;
readme = readme;
};
python-312 = pkgs.callPackage ./cpprb.nix {
inherit pkgs;
inherit lib;
ps = pkgs.python312Packages;
readme = readme;
};
site = pkgs.stdenv.mkDerivation {
name = "cpprb-site";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./README.org
./CHANGELOG.org
./LICENSE
./site
./sphinx
./example
];
};
nativeBuildInputs = [
pkgs.graphviz
pkgs.hugo
(pkgs.emacs.pkgs.withPackages (epkgs: (with epkgs.melpaStablePackages; [
ox-hugo
])))
(pkgs.python312.withPackages (ps: (with ps; [
numpy
sphinx
sphinx-rtd-theme
sphinx-automodapi
python-312
])))
];
buildPhase = ''
emacs --batch README.org --eval "${export}"
emacs --batch CHANGELOG.org --eval "${export}"
cd site
emacs --batch site.org --eval "${export}"
hugo -c content --logLevel info
cd ../
mkdir -p public/api
sphinx-build -b html sphinx public/api
'';
installPhase = ''
mkdir -p $out/public
cp -r public $out/
'';
};
};
}
);
}