use zfs as snapshot #1

Merged
rayandrew merged 8 commits from zfs into main 2024-10-26 21:07:15 -05:00
6 changed files with 75 additions and 51 deletions
Showing only changes of commit a8366161d4 - Show all commits

View file

@ -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"
}

View file

@ -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:

View file

@ -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

View file

@ -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;

View file

@ -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 = {

View file

@ -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;
}