-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
126 lines (107 loc) · 3.51 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
{
description = "Personal homepage (frederic.menou.me)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
posix-toolbox.url = "github:ptitfred/posix-toolbox";
easy-ps.url = "github:justinwoo/easy-purescript-nix";
};
outputs = { nixpkgs, gitignore, posix-toolbox, easy-ps, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system overlays; };
inherit (gitignore.lib) gitignoreSource;
scripting = pkgs.callPackage scripting/package.nix { inherit gitignoreSource; };
website = baseUrl: pkgs.callPackage website/package.nix { inherit baseUrl gitignoreSource; };
root = baseUrl:
pkgs.symlinkJoin {
name = "personal-homepage";
paths = [ scripting (website baseUrl) ];
};
overlay = _: prev: {
easy-ps = easy-ps.packages.${system};
ptitfred = {
nginx = prev.lib.makeOverridable ({ baseUrl ? "http://localhost" }: prev.callPackage webservers/nginx/package.nix { root = root baseUrl; }) {};
take-screenshots = prev.callPackage scripts/take-screenshots.nix {};
};
};
overlays = [
overlay
posix-toolbox.overlays.default
];
tests =
{
screenshots =
pkgs.callPackage tests/screenshots.nix rec {
port = "8000";
testUrl = "http://localhost:${port}";
static = website testUrl;
};
local =
pkgs.callPackage tests/local.nix rec {
port = "8000";
static = website "http://localhost:${port}";
};
in-nginx =
pkgs.callPackage tests/in-nginx.nix {
cores = 2;
memorySize = 4096;
testing-python = pkgs.callPackage "${nixpkgs}/nixos/lib/testing-python.nix" {};
};
};
mkCheck = name: checkPhase:
pkgs.stdenvNoCC.mkDerivation {
inherit name checkPhase;
dontBuild = true;
src = ./.;
doCheck = true;
installPhase = ''
mkdir "$out"
'';
};
linter = pkgs.posix-toolbox.nix-linter.override {
excludedPaths = [
"scripting/spago-packages.nix"
"scripting/.spago/*"
"nix/*"
];
};
in
{
overlays.default = overlay;
packages.${system} = {
inherit (pkgs.ptitfred) take-screenshots;
inherit scripting;
nginx-root = pkgs.ptitfred.nginx.root;
integration-tests = tests.in-nginx;
};
apps.${system} = {
tests = {
type = "app";
program = "${tests.screenshots}/bin/tests";
};
local = {
type = "app";
program = "${tests.local}/bin/local";
};
dev-server = {
type = "app";
program =
let script = pkgs.writeShellScriptBin "zola-dev-server" "${pkgs.zola}/bin/zola -r $1 serve";
in "${script}/bin/zola-dev-server";
};
lint = {
type = "app";
program = "${linter}/bin/nix-linter";
};
};
checks.${system} = {
lint =
mkCheck "lint-nix" ''
${linter}/bin/nix-linter ${./.}
'';
};
devShells.${system}.default = with pkgs; mkShell { buildInputs = [ zola ]; };
};
}