Skip to content

Commit 2c2f112

Browse files
authored
Merge pull request #18 from vancycles-knak/main
update
2 parents c2caf62 + 7af00ed commit 2c2f112

File tree

19 files changed

+569
-161
lines changed

19 files changed

+569
-161
lines changed

.config/spacemacs/.spacemacs

Lines changed: 107 additions & 88 deletions
Large diffs are not rendered by default.

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/flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
quadlet-nix.nixosModules.quadlet
113113
home-manager.nixosModules.home-manager
114114
{
115-
home-manager.useGlobalPkgs = true;
115+
# home-manager.useGlobalPkgs = true;
116116
home-manager.useUserPackages = true;
117117
home-manager.extraSpecialArgs = {
118118
inherit inputs;

nix-darwin/flakes/monolith/configuration.nix

Lines changed: 82 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 = [
@@ -88,6 +92,7 @@
8892
];
8993

9094
# secrets
95+
# if you change the secret strucutre you must first create the new secret and then rebuild and then change its reference in the config
9196
sops = {
9297
defaultSopsFile = ./secrets/secrets.yaml;
9398
defaultSopsFormat = "yaml";
@@ -249,6 +254,26 @@
249254
entryPoints = [ "web" ];
250255
middlewares = [ "strip-nextcloud-prefix" ];
251256
};
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+
};
252277
};
253278

254279
services = {
@@ -275,6 +300,24 @@
275300
{ url = "http://0.0.0.0:9999"; }
276301
];
277302
};
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+
};
278321
};
279322
middlewares = {
280323
strip-n8n-prefix = {
@@ -292,6 +335,19 @@
292335
strip-nextcloud-prefix = {
293336
stripPrefix.prefixes = [ "/nextcloud" ];
294337
};
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+
};
295351
};
296352
};
297353
};
@@ -304,8 +360,6 @@
304360
enable = true;
305361
openFirewall = true;
306362
settings = {
307-
# N8N_LISTEN_ADDRESS= "0.0.0.0";
308-
# N8N_SECURE_COOKIE = false;
309363
};
310364
};
311365
#INFO: a way to set env vars for services
@@ -355,13 +409,37 @@
355409
};
356410
services.paperless = {
357411
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+
};
358434
};
359-
360435
services.transmission = {
361436
enable = true;
362437
openFirewall = true;
438+
openPeerPorts = true;
363439
settings = {
364-
"download-dir" = "/mnt/rice/famjam/transmission";
440+
download-dir = "/mnt/rice/transmission";
441+
rpc-port = 9091;
442+
rpc-url = "/torrent/";
365443
};
366444
};
367445

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
gcc
3131
libgccjit
3232
editorconfig-core-c
33+
ispell
3334
proton-pass
3435
protonmail-bridge # for email
36+
devcontainer
3537
];
3638
};
3739

nix-darwin/users/henri.vandersleyen/configuration.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
};
2929
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # for nix.nix
3030
};
31-
3231
nixpkgs = {
3332
hostPlatform = "aarch64-darwin";
3433
config.allowUnfree = true;
34+
config.allowBroken = true; # temporary
3535
config.allowUnsupportedSystem = true;
3636
};
3737

@@ -62,6 +62,7 @@
6262
'';
6363

6464
# Homebrew needs to be installed on its own!
65+
system.primaryUser = username;
6566
homebrew = {
6667
enable = true;
6768
casks = [

nix-darwin/users/henri/home.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
hostname = "192.168.4.129";
5353
user = "henri";
5454
};
55+
macos = {
56+
# ssh macos
57+
hostname = "192.168.4.245";
58+
user = "macos";
59+
};
5560
factorio = {
5661
# ssh factorio
5762
hostname = "192.168.4.129";

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)