Compare commits
9 Commits
1a1a85aeda
...
fcdb52cc42
| Author | SHA1 | Date | |
|---|---|---|---|
| fcdb52cc42 | |||
| b6500b97ff | |||
| 8f756554ad | |||
| 583b9ea5f3 | |||
| 6a30a431f8 | |||
| 38818e7508 | |||
| 94c64e9d33 | |||
| a9854ac144 | |||
| 8b109af08b |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,5 +9,4 @@ result-*
|
|||||||
|
|
||||||
nixos-efi-vars.fd
|
nixos-efi-vars.fd
|
||||||
|
|
||||||
.direnv/
|
/.pre-commit-config.yaml
|
||||||
.pre-commit-config.yaml
|
|
||||||
|
|||||||
@@ -8,25 +8,24 @@ let
|
|||||||
utils = import ../utils { inherit lib; };
|
utils = import ../utils { inherit lib; };
|
||||||
hostDirNames = utils.dirNames ../hosts;
|
hostDirNames = utils.dirNames ../hosts;
|
||||||
|
|
||||||
mkNode = hostname: tags: {
|
mkNode = hostname: meta: {
|
||||||
imports = [ ../hosts/${hostname} ];
|
imports = [ ../hosts/${hostname} ];
|
||||||
deployment = {
|
deployment = {
|
||||||
targetHost = self.nixosConfigurations.${hostname}.config.ssh.publicHostname;
|
inherit (meta.deployment) targetHost targetUser tags;
|
||||||
targetUser = self.nixosConfigurations.${hostname}.config.ssh.username;
|
buildOnTarget = builtins.any (t: t != "local" && t != "arm") meta.deployment.tags;
|
||||||
buildOnTarget = builtins.any (t: t != "local" && t != "arm") tags;
|
|
||||||
inherit tags;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = lib.genAttrs hostDirNames (
|
nodes = lib.genAttrs hostDirNames (hostname: mkNode hostname (utils.hostMeta ../hosts/${hostname}));
|
||||||
hostname: mkNode hostname (utils.hostMeta ../hosts/${hostname}).deployment.tags
|
|
||||||
);
|
|
||||||
|
|
||||||
in
|
in
|
||||||
inputs.colmena.lib.makeHive (
|
inputs.colmena.lib.makeHive (
|
||||||
{
|
{
|
||||||
meta = {
|
meta = {
|
||||||
nixpkgs = import inputs.nixpkgs { localSystem = "x86_64-linux"; };
|
nixpkgs = import inputs.nixpkgs {
|
||||||
|
localSystem = "x86_64-linux";
|
||||||
|
};
|
||||||
|
|
||||||
|
nodeNixpkgs = builtins.mapAttrs (_: v: v.pkgs) self.nixosConfigurations;
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs;
|
inherit inputs;
|
||||||
outputs = self;
|
outputs = self;
|
||||||
|
|||||||
24
flake.lock
generated
24
flake.lock
generated
@@ -121,11 +121,11 @@
|
|||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "pkgs/firefox-addons",
|
"dir": "pkgs/firefox-addons",
|
||||||
"lastModified": 1776657773,
|
"lastModified": 1776744173,
|
||||||
"narHash": "sha256-GgExKCDspgASVM6sRH0VcVyixQznxuR4tjiAA7MfKxs=",
|
"narHash": "sha256-9pZQWypgc0H1lgyuGmLqEL5IKVdHMw/NoO/iFcoSrW0=",
|
||||||
"owner": "rycee",
|
"owner": "rycee",
|
||||||
"repo": "nur-expressions",
|
"repo": "nur-expressions",
|
||||||
"rev": "986236cd6fad0979233ae5e73456a365f79ff198",
|
"rev": "a803876f3cfc65f8858d413cef2b7d10d50a81d7",
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -342,11 +342,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1776701552,
|
"lastModified": 1776777932,
|
||||||
"narHash": "sha256-CCRzOEFg6JwCdZIR5dLD0ypah5/e2JQVuWQ/l3rYrPY=",
|
"narHash": "sha256-0R3Yow/NzSeVGUke5tL7CCkqmss4Vmi6BbV6idHzq/8=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "c81775b640d4507339d127f5adb4105f6015edf2",
|
"rev": "5d5640599a0050b994330328b9fd45709c909720",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -398,10 +398,10 @@
|
|||||||
"nix-secrets": {
|
"nix-secrets": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1776716353,
|
"lastModified": 1776422417,
|
||||||
"narHash": "sha256-4gmunPEtk1oOK/77YP7M5N0rO9mSPYPrEZbELMKkZDE=",
|
"narHash": "sha256-9R4MePj/UT0tqkWEq4Afg7Lp/zdfYHkW+qmpVGchKIs=",
|
||||||
"ref": "main",
|
"ref": "main",
|
||||||
"rev": "13b5d656e0bef196f40d1be8581a97569f7a7eb9",
|
"rev": "75759a14e8d46421fca4306393a38b5ad5240f09",
|
||||||
"shallow": true,
|
"shallow": true,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://git@github.com/hektor/nix-secrets"
|
"url": "ssh://git@github.com/hektor/nix-secrets"
|
||||||
@@ -665,11 +665,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1776119890,
|
"lastModified": 1776771786,
|
||||||
"narHash": "sha256-Zm6bxLNnEOYuS/SzrAGsYuXSwk3cbkRQZY0fJnk8a5M=",
|
"narHash": "sha256-DRFGPfFV6hbrfO9a1PH1FkCi7qR5FgjSqsQGGvk1rdI=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "d4971dd58c6627bfee52a1ad4237637c0a2fb0cd",
|
"rev": "bef289e2248991f7afeb95965c82fbcd8ff72598",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
nixpkgs.lib.nixosSystem {
|
nixpkgs.lib.nixosSystem {
|
||||||
modules = [
|
modules = [
|
||||||
./hosts/${host}
|
./hosts/${host}
|
||||||
{ nixpkgs.hostPlatform = import ./hosts/${host}/system.nix; }
|
{ nixpkgs.hostPlatform = (myUtils.hostMeta ./hosts/${host}).system; }
|
||||||
];
|
];
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit
|
inherit
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
../../modules/nvim
|
../../modules/nvim
|
||||||
../../modules/pandoc
|
../../modules/pandoc
|
||||||
../../modules/photography
|
../../modules/photography
|
||||||
../../modules/secrets
|
|
||||||
../../modules/shell
|
../../modules/shell
|
||||||
../../modules/ssh
|
../../modules/ssh
|
||||||
../../modules/taskwarrior
|
../../modules/taskwarrior
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
|
||||||
username = "hektor";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.sops-nix.homeManagerModules.sops
|
inputs.sops-nix.homeManagerModules.sops
|
||||||
@@ -57,8 +54,8 @@ in
|
|||||||
|
|
||||||
home = {
|
home = {
|
||||||
stateVersion = "25.05";
|
stateVersion = "25.05";
|
||||||
inherit username;
|
username = "hektor";
|
||||||
homeDirectory = "/home/${username}";
|
homeDirectory = "/home/${config.home.username}";
|
||||||
};
|
};
|
||||||
|
|
||||||
targets.genericLinux.nixGL = {
|
targets.genericLinux.nixGL = {
|
||||||
|
|||||||
@@ -13,12 +13,10 @@ let
|
|||||||
standalone = osConfig == null;
|
standalone = osConfig == null;
|
||||||
in
|
in
|
||||||
lib.optionalAttrs standalone {
|
lib.optionalAttrs standalone {
|
||||||
sops.secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" null {
|
sops.secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" "anki" [
|
||||||
anki = [
|
"sync-user"
|
||||||
"sync-user"
|
"sync-key"
|
||||||
"sync-key"
|
] { };
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
// {
|
// {
|
||||||
warnings = lib.optional (
|
warnings = lib.optional (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
let
|
let
|
||||||
terminal = "kitty";
|
terminal = "kitty";
|
||||||
browser = config.browser.primary;
|
browser = config.browser.primary;
|
||||||
|
font = "${config.stylix.fonts.monospace.name} ${toString config.stylix.fonts.sizes.applications}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
dconf.settings = {
|
dconf.settings = {
|
||||||
@@ -40,9 +41,9 @@ in
|
|||||||
clock-show-weekday = true;
|
clock-show-weekday = true;
|
||||||
color-scheme = "prefer-dark";
|
color-scheme = "prefer-dark";
|
||||||
enable-hot-corners = false;
|
enable-hot-corners = false;
|
||||||
font-name = "Iosevka Term SS08 12";
|
font-name = font;
|
||||||
locate-pointer = true;
|
locate-pointer = true;
|
||||||
monospace-font-name = "Iosevka Term SS08 12";
|
monospace-font-name = font;
|
||||||
};
|
};
|
||||||
|
|
||||||
"org/gnome/desktop/wm/keybindings" = {
|
"org/gnome/desktop/wm/keybindings" = {
|
||||||
|
|||||||
@@ -6,25 +6,32 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
options.nixgl.wrap = lib.mkOption {
|
options = {
|
||||||
type = lib.types.functionTo lib.types.package;
|
host.username = lib.mkOption {
|
||||||
default = if config.lib ? nixGL then config.lib.nixGL.wrap else lib.id;
|
type = lib.types.str;
|
||||||
readOnly = true;
|
default = config.home.username;
|
||||||
};
|
};
|
||||||
|
|
||||||
options.wrapApp = lib.mkOption {
|
nixgl.wrap = lib.mkOption {
|
||||||
type = lib.types.raw;
|
type = lib.types.functionTo lib.types.package;
|
||||||
default =
|
default = if config.lib ? nixGL then config.lib.nixGL.wrap else lib.id;
|
||||||
pkg: flags:
|
readOnly = true;
|
||||||
if config.lib ? nixGL then
|
};
|
||||||
pkg.overrideAttrs (old: {
|
|
||||||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.makeWrapper ];
|
wrapApp = lib.mkOption {
|
||||||
postInstall = (old.postInstall or "") + ''
|
type = lib.types.raw;
|
||||||
wrapProgram $out/bin/${pkg.meta.mainProgram} --add-flags "${flags}"
|
default =
|
||||||
'';
|
pkg: flags:
|
||||||
})
|
if config.lib ? nixGL then
|
||||||
else
|
pkg.overrideAttrs (old: {
|
||||||
pkg;
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.makeWrapper ];
|
||||||
readOnly = true;
|
postInstall = (old.postInstall or "") + ''
|
||||||
|
wrapProgram $out/bin/${pkg.meta.mainProgram} --add-flags "${flags}"
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
else
|
||||||
|
pkg;
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
{
|
{
|
||||||
outputs,
|
myUtils,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
nixosConfigs = builtins.attrNames outputs.nixosConfigurations;
|
hostDir = ../../hosts;
|
||||||
homeConfigs = map (n: lib.last (lib.splitString "@" n)) (
|
hostNames = myUtils.dirNames hostDir;
|
||||||
builtins.attrNames outputs.homeConfigurations
|
|
||||||
);
|
|
||||||
allHosts = lib.unique (homeConfigs ++ nixosConfigs);
|
|
||||||
hostsWithKeys = lib.filter (
|
hostsWithKeys = lib.filter (
|
||||||
hostname: builtins.pathExists ../../hosts/${hostname}/ssh_host.pub
|
hostname: builtins.pathExists (hostDir + "/${hostname}/ssh_host.pub")
|
||||||
) allHosts;
|
) hostNames;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home.packages = with pkgs; [ sshfs ];
|
home.packages = with pkgs; [ sshfs ];
|
||||||
@@ -25,15 +22,14 @@ in
|
|||||||
lib.genAttrs hostsWithKeys (
|
lib.genAttrs hostsWithKeys (
|
||||||
hostname:
|
hostname:
|
||||||
let
|
let
|
||||||
hostConfig = outputs.nixosConfigurations.${hostname}.config;
|
meta = myUtils.hostMeta (hostDir + "/${hostname}");
|
||||||
inherit (hostConfig.ssh) publicHostname username;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
host = hostname;
|
host = hostname;
|
||||||
user = username;
|
user = meta.deployment.targetUser;
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (publicHostname != "") {
|
// lib.optionalAttrs (meta.deployment.targetHost != "") {
|
||||||
hostname = publicHostname;
|
hostname = meta.deployment.targetHost;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -25,21 +25,6 @@ in
|
|||||||
sansSerif = config.stylix.fonts.monospace;
|
sansSerif = config.stylix.fonts.monospace;
|
||||||
emoji = config.stylix.fonts.monospace;
|
emoji = config.stylix.fonts.monospace;
|
||||||
};
|
};
|
||||||
targets = {
|
targets = import ../../../modules/stylix/targets.nix;
|
||||||
firefox = {
|
|
||||||
profileNames = [ "default" ];
|
|
||||||
colorTheme.enable = true;
|
|
||||||
};
|
|
||||||
librewolf = {
|
|
||||||
profileNames = [ "default" ];
|
|
||||||
colorTheme.enable = true;
|
|
||||||
};
|
|
||||||
gnome.enable = false;
|
|
||||||
gtk.enable = false;
|
|
||||||
kitty = {
|
|
||||||
variant256Colors = true;
|
|
||||||
};
|
|
||||||
nixvim.enable = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,11 @@ let
|
|||||||
in
|
in
|
||||||
lib.optionalAttrs standalone {
|
lib.optionalAttrs standalone {
|
||||||
sops = {
|
sops = {
|
||||||
secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" null {
|
secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" "taskwarrior" [
|
||||||
taskwarrior = [
|
"sync-server-url"
|
||||||
"sync-server-url"
|
"sync-server-client-id"
|
||||||
"sync-server-client-id"
|
"sync-encryption-secret"
|
||||||
"sync-encryption-secret"
|
] { };
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
templates."taskrc.d/sync" = {
|
templates."taskrc.d/sync" = {
|
||||||
content = ''
|
content = ''
|
||||||
|
|||||||
@@ -51,32 +51,17 @@ in
|
|||||||
../../modules/yubikey
|
../../modules/yubikey
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.${config.host.username} = import ../../home/hosts/andromache {
|
home-manager.users.${config.host.username} = import ../../home/hosts/andromache;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
config
|
|
||||||
pkgs
|
|
||||||
lib
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
ssh.username = config.host.username;
|
|
||||||
ssh.authorizedHosts = [ "astyanax" ];
|
ssh.authorizedHosts = [ "astyanax" ];
|
||||||
|
|
||||||
secrets = {
|
secrets.nixSigningKey.enable = true;
|
||||||
inherit (config.host) username;
|
|
||||||
nixSigningKey.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
restic-backup.enable = true;
|
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
|
|
||||||
docker.user = config.host.username;
|
docker.enable = true;
|
||||||
|
|
||||||
hcloud = {
|
hcloud.enable = true;
|
||||||
enable = true;
|
|
||||||
inherit (config.host) username;
|
|
||||||
};
|
|
||||||
|
|
||||||
disko.devices = {
|
disko.devices = {
|
||||||
disk.data = {
|
disk.data = {
|
||||||
@@ -108,7 +93,6 @@ in
|
|||||||
|
|
||||||
my.yubikey = {
|
my.yubikey = {
|
||||||
enable = false;
|
enable = false;
|
||||||
inherit (config.host) username;
|
|
||||||
keys = [
|
keys = [
|
||||||
{
|
{
|
||||||
handle = "<KeyHandle1>";
|
handle = "<KeyHandle1>";
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
deployment.tags = [ "local" ];
|
system = "x86_64-linux";
|
||||||
|
deployment = {
|
||||||
|
tags = [ "local" ];
|
||||||
|
targetHost = "";
|
||||||
|
targetUser = "h";
|
||||||
|
};
|
||||||
role = "desktop";
|
role = "desktop";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"x86_64-linux"
|
|
||||||
@@ -47,27 +47,15 @@ in
|
|||||||
../../modules/yubikey
|
../../modules/yubikey
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.${config.host.username} = import ../../home/hosts/astyanax {
|
home-manager.users.${config.host.username} = import ../../home/hosts/astyanax;
|
||||||
inherit
|
|
||||||
inputs
|
|
||||||
config
|
|
||||||
pkgs
|
|
||||||
lib
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
ssh.username = config.host.username;
|
|
||||||
ssh.authorizedHosts = [ "andromache" ];
|
ssh.authorizedHosts = [ "andromache" ];
|
||||||
|
|
||||||
secrets = {
|
secrets.nixSigningKey.enable = true;
|
||||||
inherit (config.host) username;
|
|
||||||
nixSigningKey.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
restic-backup.enable = true;
|
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
docker.user = config.host.username;
|
docker.enable = true;
|
||||||
nfc.user = config.host.username;
|
nfc.enable = true;
|
||||||
desktop.ly.enable = true;
|
desktop.ly.enable = true;
|
||||||
audio.automation.enable = true;
|
audio.automation.enable = true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
deployment.tags = [ "local" ];
|
system = "x86_64-linux";
|
||||||
|
deployment = {
|
||||||
|
tags = [ "local" ];
|
||||||
|
targetHost = "";
|
||||||
|
targetUser = "h";
|
||||||
|
};
|
||||||
role = "laptop";
|
role = "laptop";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"x86_64-linux"
|
|
||||||
@@ -12,8 +12,6 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit (config.host) username;
|
|
||||||
publicHostname = config.host.name;
|
|
||||||
authorizedHosts = [
|
authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
deployment.tags = [ "arm" ];
|
system = "aarch64-linux";
|
||||||
|
deployment = {
|
||||||
|
tags = [ "arm" ];
|
||||||
|
targetHost = "eetion-02";
|
||||||
|
targetUser = "h";
|
||||||
|
};
|
||||||
role = "embedded";
|
role = "embedded";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"aarch64-linux"
|
|
||||||
@@ -9,15 +9,10 @@
|
|||||||
./host.nix
|
./host.nix
|
||||||
../../modules/common
|
../../modules/common
|
||||||
../../modules/ssh
|
../../modules/ssh
|
||||||
../../modules/tailscale
|
|
||||||
# ../../modules/uptime-kuma
|
# ../../modules/uptime-kuma
|
||||||
];
|
];
|
||||||
|
|
||||||
tailscale.enable = true;
|
|
||||||
|
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit (config.host) username;
|
|
||||||
publicHostname = config.host.name;
|
|
||||||
authorizedHosts = [
|
authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
deployment.tags = [ "arm" ];
|
system = "aarch64-linux";
|
||||||
|
deployment = {
|
||||||
|
tags = [ "arm" ];
|
||||||
|
targetHost = "eetion";
|
||||||
|
targetUser = "h";
|
||||||
|
};
|
||||||
role = "embedded";
|
role = "embedded";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"aarch64-linux"
|
|
||||||
@@ -19,15 +19,13 @@
|
|||||||
|
|
||||||
networking.hostName = config.host.name;
|
networking.hostName = config.host.name;
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit (config.host) username;
|
|
||||||
publicHostname = "server.hektormisplon.xyz";
|
|
||||||
authorizedHosts = [
|
authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
docker.user = config.host.username;
|
docker.enable = true;
|
||||||
|
|
||||||
fileSystems."/" = {
|
fileSystems."/" = {
|
||||||
device = "/dev/disk/by-label/nixos";
|
device = "/dev/disk/by-label/nixos";
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
deployment.tags = [ "cloud" ];
|
system = "x86_64-linux";
|
||||||
|
deployment = {
|
||||||
|
tags = [ "cloud" ];
|
||||||
|
targetHost = "server.hektormisplon.xyz";
|
||||||
|
targetUser = "username";
|
||||||
|
};
|
||||||
role = "server";
|
role = "server";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"x86_64-linux"
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
config,
|
config,
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
@@ -29,13 +28,7 @@
|
|||||||
../../modules/x
|
../../modules/x
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.${config.host.username} = import ../../home/hosts/vm {
|
home-manager.users.${config.host.username} = import ../../home/hosts/vm;
|
||||||
inherit inputs config pkgs;
|
|
||||||
};
|
|
||||||
|
|
||||||
ssh.username = config.host.username;
|
|
||||||
|
|
||||||
secrets.username = config.host.username;
|
|
||||||
|
|
||||||
disko = {
|
disko = {
|
||||||
devices.disk.main = {
|
devices.disk.main = {
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
deployment.tags = [ "local" ];
|
system = "x86_64-linux";
|
||||||
|
deployment = {
|
||||||
|
tags = [ "local" ];
|
||||||
|
targetHost = "";
|
||||||
|
targetUser = "h";
|
||||||
|
};
|
||||||
role = "vm";
|
role = "vm";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"x86_64-linux"
|
|
||||||
@@ -12,10 +12,15 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
../modules/common/host.nix
|
||||||
../modules/ssh
|
../modules/ssh
|
||||||
];
|
];
|
||||||
|
|
||||||
ssh.username = username;
|
host = {
|
||||||
|
inherit username;
|
||||||
|
name = "orange-pi";
|
||||||
|
};
|
||||||
|
|
||||||
ssh.authorizedHosts = [
|
ssh.authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
|
|||||||
@@ -12,10 +12,15 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
../modules/common/host.nix
|
||||||
../modules/ssh
|
../modules/ssh
|
||||||
];
|
];
|
||||||
|
|
||||||
ssh.username = username;
|
host = {
|
||||||
|
inherit username;
|
||||||
|
name = "raspberry-pi";
|
||||||
|
};
|
||||||
|
|
||||||
ssh.authorizedHosts = [
|
ssh.authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
{ config, ... }:
|
{ config, myUtils, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.secrets) username owner;
|
inherit (config.secrets) sopsDir;
|
||||||
|
inherit (config.host) username;
|
||||||
|
owner = config.users.users.${username}.name;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config.sops = {
|
||||||
secrets.groups.opencode = [ "api-key" ];
|
secrets = myUtils.mkSopsSecrets sopsDir "opencode" [ "api-key" ] { inherit owner; };
|
||||||
|
|
||||||
sops.templates."opencode/auth.json" = {
|
templates."opencode/auth.json" = {
|
||||||
inherit owner;
|
inherit owner;
|
||||||
path = "/home/${username}/.local/share/opencode/auth.json";
|
path = "/home/${username}/.local/share/opencode/auth.json";
|
||||||
content = ''
|
content = ''
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
|
{ config, myUtils, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (config.secrets) sopsDir;
|
||||||
|
inherit (config.host) username;
|
||||||
|
owner = config.users.users.${username}.name;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config.secrets.groups.anki = [
|
config.sops = {
|
||||||
"sync-user"
|
secrets = myUtils.mkSopsSecrets sopsDir "anki" [ "sync-user" "sync-key" ] { inherit owner; };
|
||||||
"sync-key"
|
};
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,57 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
|
myUtils,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.restic-backup;
|
cfg = config.restic-backup;
|
||||||
host = config.networking.hostName;
|
inherit (config.secrets) sopsDir;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.restic-backup = {
|
options = {
|
||||||
enable = lib.mkEnableOption "restic backups";
|
restic-backup = {
|
||||||
|
repository = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "b2:${config.sops.placeholder."backblaze-b2/bucket-name"}:${config.networking.hostName}";
|
||||||
|
};
|
||||||
|
|
||||||
passwordFile = lib.mkOption {
|
passwordFile = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = config.sops.secrets."restic/password".path;
|
default = config.sops.secrets."restic/password".path;
|
||||||
};
|
};
|
||||||
|
|
||||||
paths = lib.mkOption {
|
paths = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ "/home" ];
|
default = [ "/home" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = {
|
||||||
secrets.groups = {
|
sops = {
|
||||||
restic = [ "password" ];
|
secrets = lib.mkMerge [
|
||||||
backblaze-b2 = [
|
(myUtils.mkSopsSecrets sopsDir "restic" [ "password" ] { })
|
||||||
"bucket-name"
|
(myUtils.mkSopsSecrets sopsDir "backblaze-b2" [ "bucket-name" "account-id" "account-key" ] { })
|
||||||
"account-id"
|
|
||||||
"account-key"
|
|
||||||
];
|
];
|
||||||
};
|
templates = {
|
||||||
|
"restic/repo-${config.networking.hostName}" = {
|
||||||
sops.templates = {
|
content = "b2:${config.sops.placeholder."backblaze-b2/bucket-name"}:${config.networking.hostName}";
|
||||||
"restic/repo-${host}" = {
|
};
|
||||||
content = "b2:${config.sops.placeholder."backblaze-b2/bucket-name"}:${host}";
|
"restic/b2-env-${config.networking.hostName}" = {
|
||||||
};
|
content = ''
|
||||||
"restic/b2-env-${host}" = {
|
B2_ACCOUNT_ID=${config.sops.placeholder."backblaze-b2/account-id"}
|
||||||
content = ''
|
B2_ACCOUNT_KEY=${config.sops.placeholder."backblaze-b2/account-key"}
|
||||||
B2_ACCOUNT_ID=${config.sops.placeholder."backblaze-b2/account-id"}
|
'';
|
||||||
B2_ACCOUNT_KEY=${config.sops.placeholder."backblaze-b2/account-key"}
|
};
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.restic.backups.home = {
|
services.restic.backups.home = {
|
||||||
repositoryFile = config.sops.templates."restic/repo-${host}".path;
|
repositoryFile = config.sops.templates."restic/repo-${config.networking.hostName}".path;
|
||||||
inherit (cfg) passwordFile paths;
|
inherit (cfg) passwordFile;
|
||||||
|
inherit (cfg) paths;
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
OnCalendar = "daily";
|
OnCalendar = "daily";
|
||||||
Persistent = true;
|
Persistent = true;
|
||||||
@@ -60,7 +64,7 @@ in
|
|||||||
"--keep-monthly 6"
|
"--keep-monthly 6"
|
||||||
"--keep-yearly 1"
|
"--keep-yearly 1"
|
||||||
];
|
];
|
||||||
environmentFile = config.sops.templates."restic/b2-env-${host}".path;
|
environmentFile = config.sops.templates."restic/b2-env-${config.networking.hostName}".path;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ in
|
|||||||
myUtils
|
myUtils
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
sharedModules = [
|
||||||
|
{
|
||||||
|
host.username = lib.mkDefault config.host.username;
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,29 +2,17 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.docker;
|
cfg = config.docker;
|
||||||
|
inherit (config.host) username;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.docker = {
|
options.docker = {
|
||||||
|
enable = lib.mkEnableOption "docker";
|
||||||
rootless = lib.mkOption {
|
rootless = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
user = lib.mkOption {
|
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
config = lib.mkMerge [
|
config = lib.mkMerge [
|
||||||
{
|
|
||||||
warnings = lib.flatten [
|
|
||||||
(lib.optional (
|
|
||||||
cfg.rootless && cfg.user != null
|
|
||||||
) "'virtualisation.docker.user' is ignored when rootless mode is enabled")
|
|
||||||
(lib.optional (
|
|
||||||
!cfg.rootless && cfg.user == null
|
|
||||||
) "'virtualisation.docker.user' is not set (no user is added to the docker group)")
|
|
||||||
];
|
|
||||||
}
|
|
||||||
(lib.mkIf cfg.rootless {
|
(lib.mkIf cfg.rootless {
|
||||||
virtualisation.docker = {
|
virtualisation.docker = {
|
||||||
enable = false;
|
enable = false;
|
||||||
@@ -34,11 +22,9 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(lib.mkIf (!cfg.rootless && cfg.user != null) {
|
(lib.mkIf (cfg.enable && !cfg.rootless) {
|
||||||
virtualisation.docker = {
|
virtualisation.docker.enable = true;
|
||||||
enable = true;
|
users.users.${username}.extraGroups = [ "docker" ];
|
||||||
};
|
|
||||||
users.users.${cfg.user}.extraGroups = [ "docker" ];
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.secrets) username;
|
inherit (config.host) username;
|
||||||
owner = config.users.users.${username}.name;
|
owner = config.users.users.${username}.name;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
|
myUtils,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.hcloud;
|
cfg = config.hcloud;
|
||||||
inherit (config.secrets) owner;
|
inherit (config.host) username;
|
||||||
|
inherit (config.secrets) sopsDir;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.hcloud = {
|
options.hcloud = {
|
||||||
enable = lib.mkEnableOption "hcloud CLI configuration";
|
enable = lib.mkEnableOption "hcloud CLI configuration";
|
||||||
username = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
description = "username for hcloud CLI configuration";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
secrets.groups.hcloud = [ "api-token" ];
|
sops.secrets = myUtils.mkSopsSecrets sopsDir "hcloud" [ "api-token" ] {
|
||||||
|
owner = config.users.users.${username}.name;
|
||||||
|
};
|
||||||
|
|
||||||
sops.templates."hcloud/cli.toml" = {
|
sops.templates."hcloud/cli.toml" = {
|
||||||
inherit owner;
|
owner = config.users.users.${username}.name;
|
||||||
path = "/home/${cfg.username}/.config/hcloud/cli.toml";
|
path = "/home/${username}/.config/hcloud/cli.toml";
|
||||||
content = ''
|
content = ''
|
||||||
active_context = "server"
|
active_context = "server"
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,13 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.nfc;
|
cfg = config.nfc;
|
||||||
|
inherit (config.host) username;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.nfc = {
|
options.nfc = {
|
||||||
user = lib.mkOption {
|
enable = lib.mkEnableOption "NFC device access";
|
||||||
type = lib.types.nullOr lib.types.str;
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
config = lib.mkIf (cfg.user != null) {
|
config = lib.mkIf cfg.enable {
|
||||||
users.users.${cfg.user}.extraGroups = [ "dialout" ];
|
users.users.${username}.extraGroups = [ "dialout" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,64 +9,53 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.secrets;
|
cfg = config.secrets;
|
||||||
|
inherit (config.host) username;
|
||||||
inherit (cfg) sopsDir;
|
inherit (cfg) sopsDir;
|
||||||
owner = config.users.users.${cfg.username}.name;
|
owner = config.users.users.${username}.name;
|
||||||
|
mkSopsSecrets = myUtils.mkSopsSecrets sopsDir;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ inputs.sops-nix.nixosModules.sops ];
|
imports = [ inputs.sops-nix.nixosModules.sops ];
|
||||||
|
|
||||||
options.secrets = {
|
options = {
|
||||||
username = lib.mkOption {
|
secrets = {
|
||||||
type = lib.types.str;
|
sopsDir = lib.mkOption {
|
||||||
};
|
type = lib.types.str;
|
||||||
|
default = "${toString inputs.nix-secrets}/secrets";
|
||||||
|
};
|
||||||
|
|
||||||
sopsDir = lib.mkOption {
|
nixSigningKey = {
|
||||||
type = lib.types.str;
|
enable = lib.mkEnableOption "nix signing key configuration";
|
||||||
default = "${toString inputs.nix-secrets}/secrets";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
groups = lib.mkOption {
|
yubikey = {
|
||||||
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
|
enable = lib.mkEnableOption "set up Yubikey";
|
||||||
default = { };
|
};
|
||||||
description = "Declarative secret groups: { group = [ key names ]; }";
|
|
||||||
};
|
|
||||||
|
|
||||||
owner = lib.mkOption {
|
|
||||||
type = lib.types.unspecified;
|
|
||||||
};
|
|
||||||
|
|
||||||
nixSigningKey = {
|
|
||||||
enable = lib.mkEnableOption "nix signing key configuration";
|
|
||||||
};
|
|
||||||
|
|
||||||
yubikey = {
|
|
||||||
enable = lib.mkEnableOption "set up Yubikey";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
secrets = {
|
|
||||||
inherit owner;
|
|
||||||
groups = {
|
|
||||||
email = [
|
|
||||||
"personal"
|
|
||||||
"work"
|
|
||||||
];
|
|
||||||
nix = lib.optional cfg.nixSigningKey.enable "signing-key";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
sops = {
|
sops = {
|
||||||
# for yubikey, generate as follows:
|
# for yubikey, generate as follows:
|
||||||
# ```
|
# ```
|
||||||
# age-plugin-yubikey --identity > <keyfile-path>
|
# age-plugin-yubikey --identity > <keyfile-path>
|
||||||
# ```
|
# ```
|
||||||
age.keyFile = "/home/${cfg.username}/.config/sops/age/keys.txt";
|
age.keyFile = "/home/${username}/.config/sops/age/keys.txt";
|
||||||
secrets = myUtils.mkSopsSecrets sopsDir owner cfg.groups;
|
|
||||||
|
secrets = lib.mkMerge [
|
||||||
|
(mkSopsSecrets "email" [ "personal" "work" ] { inherit owner; })
|
||||||
|
(lib.mkIf cfg.nixSigningKey.enable {
|
||||||
|
nix-signing-key = {
|
||||||
|
sopsFile = "${sopsDir}/nix.yaml";
|
||||||
|
key = "signing-key";
|
||||||
|
inherit owner;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.settings.secret-key-files = lib.mkIf cfg.nixSigningKey.enable [
|
nix.settings.secret-key-files = lib.mkIf cfg.nixSigningKey.enable [
|
||||||
config.sops.secrets."nix/signing-key".path
|
config.sops.secrets.nix-signing-key.path
|
||||||
];
|
];
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (config.host) username;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
options.ssh = {
|
options.ssh = {
|
||||||
authorizedHosts = lib.mkOption {
|
authorizedHosts = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
};
|
};
|
||||||
username = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "h";
|
|
||||||
};
|
|
||||||
publicHostname = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# auto generate authorized_keys from `authorizedHosts`
|
# auto generate authorized_keys from `authorizedHosts`
|
||||||
config.users.users.${config.ssh.username}.openssh.authorizedKeys.keys = lib.flatten (
|
config.users.users.${username}.openssh.authorizedKeys.keys = lib.flatten (
|
||||||
map (
|
map (
|
||||||
hostname:
|
hostname:
|
||||||
let
|
let
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (config.ssh) username;
|
inherit (config.host) username;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# auto extract SSH keys
|
# auto extract SSH keys
|
||||||
|
|||||||
@@ -30,20 +30,7 @@ in
|
|||||||
|
|
||||||
home-manager.sharedModules = [
|
home-manager.sharedModules = [
|
||||||
{
|
{
|
||||||
stylix.targets = {
|
stylix.targets = import ./targets.nix;
|
||||||
firefox = {
|
|
||||||
profileNames = [ "default" ];
|
|
||||||
colorTheme.enable = true;
|
|
||||||
};
|
|
||||||
librewolf = {
|
|
||||||
profileNames = [ "default" ];
|
|
||||||
colorTheme.enable = true;
|
|
||||||
};
|
|
||||||
kitty.variant256Colors = true;
|
|
||||||
gnome.enable = false;
|
|
||||||
gtk.enable = false;
|
|
||||||
nixvim.enable = false;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
14
modules/stylix/targets.nix
Normal file
14
modules/stylix/targets.nix
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
firefox = {
|
||||||
|
profileNames = [ "default" ];
|
||||||
|
colorTheme.enable = true;
|
||||||
|
};
|
||||||
|
librewolf = {
|
||||||
|
profileNames = [ "default" ];
|
||||||
|
colorTheme.enable = true;
|
||||||
|
};
|
||||||
|
kitty.variant256Colors = true;
|
||||||
|
gnome.enable = false;
|
||||||
|
gtk.enable = false;
|
||||||
|
nixvim.enable = false;
|
||||||
|
}
|
||||||
@@ -7,23 +7,18 @@
|
|||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.my.syncthing;
|
inherit (config.host) username;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.my.syncthing.username = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "h";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
users.groups.${cfg.username} = { };
|
users.groups.${username} = { };
|
||||||
users.users.${cfg.username}.extraGroups = [ cfg.username ];
|
users.users.${username}.extraGroups = [ username ];
|
||||||
|
|
||||||
services.syncthing = {
|
services.syncthing = {
|
||||||
enable = true;
|
enable = true;
|
||||||
user = cfg.username;
|
user = username;
|
||||||
group = cfg.username;
|
group = username;
|
||||||
configDir = "/home/${cfg.username}/.local/state/syncthing";
|
configDir = "/home/${username}/.local/state/syncthing";
|
||||||
openDefaultPorts = true;
|
openDefaultPorts = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
{ config, ... }:
|
{ config, myUtils, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (config.secrets) owner;
|
inherit (config.secrets) sopsDir;
|
||||||
|
inherit (config.host) username;
|
||||||
|
owner = config.users.users.${username}.name;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config.sops = {
|
||||||
secrets.groups.taskwarrior = [
|
secrets = myUtils.mkSopsSecrets sopsDir "taskwarrior" [
|
||||||
"sync-server-url"
|
"sync-server-url"
|
||||||
"sync-server-client-id"
|
"sync-server-client-id"
|
||||||
"sync-encryption-secret"
|
"sync-encryption-secret"
|
||||||
];
|
] { inherit owner; };
|
||||||
|
|
||||||
sops.templates."taskrc.d/sync" = {
|
templates."taskrc.d/sync" = {
|
||||||
inherit owner;
|
inherit owner;
|
||||||
content = ''
|
content = ''
|
||||||
sync.server.url=${config.sops.placeholder."taskwarrior/sync-server-url"}
|
sync.server.url=${config.sops.placeholder."taskwarrior/sync-server-url"}
|
||||||
|
|||||||
@@ -9,18 +9,14 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.my.yubikey;
|
cfg = config.my.yubikey;
|
||||||
|
inherit (config.host) username;
|
||||||
formatKey = key: ":${key.handle},${key.userKey},${key.coseType},${key.options}";
|
formatKey = key: ":${key.handle},${key.userKey},${key.coseType},${key.options}";
|
||||||
authfileContent = username: keys: username + lib.concatMapStrings formatKey keys;
|
authfileContent = u: keys: u + lib.concatMapStrings formatKey keys;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.my.yubikey = {
|
options.my.yubikey = {
|
||||||
enable = mkEnableOption "yubiKey U2F authentication";
|
enable = mkEnableOption "yubiKey U2F authentication";
|
||||||
|
|
||||||
username = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "h";
|
|
||||||
};
|
|
||||||
|
|
||||||
origin = mkOption {
|
origin = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "pam://yubi";
|
default = "pam://yubi";
|
||||||
@@ -61,7 +57,7 @@ in
|
|||||||
interactive = true;
|
interactive = true;
|
||||||
cue = true;
|
cue = true;
|
||||||
inherit (cfg) origin;
|
inherit (cfg) origin;
|
||||||
authfile = pkgs.writeText "u2f-mappings" (authfileContent cfg.username cfg.keys);
|
authfile = pkgs.writeText "u2f-mappings" (authfileContent username cfg.keys);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services = {
|
services = {
|
||||||
|
|||||||
@@ -1,12 +1,41 @@
|
|||||||
{ lib }:
|
{ lib }:
|
||||||
|
|
||||||
let
|
|
||||||
hosts = import ./hosts.nix;
|
|
||||||
secrets = import ./secrets.nix { inherit lib; };
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
dirNames =
|
dirNames =
|
||||||
path: builtins.attrNames (lib.filterAttrs (_: type: type == "directory") (builtins.readDir path));
|
path: builtins.attrNames (lib.filterAttrs (_: type: type == "directory") (builtins.readDir path));
|
||||||
|
|
||||||
|
hostMeta =
|
||||||
|
hostDir:
|
||||||
|
if builtins.pathExists (hostDir + "/meta.nix") then
|
||||||
|
import (hostDir + "/meta.nix")
|
||||||
|
else
|
||||||
|
throw "meta.nix required in ${hostDir}";
|
||||||
|
|
||||||
|
mkSopsSecrets =
|
||||||
|
sopsDir: group: names: extraOpts:
|
||||||
|
let
|
||||||
|
file = "${group}.yaml";
|
||||||
|
in
|
||||||
|
lib.foldl' lib.mergeAttrs { } (
|
||||||
|
map (name: {
|
||||||
|
"${group}/${name}" = {
|
||||||
|
sopsFile = "${sopsDir}/${file}";
|
||||||
|
key = name;
|
||||||
|
}
|
||||||
|
// extraOpts;
|
||||||
|
}) names
|
||||||
|
);
|
||||||
|
|
||||||
|
sopsAvailability =
|
||||||
|
config: osConfig:
|
||||||
|
let
|
||||||
|
osSopsAvailable = osConfig != null && osConfig ? sops && osConfig.sops ? secrets;
|
||||||
|
hmSopsAvailable = config ? sops && config.sops ? secrets;
|
||||||
|
preferOs = osSopsAvailable;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
available = osSopsAvailable || hmSopsAvailable;
|
||||||
|
secrets = if preferOs then osConfig.sops.secrets else config.sops.secrets;
|
||||||
|
templates = if preferOs then osConfig.sops.templates else config.sops.templates;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// hosts
|
|
||||||
// secrets
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
hostMeta =
|
|
||||||
hostDir:
|
|
||||||
if builtins.pathExists (hostDir + "/meta.nix") then
|
|
||||||
import (hostDir + "/meta.nix")
|
|
||||||
else
|
|
||||||
throw "meta.nix required in ${hostDir}";
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
{ lib }:
|
|
||||||
|
|
||||||
{
|
|
||||||
mkSopsSecrets =
|
|
||||||
sopsDir: owner: groups:
|
|
||||||
let
|
|
||||||
opts = lib.optionalAttrs (owner != null) { inherit owner; };
|
|
||||||
mkGroup =
|
|
||||||
group: names:
|
|
||||||
let
|
|
||||||
file = "${group}.yaml";
|
|
||||||
in
|
|
||||||
lib.foldl' lib.mergeAttrs { } (
|
|
||||||
map (name: {
|
|
||||||
"${group}/${name}" = {
|
|
||||||
sopsFile = "${sopsDir}/${file}";
|
|
||||||
key = name;
|
|
||||||
}
|
|
||||||
// opts;
|
|
||||||
}) names
|
|
||||||
);
|
|
||||||
in
|
|
||||||
lib.foldl' lib.mergeAttrs { } (lib.mapAttrsToList mkGroup groups);
|
|
||||||
|
|
||||||
sopsAvailability =
|
|
||||||
config: osConfig:
|
|
||||||
let
|
|
||||||
osSopsAvailable = osConfig != null && osConfig ? sops && osConfig.sops ? secrets;
|
|
||||||
hmSopsAvailable = config ? sops && config.sops ? secrets;
|
|
||||||
preferOs = osSopsAvailable;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
available = osSopsAvailable || hmSopsAvailable;
|
|
||||||
secrets = if preferOs then osConfig.sops.secrets else config.sops.secrets;
|
|
||||||
templates = if preferOs then osConfig.sops.templates else config.sops.templates;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user