Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 107 additions & 88 deletions .config/spacemacs/.spacemacs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions nix-darwin/containers/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
imports = [
./n8n.nix
./nginx.nix
./postgres.nix
./protonmail-bridge.nix
./redis.nix
Expand Down
42 changes: 42 additions & 0 deletions nix-darwin/containers/nginx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ lib, config, ... }:

let
cfg = config.container.nginx;
in
{
options = {
container.nginx = {
enable = lib.mkEnableOption "nginx container";
name = lib.mkOption {
type = lib.types.str;
default = "nginx";
};
mountPoint = lib.mkOption {
type = lib.types.str;
default = "/tmp/nginx";
};
ports = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "8080:80" ];
};
};
};

config = lib.mkIf cfg.enable {
virtualisation = {
oci-containers = {
backend = "docker";
containers = {
nginx = {
image = "nginx:latest";
volumes = [
"${cfg.mountPoint}/html:/usr/share/nginx/html"
"${cfg.mountPoint}/conf:/etc/nginx/conf.d"
];
ports = cfg.ports;
};
};
};
};
};
}
2 changes: 1 addition & 1 deletion nix-darwin/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
quadlet-nix.nixosModules.quadlet
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
# home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs;
Expand Down
86 changes: 82 additions & 4 deletions nix-darwin/flakes/monolith/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
isNormalUser = false;
extraGroups = [ "smbaccess" ];
};
users.users.paperless = {
isNormalUser = false;
extraGroups = [ "smbaccess" ];
};
users.users.${meta.username} = {
isNormalUser = true;
extraGroups = [
Expand Down Expand Up @@ -88,6 +92,7 @@
];

# secrets
# if you change the secret strucutre you must first create the new secret and then rebuild and then change its reference in the config
sops = {
defaultSopsFile = ./secrets/secrets.yaml;
defaultSopsFormat = "yaml";
Expand Down Expand Up @@ -249,6 +254,26 @@
entryPoints = [ "web" ];
middlewares = [ "strip-nextcloud-prefix" ];
};

paperless-router = {
rule = "PathPrefix(`/paperless`)";
service = "paperless-service";
entryPoints = [ "web" ];
middlewares = [ "strip-paperless-prefix" ];
};

transmission-router = {
rule = "PathPrefix(`/transmission`)";
service = "transmission-service";
entryPoints = [ "web" ];
middlewares = [ "strip-transmission-prefix" ];
};
homepage-router = {
rule = "PathPrefix(`/homepage`)";
service = "homepage-service";
entryPoints = [ "web" ];
middlewares = [ "strip-homepage-prefix" ];
};
};

services = {
Expand All @@ -275,6 +300,24 @@
{ url = "http://0.0.0.0:9999"; }
];
};

paperless-service = {
loadBalancer.servers = [
{ url = "http://0.0.0.0:28981"; }
];
};

transmission-service = {
loadBalancer.servers = [
{ url = "http://0.0.0.0:9091"; }
];
};

homepage-service = {
loadBalancer.servers = [
{ url = "http://0.0.0.0:8082"; }
];
};
};
middlewares = {
strip-n8n-prefix = {
Expand All @@ -292,6 +335,19 @@
strip-nextcloud-prefix = {
stripPrefix.prefixes = [ "/nextcloud" ];
};

strip-paperless-prefix = {
stripPrefix.prefixes = [ "/paperless" ];
};

strip-transmission-prefix = {
stripPrefix.prefixes = [ "/torrent" ];
};

# not working
strip-homepage-prefix = {
stripPrefix.prefixes = [ "/homepage" ];
};
};
};
};
Expand All @@ -304,8 +360,6 @@
enable = true;
openFirewall = true;
settings = {
# N8N_LISTEN_ADDRESS= "0.0.0.0";
# N8N_SECURE_COOKIE = false;
};
};
#INFO: a way to set env vars for services
Expand Down Expand Up @@ -355,13 +409,37 @@
};
services.paperless = {
enable = true;
port = 28981;
address = "0.0.0.0";
settings = {
# https://docs.paperless-ngx.com/configuration/
PAPERLESS_FORCE_SCRIPT_NAME = "/paperless";
PAPERLESS_STATIC_URL = "/paperless";
PAPERLESS_CONSUMPTION_DIR = "/mnt/rice/paperless/consume";
PAPERLESS_DATA_DIR = "/mnt/rice/paperless/data";
PAPERLESS_MEDIA_ROOT = "/mnt/rice/paperless/media";
PAPERLESS_STATICDIR = "/mnt/rice/paperless/static";
# PAPERLESS_ADMIN_USER=<username>
# PAPERLESS_ADMIN_MAIL=<email>
# PAPERLESS_ADMIN_PASSWORD=<password>
};
};
services.homepage-dashboard = {
enable = true;
listenPort = 8082;
openFirewall = true;
settings = {
"base" = "http://0.0.0.0/homepage";
};
};

services.transmission = {
enable = true;
openFirewall = true;
openPeerPorts = true;
settings = {
"download-dir" = "/mnt/rice/famjam/transmission";
download-dir = "/mnt/rice/transmission";
rpc-port = 9091;
rpc-url = "/torrent/";
};
};

