Skip to content

Commit 8fbeffb

Browse files
working
1 parent ea7c94f commit 8fbeffb

37 files changed

+1199
-371
lines changed

hp/hp1/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ rebuild_trace:
3030
update:
3131
sudo nix flake update;
3232

33+
update_flake:
34+
sudo nix --extra-experimental-features nix-command --extra-experimental-features flakes flake update
35+
3336
sync:
34-
rsync -av /home/das/nixos/hp/hp1/ hp1:/home/das/nixos/hp/hp1/
37+
rsync -av /home/das/nixos/hp/"${EXPECTED_HOSTNAME}"/ "${EXPECTED_HOSTNAME}":/home/das/nixos/hp/"${EXPECTED_HOSTNAME}"/
3538
#rsync -av /home/das/nixos/modules/ hp1:/home/das/nixos/modules/
3639

3740
# https://nixos.wiki/wiki/Kubernetes#reset_to_a_clean_state

hp/hp1/configuration.nix

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#
2+
# hp/hp1/configuration.nix
3+
#
14
{ config, pkgs, ... }:
25

36
# https://nixos.wiki/wiki/FAQ#How_can_I_install_a_package_from_unstable_while_remaining_on_the_stable_channel.3F
@@ -60,17 +63,28 @@
6063
};
6164

6265
nix = {
66+
settings = {
67+
auto-optimise-store = true;
68+
experimental-features = [ "nix-command" "flakes" ];
69+
download-buffer-size = "100000000";
70+
builders-use-substitutes = true;
71+
};
72+
# https://nix.dev/tutorials/nixos/distributed-builds-setup.html#set-up-distributed-builds
73+
distributedBuilds = true;
74+
buildMachines = [{
75+
hostName = "hp4";
76+
sshUser = "remotebuild";
77+
#sshKey = "/root/.ssh/remotebuild";
78+
sshKey = "/home/das/.ssh/remotebuild";
79+
system = pkgs.stdenv.hostPlatform.system;
80+
supportedFeatures = [ "nixos-test" "big-parallel" "kvm" ];
81+
}];
6382
gc = {
6483
automatic = true; # Enable automatic execution of the task
6584
dates = "weekly"; # Schedule the task to run weekly
6685
options = "--delete-older-than 10d"; # Specify options for the task: delete files older than 10 days
6786
randomizedDelaySec = "14m"; # Introduce a randomized delay of up to 14 minutes before executing the task
6887
};
69-
settings = {
70-
auto-optimise-store = true;
71-
experimental-features = [ "nix-command" "flakes" ];
72-
download-buffer-size = "100000000";
73-
};
7488
};
7589

7690
# find /run/opengl-driver -name "libamfrt64.so.1"
@@ -102,9 +116,6 @@
102116
# Set your time zone.
103117
time.timeZone = "America/Los_Angeles";
104118

105-
# Enable touchpad support (enabled default in most desktopManager).
106-
# services.xserver.libinput.enable = true;
107-
108119
environment.sessionVariables = {
109120
TERM = "xterm-256color";
110121
#MY_VARIABLE = "my-value";
@@ -121,9 +132,24 @@
121132
# https://nixos.wiki/wiki/SSH_public_key_authentication
122133
openssh.authorizedKeys.keys = [
123134
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGMCFUMSCFJX95eLfm7P9r72NBp9I1FiXwNwJ+x/HGPV das@t"
135+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOP3x3r8OZ5ya1GNLqmKOsKDX7oAR+BG9u4EozXvydtC das@hp0"
124136
];
125137
};
126138

139+
# # https://github.com/colemickens/nixcfg/blob/1915d408ea28a5b7279f94df7a982dbf2cf692ef/mixins/ssh.nix#L13C1-L28C7
140+
# system.activationScripts.root_ssh_config = {
141+
# text = ''
142+
# (
143+
# # symlink root ssh config to ours so daemon can use our agent/keys/etc...
144+
# mkdir -p /root/.ssh
145+
# ln -sf /home/das/.ssh/config /root/.ssh/config
146+
# ln -sf /home/das/.ssh/known_hosts /root/.ssh/known_hosts
147+
# ln -sf /home/das/.ssh/known_hosts /root/.ssh/known_hosts
148+
# )
149+
# '';
150+
# deps = [ ];
151+
# };
152+
127153
# Some programs need SUID wrappers, can be configured further or are
128154
# started in user sessions.
129155
# programs.mtr.enable = true;
@@ -136,6 +162,8 @@
136162
enableSSHSupport = true;
137163
};
138164

