-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
165 lines (142 loc) · 5.05 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
{
description = ''
collection of Nix packages, NixOS modules and configurations used on
EPITA's PIE
'';
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixpkgsUnstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgsMaster.url = "github:NixOS/nixpkgs/master";
machine-state.url = "git+https://gitlab.cri.epita.fr/forge/packages/machine-state.git";
docker-nixpkgs = {
url = "github:nix-community/docker-nixpkgs";
flake = false;
};
futils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs =
{ self
, nixpkgs
, nixpkgsUnstable
, nixpkgsMaster
, machine-state
, docker-nixpkgs
, futils
, flake-compat
} @ inputs:
let
inherit (nixpkgs) lib;
inherit (lib) attrValues optional recursiveUpdate;
inherit (futils.lib) eachDefaultSystem;
pkgImport = pkgs: system: withOverrides:
import pkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"freeimage-unstable-2021-11-01"
];
};
overlays =
(attrValues self.overlays) ++
(optional withOverrides self.overrides.${system}) ++ [
(import "${docker-nixpkgs}/overlay.nix")
(final: prev: {
machine-state = machine-state.packages.${system}.machine-state;
})
];
};
pkgset = system: {
pkgs = pkgImport nixpkgs system true;
pkgsUnstable = pkgImport nixpkgsUnstable system false;
pkgsMaster = pkgImport nixpkgsMaster system false;
};
anySystemOutputs = {
lib = import ./lib { inherit lib; };
overlays = import ./pkgs/overlays.nix { inherit lib; };
nixosModules = (import ./modules) // {
profiles = import ./profiles;
nixpie = import ./modules/nixpie.nix;
};
nixosConfigurations =
let
system = "x86_64-linux";
in
import ./images (
recursiveUpdate inputs {
inherit lib system;
pkgset = pkgset system;
}
);
# works like hydraJobs
gitlabCiJobs = {
images.x86_64-linux = lib.mapAttrs (_: nixosConfig: nixosConfig.config.system.build.toplevel) self.nixosConfigurations;
packages.x86_64-linux = lib.filterAttrs (name: _: !lib.hasSuffix "-docker" name) self.packages.x86_64-linux;
checks.x86_64-linux = self.checks.x86_64-linux;
};
};
multiSystemOutputs = eachDefaultSystem (system:
let
inherit (pkgset system) pkgs pkgsUnstable pkgsMaster;
in
{
checks = (import ./tests (recursiveUpdate inputs { inherit lib system; pkgset = pkgset system; }));
devShells.default = pkgs.mkShell {
name = "nixpie";
buildInputs = with pkgs; [
awscli
git
pkgsMaster.nix-diff
nixpkgs-fmt
nix-eval-jobs
pre-commit
shellcheck
];
};
apps =
let
checkList = builtins.attrNames self.checks.${system};
imageList = builtins.attrNames self.nixosConfigurations;
pkgsList = builtins.attrNames (lib.filterAttrs (name: _: !lib.hasSuffix "-docker" name) self.packages.${system});
dockerList = builtins.attrNames (lib.filterAttrs (name: _: lib.hasSuffix "-docker" name) self.packages.${system});
mkListApp = list: {
type = "app";
program = toString (pkgs.writeShellScript "list.sh" (lib.concatMapStringsSep "\n" (el: "echo '${el}'") list));
};
in
{
list-checks = mkListApp checkList;
list-docker = mkListApp dockerList;
list-images = mkListApp imageList;
list-pkgs = mkListApp pkgsList;
awscli = {
type = "app";
program = "${pkgs.awscli}/bin/aws";
};
nix-diff = {
type = "app";
program = "${pkgsMaster.nix-diff}/bin/nix-diff";
};
nix-eval-jobs = {
type = "app";
program = "${pkgs.nix-eval-jobs}/bin/nix-eval-jobs";
};
nixpkgs-fmt = {
type = "app";
program = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt";
};
skopeo = {
type = "app";
program = "${pkgs.skopeo}/bin/skopeo";
};
};
overrides = import ./pkgs/overrides.nix { inherit pkgsUnstable pkgsMaster; };
packages = (import ./pkgs { inherit lib pkgs; }) // (import ./images/docker.nix (recursiveUpdate inputs { inherit lib system; pkgset = pkgset system; }));
});
in
recursiveUpdate multiSystemOutputs anySystemOutputs;
}