-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
156 lines (134 loc) · 4.67 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
description = "Martin Baillie's 99p Flake";
inputs = {
nixpkgs.url = "nixpkgs/release-23.11";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
# Declarative user home management.
home-manager.url = github:rycee/home-manager/release-23.11;
home-manager.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = github:lnl7/nix-darwin/master;
darwin.inputs.nixpkgs.follows = "nixpkgs";
# Block adservers, fake news etc.
bad-hosts.url = github:StevenBlack/hosts;
bad-hosts.inputs.nixpkgs.follows = "nixpkgs";
# Secrets.
sops-nix.url = github:4825764518/sops-nix/darwin;
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
# Emacs overlays.
emacs-overlay.url = github:nix-community/emacs-overlay;
emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";
emacs-macos = {
type = "github";
owner = "tyler-dodge";
repo = "emacs";
ref = "tyler-main-emacs-29";
flake = false;
};
# Vale styles.
vale-Google.flake = false;
vale-Google.url = github:errata-ai/Google;
vale-Microsoft.flake = false;
vale-Microsoft.url = github:errata-ai/Microsoft;
vale-Joblint.flake = false;
vale-Joblint.url = github:errata-ai/Joblint;
vale-alex.flake = false;
vale-alex.url = github:errata-ai/alex;
vale-proselint.flake = false;
vale-proselint.url = github:errata-ai/proselint;
vale-write-good.flake = false;
vale-write-good.url = github:errata-ai/write-good;
# NixOS hardware definitions.
nixos-hardware.url = github:nixos/nixos-hardware;
# Firefox Darwin overlay.
firefox-darwin.url = github:bandithedoge/nixpkgs-firefox-darwin;
firefox-darwin.inputs.nixpkgs.follows = "nixpkgs";
# Zgenom zsh package manager.
zgenom.flake = false;
zgenom.url = github:jandamm/zgenom;
# Tridactyl themes.
base16-tridactyl.flake = false;
base16-tridactyl.url = github:martinbaillie/base16-tridactyl;
};
# NOTE: Flake interface found at:
# https://github.com/NixOS/nix/blob/master/src/nix/flake.cc
outputs =
inputs@{ self
, nixpkgs
, nixpkgs-unstable
, darwin
, bad-hosts
, emacs-overlay
, firefox-darwin
, ...
}:
let
inherit (lib) genAttrs;
inherit (lib.my) mapModules mapModulesRec mapHosts mapConfigurations;
supportedSystems = rec {
darwin = [ "x86_64-darwin" "aarch64-darwin" ];
linux = [ "x86_64-linux" "aarch64-linux" ];
all = darwin ++ linux;
};
mkPkgs = pkgs: extraOverlays: system:
import pkgs {
inherit system;
overlays = extraOverlays ++ (lib.attrValues self.overlays);
};
rosettaOverlay = new: old:
let
isAppleSilicon = with old.stdenv.hostPlatform; isDarwin && isAarch64;
intelPkgs = nixpkgs.legacyPackages.x86_64-darwin;
in
(lib.optionalAttrs isAppleSilicon {
# FIXME: These are all currently broken on aarch64.
inherit (intelPkgs)
# wireshark: just broken everywhere due to LLVM.
ssm-session-manager-plugin; # Waiting on AWS to fix upstream.
});
pkgs = genAttrs supportedSystems.all
(mkPkgs nixpkgs [ emacs-overlay.overlay self.overlay rosettaOverlay firefox-darwin.overlay ]);
pkgsUnstable =
genAttrs supportedSystems.all (mkPkgs nixpkgs-unstable [ ]);
lib = nixpkgs.lib.extend (self: super: {
my = import ./lib {
inherit pkgs inputs darwin;
lib = self;
};
});
in
{
lib = lib.my;
# Default modules usable in dependant flakes.
nixosModules = {
dotfiles = import ./.;
} // mapModulesRec ./modules import;
darwinModules = {
dotfiles = import ./.;
} // mapModulesRec ./modules import;
# Default overlays usable in dependant flakes.
overlay = _:
{ system, ... }: {
unstable = pkgsUnstable.${system};
my = self.packages.${system};
};
overlays = mapModules ./overlays import;
packages =
let
mkPackages = system:
mapModules ./packages (p: pkgs.${system}.callPackage p { });
in
genAttrs supportedSystems.all mkPackages;
# `nix develop`.
devShell =
let forAllSupportedSystems = f: genAttrs supportedSystems.all (s: f s);
in
forAllSupportedSystems
(system: with pkgs.${system}; import ./shell.nix { inherit pkgs; });
# Nix Darwin host configurations.
darwinConfigurations =
mapConfigurations supportedSystems.darwin ./hosts/darwin;
# NixOS host configurations.
nixosConfigurations =
mapConfigurations supportedSystems.linux ./hosts/linux;
};
}