165+
166+
# https://nixos.wiki/wiki/SSH
139167
services.openssh.enable = true;
140168

141169
services.timesyncd.enable = true;

hp/hp1/flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hp/hp1/flake.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
};
1717
};
1818

19+
nixConfig = {
20+
extra-substituters = [
21+
"http://hp4:5000"
22+
];
23+
extra-trusted-public-keys = [
24+
"hp4:YkYI70Fsy07fHWdh++V82b5Lgz03J9oE3KcIiFaJg8w="
25+
];
26+
};
27+
1928
outputs = inputs@{ nixpkgs, home-manager, ... }:
2029
let
2130
system = "x86_64-linux";

hp/hp1/home.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,57 @@
136136
#signing.signByDefault = true;
137137
};
138138

139+
# https://github.com/nix-community/home-manager/blob/master/modules/programs/ssh.nix
140+
# https://mynixos.com/home-manager/options/programs.ssh
141+
# programs.ssh = {
142+
# enable = true;
143+
# # controlPath = "~/.ssh/control/master-%r@%h:%p";
144+
# # controlPersist = "10m";
145+
# # compression = true;
146+
# # serverAliveInterval = 5;
147+
# extraConfig = ''
148+
# Host hp4
149+
# User remotebuild
150+
# IdentityFile ~/.ssh/remotebuild
151+
# Host *
152+
# User das
153+
# KeepAlive yes
154+
# ServerAliveInterval 10
155+
# Protocol 2
156+
# #UseRoaming no
157+
# ForwardAgent yes
158+
# KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
159+
# Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
160+
# # temp hmac-md5
161+
# #MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-md5
162+
# MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
163+
# ControlMaster auto
164+
# ControlPath ~/.ssh/master-%r@%h:%p
165+
# ControlPersist 10m
166+
# Compression yes
167+
# Connecttimeout 10
168+
# HashKnownHosts no
169+
# '';
170+
171+
# matchBlocks = {
172+
# "hp4" = {
173+
# #hostname = "localhost";
174+
# #port = 2222;
175+
# #identityFile = remotebuild;
176+
# };
177+
# "*" = {
178+
# # everything sucks about SSH_AUTH_SOCK, so let's just control
179+
# # it and what it points to directly
180+
# User = "das";
181+
# KeepAlive = "yes";
182+
# ServerAliveInterval = 10;
183+
# Protocol = 2;
184+
# };
185+
# };
186+
#};
187+
#aws ssh example
188+
#https://discourse.nixos.org/t/is-there-a-nix-way-to-configure-ssh-server-connections/28033/7?u=randomizedcoder
189+
139190
nixpkgs.config.allowUnfree = true;
140191

141192
programs.home-manager.enable = true;

hp/hp1/test_distributed_build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
nix-build --max-jobs 0 -E << EOF
4+
(import <nixpkgs> {}).writeText "test" "$(date)"
5+
EOF

hp/hp4/Makefile

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# nixos/hp4/Makefile
2+
# nixos/hp/hp4/Makefile
33
#
44
EXPECTED_HOSTNAME := hp4
55

@@ -16,14 +16,25 @@ else
1616
endif
1717

