Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3fcf013b6 | |||
| 409fe16b9f | |||
| 13c7ab8d6a | |||
| 16a39dc46e | |||
| 51103ec4a1 | |||
| 450be7531d | |||
| d008fa5814 | |||
| 9aadd03d66 | |||
| cb0c671f47 | |||
| 608a261807 | |||
| 1b2698e629 | |||
| 3a416e716d | |||
| 52eda301e8 | |||
| 7f69fc6dce | |||
| 5ce7ace964 | |||
| f0cab4ad1f | |||
| 061d5a6f47 | |||
| 6ef67a575a | |||
| ea7e53f04d | |||
| 4c7da4abfa | |||
| 238e64437c | |||
| 5dcac56860 | |||
| 73950c72ed | |||
| bdf187b4f9 | |||
| 336166d22d | |||
| ac525dda78 | |||
| 4cd6972302 | |||
| 76be519c0f | |||
| c578bf00a1 | |||
| 429d1b7f11 | |||
| 942cc13cf0 | |||
| f1e395fd30 | |||
| 0ebd91234e | |||
| 4a235fe1e1 | |||
| 4465fd0f90 | |||
| 9c733a135a | |||
| 193e5ee40d | |||
| 71a04c627a | |||
| 338ef34212 | |||
| 1f5319252e | |||
| 29853f4a35 | |||
| 9f2a55cfd6 | |||
| 1d8e721171 | |||
| 731277aad8 | |||
| bab4dfa131 | |||
| 2c8e7e3b63 | |||
| 2ca7dcc464 | |||
| 8b4a2a36b6 | |||
| fae745af5a | |||
| 0d39ac7ca2 | |||
| 5bbf20aabd | |||
| 3da3cc2dc6 | |||
| 18b6cc16ad | |||
| d8ced840ca | |||
| 2fad88f8a0 | |||
| 7b0f419454 | |||
| f8c09878a1 |
@@ -9,7 +9,6 @@ creation_rules:
|
|||||||
- age:
|
- age:
|
||||||
- *john-pc
|
- *john-pc
|
||||||
- *soteria
|
- *soteria
|
||||||
- *test-nix
|
|
||||||
- path_regex: john-p14s/secrets\.yaml$
|
- path_regex: john-p14s/secrets\.yaml$
|
||||||
key_groups:
|
key_groups:
|
||||||
- age:
|
- age:
|
||||||
|
|||||||
Generated
+29
-165
@@ -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": 1775848911,
|
"lastModified": 1773637821,
|
||||||
"narHash": "sha256-dqva/tlWxsXj32wYPdt06UrrR4l2QdK9JWyvPooWRi4=",
|
"narHash": "sha256-Cp1x/5/97iNjXOI5hLCA51BwR6hc1dWJiZp4VPogkTw=",
|
||||||
"owner": "vic",
|
"owner": "vic",
|
||||||
"repo": "flake-file",
|
"repo": "flake-file",
|
||||||
"rev": "b36cbd5fc01e9794a001ccb0c58b314efaabae08",
|
"rev": "bb9fbe00ba6a1945fbdd6973c2585ab770f404b0",
|
||||||
"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": 1776046499,
|
"lastModified": 1774561634,
|
||||||
"narHash": "sha256-Wzc4nn07/0RL21ypPHRzNDQZcjhIC8LaYo7QJQjM5T4=",
|
"narHash": "sha256-3q1xsREjqdVIIwQQDZQ9y0YdBzP8gAxdwKoKnZSzJtU=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "287f84846c1eb3b72c986f5f6bebcff0bd67440d",
|
"rev": "7c046c63ac3b467c1d589b99d531da5b6520825a",
|
||||||
"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": 1775490113,
|
"lastModified": 1774567711,
|
||||||
"narHash": "sha256-2ZBhDNZZwYkRmefK5XLOusCJHnoeKkoN95hoSGgMxWM=",
|
"narHash": "sha256-uVlOHBvt6Vc/iYNJXLPa4c3cLXwMllOCVfAaLAcphIo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "c775c2772ba56e906cbeb4e0b2db19079ef11ff7",
|
"rev": "3f6f874dfc34d386d10e434c48ad966c4832243e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -199,11 +125,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775423009,
|
"lastModified": 1774106199,
|
||||||
"narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=",
|
"narHash": "sha256-US5Tda2sKmjrg2lNHQL3jRQ6p96cgfWh3J1QBliQ8Ws=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9",
|
"rev": "6c9a78c09ff4d6c21d0319114873508a6ec01655",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -215,11 +141,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775888245,
|
"lastModified": 1774273680,
|
||||||
"narHash": "sha256-qTVvODr6edFBLD2lncXPF8yTQeCafZUuKVtpV3Xb3yM=",
|
"narHash": "sha256-WLxi1vfcykjq9Yb2umqBJs6lVM6MpV2tXfcrAjroxUk=",
|
||||||
"rev": "13043924aaa7375ce482ebe2494338e058282925",
|
"rev": "fdc7b8f7b30fdbedec91b71ed82f36e1637483ed",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre978638.13043924aaa7/nixexprs.tar.xz"
|
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre968305.fdc7b8f7b30f/nixexprs.tar.xz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
@@ -228,11 +154,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775579569,
|
"lastModified": 1773840656,
|
||||||
"narHash": "sha256-/m3yyS/EnXqoPGBJYVy4jTOsirdgsEZ3JdN2gGkBr14=",
|
"narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "dfd9566f82a6e1d55c30f861879186440614696e",
|
"rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -242,31 +168,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nvf": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-compat": "flake-compat",
|
|
||||||
"flake-parts": "flake-parts_2",
|
|
||||||
"mnw": "mnw",
|
|
||||||
"ndg": "ndg",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1775892726,
|
|
||||||
"narHash": "sha256-1TK1pe33cEHNvGW41TP5xAzrbG1Gp7LfyFL6c3+xf+I=",
|
|
||||||
"owner": "notashelf",
|
|
||||||
"repo": "nvf",
|
|
||||||
"rev": "5ab359ee7dfd3fa09a5c6f863efaf810bb9a9436",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "notashelf",
|
|
||||||
"repo": "nvf",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-file": "flake-file",
|
"flake-file": "flake-file",
|
||||||
@@ -279,10 +180,8 @@
|
|||||||
"nixpkgs-lib": [
|
"nixpkgs-lib": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"nvf": "nvf",
|
|
||||||
"sops-nix": "sops-nix",
|
"sops-nix": "sops-nix",
|
||||||
"wrapper-modules": "wrapper-modules",
|
"wrapper-modules": "wrapper-modules"
|
||||||
"wrappers": "wrappers"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sops-nix": {
|
"sops-nix": {
|
||||||
@@ -292,11 +191,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775971308,
|
"lastModified": 1774303811,
|
||||||
"narHash": "sha256-VKp9bhVSm0bT6JWctFy06ocqxGGnWHi1NfoE90IgIcY=",
|
"narHash": "sha256-fhG4JAcLgjKwt+XHbjs8brpWnyKUfU4LikLm3s0Q/ic=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "31ac5fe5d015f76b54058c69fcaebb66a55871a4",
|
"rev": "614e256310e0a4f8a9ccae3fa80c11844fba7042",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -320,31 +219,16 @@
|
|||||||
"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": {
|
"wrapper-modules": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs_3"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775940860,
|
"lastModified": 1774538285,
|
||||||
"narHash": "sha256-8Jxnn2uoFhm2H579ycVxFWDtrywJ6Mc8RmqWbZwk5So=",
|
"narHash": "sha256-KRDNQDEWjB2O5SRH/oUTzi34cNxlIT8sab0FK2uqZ2g=",
|
||||||
"owner": "BirdeeHub",
|
"owner": "BirdeeHub",
|
||||||
"repo": "nix-wrapper-modules",
|
"repo": "nix-wrapper-modules",
|
||||||
"rev": "fb62851ffc5f6a4d53ebc00b93743e29b41e6224",
|
"rev": "15d740b2bfc545189a569147da7718457c12758e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -352,26 +236,6 @@
|
|||||||
"repo": "nix-wrapper-modules",
|
"repo": "nix-wrapper-modules",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"wrappers": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1775600302,
|
|
||||||
"narHash": "sha256-2fgKImv78CXIcfo1RsY7EI4uMZ84x/MggA5rrusYc7c=",
|
|
||||||
"owner": "lassulus",
|
|
||||||
"repo": "wrappers",
|
|
||||||
"rev": "9d8397d8ef1ac35763085f3338589f558128f7db",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "lassulus",
|
|
||||||
"repo": "wrappers",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|||||||
@@ -21,18 +21,10 @@
|
|||||||
};
|
};
|
||||||
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";
|
wrapper-modules.url = "github:BirdeeHub/nix-wrapper-modules";
|
||||||
wrappers = {
|
|
||||||
url = "github:lassulus/wrappers";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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" ];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
mangohud
|
mangohud
|
||||||
sublime4
|
sublime4
|
||||||
|
proton-vpn
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,147 +0,0 @@
|
|||||||
{ self, inputs, ... }: {
|
|
||||||
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;
|
|
||||||
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 ];
|
|
||||||
|
|
||||||
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 = {
|
|
||||||
enable = true;
|
|
||||||
lfs.enable = true;
|
|
||||||
database.type = "postgres";
|
|
||||||
settings = {
|
|
||||||
DEFAULT = {
|
|
||||||
RUN_MODE = "dev";
|
|
||||||
};
|
|
||||||
server = lib.mkMerge [
|
|
||||||
{
|
|
||||||
HTTP_PORT = cfg.port;
|
|
||||||
DISABLE_SSH = true;
|
|
||||||
ROOT_URL = cfg.root_url;
|
|
||||||
}
|
|
||||||
(lib.mkIf cfg.https {
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
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 = {
|
|
||||||
enable = true;
|
|
||||||
type = "tar";
|
|
||||||
interval = "*-*-* 00/12:00:00";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
pkgs.gnome-settings-daemon # For gnome systray icons
|
pkgs.gnome-settings-daemon # For gnome systray icons
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.modules.homeManager.gnome = { config, pkgs, ... }:
|
flake.modules.homeManager.gnome = { config, pkgs, ... }:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# https://github.com/glabrie/dotfiles/blob/main/modules/system/settings/greetd.nix
|
# https://github.com/glabrie/dotfiles/blob/main/modules/system/settings/greetd.nix
|
||||||
{ inputs, ... }: {
|
{ inputs, ... }: {
|
||||||
flake.modules.nixos.greetd = { pkgs, lib, ... }: {
|
flake.module.nixos.greetd = { pkgs, lib, ... }: {
|
||||||
services.greetd = {
|
services.greetd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
|||||||
@@ -1,352 +0,0 @@
|
|||||||
{ self, inputs, lib, ... }:
|
|
||||||
let
|
|
||||||
# Options that will be in common between the nixos module and the home-manager module.
|
|
||||||
mkOpts = config: let cfg = config.mtls; in {
|
|
||||||
enable = lib.mkEnableOption "Enable mTLS";
|
|
||||||
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.";
|
|
||||||
type = lib.types.str;
|
|
||||||
};
|
|
||||||
certDir = lib.mkOption {
|
|
||||||
description = "String path to the directory where the certs will be stored";
|
|
||||||
type = lib.types.str;
|
|
||||||
};
|
|
||||||
caFile = lib.mkOption {
|
|
||||||
description = "String path for the root CA file";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "${cfg.certDir}/root_ca.crt";
|
|
||||||
};
|
|
||||||
keyFile = lib.mkOption {
|
|
||||||
description = "String path for the private key";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "${cfg.certDir}/key.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 {
|
|
||||||
description = "List of SAN to give the mTLS cert";
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ ];
|
|
||||||
};
|
|
||||||
provisioner = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "admin";
|
|
||||||
};
|
|
||||||
lifetime = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "24h";
|
|
||||||
};
|
|
||||||
renew = {
|
|
||||||
enable = lib.mkOption {
|
|
||||||
description = "Enable automatic mTLS certificate renewal using a systemd timer.";
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
onCalendar = lib.mkOption {
|
|
||||||
description = "systemd OnCalendar schedule for mTLS certificate renewal checks.";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "*:1/15";
|
|
||||||
};
|
|
||||||
randomizedDelaySec = lib.mkOption {
|
|
||||||
description = "Randomized delay added to renewal timer runs to avoid synchronized renewals.";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "5m";
|
|
||||||
};
|
|
||||||
user = lib.mkOption {
|
|
||||||
description = "User account to run the mTLS renewal service as.";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "root";
|
|
||||||
};
|
|
||||||
group = lib.mkOption {
|
|
||||||
description = "Group to run the mTLS renewal service as. Defaults to the configured renewal user.";
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = "mtls";
|
|
||||||
};
|
|
||||||
reloadUnits = lib.mkOption {
|
|
||||||
description = "systemd units to try-reload-or-restart after a successful certificate renewal.";
|
|
||||||
type = lib.types.listOf lib.types.str;
|
|
||||||
default = [ ];
|
|
||||||
};
|
|
||||||
postCommands = lib.mkOption {
|
|
||||||
description = "Shell commands to run after a successful certificate renewal.";
|
|
||||||
type = lib.types.listOf lib.types.lines;
|
|
||||||
default = [ ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkMtlsGenerateScript = {
|
|
||||||
pkgs,
|
|
||||||
subject,
|
|
||||||
provisioner,
|
|
||||||
san,
|
|
||||||
certFile,
|
|
||||||
keyFile,
|
|
||||||
bundleFile,
|
|
||||||
lifetime,
|
|
||||||
user,
|
|
||||||
group,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
sanArgs = lib.concatMapStringsSep " " (s: "--san \"${s}\"") san;
|
|
||||||
in
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "mtls-generate";
|
|
||||||
runtimeInputs = with pkgs; [ coreutils step-cli ];
|
|
||||||
text = ''
|
|
||||||
set -euo pipefail
|
|
||||||
step ca certificate ${subject} ${certFile} ${keyFile} \
|
|
||||||
--provisioner ${provisioner} \
|
|
||||||
--not-before=-5m --not-after=${lifetime} \
|
|
||||||
${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}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
mkMtlsCheckScript = { pkgs, bundleFile }: pkgs.writeShellApplication {
|
|
||||||
name = "mtls-check";
|
|
||||||
runtimeInputs = with pkgs; [ openssl ];
|
|
||||||
text = ''
|
|
||||||
openssl x509 -noout -in ${bundleFile} \
|
|
||||||
-subject -issuer \
|
|
||||||
-ext subjectAltName,extendedKeyUsage \
|
|
||||||
-enddate
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
mkMtlsRenewScript = {
|
|
||||||
pkgs,
|
|
||||||
cfg,
|
|
||||||
systemctlArgs ? [ ],
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
systemctlCmd = "systemctl ${lib.escapeShellArgs systemctlArgs}";
|
|
||||||
|
|
||||||
hasReloadUnits = cfg.renew.reloadUnits != [ ];
|
|
||||||
renewReloadScript = lib.concatMapStringsSep "\n" (unit: ''
|
|
||||||
if ${systemctlCmd} --quiet is-active "${unit}"; then
|
|
||||||
${systemctlCmd} 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}";
|
|
||||||
in
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "mtls-renew";
|
|
||||||
runtimeInputs = with pkgs; [ coreutils step-cli systemd ];
|
|
||||||
text = ''
|
|
||||||
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
|
|
||||||
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.optionalString hasReloadUnits ''
|
|
||||||
echo "Reloading units: ${lib.concatStringsSep ", " cfg.renew.reloadUnits}"
|
|
||||||
${renewReloadScript}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${lib.optionalString hasPostCommands ''echo "Post commands:" ${renewPostCommands}''}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
mkNixosMtlsRenewService = { pkgs, cfg, ... }:
|
|
||||||
{
|
|
||||||
description = "Renew the mTLS certificate when Smallstep marks it ready";
|
|
||||||
wantedBy = [ ];
|
|
||||||
after = [ "network-online.target" ];
|
|
||||||
wants = [ "network-online.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
User = cfg.renew.user;
|
|
||||||
Group = cfg.renew.group;
|
|
||||||
ExecStart = lib.getExe (mkMtlsRenewScript { inherit pkgs cfg; });
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkNixosMtlsRenewTimer = {
|
|
||||||
onCalendar,
|
|
||||||
randomizedDelaySec,
|
|
||||||
unit ? "mtls-renew.service",
|
|
||||||
}: {
|
|
||||||
description = "Periodic Smallstep renewal for the mTLS certificate";
|
|
||||||
wantedBy = [ "timers.target" ];
|
|
||||||
timerConfig = {
|
|
||||||
Persistent = true;
|
|
||||||
OnCalendar = onCalendar;
|
|
||||||
AccuracySec = "1us";
|
|
||||||
RandomizedDelaySec = randomizedDelaySec;
|
|
||||||
Unit = unit;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkHomeManagerMtlsRenewService = { pkgs, cfg, ... }:
|
|
||||||
let
|
|
||||||
renewScript = mkMtlsRenewScript {
|
|
||||||
inherit pkgs cfg;
|
|
||||||
systemctlArgs = [ "--user" ];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
Unit = {
|
|
||||||
Description = "Renew the mTLS certificate when Smallstep marks it ready";
|
|
||||||
After = [ "network-online.target" ];
|
|
||||||
Wants = [ "network-online.target" ];
|
|
||||||
};
|
|
||||||
Service = {
|
|
||||||
Type = "oneshot";
|
|
||||||
ExecStart = lib.getExe renewScript;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkHomeManagerMtlsRenewTimer = {
|
|
||||||
onCalendar,
|
|
||||||
randomizedDelaySec,
|
|
||||||
unit ? "mtls-renew.service",
|
|
||||||
}: {
|
|
||||||
Unit = {
|
|
||||||
Description = "Periodic Smallstep renewal for the mTLS certificate";
|
|
||||||
};
|
|
||||||
Timer = {
|
|
||||||
Persistent = true;
|
|
||||||
OnCalendar = onCalendar;
|
|
||||||
AccuracySec = "1us";
|
|
||||||
RandomizedDelaySec = randomizedDelaySec;
|
|
||||||
Unit = unit;
|
|
||||||
};
|
|
||||||
Install = {
|
|
||||||
WantedBy = [ "timers.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
flake.modules.nixos.mtls = { config, lib, pkgs, ... }:
|
|
||||||
let
|
|
||||||
cfg = config.mtls;
|
|
||||||
sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.mtls = (mkOpts config) // {
|
|
||||||
certDir = lib.mkOption {
|
|
||||||
description = "String path to where the mtls certs will be stored.";
|
|
||||||
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; })
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d ${cfg.certDir} 0750 ${cfg.renew.user} ${cfg.renew.group} -"
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.services.mtls-renew = lib.mkIf cfg.renew.enable
|
|
||||||
(mkNixosMtlsRenewService { inherit pkgs cfg; });
|
|
||||||
|
|
||||||
systemd.timers.mtls-renew = lib.mkIf cfg.renew.enable (mkNixosMtlsRenewTimer {
|
|
||||||
inherit (cfg.renew) onCalendar randomizedDelaySec;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
flake.modules.homeManager.mtls = { config, lib, pkgs, ... }:
|
|
||||||
let
|
|
||||||
cfg = config.mtls;
|
|
||||||
keyFile = cfg.keyFile;
|
|
||||||
certFile = cfg.certFile;
|
|
||||||
bundleFile = cfg.bundleFile;
|
|
||||||
sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.mtls = (mkOpts config) // {
|
|
||||||
certDir = lib.mkOption {
|
|
||||||
description = "String path to where the mtls certs will be stored.";
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "${config.home.homeDirectory}/.step/certs";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
home.packages = with pkgs; lib.optionals cfg.enable [
|
|
||||||
# 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" ]; })
|
|
||||||
];
|
|
||||||
|
|
||||||
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.timers.mtls-renew = lib.mkIf cfg.renew.enable (mkHomeManagerMtlsRenewTimer {
|
|
||||||
inherit (cfg.renew) onCalendar randomizedDelaySec;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -2,57 +2,12 @@
|
|||||||
let
|
let
|
||||||
username = "john";
|
username = "john";
|
||||||
hostname = "janus";
|
hostname = "janus";
|
||||||
ca-url = "https://janus.john-stream.com/";
|
|
||||||
fingerprint = builtins.readFile ./fingerprint;
|
|
||||||
in
|
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"
|
|
||||||
];
|
|
||||||
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 {
|
|
||||||
inherit ca-url fingerprint;
|
|
||||||
root = "/etc/${certRootEtcPath}";
|
|
||||||
};
|
|
||||||
"${certRootEtcPath}".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;
|
||||||
@@ -63,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
|
||||||
@@ -85,8 +40,9 @@ 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;
|
||||||
@@ -94,16 +50,4 @@ in
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
perSystem = { system, 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}"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
2036c44f7b5901566ff7611ea6c927291ecc6d2dd00779c0eead70ec77fa10d6
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
{ self, inputs, ... }:
|
{ self, inputs, ... }:
|
||||||
{
|
{
|
||||||
flake.modules.nixos.p14sConfiguration = { config, pkgs, lib, ... }:
|
flake.modules.nixos.p14sConfiguration = { pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
hostname = "john-p14s";
|
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
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -18,16 +15,14 @@
|
|||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
rebuild.flakeDir = flakeDir;
|
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostName = hostname;
|
hostName = hostname;
|
||||||
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";
|
||||||
|
|
||||||
programs.zsh.enable = true;
|
programs.zsh.enable = true;
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
@@ -41,7 +36,6 @@
|
|||||||
busybox
|
busybox
|
||||||
dig
|
dig
|
||||||
samba
|
samba
|
||||||
my-neovim
|
|
||||||
];
|
];
|
||||||
|
|
||||||
security.pam.services.swaylock = {};
|
security.pam.services.swaylock = {};
|
||||||
@@ -71,19 +65,18 @@
|
|||||||
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";
|
||||||
LC_MONETARY = "en_US.UTF-8";
|
LC_MONETARY = "en_US.UTF-8";
|
||||||
LC_NAME = "en_US.UTF-8";
|
LC_NAME = "en_US.UTF-8";
|
||||||
LC_NUMERIC = "en_US.UTF-8";
|
LC_NUMERIC = "en_US.UTF-8";
|
||||||
LC_PAPER = "en_US.UTF-8";
|
LC_PAPER = "en_US.UTF-8";
|
||||||
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).
|
services.libinput.enable = true; # Enable touchpad support (enabled default in most desktopManager).
|
||||||
@@ -104,44 +97,5 @@
|
|||||||
# no need to redefine it in your config for now)
|
# no need to redefine it in your config for now)
|
||||||
# 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
|
|
||||||
proton-vpn
|
|
||||||
joplin-desktop
|
|
||||||
];
|
|
||||||
ssh.certificates.enable = true;
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,16 +10,23 @@
|
|||||||
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"
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.users.john.imports = with inputs.self.modules.homeManager; [
|
||||||
|
gnome
|
||||||
|
desktop
|
||||||
|
{
|
||||||
|
my-vscode.enable = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
] ++ (with self.modules.nixos; [
|
] ++ (with self.modules.nixos; [
|
||||||
p14sConfiguration
|
p14sConfiguration
|
||||||
janus-ca
|
|
||||||
rebuild
|
|
||||||
sudo
|
sudo
|
||||||
john
|
john
|
||||||
gnome
|
gnome
|
||||||
steam
|
steam
|
||||||
wireguard
|
# wireguard
|
||||||
mtls
|
|
||||||
# greetd
|
# greetd
|
||||||
# niri
|
# niri
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,25 +1,17 @@
|
|||||||
{ withSystem, self, inputs, ... }:
|
{ inputs, ... }:
|
||||||
let
|
let
|
||||||
username = "john";
|
username = "john";
|
||||||
hostname = "john-pc-ubuntu";
|
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
|
# 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 = "test-nix";
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.modules.homeManager."${hostname}" = { config, pkgs, lib, ... }:
|
flake.modules.homeManager."${hostname}" = { pkgs, config, ... }:
|
||||||
let
|
let
|
||||||
selfPkgs = inputs.self.packages.${pkgs.stdenv.hostPlatform.system};
|
|
||||||
resticPasswordFile = "${config.xdg.configHome}/restic/password.txt";
|
|
||||||
flakeDir = "${config.xdg.configHome}/home-manager/jsl-dendritic";
|
flakeDir = "${config.xdg.configHome}/home-manager/jsl-dendritic";
|
||||||
test-push = with pkgs; writeShellApplication {
|
certDir = "${config.mtls.certDir}";
|
||||||
name = "test-push";
|
mtlsBundle = "${certDir}/${config.mtls.bundleFilename}";
|
||||||
runtimeInputs = [ nh ];
|
resticPasswordFile = "${config.xdg.configHome}/restic/password.txt";
|
||||||
text = ''nh os switch ${flakeDir}#${testHost} --target-host root@${testTarget} -e none'';
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = with inputs.self.modules.homeManager; [
|
imports = with inputs.self.modules.homeManager; [
|
||||||
@@ -33,24 +25,27 @@ in
|
|||||||
docker
|
docker
|
||||||
desktop
|
desktop
|
||||||
];
|
];
|
||||||
# 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
|
||||||
test-push
|
(writeShellScriptBin "test-push" ''
|
||||||
selfPkgs.neovim-min
|
mkdir -p /var/tmp/nix-build
|
||||||
# ${selfPkgs}.my-neovim
|
chmod 1777 /var/tmp/nix-build
|
||||||
# selfPkgs.richPrinter
|
nixos-rebuild switch \
|
||||||
selfPkgs.janus-ca
|
--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;
|
||||||
@@ -109,9 +101,10 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.homeConfigurations."john@john-pc-ubuntu" = withSystem "x86_64-linux" (ctx@{ config, inputs', ...}:
|
flake.homeConfigurations."${hostname}" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
inputs.home-manager.lib.homeManagerConfiguration {
|
pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
|
||||||
pkgs = inputs'.nixpkgs.legacyPackages;
|
modules = with inputs.self.modules; [
|
||||||
modules = [ inputs.self.modules.homeManager."${hostname}" ];
|
homeManager."${hostname}"
|
||||||
});
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +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]
|
||||||
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:
|
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-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]
|
|
||||||
unencrypted_suffix: _unencrypted
|
unencrypted_suffix: _unencrypted
|
||||||
version: 3.12.2
|
version: 3.12.1
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ self, inputs, lib, ... }:
|
{ inputs, ... }:
|
||||||
let
|
let
|
||||||
username = "john";
|
username = "john";
|
||||||
hostname = "soteria";
|
hostname = "soteria";
|
||||||
@@ -7,110 +7,65 @@ 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
|
||||||
({ config, pkgs, ... }: {
|
{
|
||||||
networking.hostName = hostname;
|
networking.hostName = hostname;
|
||||||
time.timeZone = "America/Chicago";
|
nix.settings.build-dir = "/var/tmp/nix-build";
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
# Removes password for sudo
|
"d /var/tmp/nix-build 1777 root root -"
|
||||||
security.sudo-rs.extraRules = lib.mkAfter [
|
|
||||||
{
|
|
||||||
users = [ username ];
|
|
||||||
commands = [
|
|
||||||
{
|
|
||||||
command = "ALL";
|
|
||||||
options = [ "NOPASSWD" ];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
step-ssh-host = {
|
||||||
users.users."${username}".extraGroups = [ "mtls" ];
|
hostname = hostname;
|
||||||
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" ];
|
|
||||||
};
|
|
||||||
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;
|
|
||||||
|
|
||||||
programs.zsh.enable = true;
|
|
||||||
home-manager.users."${username}" = {
|
home-manager.users."${username}" = {
|
||||||
imports = with inputs.self.modules; [
|
imports = with inputs.self.modules; [
|
||||||
homeManager."${hostname}"
|
homeManager"${hostname}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
}
|
||||||
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
|
|
||||||
];
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.modules.homeManager."${hostname}" = { config, pkgs, lib, ... }: {
|
flake.modules.homeManager."${hostname}" = { config, lib, pkgs, ... }: {
|
||||||
imports = with inputs.self.modules; [
|
imports = with inputs.self.modules; [
|
||||||
homeManager.rebuild
|
homeManager.rebuild
|
||||||
homeManager.mysops
|
homeManager.mysops
|
||||||
|
homeManager.janus-ca
|
||||||
|
homeManager.mtls
|
||||||
|
homeManager.docker
|
||||||
];
|
];
|
||||||
|
|
||||||
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager";
|
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager";
|
||||||
|
home.username = "${username}";
|
||||||
|
home.homeDirectory = "/home/${username}";
|
||||||
shell.program = "zsh";
|
shell.program = "zsh";
|
||||||
docker.enable = true;
|
docker.enable = true;
|
||||||
|
|
||||||
# This will provide the edit-secrets script targeting this file
|
# This will provide the edit-secrets script targeting this file
|
||||||
mysops.hostSecretFile = "${config.homeManagerFlakeDir}/modules/hosts/soteria/secrets.yaml";
|
mysops.hostSecretFile = "${config.xdg.configHome}/home-manager/modules/hosts/soteria/secrets.yaml";
|
||||||
|
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
flake.homeConfigurations."${hostname}" = inputs.home-manager.lib.homeManagerConfiguration {
|
flake.homeConfigurations."${hostname}" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
+25
-112
@@ -1,131 +1,44 @@
|
|||||||
{ 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 = 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 "$@"'';
|
|
||||||
};
|
|
||||||
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 nfsu ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
flake.modules.homeManager.rebuild =
|
flake.modules.homeManager.rebuild =
|
||||||
{ config, pkgs, lib, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
let
|
|
||||||
flakeDir = config.homeManagerFlakeDir;
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
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.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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 echo "Home Manager flake directory: ${flakeDir}"
|
run echo "Home Manager flake directory: ${flakeDir}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
home-manager
|
home-manager
|
||||||
(symlinkJoin {
|
(writeShellScriptBin "flake-parts-test" ''
|
||||||
name = "build-tools";
|
echo "Test ${flakeDir}"
|
||||||
paths = [
|
'')
|
||||||
flake-parts-check
|
(writeShellScriptBin "flake-parts-check" ''
|
||||||
nhms
|
cd ${flakeDir}
|
||||||
nhmu
|
${nixBin} run ".#write-flake"
|
||||||
test-build
|
${nixBin} flake check
|
||||||
cleanup
|
'')
|
||||||
];
|
(writeShellScriptBin "nhms" ''
|
||||||
})
|
HOSTNAME=$(hostname -s)
|
||||||
|
echo "Switching to the $HOSTNAME profile"
|
||||||
|
${lib.getExe home-manager} switch --impure --flake ${flakeDir}#$HOSTNAME
|
||||||
|
'')
|
||||||
|
(writeShellScriptBin "nhmu" ''
|
||||||
|
${nixBin} flake update --flake ${flakeDir}
|
||||||
|
nhms
|
||||||
|
'')
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+24
-23
@@ -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}"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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,56 +1,44 @@
|
|||||||
{ inputs, ... }: {
|
{ inputs, ... }: {
|
||||||
flake.modules.nixos.login-text = { config, lib, ... }:
|
flake.modules.nixos.login-text = { config, ... }: {
|
||||||
let
|
programs.rust-motd = {
|
||||||
defaultServiceStatus = {
|
enable = true;
|
||||||
SSH = "sshd.socket";
|
refreshInterval = "*:0/5";
|
||||||
"SSH Cert Renewal" = "step-ssh-host-renew.timer";
|
order = [
|
||||||
};
|
"global"
|
||||||
in {
|
"last_login"
|
||||||
options.loginText.extraServiceStatus = lib.mkOption {
|
"service_status"
|
||||||
type = lib.types.attrsOf lib.types.str;
|
# "uptime"
|
||||||
default = { };
|
"memory"
|
||||||
description = "Additional rust-motd service status entries keyed by display name.";
|
"filesystems"
|
||||||
};
|
];
|
||||||
|
settings = {
|
||||||
|
global = {
|
||||||
|
time_format = "%Y-%m-%d %H:%M:%S %Z";
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
last_login = {
|
||||||
programs.rust-motd = {
|
john = 3;
|
||||||
enable = true;
|
root = 3;
|
||||||
refreshInterval = "*:0/5";
|
};
|
||||||
order = [
|
|
||||||
"global"
|
|
||||||
"last_login"
|
|
||||||
"service_status"
|
|
||||||
# "uptime"
|
|
||||||
"memory"
|
|
||||||
"filesystems"
|
|
||||||
];
|
|
||||||
settings = {
|
|
||||||
global = {
|
|
||||||
time_format = "%Y-%m-%d %H:%M:%S %Z";
|
|
||||||
};
|
|
||||||
|
|
||||||
last_login = {
|
service_status = {
|
||||||
john = 3;
|
Docker = "docker";
|
||||||
root = 3;
|
SSH = "sshd.socket";
|
||||||
};
|
"SSH Cert Renewal" = "step-ssh-host-renew.timer";
|
||||||
|
"mTLS Renewal" = "mtls-renew.timer";
|
||||||
|
};
|
||||||
|
|
||||||
service_status = lib.mkMerge [
|
# This calculation is wrong for LXCs
|
||||||
defaultServiceStatus
|
# uptime = {
|
||||||
config.loginText.extraServiceStatus
|
# prefix = "Uptime";
|
||||||
];
|
# };
|
||||||
|
|
||||||
# This calculation is wrong for LXCs
|
memory = {
|
||||||
# uptime = {
|
swap_pos = "beside";
|
||||||
# prefix = "Uptime";
|
};
|
||||||
# };
|
|
||||||
|
|
||||||
memory = {
|
filesystems = {
|
||||||
swap_pos = "beside";
|
root = "/";
|
||||||
};
|
|
||||||
|
|
||||||
filesystems = {
|
|
||||||
root = "/";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,14 @@
|
|||||||
{ self, inputs, ... }:
|
{ inputs, pkgs, lib, ... }:
|
||||||
{
|
{
|
||||||
flake.modules.homeManager.eza = { config, pkgs, lib, ... }: {
|
flake.modules.homeManager.eza = { pkgs, lib, ... }: {
|
||||||
programs.eza = {
|
programs.eza = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
package = pkgs.eza;
|
||||||
enableBashIntegration = true;
|
enableBashIntegration = true;
|
||||||
enableZshIntegration = true;
|
enableZshIntegration = true;
|
||||||
git = true;
|
};
|
||||||
icons = "auto";
|
home.shellAliases = {
|
||||||
colors = "auto";
|
ls = "${lib.getExe pkgs.eza} -lgos type --no-time --follow-symlinks";
|
||||||
extraOptions = [
|
|
||||||
"--all"
|
|
||||||
"--long"
|
|
||||||
"--group-directories-first"
|
|
||||||
"--sort=type"
|
|
||||||
"--dereference"
|
|
||||||
"--octal-permissions"
|
|
||||||
"--smart-group"
|
|
||||||
"--no-time"
|
|
||||||
"--git"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,25 +1,15 @@
|
|||||||
{
|
{
|
||||||
flake.modules.homeManager.files = { pkgs, lib, ... }:
|
flake.modules.homeManager.files = { pkgs, ... }:
|
||||||
{
|
{
|
||||||
programs.lf = {
|
programs.lf.enable = true;
|
||||||
enable = true;
|
programs.lf.cmdKeybindings = {
|
||||||
cmdKeybindings = {
|
"D" = "delete";
|
||||||
"D" = "delete";
|
|
||||||
};
|
|
||||||
settings = {
|
|
||||||
preview = true;
|
|
||||||
hidden = true;
|
|
||||||
drawbox = true;
|
|
||||||
icons = true;
|
|
||||||
ignorecase = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
gdu
|
gdu
|
||||||
# (writeShellScriptBin "lfcd" ''
|
lf
|
||||||
# . <(${lib.getExe pkgs.lf} -print-last-dir | sed 's/^/cd /')
|
# TODO: find a CLI file editor that's not insane
|
||||||
# '')
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -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";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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";
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
{ self, inputs, ... }: {
|
{ 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, ... }: {
|
flake.modules.nixos.niri = { pkgs, lib, ... }: {
|
||||||
programs.niri = {
|
programs.niri = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
{ self, inputs, ... }: {
|
{ self, inputs, ... }: {
|
||||||
flake.modules.homeManager.onepassword = { config, ... }: {
|
flake.modules.homeManager.onepassword = { config, pkgs, lib, ... }: {
|
||||||
home.file.".config/1Password/ssh/agent.toml".text = ''
|
home.file.".config/1Password/ssh/agent.toml".text = ''
|
||||||
# https://developer.1password.com/docs/ssh/agent/config
|
# https://developer.1password.com/docs/ssh/agent/config
|
||||||
[[ssh-keys]]
|
[[ssh-keys]]
|
||||||
vault = "Private"
|
vault = "Private"
|
||||||
'';
|
'';
|
||||||
programs.ssh.matchBlocks."*".identityAgent = "${config.home.homeDirectory}/.1password/agent.sock";
|
programs.ssh = {
|
||||||
|
enable = true;
|
||||||
|
extraConfig = ''
|
||||||
|
Host *
|
||||||
|
IdentityAgent ${config.home.homeDirectory}/.1password/agent.sock
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
home.shell.enableShellIntegration = true;
|
home.shell.enableShellIntegration = true;
|
||||||
programs.zsh.enable = lib.mkForce (config.shell.program == "zsh");
|
programs.zsh.enable = lib.mkForce (config.shell.program == "zsh");
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
nh
|
|
||||||
nvd
|
|
||||||
nix-output-monitor
|
|
||||||
wget
|
wget
|
||||||
curl
|
curl
|
||||||
busybox
|
busybox
|
||||||
@@ -34,7 +31,6 @@
|
|||||||
xclip
|
xclip
|
||||||
jq
|
jq
|
||||||
ripgrep
|
ripgrep
|
||||||
(writeShellScriptBin "ds" ''${lib.getExe pkgs.gdu} -x -I /snap /'')
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
+11
-20
@@ -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}" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{ self, inputs, ... }: {
|
{ self, inputs, ... }: {
|
||||||
flake.modules.nixos.steam = {
|
flake.modules.nixos.steam = {
|
||||||
|
progams.gamemode.enable = true;
|
||||||
programs.steam = {
|
programs.steam = {
|
||||||
enable = true;
|
enable = true;
|
||||||
gamescopeSession.enable = true;
|
gamescopeSession.enable = true;
|
||||||
|
|||||||
@@ -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"
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,10 +21,9 @@
|
|||||||
service = "${serviceName}.service";
|
service = "${serviceName}.service";
|
||||||
in
|
in
|
||||||
pkgs.writeShellScriptBin "wg-disconnect-${interface}" ''
|
pkgs.writeShellScriptBin "wg-disconnect-${interface}" ''
|
||||||
STOPTIME=$(${lib.getExe' pkgs.coreutils "date"} '+%Y-%m-%d %H:%M:%S')
|
|
||||||
${systemctl} stop ${service}
|
${systemctl} stop ${service}
|
||||||
start_time=$(${systemctl} show -p ActiveEnterTimestamp ${serviceName} | cut -d= -f2)
|
start_time=$(${systemctl} show -p ActiveEnterTimestamp ${serviceName} | cut -d= -f2)
|
||||||
${journalctl} -u ${service} --since "$STOPTIME" --no-pager
|
${journalctl} -u ${service} --since "$start_time" --no-pager
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-135
@@ -1,4 +1,4 @@
|
|||||||
{ self, inputs, ... }:
|
{ inputs, ... }:
|
||||||
let
|
let
|
||||||
username = "john";
|
username = "john";
|
||||||
in
|
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";
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -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 = {
|
||||||
+50
-69
@@ -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,33 +109,27 @@ 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";
|
user = "john";
|
||||||
|
|
||||||
|
compression = false;
|
||||||
|
serverAliveInterval = 0;
|
||||||
|
serverAliveCountMax = 3;
|
||||||
|
|
||||||
|
identitiesOnly = true;
|
||||||
|
inherit identityFile certificateFile;
|
||||||
|
|
||||||
|
hashKnownHosts = false;
|
||||||
|
userKnownHostsFile = cfg.knownHostsFile;
|
||||||
|
|
||||||
|
addKeysToAgent = "yes";
|
||||||
|
forwardAgent = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
"*" = lib.mkMerge [
|
|
||||||
{
|
|
||||||
user = "john";
|
|
||||||
|
|
||||||
compression = false;
|
|
||||||
serverAliveInterval = 0;
|
|
||||||
serverAliveCountMax = 3;
|
|
||||||
|
|
||||||
identitiesOnly = true;
|
|
||||||
inherit identityFile;
|
|
||||||
|
|
||||||
hashKnownHosts = false;
|
|
||||||
userKnownHostsFile = cfg.knownHostsFile;
|
|
||||||
|
|
||||||
addKeysToAgent = "yes";
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,303 @@
|
|||||||
|
{ inputs, lib, ... }:
|
||||||
|
let
|
||||||
|
# Options that will be in common between
|
||||||
|
opts = {
|
||||||
|
enable = lib.mkEnableOption "Enable mTLS";
|
||||||
|
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.";
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
keyFilename = lib.mkOption {
|
||||||
|
description = "String filename for the private key";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "key.pem";
|
||||||
|
};
|
||||||
|
certFilename = lib.mkOption {
|
||||||
|
description = "String filename for the public certificate";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "cert.pem";
|
||||||
|
};
|
||||||
|
bundleFilename = lib.mkOption {
|
||||||
|
description = "String filename for the mTLS key bundle";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "mtls.pem";
|
||||||
|
};
|
||||||
|
san = lib.mkOption {
|
||||||
|
description = "List of SAN to give the mTLS cert";
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
provisioner = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "admin";
|
||||||
|
};
|
||||||
|
lifetime = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "6h";
|
||||||
|
};
|
||||||
|
renew = {
|
||||||
|
enable = lib.mkOption {
|
||||||
|
description = "Enable automatic mTLS certificate renewal using a systemd timer.";
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
onCalendar = lib.mkOption {
|
||||||
|
description = "systemd OnCalendar schedule for mTLS certificate renewal checks.";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "*:1/15";
|
||||||
|
};
|
||||||
|
randomizedDelaySec = lib.mkOption {
|
||||||
|
description = "Randomized delay added to renewal timer runs to avoid synchronized renewals.";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "5m";
|
||||||
|
};
|
||||||
|
user = lib.mkOption {
|
||||||
|
description = "User account to run the mTLS renewal service as.";
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "root";
|
||||||
|
};
|
||||||
|
group = lib.mkOption {
|
||||||
|
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 = null;
|
||||||
|
};
|
||||||
|
reloadUnits = lib.mkOption {
|
||||||
|
description = "systemd units to try-reload-or-restart after a successful certificate renewal.";
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
postCommands = lib.mkOption {
|
||||||
|
description = "Shell commands to run after a successful certificate renewal.";
|
||||||
|
type = lib.types.listOf lib.types.lines;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkMtlsRenewScript = {
|
||||||
|
pkgs,
|
||||||
|
tlsCert,
|
||||||
|
tlsKey,
|
||||||
|
mtlsBundle,
|
||||||
|
reloadUnits ? [ ],
|
||||||
|
postCommands ? [ ],
|
||||||
|
systemctlArgs ? [ ],
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
systemctl = lib.getExe' pkgs.systemd "systemctl";
|
||||||
|
escapedArgs = lib.escapeShellArgs systemctlArgs;
|
||||||
|
systemctlCommand = "${systemctl} ${escapedArgs}";
|
||||||
|
renewReloadScript = lib.concatMapStringsSep "\n" (unit: ''
|
||||||
|
if ${systemctlCommand} --quiet is-active "${unit}"; then
|
||||||
|
${systemctlCommand} try-reload-or-restart "${unit}"
|
||||||
|
fi
|
||||||
|
'') reloadUnits;
|
||||||
|
renewPostCommands = lib.concatStringsSep "\n" postCommands;
|
||||||
|
in
|
||||||
|
pkgs.writeShellScriptBin "mtls-renew" ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if ${lib.getExe pkgs.step-cli} certificate needs-renewal "${tlsCert}"; then
|
||||||
|
echo "Renewing mTLS certificate"
|
||||||
|
else
|
||||||
|
echo "Skipping renew"
|
||||||
|
exit "$?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
${lib.getExe pkgs.step-cli} ca renew --force "${tlsCert}" "${tlsKey}"
|
||||||
|
|
||||||
|
umask 077
|
||||||
|
${lib.getExe' pkgs.coreutils "cat"} "${tlsCert}" "${tlsKey}" > "${mtlsBundle}"
|
||||||
|
|
||||||
|
echo "Reloading units:"
|
||||||
|
${renewReloadScript}
|
||||||
|
|
||||||
|
echo "Post commands:"
|
||||||
|
${renewPostCommands}
|
||||||
|
'';
|
||||||
|
|
||||||
|
mkNixosMtlsRenewService = {
|
||||||
|
pkgs,
|
||||||
|
tlsCert,
|
||||||
|
tlsKey,
|
||||||
|
mtlsBundle,
|
||||||
|
reloadUnits ? [ ],
|
||||||
|
postCommands ? [ ],
|
||||||
|
user ? "root",
|
||||||
|
group ? null,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
serviceGroup = if group == null then user else group;
|
||||||
|
renewScript = mkMtlsRenewScript {
|
||||||
|
inherit pkgs tlsCert tlsKey mtlsBundle reloadUnits postCommands;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
description = "Renew the mTLS certificate when Smallstep marks it ready";
|
||||||
|
wantedBy = [ ];
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = user;
|
||||||
|
Group = serviceGroup;
|
||||||
|
ExecStart = lib.getExe renewScript;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkNixosMtlsRenewTimer = {
|
||||||
|
onCalendar,
|
||||||
|
randomizedDelaySec,
|
||||||
|
unit ? "mtls-renew.service",
|
||||||
|
}: {
|
||||||
|
description = "Periodic Smallstep renewal for the mTLS certificate";
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
Persistent = true;
|
||||||
|
OnCalendar = onCalendar;
|
||||||
|
AccuracySec = "1us";
|
||||||
|
RandomizedDelaySec = randomizedDelaySec;
|
||||||
|
Unit = unit;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkHomeManagerMtlsRenewService = {
|
||||||
|
pkgs,
|
||||||
|
tlsCert,
|
||||||
|
tlsKey,
|
||||||
|
mtlsBundle,
|
||||||
|
reloadUnits ? [ ],
|
||||||
|
postCommands ? [ ],
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
renewScript = mkMtlsRenewScript {
|
||||||
|
inherit pkgs tlsCert tlsKey mtlsBundle reloadUnits postCommands;
|
||||||
|
systemctlArgs = [ "--user" ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
Unit = {
|
||||||
|
Description = "Renew the mTLS certificate when Smallstep marks it ready";
|
||||||
|
After = [ "network-online.target" ];
|
||||||
|
Wants = [ "network-online.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = lib.getExe renewScript;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkHomeManagerMtlsRenewTimer = {
|
||||||
|
onCalendar,
|
||||||
|
randomizedDelaySec,
|
||||||
|
unit ? "mtls-renew.service",
|
||||||
|
}: {
|
||||||
|
Unit = {
|
||||||
|
Description = "Periodic Smallstep renewal for the mTLS certificate";
|
||||||
|
};
|
||||||
|
Timer = {
|
||||||
|
Persistent = true;
|
||||||
|
OnCalendar = onCalendar;
|
||||||
|
AccuracySec = "1us";
|
||||||
|
RandomizedDelaySec = randomizedDelaySec;
|
||||||
|
Unit = unit;
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "timers.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
flake.modules.nixos.mtls = { config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
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;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.mtls = opts;
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
environment.systemPackages = with pkgs; lib.optionals cfg.enable [
|
||||||
|
(writeShellScriptBin "mtls-generate" ''
|
||||||
|
set -euo pipefail
|
||||||
|
${lib.getExe pkgs.step-cli} ca certificate \
|
||||||
|
${cfg.subject} ${tlsCert} ${tlsKey} \
|
||||||
|
--provisioner ${cfg.provisioner} \
|
||||||
|
--not-before=-5m --not-after=${cfg.lifetime} \
|
||||||
|
${sanArgs} \
|
||||||
|
"$@"
|
||||||
|
cat ${tlsCert} ${tlsKey} > ${mtlsBundle}
|
||||||
|
'')
|
||||||
|
(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 {
|
||||||
|
inherit pkgs tlsCert tlsKey mtlsBundle;
|
||||||
|
inherit (cfg.renew) reloadUnits postCommands user group;
|
||||||
|
});
|
||||||
|
|
||||||
|
systemd.timers.mtls-renew = lib.mkIf cfg.renew.enable (mkNixosMtlsRenewTimer {
|
||||||
|
inherit (cfg.renew) onCalendar randomizedDelaySec;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
flake.modules.homeManager.mtls = { config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.mtls;
|
||||||
|
tlsKey = "${cfg.certDir}/${cfg.keyFilename}";
|
||||||
|
tlsCert = "${cfg.certDir}/${cfg.certFilename}";
|
||||||
|
mtlsBundle = "${cfg.certDir}/${cfg.bundleFilename}";
|
||||||
|
sanArgs = lib.concatMapStringsSep " " (san: "--san \"${san}\"") cfg.san;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.mtls = opts // {
|
||||||
|
certDir = lib.mkOption {
|
||||||
|
description = "String path to where the mtls certs will be stored.";
|
||||||
|
type = lib.types.str;
|
||||||
|
default ="${config.home.homeDirectory}/.step/certs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
home.packages = with pkgs; lib.optionals cfg.enable [
|
||||||
|
step-cli
|
||||||
|
(writeShellScriptBin "mtls-generate" ''
|
||||||
|
set -euo pipefail
|
||||||
|
${lib.getExe pkgs.step-cli} ca certificate \
|
||||||
|
${cfg.subject} ${tlsCert} ${tlsKey} \
|
||||||
|
--not-before=-5m --not-after=${cfg.lifetime} \
|
||||||
|
--provisioner ${cfg.provisioner} \
|
||||||
|
${sanArgs} \
|
||||||
|
"$@"
|
||||||
|
cat ${tlsCert} ${tlsKey} > ${mtlsBundle}
|
||||||
|
'')
|
||||||
|
(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 {
|
||||||
|
inherit pkgs tlsCert tlsKey mtlsBundle;
|
||||||
|
inherit (cfg.renew) reloadUnits postCommands;
|
||||||
|
});
|
||||||
|
|
||||||
|
systemd.user.timers.mtls-renew = lib.mkIf cfg.renew.enable (mkHomeManagerMtlsRenewTimer {
|
||||||
|
inherit (cfg.renew) onCalendar randomizedDelaySec;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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";
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ in
|
|||||||
crt = "";
|
crt = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [ step-ca step-cli ];
|
||||||
step-ca
|
|
||||||
step-cli
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+21
-22
@@ -1,48 +1,47 @@
|
|||||||
{ self, inputs, lib, ... }:
|
{ inputs, ... }:
|
||||||
let
|
let
|
||||||
username = "john";
|
username = "john";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.meta.users."${username}" = {
|
flake = {
|
||||||
email = "32917998+jsl12@users.noreply.github.com";
|
meta.users."${username}" = {
|
||||||
name = "John Lancaster";
|
email = "32917998+jsl12@users.noreply.github.com";
|
||||||
inherit username;
|
name = "John Lancaster";
|
||||||
key = "";
|
username = "${username}";
|
||||||
keygrip = [
|
key = "";
|
||||||
];
|
keygrip = [
|
||||||
authorizedKeys = [
|
];
|
||||||
# "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIAUa4dcg1TWc4pW++uodyhX4eOqrX/QYIxFWtEP7HFJ john@john-pc-ubuntu"
|
authorizedKeys = [
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMOkGLo4N/L3RYvaIZ1FmePlxa1HK0fMciZxKtRhN58F root@janus"
|
# "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIAUa4dcg1TWc4pW++uodyhX4eOqrX/QYIxFWtEP7HFJ john@john-pc-ubuntu"
|
||||||
];
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMOkGLo4N/L3RYvaIZ1FmePlxa1HK0fMciZxKtRhN58F root@janus"
|
||||||
};
|
];
|
||||||
|
};
|
||||||
|
|
||||||
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.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
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
];
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user