Skip to content

Commit 7af00ed

Browse files
udpate
1 parent 877ca81 commit 7af00ed

File tree

15 files changed

+419
-94
lines changed

15 files changed

+419
-94
lines changed

.config/spacemacs/.spacemacs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,18 +1033,36 @@ _p_rev _u_pper _=_: upper/lower _r_esolve
10331033
(interactive)
10341034
(dired "/ssh:admin@192.168.1.100:/"))
10351035

1036+
(defun connect-kube-node1 ()
1037+
"Open a remote folder using TRAMP in Dired."
1038+
(interactive)
1039+
(dired "/ssh:proxmox@192.168.2.10:/"))
1040+
1041+
(defun connect-kube-node2 ()
1042+
"Open a remote folder using TRAMP in Dired."
1043+
(interactive)
1044+
(dired "/ssh:proxmox@192.168.2.12:/"))
1045+
1046+
(defun connect-kube-node3 ()
1047+
"Open a remote folder using TRAMP in Dired."
1048+
(interactive)
1049+
(dired "/ssh:proxmox@192.168.2.13:/"))
1050+
10361051
(defhydra hydra/diredssh (:hint nil :color blue)
10371052
"
1038-
SSH Connections
1039-
--------------------------
1040-
_f_: factorio/monolith
1041-
_p_: Pi
1042-
_m_: Macos
1053+
SSH Connections Kubernetes Nodes
1054+
-------------------------- --------------------------
1055+
_f_: factorio/monolith _1_: kube-node1
1056+
_p_: Pi _2_: kube-node2
1057+
_m_: Macos _3_: kube-node3
10431058
_q_: Cancel
10441059
"
1045-
("f" connect-factorio :color yellow)
1060+
("f" connect-monolith :color yellow)
10461061
("p" connect-pi :color yellow)
10471062
("m" connect-macos :color yellow)
1063+
("1" connect-kube-node1 :color yellow)
1064+
("2" connect-kube-node2 :color yellow)
1065+
("3" connect-kube-node3 :color yellow)
10481066
("q" nil "cancel" :color blue))
10491067
(spacemacs/set-leader-keys "ods" 'hydra/diredssh/body)
10501068
;; --- sops --

nix-darwin/containers/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
imports = [
33
./n8n.nix
4+
./nginx.nix
45
./postgres.nix
56
./protonmail-bridge.nix
67
./redis.nix

nix-darwin/containers/nginx.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{ lib, config, ... }:
2+
3+
let
4+
cfg = config.container.nginx;
5+
in
6+
{
7+
options = {
8+
container.nginx = {
9+
enable = lib.mkEnableOption "nginx container";
10+
name = lib.mkOption {
11+
type = lib.types.str;
12+
default = "nginx";
13+
};
14+
mountPoint = lib.mkOption {
15+
type = lib.types.str;
16+
default = "/tmp/nginx";
17+
};
18+
ports = lib.mkOption {
19+
type = lib.types.listOf lib.types.str;
20+
default = [ "8080:80" ];
21+
};
22+
};
23+
};
24+
25+
config = lib.mkIf cfg.enable {
26+
virtualisation = {
27+
oci-containers = {
28+
backend = "docker";
29+
containers = {
30+
nginx = {
31+
image = "nginx:latest";
32+
volumes = [
33+
"${cfg.mountPoint}/html:/usr/share/nginx/html"
34+
"${cfg.mountPoint}/conf:/etc/nginx/conf.d"
35+
];
36+
ports = cfg.ports;
37+
};
38+
};
39+
};
40+
};
41+
};
42+
}

nix-darwin/flakes/monolith/configuration.nix

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
isNormalUser = false;
6262
extraGroups = [ "smbaccess" ];
6363
};
64+
users.users.paperless = {
65+
isNormalUser = false;
66+
extraGroups = [ "smbaccess" ];
67+
};
6468
users.users.${meta.username} = {
6569
isNormalUser = true;
6670
extraGroups = [
@@ -250,6 +254,26 @@
250254
entryPoints = [ "web" ];
251255
middlewares = [ "strip-nextcloud-prefix" ];
252256
};
257+
258+
paperless-router = {
259+
rule = "PathPrefix(`/paperless`)";
260+
service = "paperless-service";
261+
entryPoints = [ "web" ];
262+
middlewares = [ "strip-paperless-prefix" ];
263+
};
264+
265+
transmission-router = {
266+
rule = "PathPrefix(`/transmission`)";
267+
service = "transmission-service";
268+
entryPoints = [ "web" ];
269+
middlewares = [ "strip-transmission-prefix" ];
270+
};
271+
homepage-router = {
272+
rule = "PathPrefix(`/homepage`)";
273+
service = "homepage-service";
274+
entryPoints = [ "web" ];
275+
middlewares = [ "strip-homepage-prefix" ];
276+
};
253277
};
254278

255279
services = {
@@ -276,6 +300,24 @@
276300
{ url = "http://0.0.0.0:9999"; }
277301
];
278302
};
303+
304+
paperless-service = {
305+
loadBalancer.servers = [
306+
{ url = "http://0.0.0.0:28981"; }
307+
];
308+
};
309+
310+
transmission-service = {
311+
loadBalancer.servers = [
312+
{ url = "http://0.0.0.0:9091"; }
313+
];
314+
};
315+
316+
homepage-service = {
317+
loadBalancer.servers = [
318+
{ url = "http://0.0.0.0:8082"; }
319+
];
320+
};
279321
};
280322
middlewares = {
281323
strip-n8n-prefix = {
@@ -293,6 +335,19 @@
293335
strip-nextcloud-prefix = {
294336
stripPrefix.prefixes = [ "/nextcloud" ];
295337
};
338+
339+
strip-paperless-prefix = {
340+
stripPrefix.prefixes = [ "/paperless" ];
341+
};
342+
343+
strip-transmission-prefix = {
344+
stripPrefix.prefixes = [ "/torrent" ];
345+
};
346+
347+
# not working
348+
strip-homepage-prefix = {
349+
stripPrefix.prefixes = [ "/homepage" ];
350+
};
296351
};
297352
};
298353
};
@@ -305,8 +360,6 @@
305360
enable = true;
306361
openFirewall = true;
307362
settings = {
308-
# N8N_LISTEN_ADDRESS= "0.0.0.0";
309-
# N8N_SECURE_COOKIE = false;
310363
};
311364
};
312365
#INFO: a way to set env vars for services
@@ -356,13 +409,37 @@
356409
};
357410
services.paperless = {
358411
enable = true;
412+
port = 28981;
413+
address = "0.0.0.0";
414+
settings = {
415+
# https://docs.paperless-ngx.com/configuration/
416+
PAPERLESS_FORCE_SCRIPT_NAME = "/paperless";
417+
PAPERLESS_STATIC_URL = "/paperless";
418+
PAPERLESS_CONSUMPTION_DIR = "/mnt/rice/paperless/consume";
419+
PAPERLESS_DATA_DIR = "/mnt/rice/paperless/data";
420+
PAPERLESS_MEDIA_ROOT = "/mnt/rice/paperless/media";
421+
PAPERLESS_STATICDIR = "/mnt/rice/paperless/static";
422+
# PAPERLESS_ADMIN_USER=<username>
423+
# PAPERLESS_ADMIN_MAIL=<email>
424+
# PAPERLESS_ADMIN_PASSWORD=<password>
425+
};
426+
};
427+
services.homepage-dashboard = {
428+
enable = true;
429+
listenPort = 8082;
430+
openFirewall = true;
431+
settings = {
432+
"base" = "http://0.0.0.0/homepage";
433+
};
359434
};
360-
361435
services.transmission = {
362436
enable = true;
363437
openFirewall = true;
438+
openPeerPorts = true;
364439
settings = {
365-
"download-dir" = "/mnt/rice/famjam/transmission";
440+
download-dir = "/mnt/rice/transmission";
441+
rpc-port = 9091;
442+
rpc-url = "/torrent/";
366443
};
367444
};
368445

