-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
126 lines (107 loc) · 4.03 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 = "lounge.rocks - infrastructure";
inputs = {
# https://github.com/nixos/nixpkgs
# Nix Packages collection & NixOS
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};
### Tools for managing NixOS
# https://github.com/nix-community/disko
# Format disks with nix-config
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# https://github.com/Mic92/sops-nix
# Atomic secret provisioning for NixOS based on sops
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# https://github.com/pinpox/lollypops/
# NixOS Deployment Tool
lollypops = {
url = "github:pinpox/lollypops";
inputs.nixpkgs.follows = "nixpkgs";
};
### Applications from outside nixpkgs
# https://github.com/lounge-rocks/crab_share
# upload files to an S3 bucket and generate a shareable link.
crab_share = {
url = "github:lounge-rocks/crab_share";
};
# https://github.com/pinpox/woodpecker-flake-pipeliner
# Woodpecker configuration Service to dynamically generate pipelines from nix flakes
flake-pipeliner = {
url = "github:pinpox/woodpecker-flake-pipeliner";
inputs.nixpkgs.follows = "nixpkgs";
};
# https://github.com/Mic92/nix-fast-build
# speed-up your evaluation and building process.
nix-fast-build = {
url = "github:Mic92/nix-fast-build";
};
};
outputs = { self, ... }@inputs:
with inputs;
let
supportedSystems =
[ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; overlays = [ self.overlays.default ]; });
in
{
formatter = forAllSystems
(system: nixpkgsFor.${system}.nixpkgs-fmt);
overlays.default = final: prev:
(import ./pkgs inputs) final prev;
# TODO:
# is is possible to inherit all packages from nixpkgsFor.${system}.lounge-rocks?
# this would be much cleaner since we would not need to list all packages here
packages = forAllSystems (system: {
woodpecker-pipeline = nixpkgsFor.${system}.callPackage ./pkgs/woodpecker-pipeline {
inputs = inputs;
flake-self = self;
};
inherit (nixpkgsFor.${system}.lounge-rocks)
s3uploader
upload-nixos-iso
woodpecker-agent
woodpecker-cli
woodpecker-server
;
});
apps = forAllSystems (system: {
# nix run .\#lollypops -- --list-all
# nix run .\#lollypops -- --parallel woodpecker-agent-aarch64-1 woodpecker-agent-x86-1 woodpecker-server
lollypops = lollypops.apps.${system}.default { configFlake = self; };
});
nixosModules = builtins.listToAttrs (map
(x: {
name = x;
value = import (./modules + "/${x}");
})
(builtins.attrNames (builtins.readDir ./modules)));
# Each subdirectory in ./machines is a host. Add them all to
# nixosConfiguratons. Host configurations need a file called
# configuration.nix that will be read first
nixosConfigurations = builtins.listToAttrs (map
(x: {
name = x;
value = nixpkgs.lib.nixosSystem {
# Make inputs and the flake itself accessible as module parameters.
# Technically, adding the inputs is redundant as they can be also
# accessed with flake-self.inputs.X, but adding them individually
# allows to only pass what is needed to each module.
specialArgs = { flake-self = self; } // inputs;
modules = builtins.attrValues self.nixosModules ++ [
lollypops.nixosModules.lollypops
sops-nix.nixosModules.sops
(import "${./.}/machines/${x}/configuration.nix" { inherit self; })
];
};
})
(builtins.attrNames (builtins.readDir ./machines)));
};
}