1818
rebuild:
19-
sudo cp /home/das/nixos/modules/* /etc/nixos/
20-
sudo cp ./*.nix /etc/nixos/
21-
sudo nix-channel --update
22-
sudo nixos-rebuild switch
19+
#sudo cp /home/das/nixos/modules/* /etc/nixos/
20+
#sudo cp ./*.nix /etc/nixos/
21+
#sudo nix-channel --update
22+
#sudo nixos-rebuild switch
23+
#sudo nix-channel --update;
24+
sudo nixos-rebuild switch --flake .
25+
26+
rebuild_trace:
27+
sudo nixos-rebuild switch --show-trace --flake .
28+
29+
update:
30+
sudo nix flake update;
31+
32+
update_flake:
33+
sudo nix --extra-experimental-features nix-command --extra-experimental-features flakes flake update
2334

2435
sync:
25-
rsync -av /home/das/nixos/hp/hp4/ hp4:/home/das/nixos/hp4/
26-
rsync -av /home/das/nixos/modules/ hp4:/home/das/nixos/modules/
36+
rsync -av /home/das/nixos/hp/"${EXPECTED_HOSTNAME}"/ "${EXPECTED_HOSTNAME}":/home/das/nixos/hp/"${EXPECTED_HOSTNAME}"/
37+
#rsync -av /home/das/nixos/modules/ hp1:/home/das/nixos/modules/
2738

2839
# https://nixos.wiki/wiki/Kubernetes#reset_to_a_clean_state
2940
nuke_k8s: check_hostname delete_k8s
@@ -32,6 +43,12 @@ delete_k8s:
3243
sudo rm -rf /var/lib/kubernetes/ /var/lib/etcd/ /var/lib/cfssl/ /var/lib/kubelet/
3344
sudo rm -rf /etc/kube-flannel/ /etc/kubernetes/
3445

46+
nuke_k3s: check_hostname delete_k3s
47+
48+
delete k3s:
49+
sudo rm -rf /var/lib/rancher/k3s/ /etc/rancher/k3s
50+
k3s-killall.sh
51+
3552
create_cert:
3653
# Generate private key
3754
openssl genrsa -out /var/lib/kubernetes/secrets/cluster-admin.pem 4096
@@ -42,6 +59,16 @@ create_cert:
4259
# Issue certificate
4360
openssl ca -config ./openssl_ca_config -in /var/lib/kubernetes/secrets/cluster-admin.csr -out /var/lib/kubernetes/secrets/cluster-admin.crt -days 365 -notext -batch
4461

62+
# https://nixos.wiki/wiki/Binary_Cache
63+
# curl http://localhost:5000/nix-cache-info
64+
setup_nix_serve:
65+
cd /var
66+
nix-store --generate-binary-cache-key hp4 cache-priv-key.pem cache-pub-key.pem
67+
chown nix-serve cache-priv-key.pem
68+
chmod 600 cache-priv-key.pem
69+
cat cache-pub-key.pem
4570

71+
copy_lock:
72+
scp hp4:/home/das/nixos/hp/hp4/flake.lock ./
4673

4774
# end

hp/hp4/athens.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{ pkgs, config, ... }:
2+
{
3+
services.athens = {
4+
enable = true;
5+
#openFirewall = true; # this doesn't exist any more?
6+
port = 8888;
7+
logLevel = "debug";
8+
# storageType = "disk"; # disk is default
9+
# diskStorageRoot = "/var/lib/athens";
10+
#goBinary = unstable.go;
11+
# https://mynixos.com/nixpkgs/option/services.athens.goBinary
12+
goGetWorkers = 32; # default 10
13+
indexType = "memory"; # default none
14+
statsExporter = "prometheus";
15+
};
16+
# https://mynixos.com/nixpkgs/options/services.athens
17+
# https://github.com/ditsuke/nixpkgs-compat/blob/master/nixos/modules/services/development/athens.md
18+
# https://github.com/ditsuke/nixpkgs-compat/blob/master/nixos/modules/services/development/athens.nix
19+
# journalctl -u athens.service -f
20+
}

hp/hp4/authorizedKeys

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINjiY/MIQUyp58JXt+fuy1mQWCZfFhbYoRK6jJN5ZxeV root@t
2+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMO7liZykpeI/ggPRBXQswdLAZWNWj+h8QA3hzQLi0ai das@hp1

hp/hp4/cache-pub-key.pem

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hp4:YkYI70Fsy07fHWdh++V82b5Lgz03J9oE3KcIiFaJg8w=

0 commit comments

Comments
 (0)