Modularize code

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-20 11:42:31 +03:00
parent 4e4fb9c86c
commit ea01ac7fe0
17 changed files with 440 additions and 374 deletions

View File

@@ -0,0 +1,22 @@
{ inputs, lib, ... }:
{
imports = [ inputs.impermanence.nixosModules.impermanence ];
fileSystems."/persist".neededForBoot = true;
boot.initrd.postDeviceCommands = lib.mkAfter (builtins.readFile ./impermanence.sh);
environment.persistence."/persist" = {
hideMounts = true;
directories = [
"/etc/nixos"
"/etc/NetworkManager/system-connections"
"/var/lib/nixos"
"/var/lib/systemd/coredump"
"/var/log"
];
files = [
"/etc/machine-id"
];
};
}

View File

@@ -1,5 +1,3 @@
#!/bin/sh
delete_subvolume_recursively() { delete_subvolume_recursively() {
IFS=$'\n' IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
@@ -17,7 +15,7 @@ if [[ -e /mnt/btrfs/root ]]; then
mv /mnt/btrfs/root "/mnt/btrfs/root.bak/$timestamp" mv /mnt/btrfs/root "/mnt/btrfs/root.bak/$timestamp"
fi fi
find /mnt/btrfs/root.bak/ -maxdepth 1 -mtime +30 | while IFS= read -r i; do find /mnt/btrfs/root.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
delete_subvolume_recursively "$i" delete_subvolume_recursively "$i"
done done

View File

@@ -0,0 +1,16 @@
{ inputs, pkgs, ... }:
{
imports = [ inputs.sops-nix.nixosModules.sops ];
environment = {
persistence."/persist".files = [ "/etc/ssh/ssh_host_ed25519_key" ];
systemPackages = with pkgs; [ sops ];
};
sops.age = {
generateKey = true;
sshKeyPaths = [ "/persist/etc/ssh/ssh_host_ed25519_key" ];
keyFile = "/var/lib/sops-nix/key.txt";
};
}

View File

@@ -3,4 +3,6 @@
enable = true; enable = true;
histFile = "/var/lib/zsh/history"; histFile = "/var/lib/zsh/history";
}; };
environment.persistence."/persist".directories = [ "/var/lib/zsh" ];
} }

View File

