-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.nix
42 lines (40 loc) · 1.26 KB
/
default.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
args@{
...
}:
# HACK allow usage with both nixos-rebuild and nix-build
#
# NixOS calls this function with a certain set of arguments by default,
# including specialArgs which is pretty uniquely exclusive to NixOS modules.
# This allows us to differentiate what we're being called from; a module or
# nix-instantiate/nix-build.
if args ? specialArgs then {
imports = [
./current-config.nix
];
}
else let
configs = import ./configs;
nixpkgsConfig = import ./nixpkgs-config.nix;
selectNixfile = import ./select-nixfile.nix;
nixosFor = hostname: configuration: let
nixpkgs =
if args ? nixpkgsPath then
args.nixpkgsPath
else
selectNixfile nixpkgsConfig.${hostname} or nixpkgsConfig.default;
in import (nixpkgs + /nixos) {
inherit configuration;
};
nixosVmWithoutPackages = hostname: configuration: (nixosFor hostname ({ pkgs, ... }: {
imports = [
configuration
];
custom.packages.enable = pkgs.lib.mkForce false;
})).vm;
# Makes an attrset of all my nixos configurations.
# Try `nix-build -A TAB TAB`. Pretty neat, huh?
in builtins.mapAttrs
(name: config: nixosFor name config // {
vmWithoutPackages = nixosVmWithoutPackages name config;
vmWithPackages = (nixosFor name config).vm;
}) configs