Expand Down
13 changes: 13 additions & 0 deletions nix-darwin/flakes/monolith/fstab.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
"defaults"
];
};
fileSystems."/mnt/rice/paperless" = {
device = "//192.168.4.223/rice/paperless";
fsType = "cifs";
options = [
"credentials=/root/smbcreds_fam"
"dir_mode=0770"
"file_mode=0770"
"uid=paperless" # Set paperless as the owner
"gid=smbaccess"
"rw"
"nofail" # Don't fail boot if mount fails
];
};
# create user for read only/
# for nextcloud (and folder specific)
}
2 changes: 2 additions & 0 deletions nix-darwin/home-modules/programs/spacemacs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
gcc
libgccjit
editorconfig-core-c
ispell
proton-pass
protonmail-bridge # for email
devcontainer
];
};

Expand Down
3 changes: 2 additions & 1 deletion nix-darwin/users/henri.vandersleyen/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
};
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # for nix.nix
};

nixpkgs = {
hostPlatform = "aarch64-darwin";
config.allowUnfree = true;
config.allowBroken = true; # temporary
config.allowUnsupportedSystem = true;
};

Expand Down Expand Up @@ -62,6 +62,7 @@
'';

# Homebrew needs to be installed on its own!
system.primaryUser = username;
homebrew = {
enable = true;
casks = [
Expand Down
5 changes: 5 additions & 0 deletions nix-darwin/users/henri/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
hostname = "192.168.4.129";
user = "henri";
};
macos = {
# ssh macos
hostname = "192.168.4.245";
user = "macos";
};
factorio = {
# ssh factorio
hostname = "192.168.4.129";
Expand Down
71 changes: 20 additions & 51 deletions nix-learning/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ From that point on, nix is on your system and you can already use it (if you ope
nix shell nixpkgs#cowsay
#+end_src


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

Expand Down Expand Up @@ -55,71 +54,41 @@ nix run nix-darwin -- switch --flake .
darwin-rebuild switch --flake . # --dry-run
#+end_src

One more quick demo of the on the fly pattern
#+begin_src zsh
nix shell nixpkgs#fzf nixpkgs#neovim
nvim "$(fzf)"
#+end_src

You can use nix like a devcontainer
#+begin_src zsh
nix develop
nix develop .#anotherEnv
#+end_src

To rollback
#+begin_src zsh
nix profile history --profile /nix/var/nix/profiles/system
# or

darwin-rebuild switch --list-generations
# to undo latest
darwin-rebuild switch --rollback
# or revert to a specific version
darwin-rebuild switch --switch-generation 1
#+end_src
***** Video references
[[https://www.youtube.com/watch?v=Z8BL8mdzWHI][Nix is my favorite package manager to use on macOS - YouTube]]
[[https://www.youtube.com/watch?v=iU7B76NTr2I][Nix Darwin Turned My Mac into a Fully Automated Machine - YouTube]]

***** Update
#+begin_src bash
nix flake update
#+end_src
**** Linux (non-NixOS)
Very similar to Macos except the template is different
#+begin_src zsh
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
sh -s -- install --determinate
#+end_src

#+begin_src zsh
nix flake init # creates a basic flake (hello world)
#+end_src


***** Configuring system
We can only use home-manager to configure our computer. To do so we can must install it.
[[https://nix-community.github.io/home-manager/#sec-install-standalone][Home Manager Manual]]

If the nix bug infected you, I can only recommend that you move to Nix-OS

That being said we will be using the following flake [[file:rocky-linux/flake.nix][rocky-nix flake]]

In the aforementioned file we will
#+begin_src zsh
sudo nix run .#create-user-script
sudo passwd rocky # Set password interactively
home-manager switch --flake .#rocky
#+end_src

***** Demo

#+begin_src zsh
ssh rocky@192.168.4.245
# ensure that it has rsync on the machine
rsync -avz ~/Documents/dotFiles/nix-learning/rocky-linux/ rocky@192.168.4.215:~/Documents/
*** limitation
- not able to declare containers using ~virtualisation~ like nixos
- not all packages are compatibles with x86_64-darwin or aarch_64-darwin
- no systemd which is a big bummer

# applying the config
home-manager switch --flake .#rocky

# rollback
home-manager generations # list all generations
# I actually don't know how to do this
#+end_src

One more quick demo of the on the fly pattern
#+begin_src zsh
nix shell nixpkgs#fzf nixpkgs#neovim
nvim "$(fzf)"
#+end_src
**** Video references
[[https://www.youtube.com/watch?v=Z8BL8mdzWHI][Nix is my favorite package manager to use on macOS - YouTube]]
[[https://www.youtube.com/watch?v=iU7B76NTr2I][Nix Darwin Turned My Mac into a Fully Automated Machine - YouTube]]

*** Searching/using packages
Nixos has an extensive package manager repository
Expand Down
10 changes: 10 additions & 0 deletions nix-learning/macos/.sops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# careful when changing keys
keys:
- &primary age1df2u7xvze6rq5utz74ckx059wr3z97j484wc04063437h6hn4v6s9auec3
- &work age17jgvjp9u4wa6799e3utfqxfrq9mgkfhxxed02cpp642tm6cna9gqg4yafw
creation_rules:
- path_regex: secrets/.*\.yaml$
key_groups:
- age:
- *primary
- *work
Loading