Compare commits

6 Commits

Author SHA1 Message Date
John Lancaster 3da3cc2dc6 cleanup 2026-03-25 18:33:54 -05:00
John Lancaster 18b6cc16ad more pruning 2026-03-25 18:17:07 -05:00
John Lancaster d8ced840ca pruning 2026-03-25 18:07:19 -05:00
John Lancaster 2fad88f8a0 added root_ca content 2026-03-25 18:07:08 -05:00
John Lancaster 7b0f419454 WIP CA bootstrap rework 2026-03-25 17:55:31 -05:00
John Lancaster f8c09878a1 started p14s transition 2026-03-25 17:29:37 -05:00
44 changed files with 584 additions and 1492 deletions
-6
View File
@@ -9,12 +9,6 @@ creation_rules:
- age: - age:
- *john-pc - *john-pc
- *soteria - *soteria
- *test-nix
- path_regex: john-p14s/secrets\.yaml$
key_groups:
- age:
- *john-p14s
- *john-pc
- path_regex: john-pc/secrets\.yaml$ - path_regex: john-pc/secrets\.yaml$
key_groups: key_groups:
- age: - age:
Generated
+26 -197
View File
@@ -1,28 +1,12 @@
{ {
"nodes": { "nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1751685974,
"narHash": "sha256-NKw96t+BgHIYzHUjkTK95FqYRVKB8DHpVhefWSz/kTw=",
"ref": "refs/heads/main",
"rev": "549f2762aebeff29a2e5ece7a7dc0f955281a1d1",
"revCount": 92,
"type": "git",
"url": "https://git.lix.systems/lix-project/flake-compat.git"
},
"original": {
"type": "git",
"url": "https://git.lix.systems/lix-project/flake-compat.git"
}
},
"flake-file": { "flake-file": {
"locked": { "locked": {
"lastModified": 1774886516, "lastModified": 1773554778,
"narHash": "sha256-w2LoQVM6DXrSdGUZBZqa1nYkMzHoB0t82DrptzZKhTs=", "narHash": "sha256-keH0VNsci9e0Uwt3Msp/N+pltaP8Lb6lt09Q3WvDPw4=",
"owner": "vic", "owner": "vic",
"repo": "flake-file", "repo": "flake-file",
"rev": "3daadf37de2bb85b0ff34e2a7ab0d71e077c2b9e", "rev": "f4780a86bd4c756475d839b286f8a40aabdbc802",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -38,32 +22,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1775087534, "lastModified": 1772408722,
"narHash": "sha256-91qqW8lhL7TLwgQWijoGBbiD4t7/q75KTi8NxjVmSmA=", "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "3107b77cd68437b9a76194f0f7f9c55f2329ca5b", "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": [
"nvf",
"nixpkgs"
]
},
"locked": {
"lastModified": 1769996383,
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -95,11 +58,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1775080052, "lastModified": 1773608492,
"narHash": "sha256-jAB4ZZbx8ECu9GcE/PUUwT+wpooZ0Ssmn2imB8PVTdM=", "narHash": "sha256-QZteyExJYSQzgxqdsesDPbQgjctGG7iKV/6ooyQPITk=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "6267895e9898399f0ce2fe79b645e9ee4858aaff", "rev": "9a40ec3b78fc688d0908485887d355caa5666d18",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -110,11 +73,11 @@
}, },
"import-tree": { "import-tree": {
"locked": { "locked": {
"lastModified": 1773693634, "lastModified": 1773554199,
"narHash": "sha256-BtZ2dtkBdSUnFPPFc+n0kcMbgaTxzFNPv2iaO326Ffg=", "narHash": "sha256-6apV5N1F5tTD8JY9AUGnkWmy56HqDPn4MNFRsq4Rg+s=",
"owner": "vic", "owner": "vic",
"repo": "import-tree", "repo": "import-tree",
"rev": "c41e7d58045f9057880b0d85e1152d6a4430dbf1", "rev": "c6ebc59c85ee54cfb68163d06d1a3149ce0fe431",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -123,43 +86,6 @@
"type": "github" "type": "github"
} }
}, },
"mnw": {
"locked": {
"lastModified": 1770419553,
"narHash": "sha256-b1XqsH7AtVf2dXmq2iyRr2NC1yG7skY7Z6N2MpWHlK4=",
"owner": "Gerg-L",
"repo": "mnw",
"rev": "2aaffa8030d0b262176146adbb6b0e6374ce2957",
"type": "github"
},
"original": {
"owner": "Gerg-L",
"repo": "mnw",
"type": "github"
}
},
"ndg": {
"inputs": {
"nixpkgs": [
"nvf",
"nixpkgs"
]
},
"locked": {
"lastModified": 1768214250,
"narHash": "sha256-hnBZDQWUxJV3KbtvyGW5BKLO/fAwydrxm5WHCWMQTbw=",
"owner": "feel-co",
"repo": "ndg",
"rev": "a6bd3c1ce2668d096e4fdaaa03ad7f03ba1fbca8",
"type": "github"
},
"original": {
"owner": "feel-co",
"ref": "refs/tags/v2.6.0",
"repo": "ndg",
"type": "github"
}
},
"nixgl": { "nixgl": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
@@ -184,11 +110,11 @@
"nixos-hardware": { "nixos-hardware": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1774933469, "lastModified": 1774465523,
"narHash": "sha256-OrnCQeUO2bqaWUl0lkDWyGWjKsOhtCyd7JSfTedQNUE=", "narHash": "sha256-4v7HPm63Q90nNn4fgkgKsjW1AH2Klw7XzPtHJr562nM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "f4c4c2c0c923d7811ac2a63ccc154767e4195337", "rev": "de895be946ad1d8aafa0bb6dfc7e7e0e9e466a29",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -199,11 +125,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1774709303, "lastModified": 1773389992,
"narHash": "sha256-D3Q07BbIA2KnTcSXIqqu9P586uWxN74zNoCH3h2ESHg=", "narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8110df5ad7abf5d4c0f6fb0f8f978390e77f9685", "rev": "c06b4ae3d6599a672a6210b7021d699c351eebda",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -215,58 +141,17 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1775064974, "lastModified": 1773507054,
"narHash": "sha256-PqhsO5qloSyvATi9qAIrgUcEFK67xSoacjacPw+t4H0=", "narHash": "sha256-yzDBkI1CpeZrAt4l1nGvTOs3OFtXCS7a7Gi5Y1h878w=",
"rev": "6ebfbc38bdc6b22822a6f991f2d922306f33cfbc", "rev": "e80236013dc8b77aa49ca90e7a12d86f5d8d64c9",
"type": "tarball", "type": "tarball",
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre973084.6ebfbc38bdc6/nixexprs.tar.xz" "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre963414.e80236013dc8/nixexprs.tar.xz"
}, },
"original": { "original": {
"type": "tarball", "type": "tarball",
"url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz" "url": "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1774610258,
"narHash": "sha256-HaThtroVD9wRdx7KQk0B75JmFcXlMUoEdDFNOMOlsOs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "832efc09b4caf6b4569fbf9dc01bec3082a00611",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nvf": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts_2",
"mnw": "mnw",
"ndg": "ndg",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_2"
},
"locked": {
"lastModified": 1774852850,
"narHash": "sha256-7VK4v7ZbQw5apfgc+FvgRi8BUC45ERlcp8VTTTQ3tko=",
"owner": "notashelf",
"repo": "nvf",
"rev": "b4d6539e7e9948aaba5efd7a67a63672d1fa80ef",
"type": "github"
},
"original": {
"owner": "notashelf",
"repo": "nvf",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-file": "flake-file", "flake-file": "flake-file",
@@ -279,10 +164,7 @@
"nixpkgs-lib": [ "nixpkgs-lib": [
"nixpkgs" "nixpkgs"
], ],
"nvf": "nvf", "sops-nix": "sops-nix"
"sops-nix": "sops-nix",
"wrapper-modules": "wrapper-modules",
"wrappers": "wrappers"
} }
}, },
"sops-nix": { "sops-nix": {
@@ -292,11 +174,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1774910634, "lastModified": 1773550941,
"narHash": "sha256-B+rZDPyktGEjOMt8PcHKYmgmKoF+GaNAFJhguktXAo0=", "narHash": "sha256-wa/++bL2QeMUreNFBZEWluQfOYB0MnQIeGNMuaX9sfs=",
"owner": "Mic92", "owner": "Mic92",
"repo": "sops-nix", "repo": "sops-nix",
"rev": "19bf3d8678fbbfbc173beaa0b5b37d37938db301", "rev": "c469b6885f0dcd5c7c56bd935a0f08dbcd9e79e1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -319,59 +201,6 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"wrapper-modules": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1774879171,
"narHash": "sha256-a6JZDuBIwQmuEwYM4dziH+WyrpE8HCP8F7JFIn3CNvw=",
"owner": "BirdeeHub",
"repo": "nix-wrapper-modules",
"rev": "bab35ffae25cf6f4e4fdb3c2f7f0ac80966ce737",
"type": "github"
},
"original": {
"owner": "BirdeeHub",
"repo": "nix-wrapper-modules",
"type": "github"
}
},
"wrappers": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1774293387,
"narHash": "sha256-yVekLWxKTUfUyuvo9HVihtOK8llIP3IZCrJmftxT+Nc=",
"owner": "lassulus",
"repo": "wrappers",
"rev": "3cf1e8371129e8746d37c863c5d56a81fb16caa0",
"type": "github"
},
"original": {
"owner": "lassulus",
"repo": "wrappers",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",
-9
View File
@@ -21,18 +21,9 @@
}; };
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz";
nixpkgs-lib.follows = "nixpkgs"; nixpkgs-lib.follows = "nixpkgs";
nvf = {
url = "github:notashelf/nvf";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = { sops-nix = {
url = "github:Mic92/sops-nix"; url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
wrapper-modules.url = "github:BirdeeHub/nix-wrapper-modules";
wrappers = {
url = "github:lassulus/wrappers";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
} }
-2
View File
@@ -4,6 +4,4 @@
# https://github.com/vic/flake-file/tree/main/modules/dendritic # https://github.com/vic/flake-file/tree/main/modules/dendritic
inputs.flake-file.flakeModules.dendritic inputs.flake-file.flakeModules.dendritic
]; ];
systems = [ "x86_64-linux" "aarch64-linux" ];
} }
-16
View File
@@ -1,16 +0,0 @@
# This module is for programs with GUIs that run in a desktop environment
{ self, inputs, ... }: {
flake.modules.homeManager.desktop = { config, pkgs, lib, ... }: {
imports = with inputs.self.modules.homeManager; [
brave
ghostty
onepassword
vscode
];
home.packages = with pkgs; [
mangohud
sublime4
proton-vpn
];
};
}
-64
View File
@@ -1,64 +0,0 @@
{ self, inputs, ... }: {
flake.modules.nixos.forgejo = {config, pkgs, lib, ... }:
let
cfg = config.forgejo;
in
{
options.forgejo = {
enable = lib.mkEnableOption "Enable Forgejo backed with PostgreSQL";
port = lib.mkOption {
type = lib.types.port;
default = 3000;
description = "TCP port for the Forgejo web interface.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Open the Forgejo web interface port in the firewall.";
};
https = lib.mkEnableOption "Open the Forgejo web interface port in the firewall.";
};
config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ cfg.port ];
services.forgejo = {
enable = true;
lfs.enable = true;
settings.server = lib.mkMerge [
{
HTTP_PORT = cfg.port;
DISABLE_SSH = true;
}
(lib.mkIf cfg.https {
ROOT_URL = "https://forgejo.john-stream.com";
PROTOCOL = "https";
COOKIE_SECURE = true;
KEY_FILE = config.mtls.keyFile;
CERT_FILE = config.mtls.certFile;
})
];
database = {
type = "postgres";
port = config.services.postgresql.settings.port;
# createDatabase = false;
};
# dump = {
# enable = true;
# interval = "12h";
# };
};
services.postgresql = {
enable = true;
settings = {
};
};
};
};
}
-107
View File
@@ -1,107 +0,0 @@
{ inputs, ... }: {
flake.modules.nixos.gnome = {pkgs, ... }: {
services = {
desktopManager.gnome.enable = true;
displayManager.gdm = {
enable = true;
wayland = true;
banner = "Welcome to John's NixOS implementation";
};
udev.packages = [
pkgs.gnome-settings-daemon # For gnome systray icons
];
};
};
flake.modules.homeManager.gnome = { config, pkgs, ... }:
let
# `gnome-extensions list` for a list
extensions = with pkgs.gnomeExtensions; [
appindicator # For gnome systray icons
dash-to-panel
gtile
space-bar
switcher
tactile
vitals
];
enabledExtensions = map (ext: ext.extensionUuid) extensions;
in
{
gtk = {
enable = true;
theme = {
name = "Orchis-Dark";
package = pkgs.orchis-theme;
};
gtk4.theme = config.gtk.theme;
};
home.packages = [ pkgs.gnome-tweaks ] ++ extensions;
dconf.settings = {
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
};
"org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = enabledExtensions;
};
"org/gnome/desktop/wm/preferences" = {
button-layout = ":minimize,close";
};
"org/gnome/desktop/wm/keybindings" = {
"switch-to-workspace-1" = ["<Super>1"];
"switch-to-workspace-2" = ["<Super>2"];
"switch-to-workspace-3" = ["<Super>3"];
"switch-to-workspace-4" = ["<Super>4"];
"move-to-workspace-1" = ["<Shift><Super>1"];
"move-to-workspace-2" = ["<Shift><Super>2"];
"move-to-workspace-3" = ["<Shift><Super>3"];
"move-to-workspace-4" = ["<Shift><Super>4"];
};
"org/gnome/settings-daemon/plugins/media-keys" = {
custom-keybindings = [
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/edit-nix/"
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/launch-browser/"
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/ad-dev/"
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/shutdown/"
];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/edit-nix" = {
binding = "<Primary><Alt>n";
command = "code /etc/nixos";
name = "Edit Nix config";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/launch-browser" = {
binding = "<Primary><Alt>b";
command = "brave";
name = "Launch Brave browser";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/ad-dev" = {
binding = "<Primary><Alt>d";
command = ''code --file-uri "vscode-remote://ssh-remote+ad-nix/etc/nixos/ad-nix.code-workspace"'';
name = "Launch AppDaemon Development over Tailscale";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/ws1" = {
binding = "<Super>1";
command = "wmctrl -s 0";
name = "Switch to workspace 1";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/shutdown" = {
binding = "<Primary><Alt>p";
command = "gnome-session-quit --power-off --force";
name = "Shutdown immediately";
};
};
};
}
-28
View File
@@ -1,28 +0,0 @@
# https://github.com/glabrie/dotfiles/blob/main/modules/system/settings/greetd.nix
{ inputs, ... }: {
flake.modules.nixos.greetd = { pkgs, lib, ... }: {
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${lib.getExe pkgs.tuigreet} --time --remember --cmd niri-session";
user = "greeter";
};
};
};
systemd.services.greetd.serviceConfig = {
Type = "idle";
StandardInput = "tty";
StandardOutput = "tty";
StandardError = "journal"; # Without this errors will spam on screen
# Without these bootlogs will spam on screen
TTYReset = true;
TTYVHangup = true;
TTYVTDisallocate = true;
};
# Let's allow our keyring to work from the start
security.pam.services.greetd.enableGnomeKeyring = true;
};
}
+14 -48
View File
@@ -2,37 +2,12 @@
let let
username = "john"; username = "john";
hostname = "janus"; hostname = "janus";
ca-url = "https://janus.john-stream.com/";
fingerprint = "2036c44f7b5901566ff7611ea6c927291ecc6d2dd00779c0eead70ec77fa10d6";
in in
{ {
flake.modules.nixos.janus-ca =
{ config, lib, ... }:
let
johnHome = lib.attrByPath [ "users" "users" username "home" ] "/home/${username}" config;
johnGroup = lib.attrByPath [ "users" "users" username "group" ] username config;
mkStepRules = home: user: group: [
"d ${home}/.step 0700 ${user} ${group} -"
"d ${home}/.step/config 0700 ${user} ${group} -"
"d ${home}/.step/certs 0700 ${user} ${group} -"
"L+ ${home}/.step/config/defaults.json - - - - /etc/step/config/defaults.json"
"L+ ${home}/.step/certs/root_ca.crt - - - - /etc/step/certs/root_ca.crt"
];
in
{
environment.etc."step/config/defaults.json".text = builtins.toJSON {
inherit ca-url fingerprint;
root = "/etc/step-ca/certs/root_ca.crt";
};
environment.etc."step-ca/certs/root_ca.crt".source = ./root_ca.crt;
systemd.tmpfiles.rules =
mkStepRules johnHome username johnGroup
++ mkStepRules "/root" "root" "root";
};
flake.modules.homeManager.janus-ca = { config, ... }: { flake.modules.homeManager.janus-ca = { config, ... }: {
home.file.".step/config/defaults.json".text = builtins.toJSON { home.file.".step/config/defaults.json".text = builtins.toJSON {
inherit ca-url fingerprint; "ca-url" = "https://janus.john-stream.com/";
fingerprint = "2036c44f7b5901566ff7611ea6c927291ecc6d2dd00779c0eead70ec77fa10d6";
root = "${config.home.homeDirectory}/.step/certs/root_ca.crt"; root = "${config.home.homeDirectory}/.step/certs/root_ca.crt";
}; };
home.file.".step/certs/root_ca.crt".source = ./root_ca.crt; home.file.".step/certs/root_ca.crt".source = ./root_ca.crt;
@@ -43,9 +18,9 @@ in
nixos.lxc nixos.lxc
nixos.mysops nixos.mysops
nixos.step-ssh-host nixos.step-ssh-host
nixos.janus-ca
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
nixos."${username}" nixos."${username}"
nixos.zsh
nixos.docker nixos.docker
nixos.login-text nixos.login-text
nixos.mtls nixos.mtls
@@ -65,32 +40,23 @@ in
home-manager.users."${username}" = { home-manager.users."${username}" = {
imports = with inputs.self.modules.homeManager; [ imports = with inputs.self.modules.homeManager; [
mysops sops
step-ssh-user step-ssh-user
janus-ca
]; ];
shell.program = "zsh"; shell.program = "zsh";
docker.enable = true; docker.enable = true;
# step-ssh-user = {
# enable = true;
# principals = [ "${hostname}" ];
# };
ssh.matchSets = {
certs = true;
homelab = true;
};
}; };
} }
]; ];
}; };
flake-file.inputs = {
wrappers = {
url = "github:lassulus/wrappers";
inputs.nixpkgs.follows = "nixpkgs";
};
};
perSystem = { pkgs, lib, ... }: {
packages.janus-ca = inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.step-cli;
binName = "janus-cert";
args = [
"ca" "certificate"
"--ca-url=${ca-url}"
];
};
};
} }
+53 -59
View File
@@ -1,35 +1,40 @@
{ self, inputs, ... }: { self, inputs, ... }:
{ {
flake.modules.nixos.p14sConfiguration = { config, pkgs, lib, ... }: flake.modules.nixos.p14sConfiguration = { pkgs, lib, ... }: {
let
hostname = "john-p14s";
homeDirectory = config.home-manager.users.john.home.homeDirectory;
flakeDir = "${homeDirectory}/Documents/dendritic";
my-neovim = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.my-neovim;
in
{
imports = [ imports = [
self.modules.nixos.p14sHardware self.modules.nixos.p14sHardware
]; ];
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];
nixpkgs.config = { nixpkgs.config.allowUnfree = true;
permittedInsecurePackages = [ "openssl-1.1.1w" ];
allowUnfree = true;
};
rebuild.flakeDir = flakeDir;
networking = { networking = {
hostName = hostname; hostName = "john-p14s";
networkmanager.enable = true; networkmanager.enable = true;
}; };
# Enable automatic login for the user. # Enable automatic login for the user.
# services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.enable = true;
# services.displayManager.autoLogin.user = "john"; services.displayManager.autoLogin.user = "john";
# Define a user account. Don't forget to set a password with 'passwd'.
users.users.john = {
isNormalUser = true;
description = "John Lancaster";
extraGroups = [
"networkmanager"
"wheel"
"docker"
];
shell = pkgs.zsh;
};
programs.zsh.enable = true; programs.zsh.enable = true;
# Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@tty1".enable = false;
services.openssh.enable = true; services.openssh.enable = true;
services.tailscale.enable = true; services.tailscale.enable = true;
@@ -41,9 +46,16 @@
busybox busybox
dig dig
samba samba
my-neovim
]; ];
virtualisation.docker = {
enable = true;
enableOnBoot = true;
};
# For gnome systray icons
services.udev.packages = with pkgs; [ gnome-settings-daemon ];
security.pam.services.swaylock = {}; security.pam.services.swaylock = {};
security.pam.services.swaylock.fprintAuth = true; security.pam.services.swaylock.fprintAuth = true;
@@ -59,6 +71,24 @@
# This is needed for VSCode remote support. Read: https://nixos.wiki/wiki/Visual_Studio_Code # This is needed for VSCode remote support. Read: https://nixos.wiki/wiki/Visual_Studio_Code
programs.nix-ld.enable = true; programs.nix-ld.enable = true;
programs.steam = {
enable = true;
gamescopeSession.enable = true;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
};
# progams.gamemode.enable = true;
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave # on your system were taken. It's perfectly fine and recommended to leave
@@ -71,9 +101,9 @@
time.timeZone = "America/Chicago"; time.timeZone = "America/Chicago";
# Select internationalisation properties. # Select internationalisation properties.
i18n = { i18n.defaultLocale = "en_US.UTF-8";
defaultLocale = "en_US.UTF-8";
extraLocaleSettings = { i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8"; LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8"; LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8"; LC_MEASUREMENT = "en_US.UTF-8";
@@ -84,10 +114,9 @@
LC_TELEPHONE = "en_US.UTF-8"; LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8"; LC_TIME = "en_US.UTF-8";
}; };
};
services.libinput.enable = true; # Enable touchpad support (enabled default in most desktopManager). # Enables fingerprint sensor
services.fprintd.enable = true; # Enables fingerprint sensor services.fprintd.enable = true;
# Enable sound with pipewire. # Enable sound with pipewire.
services.pulseaudio.enable = false; services.pulseaudio.enable = false;
@@ -105,40 +134,5 @@
# media-session.enable = true; # media-session.enable = true;
}; };
home-manager.users.root = {
imports = with inputs.self.modules.homeManager; [
rebuild
];
home.stateVersion = "25.11";
};
home-manager.users.john.imports = with inputs.self.modules.homeManager; [
gnome
desktop
mysops
rebuild
{
my-vscode.enable = true;
mysops.hostSecretFile = "${flakeDir}/modules/hosts/john-p14s/secrets.yaml";
homeManagerFlakeDir = "${flakeDir}";
shell.program = "zsh";
home.packages = with pkgs; [
bash
discord
my-neovim
];
ssh.matchSets = {
appdaemon = true;
homelab = true;
dev = true;
certs = true;
};
}
];
sops.defaultSopsFile = ./secrets.yaml;
sops.age.sshKeyPaths = [ "${homeDirectory}/.ssh/id_ed25519" ];
mtls = {
enable = true;
subject = hostname;
};
}; };
} }
+2 -13
View File
@@ -10,18 +10,7 @@
modules = [ modules = [
"${inputs.nixos-hardware}/lenovo/thinkpad/p14s" "${inputs.nixos-hardware}/lenovo/thinkpad/p14s"
"${inputs.nixos-hardware}/lenovo/thinkpad/p14s/amd/gen4" "${inputs.nixos-hardware}/lenovo/thinkpad/p14s/amd/gen4"
] ++ (with self.modules.nixos; [ self.modules.nixos.p14sConfiguration
p14sConfiguration ];
janus-ca
rebuild
sudo
john
gnome
steam
wireguard
mtls
# greetd
# niri
]);
}; };
} }
+7 -26
View File
@@ -1,28 +1,16 @@
{ self, inputs, ... }: { { self, inputs, ... }: {
flake.modules.nixos.p14sHardware = { config, lib, pkgs, modulesPath, ... }: { flake.modules.nixos.p14sHardware = { config, lib, pkgs, modulesPath, ... }: {
imports = [ imports =[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
initrd = {
availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "usbhid" "sd_mod" ];
kernelModules = [ "amdgpu" ];
};
kernelModules = [ "kvm-amd" ];
extraModulePackages = [ ];
};
# boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
# boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
# boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "usbhid" "sd_mod" ];
# boot.initrd.kernelModules = [ "amdgpu" ]; boot.initrd.kernelModules = [ "amdgpu" ];
# boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
# boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = { fileSystems."/" = {
device = "/dev/disk/by-uuid/fbc7d8bc-080b-4554-a2b2-5f92d059ce07"; device = "/dev/disk/by-uuid/fbc7d8bc-080b-4554-a2b2-5f92d059ce07";
@@ -48,12 +36,5 @@
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.graphics = {
enable = true;
enable32Bit = true;
extraPackages = [ pkgs.rocmPackages.clr.icd ];
};
environment.variables.AMD_VULKAN_ICD = "RADV";
}; };
} }
-26
View File
@@ -1,26 +0,0 @@
restic_password: ENC[AES256_GCM,data:8KeL7kOMTHkK+ZpY3aq0/S4UYbkZh72FxJAolcVes79NPfdHiNi77fmAZuXb8Gxasu16vk4y6ksWFmrZquvcbg+cLt8Yze+qvuCiUW62IOppzRIBLk6w2f8uPhU41gsVuj6u4Jz/Su7miNBvJYmF8vulIwDKS7qg43dzIKXY4q1HaRHCD12PkU9EfGpIgivdNCOO0lCE6m/O3IB8Ed4R51scBnVrIj89K5OuTepvIrGElmXiWqBdsTzCIaJCZJ8fDnzJPorLhsTAzKCnQhNoIrW/aYArzj9+WmglmGuqeaoemBoNTrYC9bssUwuWAOqsf1HC7gWST/dP9FmKl7UHlgkslblRcRedFPAQjDhy/RgZCj8hs/XrVYOzwW8WJ0XeB9UPK03QPJc8EZdz9r2Q0+U3LQxMV6Jne5JZGsMpII4b+7b/WbRZTooX3G09MES/gzwD+hyBr++6EpP9QTYs+4XsNLNN+S6y5+YS/7XmRvR7xb93eZ4EfUUKiQYejVKQBl9b8QTJa3q26RPa/82O5zQlzd1w/EjA4G6Vv8H6wvK0fHNwpU3hl9V8EL7Ca7JKfJr11Vw0fNHx2nXjOLURt27wbDeWUaSrzI+z2h/0TSiKWas/Eu5+4L9n7E3H5u5Hg2uaCQkDpy6RJkW9UL6lCC1YEJw5yHTugrPNoMcRlAKRoSIeSZSPfGl0CKYAC39s422xX2f46GpJu0bO8GG/XN9Qk+SxqPHGuzx7nWghFQctZb1ssGKuvHKqaNYZvWeWqqkxyPWb6xjaBaSGxcp5MsET+RAu2F1XgX9Is11mIJETlHhRE3OpMSHh7toIiuNs8YzsgkedVFWhx+Xu27DWvOFvg/01Rh6s5RGJKMgL7WQMLTtY2KI/ko648WXVoCtVymG8d30qWnSt8319jkILX/wdB8Vqp5ceRqHwDE89jhEh0GOg07eLcREnh+gjXij1/bS66/+hHk4jhkzGtbdfEji9sro4Nm+kVRA+6fgJjCvt1sAvjuj10Scx4uH3AdDTW+y0KaniK8EHTZzaGDuaV+tk3hZEfpwpdan5mquoQvFdZWsWlDefX7gRq38szmi9LtULEai0WKOtqnnDIOnWk/3NYeNdzJ28YzrUDbkxtghkRgr7fNGEtyCGRuWRRMc5mVp2FPzAwRKk29ShILpWbvfUzwAWUOEpyAS4bstzlMybf9L8sp20+Ier8gOMGJ81eXXXmhtgMn6aWZ6EDGe1Shl0gDM0JUEAkA2+kf3oIZAvcWiFxj7vyd4Aacw3RetUSJcy8JwbV3I/isxKyy/xs8zE2PUY0z3Cwh9MpVP9G8N6Mef6v2DNDNg+2iJ/eslQdbZRQzdJwnBMhpOopzRwuUaC7jJKyGBkcNbbmNjceJWEue0XVjIcZHJ7BFe3jKluezNIJIf268V35+HIpXJA7BUJn8NPCIQXze5Frm46U2aRTQ53LU4HBGLXYPzx8QLsn0jLVy518w/TztawdT3/SmSWNwYTuZG18TmXs9v3oB6PrUr4M7kJbNRLpRb0ZelbMDwpR074FPwwud6fkjR2lLQBbufmPUBdpVJZ2xFjijle8h1h29zoFsydFNq5wSXUO/nm/S09KdKi5F2S1uKP+NL80OVEeC+QXcBdTry07meVIhsBOh+9ajy1ExaMaPs2xjB5QvTgJA9kfJOAoUygjMC33FwdRw10eGP//IsiRm9EukF1o++MfZnAtcjhoOoy79TjlO8p8YVNwEhZ14Ik/kIizyQtr0gR+pVEIc6+1W29UOWNRXb+ZavXRDq0wvxigMagfcL+zIr4gctufTfubiOmVa85qVJB,iv:VogP+OQvlsYCSqlmffO+o99C0hJm63ZqLXVd2B0oom0=,tag:+se1QHW6xLMj/dZrbY0MKQ==,type:str]
wireguard_private_key: ENC[AES256_GCM,data:sCskwDhemU1y4M4A4R9KxwiL8q+FtxnUqg1omU7yS81H1bbSM804hNzmq+A=,iv:7wNMAG+7wYYXYgKEohIAYisMN5lbz+M5RhCEaHL4yWE=,tag:FENdJTEEGD9cEJVwIIUQDA==,type:str]
sops:
age:
- recipient: age1f6drjusg866yscj8029tk4yfpgecklrvezldm02ankm6h8nnwu5s2u6ahy
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBHS0F1R0NnV0gyNFlkUEhZ
UkxvN1ZLQTFsV0tnR0pLNFJycmduU1VXUlFVCjBkRGxQd1B1c3cweTRsZm9OUCt0
anU3RTFUUkxoaXlhdlR0RkxPclVUdVkKLS0tIG9kTEVNK2piRWI5ZWFSejFFUGtD
emtTUGk0cVZWR3F5R05WTTFJUFUwNTAKrRYQAJen6QVSgaOyqPxSIniHiMLUfXuv
/O1Ebz5xLWn99EhloqW7rHhUxXlhxP2CmwfYXizyKFa6nAu6R+BCgg==
-----END AGE ENCRYPTED FILE-----
- recipient: age1ykcs39e62pz3xu6cedg8ea685kv5d5qsrhgkndygzm8rx30xd5ys5t3qxt
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBXNWRXZTFWREIzRVhRaWRB
anNDb3hsZzFOMFMrclhmeldaOWY4b3BJekFBCkJhbjRvRUwva3lFbzNTKzJqK2p2
WVlMaXpvczlhdGduZHIrb2xPaEg3OUUKLS0tIHFtM09mN0FEUWdjWEVEL3VXL00w
WHpOY280S2hpVU1mNnozODRoMnB4bGMKK5RrDK2kAZlWf2igqyzWgshxLPj+f74A
mCmMLDHo5drNieFYp+guqHaHnZkf9IzpAglj7x6wCITjk+l6go5KvA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2026-03-27T03:59:09Z"
mac: ENC[AES256_GCM,data:MsPAxssWUSvsJQP0Ogrl3r/GoVqeL1L95YTJQbAJZ4FVxhRXP7KfbUnKSclzU6G8CP5WxV18TXZfB4JITKG3Lz5rtVpD/WFMdhDmve0f6BPMAimle2ajWUaWYNePvEynClX3nydLk3h31DjHGa8YvJZqW2ieDb/JDMdBXiLTrWc=,iv:82ul5CV3XXllFCDJfF6beIcAIFj71ycJJF4iEQvovMA=,tag:108L7VkAoPUTLtV74qgrrA==,type:str]
unencrypted_suffix: _unencrypted
version: 3.12.2
+19 -27
View File
@@ -1,27 +1,17 @@
{ self, inputs, ... }: { inputs, ... }:
let let
username = "john"; username = "john";
hostname = "john-pc-ubuntu"; hostname = "john-pc-ubuntu";
# testTarget = "fded:fb16:653e:25da:be24:11ff:fea0:753f"; # test-nix
testHost = "soteria"; # which host to test build testTarget = "fded:fb16:653e:25da:be24:11ff:fe89:1cc3"; # soteria
testTarget = "fded:fb16:653e:25da:be24:11ff:fea0:753f"; # test-nix
# testTarget = "fded:fb16:653e:25da:be24:11ff:fe89:1cc3"; # soteria
in in
{ {
flake.modules.homeManager."${hostname}" = { config, pkgs, lib, ... }: flake.modules.homeManager."${hostname}" = { pkgs, config, ... }:
let let
flakeDir = "${config.xdg.configHome}/home-manager/jsl-dendritic"; flakeDir = "${config.xdg.configHome}/home-manager/jsl-dendritic";
certDir = "${config.mtls.certDir}";
mtlsBundle = "${certDir}/${config.mtls.bundleFilename}";
resticPasswordFile = "${config.xdg.configHome}/restic/password.txt"; resticPasswordFile = "${config.xdg.configHome}/restic/password.txt";
testPushCmd = (pkgs.writeShellScriptBin "test-push" ''
${lib.getExe' pkgs.coreutils "echo"} "Pushing ${testHost} to ${testTarget}"
${lib.getExe' pkgs.coreutils "mkdir"} -p /var/tmp/nix-build
${lib.getExe' pkgs.coreutils "chmod"} 1777 /var/tmp/nix-build
${lib.getExe pkgs.nixos-rebuild} switch \
--flake ${flakeDir}#${testHost} \
--target-host root@${testTarget}
'');
in in
{ {
imports = with inputs.self.modules.homeManager; [ imports = with inputs.self.modules.homeManager; [
@@ -34,23 +24,28 @@ in
restic restic
docker docker
desktop desktop
# neovim
]; ];
# TODO: make this more restrictive, rather than allowing all unfree packages
nixpkgs.config.allowUnfree = true;
nixpkgs.config.permittedInsecurePackages = [ "openssl-1.1.1w" ];
targets.genericLinux.enable = true; targets.genericLinux.enable = true;
shell.program = "zsh";
home.username = "${username}"; home.username = "${username}";
home.homeDirectory = "/home/${username}"; home.homeDirectory = "/home/${username}";
home.packages = with pkgs; [ home.packages = with pkgs; [
nixos-rebuild nixos-rebuild
testPushCmd (writeShellScriptBin "test-push" ''
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.my-neovim mkdir -p /var/tmp/nix-build
chmod 1777 /var/tmp/nix-build
nixos-rebuild switch \
--flake ${flakeDir}#john-pc-ubuntu \
--target-host root@${testTarget}
'')
]; ];
shell.program = "zsh"; # TODO: make this more restrictive, rather than allowing all unfree packages
nixpkgs.config.allowUnfree = true;
nixpkgs.config.permittedInsecurePackages = [ "openssl-1.1.1w" ];
homeManagerFlakeDir = flakeDir; homeManagerFlakeDir = flakeDir;
docker.enable = true; docker.enable = true;
@@ -62,9 +57,6 @@ in
}; };
ssh = { ssh = {
certificates.enable = true; certificates.enable = true;
knownHosts = [
"fded:fb16:653e:25da:be24:11ff:fea0:753f ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ9ZqiWPrCwHjxFCiu0lT4rlQs7KyMapxKJQQ5PJP1eh"
];
matchSets = { matchSets = {
certs = true; certs = true;
appdaemon = true; appdaemon = true;
+13 -22
View File
@@ -1,35 +1,26 @@
janus: janus:
admin_jwk: ENC[AES256_GCM,data:2XcN5X77wTQ+OUXa4C9xAErGvrwJKseHjCcgoj6jt+c=,iv:9x+M1wM0dYND1JYkJjM4N8pSOok2OF+P9vmm9NCumTI=,tag:dTCfh+KB1iRJBVoNsGqvuw==,type:str] admin_password: ENC[AES256_GCM,data:4pnSq0f1iTNFWn/Qcw+J7LWIXXd/j5v3WwFSzXfqgKA=,iv:/usSHYST8zv7AMvDNuW/fFLL+40IrderjL6bUWzBNd4=,tag:V/q1+SjIcYsZ0+PC/Q7c1A==,type:str]
sops: sops:
age: age:
- recipient: age1ykcs39e62pz3xu6cedg8ea685kv5d5qsrhgkndygzm8rx30xd5ys5t3qxt - recipient: age1ykcs39e62pz3xu6cedg8ea685kv5d5qsrhgkndygzm8rx30xd5ys5t3qxt
enc: | enc: |
-----BEGIN AGE ENCRYPTED FILE----- -----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA5QThHOFdVQ0F6ZDE3QXdL YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB0V1JsVDhnMHpaNHRQRCtw
QVF0WW5yRkNtNXIyRm1LeEhwY2dRRWo0WENZCmZoWmlXZDh4ZGlUR2JYOUxuaVAx V3JMQm1SREZSYUpaYmZNQ1FEVmN0VFZRSlQ0Ck9wQlpqZFBrRUJENWVBbTd5cVVo
WjhXVHBMNWdrdkgvTENJR2RpWldkNTAKLS0tIEF1bS9JSnFTbytBa1U5RjVzWkd3 ZlhYZnhGamk1ZlQ0N001ZWcrQ1Evb3cKLS0tIHpuTWhRTU1QeWFRUytiU21CMW94
S0pKVVI2RFN5a1BMYXBEY3VOUUM5QTAKNarYZm9DKRQhosSJBn9yryFxDkmFTV/o eFc0ankvcWhqK3Q4MjRCVC9nTlJteU0K1tJvYM2M1XmlsCTpadHyf6EGE2Lg+XBL
i8b/tZ1ZybjEXX+X1EsgylM5u8iKkbEyUzqKO0E0gpg4qXSsJaMMYQ== TGTjMPSWqClWYB9HFZ4nCurEK/JidBanmGkc0Y9eFz9XYKl7rtyXUw==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
- recipient: age1h0prahyukq4l564yqwgcpg3g6gdrjflk0suklussjjrjstxd9uesws8633 - recipient: age1h0prahyukq4l564yqwgcpg3g6gdrjflk0suklussjjrjstxd9uesws8633
enc: | enc: |
-----BEGIN AGE ENCRYPTED FILE----- -----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBhdEN2M1lkMFoyQzg3bCsz YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBNRzFlWTNxSGpaNU85QTFj
cVB0NUlkV1JPRjQ1TW5RSVFHUjdNMERoRXlzCk9tc25iMG00TkZjWjk2S2cyVE1J SnlRZkpZQTZQVjNqWFhLMHhKVm5ZVXB4Rms0CmZQclFzYkpWLzlqT2xNUTJMd2dJ
cUFITDh2SkZGN0lpeWJVcWM3V3JrTTQKLS0tIENOWVBzTFYrdHRsMERwV0RKS01j Wm5PQXNabjRwV1hVRXFGVmxteGk2emMKLS0tIG5kcm5KamxNZmpKVGt5bUo1dVg5
QVI5TVl4L0dwOWpoQ1I2THZ6cWovWGMKIo1x1ZbdTyr/dNlPhvuomfk2MoPLsHyU dFN2RGdqM29mM3hadXpBakY4QThxZnMKI9RbfXJHIHvYHy/2corfwDq+OHRPrmkA
N3CP3Scu3aZ7vqVua7uwtv4xQqyQI/yOnFjwxrVYPJ+N5Y/b4wsC6A== tWLH/KWqwGt0hvc5j8bUfRECgjdXmbC9kpAgDs8PhJF+X1ijVFrIYg==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
- recipient: age1gvplss0ddmyf6vpjy363wu3n057vhm0j6n7tc94cxd8kadapypws5mtaj0 lastmodified: "2026-03-23T22:27:45Z"
enc: | mac: ENC[AES256_GCM,data:tQ8EMXWqw7wd/QZqUPn/sAczk0G4jSUR96AF83cmJGYuoZkMkOzsMFt448IkWxNWOJHPmIc0vs+c3ngQxHyx6Uf9jVWzMkvfdzMYj82QuLsmXQ9e4/IAE9h+52uagbwgoOJwPCF+AQetSHez/jWPPIQPN5DLfz0edg4xYReX7DA=,iv:GsvotFkehIz5L4I9j0oQ89oM5XjZQAr6vrVd79tqFes=,tag:wLi4sXz8JqvaoUaYjEj/vA==,type:str]
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGSGQvL2ZYM2dtV1JWaDR1
RjJnN0YwWFM4d1IwTElqUnZQQkVDTmdydUJjCjdCUWxCVDNXUHVLd2ZHcDA5L0Mw
cEVxVE84L2xmQnRoYmsxVEdMSEZjdGcKLS0tIHViRVJyTWt4Q3JrMWtYaS9QdHlS
Yjd0MUcxcExvWVpCOUR3MkdZdGQyWUkKnru0Y2A98+0Mps7EtVK7ct3vPqIGveUt
E5fzpcKvdefzObrx7BPTwJ19t2fZg/dSi7HKwx3vmKZSzyQaqJOzsg==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2026-03-29T22:44:20Z"
mac: ENC[AES256_GCM,data:f2QVZsCNZJIxnsWsBXVyD6JFSmsMktZqCXQWAJcLfSaojEld9CMu1rJjDyCbG3GPJStrMS20WZbtQvx7H6gosnkxXL401L8SwIoy/gNNEIx0qVLUneoEsuvjSTIiiUG7B2Y9lBKQ/kO/iKrJMURSke0wWWC1Ng5mUePfZ94FVTg=,iv:xOFeak0pjBt4iTFr9vt4cuA9WzFD/ipVThgulNOp100=,tag:YPLXK4RmQLa+ADl6DohmBQ==,type:str]
unencrypted_suffix: _unencrypted unencrypted_suffix: _unencrypted
version: 3.12.1 version: 3.12.1
+41 -59
View File
@@ -1,4 +1,4 @@
{ self, inputs, lib, ... }: { inputs, ... }:
let let
username = "john"; username = "john";
hostname = "soteria"; hostname = "soteria";
@@ -7,18 +7,52 @@ in
flake.nixosConfigurations."${hostname}" = inputs.nixpkgs.lib.nixosSystem { flake.nixosConfigurations."${hostname}" = inputs.nixpkgs.lib.nixosSystem {
modules = with inputs.self.modules; [ modules = with inputs.self.modules; [
nixos.lxc nixos.lxc
nixos."${username}"
nixos.mysops nixos.mysops
nixos.step-ssh-host nixos.step-ssh-host
inputs.home-manager.nixosModules.home-manager
nixos."${username}"
nixos.zsh
nixos.login-text nixos.login-text
nixos.docker # nixos.mtls
nixos.mtls
nixos.janus-ca
nixos.forgejo
# nixos.restic-server # nixos.restic-server
# nixos.restic-envoy # nixos.restic-envoy
({ pkgs, ... }: { {
networking.hostName = hostname; networking.hostName = hostname;
nix.settings.build-dir = "/var/tmp/nix-build";
systemd.tmpfiles.rules = [
"d /var/tmp/nix-build 1777 root root -"
];
step-ssh-host = {
hostname = hostname;
};
home-manager.users."${username}" = {
imports = with inputs.self.modules; [
homeManager"${hostname}"
];
};
}
];
};
flake.modules.homeManager."${hostname}" = { config, lib, pkgs, ... }: {
imports = with inputs.self.modules; [
homeManager.rebuild
homeManager.mysops
homeManager.janus-ca
homeManager.mtls
homeManager.docker
];
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager";
home.username = "${username}";
home.homeDirectory = "/home/${username}";
shell.program = "zsh";
docker.enable = true;
# This will provide the edit-secrets script targeting this file
mysops.hostSecretFile = "${config.xdg.configHome}/home-manager/modules/hosts/soteria/secrets.yaml";
mtls = { mtls = {
enable = true; enable = true;
subject = hostname; subject = hostname;
@@ -32,58 +66,6 @@ in
"${lib.getExe pkgs.docker} restart envoy" "${lib.getExe pkgs.docker} restart envoy"
]; ];
}; };
# Removes password for sudo
security.sudo-rs.extraRules = lib.mkAfter [
{
users = [ username ];
commands = [
{
command = "ALL";
options = [ "NOPASSWD" ];
}
];
}
];
# nix.settings.build-dir = "/var/tmp/nix-build";
# systemd.tmpfiles.rules = [
# "d /var/tmp/nix-build 1777 root root -"
# ];
step-ssh-host = {
hostname = hostname;
};
# This provides the secrets at install time
sops.defaultSopsFile = ./secrets.yaml;
programs.zsh.enable = true;
home-manager.users."${username}" = {
imports = with inputs.self.modules; [
homeManager."${hostname}"
];
};
environment.systemPackages = [
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.janus-ca
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.my-neovim
];
forgejo.enable = true;
})
];
};
flake.modules.homeManager."${hostname}" = { config, pkgs, lib, ... }: {
imports = with inputs.self.modules; [
homeManager.rebuild
homeManager.mysops
];
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager";
shell.program = "zsh";
docker.enable = true;
# This will provide the edit-secrets script targeting this file
mysops.hostSecretFile = "${config.homeManagerFlakeDir}/modules/hosts/soteria/secrets.yaml";
}; };
flake.homeConfigurations."${hostname}" = inputs.home-manager.lib.homeManagerConfiguration { flake.homeConfigurations."${hostname}" = inputs.home-manager.lib.homeManagerConfiguration {
+2 -1
View File
@@ -11,11 +11,12 @@ in
nixos.step-ssh-host nixos.step-ssh-host
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
nixos."${username}" nixos."${username}"
nixos.zsh
nixos.docker nixos.docker
{ {
home-manager.users."${username}" = { home-manager.users."${username}" = {
imports = with inputs.self.modules.homeManager; [ imports = with inputs.self.modules.homeManager; [
mysops sops
]; ];
shell.program = "zsh"; shell.program = "zsh";
docker.enable = true; docker.enable = true;
+19 -80
View File
@@ -1,104 +1,43 @@
{ self, inputs, ... }: { inputs, ... }:
{ {
flake.modules.nixos.rebuild =
{ config, pkgs, lib, ... }:
let
flakeDir = config.rebuild.flakeDir;
echoCmd = lib.getExe' pkgs.coreutils "echo";
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
nfs = (pkgs.writeShellScriptBin "nfs" ''
HOSTNAME=${hostnameCmd}
${echoCmd} "Switching to the $HOSTNAME nixos profile"
sudo ${lib.getExe pkgs.nixos-rebuild} switch --impure --flake ${flakeDir}#$HOSTNAME
'');
in
{
options.rebuild = {
flakeDir = lib.mkOption {
description = "Path to the flake directory.";
type = lib.types.str;
default = "/etc/nixos";
};
};
config = {
environment.systemPackages = with pkgs; [
nfs
(writeShellScriptBin "nfsu" ''
${lib.getExe nix} flake update --impure --flake ${flakeDir}
${lib.getExe git} -C ${flakeDir} add ${flakeDir}/flake.lock > /dev/null 2>&1
${lib.getExe nfs}
'')
];
};
};
flake.modules.homeManager.rebuild = flake.modules.homeManager.rebuild =
{ config, pkgs, lib, ... }: { pkgs, lib, config, ... }:
let
nixBin = lib.getExe pkgs.nix;
flakeDir = config.homeManagerFlakeDir;
echoCmd = lib.getExe' pkgs.coreutils "echo";
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
nhms = (pkgs.writeShellScriptBin "nhms" ''
HOSTNAME=${hostnameCmd}
${echoCmd} "Switching to the $HOSTNAME home-manager profile"
${lib.getExe pkgs.home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
'');
in
{ {
options = { options = {
homeManagerFlakeDir = lib.mkOption { homeManagerFlakeDir = lib.mkOption {
description = "Path to the home-manager flake directory.";
type = lib.types.str; type = lib.types.str;
default = "${config.xdg.configHome}/home-manager"; default = "${config.xdg.configHome}/home-manager";
}; description = "Path to the home-manager flake directory.";
buildHostname = lib.mkOption {
description = "Hostname for the NixOS configuration to use.";
type = lib.types.str;
default = hostnameCmd;
}; };
}; };
config = { config = let
nixBin = lib.getExe pkgs.nix;
flakeDir = config.homeManagerFlakeDir;
in
{
home.activation.printFlakeDir = lib.hm.dag.entryAfter ["writeBoundary"] '' home.activation.printFlakeDir = lib.hm.dag.entryAfter ["writeBoundary"] ''
run ${echoCmd} "Home Manager flake directory: ${flakeDir}" run echo "Home Manager flake directory: ${flakeDir}"
''; '';
home.packages = with pkgs; [ home.packages = with pkgs; [
home-manager home-manager
(writeShellScriptBin "flake-parts-test" ''
echo "Test ${flakeDir}"
'')
(writeShellScriptBin "flake-parts-check" '' (writeShellScriptBin "flake-parts-check" ''
cd ${flakeDir} cd ${flakeDir}
${nixBin} run "${flakeDir}#write-flake" ${nixBin} run ".#write-flake"
${nixBin} flake check ${nixBin} flake check
'') '')
nhms (writeShellScriptBin "nhms" ''
HOSTNAME=$(hostname -s)
echo "Switching to the $HOSTNAME profile"
${lib.getExe home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
'')
(writeShellScriptBin "nhmu" '' (writeShellScriptBin "nhmu" ''
${nixBin} flake update --flake ${flakeDir} ${nixBin} flake update --flake ${flakeDir}
${lib.getExe nhms} nhms
'')
(writeShellScriptBin "test-build" ''
if [ -z "$1" ]; then
HOSTNAME=${hostnameCmd}
else
HOSTNAME="$1"
fi
${echoCmd} "Testing the evaulation of the nixos config for $HOSTNAME"
${lib.getExe nix} eval ${flakeDir}#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath
'')
(writeShellScriptBin "cleanup" ''
set -e
DAYS=$1
if [ -z "$DAYS" ]; then
${echoCmd} "usage: cleanup <days>"
exit 1
fi
${lib.getExe home-manager} expire-generations "-$DAYS days"
${lib.getExe nix} profile wipe-history --older-than "''${DAYS}d"
${lib.getExe nix} store gc
${lib.getExe nix} store optimise
'') '')
]; ];
}; };
+24 -23
View File
@@ -1,39 +1,40 @@
# Lifted from: # Lifted from:
# https://github.com/Doc-Steve/dendritic-design-with-flake-parts/blob/69edacdb5a4a6ca71d649bb8eb62cf8c630c8627/modules/users/bob%20%5BNDn%5D/bob.nix#L8 # https://github.com/Doc-Steve/dendritic-design-with-flake-parts/blob/69edacdb5a4a6ca71d649bb8eb62cf8c630c8627/modules/users/bob%20%5BNDn%5D/bob.nix#L8
{ self, inputs, ... }: { self, ... }:
{ {
config.flake.factory.user = { config.flake.factory.user = username: isAdmin: {
username, nixos."${username}" = { lib, pkgs, ... }: {
isAdmin ? false,
noPassword ? false,
# homeImports ? [ ],
# homePackages ? [ ],
}: {
nixos."${username}" = { config, lib, pkgs, ... }: {
imports = [
inputs.home-manager.nixosModules.home-manager
];
users.users."${username}" = { users.users."${username}" = {
isNormalUser = true; isNormalUser = true;
home = "/home/${username}"; home = "/home/${username}";
shell = lib.mkIf config.programs.zsh.enable pkgs.zsh; extraGroups = [
extraGroups = [ "input" "networkmanager" ] "input"
++ lib.optional isAdmin "wheel" "networkmanager"
++ lib.optional config.virtualisation.docker.enable "docker" ] ++ lib.optionals isAdmin [
++ lib.optional (isAdmin && config.services.forgejo.enable) config.services.forgejo.group "docker"
++ lib.optional (isAdmin && config.services.postgresql.enable) "postgres"; "wheel"
];
}; };
security.sudo-rs.enable = lib.mkIf isAdmin true; # Removes password for sudo
security.sudo-rs = lib.mkIf isAdmin {
enable = true;
extraRules = [{
users = [ "${username}" ];
commands = [{
command = "ALL";
options = [ "NOPASSWD" ];
}];
}];
};
home-manager.useGlobalPkgs = true;
# https://github.com/Doc-Steve/dendritic-design-with-flake-parts/wiki/Dendritic_Aspects#multi-context-aspect # https://github.com/Doc-Steve/dendritic-design-with-flake-parts/wiki/Dendritic_Aspects#multi-context-aspect
home-manager.users."${username}" = { home-manager.users."${username}" = {
imports = [ self.modules.homeManager."${username}" ];
home.username = "${username}"; home.username = "${username}";
home.homeDirectory = "/home/${username}"; home.homeDirectory = "/home/${username}";
# home.packages = homePackages; imports = [
self.modules.homeManager."${username}"
];
}; };
}; };
}; };
-11
View File
@@ -1,11 +0,0 @@
{ self, inputs, ... }: {
flake.modules.homeManager.brave = {
programs.brave = {
enable = true;
extensions = [
# https://chromewebstore.google.com/detail/1password-%E2%80%93-password-mana/aeblfdkhhhdcdjpifhhbdiojplfjncoa
"aeblfdkhhhdcdjpifhhbdiojplfjncoa"
];
};
};
}
+12
View File
@@ -0,0 +1,12 @@
# This module is for programs with GUIs that run in a desktop environment
{ inputs, ... }:
{
flake.modules.homeManager.desktop =
{
imports = with inputs.self.modules.homeManager; [
onepassword
ghostty
sublime
];
};
}
+4 -20
View File
@@ -8,17 +8,6 @@
}; };
flake.modules.homeManager.ghostty = { config, pkgs, lib, ... }: flake.modules.homeManager.ghostty = { config, pkgs, lib, ... }:
let
ghosttyPackage = pkgs.symlinkJoin {
name = "ghostty-x11";
paths = [ (config.lib.nixGL.wrap pkgs.ghostty) ];
nativeBuildInputs = [ pkgs.makeWrapper ];
meta.mainProgram = "ghostty";
postBuild = ''
wrapProgram $out/bin/ghostty --set GDK_BACKEND x11
'';
};
in
{ {
home.sessionVariables = { home.sessionVariables = {
TERMINAL = "ghostty"; TERMINAL = "ghostty";
@@ -33,7 +22,7 @@
programs.ghostty = { programs.ghostty = {
enable = true; enable = true;
enableZshIntegration = true; enableZshIntegration = true;
package = ghosttyPackage; package = config.lib.nixGL.wrap pkgs.ghostty;
settings = { settings = {
command = "TERM=xterm-256color ${lib.getExe pkgs.zsh}"; command = "TERM=xterm-256color ${lib.getExe pkgs.zsh}";
font-size = 12; font-size = 12;
@@ -43,7 +32,6 @@
shell-integration = "zsh"; shell-integration = "zsh";
shell-integration-features = [ "no-title" "sudo" ]; shell-integration-features = [ "no-title" "sudo" ];
gtk-single-instance = true; gtk-single-instance = true;
mouse-scroll-multiplier = 0.375;
window-position-x = 25; window-position-x = 25;
window-position-y = 25; window-position-y = 25;
@@ -70,15 +58,11 @@
}; };
# https://github.com/ghostty-org/ghostty/discussions/3763#discussioncomment-11699970 # https://github.com/ghostty-org/ghostty/discussions/3763#discussioncomment-11699970
xdg.desktopEntries."com.mitchellh.ghostty" = xdg.desktopEntries."com.mitchellh.ghostty" = {
let
ghosttyCmd = lib.getExe ghosttyPackage;
in
{
name = "Ghostty"; name = "Ghostty";
type = "Application"; type = "Application";
comment = "A terminal emulator"; comment = "A terminal emulator";
exec = ghosttyCmd; exec = "nixGLMesa ghostty";
icon = "com.mitchellh.ghostty"; icon = "com.mitchellh.ghostty";
terminal = false; terminal = false;
startupNotify = true; startupNotify = true;
@@ -95,7 +79,7 @@
actions = { actions = {
new-window = { new-window = {
name = "New Window"; name = "New Window";
exec = ghosttyCmd; exec = "nixGLMesa ghostty";
}; };
}; };
}; };
+3 -8
View File
@@ -1,8 +1,6 @@
{ self, inputs, ... }: { {
flake.modules.homeManager.git = { config, pkgs, lib, ... }: { flake.modules.homeManager.git = { config, lib, ... }:
home.packages = with pkgs; [ {
git-credential-oauth
];
programs.git = { programs.git = {
enable = true; enable = true;
settings = { settings = {
@@ -16,8 +14,5 @@
enableBashIntegration = true; enableBashIntegration = true;
enableZshIntegration = true; enableZshIntegration = true;
}; };
home.shellAliases = {
"lzg" = "lazygit";
};
}; };
} }
-158
View File
@@ -1,158 +0,0 @@
{ self, inputs, ... }: {
flake-file.inputs = {
nvf = {
url = "github:notashelf/nvf";
inputs.nixpkgs.follows = "nixpkgs";
};
};
perSystem = { system, pkgs, config, ... }: {
packages.my-neovim = ((inputs.nvf.lib.neovimConfiguration {
inherit pkgs;
modules = [
{
# https://nvf.notashelf.dev/search.html
config.vim = {
options = {
number = true;
relativenumber = true;
expandtab = true;
shiftwidth = 4;
tabstop = 4;
softtabstop = 4;
wrap = true;
linebreak = true;
};
syntaxHighlighting = true;
# Enable custom theming options
theme.enable = true;
theme.name = "catppuccin";
theme.style = "mocha";
git.enable = true;
# git.neogit.enable = true;
# https://github.com/akinsho/toggleterm.nvim
terminal.toggleterm.enable = true;
terminal.toggleterm.lazygit.enable = true;
terminal.toggleterm.lazygit.direction = "float";
terminal.toggleterm.lazygit.mappings.open = "<C-g>";
utility.nix-develop.enable = true;
utility.oil-nvim.enable = true;
utility.oil-nvim.gitStatus.enable = true;
filetree.neo-tree = {
enable = true;
};
# lazy = {
# enable = true;
# };
# globals = {
# SimpylFold_docstring_preview = 1;
# SimpylFold_fold_blank = 0;
# };
# extraPlugins = with pkgs.vimPlugins; {
# SimpylFold.package = SimpylFold;
# };
telescope = {
enable = true;
extensions = [
{
name = "fzf";
packages = [pkgs.vimPlugins.telescope-fzf-native-nvim];
setup = {fzf = {fuzzy = true;};};
}
];
};
# Enable Treesitter
treesitter = {
enable = true;
grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [ python ];
};
lsp.enable = true;
languages = {
enableTreesitter = true;
enableFormat = true;
markdown = {
enable = true;
extensions = {
# render-markdown-nvim.enable = true;
markview-nvim.enable = true;
};
};
bash.enable = true;
css.enable = true;
yaml.enable = true;
toml.enable = true;
nix = {
enable = true;
};
python = {
enable = true;
dap.enable = true;
format.type = [ "ruff" ];
};
};
keymaps = [
{
desc = "Edit key mappings";
key = "<leader>ekm";
mode = [ "n" ];
silent = false;
action = "<cmd>:edit +/keymaps /home/john/.config/home-manager/jsl-dendritic/modules/programs/neovim.nix<CR>";
}
{
desc = "Home Manager Switch";
key = "<leader>nhms";
mode = [ "n" ];
silent = false;
action = "<cmd>:TermExec cmd='clear && nhms && exit' name='Nix Home Manager Switch' direction=float<CR>";
}
{
desc = "Key Maps [Telescope]";
key = "<leader>fkm";
mode = "n";
silent = false;
action = "<cmd>:Telescope keymaps<CR>";
}
{
desc = "Toggle Filesystem Tree [NeoTree]";
key = "<C-b>";
mode = [ "n" "v" "t" ];
silent = false;
action = "<cmd>:Neotree toggle filesystem left action=show<CR>";
}
{
key = "<C-`>";
mode = ["n" "v" "t"];
silent = false;
action = "<cmd>:ToggleTerm<CR>";
}
];
};
}
];
}).neovim).overrideAttrs (old: {
pname = "my-neovim";
version = "custom";
});
};
}
-33
View File
@@ -1,33 +0,0 @@
{ self, inputs, ... }: {
flake-file.inputs = {
wrapper-modules.url = "github:BirdeeHub/nix-wrapper-modules";
# wrapper-modules.inputs.nixpkgs.follows = "nixpkgs";
};
flake.modules.nixos.niri = { pkgs, lib, ... }: {
programs.niri = {
enable = true;
package = self.packages.${pkgs.stdenv.hostPlatform.system}.myNiri;
};
};
perSystem = { pkgs, lib, self', ... }: {
packages.myNiri = inputs.wrapper-modules.wrappers.niri.wrap {
inherit pkgs;
env.RUST_BACKTRACE = "full";
settings = {
spawn-at-startup = [
"${lib.getExe self'.packages.myNoctalia}"
];
xwayland-satellite.path = lib.getExe pkgs.xwayland-satellite;
input.keyboard.xkb.layout = "us,ua";
layout.gaps = 5;
binds = {
"Mod+Return".spawn-sh = lib.getExe pkgs.ghostty;
"Mod+Q".close-window = null;
"Mod+S".spawn-sh = "${lib.getExe self'.packages.myNoctalia} ipc call launcher toggle";
};
};
};
};
}
-8
View File
@@ -1,8 +0,0 @@
{ self, inputs, ... }: {
perSystem = { pkgs, ... }: {
packages.myNoctalia = inputs.wrapper-modules.wrappers.noctalia-shell.wrap {
inherit pkgs;
# settings = (builtins.fromJSON (builtins.readFile ./noctalia.json)).settings;
};
};
}
+3 -8
View File
@@ -1,10 +1,5 @@
{ self, inputs, ... }: { {
flake.modules.homeManager.onepassword = { config, ... }: { flake.modules.homeManager.onepassword = {
home.file.".config/1Password/ssh/agent.toml".text = '' # TODO: Port `_1password = true` behavior into an explicit Home Manager module.
# https://developer.1password.com/docs/ssh/agent/config
[[ssh-keys]]
vault = "Private"
'';
programs.ssh.matchBlocks."*".identityAgent = "${config.home.homeDirectory}/.1password/agent.sock";
}; };
} }
@@ -23,6 +23,7 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
wget wget
curl curl
cacert
busybox busybox
gnugrep gnugrep
dig dig
@@ -30,10 +31,6 @@
uv uv
xclip xclip
jq jq
ripgrep
(writeShellScriptBin "ds" ''
${lib.getExe pkgs.gdu} -x -I /snap /
'')
]; ];
}; };
}; };
+11 -20
View File
@@ -40,22 +40,13 @@ in
default = "${config.xdg.configHome}/sops/age/keys.txt"; default = "${config.xdg.configHome}/sops/age/keys.txt";
}; };
hostSecretFile = lib.mkOption { hostSecretFile = lib.mkOption {
description = "Path to the secrets file for this host. Used to create the edit-secrets script"; description = "Path to the secrets file for this host";
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
}; };
}; };
config = config = {
let
echo = lib.getExe' pkgs.coreutils "echo";
dirname = lib.getExe' pkgs.coreutils "dirname";
mkdir = lib.getExe' pkgs.coreutils "mkdir";
show-age-key = (pkgs.writeShellScriptBin "show-age-key" ''
${lib.getExe' pkgs.age "age-keygen"} -y ${cfg.ageKeyFile}
'');
in
{
home.packages = with pkgs; [ home.packages = with pkgs; [
eza eza
age age
@@ -64,22 +55,22 @@ in
(writeShellScriptBin "gen-age-key" '' (writeShellScriptBin "gen-age-key" ''
set -eu set -eu
if [ ! -f "${config.ssh.identityFile}" ]; then if [ ! -f "${config.ssh.IdentityFile}" ]; then
${echo} "SSH identity file not found: ${config.ssh.identityFile}" >&2 echo "SSH identity file not found: ${config.ssh.IdentityFile}" >&2
exit 1 exit 1
fi fi
if [ -e "${cfg.ageKeyFile}" ]; then if [ -e "${cfg.ageKeyFile}" ]; then
${echo} "Refusing to overwrite existing age key file: ${cfg.ageKeyFile}" >&2 echo "Refusing to overwrite existing age key file: ${cfg.ageKeyFile}" >&2
exit 1 exit 1
fi fi
${mkdir} -p "$(${dirname} "${cfg.ageKeyFile}")" mkdir -p "$(dirname "${cfg.ageKeyFile}")"
${lib.getExe pkgs.ssh-to-age} -i ${config.ssh.identityFile} -private-key > ${cfg.ageKeyFile} ${lib.getExe pkgs.ssh-to-age} -i ${config.ssh.IdentityFile} -private-key > ${cfg.ageKeyFile}
${echo} -n "Created ${cfg.ageKeyFile}: " echo -n "Created ${cfg.ageKeyFile}: "
${echo} $(${lib.getExe show-age-key}) echo $(show-age-key)
'') '')
show-age-key (writeShellScriptBin "show-age-key" "${lib.getExe' pkgs.age "age-keygen"} -y ${cfg.ageKeyFile}")
(writeShellScriptBin "ls-secrets" "${lib.getExe pkgs.eza} -alT --follow-symlinks ~/.config/sops-nix/secrets") (writeShellScriptBin "ls-secrets" "${lib.getExe pkgs.eza} -alT --follow-symlinks ~/.config/sops-nix/secrets")
] ++ editScript; ] ++ editScript;
@@ -90,7 +81,7 @@ in
sops = { sops = {
defaultSopsFile = sopsSecretsPath; defaultSopsFile = sopsSecretsPath;
defaultSopsFormat = "yaml"; defaultSopsFormat = "yaml";
age.sshKeyPaths = [ "${config.ssh.identityFile}" ]; age.sshKeyPaths = [ "${config.ssh.IdentityFile}" ];
}; };
}; };
}; };
-14
View File
@@ -1,14 +0,0 @@
{ self, inputs, ... }: {
flake.modules.nixos.steam = {
programs.steam = {
enable = true;
gamescopeSession.enable = true;
# Open ports in the firewall for Steam Remote Play
remotePlay.openFirewall = true;
# Open ports in the firewall for Source Dedicated Server
dedicatedServer.openFirewall = true;
# Open ports in the firewall for Steam Local Network Game Transfers
localNetworkGameTransfers.openFirewall = true;
};
};
}
+1 -1
View File
@@ -29,7 +29,7 @@
${principalArgs} \ ${principalArgs} \
--provisioner "${cfg.provisioner}" \ --provisioner "${cfg.provisioner}" \
--provisioner-password-file "${config.sops.secrets."janus/admin_jwk".path}" \ --provisioner-password-file "${config.sops.secrets."janus/admin_jwk".path}" \
"${firstPrincipal}" "${config.ssh.identityFile}.pub" "${firstPrincipal}" "${config.ssh.IdentityFile}.pub"
'') '')
]; ];
}; };
+8
View File
@@ -0,0 +1,8 @@
{ inputs, pkgs, ... }:
{
flake.modules.homeManager.sublime = { pkgs, lib, ... }: {
home.packages = with pkgs; [
sublime4
];
};
}
-10
View File
@@ -1,10 +0,0 @@
{ self, inputs, ... }: {
flake.modules.nixos.sudo = {
security.sudo-rs = {
enable = true;
execWheelOnly = false;
wheelNeedsPassword = false;
extraConfig = "Defaults timestamp_timeout=1440";
};
};
}
+3 -8
View File
@@ -1,10 +1,6 @@
{ self, inputs, ... }: { {
flake.modules.homeManager.vscode = { config, pkgs, lib, ... }: { flake.modules.homeManager.vscode = { pkgs, ... }:
options.my-vscode = { {
enable = lib.mkEnableOption "Enable nix-managed VSCode";
};
config = lib.mkIf config.my-vscode.enable {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.vscode; package = pkgs.vscode;
@@ -22,5 +18,4 @@
]; ];
}; };
}; };
};
} }
-59
View File
@@ -1,59 +0,0 @@
{ self, inputs, ... }: {
flake.modules.nixos.wireguard = { config, pkgs, lib, ... }:
let
wgInterface = "platform";
systemctl = lib.getExe' pkgs.systemd "systemctl";
journalctl = lib.getExe' pkgs.systemd "journalctl";
mkConnect = interface:
let
serviceName = "wg-quick-${interface}";
service = "${serviceName}.service";
in
pkgs.writeShellScriptBin "wg-connect-${interface}" ''
${systemctl} start ${service}
start_time=$(${systemctl} show -p ActiveEnterTimestamp ${serviceName} | cut -d= -f2)
${journalctl} -u ${service} --since "$start_time" --no-pager
'';
mkDisconnect = interface:
let
serviceName = "wg-quick-${interface}";
service = "${serviceName}.service";
in
pkgs.writeShellScriptBin "wg-disconnect-${interface}" ''
STOPTIME=$(${lib.getExe' pkgs.coreutils "date"} '+%Y-%m-%d %H:%M:%S')
${systemctl} stop ${service}
start_time=$(${systemctl} show -p ActiveEnterTimestamp ${serviceName} | cut -d= -f2)
${journalctl} -u ${service} --since "$STOPTIME" --no-pager
'';
in
{
imports = [ inputs.sops-nix.nixosModules.sops ];
environment.systemPackages = with pkgs; [
wireguard-tools
wg-netmanager
(mkConnect "platform")
(mkDisconnect "platform")
];
sops.secrets.wireguard_private_key = { };
networking.wg-quick.interfaces = {
${wgInterface} = {
autostart = false; # Managed by dispatcher
postUp = "echo 'Post up command'";
address = [ "192.168.3.5/32" ];
dns = [ "192.168.1.150" ];
privateKeyFile = config.sops.secrets.wireguard_private_key.path;
peers = [
{
publicKey = "BD1/q18OfpoMCDusNZk9cqB1vvR8bgodZ1L7198jVic=";
allowedIPs = [ "192.168.0.0/16" ];
endpoint = "wg.john-stream.com:51830";
persistentKeepalive = 25;
}
];
};
};
};
}
+11 -4
View File
@@ -1,13 +1,20 @@
{ self, inputs, ... }: { inputs, ... }:
{ {
flake.modules.nixos.docker = { flake.modules.nixos.docker = {
virtualisation.docker.enable = true; virtualisation.docker = {
home-manager.sharedModules = [ inputs.self.modules.homeManager.docker ]; enable = true;
};
home-manager.sharedModules = with inputs.self.modules.homeManager; [
docker
];
}; };
flake.modules.homeManager.docker = { config, lib, pkgs, ... }: flake.modules.homeManager.docker = { config, lib, pkgs, ... }:
{ {
options.docker.enable = lib.mkEnableOption "Docker tools and utilities"; options.docker = {
enable = lib.mkEnableOption "Docker tools and utilities";
};
config = lib.mkIf config.docker.enable { config = lib.mkIf config.docker.enable {
programs.lazydocker.enable = true; programs.lazydocker.enable = true;
programs.docker-cli.enable = true; programs.docker-cli.enable = true;
@@ -1,4 +1,4 @@
{ self, inputs, ... }: { { inputs, ... }: {
flake.modules.nixos.restic-server = { config, pkgs, lib, ... }: { flake.modules.nixos.restic-server = { config, pkgs, lib, ... }: {
services.restic.server = { services.restic.server = {
enable = true; enable = true;
@@ -19,11 +19,6 @@
type = lib.types.str; type = lib.types.str;
default = "john-ubuntu"; default = "john-ubuntu";
}; };
repoUrl = lib.mkOption {
description = "URL to the REST endpoint";
type = lib.types.str;
default = "rest:https://soteria.john-stream.com/${cfg.repoName}";
};
passwordFile = lib.mkOption { passwordFile = lib.mkOption {
description = "String path to the restic password file"; description = "String path to the restic password file";
type = lib.types.str; type = lib.types.str;
@@ -49,24 +44,29 @@
}; };
}; };
config = { config = let
resticRepository = "rest:https://soteria.john-stream.com/${cfg.repoName}";
caCert = "${config.mtls.certDir}/root_ca.crt";
mtlsClientCert = "${config.mtls.certDir}/${config.mtls.bundleFilename}";
in
{
home.sessionVariables = { home.sessionVariables = {
RESTIC_REPOSITORY = cfg.repoUrl; RESTIC_REPOSITORY = resticRepository;
RESTIC_PASSWORD_FILE = cfg.passwordFile; RESTIC_PASSWORD_FILE = cfg.passwordFile;
RESTIC_CACERT = config.mtls.caFile; RESTIC_CACERT = caCert;
RESTIC_TLS_CLIENT_CERT = config.mtls.bundleFile; RESTIC_TLS_CLIENT_CERT = mtlsClientCert;
}; };
# This is necessary because the restic service in home manager doesn't otherwise expose these options. # This is necessary because the restic service in home manager doesn't otherwise expose these options.
systemd.user.services."restic-backups-${cfg.repoName}".Service.Environment = [ systemd.user.services."restic-backups-${cfg.repoName}".Service.Environment = [
"RESTIC_CACERT=${config.mtls.caFile}" "RESTIC_CACERT=${caCert}"
"RESTIC_TLS_CLIENT_CERT=${config.mtls.bundleFile}" "RESTIC_TLS_CLIENT_CERT=${mtlsClientCert}"
]; ];
services.restic = { services.restic = {
enable = true; enable = true;
backups.${cfg.repoName} = { backups.${cfg.repoName} = {
repository = cfg.repoUrl; repository = resticRepository;
passwordFile = cfg.passwordFile; passwordFile = cfg.passwordFile;
paths = cfg.paths; paths = cfg.paths;
timerConfig = { timerConfig = {
@@ -103,6 +103,7 @@
]; ];
}; };
}; };
}; };
}; };
} }
+38 -57
View File
@@ -1,32 +1,22 @@
{ inputs, ... }: {inputs, ... }:
let let
userName = "john"; userName = "john";
sshHostCAPubKey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNug18oLH0vZxnibXJzMJvTWFPZTnSlhCDDVi+rHhgnIum6ZXQ4SF+VHOOAM5BbzZmMKitNJ5lcrGP15Eur7DzQ="; sshHostCAPubKey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNug18oLH0vZxnibXJzMJvTWFPZTnSlhCDDVi+rHhgnIum6ZXQ4SF+VHOOAM5BbzZmMKitNJ5lcrGP15Eur7DzQ=";
in in
{ {
flake.modules.nixos.ssh = { config, pkgs, lib, ... }: flake.modules.nixos.ssh = { pkgs, config, lib, ... }:
let let
cfg = config.ssh; cfg = config.ssh;
configDir = "/etc/ssh"; userCAPath = "ssh/ssh_user_ca.pub";
hostKeyFile = "ssh/ssh_host_ed25519_key";
in in
{ {
options.ssh = { options.ssh = {
hostKey = lib.mkOption {
description = "String path to the host private key file";
type = lib.types.str;
default = "ssh_host_ed25519_key";
};
certificates = { certificates = {
enable = lib.mkEnableOption "Enable SSH host certificates"; enable = lib.mkEnableOption "Enable SSH host certificates";
userCA = lib.mkOption { userCA = lib.mkOption {
description = "Content for the SSH user CA file (public key)";
type = lib.types.path; type = lib.types.path;
default = ../hosts/janus/ssh_user_ca.pub; default = ../../keys/ssh_user_ca.pub;
};
userCAFile = lib.mkOption {
description = "String path to the SSh user CA";
type = lib.types.str;
default = "ssh_user_ca.pub";
}; };
}; };
}; };
@@ -39,16 +29,16 @@ in
{ {
PasswordAuthentication = false; PasswordAuthentication = false;
KbdInteractiveAuthentication = false; KbdInteractiveAuthentication = false;
HostKey = "${configDir}/${cfg.hostKey}"; HostKey = "/etc/${hostKeyFile}";
} }
(lib.mkIf cfg.certificates.enable { (lib.mkIf cfg.certificates.enable {
TrustedUserCAKeys = "${configDir}/${cfg.certificates.userCAFile}"; TrustedUserCAKeys = "/etc/${userCAPath}";
HostCertificate = "${configDir}/${cfg.hostKey}-cert.pub"; HostCertificate = "/etc/${hostKeyFile}-cert.pub";
}) })
]; ];
}; };
environment.etc."ssh/${cfg.certificates.userCAFile}" = lib.mkIf cfg.certificates.enable { environment.etc."${userCAPath}" = lib.mkIf cfg.certificates.enable {
source = cfg.certificates.userCA; source = cfg.certificates.userCA;
}; };
@@ -65,56 +55,52 @@ in
}; };
}; };
flake.modules.homeManager.ssh = { config, pkgs, lib, ... }: flake.modules.homeManager.ssh = { pkgs, config, lib, ... }:
let
cfg = config.ssh;
configDir = "${config.home.homeDirectory}/.ssh";
identityFile = cfg.identityFile;
publicKeyFile = "${identityFile}.pub";
certificateFile = "${identityFile}-cert.pub";
in
{ {
options.ssh = with lib; { options.ssh = {
identityFile = mkOption { IdentityFile = lib.mkOption {
# Intentionally not using a path type here because that will end up with the private key getting copied into the store # Intentionally not using a path type here because that will end up with the private key getting copied into the store
type = types.str; type = lib.types.str;
default = "${config.home.homeDirectory}/.ssh/id_ed25519"; default = "${config.home.homeDirectory}/.ssh/id_ed25519";
description = "Path to the SSH identity file."; description = "Path to the SSH identity file.";
}; };
certificates = { certificates = {
enable = mkEnableOption "Enable SSH client certificates"; enable = lib.mkEnableOption "Enable SSH user certificates";
# sshCertProvisioner = lib.mkOption {
# type = lib.types.str;
# default = "admin";
# };
}; };
knownHostsFile = mkOption { knownHostsFile = lib.mkOption {
type = types.str; type = lib.types.str;
default = "${configDir}/known_hosts"; default = "${config.home.homeDirectory}/.ssh/known_hosts";
};
knownHosts = mkOption {
description = "";
type = types.listOf types.str;
default = [ ];
}; };
matchSets = { matchSets = {
appdaemon = mkEnableOption "Enable AppDaemon SSH targets"; appdaemon = lib.mkEnableOption "Enable AppDaemon SSH targets";
certs = mkEnableOption "Enable Janus and Soteria SSH targets"; certs = lib.mkEnableOption "Enable Janus and Soteria SSH targets";
homelab = mkEnableOption "Enable various Homelab targets"; homelab = lib.mkEnableOption "Enable various Homelab targets";
dev = mkEnableOption "Enable development targets"; dev = lib.mkEnableOption "Enable development targets";
}; };
}; };
# All this stuff has to be wrapped in a config attribute because of the presence of the options here? # All this stuff has to be wrapped in a config attribute because of the presence of the options here?
config = let config = let
cfg = config.ssh;
identityFile = cfg.IdentityFile;
publicKeyFile = "${identityFile}.pub";
certificateFile = "${identityFile}-cert.pub";
provisionerPasswordPath = config.sops.secrets."janus/admin_jwk".path; provisionerPasswordPath = config.sops.secrets."janus/admin_jwk".path;
in { in {
home.file.".ssh/known_hosts" = { home.file.".ssh/known_hosts" = {
text = lib.concatStringsSep "\n" ( text = lib.concatStringsSep "\n" (
cfg.knownHosts ++ lib.optionals cfg.certificates.enable [ [
"@cert-authority 192.168.1.* ${sshHostCAPubKey}" "fded:fb16:653e:25da:be24:11ff:fea0:753f ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ9ZqiWPrCwHjxFCiu0lT4rlQs7KyMapxKJQQ5PJP1eh"
"@cert-authority *.john-stream.com ${sshHostCAPubKey}"
] ]
++ (lib.optional cfg.certificates.enable "@cert-authority 192.168.1.* ${sshHostCAPubKey}")
++ (lib.optional cfg.certificates.enable "@cert-authority *.john-stream.com ${sshHostCAPubKey}")
); );
}; };
@@ -123,16 +109,12 @@ in
enableDefaultConfig = false; enableDefaultConfig = false;
extraConfig = '' extraConfig = ''
SetEnv TERM="xterm-256color" SetEnv TERM="xterm-256color"
IdentityAgent ~/.1password/agent.sock
''; '';
matchBlocks = lib.mkMerge [ matchBlocks = lib.mkMerge [
{ {
"john-pc-ubuntu" = { "*" = {
hostname = "192.168.1.85";
};
"*" = lib.mkMerge [
{
user = "john"; user = "john";
compression = false; compression = false;
@@ -140,16 +122,14 @@ in
serverAliveCountMax = 3; serverAliveCountMax = 3;
identitiesOnly = true; identitiesOnly = true;
inherit identityFile; inherit identityFile certificateFile;
hashKnownHosts = false; hashKnownHosts = false;
userKnownHostsFile = cfg.knownHostsFile; userKnownHostsFile = cfg.knownHostsFile;
addKeysToAgent = "yes"; addKeysToAgent = "yes";
forwardAgent = false; forwardAgent = false;
} };
(lib.mkIf cfg.certificates.enable { inherit certificateFile; })
];
} }
(lib.mkIf cfg.matchSets.appdaemon { (lib.mkIf cfg.matchSets.appdaemon {
"appdaemon" = { "appdaemon" = {
@@ -193,6 +173,7 @@ in
"test-nix" = { "test-nix" = {
hostname = "fded:fb16:653e:25da:be24:11ff:fea0:753f"; hostname = "fded:fb16:653e:25da:be24:11ff:fea0:753f";
user = "john"; user = "john";
identityFile = identityFile;
}; };
}) })
]; ];
@@ -1,35 +1,26 @@
{ self, inputs, lib, ... }: { inputs, lib, ... }:
let let
# Options that will be in common between the nixos module and the home-manager module. # Options that will be in common between
mkOpts = config: let cfg = config.mtls; in { opts = {
enable = lib.mkEnableOption "Enable mTLS"; enable = lib.mkEnableOption "Enable mTLS";
subject = lib.mkOption { subject = lib.mkOption {
description = "The Common Name, DNS Name, or IP address that will be set as the Subject Common Name for the certificate. If no Subject Alternative Names (SANs) are configured (via the --san flag) then the subject will be set as the only SAN."; description = "The Common Name, DNS Name, or IP address that will be set as the Subject Common Name for the certificate. If no Subject Alternative Names (SANs) are configured (via the --san flag) then the subject will be set as the only SAN.";
type = lib.types.str; type = lib.types.str;
}; };
certDir = lib.mkOption { keyFilename = lib.mkOption {
description = "String path to the directory where the certs will be stored"; description = "String filename for the private key";
type = lib.types.str; type = lib.types.str;
default = "key.pem";
}; };
caFile = lib.mkOption { certFilename = lib.mkOption {
description = "String path for the root CA file"; description = "String filename for the public certificate";
type = lib.types.str; type = lib.types.str;
default = "${cfg.certDir}/root_ca.crt"; default = "cert.pem";
}; };
keyFile = lib.mkOption { bundleFilename = lib.mkOption {
description = "String path for the private key"; description = "String filename for the mTLS key bundle";
type = lib.types.str; type = lib.types.str;
default = "${cfg.certDir}/key.pem"; default = "mtls.pem";
};
certFile = lib.mkOption {
description = "String path for the public cert";
type = lib.types.str;
default = "${cfg.certDir}/cert.pem";
};
bundleFile = lib.mkOption {
description = "String path for the mTLS key bundle";
type = lib.types.str;
default = "${cfg.certDir}/mtls.pem";
}; };
san = lib.mkOption { san = lib.mkOption {
description = "List of SAN to give the mTLS cert"; description = "List of SAN to give the mTLS cert";
@@ -42,7 +33,7 @@ let
}; };
lifetime = lib.mkOption { lifetime = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "24h"; default = "6h";
}; };
renew = { renew = {
enable = lib.mkOption { enable = lib.mkOption {
@@ -83,49 +74,16 @@ let
}; };
}; };
mkMtlsGenerateScript = {
pkgs,
subject,
provisioner,
san,
certFile,
keyFile,
bundleFile,
lifetime,
}:
let
stepCmd = lib.getExe pkgs.step-cli;
sanArgs = lib.concatMapStringsSep " " (s: "--san \"${s}\"") san;
in
pkgs.writeShellScriptBin "mtls-generate" ''
set -euo pipefail
${stepCmd} ca certificate \
${subject} ${certFile} ${keyFile} \
--not-before=-5m --not-after=${lifetime} \
--provisioner ${provisioner} \
${sanArgs} \
"$@"
cat ${certFile} ${keyFile} > ${bundleFile}
'';
mkMtlsCheckScript = { pkgs, bundleFile }: pkgs.writeShellScriptBin "mtls-check" ''
${lib.getExe pkgs.openssl} x509 \
-noout -subject -issuer \
-ext subjectAltName,extendedKeyUsage \
-enddate -in ${bundleFile}
'';
mkMtlsRenewScript = { mkMtlsRenewScript = {
pkgs, pkgs,
certFile, tlsCert,
keyFile, tlsKey,
bundleFile, mtlsBundle,
reloadUnits ? [ ], reloadUnits ? [ ],
postCommands ? [ ], postCommands ? [ ],
systemctlArgs ? [ ], systemctlArgs ? [ ],
}: }:
let let
echoCmd = lib.getExe' pkgs.coreutils "echo";
systemctl = lib.getExe' pkgs.systemd "systemctl"; systemctl = lib.getExe' pkgs.systemd "systemctl";
escapedArgs = lib.escapeShellArgs systemctlArgs; escapedArgs = lib.escapeShellArgs systemctlArgs;
systemctlCommand = "${systemctl} ${escapedArgs}"; systemctlCommand = "${systemctl} ${escapedArgs}";
@@ -139,30 +97,30 @@ let
pkgs.writeShellScriptBin "mtls-renew" '' pkgs.writeShellScriptBin "mtls-renew" ''
set -euo pipefail set -euo pipefail
if ${lib.getExe pkgs.step-cli} certificate needs-renewal "${certFile}"; then if ${lib.getExe pkgs.step-cli} certificate needs-renewal "${tlsCert}"; then
${echoCmd} "Renewing mTLS certificate" echo "Renewing mTLS certificate"
else else
${echoCmd} "Skipping renew" echo "Skipping renew"
exit "$?" exit "$?"
fi fi
${lib.getExe pkgs.step-cli} ca renew --force "${certFile}" "${keyFile}" ${lib.getExe pkgs.step-cli} ca renew --force "${tlsCert}" "${tlsKey}"
umask 077 umask 077
${lib.getExe' pkgs.coreutils "cat"} "${certFile}" "${keyFile}" > "${bundleFile}" ${lib.getExe' pkgs.coreutils "cat"} "${tlsCert}" "${tlsKey}" > "${mtlsBundle}"
${echoCmd} "Reloading units:" echo "Reloading units:"
${renewReloadScript} ${renewReloadScript}
${echoCmd} "Post commands:" echo "Post commands:"
${renewPostCommands} ${renewPostCommands}
''; '';
mkNixosMtlsRenewService = { mkNixosMtlsRenewService = {
pkgs, pkgs,
certFile, tlsCert,
keyFile, tlsKey,
bundleFile, mtlsBundle,
reloadUnits ? [ ], reloadUnits ? [ ],
postCommands ? [ ], postCommands ? [ ],
user ? "root", user ? "root",
@@ -171,7 +129,7 @@ let
let let
serviceGroup = if group == null then user else group; serviceGroup = if group == null then user else group;
renewScript = mkMtlsRenewScript { renewScript = mkMtlsRenewScript {
inherit pkgs certFile keyFile bundleFile reloadUnits postCommands; inherit pkgs tlsCert tlsKey mtlsBundle reloadUnits postCommands;
}; };
in in
{ {
@@ -205,15 +163,15 @@ let
mkHomeManagerMtlsRenewService = { mkHomeManagerMtlsRenewService = {
pkgs, pkgs,
certFile, tlsCert,
keyFile, tlsKey,
bundleFile, mtlsBundle,
reloadUnits ? [ ], reloadUnits ? [ ],
postCommands ? [ ], postCommands ? [ ],
}: }:
let let
renewScript = mkMtlsRenewScript { renewScript = mkMtlsRenewScript {
inherit pkgs certFile keyFile bundleFile reloadUnits postCommands; inherit pkgs tlsCert tlsKey mtlsBundle reloadUnits postCommands;
systemctlArgs = [ "--user" ]; systemctlArgs = [ "--user" ];
}; };
in in
@@ -254,35 +212,36 @@ in
flake.modules.nixos.mtls = { config, lib, pkgs, ... }: flake.modules.nixos.mtls = { config, lib, pkgs, ... }:
let let
cfg = config.mtls; cfg = config.mtls;
certDir = "/etc/step/certs";
tlsKey = "${certDir}/${cfg.keyFilename}";
tlsCert = "${certDir}/${cfg.certFilename}";
mtlsBundle = "${certDir}/${cfg.bundleFilename}";
sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san; sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san;
in in
{ {
options.mtls = (mkOpts config) // { options.mtls = opts;
certDir = lib.mkOption {
description = "String path to where the mtls certs will be stored.";
type = lib.types.str;
default = "/etc/step-ca/certs";
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; lib.optionals cfg.enable [ environment.systemPackages = with pkgs; lib.optionals cfg.enable [
# step-cli (writeShellScriptBin "mtls-generate" ''
(mkMtlsGenerateScript { set -euo pipefail
inherit pkgs; ${lib.getExe pkgs.step-cli} ca certificate \
inherit (cfg) subject provisioner san certFile keyFile bundleFile lifetime; ${cfg.subject} ${tlsCert} ${tlsKey} \
}) --provisioner ${cfg.provisioner} \
(mkMtlsCheckScript { inherit pkgs; inherit (cfg) bundleFile; }) --not-before=-5m --not-after=${cfg.lifetime} \
(mkMtlsRenewScript { inherit pkgs; inherit (cfg) certFile keyFile bundleFile; }) ${sanArgs} \
]; "$@"
cat ${tlsCert} ${tlsKey} > ${mtlsBundle}
systemd.tmpfiles.rules = [ '')
"d ${cfg.certDir} 0750 ${cfg.renew.user} ${if cfg.renew.group == null then cfg.renew.user else cfg.renew.group} -" (writeShellScriptBin "mtls-check" ''
${lib.getExe pkgs.openssl} x509 \
-noout -subject -issuer \
-ext subjectAltName,extendedKeyUsage \
-enddate -in ${mtlsBundle}
'')
]; ];
systemd.services.mtls-renew = lib.mkIf cfg.renew.enable (mkNixosMtlsRenewService { systemd.services.mtls-renew = lib.mkIf cfg.renew.enable (mkNixosMtlsRenewService {
inherit pkgs; inherit pkgs tlsCert tlsKey mtlsBundle;
inherit (cfg) certFile keyFile bundleFile;
inherit (cfg.renew) reloadUnits postCommands user group; inherit (cfg.renew) reloadUnits postCommands user group;
}); });
@@ -295,37 +254,45 @@ in
flake.modules.homeManager.mtls = { config, lib, pkgs, ... }: flake.modules.homeManager.mtls = { config, lib, pkgs, ... }:
let let
cfg = config.mtls; cfg = config.mtls;
keyFile = cfg.keyFile; certDir = cfg.certDir;
certFile = cfg.certFile; tlsKey = "${certDir}/${cfg.keyFilename}";
bundleFile = cfg.bundleFile; tlsCert = "${certDir}/${cfg.certFilename}";
mtlsBundle = "${certDir}/${cfg.bundleFilename}";
sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san; sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san;
in in
{ {
options.mtls = (mkOpts config) // { options.mtls = opts // {
certDir = lib.mkOption { certDir = lib.mkOption {
description = "String path to where the mtls certs will be stored."; description = "String path to where the mtls certs will be stored.";
type = lib.types.str; type = lib.types.str;
default = "${config.home.homeDirectory}/.step/certs"; default ="${config.home.homeDirectory}/.step/certs";
}; };
}; };
config = { config = {
home.packages = with pkgs; lib.optionals cfg.enable [ home.packages = with pkgs; lib.optionals cfg.enable [
# step-cli step-cli
(mkMtlsGenerateScript { (writeShellScriptBin "mtls-generate" ''
inherit (cfg) subject provisioner san lifetime; set -euo pipefail
inherit pkgs certFile keyFile bundleFile; ${lib.getExe pkgs.step-cli} ca certificate \
}) ${cfg.subject} ${tlsCert} ${tlsKey} \
(mkMtlsCheckScript { inherit pkgs bundleFile; }) --not-before=-5m --not-after=${cfg.lifetime} \
(mkMtlsRenewScript { inherit pkgs certFile keyFile bundleFile; }) --provisioner ${cfg.provisioner} \
]; ${sanArgs} \
"$@"
systemd.user.tmpfiles.rules = lib.mkIf cfg.enable [ cat ${tlsCert} ${tlsKey} > ${mtlsBundle}
"d ${cfg.certDir} 0700 - - -" '')
(writeShellScriptBin "mtls-check" ''
${lib.getExe pkgs.openssl} x509 \
-noout -subject -issuer \
-ext subjectAltName,extendedKeyUsage \
-enddate -in ${mtlsBundle}
'')
(mkMtlsRenewScript { inherit pkgs tlsCert tlsKey mtlsBundle; })
]; ];
systemd.user.services.mtls-renew = lib.mkIf cfg.renew.enable (mkHomeManagerMtlsRenewService { systemd.user.services.mtls-renew = lib.mkIf cfg.renew.enable (mkHomeManagerMtlsRenewService {
inherit pkgs certFile keyFile bundleFile; inherit pkgs tlsCert tlsKey mtlsBundle;
inherit (cfg.renew) reloadUnits postCommands; inherit (cfg.renew) reloadUnits postCommands;
}); });
+2 -2
View File
@@ -33,7 +33,7 @@
networking.nameservers = [ "192.168.1.150" ]; networking.nameservers = [ "192.168.1.150" ];
networking.dhcpcd.extraConfig = "nohook resolv.conf"; networking.dhcpcd.extraConfig = "nohook resolv.conf";
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# step-cli step-cli
(writeShellScriptBin "ssh-host-cert-renew" '' (writeShellScriptBin "ssh-host-cert-renew" ''
${lib.getExe pkgs.step-cli} ssh certificate \ ${lib.getExe pkgs.step-cli} ssh certificate \
--host --sign \ --host --sign \
@@ -51,7 +51,7 @@
wantedBy = [ ]; wantedBy = [ ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
path = with pkgs; [ coreutils systemd step-cli openssh ]; path = [ pkgs.step-cli pkgs.openssh pkgs.coreutils pkgs.systemd ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
User = "root"; User = "root";
+1 -4
View File
@@ -17,9 +17,6 @@ in
crt = ""; crt = "";
}; };
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [ step-ca step-cli ];
step-ca
step-cli
];
}; };
} }
+11 -13
View File
@@ -1,12 +1,13 @@
{ self, inputs, lib, ... }: { inputs, ... }:
let let
username = "john"; username = "john";
in in
{ {
flake.meta.users."${username}" = { flake = {
meta.users."${username}" = {
email = "32917998+jsl12@users.noreply.github.com"; email = "32917998+jsl12@users.noreply.github.com";
name = "John Lancaster"; name = "John Lancaster";
inherit username; username = "${username}";
key = ""; key = "";
keygrip = [ keygrip = [
]; ];
@@ -16,33 +17,30 @@ in
]; ];
}; };
flake.modules = lib.mkMerge [ modules = {
(self.factory.user {
username = username;
isAdmin = true;
})
{
nixos."${username}" = { nixos."${username}" = {
imports = [ imports = [
inputs.home-manager.nixosModules.home-manager (inputs.self.factory.user username true).nixos."${username}"
]; ];
users.users."${username}" = { users.users."${username}" = {
openssh.authorizedKeys.keys = inputs.self.meta.users."${username}".authorizedKeys; openssh.authorizedKeys.keys = inputs.self.meta.users."${username}".authorizedKeys;
extraGroups = [ "docker" ];
}; };
}; };
# This module will be imported by the user factory
homeManager."${username}" = with inputs.self.meta.users."${username}"; { homeManager."${username}" = with inputs.self.meta.users."${username}"; {
home.stateVersion = "25.11"; home.stateVersion = "25.11";
xdg.enable = true; xdg.enable = true;
programs.git.settings.user.name = name; programs.git.settings.user.name = name;
programs.git.settings.user.email = email; programs.git.settings.user.email = email;
imports = with inputs.self.modules.homeManager; [ imports = with inputs.self.modules.homeManager; [
ssh ssh
shell-tools shell-tools
git git
]; ];
}; };
} };
]; };
} }
+50
View File
@@ -0,0 +1,50 @@
{
base = {
repository = "local:/mnt/backup";
password-file = "{{ .ConfigDir }}/password.txt";
status-file = "{{ .ConfigDir }}/backup-status.json";
retention = {
after-backup = true;
keep-last = "10";
keep-hourly = "8";
keep-daily = "14";
keep-weekly = "8";
};
backup = {
verbose = true;
exclude = [
".cache"
".devenv"
".rustup"
".cargo"
".venv"
".pyenv"
".vscode*"
"data/postgres"
"build"
"__pycache__"
"*.log"
"*.egg-info"
"*.csv"
"*.m4a"
".local/share/Steam"
".local/share/Trash"
"build"
"dist"
"/home/*/Pictures"
"/home/*/Videos"
"/home/*/go"
"/home/*/snap"
"/home/john/john-nas"
];
schedule-permission = "user";
schedule-priority = "background";
check-after = true;
};
prune = {
schedule-permission = "user";
schedule-lock-wait = "1h";
};
};
}