-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
77 lines (65 loc) · 2.44 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
# SPDX-FileCopyrightText: 2023 Connor Feeley
#
# SPDX-License-Identifier: BSD-3-Clause
{
description = "Nix flake for GoatCounter, a privacy-focused self-hosted web analytics platform.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
# flake-parts and friends.
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; };
};
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, moduleWithSystem, flake-parts-lib, ... }:
let
inherit (flake-parts-lib) importApply;
# Goatcounter (privacy-focused, self-hosted web analytics)
flakeModules.options-doc = importApply ./render { localFlake = self; inherit withSystem; };
in
{
debug = true;
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.treefmt-nix.flakeModule
inputs.flake-root.flakeModule
flakeModules.options-doc
];
flake = {
# Export flakeModules.
inherit flakeModules;
# Export goatcounter module.
nixosModules.goatcounter = { pkgs, ... }: {
imports = [ ./nixos/modules/services/web-apps/goatcounter ];
services.goatcounter.package = withSystem pkgs.stdenv.hostPlatform.system ({ config, ... }:
config.packages.default
);
};
# Export goatcounter module.
templates = rec {
default = container;
container = {
path = ./examples/container;
description = "A very basic flake";
};
};
};
perSystem = { self', config, pkgs, ... }: {
packages = rec {
goatcounter = pkgs.callPackage ./pkgs/servers/web-apps/goatcounter { };
default = goatcounter;
};
# Shell with treefmt.
devShells.default = pkgs.mkShell {
nativeBuildInputs = [ config.treefmt.build.wrapper pkgs.reuse ];
};
# Treefmt configuration.
treefmt.config = {
inherit (config.flake-root) projectRootFile;
package = pkgs.treefmt;
programs.nixpkgs-fmt.enable = true;
};
};
});
}