stable zfs

This commit is contained in:
Ray Andrew 2024-10-26 21:06:24 -05:00
parent 2026e3e40e
commit ee88194deb
23 changed files with 442 additions and 266 deletions

16
src/home/bash.nix Normal file
View file

@ -0,0 +1,16 @@
{ lib, pkgs, config, ... }:
{
programs.bash.enable = true;
programs.bash.profileExtra = lib.mkAfter ''
rm -rf ${config.home.homeDirectory}/.local/share/applications/home-manager
rm -rf ${config.home.homeDirectory}/.icons/nix-icons
ls ${config.home.homeDirectory}/.nix-profile/share/applications/*.desktop > ${config.home.homeDirectory}/.cache/current_desktop_files.txt
'';
custom.persist = {
home.files = [
".bash_history"
];
};
}

View file

@ -8,7 +8,12 @@
{
imports = [
./bash.nix
./emacs.nix
./impermanence.nix
./git.nix
./gui
./ssh.nix
];
config = {
@ -20,6 +25,39 @@
stateVersion = "24.11";
username = user;
homeDirectory = "/home/${user}";
activation = {
# linkDesktopApplications = {
# after = ["writeBoundary" "createXdgUserDirectories"];
# before = [];
# data = ''
# rm -rf ${config.home.homeDirectory}/.local/share/applications/home-manager
# rm -rf ${config.home.homeDirectory}/.icons/nix-icons
# mkdir -p ${config.home.homeDirectory}/.local/share/applications/home-manager
# mkdir -p ${config.home.homeDirectory}/.icons
# ln -sf ${config.home.homeDirectory}/.nix-profile/share/icons ${config.home.homeDirectory}/.icons/nix-icons
# # Check if the cached desktop files list exists
# if [ -f ${config.home.homeDirectory}/.cache/current_desktop_files.txt ]; then
# current_files=$(cat ${config.home.homeDirectory}/.cache/current_desktop_files.txt)
# else
# current_files=""
# fi
# # Symlink new desktop entries
# ${pkgs.bash}/bin/bash -c <
# for desktop_file in "${config.home.homeDirectory}/.nix-profile/share/applications/*.desktop"; do
# if ! echo "$current_files" | grep -q "$(basename $desktop_file)"; then
# echo $desktop_file
# ln -sf "$desktop_file" ${config.home.homeDirectory}/.local/share/applications/home-manager/$(basename $desktop_file)
# fi
# done
# # Update desktop database
# ${pkgs.desktop-file-utils}/bin/update-desktop-database ${config.home.homeDirectory}/.local/share/applications
# '';
# };
};
};
programs.home-manager.enable = true;

8
src/home/emacs.nix Normal file
View file

@ -0,0 +1,8 @@
{ pkgs, ... }:
{
programs.emacs = {
enable = true;
package = pkgs.emacs;
};
}

10
src/home/git.nix Normal file
View file

@ -0,0 +1,10 @@
{ lib, pkgs, config, ... }:
{
home.packages = with pkgs; [
git
];
# programs.git = {
# enable = true;
# };
}

View file

@ -1,6 +1,35 @@
_: {
{ pkgs, config, ... }:
{
imports = [
./firefox.nix
./1password.nix
./firefox.nix
./keyd.nix
./gnome.nix
./slack.nix
./skype.nix
./vscode.nix
./xdg.nix
./zathura.nix
./zoom.nix
];
config = {
gtk = {
enable = true;
theme = {
name = "Adwaita-dark";
package = pkgs.gnome-themes-extra;
};
gtk2 = {
configLocation = "${config.home.homeDirectory}/.config/gtkrc-2.0";
};
};
qt = {
enable = true;
platformTheme.name = "adwaita";
style.name = "adwaita-dark";
};
};
}

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ config, pkgs, lib, user, ... }:
let
vendorPath = ".config/.mozilla";
@ -17,14 +17,8 @@ in
lib.concatStringsSep " " (
[
"--name firefox"
# load user firefox profile
"-P ${user}"
# start with urls:
"https://discordapp.com/channels/@me"
]
++ lib.optionals (host == "desktop") [
"https://web.whatsapp.com" # requires access via local network
"http://localhost:9091" # transmission
# "--profile ${config.xdg.configHome}/.mozilla/${user}"
]
)
}"
@ -32,10 +26,10 @@ in
});
};
custom.persist = [
custom.persist = {
home.directories = [
".cache/mozilla"
".config/.mozilla"
];
];
};
}

78
src/home/gui/gnome.nix Normal file
View file

@ -0,0 +1,78 @@
{ lib, pkgs, config, ... }:
{
home.packages = with pkgs; [
pop-launcher
gnomeExtensions.pop-shell
gnomeExtensions.tray-icons-reloaded
gnomeExtensions.hibernate-status-button
];
dconf.settings = {
"org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = [
"pop-shell@system76.com"
"keyd"
];
favorite-apps = [
"org.gnome.Console.desktop"
"firefox.desktop"
];
};
"org/gnome/desktop/wm/keybindings" = {
minimize = [];
lock = [];
switch-to-workspace-left = [];
switch-to-workspace-right = [];
maximize = [ "<Super>f" ];
unmaximize = [ "<Super><Shift>f" ];
move-to-monitor-up = [ ];
move-to-monitor-down = [];
move-to-monitor-left = [];
move-to-monitor-right = [];
move-to-workspace-down = [];
move-to-workspace-up = [];
close = [ "<Super><Shift>q" "<Alt>F4" ];
};
"org/gnome/settings-daemon/plugins/media-keys" = {
video-out = [ ];
custom-keybindings = [
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal/"
];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal" = {
binding = "<Super>Return";
command = "kgx";
name = "GNOME Console";
};
"org/gnome/mutter/keybindings" = {
toggle-tiled-left = [];
toggle-tiled-right = [];
switch-monitor = [ "XF86Display" ];
};
"org/gnome/shell/extensions/pop-shell" = {
activate-launcher = [ "<Super>Space" ];
toggle-float = [ "<Super>p" ];
tile-enter = ["<Super>r"];
tile-by-default = true;
};
"org/gnome/desktop/background" = {
picture-uri-dark = "file://${pkgs.nixos-artwork.wallpapers.nineish-dark-gray.src}";
};
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
};
};
custom.persist = {
home = {
directories = [
".local/share/keyrings"
];
files = [
".config/monitors.xml"
];
};
};
}

20
src/home/gui/keyd.nix Normal file
View file

@ -0,0 +1,20 @@
{ pkgs, ... }:
{
xdg.configFile."keyd/app.conf" = {
text = ''
[firefox]
control.p = up
control.n = down
control.e = end
control.a = home
control.shift.p = macro(C-S-p)
'';
};
home.file.".local/share/gnome-shell/extensions/keyd" = {
source = "${pkgs.keyd}/share/keyd/gnome-extension-45";
recursive = true;
};
}

13
src/home/gui/skype.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
skypeforlinux
];
custom.persist = {
home.directories = [
".config/skypeforlinux"
];
};
}

13
src/home/gui/slack.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
slack
];
custom.persist = {
home.directories = [
".config/Slack"
];
};
}

13
src/home/gui/vscode.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
programs.vscode = {
enable = true;
};
custom.persist = {
home.directories = [
".config/Code"
];
};
}

40
src/home/gui/xdg.nix Normal file
View file

@ -0,0 +1,40 @@
{ pkgs, ... }:
{
xdg = {
mimeApps = {
enable = true;
defaultApplications = {
"application/pdf" = "firefox.desktop";
"application/x-extension-htm" = "firefox.desktop";
"application/x-extension-html" = "firefox.desktop";
"application/x-extension-shtml" = "firefox.desktop";
"application/x-extension-xht" = "firefox.desktop";
"application/x-extension-xhtml" = "firefox.desktop";
"application/xhtml+xml" = "firefox.desktop";
"image/jpeg" = "firefox.desktop";
"image/png" = "firefox.desktop";
"text/html" = "firefox.desktop";
"text/uri-list" = "firefox.desktop";
"x-scheme-handler/chrome" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
};
};
configFile."mimeapps.list".force = true;
};
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-kde
xdg-desktop-portal-gnome
xdg-desktop-portal-gtk
];
config = {
common = { default = [ "gtk" ]; };
gnome = { default = [ "gnome" "gtk" ]; };
};
};
}

8
src/home/gui/zathura.nix Normal file
View file

@ -0,0 +1,8 @@
_:
{
programs.zathura = {
enable = true;
};
}

16
src/home/gui/zoom.nix Normal file
View file

@ -0,0 +1,16 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
zoom-us
];
custom.persist = {
home.directories = [
".zoom"
];
home.files = [
".config/zoomus.conf"
];
};
}

View file

@ -1,7 +1,11 @@
# note: this file exists just to define options for home-manager,
# impermanence is not actually used in standalone home-manager as
# it doesn't serve much utility on legacy distros
{ lib, ... }:
{ lib, user, config, ... }:
let
cfg = config.custom.persist;
in
{
options.custom = with lib; {
persist = {
@ -31,4 +35,19 @@
};
};
};
config = {
# home.persistence = {
# "/persist/home/${user}" = {
# files = cfg.home.files;
# directories = cfg.home.directories;
# allowOther = false;
# };
# "/cache/home/${user}" = {
# files = cfg.home.cache.files;
# directories = cfg.home.cache.directories;
# allowOther = true;
# };
# };
};
}

13
src/home/ssh.nix Normal file
View file

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
programs.ssh = {
enable = true;
};
custom.persist = {
home.directories = [
".ssh"
];
};
}

View file

@ -42,6 +42,7 @@ let
users.${user} = {
imports = [
inputs.nix-index-database.hmModules.nix-index
inputs.impermanence.nixosModules.home-manager.impermanence
# ./${host}/home.nix
../home
];

View file

@ -3,10 +3,6 @@
{
imports = [];
boot.kernelParams = [ "resume_offset=533760" ];
# boot.resumeDevice = "/dev/pool/root";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "pickwick";
networking.hostId = builtins.substring 0 8 (builtins.hashString "md5" config.networking.hostName);
@ -167,8 +163,18 @@
# swapDevices = [
# { device = "/swap/swapfile"; }
# ];
swapDevices = [ { device = "/dev/disk/by-label/SWAP"; } ];
zramSwap.enable = true;
systemd.services = {
# https://github.com/openzfs/zfs/issues/10891
systemd-udev-settle.enable = false;
# snapshot dirs sometimes not accessible
# https://github.com/NixOS/nixpkgs/issues/257505#issuecomment-2348313665
zfs-mount = {
serviceConfig = {
ExecStart = [ "${lib.getExe' pkgs.util-linux "mount"} -t zfs zroot/persist -o remount" ];
};
};
};
system.stateVersion = "24.11";
}

View file

@ -13,14 +13,14 @@
"mode=755"
];
};
"/home" = {
fsType = "tmpfs";
mountOptions = [
"defaults"
"size=1G"
"mode=755"
];
};
# "/home" = {
# fsType = "tmpfs";
# mountOptions = [
# "defaults"
# "size=1G"
# "mode=755"
# ];
# };
};
disk.main = {
@ -56,6 +56,7 @@
type = "swap";
discardPolicy = "both";
resumeDevice = true;
extraArgs = [ "--label" "SWAP" ];
};
};
zfs = {

View file

@ -26,6 +26,37 @@
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
boot.supportedFilesystems.zfs = true;
boot.zfs = {
devNodes ="/dev/disk/by-partuuid";
package = pkgs.zfs_unstable;
requestEncryptionCredentials = true;
};
# boot.kernelPackages =
# assert lib.assertMsg (lib.versionOlder pkgs.zfs_unstable.version "2.3")
# "zfs 2.3 supports kernel 6.11 or greater";
# pkgs.linuxPackagesFor (
# pkgs.linux_xanmod_latest.override {
# argsOverride = rec {
# version = "6.10.11";
# modDirVersion = lib.versions.pad 3 "${version}-xanmod1";
# src = pkgs.fetchFromGitHub {
# owner = "xanmod";
# repo = "linux";
# rev = modDirVersion;
# hash = "sha256-FDWFpiN0VvzdXcS3nZHm1HFgASazNX5+pL/8UJ3hkI8=";
# };
# };
# }
# );
boot.kernelParams = [ ];
# boot.resumeDevice = "/dev/pool/root";
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
swapDevices = [ { device = "/dev/disk/by-label/SWAP"; } ];
zramSwap.enable = true;
# filesystems
fileSystems."/cache".neededForBoot = true;
fileSystems."/persist".neededForBoot = true;

View file

@ -5,238 +5,45 @@
inputs.impermanence.nixosModules.home-manager.impermanence
];
home.persistence."/persist/home/rayandrew/common" = {
directories = [
"Downloads"
"Music"
"Pictures"
"Documents"
"Videos"
"Code"
".gnupg"
# ".ssh"
".local/share/keyrings"
".local/share/direnv"
".config/1Password"
".zoom"
".config/Slack"
".config/skypeforlinux"
];
files = [
".bash_history"
".config/zoomus.conf"
];
allowOther = true;
};
# home.persistence."/persist/home/rayandrew/common" = {
# directories = [
# "Downloads"
# "Music"
# "Pictures"
# "Documents"
# "Videos"
# "Code"
# ".gnupg"
# # ".ssh"
# ".local/share/keyrings"
# ".local/share/direnv"
# ".config/1Password"
# ".zoom"
# ".config/Slack"
# ".config/skypeforlinux"
# ];
# files = [
# ".bash_history"
# ".config/zoomus.conf"
# ];
# allowOther = true;
# };
home.persistence."/persist/home/rayandrew/dotfiles" = {
removePrefixDirectory = true;
allowOther = true;
directories = [
"scripts/bin"
"ssh/.ssh"
];
files = [
];
};
programs.home-manager = {
enable = true;
};
dconf.settings = {
"org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = [
"pop-shell@system76.com"
"keyd"
];
favorite-apps = [
"org.gnome.Console.desktop"
"firefox.desktop"
];
};
"org/gnome/desktop/wm/keybindings" = {
minimize = [];
lock = [];
switch-to-workspace-left = [];
switch-to-workspace-right = [];
maximize = [ "<Super>f" ];
unmaximize = [ "<Super><Shift>f" ];
move-to-monitor-up = [ ];
move-to-monitor-down = [];
move-to-monitor-left = [];
move-to-monitor-right = [];
move-to-workspace-down = [];
move-to-workspace-up = [];
close = [ "<Super><Shift>q" "<Alt>F4" ];
};
"org/gnome/settings-daemon/plugins/media-keys" = {
video-out = [ ];
custom-keybindings = [
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal/"
];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/terminal" = {
binding = "<Super>Return";
command = "kgx";
name = "GNOME Console";
};
"org/gnome/mutter/keybindings" = {
toggle-tiled-left = [];
toggle-tiled-right = [];
switch-monitor = [ "XF86Display" ];
};
"org/gnome/shell/extensions/pop-shell" = {
activate-launcher = [ "<Super>Space" ];
toggle-float = [ "<Super>p" ];
tile-enter = ["<Super>r"];
tile-by-default = true;
};
"org/gnome/desktop/background" = {
picture-uri-dark = "file://${pkgs.nixos-artwork.wallpapers.nineish-dark-gray.src}";
};
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
};
};
gtk = {
enable = true;
theme = {
name = "Adwaita-dark";
package = pkgs.gnome-themes-extra;
};
gtk2 = {
configLocation = "${config.home.homeDirectory}/.config/gtkrc-2.0";
};
};
qt = {
enable = true;
platformTheme.name = "adwaita";
style.name = "adwaita-dark";
};
xdg = {
mimeApps = {
enable = true;
defaultApplications = {
"application/pdf" = "firefox.desktop";
"application/x-extension-htm" = "firefox.desktop";
"application/x-extension-html" = "firefox.desktop";
"application/x-extension-shtml" = "firefox.desktop";
"application/x-extension-xht" = "firefox.desktop";
"application/x-extension-xhtml" = "firefox.desktop";
"application/xhtml+xml" = "firefox.desktop";
"image/jpeg" = "firefox.desktop";
"image/png" = "firefox.desktop";
"text/html" = "firefox.desktop";
"text/uri-list" = "firefox.desktop";
"x-scheme-handler/chrome" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
};
};
configFile."mimeapps.list".force = true;
};
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-kde
xdg-desktop-portal-gnome
xdg-desktop-portal-gtk
];
config = {
common = { default = [ "gtk" ]; };
gnome = { default = [ "gnome" "gtk" ]; };
};
};
home.packages = with pkgs; [
zoom-us
slack
skypeforlinux
desktop-file-utils
gnomeExtensions.pop-shell
gnomeExtensions.tray-icons-reloaded
gnomeExtensions.hibernate-status-button
pop-launcher
];
programs.git = {
enable = true;
};
programs.bash.profileExtra = lib.mkAfter ''
rm -rf ${config.home.homeDirectory}/.local/share/applications/home-manager
rm -rf ${config.home.homeDirectory}/.icons/nix-icons
ls ${config.home.homeDirectory}/.nix-profile/share/applications/*.desktop > ${config.home.homeDirectory}/.cache/current_desktop_files.txt
'';
home.activation = {
linkDesktopApplications = {
after = ["writeBoundary" "createXdgUserDirectories"];
before = [];
data = ''
rm -rf ${config.home.homeDirectory}/.local/share/applications/home-manager
rm -rf ${config.home.homeDirectory}/.icons/nix-icons
mkdir -p ${config.home.homeDirectory}/.local/share/applications/home-manager
mkdir -p ${config.home.homeDirectory}/.icons
ln -sf ${config.home.homeDirectory}/.nix-profile/share/icons ${config.home.homeDirectory}/.icons/nix-icons
# Check if the cached desktop files list exists
if [ -f ${config.home.homeDirectory}/.cache/current_desktop_files.txt ]; then
current_files=$(cat ${config.home.homeDirectory}/.cache/current_desktop_files.txt)
else
current_files=""
fi
# Symlink new desktop entries
for desktop_file in ${config.home.homeDirectory}/.nix-profile/share/applications/*.desktop; do
if ! echo "$current_files" | grep -q "$(basename $desktop_file)"; then
ln -sf "$desktop_file" ${config.home.homeDirectory}/.local/share/applications/home-manager/$(basename $desktop_file)
fi
done
# Update desktop database
${pkgs.desktop-file-utils}/bin/update-desktop-database ${config.home.homeDirectory}/.local/share/applications
'';
};
};
programs.emacs = {
enable = true;
package = pkgs.emacs;
};
programs.vscode = {
enable = true;
};
# home.persistence."/persist/home/rayandrew/dotfiles" = {
# removePrefixDirectory = true;
# allowOther = true;
# directories = [
# "scripts/bin"
# "ssh/.ssh"
# ];
# files = [
# ];
# };
programs.zathura = {
enable = true;
};
xdg.configFile."keyd/app.conf" = {
text = ''
[firefox]
control.p = up
control.n = down
control.e = end
control.a = home
control.shift.p = macro(C-S-p)
'';
};
home.file.".local/share/gnome-shell/extensions/keyd" = {
source = "${pkgs.keyd}/share/keyd/gnome-extension-45";
recursive = true;
};
# systemd.user.services.keyd-application-mapper = {
# Install.WantedBy = [ "default.target" ];
# Unit = { Description = "keyd-application-mapper"; };

View file

@ -60,12 +60,9 @@ in
};
config = {
# clear /tmp on boot, since it's a zfs dataset
boot.tmp.cleanOnBoot = true;
# root and home on tmpfs
# neededForBoot is required, so there won't be permission errors creating directories or symlinks
# https://github.com/nix-community/impermanence/issues/149#issuecomment-1806604102
fileSystems."/" = lib.mkForce {
device = "tmpfs";
fsType = "tmpfs";
@ -91,14 +88,18 @@ in
"/etc/NetworkManager/system-connections"
] ++ cfg.root.directories;
# users.${user} = {
# files = cfg.home.files ++ hmPersistCfg.home.files;
# directories = [
# "projects"
# ".cache/dconf"
# ".config/dconf"
# ] ++ cfg.home.directories ++ hmPersistCfg.home.directories;
# };
users.${user} = {
files = cfg.home.files ++ hmPersistCfg.home.files;
directories = lib.unique (
[
"Code"
".cache/dconf"
".config/dconf"
]
++ cfg.home.directories
++ hmPersistCfg.home.directories
);
};
};
# cache are files that should be persisted, but not to snapshot

View file

@ -21,6 +21,7 @@
};
${user} = {
isNormalUser = true;
createHome = true;
# initialPassword = "password";
hashedPasswordFile = "/persist/etc/shadow/${user}";
extraGroups = [