@@ -2,8 +2,9 @@
{ {
imports = [ imports = [
inputs.impermanence.nixosModules.impermanence ./configs/persist
inputs.sops-nix.nixosModules.sops ./configs/sops
./configs/pipewire ./configs/pipewire
./configs/zsh ./configs/zsh
./configs/neovim ./configs/neovim
@@ -14,8 +15,6 @@
./configs/gpg-agent ./configs/gpg-agent
]; ];
fileSystems."/persist".neededForBoot = true;
boot = { boot = {
loader = { loader = {
systemd-boot.enable = true; systemd-boot.enable = true;
@@ -23,46 +22,23 @@
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
initrd = {
verbose = false;
postDeviceCommands = lib.mkAfter (builtins.readFile ./scripts/impermanence.sh);
};
kernelPackages = pkgs.linuxPackages_latest; kernelPackages = pkgs.linuxPackages_latest;
supportedFilesystems = [ "btrfs" "ntfs" ]; supportedFilesystems = [ "btrfs" "ntfs" ];
kernelParams = [ "loglevel=3" "quiet" ]; kernelParams = [ "loglevel=3" "quiet" ];
initrd.verbose = false;
consoleLogLevel = 0; consoleLogLevel = 0;
}; };
environment = {
persistence."/persist" = {
hideMounts = true;
directories = [
"/etc/nixos"
"/etc/NetworkManager/system-connections"
"/var/lib/nixos"
"/var/lib/systemd/coredump"
"/var/lib/zsh"
"/var/log"
];
files = [
"/etc/ssh/ssh_host_ed25519_key"
"/etc/machine-id"
];
};
systemPackages = with pkgs; [
tree
ranger
btop
fastfetch
sops
];
};
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
i18n.defaultLocale = "en_US.UTF-8"; i18n.defaultLocale = "en_US.UTF-8";
environment.systemPackages = with pkgs; [
tree
ranger
btop
fastfetch
];
users = { users = {
mutableUsers = false; mutableUsers = false;
defaultUserShell = pkgs.zsh; defaultUserShell = pkgs.zsh;
@@ -72,12 +48,6 @@
Defaults lecture = never Defaults lecture = never
''; '';
sops.age = {
generateKey = true;
sshKeyPaths = [ "/persist/etc/ssh/ssh_host_ed25519_key" ];
keyFile = "/var/lib/sops-nix/key.txt";
};
system = { system = {
autoUpgrade = { autoUpgrade = {
enable = true; enable = true;

View File

@@ -13,9 +13,7 @@
# https://github.com/NixOS/nixos-hardware/tree/master/lenovo/legion/16achg6 # https://github.com/NixOS/nixos-hardware/tree/master/lenovo/legion/16achg6
hardware = { hardware = {
cpu.amd = { cpu.amd.updateMicrocode = true;
updateMicrocode = true;
};
nvidia = { nvidia = {
modesetting.enable = true; modesetting.enable = true;

View File

@@ -1,88 +1,98 @@
{ pkgs, ... }: { config, lib, pkgs, ... }:
{ {
programs.firefox = { home-manager = {
enable = true; sharedModules = [{
policies = { programs.firefox = {
DisableTelemetry = true; enable = true;
DisableFirefoxStudies = true;
DontCheckDefaultBrowser = true;
DisablePocket = true;
DefaultDownloadDirectory = "\${HOME}/Downloads";
OfferToSaveLogins = false;
AutofillAddressEnabled = false;
AutofillCreditCardEnabled = false;
Preferences = {
"browser.aboutConfig.showWarning" = false;
"browser.contentblocking.category" = "strict";
"browser.download.useDownloadDir" = false;
"browser.newtabpage.activity-stream.feeds.section.topstories" = false;
"browser.newtabpage.activity-stream.showSponsored" = false;
"browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
"browser.toolbars.bookmarks.visibility" = true;
"browser.sessionstore.restore_on_demand" = true;
"browser.sessionstore.restore_pinned_tabs_on_demand" = false;
"browser.translations.automaticallyPopup" = false;
};
};
profiles.nick = {
search = {
default = "DuckDuckGo";
privateDefault = "DuckDuckGo";
order = [
"DuckDuckGo"
"Google"
"Wikipedia (en)"
"Nix Packages"
"Nix Options"
"Home Manager Options"
];
force = true;
engines = {
"Google".metaData.alias = "@g";
"DuckDuckGo".metaData.alias = "@d";
"Wikipedia (en)".metaData.alias = "@w";
"Nix Packages" = { policies = {
urls = [{ DisableTelemetry = true;
template = "https://search.nixos.org/packages"; DisableFirefoxStudies = true;
params = [ DontCheckDefaultBrowser = true;
{ name = "type"; value = "packages"; } DisablePocket = true;
{ name = "query"; value = "{searchTerms}"; } DefaultDownloadDirectory = "\${HOME}/Downloads";
]; OfferToSaveLogins = false;
}]; AutofillAddressEnabled = false;
AutofillCreditCardEnabled = false;
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; Preferences = {
definedAliases = [ "@np" ]; "browser.aboutConfig.showWarning" = false;
"browser.contentblocking.category" = "strict";
"browser.download.useDownloadDir" = false;
"browser.newtabpage.activity-stream.feeds.section.topstories" = false;
"browser.newtabpage.activity-stream.showSponsored" = false;
"browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
"browser.toolbars.bookmarks.visibility" = true;
"browser.sessionstore.restore_on_demand" = true;
"browser.sessionstore.restore_pinned_tabs_on_demand" = false;
"browser.translations.automaticallyPopup" = false;
}; };
};
"Nix Options" = { profiles.nick = {
urls = [{ search = {
template = "https://search.nixos.org/options"; default = "DuckDuckGo";
params = [ privateDefault = "DuckDuckGo";
{ name = "type"; value = "options"; } order = [
{ name = "query"; value = "{searchTerms}"; } "DuckDuckGo"
]; "Google"
}]; "Wikipedia (en)"
"Nix Packages"
"Nix Options"
"Home Manager Options"
];
force = true;
engines = {
"Google".metaData.alias = "@g";
"DuckDuckGo".metaData.alias = "@d";
"Wikipedia (en)".metaData.alias = "@w";
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; "Nix Packages" = {
definedAliases = [ "@no" ]; urls = [{
}; template = "https://search.nixos.org/packages";
params = [
{ name = "type"; value = "packages"; }
{ name = "query"; value = "{searchTerms}"; }
];
}];
"Home Manager Options" = { icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
urls = [{ definedAliases = [ "@np" ];
template = "https://home-manager-options.extranix.com/"; };
params = [
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; "Nix Options" = {
definedAliases = [ "@nh" ]; urls = [{
template = "https://search.nixos.org/options";
params = [
{ name = "type"; value = "options"; }
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@no" ];
};
"Home Manager Options" = {
urls = [{
template = "https://home-manager-options.extranix.com/";
params = [
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@nh" ];
};
};
}; };
}; };
}; };
}; }];
users = lib.attrsets.mapAttrs (user: config: ({
home.persistence."/persist${config.home}".directories = [ ".mozilla" ];
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
}; };
} }

View File

@@ -1,23 +1,35 @@
{ pkgs, ... }: { config, lib, pkgs, ... }:
{ {
programs.git = { home-manager = {
enable = true; sharedModules = [{
lfs.enable = true; programs.git = {
signing = { enable = true;
signByDefault = true; lfs.enable = true;
key = null; signing = {
}; signByDefault = true;
extraConfig.credential.helper = "store"; key = null;
hooks = { };
commit-msg = pkgs.writeScript "git-commit-msg" '' extraConfig.credential.helper = "store";
#!${pkgs.runtimeShell} hooks = let
commit-msg-hook = pkgs.writeShellScriptBin "git-commit-msg" ''
git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
--in-place "$1"
'';
in
{
commit-msg = "${commit-msg-hook}/bin/git-commit-msg";
};
};
}];
git interpret-trailers --if-exists doNothing --trailer \ users = lib.attrsets.mapAttrs (user: config: ({
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \ programs.git = {
--in-place "$1" userName = config.fullName;
''; userEmail = config.email;
}; };
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
}; };
} }

View File

@@ -1,43 +1,52 @@
{ pkgs, ... }: { config, lib, pkgs, ... }:
{ {
services.gpg-agent = { home-manager = {
enable = true; sharedModules = [{
defaultCacheTtl = 31536000; services.gpg-agent = {
maxCacheTtl = 31536000; enable = true;
}; defaultCacheTtl = 31536000;
maxCacheTtl = 31536000;
};
systemd.user.services.gpg-agent-import = { systemd.user.services.gpg-agent-import = let
Unit = { init = pkgs.writeShellScriptBin "import-gpg-keys" ''
Description = "Auto-import GPG keys"; for keyfile in "$HOME"/.config/sops-nix/secrets/gpg-agent/*.key; do
Requires = [ "sops-nix.service" "gpg-agent.socket" ]; passfile="''${keyfile%.key}.pass"
After = [ "sops-nix.service" "gpg-agent.socket" ];
};
Service = { if [ -f "$passfile" ]; then
Type = "oneshot"; gpg --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
ExecStart = pkgs.writeScript "import-gpg-keys" '' else
#!${pkgs.runtimeShell} gpg --batch --yes --import "$keyfile"
fi
for keyfile in "$HOME"/.config/sops-nix/secrets/gpg-agent/*.key; do gpg --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
passfile="''${keyfile%.key}.pass" echo "$KEY_ID:6:" >> "$HOME"/.gnupg/otrust.txt
done
if [ -f "$passfile" ]; then
gpg --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
else
gpg --batch --yes --import "$keyfile"
fi
gpg --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
echo "$KEY_ID:6:" >> "$HOME"/.gnupg/otrust.txt
done done
done
gpg --import-ownertrust "$HOME"/.gnupg/otrust.txt gpg --import-ownertrust "$HOME"/.gnupg/otrust.txt
rm "$HOME"/.gnupg/otrust.txt rm "$HOME"/.gnupg/otrust.txt
''; '';
}; in
{
Unit = {
Description = "Auto-import GPG keys";
Requires = [ "sops-nix.service" "gpg-agent.socket" ];
After = [ "sops-nix.service" "gpg-agent.socket" ];
};
Install = { WantedBy = [ "default.target" ]; }; Service = {
Type = "oneshot";
ExecStart = "${init}/bin/import-gpg-keys";
};
Install = { WantedBy = [ "default.target" ]; };
};
}];
users = lib.attrsets.mapAttrs (user: config: ({
systemd.user.tmpfiles.rules = [ "d ${config.home}/.gnupg 0700 ${user} users -" ];
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
}; };
} }

View File

@@ -1,99 +1,132 @@
{ config, lib, pkgs, ... }:
{ {
wayland.windowManager.hyprland = { programs.hyprland.enable = true;
enable = true;
settings = {
"$mod" = "SUPER";
"$term" = "kitty";
bind = [ environment.sessionVariables.NIXOS_OZONE_WL = "1";
"$mod, Return, exec, $term"
"$mod, r, exec, rofi -show drun"
"$mod, b, exec, firefox"
"$mod, 1, workspace, 1" home-manager = {
"$mod, 2, workspace, 2" sharedModules = [{
"$mod, 3, workspace, 3" wayland.windowManager.hyprland = {
"$mod, 4, workspace, 4" enable = true;
"$mod, 5, workspace, 5" settings = {
"$mod, 6, workspace, 6" "$mod" = "SUPER";
"$mod, 7, workspace, 7" "$term" = "kitty";
"$mod, 8, workspace, 8"
"$mod, 9, workspace, 9"
"$mod, 0, workspace, 10"
"$mod_SHIFT, 1, movetoworkspacesilent, 1" bind = [
"$mod_SHIFT, 2, movetoworkspacesilent, 2" "$mod, Return, exec, $term"
"$mod_SHIFT, 3, movetoworkspacesilent, 3" "$mod, r, exec, rofi -show drun"
"$mod_SHIFT, 4, movetoworkspacesilent, 4" "$mod, b, exec, firefox"
"$mod_SHIFT, 5, movetoworkspacesilent, 5"
"$mod_SHIFT, 6, movetoworkspacesilent, 6"
"$mod_SHIFT, 7, movetoworkspacesilent, 7"
"$mod_SHIFT, 8, movetoworkspacesilent, 8"
"$mod_SHIFT, 9, movetoworkspacesilent, 9"
"$mod_SHIFT, 0, movetoworkspacesilent, 10"
"$mod_CTRL, Space, workspaceopt, allfloat" "$mod, 1, workspace, 1"
"$mod, 2, workspace, 2"
"$mod, 3, workspace, 3"
"$mod, 4, workspace, 4"
"$mod, 5, workspace, 5"
"$mod, 6, workspace, 6"
"$mod, 7, workspace, 7"
"$mod, 8, workspace, 8"
"$mod, 9, workspace, 9"
"$mod, 0, workspace, 10"
"$mod, left, movefocus, l" "$mod_SHIFT, 1, movetoworkspacesilent, 1"
"$mod, h, movefocus, l" "$mod_SHIFT, 2, movetoworkspacesilent, 2"
"$mod, down, movefocus, d" "$mod_SHIFT, 3, movetoworkspacesilent, 3"
"$mod, j, movefocus, d" "$mod_SHIFT, 4, movetoworkspacesilent, 4"
"$mod, up, movefocus, u" "$mod_SHIFT, 5, movetoworkspacesilent, 5"
"$mod, k, movefocus, u" "$mod_SHIFT, 6, movetoworkspacesilent, 6"
"$mod, right, movefocus, r" "$mod_SHIFT, 7, movetoworkspacesilent, 7"
"$mod, l, movefocus, r" "$mod_SHIFT, 8, movetoworkspacesilent, 8"
"$mod_SHIFT, 9, movetoworkspacesilent, 9"
"$mod_SHIFT, 0, movetoworkspacesilent, 10"
"$mod_SHIFT, left, movewindow, l" "$mod_CTRL, Space, workspaceopt, allfloat"
"$mod_SHIFT, h, movewindow, l"
"$mod_SHIFT, down, movewindow, d"
"$mod_SHIFT, j, movewindow, d"
"$mod_SHIFT, up, movewindow, u"
"$mod_SHIFT, k, movewindow, u"
"$mod_SHIFT, right, movewindow, r"
"$mod_SHIFT, l, movewindow, r"
"$mod_CTRL, left, resizeactive, -20 0" "$mod, left, movefocus, l"
"$mod_CTRL, h, resizeactive, -20 0" "$mod, h, movefocus, l"
"$mod_CTRL, down, resizeactive, 0 20" "$mod, down, movefocus, d"
"$mod_CTRL, j, resizeactive, 0 20" "$mod, j, movefocus, d"
"$mod_CTRL, up, resizeactive, 0 -20" "$mod, up, movefocus, u"
"$mod_CTRL, k, resizeactive, 0 -20" "$mod, k, movefocus, u"
"$mod_CTRL, right, resizeactive, 20 0" "$mod, right, movefocus, r"
"$mod_CTRL, l, resizeactive, 20 0" "$mod, l, movefocus, r"
"$mod, Tab, cyclenext" "$mod_SHIFT, left, movewindow, l"
"$mod, Tab, bringactivetotop" "$mod_SHIFT, h, movewindow, l"
"$mod_SHIFT, Tab, cyclenext, prev" "$mod_SHIFT, down, movewindow, d"
"$mod_SHIFT, Tab, bringactivetotop" "$mod_SHIFT, j, movewindow, d"
"$mod_SHIFT, up, movewindow, u"
"$mod_SHIFT, k, movewindow, u"
"$mod_SHIFT, right, movewindow, r"
"$mod_SHIFT, l, movewindow, r"
"$mod, f, fullscreen, 0" "$mod_CTRL, left, resizeactive, -20 0"
"$mod, p, pin" "$mod_CTRL, h, resizeactive, -20 0"
"$mod, Space, togglefloating" "$mod_CTRL, down, resizeactive, 0 20"
"$mod, Space, centerwindow" "$mod_CTRL, j, resizeactive, 0 20"
"$mod, q, killactive" "$mod_CTRL, up, resizeactive, 0 -20"
"$mod_CTRL, k, resizeactive, 0 -20"
"$mod_CTRL, right, resizeactive, 20 0"
"$mod_CTRL, l, resizeactive, 20 0"
"CTRL_ALT, Delete, exit" "$mod, Tab, cyclenext"
]; "$mod, Tab, bringactivetotop"
"$mod_SHIFT, Tab, cyclenext, prev"
"$mod_SHIFT, Tab, bringactivetotop"
bindm = [ "$mod, f, fullscreen, 0"
"$mod, mouse:272, movewindow" "$mod, p, pin"
"$mod, mouse:273, resizewindow" "$mod, Space, togglefloating"
]; "$mod, Space, centerwindow"
"$mod, q, killactive"
input = { "CTRL_ALT, Delete, exit"
"accel_profile" = "flat"; ];
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
input = {
"accel_profile" = "flat";
};
misc = {
"disable_hyprland_logo" = true;
"disable_splash_rendering" = true;
};
};
}; };
misc = { programs.zsh.loginExtra = ''
"disable_hyprland_logo" = true; if [ -z "''${WAYLAND_DISPLAY}" ] && [ ! -z "''${XDG_VTNR}" ] && [ "''${XDG_VTNR}" -eq 1 ]; then
"disable_splash_rendering" = true; ${pkgs.hyprland}/bin/hyprland &> /tmp/hyprland.log
}; fi
}; '';
home.packages = with pkgs; [
swww
rofi-wayland
pavucontrol
];
}];
users = lib.attrsets.mapAttrs (user: config: (
let
init = pkgs.writeShellScriptBin "hyprland-init" ''
${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log &
while ! ${pkgs.swww}/bin/swww query &> /dev/null; do
sleep 0.1
done
${pkgs.swww}/bin/swww img ${config.wallpaper}
'';
in
{
wayland.windowManager.hyprland.settings.exec-once = "${init}/bin/hyprland-init";
}
)) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
}; };
programs.zsh.loginExtra = ''
if [ -z "''${WAYLAND_DISPLAY}" ] && [ ! -z "''${XDG_VTNR}" ] && [ "''${XDG_VTNR}" -eq 1 ]; then
hyprland &> /tmp/hyprland.log
fi
'';
} }

View File

@@ -1,8 +1,10 @@
{ {
programs.kitty = { home-manager.sharedModules = [{
enable = true; programs.kitty = {
extraConfig = '' enable = true;
confirm_os_window_close 0 extraConfig = ''
''; confirm_os_window_close 0
}; '';
};
}];
} }

View File

@@ -1,16 +1,18 @@
{ {
programs.neovim = { home-manager.sharedModules = [{
enable = true; programs.neovim = {
defaultEditor = true; enable = true;
viAlias = true; defaultEditor = true;
vimAlias = true; viAlias = true;
vimdiffAlias = true; vimAlias = true;
extraConfig = '' vimdiffAlias = true;
set tabstop=2 extraConfig = ''
set shiftwidth=2 set tabstop=2
set expandtab set shiftwidth=2
set smartindent set expandtab
''; set smartindent
}; '';
};
}];
} }

View File

@@ -0,0 +1,28 @@
{ config, inputs, lib, ... }:
{
programs.fuse.userAllowOther = true;
systemd.tmpfiles.rules = [ "d /persist/home 0755 root root -" ] ++
lib.attrsets.mapAttrsToList (user: config: "d /persist${config.home} 0700 ${user} users -")
(lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
home-manager = {
sharedModules = [{ imports = [ inputs.impermanence.nixosModules.home-manager.impermanence ]; }];
users = lib.attrsets.mapAttrs (user: config: ({
home.persistence."/persist${config.home}" = {
allowOther = true;
directories = [
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
"Templates"
"VMs"
"git"
];
};
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
};
}

View File

@@ -0,0 +1,17 @@
{ config, inputs, lib, ... }:
let
sopsKeyPath = ".config/sops-nix/key.txt";
in
{
environment.sessionVariables.SOPS_AGE_KEY_FILE = "$HOME/${sopsKeyPath}";
home-manager = {
sharedModules = [{ imports = [ inputs.sops-nix.homeManagerModules.sops ]; }];
users = lib.attrsets.mapAttrs (user: config: ({
home.persistence."/persist${config.home}".files = [ sopsKeyPath ];
sops.age.keyFile = "/persist${config.home}/${sopsKeyPath}";
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
};
}

View File

@@ -1,3 +1,17 @@
{ config, inputs, lib, ... }:
{ {
stylix.enable = true; home-manager = {
sharedModules = [{
imports = [ inputs.stylix.homeManagerModules.stylix ];
stylix.enable = true;
}];
users = lib.attrsets.mapAttrs (user: config: ({
stylix = {
image = config.wallpaper;
base16Scheme = config.base16Scheme;
};
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
};
} }

View File

@@ -1,13 +1,23 @@
{ config, lib, ... }:
{ {
programs.zsh = { home-manager = {
enable = true; sharedModules = [{
autocd = true; programs.zsh = {
history = { enable = true;
path = "$HOME/.local/share/zsh/history"; autocd = true;
expireDuplicatesFirst = true; history = {
}; path = "$HOME/.local/share/zsh/history";
historySubstringSearch.enable = true; expireDuplicatesFirst = true;
autosuggestion.enable = true; };
syntaxHighlighting.enable = true; historySubstringSearch.enable = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
};
}];
users = lib.attrsets.mapAttrs (user: config: ({
home.persistence."/persist${config.home}".directories = [ ".local/share/zsh" ];
})) (lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users);
}; };
} }

View File

@@ -1,108 +1,31 @@
{ config, inputs, lib, pkgs, ... }: { config, inputs, lib, pkgs, ... }:
let
normalUsers = lib.attrsets.filterAttrs (name: config: config.isNormalUser) config.users.users;
in
{ {
imports = [ imports = [
inputs.home-manager.nixosModules.default inputs.home-manager.nixosModules.default
./extra.nix ./extra.nix
./configs/persist
./configs/sops
./configs/firefox
./configs/git
./configs/gpg-agent
./configs/hyprland
./configs/kitty
./configs/neovim
./configs/stylix
./configs/zsh
]; ];
programs = {
hyprland.enable = true;
fuse.userAllowOther = true;
dconf.enable = true;
};
environment.sessionVariables = {
NIXOS_OZONE_WL = "1";
SOPS_AGE_KEY_FILE = "$HOME/.config/sops-nix/key.txt";
};
home-manager = { home-manager = {
extraSpecialArgs = { inherit inputs; }; extraSpecialArgs = { inherit inputs; };
backupFileExtension = "bak"; backupFileExtension = "bak";
sharedModules = [{ sharedModules = [{
imports = [ home.stateVersion = "24.05";
inputs.impermanence.nixosModules.home-manager.impermanence
inputs.sops-nix.homeManagerModules.sops
inputs.stylix.homeManagerModules.stylix
./configs/stylix
./configs/hyprland
./configs/git
./configs/zsh
./configs/neovim
./configs/kitty
./configs/firefox
./configs/gpg-agent
];
home = {
packages = with pkgs; [
rofi-wayland
swww
pavucontrol
];
stateVersion = "24.05";
};
systemd.user.startServices = "sd-switch"; systemd.user.startServices = "sd-switch";
}]; }];
users = lib.attrsets.mapAttrs' (user: config: lib.attrsets.nameValuePair
(user)
(let
init = pkgs.pkgs.writeShellScriptBin "hyprland-init" ''
${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log &
while ! swww query &> /dev/null; do
sleep 0.1
done
${pkgs.swww}/bin/swww img ${config.wallpaper}
'';
in
{
home.persistence."/persist${config.home}" = {
directories = [
"Documents"
"Downloads"
"Music"
"Pictures"
"Videos"
"Templates"
"VMs"
"git"
".mozilla"
".local/share/zsh"
];
files = [
".config/sops-nix/key.txt"
];
allowOther = true;
};
sops.age.keyFile = "/persist${config.home}/.config/sops-nix/key.txt";
programs.git = {
userName = config.fullName;
userEmail = config.email;
};
stylix = {
image = config.wallpaper;
base16Scheme = config.base16Scheme;
};
wayland.windowManager.hyprland.settings.exec-once = "${init}/bin/hyprland-init";
})
) normalUsers;
}; };
systemd.tmpfiles.rules = [ "d /persist/home/ 0755 root root -" ] ++ programs.dconf.enable = true;
lib.attrsets.mapAttrsToList ( user: config: "d /persist${config.home} 0700 ${user} users -" ) normalUsers ++
lib.attrsets.mapAttrsToList ( user: config: "d ${config.home}/.gnupg 0700 ${user} users -" ) normalUsers;
} }