forked from NixOS/nixos-homepage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
199 lines (167 loc) · 7.65 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
rec {
description = "The nixos.org homepage";
# This is used to build the site.
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
# These inputs are used for the manuals and release artifacts
inputs.released-nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
inputs.released-nixpkgs-stable.url = "nixpkgs/nixos-23.05";
inputs.released-nix-unstable.url = "github:nixos/nix/master";
inputs.released-nix-stable.url = "github:nixos/nix/latest-release";
inputs.nix-pills.url = "github:NixOS/nix-pills";
inputs.nix-pills.flake = false;
inputs.nix-dev.url = "github:NixOS/nix.dev";
inputs.nixos-common-styles.url = "github:NixOS/nixos-common-styles";
inputs.nixos-common-styles.inputs.flake-utils.follows = "flake-utils";
nixConfig.extra-substituters = [
"https://nixos-homepage.cachix.org"
"https://nixos-nix-install-tests.cachix.org"
];
nixConfig.extra-trusted-public-keys = [
"nixos-homepage.cachix.org-1:NHKBt7NjLcWfgkX4OR72q7LVldKJe/JOsfIWFDAn/tE="
"nixos-nix-install-tests.cachix.org-1:Le57vOUJjOcdzLlbwmZVBuLGoDC+Xg2rQDtmIzALgFU="
];
outputs =
{ self
, nixpkgs
, flake-utils
, released-nixpkgs-unstable
, released-nixpkgs-stable
, released-nix-unstable
, released-nix-stable
, nix-pills
, nix-dev
, nixos-common-styles
}:
flake-utils.lib.eachDefaultSystem (system:
let
overlay = final: prev: {
asciinema-scenario = final.rustPlatform.buildRustPackage rec {
pname = "asciinema-scenario";
version = "0.2.0";
src = final.fetchCrate {
inherit pname version;
sha256 = "sha256-qMGi+myppWBapM7TkPeXC2g/M1FA1YGwESNrx8LVXkw=";
};
cargoSha256 = "0z4iwjm38xfgipl1pcrkl8277p627pls565k7cclrhxfcx3f513p";
};
};
pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };
inherit (pkgs.lib) getVersion;
pkgs-unstable = import released-nixpkgs-unstable { inherit system; };
pkgs-stable = import released-nixpkgs-stable { inherit system; };
nix_stable = released-nix-stable.packages."${system}".nix;
nix_unstable = released-nix-unstable.packages."${system}".nix;
nixPills = import nix-pills {
inherit pkgs;
revCount = nix-pills.lastModifiedDate; # FIXME
shortRev = nix-pills.shortRev;
};
nixosAmis = pkgs.writeText "ec2-amis.json"
(builtins.toJSON (
import (released-nixpkgs-stable + "/nixos/modules/virtualisation/ec2-amis.nix")));
mkPyScript = dependencies: name:
let
pythonEnv = pkgs.python3.buildEnv.override {
extraLibs = dependencies;
};
in
pkgs.writeShellScriptBin name ''exec "${pythonEnv}/bin/python" "${toString ./.}/scripts/${name}.py" "$@"'';
serve =
mkPyScript (with pkgs.python3Packages; [ click livereload ]) "serve";
shuffle_commercial_providers =
mkPyScript (with pkgs.python3Packages; [ click toml ]) "shuffle-commercial-providers";
update_blog =
mkPyScript (with pkgs.python3Packages; [ aiohttp click feedparser cchardet ]) "update-blog";
in rec {
defaultPackage = packages.homepage;
checks.build = defaultPackage;
packages = rec {
homepage = pkgs.stdenv.mkDerivation {
name = "nixos-homepage-${self.lastModifiedDate}";
src = self;
preferLocalBuild = true;
enableParallelBuilding = true;
buildInputs = with pkgs; [
asciinema-scenario
gnused
imagemagick
jq
libxml2
libxslt
linkchecker
nixVersions.stable
nixos-common-styles.packages."${system}".embedSVG
nodePackages.less
perl
perlPackages.AppConfig
perlPackages.JSON
perlPackages.TemplatePluginIOAll
perlPackages.TemplatePluginJSONEscape
perlPackages.TemplateToolkit
perlPackages.XMLSimple
serve
shuffle_commercial_providers
update_blog
xhtml1
which
];
preBuild = ''
export NIX_DB_DIR=$TMPDIR
export NIX_STATE_DIR=$TMPDIR
rm -f site-styles/common-styles
ln -s ${nixos-common-styles.packages."${system}".commonStyles} site-styles/common-styles
'';
makeFlags =
[ "NIX_STABLE_VERSION=${getVersion nix_stable.name}"
"NIX_MANUAL_STABLE_IN=${nix_stable.doc}/share/doc/nix/manual"
"NIXPKGS_MANUAL_STABLE_IN=${released-nixpkgs-stable.htmlDocs.nixpkgsManual}"
"NIXOS_MANUAL_STABLE_IN=${released-nixpkgs-stable.htmlDocs.nixosManual}"
"NIXOS_STABLE_SERIES=${pkgs-stable.lib.trivial.release}"
"NIX_UNSTABLE_VERSION=${getVersion nix_unstable.name}"
"NIX_MANUAL_UNSTABLE_IN=${nix_unstable.doc}/share/doc/nix/manual"
"NIXPKGS_MANUAL_UNSTABLE_IN=${released-nixpkgs-unstable.htmlDocs.nixpkgsManual}"
"NIXOS_MANUAL_UNSTABLE_IN=${released-nixpkgs-unstable.htmlDocs.nixosManual}"
"NIXOS_UNSTABLE_SERIES=${pkgs-unstable.lib.trivial.release}"
"NIXOS_AMIS=${nixosAmis}"
"NIX_PILLS_MANUAL_IN=${nixPills.html-split}/share/doc/nix-pills"
"NIX_PILLS_MANUAL_EPUB=${nixPills.epub}/share/doc/nix-pills/nix-pills.epub"
"NIX_DEV_MANUAL_IN=${nix-dev.defaultPackage.${system}}"
"-j 1"
];
doCheck = true;
installPhase = ''
mkdir $out
cp -prd . .well-known/ $out/
'';
shellHook = ''
export NIX_STABLE_VERSION="${getVersion nix_stable.name}"
export NIX_MANUAL_STABLE_IN="${nix_stable.doc}/share/doc/nix/manual"
export NIXPKGS_MANUAL_STABLE_IN="${released-nixpkgs-stable.htmlDocs.nixpkgsManual}"
export NIXOS_MANUAL_STABLE_IN="${released-nixpkgs-stable.htmlDocs.nixosManual}"
export NIXOS_STABLE_SERIES="${pkgs-stable.lib.trivial.release}"
export NIX_UNSTABLE_VERSION="${getVersion nix_unstable.name}"
export NIX_MANUAL_UNSTABLE_IN="${nix_unstable.doc}/share/doc/nix/manual"
export NIXPKGS_MANUAL_UNSTABLE_IN="${released-nixpkgs-unstable.htmlDocs.nixpkgsManual}"
export NIXOS_MANUAL_UNSTABLE_IN="${released-nixpkgs-unstable.htmlDocs.nixosManual}"
export NIXOS_UNSTABLE_SERIES="${pkgs-unstable.lib.trivial.release}"
export NIXOS_AMIS="${nixosAmis}"
export NIX_PILLS_MANUAL_IN="${nixPills.html-split}/share/doc/nix-pills"
export NIX_PILLS_MANUAL_EPUB="${nixPills.epub}/share/doc/nix-pills/nix-pills.epub"
export NIX_DEV_MANUAL_IN="${nix-dev.defaultPackage.${system}}"
rm -f site-styles/common-styles
ln -s ${nixos-common-styles.packages."${system}".commonStyles} site-styles/common-styles
>&2 echo ""
>&2 echo " To start developing run:"
>&2 echo " serve"
>&2 echo ""
>&2 echo " and go to the following URL in your browser:"
>&2 echo " https://127.0.0.1:8000/"
>&2 echo ""
>&2 echo " It will rebuild the website on each change."
>&2 echo ""
'';
};
};
});
}