-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
116 lines (112 loc) · 3.65 KB
/
flake.nix
File metadata and controls
116 lines (112 loc) · 3.65 KB
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
{
description = "A flake for building development shells with both mkMiniDevShell and an additive flake-parts module";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
mk-minimal-shell.url = "github:n-hass/mk-minimal-shell";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs =
{
self,
nixpkgs,
mk-minimal-shell,
flake-parts,
...
}:
let
myLib = import ./lib.nix { };
overlay = (import ./overlay.nix { inherit mk-minimal-shell; }).overlay;
types = import ./types.nix { lib = nixpkgs.lib; };
in
{
mkMiniDevShell =
argThunk:
(myLib.forAllSystems (
system:
let
requiredPkgs = import nixpkgs {
inherit system;
overlays = [
mk-minimal-shell.overlay
overlay
];
};
uncheckedArgs = argThunk system requiredPkgs;
extraFlakeOutputs = uncheckedArgs.extraFlakeOutputs or { };
args = {
pkgs = requiredPkgs;
} // uncheckedArgs;
pkgs = args.pkgs;
lib = pkgs.lib;
shellArgs = args // {
extraFlakeOutputs = null;
pkgs = null;
};
in
(lib.recursiveUpdate {
devShells =
let
shell = myLib.mkCustomShell pkgs.mkMinimalShell shellArgs pkgs;
in
{
default =
let
result =
lib.warnIf (!(pkgs ? mkMinimalShell))
"mkMinimalShell is missing! If you've overriden pkgs, ensure that it's provided as pkgs.mkMinimalShell."
shell;
in
result;
};
} extraFlakeOutputs)
));
flakeModule =
{
flake-parts-lib,
lib,
pkgs,
config,
system,
...
}:
{
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, system, ... }:
{
options = {
miniShell = types.miniShellType;
miniShellOpts = types.miniShellOptsType;
};
config =
let
shellArgs = config.miniShell;
cfg = config.miniShellOpts;
finalPkgs = if cfg.pkgs != null then cfg.pkgs else import nixpkgs {
inherit system;
overlays = [
overlay
mk-minimal-shell.overlay
];
};
warningMkShell = userConfigArgs:
lib.warnIf (!(finalPkgs ? mkMinimalShell))
"mkMinimalShell is missing! If you've overridden pkgs, ensure that it's provided as pkgs.mkMinimalShell."
(myLib.mkCustomShell finalPkgs.mkMinimalShell userConfigArgs finalPkgs);
in
{
devShells.default = warningMkShell shellArgs;
miniShellOpts.mkShell = warningMkShell;
miniShellOpts.processCompose._package = if cfg.processCompose.overridePackage != null
then cfg.processCompose.overridePackage
else builtins.head ((import ./services.nix { pkgs = finalPkgs; inherit lib; }).mkProcessComposeWrappers shellArgs);
};
}
);
};
lib = myLib;
overlays = {
default = overlay;
mk-minimal-shell = mk-minimal-shell.overlay;
};
};
}