Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c357c69183 |
Generated
+31
-31
@@ -18,11 +18,11 @@
|
||||
},
|
||||
"flake-file": {
|
||||
"locked": {
|
||||
"lastModified": 1775848911,
|
||||
"narHash": "sha256-dqva/tlWxsXj32wYPdt06UrrR4l2QdK9JWyvPooWRi4=",
|
||||
"lastModified": 1774886516,
|
||||
"narHash": "sha256-w2LoQVM6DXrSdGUZBZqa1nYkMzHoB0t82DrptzZKhTs=",
|
||||
"owner": "vic",
|
||||
"repo": "flake-file",
|
||||
"rev": "b36cbd5fc01e9794a001ccb0c58b314efaabae08",
|
||||
"rev": "3daadf37de2bb85b0ff34e2a7ab0d71e077c2b9e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -95,11 +95,11 @@
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1776046499,
|
||||
"narHash": "sha256-Wzc4nn07/0RL21ypPHRzNDQZcjhIC8LaYo7QJQjM5T4=",
|
||||
"lastModified": 1775080052,
|
||||
"narHash": "sha256-jAB4ZZbx8ECu9GcE/PUUwT+wpooZ0Ssmn2imB8PVTdM=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "287f84846c1eb3b72c986f5f6bebcff0bd67440d",
|
||||
"rev": "6267895e9898399f0ce2fe79b645e9ee4858aaff",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -184,11 +184,11 @@
|
||||
"nixos-hardware": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1775490113,
|
||||
"narHash": "sha256-2ZBhDNZZwYkRmefK5XLOusCJHnoeKkoN95hoSGgMxWM=",
|
||||
"lastModified": 1774933469,
|
||||
"narHash": "sha256-OrnCQeUO2bqaWUl0lkDWyGWjKsOhtCyd7JSfTedQNUE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "c775c2772ba56e906cbeb4e0b2db19079ef11ff7",
|
||||
"rev": "f4c4c2c0c923d7811ac2a63ccc154767e4195337",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -199,11 +199,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1775423009,
|
||||
"narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=",
|
||||
"lastModified": 1774709303,
|
||||
"narHash": "sha256-D3Q07BbIA2KnTcSXIqqu9P586uWxN74zNoCH3h2ESHg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9",
|
||||
"rev": "8110df5ad7abf5d4c0f6fb0f8f978390e77f9685",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -215,11 +215,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1775888245,
|
||||
"narHash": "sha256-qTVvODr6edFBLD2lncXPF8yTQeCafZUuKVtpV3Xb3yM=",
|
||||
"rev": "13043924aaa7375ce482ebe2494338e058282925",
|
||||
"lastModified": 1775064974,
|
||||
"narHash": "sha256-PqhsO5qloSyvATi9qAIrgUcEFK67xSoacjacPw+t4H0=",
|
||||
"rev": "6ebfbc38bdc6b22822a6f991f2d922306f33cfbc",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre978638.13043924aaa7/nixexprs.tar.xz"
|
||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre973084.6ebfbc38bdc6/nixexprs.tar.xz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
@@ -228,11 +228,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1775579569,
|
||||
"narHash": "sha256-/m3yyS/EnXqoPGBJYVy4jTOsirdgsEZ3JdN2gGkBr14=",
|
||||
"lastModified": 1774610258,
|
||||
"narHash": "sha256-HaThtroVD9wRdx7KQk0B75JmFcXlMUoEdDFNOMOlsOs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dfd9566f82a6e1d55c30f861879186440614696e",
|
||||
"rev": "832efc09b4caf6b4569fbf9dc01bec3082a00611",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -254,11 +254,11 @@
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775892726,
|
||||
"narHash": "sha256-1TK1pe33cEHNvGW41TP5xAzrbG1Gp7LfyFL6c3+xf+I=",
|
||||
"lastModified": 1774852850,
|
||||
"narHash": "sha256-7VK4v7ZbQw5apfgc+FvgRi8BUC45ERlcp8VTTTQ3tko=",
|
||||
"owner": "notashelf",
|
||||
"repo": "nvf",
|
||||
"rev": "5ab359ee7dfd3fa09a5c6f863efaf810bb9a9436",
|
||||
"rev": "b4d6539e7e9948aaba5efd7a67a63672d1fa80ef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -292,11 +292,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775971308,
|
||||
"narHash": "sha256-VKp9bhVSm0bT6JWctFy06ocqxGGnWHi1NfoE90IgIcY=",
|
||||
"lastModified": 1774910634,
|
||||
"narHash": "sha256-B+rZDPyktGEjOMt8PcHKYmgmKoF+GaNAFJhguktXAo0=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "31ac5fe5d015f76b54058c69fcaebb66a55871a4",
|
||||
"rev": "19bf3d8678fbbfbc173beaa0b5b37d37938db301",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -340,11 +340,11 @@
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775940860,
|
||||
"narHash": "sha256-8Jxnn2uoFhm2H579ycVxFWDtrywJ6Mc8RmqWbZwk5So=",
|
||||
"lastModified": 1774879171,
|
||||
"narHash": "sha256-a6JZDuBIwQmuEwYM4dziH+WyrpE8HCP8F7JFIn3CNvw=",
|
||||
"owner": "BirdeeHub",
|
||||
"repo": "nix-wrapper-modules",
|
||||
"rev": "fb62851ffc5f6a4d53ebc00b93743e29b41e6224",
|
||||
"rev": "bab35ffae25cf6f4e4fdb3c2f7f0ac80966ce737",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -360,11 +360,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775600302,
|
||||
"narHash": "sha256-2fgKImv78CXIcfo1RsY7EI4uMZ84x/MggA5rrusYc7c=",
|
||||
"lastModified": 1774293387,
|
||||
"narHash": "sha256-yVekLWxKTUfUyuvo9HVihtOK8llIP3IZCrJmftxT+Nc=",
|
||||
"owner": "lassulus",
|
||||
"repo": "wrappers",
|
||||
"rev": "9d8397d8ef1ac35763085f3338589f558128f7db",
|
||||
"rev": "3cf1e8371129e8746d37c863c5d56a81fb16caa0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
home.packages = with pkgs; [
|
||||
mangohud
|
||||
sublime4
|
||||
proton-vpn
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,14 +2,10 @@
|
||||
flake.modules.nixos.forgejo = {config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.forgejo;
|
||||
needsPrivilegedPort = cfg.port < 1024;
|
||||
in
|
||||
{
|
||||
options.forgejo = {
|
||||
enable = lib.mkEnableOption "Enable Forgejo backed with PostgreSQL";
|
||||
root_url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
@@ -29,119 +25,40 @@
|
||||
config = lib.mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ cfg.port ];
|
||||
|
||||
systemd.services.forgejo.serviceConfig = lib.mkIf needsPrivilegedPort {
|
||||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
|
||||
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
|
||||
PrivateUsers = lib.mkForce false;
|
||||
};
|
||||
|
||||
sops.secrets = {
|
||||
"forgejo/secret_key".owner = config.services.forgejo.user;
|
||||
"forgejo/internal_token".owner = config.services.forgejo.user;
|
||||
"forgejo/jwt_secret".owner = config.services.forgejo.user;
|
||||
"forgejo/lfs_jwt_secret".owner = config.services.forgejo.user;
|
||||
};
|
||||
|
||||
services = {
|
||||
forgejo = {
|
||||
services.forgejo = {
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
database.type = "postgres";
|
||||
settings = {
|
||||
DEFAULT = {
|
||||
RUN_MODE = "dev";
|
||||
};
|
||||
server = lib.mkMerge [
|
||||
settings.server = lib.mkMerge [
|
||||
{
|
||||
HTTP_PORT = cfg.port;
|
||||
DISABLE_SSH = true;
|
||||
ROOT_URL = cfg.root_url;
|
||||
}
|
||||
(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;
|
||||
})
|
||||
];
|
||||
oauth2_client = {
|
||||
ENABLE_AUTO_REGISTRATION = true;
|
||||
USERNAME = "nickname";
|
||||
UPDATE_AVATAR = true;
|
||||
ACCOUNT_LINKING = "login";
|
||||
REGISTER_EMAIL_CONFIRM = false;
|
||||
};
|
||||
repository = {
|
||||
ENABLE_PUSH_CREATE_USER = true;
|
||||
};
|
||||
ui.SHOW_USER_EMAIL = false;
|
||||
markup = {
|
||||
ENABLED = true;
|
||||
|
||||
database = {
|
||||
type = "postgres";
|
||||
port = config.services.postgresql.settings.port;
|
||||
# createDatabase = false;
|
||||
};
|
||||
# dump = {
|
||||
# enable = true;
|
||||
# interval = "12h";
|
||||
# };
|
||||
};
|
||||
|
||||
secrets = {
|
||||
security = {
|
||||
SECRET_KEY = lib.mkForce config.sops.secrets."forgejo/secret_key".path;
|
||||
INTERNAL_TOKEN = lib.mkForce config.sops.secrets."forgejo/internal_token".path;
|
||||
};
|
||||
oauth2.JWT_SECRET = lib.mkForce config.sops.secrets."forgejo/jwt_secret".path;
|
||||
server.LFS_JWT_SECRET = lib.mkForce config.sops.secrets."forgejo/lfs_jwt_secret".path;
|
||||
};
|
||||
dump = {
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
type = "tar";
|
||||
interval = "*-*-* 00/12:00:00";
|
||||
};
|
||||
};
|
||||
settings = {
|
||||
|
||||
postgresql = {
|
||||
enable = true;
|
||||
enableTCPIP = false;
|
||||
};
|
||||
};
|
||||
|
||||
# https://forgejo.org/docs/latest/admin/command-line/#dump
|
||||
systemd.services.forgejo-dump.serviceConfig.ExecStart = lib.mkForce ''
|
||||
${lib.getExe config.services.forgejo.package} dump --verbose \
|
||||
--type ${config.services.forgejo.dump.type} \
|
||||
--database postgres \
|
||||
--work-path ${config.services.forgejo.dump.backupDir}
|
||||
'';
|
||||
|
||||
environment.systemPackages =
|
||||
let
|
||||
systemctl = lib.getExe' pkgs.systemd "systemctl";
|
||||
clean-forgejo = (pkgs.writeShellScriptBin "clean-forgejo" ''
|
||||
set -euo pipefail
|
||||
sudo ${systemctl} stop forgejo.service
|
||||
${lib.getExe' pkgs.coreutils "echo"} "Stopped Forgejo"
|
||||
sudo ${lib.getExe' pkgs.coreutils "rm"} -rf ${config.services.forgejo.stateDir}
|
||||
${lib.getExe' pkgs.coreutils "echo"} "Removed ${config.services.forgejo.stateDir}"
|
||||
'');
|
||||
clean-postgres = (pkgs.writeShellScriptBin "clean-postgres" ''
|
||||
set -euo pipefail
|
||||
sudo ${systemctl} stop postgresql.service
|
||||
${lib.getExe' pkgs.coreutils "echo"} "Stopped PostgreSQL"
|
||||
sudo ${lib.getExe' pkgs.coreutils "rm"} -rf ${config.services.postgresql.dataDir}
|
||||
${lib.getExe' pkgs.coreutils "echo"} "Removed ${config.services.postgresql.dataDir}"
|
||||
'');
|
||||
in [
|
||||
clean-forgejo
|
||||
clean-postgres
|
||||
(pkgs.writeShellScriptBin "clean-all" ''
|
||||
set -euo pipefail
|
||||
GREEN_CHECK="\e[32m✔\e[0m"
|
||||
YELLOW_BANG="\e[33m!\e[0m"
|
||||
${lib.getExe' pkgs.coreutils "echo"} -n -e "$YELLOW_BANG Remove everything related to Forgejo and the PostgreSQL database behind it?"
|
||||
read -p " (y/n) " -n 1 -r
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
${lib.getExe clean-forgejo}
|
||||
${lib.getExe clean-postgres}
|
||||
${lib.getExe' pkgs.coreutils "echo"} -e "$GREEN_CHECK Removed everything related to forgejo"
|
||||
fi
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
+78
-93
@@ -66,9 +66,9 @@ let
|
||||
default = "root";
|
||||
};
|
||||
group = lib.mkOption {
|
||||
description = "Group to run the mTLS renewal service as. Defaults to the configured renewal user.";
|
||||
description = "Group to run the mTLS renewal service as. Defaults to the configured renewal user when null.";
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = "mtls";
|
||||
default = null;
|
||||
};
|
||||
reloadUnits = lib.mkOption {
|
||||
description = "systemd units to try-reload-or-restart after a successful certificate renewal.";
|
||||
@@ -92,103 +92,88 @@ let
|
||||
keyFile,
|
||||
bundleFile,
|
||||
lifetime,
|
||||
user,
|
||||
group,
|
||||
}:
|
||||
let
|
||||
stepCmd = lib.getExe pkgs.step-cli;
|
||||
sanArgs = lib.concatMapStringsSep " " (s: "--san \"${s}\"") san;
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "mtls-generate";
|
||||
runtimeInputs = with pkgs; [ coreutils step-cli ];
|
||||
text = ''
|
||||
pkgs.writeShellScriptBin "mtls-generate" ''
|
||||
set -euo pipefail
|
||||
step ca certificate ${subject} ${certFile} ${keyFile} \
|
||||
--provisioner ${provisioner} \
|
||||
${stepCmd} ca certificate \
|
||||
${subject} ${certFile} ${keyFile} \
|
||||
--not-before=-5m --not-after=${lifetime} \
|
||||
--provisioner ${provisioner} \
|
||||
${sanArgs} \
|
||||
"$@"
|
||||
(umask 077; cat ${certFile} ${keyFile} > ${bundleFile})
|
||||
chown ${user}:${group} ${certFile} ${keyFile} ${bundleFile}
|
||||
chmod 640 ${certFile} ${keyFile} ${bundleFile}
|
||||
printf '\033[32m✔\033[0m \033[1mmTLS Bundle:\033[0m %s\n' ${lib.escapeShellArg bundleFile}
|
||||
cat ${certFile} ${keyFile} > ${bundleFile}
|
||||
'';
|
||||
};
|
||||
|
||||
mkMtlsCheckScript = { pkgs, bundleFile }: pkgs.writeShellApplication {
|
||||
name = "mtls-check";
|
||||
runtimeInputs = with pkgs; [ openssl ];
|
||||
text = ''
|
||||
openssl x509 -noout -in ${bundleFile} \
|
||||
-subject -issuer \
|
||||
mkMtlsCheckScript = { pkgs, bundleFile }: pkgs.writeShellScriptBin "mtls-check" ''
|
||||
${lib.getExe pkgs.openssl} x509 \
|
||||
-noout -subject -issuer \
|
||||
-ext subjectAltName,extendedKeyUsage \
|
||||
-enddate
|
||||
-enddate -in ${bundleFile}
|
||||
'';
|
||||
};
|
||||
|
||||
mkMtlsRenewScript = {
|
||||
pkgs,
|
||||
cfg,
|
||||
certFile,
|
||||
keyFile,
|
||||
bundleFile,
|
||||
reloadUnits ? [ ],
|
||||
postCommands ? [ ],
|
||||
systemctlArgs ? [ ],
|
||||
}:
|
||||
let
|
||||
systemctlCmd = "systemctl ${lib.escapeShellArgs systemctlArgs}";
|
||||
|
||||
hasReloadUnits = cfg.renew.reloadUnits != [ ];
|
||||
echoCmd = lib.getExe' pkgs.coreutils "echo";
|
||||
systemctl = lib.getExe' pkgs.systemd "systemctl";
|
||||
escapedArgs = lib.escapeShellArgs systemctlArgs;
|
||||
systemctlCommand = "${systemctl} ${escapedArgs}";
|
||||
renewReloadScript = lib.concatMapStringsSep "\n" (unit: ''
|
||||
if ${systemctlCmd} --quiet is-active "${unit}"; then
|
||||
${systemctlCmd} try-reload-or-restart "${unit}"
|
||||
if ${systemctlCommand} --quiet is-active "${unit}"; then
|
||||
${systemctlCommand} try-reload-or-restart "${unit}"
|
||||
fi
|
||||
'') cfg.renew.reloadUnits;
|
||||
|
||||
hasPostCommands = cfg.renew.postCommands != [ ];
|
||||
renewPostCommands = lib.concatStringsSep "\n" cfg.renew.postCommands;
|
||||
|
||||
fileOwner = "${cfg.renew.user}:${cfg.renew.group}";
|
||||
'') reloadUnits;
|
||||
renewPostCommands = lib.concatStringsSep "\n" postCommands;
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
name = "mtls-renew";
|
||||
runtimeInputs = with pkgs; [ coreutils step-cli systemd ];
|
||||
text = ''
|
||||
pkgs.writeShellScriptBin "mtls-renew" ''
|
||||
set -euo pipefail
|
||||
|
||||
YELLOW_BANG="\e[33m!\e[0m"
|
||||
|
||||
force=0
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--force)
|
||||
force=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo -e "$YELLOW_BANG Warning: ignoring unrecognized argument '$1'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $force -eq 0 ]] && ! step certificate needs-renewal "${cfg.certFile}"; then
|
||||
echo "Skipping renew"
|
||||
exit 0
|
||||
if ${lib.getExe pkgs.step-cli} certificate needs-renewal "${certFile}"; then
|
||||
${echoCmd} "Renewing mTLS certificate"
|
||||
else
|
||||
${echoCmd} "Skipping renew"
|
||||
exit "$?"
|
||||
fi
|
||||
|
||||
echo "Renewing mTLS certificate"
|
||||
step ca renew --force "${cfg.certFile}" "${cfg.keyFile}"
|
||||
(umask 077; cat "${cfg.certFile}" "${cfg.keyFile}" > "${cfg.bundleFile}")
|
||||
chown ${fileOwner} ${cfg.certFile} ${cfg.keyFile} ${cfg.bundleFile}
|
||||
chmod 640 ${cfg.certFile} ${cfg.keyFile} ${cfg.bundleFile}
|
||||
${lib.getExe pkgs.step-cli} ca renew --force "${certFile}" "${keyFile}"
|
||||
|
||||
${lib.optionalString hasReloadUnits ''
|
||||
echo "Reloading units: ${lib.concatStringsSep ", " cfg.renew.reloadUnits}"
|
||||
umask 077
|
||||
${lib.getExe' pkgs.coreutils "cat"} "${certFile}" "${keyFile}" > "${bundleFile}"
|
||||
|
||||
${echoCmd} "Reloading units:"
|
||||
${renewReloadScript}
|
||||
''}
|
||||
|
||||
${lib.optionalString hasPostCommands ''echo "Post commands:" ${renewPostCommands}''}
|
||||
${echoCmd} "Post commands:"
|
||||
${renewPostCommands}
|
||||
'';
|
||||
};
|
||||
|
||||
mkNixosMtlsRenewService = { pkgs, cfg, ... }:
|
||||
mkNixosMtlsRenewService = {
|
||||
pkgs,
|
||||
certFile,
|
||||
keyFile,
|
||||
bundleFile,
|
||||
reloadUnits ? [ ],
|
||||
postCommands ? [ ],
|
||||
user ? "root",
|
||||
group ? null,
|
||||
}:
|
||||
let
|
||||
serviceGroup = if group == null then user else group;
|
||||
renewScript = mkMtlsRenewScript {
|
||||
inherit pkgs certFile keyFile bundleFile reloadUnits postCommands;
|
||||
};
|
||||
in
|
||||
{
|
||||
description = "Renew the mTLS certificate when Smallstep marks it ready";
|
||||
wantedBy = [ ];
|
||||
@@ -196,9 +181,9 @@ let
|
||||
wants = [ "network-online.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = cfg.renew.user;
|
||||
Group = cfg.renew.group;
|
||||
ExecStart = lib.getExe (mkMtlsRenewScript { inherit pkgs cfg; });
|
||||
User = user;
|
||||
Group = serviceGroup;
|
||||
ExecStart = lib.getExe renewScript;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -218,10 +203,17 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
mkHomeManagerMtlsRenewService = { pkgs, cfg, ... }:
|
||||
mkHomeManagerMtlsRenewService = {
|
||||
pkgs,
|
||||
certFile,
|
||||
keyFile,
|
||||
bundleFile,
|
||||
reloadUnits ? [ ],
|
||||
postCommands ? [ ],
|
||||
}:
|
||||
let
|
||||
renewScript = mkMtlsRenewScript {
|
||||
inherit pkgs cfg;
|
||||
inherit pkgs certFile keyFile bundleFile reloadUnits postCommands;
|
||||
systemctlArgs = [ "--user" ];
|
||||
};
|
||||
in
|
||||
@@ -271,36 +263,28 @@ in
|
||||
type = lib.types.str;
|
||||
default = "/etc/step-ca/certs";
|
||||
};
|
||||
certReaders = lib.mkOption {
|
||||
description = "";
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups.certReaders = {
|
||||
name = cfg.renew.group;
|
||||
members = cfg.certReaders;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; lib.optionals cfg.enable [
|
||||
# step-cli
|
||||
(mkMtlsGenerateScript {
|
||||
inherit pkgs;
|
||||
inherit (cfg) subject provisioner san certFile keyFile bundleFile lifetime;
|
||||
inherit (cfg.renew) user group;
|
||||
})
|
||||
(mkMtlsCheckScript { inherit pkgs; inherit (cfg) bundleFile; })
|
||||
(mkMtlsRenewScript { inherit pkgs cfg; })
|
||||
(mkMtlsRenewScript { inherit pkgs; inherit (cfg) certFile keyFile bundleFile; })
|
||||
];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${cfg.certDir} 0750 ${cfg.renew.user} ${cfg.renew.group} -"
|
||||
"d ${cfg.certDir} 0750 ${cfg.renew.user} ${if cfg.renew.group == null then cfg.renew.user else cfg.renew.group} -"
|
||||
];
|
||||
|
||||
systemd.services.mtls-renew = lib.mkIf cfg.renew.enable
|
||||
(mkNixosMtlsRenewService { inherit pkgs cfg; });
|
||||
systemd.services.mtls-renew = lib.mkIf cfg.renew.enable (mkNixosMtlsRenewService {
|
||||
inherit pkgs;
|
||||
inherit (cfg) certFile keyFile bundleFile;
|
||||
inherit (cfg.renew) reloadUnits postCommands user group;
|
||||
});
|
||||
|
||||
systemd.timers.mtls-renew = lib.mkIf cfg.renew.enable (mkNixosMtlsRenewTimer {
|
||||
inherit (cfg.renew) onCalendar randomizedDelaySec;
|
||||
@@ -330,19 +314,20 @@ in
|
||||
# step-cli
|
||||
(mkMtlsGenerateScript {
|
||||
inherit (cfg) subject provisioner san lifetime;
|
||||
inherit (cfg.renew) user group;
|
||||
inherit pkgs certFile keyFile bundleFile;
|
||||
})
|
||||
(mkMtlsCheckScript { inherit pkgs bundleFile; })
|
||||
(mkMtlsRenewScript { inherit pkgs cfg; systemctlArgs = [ "--user" ]; })
|
||||
(mkMtlsRenewScript { inherit pkgs certFile keyFile bundleFile; })
|
||||
];
|
||||
|
||||
systemd.user.tmpfiles.rules = lib.mkIf cfg.enable [
|
||||
"d ${cfg.certDir} 0700 - - -"
|
||||
];
|
||||
|
||||
systemd.user.services.mtls-renew = lib.mkIf cfg.renew.enable
|
||||
(mkHomeManagerMtlsRenewService { inherit pkgs cfg; });
|
||||
systemd.user.services.mtls-renew = lib.mkIf cfg.renew.enable (mkHomeManagerMtlsRenewService {
|
||||
inherit pkgs certFile keyFile bundleFile;
|
||||
inherit (cfg.renew) reloadUnits postCommands;
|
||||
});
|
||||
|
||||
systemd.user.timers.mtls-renew = lib.mkIf cfg.renew.enable (mkHomeManagerMtlsRenewTimer {
|
||||
inherit (cfg.renew) onCalendar randomizedDelaySec;
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
home.shell.enableShellIntegration = true;
|
||||
programs.zsh.enable = lib.mkForce (config.shell.program == "zsh");
|
||||
home.packages = with pkgs; [
|
||||
nh
|
||||
nvd
|
||||
nix-output-monitor
|
||||
wget
|
||||
curl
|
||||
busybox
|
||||
@@ -34,7 +31,9 @@
|
||||
xclip
|
||||
jq
|
||||
ripgrep
|
||||
(writeShellScriptBin "ds" ''${lib.getExe pkgs.gdu} -x -I /snap /'')
|
||||
(writeShellScriptBin "ds" ''
|
||||
${lib.getExe pkgs.gdu} -x -I /snap /
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,52 +3,32 @@ let
|
||||
username = "john";
|
||||
hostname = "janus";
|
||||
ca-url = "https://janus.john-stream.com/";
|
||||
fingerprint = builtins.readFile ./fingerprint;
|
||||
fingerprint = "2036c44f7b5901566ff7611ea6c927291ecc6d2dd00779c0eead70ec77fa10d6";
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.janus-ca =
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.janus-ca;
|
||||
johnHome = lib.attrByPath [ "users" "users" username "home" ] "/home/${username}" config;
|
||||
johnGroup = lib.attrByPath [ "users" "users" username "group" ] username config;
|
||||
cfgInEtc = lib.hasPrefix "/etc/" cfg.certDir;
|
||||
certDirEtcPath =
|
||||
if cfgInEtc then
|
||||
lib.removePrefix "/etc/" cfg.certDir
|
||||
else
|
||||
cfg.certDir;
|
||||
certRootEtcPath = "${certDirEtcPath}/root_ca.crt";
|
||||
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-ca/defaults.json"
|
||||
"L+ ${home}/.step/certs/root_ca.crt - - - - ${cfg.certDir}/root_ca.crt"
|
||||
"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
|
||||
{
|
||||
options.janus-ca = {
|
||||
certDir = lib.mkOption {
|
||||
description = "String path to where the mtls certs will be stored.";
|
||||
type = lib.types.str;
|
||||
default = "/etc/step-ca/certs";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
environment.etc = lib.mkIf cfgInEtc {
|
||||
"step-ca/defaults.json".text = builtins.toJSON {
|
||||
environment.etc."step/config/defaults.json".text = builtins.toJSON {
|
||||
inherit ca-url fingerprint;
|
||||
root = "/etc/${certRootEtcPath}";
|
||||
};
|
||||
"${certRootEtcPath}".source = ./root_ca.crt;
|
||||
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, ... }: {
|
||||
home.file.".step/config/defaults.json".text = builtins.toJSON {
|
||||
@@ -95,7 +75,14 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
perSystem = { system, pkgs, lib, ... }: {
|
||||
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;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
2036c44f7b5901566ff7611ea6c927291ecc6d2dd00779c0eead70ec77fa10d6
|
||||
@@ -125,10 +125,7 @@
|
||||
bash
|
||||
discord
|
||||
my-neovim
|
||||
proton-vpn
|
||||
joplin-desktop
|
||||
];
|
||||
ssh.certificates.enable = true;
|
||||
ssh.matchSets = {
|
||||
appdaemon = true;
|
||||
homelab = true;
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
{ withSystem, self, inputs, ... }:
|
||||
{ self, inputs, ... }:
|
||||
let
|
||||
username = "john";
|
||||
hostname = "john-pc-ubuntu";
|
||||
|
||||
# testTarget = "fded:fb16:653e:25da:be24:11ff:fe89:1cc3"; # soteria
|
||||
# testTarget = "fded:fb16:653e:25da:be24:11ff:fea0:753f"; # test-nix
|
||||
testHost = "soteria"; # which host to test build
|
||||
testTarget = "test-nix";
|
||||
testTarget = "fded:fb16:653e:25da:be24:11ff:fea0:753f"; # test-nix
|
||||
# testTarget = "fded:fb16:653e:25da:be24:11ff:fe89:1cc3"; # soteria
|
||||
|
||||
in
|
||||
{
|
||||
flake.modules.homeManager."${hostname}" = { config, pkgs, lib, ... }:
|
||||
let
|
||||
selfPkgs = inputs.self.packages.${pkgs.stdenv.hostPlatform.system};
|
||||
resticPasswordFile = "${config.xdg.configHome}/restic/password.txt";
|
||||
flakeDir = "${config.xdg.configHome}/home-manager/jsl-dendritic";
|
||||
test-push = with pkgs; writeShellApplication {
|
||||
name = "test-push";
|
||||
runtimeInputs = [ nh ];
|
||||
text = ''nh os switch ${flakeDir}#${testHost} --target-host root@${testTarget} -e none'';
|
||||
};
|
||||
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
|
||||
{
|
||||
imports = with inputs.self.modules.homeManager; [
|
||||
@@ -32,6 +34,7 @@ in
|
||||
restic
|
||||
docker
|
||||
desktop
|
||||
# neovim
|
||||
];
|
||||
# TODO: make this more restrictive, rather than allowing all unfree packages
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
@@ -43,11 +46,8 @@ in
|
||||
home.homeDirectory = "/home/${username}";
|
||||
home.packages = with pkgs; [
|
||||
nixos-rebuild
|
||||
test-push
|
||||
selfPkgs.neovim-min
|
||||
# ${selfPkgs}.my-neovim
|
||||
# selfPkgs.richPrinter
|
||||
selfPkgs.janus-ca
|
||||
testPushCmd
|
||||
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.my-neovim
|
||||
];
|
||||
|
||||
shell.program = "zsh";
|
||||
@@ -109,9 +109,10 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeConfigurations."john@john-pc-ubuntu" = withSystem "x86_64-linux" (ctx@{ config, inputs', ...}:
|
||||
inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = inputs'.nixpkgs.legacyPackages;
|
||||
modules = [ inputs.self.modules.homeManager."${hostname}" ];
|
||||
});
|
||||
flake.homeConfigurations."${hostname}" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
|
||||
modules = with inputs.self.modules; [
|
||||
homeManager."${hostname}"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
janus:
|
||||
admin_jwk: ENC[AES256_GCM,data:2XcN5X77wTQ+OUXa4C9xAErGvrwJKseHjCcgoj6jt+c=,iv:9x+M1wM0dYND1JYkJjM4N8pSOok2OF+P9vmm9NCumTI=,tag:dTCfh+KB1iRJBVoNsGqvuw==,type:str]
|
||||
forgejo:
|
||||
#ENC[AES256_GCM,data:/wtm0uXbiWFoGNWtlTzVuNxBR7CPm2FMB98t3AxSj5V5rltLvzF9BjgWoJCiX3ltzmU=,iv:xaZXbUIGJHxPrLRQzEQI7hgRgc0y061jIhoE3zlcMaA=,tag:fQGheCIdBKm6wE+vtj7g6A==,type:comment]
|
||||
secret_key: ENC[AES256_GCM,data:/jcyeDcsryLqu9Q3VnNaENb71/Tl5JUr0zDzxt8L5UCtnJ/YHA6MKItrQ9ZHFv1XROtnSfZl9D5kKomeM8EVqA==,iv:HxMKAMVQ08gkq6SWENj0/d8i9PhcgPCp5eqbztj9bSg=,tag:nO2dFWT/vfgGc/9JIDZrGw==,type:str]
|
||||
#ENC[AES256_GCM,data:TADqVsZwXpH/zfrXNclavH8Sv++jX081UjK/Mkys5x52gU5fU0ikk478EmwzeergsHpmxxon,iv:v9HsIsud+eiko7F0u622MBrTVDsIxlpqru0Viifvqow=,tag:FLgNTW0EcGhHT6iI9I6Bsg==,type:comment]
|
||||
internal_token: ENC[AES256_GCM,data:7eZM+misgHZz1p6HH9VzCAPIIFjp2vT0kyc9B1KllE+x2URyrgs5IR9SZ+T5vNdMdnlNzF25pUhKzjbak8tVN554rYWp06SczzqhLyaoHKs8iGBohMqfJkoZxxIVSB7g7GC+/SAsb719,iv:XbBXqXh/PqjEcAj0qsajR7Ij56KGT/9Spdp5T549p9I=,tag:o4ONucOkIE2VJ6VjOlPb6w==,type:str]
|
||||
#ENC[AES256_GCM,data:ZqwgnKjaolJtjcy287fnDOkb/oSLnBpfWfsTeVPwbIE8YLRSoPP4gbCnHJBLq+TJNNI=,iv:zTvw4ZS6C1ifUwOijNLuTfUQ3JM+5gj1X2f/s8MwWXc=,tag:Y1yKlL+jIRHVBulGlSErog==,type:comment]
|
||||
jwt_secret: ENC[AES256_GCM,data:e59MlATOorsTIQjtTUKfX5Yo3CVsbbfuKczp1gh1m2D1kkZK3ORFztYpjg==,iv:JH3PVUmXToiThEKDkDJ8MGVMAPlIEgPSWhru+9WgNjk=,tag:FfDpaCPejpw6kGDkxJwDWw==,type:str]
|
||||
lfs_jwt_secret: ENC[AES256_GCM,data:xi9PEKFUGRyc3YOg3JM3KrrENi9xsbeBjiz4R16SK5WDafoGFLazN6KRJQ==,iv:1IhPyQDwA8tZ22pfZJiU8TRTCLCHC/HAnKdmSGDfvcM=,tag:rLdREVSKBm67rt8ayN16Vw==,type:str]
|
||||
restic_password: ENC[AES256_GCM,data:u7QOZXJkxVG4J75K5nphb2uJGdz6jbWuVSsKKu+41fshp7cVoRijtr/Cs02LjVse,iv:bt1W2FeBTG6ypBFYzMPXPIkYTSn0uHURY2ui6MRgYY8=,tag:DObAMws/zQcM+UKUe9EECA==,type:str]
|
||||
sops:
|
||||
age:
|
||||
- recipient: age1ykcs39e62pz3xu6cedg8ea685kv5d5qsrhgkndygzm8rx30xd5ys5t3qxt
|
||||
@@ -38,7 +29,7 @@ sops:
|
||||
Yjd0MUcxcExvWVpCOUR3MkdZdGQyWUkKnru0Y2A98+0Mps7EtVK7ct3vPqIGveUt
|
||||
E5fzpcKvdefzObrx7BPTwJ19t2fZg/dSi7HKwx3vmKZSzyQaqJOzsg==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2026-04-04T23:18:43Z"
|
||||
mac: ENC[AES256_GCM,data:qBgeli5lHb4pyA8nAADBuRBAaq8VbAIsFI37OZtgnbnoHW2crxo3YC+EknaIYnZpZ48kwVhQS5lGRjI6JsWWhTH3+LVAhTmS2Qj/pZTD/JDLK6XJGXS4U9nB7m9aGYyW8gFCy9/DfoJWGsS//+ZmUikKPfd5kMZgh1zGoYCIGug=,iv:h+2fA+bO2SMCNrEslP36x3BPRaIy25cU/DNX8CYSC6A=,tag:RvVyUZ4ONRaKaqGiT31eUQ==,type:str]
|
||||
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
|
||||
version: 3.12.2
|
||||
version: 3.12.1
|
||||
|
||||
@@ -17,9 +17,21 @@ in
|
||||
nixos.forgejo
|
||||
# nixos.restic-server
|
||||
# nixos.restic-envoy
|
||||
({ config, pkgs, ... }: {
|
||||
({ pkgs, ... }: {
|
||||
networking.hostName = hostname;
|
||||
time.timeZone = "America/Chicago";
|
||||
mtls = {
|
||||
enable = true;
|
||||
subject = hostname;
|
||||
san = [
|
||||
"${hostname}.john-stream.com"
|
||||
"192.168.1.142"
|
||||
];
|
||||
lifetime = "1h";
|
||||
renew.onCalendar = "*:3/15";
|
||||
renew.postCommands = [
|
||||
"${lib.getExe pkgs.docker} restart envoy"
|
||||
];
|
||||
};
|
||||
|
||||
# Removes password for sudo
|
||||
security.sudo-rs.extraRules = lib.mkAfter [
|
||||
@@ -33,53 +45,13 @@ in
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
users.users."${username}".extraGroups = [ "mtls" ];
|
||||
mtls = {
|
||||
enable = true;
|
||||
certDir = config.janus-ca.certDir;
|
||||
subject = hostname;
|
||||
san = [
|
||||
"${hostname}.john-stream.com"
|
||||
# "192.168.1.142"
|
||||
"forgejo.john-stream.com"
|
||||
"192.168.1.244"
|
||||
];
|
||||
lifetime = "12h";
|
||||
renew.onCalendar = "*:3/15";
|
||||
renew.reloadUnits = [ "forgejo.service" "restic-rest-server.service" ];
|
||||
certReaders = [ config.services.forgejo.user "restic" ];
|
||||
# nix.settings.build-dir = "/var/tmp/nix-build";
|
||||
# systemd.tmpfiles.rules = [
|
||||
# "d /var/tmp/nix-build 1777 root root -"
|
||||
# ];
|
||||
step-ssh-host = {
|
||||
hostname = hostname;
|
||||
};
|
||||
forgejo = {
|
||||
enable = true;
|
||||
root_url = "https://forgejo.john-stream.com";
|
||||
https = true;
|
||||
port = 443;
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 8000 ];
|
||||
services.restic.server = {
|
||||
enable = true;
|
||||
privateRepos = true;
|
||||
listenAddress = "0.0.0.0:8000";
|
||||
extraFlags = [
|
||||
"--no-auth"
|
||||
"--tls"
|
||||
"--tls-cert=${config.mtls.certFile}"
|
||||
"--tls-key=${config.mtls.keyFile}"
|
||||
];
|
||||
};
|
||||
|
||||
loginText.extraServiceStatus = {
|
||||
Docker = "docker";
|
||||
"mTLS Renewal" = "mtls-renew.timer";
|
||||
Forgejo = "forgejo.service";
|
||||
"Forgejo Backup" = "forgejo-dump.timer";
|
||||
"Restic REST Server" = "restic-rest-server.service";
|
||||
};
|
||||
|
||||
step-ssh-host.hostname = hostname;
|
||||
|
||||
# This provides the secrets at install time
|
||||
sops.defaultSopsFile = ./secrets.yaml;
|
||||
|
||||
@@ -93,8 +65,9 @@ in
|
||||
environment.systemPackages = [
|
||||
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.janus-ca
|
||||
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.my-neovim
|
||||
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.jsl-zsh
|
||||
];
|
||||
|
||||
forgejo.enable = true;
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
@@ -6,21 +6,11 @@
|
||||
flakeDir = config.rebuild.flakeDir;
|
||||
echoCmd = lib.getExe' pkgs.coreutils "echo";
|
||||
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
|
||||
|
||||
nfs = with pkgs; writeShellApplication {
|
||||
name = "nfs";
|
||||
runtimeInputs = [ coreutils hostname nh ];
|
||||
text = ''
|
||||
HOSTNAME=$(hostname -s)
|
||||
echo "Switching to the $HOSTNAME nixos profile"
|
||||
nh os switch "$@" "${flakeDir}#$HOSTNAME"
|
||||
'';
|
||||
};
|
||||
nfsu = with pkgs; writeShellApplication {
|
||||
name = "nfsu";
|
||||
runtimeInputs = [ nfs pkgs.git ];
|
||||
text = ''nfs --refresh "$@"'';
|
||||
};
|
||||
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 = {
|
||||
@@ -32,73 +22,29 @@
|
||||
};
|
||||
|
||||
config = {
|
||||
environment.systemPackages = with pkgs; [ nfs nfsu ];
|
||||
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 =
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
nixBin = lib.getExe pkgs.nix;
|
||||
flakeDir = config.homeManagerFlakeDir;
|
||||
echoCmd = lib.getExe' pkgs.coreutils "echo";
|
||||
hostnameCmd = "$(${lib.getExe pkgs.hostname} -s)";
|
||||
|
||||
flake-parts-check = with pkgs; writeShellApplication {
|
||||
name = "flake-parts-check";
|
||||
runtimeInputs = [ nix ];
|
||||
text = ''
|
||||
cd ${flakeDir}
|
||||
nix run "${flakeDir}#write-flake"
|
||||
nix flake check
|
||||
'';
|
||||
};
|
||||
|
||||
nhms = with pkgs; writeShellApplication {
|
||||
name = "nhms";
|
||||
runtimeInputs = [ coreutils hostname nh ];
|
||||
text = ''
|
||||
HOSTNAME=$(hostname -s)
|
||||
echo "Switching to the $HOSTNAME home-manager profile"
|
||||
nh home switch ${flakeDir} -c "$HOSTNAME" "$@"
|
||||
'';
|
||||
};
|
||||
|
||||
nhmu = with pkgs; writeShellApplication {
|
||||
name = "nhmu";
|
||||
runtimeInputs = [ nhms ];
|
||||
text = ''nhms --update'';
|
||||
};
|
||||
|
||||
test-build = with pkgs; writeShellApplication {
|
||||
name = "test-build";
|
||||
runtimeInputs = [ coreutils nix hostname ];
|
||||
text = ''
|
||||
if [ -z "$1" ]; then
|
||||
HOSTNAME=$(hostname -s)
|
||||
else
|
||||
HOSTNAME="$1"
|
||||
fi
|
||||
echo "Testing the evaulation of the nixos config for $HOSTNAME"
|
||||
nix eval "${flakeDir}#nixosConfigurations.$HOSTNAME.config.system.build.toplevel.drvPath"
|
||||
'';
|
||||
};
|
||||
|
||||
cleanup = with pkgs; writeShellApplication {
|
||||
name = "cleanup";
|
||||
runtimeInputs = [ coreutils home-manager nix ];
|
||||
text = ''
|
||||
set -e
|
||||
DAYS=$1
|
||||
if [ -z "$DAYS" ]; then
|
||||
echo "usage: cleanup <days>"
|
||||
exit 1
|
||||
fi
|
||||
home-manager expire-generations "-$DAYS days"
|
||||
nix profile wipe-history --older-than "''${DAYS}d"
|
||||
nix store gc
|
||||
nix store optimise
|
||||
'';
|
||||
};
|
||||
|
||||
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 = {
|
||||
@@ -107,25 +53,53 @@
|
||||
type = lib.types.str;
|
||||
default = "${config.xdg.configHome}/home-manager";
|
||||
};
|
||||
buildHostname = lib.mkOption {
|
||||
description = "Hostname for the NixOS configuration to use.";
|
||||
type = lib.types.str;
|
||||
default = hostnameCmd;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
home.activation.printFlakeDir = lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||
run echo "Home Manager flake directory: ${flakeDir}"
|
||||
run ${echoCmd} "Home Manager flake directory: ${flakeDir}"
|
||||
'';
|
||||
|
||||
home.packages = with pkgs; [
|
||||
home-manager
|
||||
(symlinkJoin {
|
||||
name = "build-tools";
|
||||
paths = [
|
||||
flake-parts-check
|
||||
(writeShellScriptBin "flake-parts-check" ''
|
||||
cd ${flakeDir}
|
||||
${nixBin} run "${flakeDir}#write-flake"
|
||||
${nixBin} flake check
|
||||
'')
|
||||
nhms
|
||||
nhmu
|
||||
test-build
|
||||
cleanup
|
||||
];
|
||||
})
|
||||
(writeShellScriptBin "nhmu" ''
|
||||
${nixBin} flake update --flake ${flakeDir}
|
||||
${lib.getExe 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
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
{ self, inputs, ... }: {
|
||||
flake-file.inputs = {
|
||||
wrapper-modules = {
|
||||
url = "github:BirdeeHub/nix-wrapper-modules";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
wrappers = {
|
||||
url = "github:lassulus/wrappers";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
{ inputs, ... }: {
|
||||
flake.modules.nixos.login-text = { config, lib, ... }:
|
||||
let
|
||||
defaultServiceStatus = {
|
||||
SSH = "sshd.socket";
|
||||
"SSH Cert Renewal" = "step-ssh-host-renew.timer";
|
||||
};
|
||||
in {
|
||||
options.loginText.extraServiceStatus = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.str;
|
||||
default = { };
|
||||
description = "Additional rust-motd service status entries keyed by display name.";
|
||||
};
|
||||
|
||||
config = {
|
||||
flake.modules.nixos.login-text = { config, ... }: {
|
||||
programs.rust-motd = {
|
||||
enable = true;
|
||||
refreshInterval = "*:0/5";
|
||||
@@ -34,10 +21,12 @@
|
||||
root = 3;
|
||||
};
|
||||
|
||||
service_status = lib.mkMerge [
|
||||
defaultServiceStatus
|
||||
config.loginText.extraServiceStatus
|
||||
];
|
||||
service_status = {
|
||||
Docker = "docker";
|
||||
SSH = "sshd.socket";
|
||||
"SSH Cert Renewal" = "step-ssh-host-renew.timer";
|
||||
"mTLS Renewal" = "mtls-renew.timer";
|
||||
};
|
||||
|
||||
# This calculation is wrong for LXCs
|
||||
# uptime = {
|
||||
@@ -54,5 +43,4 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,24 +1,14 @@
|
||||
{ self, inputs, ... }:
|
||||
{ inputs, pkgs, lib, ... }:
|
||||
{
|
||||
flake.modules.homeManager.eza = { config, pkgs, lib, ... }: {
|
||||
flake.modules.homeManager.eza = { pkgs, lib, ... }: {
|
||||
programs.eza = {
|
||||
enable = true;
|
||||
package = pkgs.eza;
|
||||
enableBashIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
git = true;
|
||||
icons = "auto";
|
||||
colors = "auto";
|
||||
extraOptions = [
|
||||
"--all"
|
||||
"--long"
|
||||
"--group-directories-first"
|
||||
"--sort=type"
|
||||
"--dereference"
|
||||
"--octal-permissions"
|
||||
"--smart-group"
|
||||
"--no-time"
|
||||
"--git"
|
||||
];
|
||||
};
|
||||
home.shellAliases = {
|
||||
ls = "${lib.getExe pkgs.eza} -lgos type --no-time --follow-symlinks";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,25 +1,15 @@
|
||||
{
|
||||
flake.modules.homeManager.files = { pkgs, lib, ... }:
|
||||
flake.modules.homeManager.files = { pkgs, ... }:
|
||||
{
|
||||
programs.lf = {
|
||||
enable = true;
|
||||
cmdKeybindings = {
|
||||
programs.lf.enable = true;
|
||||
programs.lf.cmdKeybindings = {
|
||||
"D" = "delete";
|
||||
};
|
||||
settings = {
|
||||
preview = true;
|
||||
hidden = true;
|
||||
drawbox = true;
|
||||
icons = true;
|
||||
ignorecase = true;
|
||||
};
|
||||
};
|
||||
|
||||
home.packages = with pkgs; [
|
||||
gdu
|
||||
# (writeShellScriptBin "lfcd" ''
|
||||
# . <(${lib.getExe pkgs.lf} -print-last-dir | sed 's/^/cd /')
|
||||
# '')
|
||||
lf
|
||||
# TODO: find a CLI file editor that's not insane
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -43,7 +43,6 @@
|
||||
shell-integration = "zsh";
|
||||
shell-integration-features = [ "no-title" "sudo" ];
|
||||
gtk-single-instance = true;
|
||||
mouse-scroll-multiplier = 0.375;
|
||||
|
||||
window-position-x = 25;
|
||||
window-position-y = 25;
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
{ 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;
|
||||
|
||||
+1
-135
@@ -1,4 +1,4 @@
|
||||
{ self, inputs, ... }:
|
||||
{ inputs, ... }:
|
||||
let
|
||||
username = "john";
|
||||
in
|
||||
@@ -51,138 +51,4 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
perSystem = { system, pkgs, ... }: {
|
||||
packages.jsl-zsh = inputs.wrapper-modules.wrappers.zsh.wrap {
|
||||
inherit pkgs;
|
||||
extraPackages = with pkgs; [
|
||||
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.neovim-min
|
||||
btop
|
||||
coreutils
|
||||
curl
|
||||
wget
|
||||
yazi
|
||||
zsh
|
||||
];
|
||||
};
|
||||
|
||||
packages.neovim-min = ((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;
|
||||
extraPlugins = with pkgs.vimPlugins; {
|
||||
icons = {
|
||||
package = nvim-web-devicons;
|
||||
};
|
||||
octo = {
|
||||
package = octo-nvim;
|
||||
setup = "require('octo').setup {}";
|
||||
after = ["telescope" "icons"];
|
||||
};
|
||||
};
|
||||
|
||||
# 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;
|
||||
|
||||
filetree.neo-tree.enable = true;
|
||||
|
||||
telescope = {
|
||||
enable = true;
|
||||
extensions = [
|
||||
{
|
||||
name = "fzf";
|
||||
packages = [pkgs.vimPlugins.telescope-fzf-native-nvim];
|
||||
setup = {fzf = {fuzzy = true;};};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
languages = {
|
||||
enableTreesitter = true;
|
||||
enableFormat = true;
|
||||
|
||||
markdown = {
|
||||
enable = true;
|
||||
extensions = {
|
||||
markview-nvim.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
bash.enable = true;
|
||||
yaml.enable = true;
|
||||
toml.enable = true;
|
||||
nix.enable = true;
|
||||
};
|
||||
|
||||
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 = "neovim-min";
|
||||
version = "custom";
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user