-
Notifications
You must be signed in to change notification settings - Fork 39
/
flake.nix
56 lines (44 loc) · 1.37 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
{
description = "Spawns lightweight nixos vms in a shell";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = inp:
let
lib = inp.nixpkgs.lib;
inherit (lib) mapAttrs' removeSuffix makeOverridable nixosSystem mapAttrs;
vms = mapAttrs' (file: _: {
name = removeSuffix ".nix" file;
value = import (./examples + "/${file}");
}) (builtins.readDir ./examples);
mkSystem = pkgs: config: makeOverridable nixosSystem {
system = "x86_64-linux";
modules = [ config inp.self.nixosModules.nixos-shell ];
};
supportedSystems = [ "x86_64-linux" ];
in
{
nixosConfigurations =
let
configs = mapAttrs (_name: config: mkSystem inp.nixpkgs config) vms;
in
configs
//
{
# Used for testing that nixos-shell exits nonzero when provided a
# non-extensible config
BROKEN-DO-NOT-USE-UNLESS-YOU-KNOW-WHAT-YOU-ARE-DOING =
removeAttrs configs.vm [ "extendModules" "override" ];
};
nixosModules.nixos-shell.imports = [ ./share/modules/nixos-shell.nix ];
}
//
lib.foldl' lib.recursiveUpdate {} (lib.forEach supportedSystems (system: {
packages."${system}" = {
nixos-shell = import ./default.nix {
pkgs = inp.nixpkgs.legacyPackages."${system}";
};
default = inp.self.packages."${system}".nixos-shell;
};
}));
}