-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
132 lines (120 loc) · 3.07 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
description = "A collection of lessons for learning NixOS Modules.";
nixConfig.extra-substituters = [
"https://djacu-nixos-modules-lessons.cachix.org"
];
nixConfig.extra-trusted-public-keys = [
"djacu-nixos-modules-lessons.cachix.org-1:xvTRAYg4Wh6fagK80iDXwFDj5zL0uzSSfUr2VfesA/k="
];
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix.url = "github:nix-community/poetry2nix";
poetry2nix.inputs.flake-utils.follows = "flake-utils";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
flake-utils,
poetry2nix,
}:
flake-utils.lib.eachSystem ["x86_64-linux"] (system: let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
inherit (lib) fileset;
inherit
(poetry2nix.lib.mkPoetry2Nix {inherit pkgs;})
mkPoetryEnv
;
lessonsLib = import ./lib/lessons.nix {inherit pkgs lib;};
site-env = mkPoetryEnv {
projectDir = fileset.toSource {
root = ./site;
fileset = fileset.unions [
./site/pyproject.toml
./site/poetry.lock
];
};
python = pkgs.python311;
};
lessonsInfo = {
lessonsPath = (
fileset.toSource {
root = ./lessons;
fileset = ./lessons;
}
);
lessonFile = "lesson.md";
};
lessonsDocumentation = lessonsLib.generateLessonsDocumentation lessonsInfo;
site = pkgs.stdenvNoCC.mkDerivation {
name = "modules-lessons-site";
src = fileset.toSource {
root = ./site;
fileset =
fileset.difference
./site
(fileset.unions [
./site/pyproject.toml
./site/poetry.lock
]);
};
nativeBuildInputs = [site-env];
buildPhase = ''
cp -r ${lessonsDocumentation}/* ./docs/
mkdir -p .cache/plugin/social
cp ${pkgs.roboto}/share/fonts/truetype/Roboto-* .cache/plugin/social/
mkdocs build --site-dir dist
'';
installPhase = ''
mkdir $out
cp -R dist/* $out/
'';
};
slides =
import
./slides
{
inherit pkgs;
parentPath = ./slides;
};
in {
devShells = {
poetry = pkgs.mkShell {
packages = [
pkgs.poetry
pkgs.python311
];
};
site = pkgs.mkShell {
buildInputs = [
pkgs.poetry
site-env
];
};
};
packages =
slides
// {
inherit
site
lessonsDocumentation
;
};
apps = {
copyLessonsToSite = {
type = "app";
program = "${lessonsLib.copyLessonsToSite}/bin/copy-lessons-to-site";
};
};
checks =
slides
// {
inherit
site
;
};
inherit lessonsLib;
});
}