From 3b50015cb99ed6800251b7a3ef5e2afd680265ae Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Sat, 26 Oct 2024 17:06:28 -0500 Subject: [PATCH 1/8] zfs init --- README.md | 4 + disko.nix | 96 ---------------- flake.nix | 72 +++++++++--- src/home/default.nix | 44 +++++++ src/home/gui/1password.nix | 9 ++ src/home/gui/default.nix | 6 + src/home/gui/firefox.nix | 41 +++++++ src/hosts/default.nix | 63 ++++++++++ .../hosts/pickwick/default.nix | 35 +----- src/hosts/pickwick/disko.nix | 108 ++++++++++++++++++ .../hosts/pickwick/hardware.nix | 10 +- home.nix => src/hosts/pickwick/home.nix | 95 --------------- 12 files changed, 344 insertions(+), 239 deletions(-) delete mode 100644 disko.nix create mode 100644 src/home/default.nix create mode 100644 src/home/gui/1password.nix create mode 100644 src/home/gui/default.nix create mode 100644 src/home/gui/firefox.nix create mode 100644 src/hosts/default.nix rename configuration.nix => src/hosts/pickwick/default.nix (83%) create mode 100644 src/hosts/pickwick/disko.nix rename hardware-configuration.nix => src/hosts/pickwick/hardware.nix (82%) rename home.nix => src/hosts/pickwick/home.nix (72%) diff --git a/README.md b/README.md index e8ae5ca..f8004e7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ +``` +sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /tmp/disk-config.nix +``` + - https://github.com/iynaix/dotfiles/blob/13c2fcec880d292726f52be1075277d521caf3a7/nixos/zfs.nix - https://github.com/iynaix/dotfiles/blob/13c2fcec880d292726f52be1075277d521caf3a7/nixos/impermanence.nix#L69 - https://github.com/maydayv7/dotfiles diff --git a/disko.nix b/disko.nix deleted file mode 100644 index 4c2301c..0000000 --- a/disko.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - device ? throw "Set this to your disk device, e.g. /dev/sda", - ... -}: -{ - disko.devices = { - nodev = { - "/" = { - fsType = "tmpfs"; - mountOptions = [ - "defaults" - "size=8G" - "mode=755" - ]; - }; - }; - - disk.main = { - type = "disk"; - inherit device; - - content = { - type = "gpt"; - partitions = { - boot = { - name = "boot"; - size = "1M"; - type = "EF02"; - }; - esp = { - priority = 1; - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ - "defaults" - "umask=0077" - ]; - }; - }; - - luks = { - size = "100%"; - content = { - type = "luks"; - name = "crypted"; - settings = { - allowDiscards = true; - }; - content = { - type = "lvm_pv"; - vg = "pool"; - }; - }; - }; - }; - }; - }; - - lvm_vg = { - pool = { - type = "lvm_vg"; - lvs = { - root = { - size = "100%FREE"; - content = { - type = "btrfs"; - extraArgs = ["-f"]; - - subvolumes = { - "/persist" = { - mountOptions = ["subvol=persist" "compress=zstd" "noatime"]; - mountpoint = "/persist"; - }; - - "/nix" = { - mountOptions = ["subvol=nix" "compress=zstd" "noatime"]; - mountpoint = "/nix"; - }; - - "/swap" = { - mountpoint = "/swap"; - mountOptions = ["noatime"]; - swap.swapfile.size = "108G"; - }; - }; - }; - }; - }; - }; - }; - }; -} diff --git a/flake.nix b/flake.nix index 82d1f01..6e30e20 100644 --- a/flake.nix +++ b/flake.nix @@ -9,21 +9,65 @@ home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + nix-index-database.url = "github:nix-community/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = {nixpkgs, ...} @ inputs: - { - nixosConfigurations.pickwick = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; - modules = [ - inputs.disko.nixosModules.default - (import ./disko.nix { device = "/dev/nvme0n1"; }) - - ./configuration.nix - - inputs.home-manager.nixosModules.default - inputs.impermanence.nixosModules.impermanence - ]; + outputs = + inputs@{ nixpkgs, self, ... }: + let + system = "x86_64-linux"; + pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + lib = import ./lib.nix { + inherit (nixpkgs) lib; + inherit pkgs; + inherit (inputs) home-manager; + }; + createCommonArgs = system: { + inherit + self + inputs + nixpkgs + lib + pkgs + system + ; + specialArgs = { + inherit self inputs; + }; + }; + commonArgs = createCommonArgs system; + # call with forAllSystems (commonArgs: function body) + forAllSystems = + fn: + lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ] (system: fn (createCommonArgs system)); + in + { + inherit lib self; + nixosConfigurations = (import ./src/hosts/nixos.nix commonArgs); }; - }; + + # outputs = {nixpkgs, ...} @ inputs: + # { + # nixosConfigurations.pickwick = nixpkgs.lib.nixosSystem { + # specialArgs = { inherit inputs; }; + # modules = [ + # inputs.disko.nixosModules.default + # (import ./disko.nix { device = "/dev/nvme0n1"; }) + + # ./configuration.nix + # + # inputs.home-manager.nixosModules.default + # inputs.impermanence.nixosModules.impermanence + # ]; + # }; + # }; } diff --git a/src/home/default.nix b/src/home/default.nix new file mode 100644 index 0000000..5ef0475 --- /dev/null +++ b/src/home/default.nix @@ -0,0 +1,44 @@ +{ + config, + lib, + pkgs, + user, + ... +}: + +{ + imports = [ + ./impermanence.nix + ]; + + config = { + + # setup fonts for other distros, run "fc-cache -f" to refresh fonts + fonts.fontconfig.enable = true; + + home = { + stateVersion = "24.11"; + username = user; + homeDirectory = "/home/${user}"; + }; + + programs.home-manager.enable = true; + + xdg = { + enable = true; + userDirs.enable = true; + mimeApps.enable = true; + }; + + custom = { + persist = { + home.directories = [ + "Documents" + "Downloads" + "Pictures" + "Code" + ]; + }; + }; + }; +} diff --git a/src/home/gui/1password.nix b/src/home/gui/1password.nix new file mode 100644 index 0000000..e590571 --- /dev/null +++ b/src/home/gui/1password.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ + custom.persist = { + home.directories = [ + ".config/1Password" + ]; + }; +} diff --git a/src/home/gui/default.nix b/src/home/gui/default.nix new file mode 100644 index 0000000..232f6b5 --- /dev/null +++ b/src/home/gui/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./firefox.nix + ./1password.nix + ]; +} diff --git a/src/home/gui/firefox.nix b/src/home/gui/firefox.nix new file mode 100644 index 0000000..8c3bc93 --- /dev/null +++ b/src/home/gui/firefox.nix @@ -0,0 +1,41 @@ +{ config, pkgs, ... }: + +let + vendorPath = ".config/.mozilla"; + configPath = "${vendorPath}/firefox"; +in +{ + programs.firefox = { + enable = true; + package = pkgs.firefox-bin.overrideAttrs (o: { + buildCommand = + o.buildCommand + + '' + wrapProgram "$executablePath" \ + --set 'HOME' '${config.xdg.configHome}' \ + --append-flags "${ + 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 + ] + ) + }" + ''; + }); + }; + + custom.persist = [ + home.directories = [ + ".cache/mozilla" + ".config/.mozilla" + ]; + ]; +} diff --git a/src/hosts/default.nix b/src/hosts/default.nix new file mode 100644 index 0000000..d45568e --- /dev/null +++ b/src/hosts/default.nix @@ -0,0 +1,63 @@ +{ + inputs, + lib, + system, + specialArgs, + user ? "rayandrew", + ... +}: +let + # provide an optional { pkgs } 2nd argument to override the pkgs + mkNixosConfiguration = + host: + { + pkgs ? ( + import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + } + ), + }: + lib.nixosSystem { + inherit pkgs; + + specialArgs = specialArgs // { + inherit host user; + }; + + modules = [ + inputs.disko.nixosModules.default + inputs.home-manager.nixosModules.home-manager + inputs.impermanence.nixosModules.impermanence + ./${host} + ./${host}/hardware.nix + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + + extraSpecialArgs = specialArgs // { + inherit host user; + }; + + users.${user} = { + imports = [ + inputs.nix-index-database.hmModules.nix-index + # ./${host}/home.nix + ../../home + ]; + }; + }; + } + # alias for home-manager + (lib.mkAliasOptionModule [ "hm" ] [ + "home-manager" + "users" + user + ]) + ]; + }; +in +{ + pickwick = mkNixosConfiguration "pickwick" { }; +} diff --git a/configuration.nix b/src/hosts/pickwick/default.nix similarity index 83% rename from configuration.nix rename to src/hosts/pickwick/default.nix index 0e6969e..1fb381b 100644 --- a/configuration.nix +++ b/src/hosts/pickwick/default.nix @@ -2,8 +2,6 @@ { imports = [ - ./hardware-configuration.nix - inputs.nixos-hardware.nixosModules.framework-13-7040-amd ]; nixpkgs.config.allowUnfree = true; @@ -21,13 +19,10 @@ i18n.defaultLocale = "en_US.UTF-8"; services.xserver.enable = true; - # services.displayManager.sddm.enable = true; - # services.desktopManager.plasma6.enable = true; services.xserver.displayManager.gdm.enable = true; services.xserver.desktopManager.gnome.enable = true; services.xserver.xkb.layout = "us"; - # services.xserver.xkb.options = "caps:ctrl_modifier"; security.sudo.extraConfig = "Defaults lecture=never"; security.pam.services.login.fprintAuth = false; @@ -69,16 +64,7 @@ vim wget htop-vim - - # gnome keyd - # gnomeExtensions.pop-launcher-super-key - ]; - - environment.plasma6.excludePackages = with pkgs.kdePackages; [ - # plasma-browser-integration - # konsole - oxygen ]; environment.gnome.excludePackages = with pkgs; [ @@ -117,8 +103,6 @@ environment.persistence."/persist/system" = { hideMounts = true; directories = [ - "/etc/nixos" - # "/etc/gdm" "/var/log" "/var/lib/fprint" "/var/lib/nixos" @@ -142,16 +126,6 @@ useUserPackages = true; }; - - # xdg.portal = { - # enable = true; - # xdgOpenUsePortal = true; - # extraPortals = [ - # pkgs.xdg-desktop-portal-gnome - # pkgs.xdg-desktop-portal-gtk - # ]; - # }; - services.keyd = { enable = true; keyboards = { @@ -161,7 +135,6 @@ main = { capslock = "layer(capslock)"; insert = "S-insert"; - # capslock = "layer(control)"; }; meta = { w = "macro(C-w)"; @@ -195,9 +168,11 @@ "CAP_SETGID" ]; - swapDevices = [ - { device = "/swap/swapfile"; } - ]; + # swapDevices = [ + # { device = "/swap/swapfile"; } + # ]; + swapDevices = [ { device = "/dev/disk/by-label/SWAP"; } ]; + zramSwap.enable = true; system.stateVersion = "24.11"; } diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix new file mode 100644 index 0000000..1cfe5f9 --- /dev/null +++ b/src/hosts/pickwick/disko.nix @@ -0,0 +1,108 @@ +{ + device ? throw "Set this to your disk device, e.g. /dev/sda", + ... +}: +{ + disko.devices = { + nodev = { + "/" = { + fsType = "tmpfs"; + mountOptions = [ + "defaults" + "size=1G" + "mode=755" + ]; + }; + "/home" = { + fsType = "tmpfs"; + mountOptions = [ + "defaults" + "size=1G" + "mode=755" + ]; + }; + }; + + disk.main = { + type = "disk"; + inherit device; + + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + priority = 1; + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "defaults" + "umask=0077" + ]; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + mode = "mirror"; + options = { + cachefile = "none"; + ashift = 12; + autotrim = "on"; + }; + rootFsOptions = { + compression = "zstd"; + acltype = "posixacl"; + xattr = "sa"; + "com.sun:auto-snapshot" = "false"; + mountpoint = "none"; + encryption = "aes-256-gcm"; + keyformat = "passphrase"; + keylocation = "prompt"; + }; + mountpoint = "none"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; + datasets = { + nix = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/nix"; + }; + cache = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/cache"; + }; + persist = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/persist"; + }; + tmp = { + type = "zfs_fs"; + options.mountpoint = "legacy"; + mountpoint = "/tmp"; + }; + }; + }; + }; + }; +} diff --git a/hardware-configuration.nix b/src/hosts/pickwick/hardware.nix similarity index 82% rename from hardware-configuration.nix rename to src/hosts/pickwick/hardware.nix index 9ded9b2..71a87ed 100644 --- a/hardware-configuration.nix +++ b/src/hosts/pickwick/hardware.nix @@ -1,12 +1,14 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ input, config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + (import ./disko.nix { device = "/dev/nvme0n1"; }) + inputs.nixos-hardware.nixosModules.framework-13-7040-amd + ]; boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.kernelModules = [ "dm-snapshot" ]; diff --git a/home.nix b/src/hosts/pickwick/home.nix similarity index 72% rename from home.nix rename to src/hosts/pickwick/home.nix index e954d3a..d1b24f2 100644 --- a/home.nix +++ b/src/hosts/pickwick/home.nix @@ -26,101 +26,6 @@ ".bash_history" ".config/zoomus.conf" ]; - allowOther = false; - }; - - home.persistence."/persist/home/rayandrew/desktop" = { - removePrefixDirectory = false; - allowOther = false; - directories = [ - ".config/gtk-3.0" - ".config/gtk-4.0" - ".config/KDE" - ".config/kde.org" - ".config/plasma-workspace" - ".config/xsettingsd" - ".kde" - - ".local/share/baloo" - ".local/share/dolphin" - ".local/share/kactivitymanagerd" - ".local/share/kate" - ".local/share/klipper" - ".local/share/konsole" - ".local/share/kscreen" - ".local/share/kwalletd" - ".local/share/kxmlgui5" - ".local/share/RecentDocuments" - ".local/share/sddm" - ]; - files = [ - ".config/monitors.xml" - ".config/akregatorrc" - ".config/baloofileinformationrc" - ".config/baloofilerc" - ".config/bluedevilglobalrc" - ".config/device_automounter_kcmrc" - ".config/dolphinrc" - ".config/filetypesrc" - # ".config/gtkrc" - # ".config/gtkrc-2.0" - # ".config/gtkrc-3.0" - ".config/gwenviewrc" - ".config/kactivitymanagerd-pluginsrc" - ".config/kactivitymanagerd-statsrc" - ".config/kactivitymanagerd-switcher" - ".config/kactivitymanagerdrc" - ".config/katemetainfos" - ".config/katerc" - ".config/kateschemarc" - ".config/katevirc" - ".config/kcmfonts" - ".config/kcminputrc" - ".config/kconf_updaterc" - ".config/kded5rc" - ".config/kdeglobals" - ".config/kgammarc" - ".config/kglobalshortcutsrc" - ".config/khotkeysrc" - ".config/kmixrc" - ".config/konsolerc" - ".config/kscreenlockerrc" - ".config/ksmserverrc" - ".config/ksplashrc" - ".config/ktimezonedrc" - ".config/kwinrc" - ".config/kwinrulesrc" - ".config/kxkbrc" - # ".config/mimeapps.list" - ".config/partitionmanagerrc" - ".config/plasma-localerc" - ".config/plasma-nm" - ".config/plasma-org.kde.plasma.desktop-appletsrc" - ".config/plasmanotifyrc" - ".config/plasmarc" - ".config/plasmashellrc" - ".config/PlasmaUserFeedback" - ".config/plasmawindowed-appletsrc" - ".config/plasmawindowedrc" - ".config/powermanagementprofilesrc" - ".config/spectaclerc" - ".config/startkderc" - ".config/systemsettingsrc" - ".config/Trolltech.conf" - # ".config/user-dirs.dirs" - ".config/user-dirs.locale" - - ".local/share/krunnerstaterc" - ".local/share/user-places.xbel" - # ".local/share/user-places.xbel.bak" - ".local/share/user-places.xbel.tbcache" - ]; - }; - - home.persistence."/persist/home/rayandrew/firefox" = { - directories = [ - ".mozilla" - ]; allowOther = true; }; -- 2.46.0 From 5381b594e8cd16e0b39737e972a7c69fd57b4f62 Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Sat, 26 Oct 2024 17:12:20 -0500 Subject: [PATCH 2/8] add swap --- README.md | 2 +- src/hosts/pickwick/disko.nix | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8004e7..5073578 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ``` -sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /tmp/disk-config.nix +sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /tmp/nix-priv/src/hosts/pickwick/disko.nix ``` - https://github.com/iynaix/dotfiles/blob/13c2fcec880d292726f52be1075277d521caf3a7/nixos/zfs.nix diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix index 1cfe5f9..a0ae040 100644 --- a/src/hosts/pickwick/disko.nix +++ b/src/hosts/pickwick/disko.nix @@ -47,8 +47,17 @@ "defaults" "umask=0077" ]; + extraArgs = [ "-n" "BOOT" ]; }; }; + swap = { + size = "108G"; + content = { + type = "swap"; + discardPolicy = "both"; + resumeDevice = true; + }; + }; zfs = { size = "100%"; content = { -- 2.46.0 From a8366161d4bda769d49b497a8f37240957435c66 Mon Sep 17 00:00:00 2001 From: rayandrew Date: Sat, 26 Oct 2024 18:17:29 -0500 Subject: [PATCH 3/8] Apply patch --- flake.lock | 21 +++++++++ flake.nix | 4 +- src/hosts/default.nix | 7 +-- src/hosts/pickwick/default.nix | 78 ++++++++++++++++----------------- src/hosts/pickwick/disko.nix | 9 ++-- src/hosts/pickwick/hardware.nix | 7 ++- 6 files changed, 75 insertions(+), 51 deletions(-) diff --git a/flake.lock b/flake.lock index ef81198..a4c1454 100644 --- a/flake.lock +++ b/flake.lock @@ -55,6 +55,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729394935, + "narHash": "sha256-2ntUG+NJKdfhlrh/tF+jOU0fOesO7lm5ZZVSYitsvH8=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "04f8a11f247ba00263b060fbcdc95484fd046104", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1729742320, @@ -92,6 +112,7 @@ "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", + "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 6e30e20..60e2591 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ inherit system; config.allowUnfree = true; }; - lib = import ./lib.nix { + lib = import ./src/lib.nix { inherit (nixpkgs) lib; inherit pkgs; inherit (inputs) home-manager; @@ -52,7 +52,7 @@ in { inherit lib self; - nixosConfigurations = (import ./src/hosts/nixos.nix commonArgs); + nixosConfigurations = (import ./src/hosts/default.nix commonArgs); }; # outputs = {nixpkgs, ...} @ inputs: diff --git a/src/hosts/default.nix b/src/hosts/default.nix index d45568e..bcb9292 100644 --- a/src/hosts/default.nix +++ b/src/hosts/default.nix @@ -27,10 +27,9 @@ let modules = [ inputs.disko.nixosModules.default - inputs.home-manager.nixosModules.home-manager - inputs.impermanence.nixosModules.impermanence ./${host} ./${host}/hardware.nix + ../nixos { home-manager = { useGlobalPkgs = true; @@ -44,7 +43,7 @@ let imports = [ inputs.nix-index-database.hmModules.nix-index # ./${host}/home.nix - ../../home + ../home ]; }; }; @@ -55,6 +54,8 @@ let "users" user ]) + inputs.home-manager.nixosModules.home-manager + inputs.impermanence.nixosModules.impermanence ]; }; in diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix index 1fb381b..78e97d6 100644 --- a/src/hosts/pickwick/default.nix +++ b/src/hosts/pickwick/default.nix @@ -1,17 +1,15 @@ { config, lib, pkgs, inputs, ... }: { - imports = [ - ]; - - nixpkgs.config.allowUnfree = true; + imports = []; boot.kernelParams = [ "resume_offset=533760" ]; - boot.resumeDevice = "/dev/pool/root"; + # 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); networking.networkmanager.enable = true; time.timeZone = "America/Chicago"; @@ -24,7 +22,6 @@ services.xserver.desktopManager.gnome.enable = true; services.xserver.xkb.layout = "us"; - security.sudo.extraConfig = "Defaults lecture=never"; security.pam.services.login.fprintAuth = false; security.pam.services.sudo.fprintAuth = false; @@ -47,17 +44,17 @@ services.libinput.enable = true; - users.users.root.hashedPasswordFile = "/persist/passwords/root"; - users.users.rayandrew = { - isNormalUser = true; - # initialPassword = "12345"; - hashedPasswordFile = "/persist/passwords/rayandrew"; - extraGroups = [ "wheel" "audio" "keyd" ]; - packages = with pkgs; [ - firefox - tree - ]; - }; + # users.users.root.hashedPasswordFile = "/persist/passwords/root"; + # users.users.rayandrew = { + # isNormalUser = true; + # # initialPassword = "12345"; + # hashedPasswordFile = "/persist/passwords/rayandrew"; + # extraGroups = [ "wheel" "audio" "keyd" ]; + # packages = with pkgs; [ + # firefox + # tree + # ]; + # }; users.groups.keyd = {}; environment.systemPackages = with pkgs; [ @@ -99,32 +96,31 @@ programs.dconf.enable = true; - fileSystems."/persist".neededForBoot = true; - environment.persistence."/persist/system" = { - hideMounts = true; - directories = [ - "/var/log" - "/var/lib/fprint" - "/var/lib/nixos" - "/var/lib/bluetooth" - "/var/lib/systemd/coredump" - "/etc/NetworkManager/system-connections" - { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } - ]; - files = [ - "/etc/machine-id" - ]; - }; + # environment.persistence."/persist/system" = { + # hideMounts = true; + # directories = [ + # "/var/log" + # "/var/lib/fprint" + # "/var/lib/nixos" + # "/var/lib/bluetooth" + # "/var/lib/systemd/coredump" + # "/etc/NetworkManager/system-connections" + # { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } + # ]; + # files = [ + # "/etc/machine-id" + # ]; + # }; programs.fuse.userAllowOther = true; - home-manager = { - extraSpecialArgs = {inherit inputs pkgs;}; - users = { - "rayandrew" = import ./home.nix; - }; - useGlobalPkgs = true; - useUserPackages = true; - }; + # home-manager = { + # extraSpecialArgs = {inherit inputs pkgs;}; + # users = { + # "rayandrew" = import ./home.nix; + # }; + # useGlobalPkgs = true; + # useUserPackages = true; + # }; services.keyd = { enable = true; diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix index a0ae040..2b796fb 100644 --- a/src/hosts/pickwick/disko.nix +++ b/src/hosts/pickwick/disko.nix @@ -71,23 +71,24 @@ zpool = { zroot = { type = "zpool"; - mode = "mirror"; + # mode = "mirror"; options = { cachefile = "none"; - ashift = 12; + ashift = "12"; autotrim = "on"; }; rootFsOptions = { compression = "zstd"; acltype = "posixacl"; xattr = "sa"; - "com.sun:auto-snapshot" = "false"; mountpoint = "none"; encryption = "aes-256-gcm"; keyformat = "passphrase"; keylocation = "prompt"; + normalization = "formD"; + "com.sun:auto-snapshot" = "false"; }; - mountpoint = "none"; + mountpoint = null; postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; datasets = { nix = { diff --git a/src/hosts/pickwick/hardware.nix b/src/hosts/pickwick/hardware.nix index 71a87ed..80cd2dd 100644 --- a/src/hosts/pickwick/hardware.nix +++ b/src/hosts/pickwick/hardware.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ input, config, lib, pkgs, modulesPath, ... }: +{ inputs, config, lib, pkgs, modulesPath, ... }: { imports = [ @@ -25,4 +25,9 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + # filesystems + fileSystems."/cache".neededForBoot = true; + fileSystems."/persist".neededForBoot = true; } + -- 2.46.0 From 99785ac890524e0881808158007bc9e7dfc5c11a Mon Sep 17 00:00:00 2001 From: rayandrew Date: Sat, 26 Oct 2024 18:18:22 -0500 Subject: [PATCH 4/8] revert a8366161d4bda769d49b497a8f37240957435c66 revert Apply patch --- flake.lock | 21 --------- flake.nix | 4 +- src/hosts/default.nix | 7 ++- src/hosts/pickwick/default.nix | 78 +++++++++++++++++---------------- src/hosts/pickwick/disko.nix | 9 ++-- src/hosts/pickwick/hardware.nix | 7 +-- 6 files changed, 51 insertions(+), 75 deletions(-) diff --git a/flake.lock b/flake.lock index a4c1454..ef81198 100644 --- a/flake.lock +++ b/flake.lock @@ -55,26 +55,6 @@ "type": "github" } }, - "nix-index-database": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1729394935, - "narHash": "sha256-2ntUG+NJKdfhlrh/tF+jOU0fOesO7lm5ZZVSYitsvH8=", - "owner": "nix-community", - "repo": "nix-index-database", - "rev": "04f8a11f247ba00263b060fbcdc95484fd046104", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nix-index-database", - "type": "github" - } - }, "nixos-hardware": { "locked": { "lastModified": 1729742320, @@ -112,7 +92,6 @@ "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", - "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 60e2591..6e30e20 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ inherit system; config.allowUnfree = true; }; - lib = import ./src/lib.nix { + lib = import ./lib.nix { inherit (nixpkgs) lib; inherit pkgs; inherit (inputs) home-manager; @@ -52,7 +52,7 @@ in { inherit lib self; - nixosConfigurations = (import ./src/hosts/default.nix commonArgs); + nixosConfigurations = (import ./src/hosts/nixos.nix commonArgs); }; # outputs = {nixpkgs, ...} @ inputs: diff --git a/src/hosts/default.nix b/src/hosts/default.nix index bcb9292..d45568e 100644 --- a/src/hosts/default.nix +++ b/src/hosts/default.nix @@ -27,9 +27,10 @@ let modules = [ inputs.disko.nixosModules.default + inputs.home-manager.nixosModules.home-manager + inputs.impermanence.nixosModules.impermanence ./${host} ./${host}/hardware.nix - ../nixos { home-manager = { useGlobalPkgs = true; @@ -43,7 +44,7 @@ let imports = [ inputs.nix-index-database.hmModules.nix-index # ./${host}/home.nix - ../home + ../../home ]; }; }; @@ -54,8 +55,6 @@ let "users" user ]) - inputs.home-manager.nixosModules.home-manager - inputs.impermanence.nixosModules.impermanence ]; }; in diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix index 78e97d6..1fb381b 100644 --- a/src/hosts/pickwick/default.nix +++ b/src/hosts/pickwick/default.nix @@ -1,15 +1,17 @@ { config, lib, pkgs, inputs, ... }: { - imports = []; + imports = [ + ]; + + nixpkgs.config.allowUnfree = true; boot.kernelParams = [ "resume_offset=533760" ]; - # boot.resumeDevice = "/dev/pool/root"; + 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); networking.networkmanager.enable = true; time.timeZone = "America/Chicago"; @@ -22,6 +24,7 @@ services.xserver.desktopManager.gnome.enable = true; services.xserver.xkb.layout = "us"; + security.sudo.extraConfig = "Defaults lecture=never"; security.pam.services.login.fprintAuth = false; security.pam.services.sudo.fprintAuth = false; @@ -44,17 +47,17 @@ services.libinput.enable = true; - # users.users.root.hashedPasswordFile = "/persist/passwords/root"; - # users.users.rayandrew = { - # isNormalUser = true; - # # initialPassword = "12345"; - # hashedPasswordFile = "/persist/passwords/rayandrew"; - # extraGroups = [ "wheel" "audio" "keyd" ]; - # packages = with pkgs; [ - # firefox - # tree - # ]; - # }; + users.users.root.hashedPasswordFile = "/persist/passwords/root"; + users.users.rayandrew = { + isNormalUser = true; + # initialPassword = "12345"; + hashedPasswordFile = "/persist/passwords/rayandrew"; + extraGroups = [ "wheel" "audio" "keyd" ]; + packages = with pkgs; [ + firefox + tree + ]; + }; users.groups.keyd = {}; environment.systemPackages = with pkgs; [ @@ -96,31 +99,32 @@ programs.dconf.enable = true; - # environment.persistence."/persist/system" = { - # hideMounts = true; - # directories = [ - # "/var/log" - # "/var/lib/fprint" - # "/var/lib/nixos" - # "/var/lib/bluetooth" - # "/var/lib/systemd/coredump" - # "/etc/NetworkManager/system-connections" - # { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } - # ]; - # files = [ - # "/etc/machine-id" - # ]; - # }; + fileSystems."/persist".neededForBoot = true; + environment.persistence."/persist/system" = { + hideMounts = true; + directories = [ + "/var/log" + "/var/lib/fprint" + "/var/lib/nixos" + "/var/lib/bluetooth" + "/var/lib/systemd/coredump" + "/etc/NetworkManager/system-connections" + { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } + ]; + files = [ + "/etc/machine-id" + ]; + }; programs.fuse.userAllowOther = true; - # home-manager = { - # extraSpecialArgs = {inherit inputs pkgs;}; - # users = { - # "rayandrew" = import ./home.nix; - # }; - # useGlobalPkgs = true; - # useUserPackages = true; - # }; + home-manager = { + extraSpecialArgs = {inherit inputs pkgs;}; + users = { + "rayandrew" = import ./home.nix; + }; + useGlobalPkgs = true; + useUserPackages = true; + }; services.keyd = { enable = true; diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix index 2b796fb..a0ae040 100644 --- a/src/hosts/pickwick/disko.nix +++ b/src/hosts/pickwick/disko.nix @@ -71,24 +71,23 @@ zpool = { zroot = { type = "zpool"; - # mode = "mirror"; + mode = "mirror"; options = { cachefile = "none"; - ashift = "12"; + ashift = 12; autotrim = "on"; }; rootFsOptions = { compression = "zstd"; acltype = "posixacl"; xattr = "sa"; + "com.sun:auto-snapshot" = "false"; mountpoint = "none"; encryption = "aes-256-gcm"; keyformat = "passphrase"; keylocation = "prompt"; - normalization = "formD"; - "com.sun:auto-snapshot" = "false"; }; - mountpoint = null; + mountpoint = "none"; postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; datasets = { nix = { diff --git a/src/hosts/pickwick/hardware.nix b/src/hosts/pickwick/hardware.nix index 80cd2dd..71a87ed 100644 --- a/src/hosts/pickwick/hardware.nix +++ b/src/hosts/pickwick/hardware.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ inputs, config, lib, pkgs, modulesPath, ... }: +{ input, config, lib, pkgs, modulesPath, ... }: { imports = [ @@ -25,9 +25,4 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; - - # filesystems - fileSystems."/cache".neededForBoot = true; - fileSystems."/persist".neededForBoot = true; } - -- 2.46.0 From 71ca7f996b1836dc8eb401f5fa46a13ac2af0efb Mon Sep 17 00:00:00 2001 From: rayandrew Date: Sat, 26 Oct 2024 18:18:52 -0500 Subject: [PATCH 5/8] Upload files to "/" --- a.patch | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 a.patch diff --git a/a.patch b/a.patch new file mode 100644 index 0000000..7065d1d --- /dev/null +++ b/a.patch @@ -0,0 +1,268 @@ +diff --git a/flake.lock b/flake.lock +index ef81198..a4c1454 100644 +--- a/flake.lock ++++ b/flake.lock +@@ -55,6 +55,26 @@ + "type": "github" + } + }, ++ "nix-index-database": { ++ "inputs": { ++ "nixpkgs": [ ++ "nixpkgs" ++ ] ++ }, ++ "locked": { ++ "lastModified": 1729394935, ++ "narHash": "sha256-2ntUG+NJKdfhlrh/tF+jOU0fOesO7lm5ZZVSYitsvH8=", ++ "owner": "nix-community", ++ "repo": "nix-index-database", ++ "rev": "04f8a11f247ba00263b060fbcdc95484fd046104", ++ "type": "github" ++ }, ++ "original": { ++ "owner": "nix-community", ++ "repo": "nix-index-database", ++ "type": "github" ++ } ++ }, + "nixos-hardware": { + "locked": { + "lastModified": 1729742320, +@@ -92,6 +112,7 @@ + "disko": "disko", + "home-manager": "home-manager", + "impermanence": "impermanence", ++ "nix-index-database": "nix-index-database", + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs" + } +diff --git a/flake.nix b/flake.nix +index 6e30e20..60e2591 100644 +--- a/flake.nix ++++ b/flake.nix +@@ -21,7 +21,7 @@ + inherit system; + config.allowUnfree = true; + }; +- lib = import ./lib.nix { ++ lib = import ./src/lib.nix { + inherit (nixpkgs) lib; + inherit pkgs; + inherit (inputs) home-manager; +@@ -52,7 +52,7 @@ + in + { + inherit lib self; +- nixosConfigurations = (import ./src/hosts/nixos.nix commonArgs); ++ nixosConfigurations = (import ./src/hosts/default.nix commonArgs); + }; + + # outputs = {nixpkgs, ...} @ inputs: +diff --git a/src/hosts/default.nix b/src/hosts/default.nix +index d45568e..bcb9292 100644 +--- a/src/hosts/default.nix ++++ b/src/hosts/default.nix +@@ -27,10 +27,9 @@ let + + modules = [ + inputs.disko.nixosModules.default +- inputs.home-manager.nixosModules.home-manager +- inputs.impermanence.nixosModules.impermanence + ./${host} + ./${host}/hardware.nix ++ ../nixos + { + home-manager = { + useGlobalPkgs = true; +@@ -44,7 +43,7 @@ let + imports = [ + inputs.nix-index-database.hmModules.nix-index + # ./${host}/home.nix +- ../../home ++ ../home + ]; + }; + }; +@@ -55,6 +54,8 @@ let + "users" + user + ]) ++ inputs.home-manager.nixosModules.home-manager ++ inputs.impermanence.nixosModules.impermanence + ]; + }; + in +diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix +index 1fb381b..78e97d6 100644 +--- a/src/hosts/pickwick/default.nix ++++ b/src/hosts/pickwick/default.nix +@@ -1,17 +1,15 @@ + { config, lib, pkgs, inputs, ... }: + + { +- imports = [ +- ]; +- +- nixpkgs.config.allowUnfree = true; ++ imports = []; + + boot.kernelParams = [ "resume_offset=533760" ]; +- boot.resumeDevice = "/dev/pool/root"; ++ # 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); + networking.networkmanager.enable = true; + + time.timeZone = "America/Chicago"; +@@ -24,7 +22,6 @@ + services.xserver.desktopManager.gnome.enable = true; + services.xserver.xkb.layout = "us"; + +- security.sudo.extraConfig = "Defaults lecture=never"; + security.pam.services.login.fprintAuth = false; + security.pam.services.sudo.fprintAuth = false; + +@@ -47,17 +44,17 @@ + services.libinput.enable = true; + + +- users.users.root.hashedPasswordFile = "/persist/passwords/root"; +- users.users.rayandrew = { +- isNormalUser = true; +- # initialPassword = "12345"; +- hashedPasswordFile = "/persist/passwords/rayandrew"; +- extraGroups = [ "wheel" "audio" "keyd" ]; +- packages = with pkgs; [ +- firefox +- tree +- ]; +- }; ++ # users.users.root.hashedPasswordFile = "/persist/passwords/root"; ++ # users.users.rayandrew = { ++ # isNormalUser = true; ++ # # initialPassword = "12345"; ++ # hashedPasswordFile = "/persist/passwords/rayandrew"; ++ # extraGroups = [ "wheel" "audio" "keyd" ]; ++ # packages = with pkgs; [ ++ # firefox ++ # tree ++ # ]; ++ # }; + users.groups.keyd = {}; + + environment.systemPackages = with pkgs; [ +@@ -99,32 +96,31 @@ + + programs.dconf.enable = true; + +- fileSystems."/persist".neededForBoot = true; +- environment.persistence."/persist/system" = { +- hideMounts = true; +- directories = [ +- "/var/log" +- "/var/lib/fprint" +- "/var/lib/nixos" +- "/var/lib/bluetooth" +- "/var/lib/systemd/coredump" +- "/etc/NetworkManager/system-connections" +- { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } +- ]; +- files = [ +- "/etc/machine-id" +- ]; +- }; ++ # environment.persistence."/persist/system" = { ++ # hideMounts = true; ++ # directories = [ ++ # "/var/log" ++ # "/var/lib/fprint" ++ # "/var/lib/nixos" ++ # "/var/lib/bluetooth" ++ # "/var/lib/systemd/coredump" ++ # "/etc/NetworkManager/system-connections" ++ # { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } ++ # ]; ++ # files = [ ++ # "/etc/machine-id" ++ # ]; ++ # }; + + programs.fuse.userAllowOther = true; +- home-manager = { +- extraSpecialArgs = {inherit inputs pkgs;}; +- users = { +- "rayandrew" = import ./home.nix; +- }; +- useGlobalPkgs = true; +- useUserPackages = true; +- }; ++ # home-manager = { ++ # extraSpecialArgs = {inherit inputs pkgs;}; ++ # users = { ++ # "rayandrew" = import ./home.nix; ++ # }; ++ # useGlobalPkgs = true; ++ # useUserPackages = true; ++ # }; + + services.keyd = { + enable = true; +diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix +index a0ae040..cc5376d 100644 +--- a/src/hosts/pickwick/disko.nix ++++ b/src/hosts/pickwick/disko.nix +@@ -71,23 +71,24 @@ + zpool = { + zroot = { + type = "zpool"; +- mode = "mirror"; ++ # mode = "mirror"; + options = { + cachefile = "none"; +- ashift = 12; ++ ashift = "12"; + autotrim = "on"; + }; + rootFsOptions = { + compression = "zstd"; + acltype = "posixacl"; + xattr = "sa"; +- "com.sun:auto-snapshot" = "false"; + mountpoint = "none"; + encryption = "aes-256-gcm"; + keyformat = "passphrase"; + keylocation = "prompt"; ++ normalization = "formD"; ++ "com.sun:auto-snapshot" = "false"; + }; +- mountpoint = "none"; ++ mountpoint = null; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; + datasets = { + nix = { +diff --git a/src/hosts/pickwick/hardware.nix b/src/hosts/pickwick/hardware.nix +index 71a87ed..4f09066 100644 +--- a/src/hosts/pickwick/hardware.nix ++++ b/src/hosts/pickwick/hardware.nix +@@ -1,7 +1,7 @@ + # Do not modify this file! It was generated by ‘nixos-generate-config’ + # and may be overwritten by future invocations. Please make changes + # to /etc/nixos/configuration.nix instead. +-{ input, config, lib, pkgs, modulesPath, ... }: ++{ inputs, config, lib, pkgs, modulesPath, ... }: + + { + imports = [ +@@ -25,4 +25,8 @@ + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; ++ ++ # filesystems ++ fileSystems."/cache".neededForBoot = true; ++ fileSystems."/persist".neededForBoot = true; + } -- 2.46.0 From 275e2ecd2a5a8bad45afe72b72783ad8ec150e4c Mon Sep 17 00:00:00 2001 From: rayandrew Date: Sat, 26 Oct 2024 18:20:20 -0500 Subject: [PATCH 6/8] revert 71ca7f996b1836dc8eb401f5fa46a13ac2af0efb revert Upload files to "/" --- a.patch | 268 -------------------------------------------------------- 1 file changed, 268 deletions(-) delete mode 100644 a.patch diff --git a/a.patch b/a.patch deleted file mode 100644 index 7065d1d..0000000 --- a/a.patch +++ /dev/null @@ -1,268 +0,0 @@ -diff --git a/flake.lock b/flake.lock -index ef81198..a4c1454 100644 ---- a/flake.lock -+++ b/flake.lock -@@ -55,6 +55,26 @@ - "type": "github" - } - }, -+ "nix-index-database": { -+ "inputs": { -+ "nixpkgs": [ -+ "nixpkgs" -+ ] -+ }, -+ "locked": { -+ "lastModified": 1729394935, -+ "narHash": "sha256-2ntUG+NJKdfhlrh/tF+jOU0fOesO7lm5ZZVSYitsvH8=", -+ "owner": "nix-community", -+ "repo": "nix-index-database", -+ "rev": "04f8a11f247ba00263b060fbcdc95484fd046104", -+ "type": "github" -+ }, -+ "original": { -+ "owner": "nix-community", -+ "repo": "nix-index-database", -+ "type": "github" -+ } -+ }, - "nixos-hardware": { - "locked": { - "lastModified": 1729742320, -@@ -92,6 +112,7 @@ - "disko": "disko", - "home-manager": "home-manager", - "impermanence": "impermanence", -+ "nix-index-database": "nix-index-database", - "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs" - } -diff --git a/flake.nix b/flake.nix -index 6e30e20..60e2591 100644 ---- a/flake.nix -+++ b/flake.nix -@@ -21,7 +21,7 @@ - inherit system; - config.allowUnfree = true; - }; -- lib = import ./lib.nix { -+ lib = import ./src/lib.nix { - inherit (nixpkgs) lib; - inherit pkgs; - inherit (inputs) home-manager; -@@ -52,7 +52,7 @@ - in - { - inherit lib self; -- nixosConfigurations = (import ./src/hosts/nixos.nix commonArgs); -+ nixosConfigurations = (import ./src/hosts/default.nix commonArgs); - }; - - # outputs = {nixpkgs, ...} @ inputs: -diff --git a/src/hosts/default.nix b/src/hosts/default.nix -index d45568e..bcb9292 100644 ---- a/src/hosts/default.nix -+++ b/src/hosts/default.nix -@@ -27,10 +27,9 @@ let - - modules = [ - inputs.disko.nixosModules.default -- inputs.home-manager.nixosModules.home-manager -- inputs.impermanence.nixosModules.impermanence - ./${host} - ./${host}/hardware.nix -+ ../nixos - { - home-manager = { - useGlobalPkgs = true; -@@ -44,7 +43,7 @@ let - imports = [ - inputs.nix-index-database.hmModules.nix-index - # ./${host}/home.nix -- ../../home -+ ../home - ]; - }; - }; -@@ -55,6 +54,8 @@ let - "users" - user - ]) -+ inputs.home-manager.nixosModules.home-manager -+ inputs.impermanence.nixosModules.impermanence - ]; - }; - in -diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix -index 1fb381b..78e97d6 100644 ---- a/src/hosts/pickwick/default.nix -+++ b/src/hosts/pickwick/default.nix -@@ -1,17 +1,15 @@ - { config, lib, pkgs, inputs, ... }: - - { -- imports = [ -- ]; -- -- nixpkgs.config.allowUnfree = true; -+ imports = []; - - boot.kernelParams = [ "resume_offset=533760" ]; -- boot.resumeDevice = "/dev/pool/root"; -+ # 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); - networking.networkmanager.enable = true; - - time.timeZone = "America/Chicago"; -@@ -24,7 +22,6 @@ - services.xserver.desktopManager.gnome.enable = true; - services.xserver.xkb.layout = "us"; - -- security.sudo.extraConfig = "Defaults lecture=never"; - security.pam.services.login.fprintAuth = false; - security.pam.services.sudo.fprintAuth = false; - -@@ -47,17 +44,17 @@ - services.libinput.enable = true; - - -- users.users.root.hashedPasswordFile = "/persist/passwords/root"; -- users.users.rayandrew = { -- isNormalUser = true; -- # initialPassword = "12345"; -- hashedPasswordFile = "/persist/passwords/rayandrew"; -- extraGroups = [ "wheel" "audio" "keyd" ]; -- packages = with pkgs; [ -- firefox -- tree -- ]; -- }; -+ # users.users.root.hashedPasswordFile = "/persist/passwords/root"; -+ # users.users.rayandrew = { -+ # isNormalUser = true; -+ # # initialPassword = "12345"; -+ # hashedPasswordFile = "/persist/passwords/rayandrew"; -+ # extraGroups = [ "wheel" "audio" "keyd" ]; -+ # packages = with pkgs; [ -+ # firefox -+ # tree -+ # ]; -+ # }; - users.groups.keyd = {}; - - environment.systemPackages = with pkgs; [ -@@ -99,32 +96,31 @@ - - programs.dconf.enable = true; - -- fileSystems."/persist".neededForBoot = true; -- environment.persistence."/persist/system" = { -- hideMounts = true; -- directories = [ -- "/var/log" -- "/var/lib/fprint" -- "/var/lib/nixos" -- "/var/lib/bluetooth" -- "/var/lib/systemd/coredump" -- "/etc/NetworkManager/system-connections" -- { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } -- ]; -- files = [ -- "/etc/machine-id" -- ]; -- }; -+ # environment.persistence."/persist/system" = { -+ # hideMounts = true; -+ # directories = [ -+ # "/var/log" -+ # "/var/lib/fprint" -+ # "/var/lib/nixos" -+ # "/var/lib/bluetooth" -+ # "/var/lib/systemd/coredump" -+ # "/etc/NetworkManager/system-connections" -+ # { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } -+ # ]; -+ # files = [ -+ # "/etc/machine-id" -+ # ]; -+ # }; - - programs.fuse.userAllowOther = true; -- home-manager = { -- extraSpecialArgs = {inherit inputs pkgs;}; -- users = { -- "rayandrew" = import ./home.nix; -- }; -- useGlobalPkgs = true; -- useUserPackages = true; -- }; -+ # home-manager = { -+ # extraSpecialArgs = {inherit inputs pkgs;}; -+ # users = { -+ # "rayandrew" = import ./home.nix; -+ # }; -+ # useGlobalPkgs = true; -+ # useUserPackages = true; -+ # }; - - services.keyd = { - enable = true; -diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix -index a0ae040..cc5376d 100644 ---- a/src/hosts/pickwick/disko.nix -+++ b/src/hosts/pickwick/disko.nix -@@ -71,23 +71,24 @@ - zpool = { - zroot = { - type = "zpool"; -- mode = "mirror"; -+ # mode = "mirror"; - options = { - cachefile = "none"; -- ashift = 12; -+ ashift = "12"; - autotrim = "on"; - }; - rootFsOptions = { - compression = "zstd"; - acltype = "posixacl"; - xattr = "sa"; -- "com.sun:auto-snapshot" = "false"; - mountpoint = "none"; - encryption = "aes-256-gcm"; - keyformat = "passphrase"; - keylocation = "prompt"; -+ normalization = "formD"; -+ "com.sun:auto-snapshot" = "false"; - }; -- mountpoint = "none"; -+ mountpoint = null; - postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; - datasets = { - nix = { -diff --git a/src/hosts/pickwick/hardware.nix b/src/hosts/pickwick/hardware.nix -index 71a87ed..4f09066 100644 ---- a/src/hosts/pickwick/hardware.nix -+++ b/src/hosts/pickwick/hardware.nix -@@ -1,7 +1,7 @@ - # Do not modify this file! It was generated by ‘nixos-generate-config’ - # and may be overwritten by future invocations. Please make changes - # to /etc/nixos/configuration.nix instead. --{ input, config, lib, pkgs, modulesPath, ... }: -+{ inputs, config, lib, pkgs, modulesPath, ... }: - - { - imports = [ -@@ -25,4 +25,8 @@ - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -+ -+ # filesystems -+ fileSystems."/cache".neededForBoot = true; -+ fileSystems."/persist".neededForBoot = true; - } -- 2.46.0 From 2026e3e40eb4ddc6ccfed295ca3c0a9753ff5e81 Mon Sep 17 00:00:00 2001 From: rayandrew Date: Sat, 26 Oct 2024 18:20:27 -0500 Subject: [PATCH 7/8] Apply patch --- flake.lock | 21 +++++ flake.nix | 4 +- src/home/impermanence.nix | 34 ++++++++ src/hosts/default.nix | 7 +- src/hosts/pickwick/default.nix | 78 +++++++++--------- src/hosts/pickwick/disko.nix | 9 ++- src/hosts/pickwick/hardware.nix | 6 +- src/lib.nix | 4 + src/nixos/default.nix | 13 +++ src/nixos/impermanence.nix | 135 ++++++++++++++++++++++++++++++++ src/nixos/users.nix | 35 +++++++++ 11 files changed, 295 insertions(+), 51 deletions(-) create mode 100644 src/home/impermanence.nix create mode 100644 src/lib.nix create mode 100644 src/nixos/default.nix create mode 100644 src/nixos/impermanence.nix create mode 100644 src/nixos/users.nix diff --git a/flake.lock b/flake.lock index ef81198..a4c1454 100644 --- a/flake.lock +++ b/flake.lock @@ -55,6 +55,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729394935, + "narHash": "sha256-2ntUG+NJKdfhlrh/tF+jOU0fOesO7lm5ZZVSYitsvH8=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "04f8a11f247ba00263b060fbcdc95484fd046104", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1729742320, @@ -92,6 +112,7 @@ "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", + "nix-index-database": "nix-index-database", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 6e30e20..60e2591 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ inherit system; config.allowUnfree = true; }; - lib = import ./lib.nix { + lib = import ./src/lib.nix { inherit (nixpkgs) lib; inherit pkgs; inherit (inputs) home-manager; @@ -52,7 +52,7 @@ in { inherit lib self; - nixosConfigurations = (import ./src/hosts/nixos.nix commonArgs); + nixosConfigurations = (import ./src/hosts/default.nix commonArgs); }; # outputs = {nixpkgs, ...} @ inputs: diff --git a/src/home/impermanence.nix b/src/home/impermanence.nix new file mode 100644 index 0000000..6407386 --- /dev/null +++ b/src/home/impermanence.nix @@ -0,0 +1,34 @@ +# 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, ... }: +{ + options.custom = with lib; { + persist = { + home = { + directories = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Directories to persist in home directory"; + }; + files = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Files to persist in home directory"; + }; + cache = { + directories = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Directories to persist, but not to snapshot"; + }; + files = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Files to persist, but not to snapshot"; + }; + }; + }; + }; + }; +} diff --git a/src/hosts/default.nix b/src/hosts/default.nix index d45568e..bcb9292 100644 --- a/src/hosts/default.nix +++ b/src/hosts/default.nix @@ -27,10 +27,9 @@ let modules = [ inputs.disko.nixosModules.default - inputs.home-manager.nixosModules.home-manager - inputs.impermanence.nixosModules.impermanence ./${host} ./${host}/hardware.nix + ../nixos { home-manager = { useGlobalPkgs = true; @@ -44,7 +43,7 @@ let imports = [ inputs.nix-index-database.hmModules.nix-index # ./${host}/home.nix - ../../home + ../home ]; }; }; @@ -55,6 +54,8 @@ let "users" user ]) + inputs.home-manager.nixosModules.home-manager + inputs.impermanence.nixosModules.impermanence ]; }; in diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix index 1fb381b..78e97d6 100644 --- a/src/hosts/pickwick/default.nix +++ b/src/hosts/pickwick/default.nix @@ -1,17 +1,15 @@ { config, lib, pkgs, inputs, ... }: { - imports = [ - ]; - - nixpkgs.config.allowUnfree = true; + imports = []; boot.kernelParams = [ "resume_offset=533760" ]; - boot.resumeDevice = "/dev/pool/root"; + # 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); networking.networkmanager.enable = true; time.timeZone = "America/Chicago"; @@ -24,7 +22,6 @@ services.xserver.desktopManager.gnome.enable = true; services.xserver.xkb.layout = "us"; - security.sudo.extraConfig = "Defaults lecture=never"; security.pam.services.login.fprintAuth = false; security.pam.services.sudo.fprintAuth = false; @@ -47,17 +44,17 @@ services.libinput.enable = true; - users.users.root.hashedPasswordFile = "/persist/passwords/root"; - users.users.rayandrew = { - isNormalUser = true; - # initialPassword = "12345"; - hashedPasswordFile = "/persist/passwords/rayandrew"; - extraGroups = [ "wheel" "audio" "keyd" ]; - packages = with pkgs; [ - firefox - tree - ]; - }; + # users.users.root.hashedPasswordFile = "/persist/passwords/root"; + # users.users.rayandrew = { + # isNormalUser = true; + # # initialPassword = "12345"; + # hashedPasswordFile = "/persist/passwords/rayandrew"; + # extraGroups = [ "wheel" "audio" "keyd" ]; + # packages = with pkgs; [ + # firefox + # tree + # ]; + # }; users.groups.keyd = {}; environment.systemPackages = with pkgs; [ @@ -99,32 +96,31 @@ programs.dconf.enable = true; - fileSystems."/persist".neededForBoot = true; - environment.persistence."/persist/system" = { - hideMounts = true; - directories = [ - "/var/log" - "/var/lib/fprint" - "/var/lib/nixos" - "/var/lib/bluetooth" - "/var/lib/systemd/coredump" - "/etc/NetworkManager/system-connections" - { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } - ]; - files = [ - "/etc/machine-id" - ]; - }; + # environment.persistence."/persist/system" = { + # hideMounts = true; + # directories = [ + # "/var/log" + # "/var/lib/fprint" + # "/var/lib/nixos" + # "/var/lib/bluetooth" + # "/var/lib/systemd/coredump" + # "/etc/NetworkManager/system-connections" + # { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } + # ]; + # files = [ + # "/etc/machine-id" + # ]; + # }; programs.fuse.userAllowOther = true; - home-manager = { - extraSpecialArgs = {inherit inputs pkgs;}; - users = { - "rayandrew" = import ./home.nix; - }; - useGlobalPkgs = true; - useUserPackages = true; - }; + # home-manager = { + # extraSpecialArgs = {inherit inputs pkgs;}; + # users = { + # "rayandrew" = import ./home.nix; + # }; + # useGlobalPkgs = true; + # useUserPackages = true; + # }; services.keyd = { enable = true; diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix index a0ae040..2b796fb 100644 --- a/src/hosts/pickwick/disko.nix +++ b/src/hosts/pickwick/disko.nix @@ -71,23 +71,24 @@ zpool = { zroot = { type = "zpool"; - mode = "mirror"; + # mode = "mirror"; options = { cachefile = "none"; - ashift = 12; + ashift = "12"; autotrim = "on"; }; rootFsOptions = { compression = "zstd"; acltype = "posixacl"; xattr = "sa"; - "com.sun:auto-snapshot" = "false"; mountpoint = "none"; encryption = "aes-256-gcm"; keyformat = "passphrase"; keylocation = "prompt"; + normalization = "formD"; + "com.sun:auto-snapshot" = "false"; }; - mountpoint = "none"; + mountpoint = null; postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; datasets = { nix = { diff --git a/src/hosts/pickwick/hardware.nix b/src/hosts/pickwick/hardware.nix index 71a87ed..4f09066 100644 --- a/src/hosts/pickwick/hardware.nix +++ b/src/hosts/pickwick/hardware.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ input, config, lib, pkgs, modulesPath, ... }: +{ inputs, config, lib, pkgs, modulesPath, ... }: { imports = [ @@ -25,4 +25,8 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + # filesystems + fileSystems."/cache".neededForBoot = true; + fileSystems."/persist".neededForBoot = true; } diff --git a/src/lib.nix b/src/lib.nix new file mode 100644 index 0000000..9fb4299 --- /dev/null +++ b/src/lib.nix @@ -0,0 +1,4 @@ +{ lib, pkgs, ... }: + +lib.extend (_: libprev: { +}) diff --git a/src/nixos/default.nix b/src/nixos/default.nix new file mode 100644 index 0000000..3fe9fb3 --- /dev/null +++ b/src/nixos/default.nix @@ -0,0 +1,13 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ + ./users.nix + ./impermanence.nix + ]; +} diff --git a/src/nixos/impermanence.nix b/src/nixos/impermanence.nix new file mode 100644 index 0000000..9956740 --- /dev/null +++ b/src/nixos/impermanence.nix @@ -0,0 +1,135 @@ +{ + config, + lib, + pkgs, + user, + ... +}: +let + cfg = config.custom.persist; + hmPersistCfg = config.hm.custom.persist; + assertNoHomeDirs = + paths: + assert (lib.assertMsg (!lib.any (lib.hasPrefix "/home") paths) "/home used in a root persist!"); + paths; +in +{ + options.custom = with lib; { + persist = { + root = { + directories = mkOption { + type = types.listOf types.str; + default = [ ]; + apply = assertNoHomeDirs; + description = "Directories to persist in root filesystem"; + }; + files = mkOption { + type = types.listOf types.str; + default = [ ]; + apply = assertNoHomeDirs; + description = "Files to persist in root filesystem"; + }; + cache = { + directories = mkOption { + type = types.listOf types.str; + default = [ ]; + apply = assertNoHomeDirs; + description = "Directories to persist, but not to snapshot"; + }; + files = mkOption { + type = types.listOf types.str; + default = [ ]; + apply = assertNoHomeDirs; + description = "Files to persist, but not to snapshot"; + }; + }; + }; + home = { + directories = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Directories to persist in home directory"; + }; + files = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Files to persist in home directory"; + }; + }; + }; + }; + + 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"; + neededForBoot = true; + options = [ + "defaults" + "size=1G" + "mode=755" + ]; + }; + + # shut sudo up + security.sudo.extraConfig = "Defaults lecture=never"; + + # setup persistence + environment.persistence = { + "/persist" = { + hideMounts = true; + files = [ "/etc/machine-id" ] ++ cfg.root.files; + directories = [ + "/var/log" # systemd journal is stored in /var/log/journal + "/var/lib/nixos" # for persisting user uids and gids + "/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; + # }; + }; + + # cache are files that should be persisted, but not to snapshot + # e.g. npm, cargo cache etc, that could always be redownloaded + "/cache" = { + hideMounts = true; + inherit (cfg.root.cache) directories files; + + users.${user} = { + inherit (hmPersistCfg.home.cache) directories files; + }; + }; + }; + + hm.xdg.stateFile."impermanence.json".text = + let + getDirPath = prefix: d: "${prefix}${d.dirPath}"; + getFilePath = prefix: f: "${prefix}${f.filePath}"; + persistCfg = config.environment.persistence."/persist"; + persistCacheCfg = config.environment.persistence."/cache"; + allDirectories = + map (getDirPath "/persist") (persistCfg.directories) + ++ map (getDirPath "/cache") (persistCacheCfg.directories); + allFiles = + map (getFilePath "/persist") (persistCfg.files) + ++ map (getFilePath "/cache") (persistCacheCfg.files); + sort-uniq = arr: lib.sort lib.lessThan (lib.unique arr); + in + lib.strings.toJSON { + directories = sort-uniq allDirectories; + files = sort-uniq allFiles; + }; + }; +} diff --git a/src/nixos/users.nix b/src/nixos/users.nix new file mode 100644 index 0000000..36aff4a --- /dev/null +++ b/src/nixos/users.nix @@ -0,0 +1,35 @@ +{ + config, + lib, + user, + ... +}: + +{ + config = lib.mkMerge [ + { + users = { + mutableUsers = false; + # setup users with persistent passwords + # https://reddit.com/r/NixOS/comments/o1er2p/tmpfs_as_root_but_without_hardcoding_your/h22f1b9/ + # create a password with for root and $user with: + # mkpasswd -m sha-512 'PASSWORD' | sudo tee -a /persist/etc/shadow/root + users = { + root = { + # initialPassword = "password"; + hashedPasswordFile = "/persist/etc/shadow/root"; + }; + ${user} = { + isNormalUser = true; + # initialPassword = "password"; + hashedPasswordFile = "/persist/etc/shadow/${user}"; + extraGroups = [ + "networkmanager" + "wheel" + ]; + }; + }; + }; + } + ]; +} -- 2.46.0 From ee88194debb0778729c898a83b928b714d2b220a Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Sat, 26 Oct 2024 21:06:24 -0500 Subject: [PATCH 8/8] stable zfs --- src/home/bash.nix | 16 ++ src/home/default.nix | 38 +++++ src/home/emacs.nix | 8 + src/home/git.nix | 10 ++ src/home/gui/default.nix | 33 +++- src/home/gui/firefox.nix | 14 +- src/home/gui/gnome.nix | 78 ++++++++++ src/home/gui/keyd.nix | 20 +++ src/home/gui/skype.nix | 13 ++ src/home/gui/slack.nix | 13 ++ src/home/gui/vscode.nix | 13 ++ src/home/gui/xdg.nix | 40 +++++ src/home/gui/zathura.nix | 8 + src/home/gui/zoom.nix | 16 ++ src/home/impermanence.nix | 21 ++- src/home/ssh.nix | 13 ++ src/hosts/default.nix | 1 + src/hosts/pickwick/default.nix | 18 ++- src/hosts/pickwick/disko.nix | 17 ++- src/hosts/pickwick/hardware.nix | 31 ++++ src/hosts/pickwick/home.nix | 263 +++++--------------------------- src/nixos/impermanence.nix | 23 +-- src/nixos/users.nix | 1 + 23 files changed, 442 insertions(+), 266 deletions(-) create mode 100644 src/home/bash.nix create mode 100644 src/home/emacs.nix create mode 100644 src/home/git.nix create mode 100644 src/home/gui/gnome.nix create mode 100644 src/home/gui/keyd.nix create mode 100644 src/home/gui/skype.nix create mode 100644 src/home/gui/slack.nix create mode 100644 src/home/gui/vscode.nix create mode 100644 src/home/gui/xdg.nix create mode 100644 src/home/gui/zathura.nix create mode 100644 src/home/gui/zoom.nix create mode 100644 src/home/ssh.nix diff --git a/src/home/bash.nix b/src/home/bash.nix new file mode 100644 index 0000000..239a2e3 --- /dev/null +++ b/src/home/bash.nix @@ -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" + ]; + }; +} diff --git a/src/home/default.nix b/src/home/default.nix index 5ef0475..5e21144 100644 --- a/src/home/default.nix +++ b/src/home/default.nix @@ -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; diff --git a/src/home/emacs.nix b/src/home/emacs.nix new file mode 100644 index 0000000..eb50a68 --- /dev/null +++ b/src/home/emacs.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: + +{ + programs.emacs = { + enable = true; + package = pkgs.emacs; + }; +} diff --git a/src/home/git.nix b/src/home/git.nix new file mode 100644 index 0000000..aaa26a9 --- /dev/null +++ b/src/home/git.nix @@ -0,0 +1,10 @@ +{ lib, pkgs, config, ... }: + +{ + home.packages = with pkgs; [ + git + ]; + # programs.git = { + # enable = true; + # }; +} diff --git a/src/home/gui/default.nix b/src/home/gui/default.nix index 232f6b5..807039c 100644 --- a/src/home/gui/default.nix +++ b/src/home/gui/default.nix @@ -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"; + }; + }; } diff --git a/src/home/gui/firefox.nix b/src/home/gui/firefox.nix index 8c3bc93..f013d51 100644 --- a/src/home/gui/firefox.nix +++ b/src/home/gui/firefox.nix @@ -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" ]; - ]; + }; } diff --git a/src/home/gui/gnome.nix b/src/home/gui/gnome.nix new file mode 100644 index 0000000..92ec3b5 --- /dev/null +++ b/src/home/gui/gnome.nix @@ -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 = [ "f" ]; + unmaximize = [ "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 = [ "q" "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 = "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 = [ "Space" ]; + toggle-float = [ "p" ]; + tile-enter = ["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" + ]; + }; + }; +} diff --git a/src/home/gui/keyd.nix b/src/home/gui/keyd.nix new file mode 100644 index 0000000..7211380 --- /dev/null +++ b/src/home/gui/keyd.nix @@ -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; + }; +} diff --git a/src/home/gui/skype.nix b/src/home/gui/skype.nix new file mode 100644 index 0000000..4ecbe6d --- /dev/null +++ b/src/home/gui/skype.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + home.packages = with pkgs; [ + skypeforlinux + ]; + + custom.persist = { + home.directories = [ + ".config/skypeforlinux" + ]; + }; +} diff --git a/src/home/gui/slack.nix b/src/home/gui/slack.nix new file mode 100644 index 0000000..2d2e5c0 --- /dev/null +++ b/src/home/gui/slack.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + home.packages = with pkgs; [ + slack + ]; + + custom.persist = { + home.directories = [ + ".config/Slack" + ]; + }; +} diff --git a/src/home/gui/vscode.nix b/src/home/gui/vscode.nix new file mode 100644 index 0000000..8d0846d --- /dev/null +++ b/src/home/gui/vscode.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + programs.vscode = { + enable = true; + }; + + custom.persist = { + home.directories = [ + ".config/Code" + ]; + }; +} diff --git a/src/home/gui/xdg.nix b/src/home/gui/xdg.nix new file mode 100644 index 0000000..b667aed --- /dev/null +++ b/src/home/gui/xdg.nix @@ -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" ]; }; + }; + }; +} diff --git a/src/home/gui/zathura.nix b/src/home/gui/zathura.nix new file mode 100644 index 0000000..50023b7 --- /dev/null +++ b/src/home/gui/zathura.nix @@ -0,0 +1,8 @@ +_: + +{ + programs.zathura = { + enable = true; + }; +} + diff --git a/src/home/gui/zoom.nix b/src/home/gui/zoom.nix new file mode 100644 index 0000000..2c0927e --- /dev/null +++ b/src/home/gui/zoom.nix @@ -0,0 +1,16 @@ +{ config, pkgs, ... }: + +{ + home.packages = with pkgs; [ + zoom-us + ]; + + custom.persist = { + home.directories = [ + ".zoom" + ]; + home.files = [ + ".config/zoomus.conf" + ]; + }; +} diff --git a/src/home/impermanence.nix b/src/home/impermanence.nix index 6407386..018bf6e 100644 --- a/src/home/impermanence.nix +++ b/src/home/impermanence.nix @@ -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; + # }; + # }; + }; } diff --git a/src/home/ssh.nix b/src/home/ssh.nix new file mode 100644 index 0000000..b86a2e0 --- /dev/null +++ b/src/home/ssh.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + programs.ssh = { + enable = true; + }; + + custom.persist = { + home.directories = [ + ".ssh" + ]; + }; +} diff --git a/src/hosts/default.nix b/src/hosts/default.nix index bcb9292..674f4ed 100644 --- a/src/hosts/default.nix +++ b/src/hosts/default.nix @@ -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 ]; diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix index 78e97d6..a1e8fa6 100644 --- a/src/hosts/pickwick/default.nix +++ b/src/hosts/pickwick/default.nix @@ -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"; } diff --git a/src/hosts/pickwick/disko.nix b/src/hosts/pickwick/disko.nix index 2b796fb..83e747d 100644 --- a/src/hosts/pickwick/disko.nix +++ b/src/hosts/pickwick/disko.nix @@ -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 = { diff --git a/src/hosts/pickwick/hardware.nix b/src/hosts/pickwick/hardware.nix index 4f09066..bfd6a08 100644 --- a/src/hosts/pickwick/hardware.nix +++ b/src/hosts/pickwick/hardware.nix @@ -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; diff --git a/src/hosts/pickwick/home.nix b/src/hosts/pickwick/home.nix index d1b24f2..2b2c72e 100644 --- a/src/hosts/pickwick/home.nix +++ b/src/hosts/pickwick/home.nix @@ -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/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 = [ "f" ]; - unmaximize = [ "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 = [ "q" "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 = "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 = [ "Space" ]; - toggle-float = [ "p" ]; - tile-enter = ["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/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.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"; }; diff --git a/src/nixos/impermanence.nix b/src/nixos/impermanence.nix index 9956740..aa33aec 100644 --- a/src/nixos/impermanence.nix +++ b/src/nixos/impermanence.nix @@ -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 diff --git a/src/nixos/users.nix b/src/nixos/users.nix index 36aff4a..6245b5e 100644 --- a/src/nixos/users.nix +++ b/src/nixos/users.nix @@ -21,6 +21,7 @@ }; ${user} = { isNormalUser = true; + createHome = true; # initialPassword = "password"; hashedPasswordFile = "/persist/etc/shadow/${user}"; extraGroups = [ -- 2.46.0