-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputs.nix
108 lines (91 loc) · 2.95 KB
/
outputs.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
{ self, ... } @ inputs:
let
nixpkgs = inputs.nixpkgs;
lib = nixpkgs.lib;
# It's a personal repo, not supporting other systems right now
supportedSystems = lib.singleton "x86_64-linux";
forAllSystems = function: lib.genAttrs
supportedSystems
(system: function nixpkgs.legacyPackages.${system});
# My custom lib functions, stored in a separate repo.
# This instance only holds pure functions, and isn't passed
# to anywhere. We just use it when we need a custom function,
# but don't have system access.
pureLlakaLib = inputs.llakaLib.pureLib;
mkNixos = hostname:
{ system }: let llakaLib = inputs.llakaLib.fullLib.${system};
in lib.nixosSystem
{
specialArgs =
{
inherit inputs llakaLib self;
# We never use unfree packages from unstable, to avoid re-instantiating nixpkgs
pkgs-unstable = inputs.nixpkgs-unstable.legacyPackages.${system};
};
# Use custom function that grabs all files within a folder and filters out non-nix files
modules = llakaLib.resolveAndFilter
[
./config/core
./config/features
./config/gnome
./config/baseVars.nix
./apps/core
./apps/dev
./apps/extras
./apps/gui
./hosts/${hostname}/config
./hosts/${hostname}/hardware-configuration.nix
./hosts/${hostname}/${hostname}Vars.nix
self.nixosModules.default
];
};
in
{
# Run mkNixos for each host. mapAttrs is magic here.
#
# mkNixos expects two arguments - a string representing the hostname,
# and an attrset with a value for the key `system`. An example call of
# `mkNixos` without `mapAttrs` would be:
# `mkNixos "framework" { system = "x86_64-linux"; }`.
#
# Now, `mapAttrs` is very simple: it takes `key = value` and turns it
# into `key value`.
#
# This is useful because `framework.system = val;` is just syntactic
# sugar for `framework = { system = val; }` so, `mapAttrs` receives
# that unsugared and separates the key and the value, to:
# `"framework" { system = "x86_64-linux"; }`.
#
# Which, if you remember the mkNixos description, is exactly what we
# wanted!
nixosConfigurations = builtins.mapAttrs mkNixos
{
framework.system = "x86_64-linux";
desktop.system = "x86_64-linux";
iso.system = "x86_64-linux";
};
# Call all packages automatically in directory, while letting packages refer to each other
# via custom lib function
legacyPackages = forAllSystems
(
pkgs: let llakaLib = inputs.llakaLib.fullLib.${pkgs.system};
in llakaLib.collectDirectoryPackages
{
inherit pkgs;
directory = ./extras/packages;
extras = { inherit llakaLib; }; # So custom packages can rely on llakaLib
}
);
# for easier access, this lets us add all our modules by just importing self.nixosModules.default
nixosModules.default =
{
imports = pureLlakaLib.resolveAndFilter
[
./extras/nixosModules
];
};
formatter = forAllSystems
(
pkgs: pkgs.nixfmt-rfc-style
);
}