From 0f61cc5118f4b8243f95926630de17a84030702e Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Fri, 18 Apr 2025 09:20:15 +0800 Subject: [PATCH] feat: modify wsl config --- .sops.yaml | 2 ++ config/hosts/imxyy-nix-wsl/home.nix | 4 ++-- config/hosts/imxyy-nix-wsl/nixos.nix | 3 +++ modules/sops.nix | 28 +++++++++++++++++++--------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.sops.yaml b/.sops.yaml index d8e7406..111afcf 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -1,9 +1,11 @@ keys: - &imxyy-nix age1jf5pg2x6ta8amj40xdy0stvcvrdlkwc2nrwtmkpymu0qclk0eg5qmm9kns - &imxyy-nix-server age1hpgg6psejh4y6jcdd34wxuml75fnweqpe0kh8376yqsctsfn9qxs037kk6 + - &imxyy-cloudwin age1tp7th3rrv3x0l6jl76n0hjqjp223w2y586pkgr0hcjwdm254jd5shkj6a8 creation_rules: - path_regex: secrets/.*\.(yaml|toml|json|env|dae|txt)$ key_groups: - age: - *imxyy-nix - *imxyy-nix-server + - *imxyy-cloudwin diff --git a/config/hosts/imxyy-nix-wsl/home.nix b/config/hosts/imxyy-nix-wsl/home.nix index 1fcb4d0..a8b0e98 100644 --- a/config/hosts/imxyy-nix-wsl/home.nix +++ b/config/hosts/imxyy-nix-wsl/home.nix @@ -1,13 +1,13 @@ -{ ... }: +{ username, ... }: { my.home.programs.zsh.shellAliases = { localproxy_on = "export http_proxy=http://192.168.128.1:7890 https_proxy=http://192.168.128.1:7890 all_proxy=socks://192.168.128.1:7890"; }; my = { + sops.sshKeyPath = "/home/${username}/.ssh/id_ed25519"; coding.all.enable = true; cmd.misc.enable = true; xdg.enable = true; cmd.media.all.enable = true; - desktop.media.all.enable = true; }; } diff --git a/config/hosts/imxyy-nix-wsl/nixos.nix b/config/hosts/imxyy-nix-wsl/nixos.nix index b5db845..a6e4da3 100644 --- a/config/hosts/imxyy-nix-wsl/nixos.nix +++ b/config/hosts/imxyy-nix-wsl/nixos.nix @@ -14,4 +14,7 @@ PasswordAuthentication = true; }; }; + + # fix vscode remote + programs.nix-ld.enable = true; } diff --git a/modules/sops.nix b/modules/sops.nix index 675af73..eb9ea6b 100644 --- a/modules/sops.nix +++ b/modules/sops.nix @@ -1,24 +1,34 @@ { + lib, config, pkgs, - lib, username, ... }: -lib.my.makeSwitch { - inherit config; - default = true; - optionName = "sops secret settings"; - optionPath = [ "sops" ]; - config' = { +let + cfg = config.my.sops; +in +{ + options.my.sops = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + sshKeyPath = lib.mkOption { + type = lib.types.str; + default = "/persistent/home/${username}/.ssh/id_ed25519"; + }; + }; + + config = lib.mkIf cfg.enable { sops.age.sshKeyPaths = [ - "/persistent/home/${username}/.ssh/id_ed25519" + cfg.sshKeyPath ]; users.users.${username}.extraGroups = [ "keys" ]; environment.variables.SOPS_AGE_KEY_FILE = "/run/secrets.d/age-keys.txt"; my.home = { sops.age.sshKeyPaths = [ - "/persistent/home/${username}/.ssh/id_ed25519" + cfg.sshKeyPath ]; home.packages = [ pkgs.sops