nix-darwin/flakes/monolith/fstab.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
"defaults"
1515
];
1616
};
17+
fileSystems."/mnt/rice/paperless" = {
18+
device = "//192.168.4.223/rice/paperless";
19+
fsType = "cifs";
20+
options = [
21+
"credentials=/root/smbcreds_fam"
22+
"dir_mode=0770"
23+
"file_mode=0770"
24+
"uid=paperless" # Set paperless as the owner
25+
"gid=smbaccess"
26+
"rw"
27+
"nofail" # Don't fail boot if mount fails
28+
];
29+
};
1730
# create user for read only/
1831
# for nextcloud (and folder specific)
1932
}

nix-darwin/home-modules/programs/spacemacs.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
ispell
3434
proton-pass
3535
protonmail-bridge # for email
36+
devcontainer
3637
];
3738
};
3839

nix-learning/README.org

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ From that point on, nix is on your system and you can already use it (if you ope
2323
nix shell nixpkgs#cowsay
2424
#+end_src
2525

26-
2726
***** Configuring system
2827
We will be using flakes as they are the nix equivalent of a ~Dockerfile~ and can provide multiple outputs.
2928

@@ -55,71 +54,41 @@ nix run nix-darwin -- switch --flake .
5554
darwin-rebuild switch --flake . # --dry-run
5655
#+end_src
5756

57+
One more quick demo of the on the fly pattern
58+
#+begin_src zsh
59+
nix shell nixpkgs#fzf nixpkgs#neovim
60+
nvim "$(fzf)"
61+
#+end_src
62+
63+
You can use nix like a devcontainer
64+
#+begin_src zsh
65+
nix develop
66+
nix develop .#anotherEnv
67+
#+end_src
68+
5869
To rollback
5970
#+begin_src zsh
6071
nix profile history --profile /nix/var/nix/profiles/system
6172
# or
62-
6373
darwin-rebuild switch --list-generations
6474
# to undo latest
6575
darwin-rebuild switch --rollback
6676
# or revert to a specific version
6777
darwin-rebuild switch --switch-generation 1
6878
#+end_src
69-
***** Video references
70-
[[https://www.youtube.com/watch?v=Z8BL8mdzWHI][Nix is my favorite package manager to use on macOS - YouTube]]
71-
[[https://www.youtube.com/watch?v=iU7B76NTr2I][Nix Darwin Turned My Mac into a Fully Automated Machine - YouTube]]
79+
7280
***** Update
7381
#+begin_src bash
7482
nix flake update
7583
#+end_src
76-
**** Linux (non-NixOS)
77-
Very similar to Macos except the template is different
78-
#+begin_src zsh
79-
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
80-
sh -s -- install --determinate
81-
#+end_src
82-
83-
#+begin_src zsh
84-
nix flake init # creates a basic flake (hello world)
85-
#+end_src
86-
87-
88-
***** Configuring system
89-
We can only use home-manager to configure our computer. To do so we can must install it.
90-
[[https://nix-community.github.io/home-manager/#sec-install-standalone][Home Manager Manual]]
91-
92-
If the nix bug infected you, I can only recommend that you move to Nix-OS
93-
94-
That being said we will be using the following flake [[file:rocky-linux/flake.nix][rocky-nix flake]]
95-
96-
In the aforementioned file we will
97-
#+begin_src zsh
98-
sudo nix run .#create-user-script
99-
sudo passwd rocky # Set password interactively
100-
home-manager switch --flake .#rocky
101-
#+end_src
102-
103-
***** Demo
104-
105-
#+begin_src zsh
106-
ssh rocky@192.168.4.245
107-
# ensure that it has rsync on the machine
108-
rsync -avz ~/Documents/dotFiles/nix-learning/rocky-linux/ rocky@192.168.4.215:~/Documents/
84+
*** limitation
85+
- not able to declare containers using ~virtualisation~ like nixos
86+
- not all packages are compatibles with x86_64-darwin or aarch_64-darwin
87+
- no systemd which is a big bummer
10988

110-
# applying the config
111-
home-manager switch --flake .#rocky
112-
113-
# rollback
114-
home-manager generations # list all generations
115-
# I actually don't know how to do this
116-
#+end_src
117-
118-
One more quick demo of the on the fly pattern
119-
#+begin_src zsh
120-
nix shell nixpkgs#fzf nixpkgs#neovim
121-
nvim "$(fzf)"
122-
#+end_src
89+
**** Video references
90+
[[https://www.youtube.com/watch?v=Z8BL8mdzWHI][Nix is my favorite package manager to use on macOS - YouTube]]
91+
[[https://www.youtube.com/watch?v=iU7B76NTr2I][Nix Darwin Turned My Mac into a Fully Automated Machine - YouTube]]
12392

12493
*** Searching/using packages
12594
Nixos has an extensive package manager repository

0 commit comments

Comments
 (0)