zfs init
This commit is contained in:
parent
0134929339
commit
3b50015cb9
12 changed files with 344 additions and 239 deletions
|
|
@ -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
|
||||
|
|
|
|||
96
disko.nix
96
disko.nix
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
72
flake.nix
72
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
|
||||
# ];
|
||||
# };
|
||||
# };
|
||||
}
|
||||
|
|
|
|||
44
src/home/default.nix
Normal file
44
src/home/default.nix
Normal file
|
|
@ -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"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
9
src/home/gui/1password.nix
Normal file
9
src/home/gui/1password.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
custom.persist = {
|
||||
home.directories = [
|
||||
".config/1Password"
|
||||
];
|
||||
};
|
||||
}
|
||||
6
src/home/gui/default.nix
Normal file
6
src/home/gui/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
_: {
|
||||
imports = [
|
||||
./firefox.nix
|
||||
./1password.nix
|
||||
];
|
||||
}
|
||||
41
src/home/gui/firefox.nix
Normal file
41
src/home/gui/firefox.nix
Normal file
|
|
@ -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"
|
||||
];
|
||||
];
|
||||
}
|
||||
63
src/hosts/default.nix
Normal file
63
src/hosts/default.nix
Normal file
|
|
@ -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" { };
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
||||
108
src/hosts/pickwick/disko.nix
Normal file
108
src/hosts/pickwick/disko.nix
Normal file
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -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" ];
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
||||
Loading…
Reference in a new issue