reorg + condiational secrets

This commit is contained in:
2023-03-09 05:00:20 +00:00
parent 24ef309194
commit dea10b0752
23 changed files with 190 additions and 273 deletions

View File

@@ -13,17 +13,9 @@ in {
config = mkIf cfg.enable {
# xdg.configFile."beets/config.old".source = config.lib.file.mkOutOfStoreSymlink /run/user/1000/secrets/test;
# secrets.discogs_json = {
# mode = "0440";
# owner = config.users.users.sstent.name;
# group = config.users.users.sstent.group;
# };
sops = {
sops = {
secrets.discogs_json = {
path = "${config.xdg.configHome}/discogs_token.json";
# path = "${config.home.homeDirectory}/${getEnv_name}";
path = "${config.xdg.configHome}/beets/discogs_token.json";
};
};
programs.beets = {

View File

@@ -0,0 +1,30 @@
{ config, pkgs, inputs, lib, util, hostName, ... }:
with lib;
with lib.my;
let
cfg = config.custom.keybase;
username = config.home.username;
secretstore = config._secretstore;
in {
options.custom.keybase = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable KeyBase";
};
};
config = mkIf cfg.enable {
services.keybase.enable = true;
services.kbfs.enable = true;
systemd.user.services.keybase.Unit.After = [ "sops-nix.service" ];
systemd.user.services.kbfs.Unit.After = [ "sops-nix.service" ];
sops = {
secrets = hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/";
};
};
}

View File

@@ -0,0 +1,19 @@
{ lib, inputs, outputs, config, ... }:
with lib;
let cfg = config.custom.mnt_public;
in {
options.custom.mnt_public.enable = mkEnableOption "Enable mnt/Public";
config = mkIf cfg.enable {
fileSystems."/mnt/Public" = {
device = "//192.168.1.109/Public";
fsType = "cifs";
# options = ["uid=0,gid=1000"];
options = ["guest" "uid=1000"];
};
};
}

View File

@@ -0,0 +1,33 @@
{ lib, inputs, outputs, config, ... }:
with lib;
let cfg = config.custom.syncthing;
in {
options.custom.syncthing.enable = mkEnableOption "Enable mnt/Public";
config = mkIf cfg.enable {
services.syncthing = {
enable = true;
dataDir = "/home/sstent";
openDefaultPorts = true;
configDir = "/home/sstent/.config/syncthing";
user = "sstent";
group = "users";
guiAddress = "0.0.0.0:8385";
overrideDevices = true;
overrideFolders = true;
devices = {
"StuPC" = { id = "Z43MPGF-OKG6K34-WTTFUDO-UG6E3TE-YCLSOAT-5LN5KMW-QHL2VSK-EZCGCAP"; };
"go3" = { id = "YDOL433-AHAL33M-NWLLDDQ-2D36ZIE-YNZVTKE-25TRBZ2-JXRSN7Y-Z5EOVQN"; };
};
folders = {
"default" = {
path = "/home/sstent/sync";
devices = [ "StuPC" "go3" ];
};
};
};
};
}

View File

@@ -2,28 +2,28 @@
with lib;
let
cfg = config.custom.mullvad;
secretstore = config._secretstore;
host = config.networking.hostName;
cfg = config.custom.mullvad;
secret = if builtins.pathExists "${secretstore}/hosts/${host}/mullvad/device.json" then
./secrets.nix
else
{ };
in {
#define option to enable this
options.custom.mullvad.enable = mkEnableOption "Enable SSH";
# imports = [ secret ];
config = mkIf cfg.enable {
networking.wireguard.enable = true;
services.mullvad-vpn.enable = true;
sops.secrets.device_json = {
sopsFile = "${secretstore}/hosts/${host}/mullvad/device.json";
format = "binary";
};
environment.etc."mullvad-vpn/device.conf".source = config.sops.secrets.device_json.path;
# set some options after every daemon start
# set some options after every daemon start
# to avoid accidentally leaving unsafe settings
systemd.services."mullvad-daemon" = {
postStart = ''
@@ -33,42 +33,9 @@ in {
${pkgs.mullvad}/bin/mullvad relay set location ca mtr
'';
};
};
}
# secrets = hm_secrets "${secretstore}/user_dotfiles/${username}@${hostName}/keybase/" "${config.xdg.configHome}/keybase/";
#
# { config, pkgs, ... }:
# {
# age.secrets.mullvad.file = ../secrets/mullvad.age;
# networking.wireguard.enable = true;
# services.mullvad-vpn.enable = true;
# # set some options after every daemon start
# # to avoid accidentally leaving unsafe settings
# systemd.services."mullvad-daemon" = {
# serviceConfig.LoadCredential =
# [ "account:${config.age.secrets.mullvad.path}" ];
# postStart = ''
# while ! ${pkgs.mullvad}/bin/mullvad status >/dev/null; do sleep 1; done
# account="$(<"$CREDENTIALS_DIRECTORY/account")"
# current_account="$(${pkgs.mullvad}/bin/mullvad account get | grep "account:" | sed 's/.* //')"
# if [[ "$current_account" != "$account" ]]; then
# ${pkgs.mullvad}/bin/mullvad account login "$account"
# fi
# ${pkgs.mullvad}/bin/mullvad always-require-vpn set on
# ${pkgs.mullvad}/bin/mullvad dns set default \
# --block-ads --block-trackers --block-malware
# ${pkgs.mullvad}/bin/mullvad lan set allow
# ${pkgs.mullvad}/bin/mullvad tunnel ipv6 set on
# ${pkgs.mullvad}/bin/mullvad relay set tunnel-protocol wireguard
# ${pkgs.mullvad}/bin/mullvad relay set location de dus
# '';
# };
# }
}

View File

@@ -0,0 +1,23 @@
{ lib, pkgs, config, ... }:
with lib;
let
secretstore = config._secretstore;
host = config.networking.hostName;
secretpath = "${secretstore}/hosts/${host}/mullvad/device.json";
in {
sops.secrets.device_json= {
sopsFile = "${secretstore}/hosts/${host}/mullvad/device.json";
device_json.format = "binary";
};
environment.etc."mullvad-vpn/device.conf".source = config.sops.secrets.device_json.path;
}

View File

@@ -0,0 +1,51 @@
{ lib, inputs, outputs, config, pkgs, ... }:
with lib;
let cfg = config.custom.wsl;
in {
options.custom.wsl.enable = mkEnableOption "Enable WSL2 settings";
config = mkIf cfg.enable {
wsl = {
enable = true;
wslConf.automount.root = "/mnt";
defaultUser = "sstent";
startMenuLaunchers = true;
interop.preserveArgvZero = true;
nativeSystemd = true;
# Enable native Docker support
docker-native.enable = true;
# Enable integration with Docker Desktop (needs to be installed)
# docker-desktop.enable = true;
};
systemd.services.nixs-wsl-systemd-fix = {
description = "Fix the /dev/shm symlink to be a mount";
unitConfig = {
DefaultDependencies = "no";
Before = [
"sysinit.target"
"systemd-tmpfiles-setup-dev.service"
"systemd-tmpfiles-setup.service"
"systemd-sysctl.service"
];
ConditionPathExists = "/dev/shm";
ConditionPathIsSymbolicLink = "/dev/shm";
ConditionPathIsMountPoint = "/run/shm";
};
serviceConfig = {
Type = "oneshot";
ExecStart = [
"${pkgs.coreutils-full}/bin/rm /dev/shm"
"/run/wrappers/bin/mount --bind -o X-mount.mkdir /run/shm /dev/shm"
];
};
wantedBy = [ "sysinit.target" ];
};
};
}