-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.nix
168 lines (155 loc) · 4.38 KB
/
config.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
args@{
inputs,
lib ? args.pkgs.lib,
pkgs ? { },
}:
let
hardwareModules = inputs.nixos-hardware.nixosModules;
hosts = {
hamilton = {
name = "hamilton";
system = "x86_64-linux";
host = ./hosts/hamilton;
roles = [
hardwareModules.asus-zephyrus-ga502
./roles/dev
./roles/gaming
./roles/education
./roles/productivity
./roles/desktop/gnome
./roles/desktop/email
./roles/internet/syncthing
./roles/internet/ipfs
];
keys.ssh = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO5JejZv7d0tOG1QXxbHVt4qhp8nMpOfSGTMsL/l98kf" ];
};
macadamia = {
name = "macadamia";
system = "x86_64-linux";
host = ./hosts/macadamia;
roles = [
hardwareModules.apple-macbook-pro-14-1
./roles/dev
./roles/productivity
./roles/desktop/gnome
./roles/desktop/email
./roles/internet/syncthing
./roles/internet/ipfs
];
keys.ssh = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPnTI64CyDnCoQFZKWI0T1Z6YcyVW8XrJypWxD9HdMGW" ];
};
sakamoto = {
name = "sakamoto";
system = "x86_64-linux";
host = ./hosts/sakamoto;
roles = [
hardwareModules.framework-16-7040-amd
./roles/dev
./roles/gaming
./roles/education
./roles/productivity
./roles/desktop/gnome
./roles/desktop/email
./roles/internet/syncthing
./roles/internet/ipfs
];
keys.ssh = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBPQ3PpMq59iLXy5j/r/mwTlrZsU2xhyDtTXdHv6yM7b" ];
};
};
# "release" = [ "pkgs-0.1.0" "to-0.2.0" "allow-0.3.0];
# i.e. `"23.11" = [ "hello-2.12.1" ];`
permittedInsecurePackages = {
"24.05" = [ "electron-27.3.11" ];
};
# "release" = [ "pkgs-0.1.0" "to-0.2.0" "allow-0.3.0];
# i.e. `"23.11" = [ "hello-2.12.1" ];`
# the entries are regex patterns
permittedUnfreePatterns = {
unstable = [
"canon-cups-ufr2"
"drawio"
"flagfox"
"geogebra"
"steam(-(run|original|unwrapped))?"
];
};
user = {
name = "mib";
email = "[email protected]";
};
defaults = {
editor = "nvim";
};
shell = {
aliases =
let
dotnixDir = "~/dev/dotnix";
in
rec {
e = defaults.editor;
se = "sudo ${e}";
ns = "nom shell";
nd = "nom develop";
lsblk = "lsblk -o NAME,SIZE,TYPE,FSTYPE,FSVER,MOUNTPOINTS";
build = "nom build ${dotnixDir}#nixosConfigurations.$(hostname).config.system.build.toplevel --out-link /tmp/nixos-configuration && nvd diff /run/current-system /tmp/nixos-configuration";
switch = "sudo nixos-rebuild switch --flake ${dotnixDir}#$(hostname)";
rebuild = "${build} && sudo /tmp/nixos-configuration/bin/switch-to-configuration switch";
rebuild-offline = "${build} --offline && ${switch} --offline";
tmp = "pushd $(mktemp -d)";
gc-nix = "nix-env --delete-generations +3 && nix store gc --verbose && nix store optimise --verbose";
};
functions = {
# Find directory in dev folder based on search and cd into it
dev =
let
fdOpts = "--type=directory --full-path ~/dev/nixpkgs/*";
in
''
cd $(fzf \
--bind 'start:reload:fd "" ~/dev ${fdOpts}' \
--bind 'change:reload:fd {q} ~/dev ${fdOpts} || true' \
--preview='tree -CL 2 {}' \
--height=50% --layout=reverse \
--query "$argv")
'';
# killall, but works wrapped programs
killall-nix = ''
name="$1"
shift
for pid in $(pgrep "$name"); do
echo "killing $pid";
kill "$@" "$pid";
done
'';
# unlink result symlinks
cleanup-results =
let
cleanup = pkgs.writeShellScript "cleanup.sh" ''
for link in "$@"
do
target=$(readlink -f "$link")
printf "\n%s -> %s" "$link" "$target"
case $target in "/nix/store/"*)
printf " [unlinked]"
unlink "$link"
esac
done
'';
in
''fd '^result(-[a-zA-Z]+)?$' --type symlink --unrestricted --exec-batch ${cleanup}'';
};
};
gpg = {
#keyId = "";
};
in
{
inherit
hosts
user
defaults
shell
gpg
;
inherit permittedInsecurePackages permittedUnfreePatterns;
}