From 93eab92cf1c11c449c6af69493c2f897e21b2f9c Mon Sep 17 00:00:00 2001 From: rocketcamel Date: Sat, 1 Feb 2025 23:55:50 +0000 Subject: [PATCH] better practice, lib.mkDefault, ssh --- .config/nvim/lazy-lock.json | 10 +++++----- nix/hosts/tux/configuration.nix | 5 ++--- nix/hosts/wsl-kumatani/configuration.nix | 5 ++++- nix/hosts/wsl-usahara/configuration.nix | 5 ++++- nix/modules/commonPackages.nix | 7 ++++--- nix/modules/default.nix | 1 + nix/modules/keys.nix | 20 ++++++++++++++++++++ 7 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 nix/modules/keys.nix diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 67a1e36..85eb01c 100755 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,12 +1,12 @@ { "conform.nvim": { "branch": "master", "commit": "363243c03102a531a8203311d4f2ae704c620d9b" }, "fidget.nvim": { "branch": "main", "commit": "a0abbf18084b77d28bc70e24752e4f4fd54aea17" }, - "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" }, + "lazy.nvim": { "branch": "main", "commit": "7527af40ddd4a93a02911be570b32609b9d4ea53" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f75e877f5266e87523eb5a18fcde2081820d087b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "12ebac8280869048c286d13bd35cfa6653e07642" }, - "nvim-lspconfig": { "branch": "master", "commit": "9962e25a23f0e992116b99a9a6400947d5a7177b" }, - "nvim-treesitter": { "branch": "master", "commit": "80c7af6d0408411ff1f502fbac8ca94b738b8762" }, + "mini.nvim": { "branch": "main", "commit": "034698a100e91fd5798b27c2927378eb5b06615a" }, + "nvim-lspconfig": { "branch": "master", "commit": "f98fa715acc975c2dd5fb5ba7ceddeb1cc725ad2" }, + "nvim-treesitter": { "branch": "master", "commit": "4988b7068001b3a772c7cc738708341e612e3c26" }, "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "rose-pine": { "branch": "main", "commit": "42f0724e0bca9f57f0bcfa688787c37b8d4befe8" }, "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" } diff --git a/nix/hosts/tux/configuration.nix b/nix/hosts/tux/configuration.nix index f4fc3ee..85c8ff1 100644 --- a/nix/hosts/tux/configuration.nix +++ b/nix/hosts/tux/configuration.nix @@ -89,7 +89,8 @@ isNormalUser = true; extraGroups = [ "wheel" ]; shell = pkgs.zsh; - hashedPassword = "$y$j9T$wp9I05TfxjrAzCMCcxlei1$Fm7sJJSwFHpSIQT0RESOdJ7vkTYyN0IXs5n/xkg65y3"; + hashedPassword = config.hashedPassword; + openssh.authorizedKeys.keys = config.authorized_ssh; }; environment.systemPackages = @@ -106,7 +107,5 @@ # enableSSHSupport = true; # }; - services.openssh.enable = true; - system.stateVersion = "24.11"; } diff --git a/nix/hosts/wsl-kumatani/configuration.nix b/nix/hosts/wsl-kumatani/configuration.nix index db06b28..0ca33be 100644 --- a/nix/hosts/wsl-kumatani/configuration.nix +++ b/nix/hosts/wsl-kumatani/configuration.nix @@ -17,7 +17,10 @@ wsl.defaultUser = "luca"; networking.hostName = meta.hostname; hm.enable = true; - users.users.luca.shell = pkgs.zsh; + users.users.luca = { + shell = pkgs.zsh; + openssh.authorizedKeys.keys = config.authorized_ssh; + }; environment.systemPackages = with pkgs; config.commonPackages ++ [ ]; diff --git a/nix/hosts/wsl-usahara/configuration.nix b/nix/hosts/wsl-usahara/configuration.nix index db06b28..0ca33be 100644 --- a/nix/hosts/wsl-usahara/configuration.nix +++ b/nix/hosts/wsl-usahara/configuration.nix @@ -17,7 +17,10 @@ wsl.defaultUser = "luca"; networking.hostName = meta.hostname; hm.enable = true; - users.users.luca.shell = pkgs.zsh; + users.users.luca = { + shell = pkgs.zsh; + openssh.authorizedKeys.keys = config.authorized_ssh; + }; environment.systemPackages = with pkgs; config.commonPackages ++ [ ]; diff --git a/nix/modules/commonPackages.nix b/nix/modules/commonPackages.nix index 71e5db0..88e0280 100644 --- a/nix/modules/commonPackages.nix +++ b/nix/modules/commonPackages.nix @@ -25,10 +25,11 @@ wireguard-tools fzf ]; - programs.nix-ld.enable = true; - programs.zsh.enable = true; + programs.nix-ld.enable = lib.mkDefault true; + programs.zsh.enable = lib.mkDefault true; + services.openssh.enable = lib.mkDefault true; - programs.neovim = { + programs.neovim = lib.mkDefault { enable = true; defaultEditor = true; vimAlias = true; diff --git a/nix/modules/default.nix b/nix/modules/default.nix index b2d40a8..38be5d8 100644 --- a/nix/modules/default.nix +++ b/nix/modules/default.nix @@ -11,5 +11,6 @@ ./i3.nix ./kanata.nix ./pipewire.nix + ./keys.nix ]; } diff --git a/nix/modules/keys.nix b/nix/modules/keys.nix new file mode 100644 index 0000000..d998fd2 --- /dev/null +++ b/nix/modules/keys.nix @@ -0,0 +1,20 @@ +{ + pkgs, + lib, + config, + ... +}: +{ + options = { + authorized_ssh = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDBIvu/oh6LiuRvrluMV1hStvgdg0x1KNWnNxlR26zer75z2dEQcyou54uTyqJ0hbQXRTaolD5GxAoCc0HdPMkXiZJYPyMl65mVxyFWreXgFNSAAx5z/3D7B23qGNOBcc8mIiDwcNL5gKCzm5kHlRp9XY+VMTc8i89Abj3eo3pubcw2P8u8kmNgkswHrcwTjCDP6MBVkE0LwoamhB/KrpnYJrqsoBcOljhlKh6w9EBGcZPYBA1tg555IywZ89B4Kty5/0ydaO3E/qpr8lXfVRrhA7JRzeuUfnkXJLJetmwLT28O5fn+swzwdMM3TUbtL73ncGaLHR0/cpeTSgVxAV9KLMJIhS9EULlz9Fk79nWZ0w+JHjzVbmwWXA9GABMr1OgfksqNhs/FDQeyMYTf8+o7lGKtl1eHmD3TuuENIAIrq3RvIY5Q8O4xpioWZA9mZ3bLkp1EBowT6z059iDoxTw0fRWmegEXpSvbleXH7So68W72YJo200IXcwfizfwTsPE= luca@DESKTOP-G36D6AR" + ]; + }; + hashedPassword = lib.mkOption { + type = lib.types.str; + default = "$y$j9T$wp9I05TfxjrAzCMCcxlei1$Fm7sJJSwFHpSIQT0RESOdJ7vkTYyN0IXs5n/xkg65y3"; + }; + }; +}