-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
120 lines (106 loc) · 3.27 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
{
description = "TODO: add description";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
nmd = {
url = "github:nix-basement/nmd";
flake = false;
};
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
};
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
let
lib = import ./lib { inherit inputs; };
in
with builtins; with lib; {
# system independent outputs
inherit lib;
nixosModules = findNixosModules self;
darwinModules = findDarwinModules self;
overlays = findOverlays self true
(final: prev: {
inherit lib; # overwrite pkgs.lib with our extended lib
agenix = inputs.agenix.packages.${prev.system}.agenix;
base = self.packages.${prev.system}; # Add our packages to the base scope
deploy-rs = inputs.deploy-rs.packages.${prev.system};
});
} // (flake-utils.lib.eachDefaultSystem (system:
let
# import nixpkgs for the current system and set options
pkgs = loadPkgs inputs {
inherit system;
allowUnfree = true;
overlays = inputOverlays inputs;
};
in
{
# system-specific outputs
packages = listToAttrs
(
map
(file: rec {
name = unsafeDiscardStringContext (replaceStrings [ "/" ] [ "-" ] (removePrefix "${self}/scripts/" file)); # this is safe, actually
value = pkgs.substituteAll {
inherit name;
src = file;
dir = "bin";
isExecutable = true;
# packages that are available to the scripts
inherit (pkgs)
bash
gnused
jq
nixFlakes
nixfmt
python3
rage
;
wireguard = pkgs.wireguard-tools;
nixpkgs = toString inputs.nixpkgs;
};
})
(find "" "${self}/scripts")
);
apps = mapAttrs
(name: value:
(flake-utils.lib.mkApp {
inherit name;
drv = value;
})
)
inputs.self.packages.${system};
devShells.default =
pkgs.mkShell {
buildInputs = with pkgs;
flatten [
agenix
deploy-rs.deploy-rs
nixpkgs-fmt
rage
(attrValues self.packages.${system})
];
};
checks = {
nixpkgs-fmt = pkgs.runCommand "check-nix-format" { } ''
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
mkdir $out #sucess
'';
};
buildJobs = generateBuildJobs self pkgs;
docs = (import ./docs { inherit pkgs lib inputs; });
}
));
}