-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
209 lines (198 loc) · 7.63 KB
/
Copy pathflake.nix
File metadata and controls
209 lines (198 loc) · 7.63 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
utils.url = "github:numtide/flake-utils";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
wsl = {
url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "utils";
};
vscode-server = {
url = "github:msteen/nixos-vscode-server";
inputs.nixpkgs.follows = "nixpkgs";
};
attic = {
url = "github:zhaofengli/attic";
inputs.nixpkgs.follows = "nixpkgs";
};
# deploy-rs = {
# url = "github:serokell/deploy-rs";
# inputs.nixpkgs.follows = "nixpkgs";
# };
nurl = {
url = "github:nix-community/nurl";
# inputs.nixpkgs.follows = "nixpkgs";
};
# TODO: pick one
nixd = { url = "github:nix-community/nixd"; };
nil = { url = "github:oxalica/nil"; };
agenix.url = "github:ryantm/agenix";
secrets = {
url = "git+ssh://git@github.com/JRMurr/nix-secrets";
inputs.nixpkgs.follows = "nixpkgs";
inputs.agenix.follows = "agenix";
inputs.flake-utils.follows = "utils";
};
flake-compat = {
url = "github:inclyc/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, home-manager, wsl, flake-utils, ... }@inputs:
let
overlays = [
inputs.attic.overlays.default
inputs.agenix.overlays.default
(import ./pkgs/overlay.nix)
# TODO: nil and nurl
];
defaultModules = [
{ _module.args = { inherit inputs; }; }
inputs.agenix.nixosModules.default
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# environment.systemPackages =
# [ deploy-rs.packages.x86_64-linux.deploy-rs ];
}
];
mkPkgs = system:
import nixpkgs {
inherit system overlays;
config.allowUnfree = true;
};
mkSystem = extraModules:
nixpkgs.lib.nixosSystem rec {
pkgs = mkPkgs "x86_64-linux";
system = "x86_64-linux";
modules = defaultModules ++ extraModules;
};
mkHomemanager = name: user: system:
let
pkgs = mkPkgs system;
# myOptions = import ./common/myOptions {
# config = { };
# lib = pkgs.lib;
# };
myOptions = { graphics.enable = false; };
in home-manager.lib.homeManagerConfiguration {
pkgs = pkgs;
extraSpecialArgs = { nixosConfig = { inherit myOptions; }; };
modules = [
{
_module.args.nixpkgs = nixpkgs;
_module.args.inputs = inputs;
# _module.args.vars = { stateVersion = "22.05"; };
}
({ config, pkgs, lib, ... }: {
home = {
# TODO: this is the macos path, if used on linux need to switch to home
homeDirectory = "/Users/${user}";
username = user;
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
stateVersion = "22.05";
# # symlink apps to $HOME/Applications so they show up in finder
# # https://github.com/nix-community/home-manager/issues/1341#issuecomment-1190875080
# activation = lib.mkIf pkgs.stdenv.isDarwin {
# copyApplications = let
# apps = pkgs.buildEnv {
# name = "home-manager-applications";
# paths = config.home.packages;
# pathsToLink = "/Applications";
# };
# in home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] ''
# baseDir="$HOME/Applications/Home Manager Apps"
# if [ -d "$baseDir" ]; then
# rm -rf "$baseDir"
# fi
# mkdir -p "$baseDir"
# for appFile in ${apps}/Applications/*; do
# target="$baseDir/$(basename "$appFile")"
# $DRY_RUN_CMD cp ''${VERBOSE_ARG:+-v} -fHRL "$appFile" "$baseDir"
# $DRY_RUN_CMD chmod ''${VERBOSE_ARG:+-v} -R +w "$target"
# done
# '';
# };
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
})
(./common/users + "/${name}" + /home.nix)
];
};
in {
inherit overlays;
lib = { inherit mkSystem; };
nixosModules.default = { ... }: {
imports = defaultModules ++ [ ./common ];
};
templates = import ./templates { };
nixosConfigurations = {
nixos-john = mkSystem [ ./hosts/desktop ];
wsl = mkSystem [ wsl.nixosModules.wsl ./hosts/wsl ];
graphicalIso = mkSystem [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma5.nix"
./common/essentials.nix
./common/programs.nix
./common/myOptions
];
framework = mkSystem [
inputs.nixos-hardware.nixosModules.framework
./hosts/framework
];
thicc-server = mkSystem [
./hosts/thicc-server
inputs.vscode-server.nixosModule
inputs.attic.nixosModules.atticd
({ config, pkgs, ... }: { services.vscode-server.enable = true; })
];
};
homeConfigurations = {
# stolen sorta from https://github.com/mrkuz/nixos/blob/738528d405bdb5b6e729c1d8d1885664650e08dd/flake.nix#L110
jmurray = mkHomemanager "jmurray" "jmurray" "x86_64-darwin";
};
# deploy = {
# # https://lantian.pub/en/article/modify-website/nixos-initial-config-flake-deploy.lantian/
# # Auto rollback on deployment failure, recommended off.
# #
# # NixOS deployment can be a bit flaky (especially on unstable)
# # and you may need to deploy twice to succeed, but auto rollback
# # works against that and make your deployments constantly fail.
# autoRollback = false;
# # Auto rollback on Internet disconnection, recommended off.
# #
# # Rollback when your new config killed the Internet connection,
# # so you don't have to use VNC or IPMI from your service provider.
# # But if you're adjusting firewall or IP settings, chances are
# # although the Internet is down atm, a simple reboot will make everything work.
# # Magic rollback works against that, so you should keep that off.
# magicRollback = false;
# nodes.thicc-server = {
# hostname = "192.168.1.160";
# sshUser = "root";
# fastConnection = true;
# profiles.system = {
# user = "root";
# path = deploy-rs.lib.x86_64-linux.activate.nixos
# self.nixosConfigurations.thicc-server;
# };
# };
# };
# checks = builtins.mapAttrs
# (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}