-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
169 lines (150 loc) · 4.31 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
157
158
159
160
161
162
163
164
165
166
167
168
169
{
description = "Ayman's Nix and NixOS dotfiles";
inputs = {
# We use the unstable nixpkgs repo
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nur.url = "github:nix-community/NUR";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Zsh Plugins
tinted-shell = {
url = "github:tinted-theming/tinted-shell";
flake = false;
};
tinted-fzf = {
url = "github:tinted-theming/tinted-fzf";
flake = false;
};
zsh-vim-mode = {
url = "github:softmoth/zsh-vim-mode";
flake = false;
};
# NOTE: The following inputs will require your git SSH access to the repo.
# Here we have my local dotfiles repo, which contains private
# variables, configurations, and Sops secrets.
# WARNING: You should remove or change this to your own dotfiles repo,
# otherwise running this flake will not work.
dotfiles = {
url = "git+ssh://[email protected]/aymanbagabas/dotfiles.local?shallow=1";
flake = false;
};
# WARNING: Do NOT pin the `nixpkgs` input, as that will
# declare the cache useless. If you do, you will have
# to compile LLVM, Zig and Ghostty itself on your machine,
# which will take a very very long time.
ghostty = {
url = "git+ssh://[email protected]/mitchellh/ghostty";
};
};
outputs =
inputs@{
self,
nixpkgs,
home-manager,
darwin,
nur,
...
}:
let
overlays = [ nur.overlays.default ];
mkSystem = import ./lib/mksystem.nix { inherit nixpkgs overlays inputs; };
# Generate a list of systems based on their hostname
mkSystems =
list:
builtins.listToAttrs (
map (x: {
name = x.hostname;
value = mkSystem x;
}) list
);
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.unix;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system overlays; });
in
{
nixosConfigurations = mkSystems [
{
hostname = "media";
system = "x86_64-linux";
isHeadless = true;
}
{
hostname = "traffic";
system = "x86_64-linux";
isHeadless = true;
}
{
hostname = "genericlxc";
system = "x86_64-linux";
isHeadless = true;
}
];
darwinConfigurations = mkSystems [
{
hostname = "spaceship";
system = "x86_64-darwin";
}
{
hostname = "blackhole";
system = "aarch64-darwin";
}
];
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShellNoCC {
shellHook = ''
# Use GitHub access tokens to avoid rate limiting
export NIX_CONFIG="access-tokens = github=$(${pkgs.gh}/bin/gh auth token)"
'';
buildInputs = with pkgs; [
(writeScriptBin "dot-release" ''
git tag -m "$(date +%Y-%m-%d)" "$(date +%Y-%m-%d)"
git push --tags
'')
(writeScriptBin "dot-update" ''
nix flake update
dot-apply "$@"
'')
(writeScriptBin "dot-sync" ''
dot-update
nix-collect-garbage -d
dot-apply "$@"
'')
(writeScriptBin "dot-apply" ''
case "$(uname -s)" in
Linux)
sudo nixos-rebuild switch --flake .#$HOST "$@"
;;
Darwin)
HOST=$(hostname | cut -f1 -d'.')
nix run nix-darwin -- switch --flake .#$HOST "$@"
;;
*)
echo "Unsupported OS"
exit 1
;;
esac
'')
];
};
}
);
};
}