-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
110 lines (92 loc) · 3.57 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nix-github-actions, ... } @inputs: inputs.utils.lib.eachSystem [
"x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"
] (system: let
pkgs = import nixpkgs {
inherit system;
# Add overlay here to inject the mkdocs-material and extensions plugin
nixpkgs.overlays = (self: super: {
mkdocs = super.mkdocs.override {
propogatedBuildInputs = [super.mkdocs.propogatedBuildInputs]
++ pkgs.python311Packages.mkdocs-material
++ pkgs.python311Packages.mkdocs-material-extensions;
};
});
};
in {
githubActions = nix-github-actions.lib.mkGithubMatrix { checks = self.packages; };
# packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
# packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
hydraJobs."tester" = self.defaultPackage;
# hydraJobs."tester-container" = self.container;
packages.container = pkgs.dockerTools.buildImage {
name = "gitea.c4er.com/matt/wiki";
tag = "latest";
# created = builtins.substring 0 8 self.lastModifiedDate; # this is recommended instead of using "now" the docs but throws a parser error
created = "now";
# The withPackages bit in the extra command adds the other packages
# to the scope of this nix package. Not sure why this is needed to be done
# this way here. It appears to ignore the overlay defined above despite
# working below for the default nix build command
extraCommands = ''
${(pkgs.python311.withPackages(ps: with ps; [
mkdocs mkdocs-material mkdocs-material-extensions
]))}/bin/mkdocs build
'';
copyToRoot = pkgs.buildEnv {
name = "wiki";
paths = [
./. # copy current working directory into image TODO copy this into a sub path so resulting image root is cleaner
];
};
config = {
Cmd = [ "${pkgs.caddy}/bin/caddy" "file-server" "-r" "/site" ];
ExposedPorts = {
"80/tcp" = { };
};
};
};
defaultPackage = pkgs.stdenv.mkDerivation {
# wiki = pkgs.stdenv.mkDerivation {
name = "wiki";
src = ./.;
# Set this to true so the make command does not run by default
# and fail because makefile is not in repo
buildPhase = "true";
buildInputs = [
pkgs.mkdocs
pkgs.python311Packages.mkdocs-material # materials theme
pkgs.python311Packages.mkdocs-material-extensions # extensions plugin
];
# run build command
# create output directory (this is what gets copied into the ./result path)
# copy contents to output
# zip contents
installPhase = ''
${pkgs.mkdocs}/bin/mkdocs build
mkdir -p $out/www
cp -r site/* $out/www
'';
};
devShells.default = pkgs.mkShell rec {
name = "wiki";
# Set this to true so the make command does not run by default
# and fail because makefile is not in repo
buildPhase = "true";
shellHook = ''
${pkgs.mkdocs}/bin/mkdocs build
'';
# this is used instead of packages
nativeBuildInputs = [
pkgs.python311Packages.mkdocs-material # materials theme
pkgs.python311Packages.mkdocs-material-extensions # extensions plugin
];
};
});
}