feat(ssh/openssh): overhauling ssh and openssh modules
This commit is contained in:
@@ -20,11 +20,13 @@
|
|||||||
smodPath = "${self}/modules/system";
|
smodPath = "${self}/modules/system";
|
||||||
|
|
||||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||||
|
inherit (self) outputs;
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit
|
inherit
|
||||||
cLib
|
cLib
|
||||||
inputs
|
inputs
|
||||||
|
outputs
|
||||||
self
|
self
|
||||||
userConfig
|
userConfig
|
||||||
systemConfig
|
systemConfig
|
||||||
|
|||||||
1
hosts/kima/ssh_host_ed25519_key.pub
Normal file
1
hosts/kima/ssh_host_ed25519_key.pub
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJjoPdpiF8pjKN3ZEHeLEwVxoqwcCdzpVVlZkxJohFdg root@cnix
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
};
|
};
|
||||||
fish = {
|
fish = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
homeless.enable = true;
|
||||||
};
|
};
|
||||||
gamemode = {
|
gamemode = {
|
||||||
enable = false;
|
enable = false;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
};
|
};
|
||||||
fish = {
|
fish = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
homeless.enable = true;
|
||||||
};
|
};
|
||||||
gamemode = {
|
gamemode = {
|
||||||
enable = false;
|
enable = false;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ in
|
|||||||
];
|
];
|
||||||
shellAbbrs = {
|
shellAbbrs = {
|
||||||
extract = "extract.sh";
|
extract = "extract.sh";
|
||||||
nixcleanboot = "sudo nix run /home/$USER/.nix-config#cleanup-boot";
|
|
||||||
nixclean = "nh clean all --keep 3";
|
nixclean = "nh clean all --keep 3";
|
||||||
nixdev = "nix develop ~/.nix-config -c $SHELL";
|
nixdev = "nix develop ~/.nix-config -c $SHELL";
|
||||||
nixup = "nh os switch -H $hostname";
|
nixup = "nh os switch -H $hostname";
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
{
|
{
|
||||||
|
outputs,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
nixosConfigs = builtins.attrNames outputs.nixosConfigurations;
|
||||||
|
homeConfigs = map (n: lib.last (lib.splitString "@" n)) (
|
||||||
|
builtins.attrNames outputs.homeConfigurations
|
||||||
|
);
|
||||||
|
hostnames = lib.unique (homeConfigs ++ nixosConfigs);
|
||||||
|
|
||||||
inherit (lib) mkIf mkEnableOption;
|
inherit (lib) mkIf mkEnableOption;
|
||||||
cfg = config.home.programs.ssh;
|
cfg = config.home.programs.ssh;
|
||||||
in
|
in
|
||||||
@@ -13,8 +20,23 @@ in
|
|||||||
};
|
};
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.ssh = {
|
programs.ssh = {
|
||||||
enable = true;
|
matchBlocks = {
|
||||||
userKnownHostsFile = "~/.ssh/known_hosts";
|
net = {
|
||||||
|
host = lib.concatStringsSep " " (
|
||||||
|
lib.flatten (
|
||||||
|
map (host: [
|
||||||
|
host
|
||||||
|
"${host}.local"
|
||||||
|
]) hostnames
|
||||||
|
)
|
||||||
|
);
|
||||||
|
extraOptions.StreamLocalBindUnlink = "yes";
|
||||||
|
forwardAgent = true;
|
||||||
|
forwardX11 = true;
|
||||||
|
forwardX11Trusted = true;
|
||||||
|
setEnv.WAYLAND_DISPLAY = "wayland-waypipe";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,25 +7,26 @@
|
|||||||
let
|
let
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (pkgs) eza bat;
|
inherit (pkgs) eza bat;
|
||||||
inherit (lib) mkIf mkEnableOption;
|
inherit (lib) mkIf mkEnableOption mkMerge;
|
||||||
cfg = config.nixos.programs.fish;
|
cfg = config.nixos.programs.fish;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
nixos.programs.fish.enable = mkEnableOption "Enables fish shell";
|
nixos.programs.fish = {
|
||||||
|
enable = mkEnableOption "Enables fish shell";
|
||||||
|
homeless.enable = mkEnableOption "Enables features for homeless environments";
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable {
|
};
|
||||||
|
|
||||||
|
config = mkMerge [
|
||||||
|
(mkIf cfg.enable {
|
||||||
|
programs.fish.enable = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.homeless.enable {
|
||||||
programs.fish = {
|
programs.fish = {
|
||||||
enable = true;
|
|
||||||
# plugins = [
|
|
||||||
# {
|
|
||||||
# name = "hydro";
|
|
||||||
# src = pkgs.fishPlugins.hydro;
|
|
||||||
# }
|
|
||||||
# ];
|
|
||||||
shellAbbrs = {
|
shellAbbrs = {
|
||||||
extract = "extract.sh";
|
extract = "extract.sh";
|
||||||
nixcleanboot = "sudo nix run /home/$USER/.nix-config#cleanup-boot";
|
|
||||||
nixclean = "nh clean all --keep 3";
|
nixclean = "nh clean all --keep 3";
|
||||||
nixdev = "nix develop ~/.nix-config -c $SHELL";
|
nixdev = "nix develop ~/.nix-config -c $SHELL";
|
||||||
nixup = "nh os switch -H $hostname";
|
nixup = "nh os switch -H $hostname";
|
||||||
@@ -54,18 +55,6 @@ in
|
|||||||
# Clear screen and scrollback
|
# Clear screen and scrollback
|
||||||
clear = "printf '\\033[2J\\033[3J\\033[1;1H'";
|
clear = "printf '\\033[2J\\033[3J\\033[1;1H'";
|
||||||
};
|
};
|
||||||
# functions = {
|
|
||||||
# # Disable greeting
|
|
||||||
# fish_greeting = "";
|
|
||||||
# # Merge history when pressing up
|
|
||||||
# up-or-search = lib.readFile ./up-or-search.fish;
|
|
||||||
# # Check stuff in PATH
|
|
||||||
# nix-inspect =
|
|
||||||
# # fish
|
|
||||||
# ''
|
|
||||||
# set -s PATH | grep "PATH\[.*/nix/store" | cut -d '|' -f2 | grep -v -e "-man" -e "-terminfo" | perl -pe 's:^/nix/store/\w{32}-([^/]*)/bin$:\1:' | sort | uniq
|
|
||||||
# '';
|
|
||||||
# };
|
|
||||||
interactiveShellInit =
|
interactiveShellInit =
|
||||||
# fish
|
# fish
|
||||||
''
|
''
|
||||||
@@ -107,10 +96,8 @@ in
|
|||||||
set -x fish_pager_color_description yellow
|
set -x fish_pager_color_description yellow
|
||||||
set -x fish_pager_color_prefix 'white' '--bold' '--underline'
|
set -x fish_pager_color_prefix 'white' '--bold' '--underline'
|
||||||
set -x fish_pager_color_progress 'brwhite' '--background=cyan'
|
set -x fish_pager_color_progress 'brwhite' '--background=cyan'
|
||||||
|
|
||||||
microfetch
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
34
modules/nixos/programs/ssh/default.nix
Normal file
34
modules/nixos/programs/ssh/default.nix
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkIf mkEnableOption;
|
||||||
|
cfg = config.nixos.services.openssh;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
nixos.services.openssh = {
|
||||||
|
enable = mkEnableOption "Enables ssh";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
programs.ssh = {
|
||||||
|
knownHosts = {
|
||||||
|
publicKeyFile = /etc/ssh/ssh_host_ed25519_key.pub;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
AcceptEnv = "WAYLAND_DISPLAY";
|
||||||
|
GatewayPorts = "clientspecified";
|
||||||
|
PasswordAuthentication = false;
|
||||||
|
PermitRootLogin = "no";
|
||||||
|
StreamLocalBindUnlink = "yes";
|
||||||
|
X11Forwarding = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,19 +1,43 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
|
outputs,
|
||||||
lib,
|
lib,
|
||||||
|
self,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
hosts = lib.attrNames outputs.nixosConfigurations;
|
||||||
inherit (lib) mkIf mkEnableOption;
|
inherit (lib) mkIf mkEnableOption;
|
||||||
cfg = config.nixos.services.openssh;
|
cfg = config.nixos.services.openssh;
|
||||||
|
|
||||||
|
hostsWithKeys = builtins.filter (
|
||||||
|
hostname: builtins.pathExists "${self}/hosts/${hostname}/ssh_host_ed25519_key.pub"
|
||||||
|
) hosts;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
nixos.services.openssh.enable = mkEnableOption "Enables openssh";
|
nixos.services.openssh = {
|
||||||
|
enable = mkEnableOption "Enables openssh";
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
programs.ssh = {
|
||||||
|
knownHosts = lib.genAttrs hostsWithKeys (hostname: {
|
||||||
|
publicKeyFile = "${self}/hosts/${hostname}/ssh_host_ed25519_key.pub";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
AcceptEnv = "WAYLAND_DISPLAY";
|
||||||
|
GatewayPorts = "clientspecified";
|
||||||
|
PasswordAuthentication = false;
|
||||||
|
PermitRootLogin = "no";
|
||||||
|
StreamLocalBindUnlink = "yes";
|
||||||
|
X11Forwarding = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
fish = {
|
fish = {
|
||||||
enable = false;
|
enable = true;
|
||||||
};
|
};
|
||||||
foot = {
|
foot = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user