impermanence module and home-manager

This commit is contained in:
samual.shop@proton.me 2024-05-17 00:07:42 +00:00
parent f90f7cf8a4
commit 07f064e4fd
8 changed files with 100 additions and 17 deletions

View File

@ -7,11 +7,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1715756862, "lastModified": 1715872464,
"narHash": "sha256-cNGZK/RNvb29giR2KtnbwU5lx2Kw+wWqAaeWqfYlPts=", "narHash": "sha256-mkZ3hrPG7d+qL7B6pQcrNfPh2mnQEJR3FHK93qCp6Uk=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "cb1d6fba694ab3887600d606106f5a044ba1712c", "rev": "5f6dbcce99d60dd77f96dfc66d06bbea149a40e1",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -40,6 +40,21 @@
"type": "github" "type": "github"
} }
}, },
"impermanence": {
"locked": {
"lastModified": 1708968331,
"narHash": "sha256-VUXLaPusCBvwM3zhGbRIJVeYluh2uWuqtj4WirQ1L9Y=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "a33ef102a02ce77d3e39c25197664b7a636f9c30",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "impermanence",
"type": "github"
}
},
"nix-secrets": { "nix-secrets": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -86,11 +101,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1715534503, "lastModified": 1715787315,
"narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", "narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2057814051972fa1453ddfb0d98badbea9b83c06", "rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -104,6 +119,7 @@
"inputs": { "inputs": {
"disko": "disko", "disko": "disko",
"home-manager": "home-manager", "home-manager": "home-manager",
"impermanence": "impermanence",
"nix-secrets": "nix-secrets", "nix-secrets": "nix-secrets",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",

View File

@ -17,6 +17,10 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
impermanence = {
url = "github:nix-community/impermanence";
};
# Secrets management # Secrets management
sops-nix = { sops-nix = {
url = "github:mic92/sops-nix"; url = "github:mic92/sops-nix";
@ -34,6 +38,7 @@
nixpkgs, nixpkgs,
home-manager, home-manager,
disko, disko,
#impermanence,
... ...
} @ inputs: } @ inputs:
let let
@ -73,19 +78,16 @@
bootstrap = nixpkgs.lib.nixosSystem { bootstrap = nixpkgs.lib.nixosSystem {
inherit specialArgs; inherit specialArgs;
modules = [ modules = [
#disko.nixosModules.disko
#./hosts/common/disks/gpt-bios-compact.nix
#./hosts/common/disks/std-disk-config.nix
./hosts/bootstrap ./hosts/bootstrap
]; ];
}; };
media = nixpkgs.lib.nixosSystem { media = nixpkgs.lib.nixosSystem {
inherit specialArgs; inherit specialArgs;
modules = [ modules = [
#disko.nixosModules.disko
#./hosts/common/disks/gpt-bios-compact.nix
#./hosts/common/disks/std-disk-config.nix
./hosts/media ./hosts/media
home-manager.nixosModules.home-manager{
home-manager.extraSpecialArgs = specialArgs;
}
]; ];
}; };
}; };

View File

@ -14,3 +14,4 @@
# Import users # Import users
./users/media ./users/media
]; ];
}

View File

@ -1,4 +1,4 @@
{ config, pkgs, lib, outputs, ... }: { config, pkgs, lib, outputs, inputs, ... }:
{ {
home.username = "media"; home.username = "media";
@ -6,6 +6,7 @@
home.stateVersion = "23.11"; home.stateVersion = "23.11";
imports = [ imports = [
inputs.impermanence.nixosModules.home-manager.impermanence
] ++ (builtins.attrValues outputs.homeManagerModules); # import all homeManagerModules? ] ++ (builtins.attrValues outputs.homeManagerModules); # import all homeManagerModules?
home.packages = [ home.packages = [
@ -32,6 +33,13 @@
''; '';
}; };
home.persistence."/persist/home" = {
directories = [
".gnupg"
".ssh"
];
allowOther = true;
};
home.file = { home.file = {
}; };

View File

@ -24,4 +24,6 @@ boot.initrd.postDeviceCommands = lib.mkAfter ''
btrfs subvolume create /btrfs_tmp/root btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp umount /btrfs_tmp
''; '';
} }

View File

@ -1,6 +1,7 @@
{ pkgs, inputs, config, lib, ... }: { pkgs, inputs, config, lib, ... }:
let let
pubKeys = lib.filesystem.listFilesRecursive (../keys); pubKeys = lib.filesystem.listFilesRecursive (../keys);
hostname = config.networking.hostName;
in in
{ {
users.users.media = { users.users.media = {
@ -18,6 +19,14 @@ in
}; };
programs.zsh.enable = true; programs.zsh.enable = true;
programs.fuse.userAllowOther = true;
#home-manager.users.sam =
home-manager = {
extraSpecialArgs = { inherit inputs; };
users = {
media = import ../../../../home/${hostname}.nix;
};
};
environment.systemPackages = [ environment.systemPackages = [
]; ];

View File

@ -4,9 +4,10 @@
imports = imports =
[ [
# Disk configuration # Disk configuration
inputs.disko.nixosModules.disko #inputs.disko.nixosModules.disko
(import ../common/disks/std-disk-config.nix { device = "/dev/vda"; }) #(import ../common/disks/std-disk-config.nix { device = "/dev/vda"; })
../common/optional/btrfs-impermanence.nix ../common/optional/btrfs-impermanence.nix
inputs.impermanence.nixosModules.impermanence
# Import core options # Import core options
./hardware-configuration.nix ./hardware-configuration.nix
@ -17,6 +18,18 @@
]; ];
fileSystems."/persist".neededForBoot = true;
environment.persistence."/persist/system" = {
hideMounts = true;
directories = [
"/etc/nixos"
"/var/log"
"/var/lib/nixos"
"/var/lib/systemd/coredump"
"/etc/NetworkManager/system-connections"
];
};
nixpkgs = { nixpkgs = {
overlays = [ overlays = [
outputs.overlays.additions outputs.overlays.additions

View File

@ -9,10 +9,42 @@
]; ];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/d6657061-a847-49f8-9219-f9e668fe34aa";
fsType = "btrfs";
options = [ "subvol=root" ];
};
fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/d6657061-a847-49f8-9219-f9e668fe34aa";
fsType = "btrfs";
options = [ "subvol=nix" ];
};
fileSystems."/.swapvol" =
{ device = "/dev/disk/by-uuid/d6657061-a847-49f8-9219-f9e668fe34aa";
fsType = "btrfs";
options = [ "subvol=swap" ];
};
fileSystems."/persist" =
{ device = "/dev/disk/by-uuid/d6657061-a847-49f8-9219-f9e668fe34aa";
fsType = "btrfs";
options = [ "subvol=persist" ];
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/7619-58F2";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction # still possible to use this option, but it's recommended to use it in conjunction