Major rework in progress
This commit is contained in:
12
system/configuration/default.nix
Normal file
12
system/configuration/default.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ config, lib, pkgs, ... }: {
|
||||
|
||||
imports = [
|
||||
./generic
|
||||
./laptop
|
||||
./homebox
|
||||
];
|
||||
|
||||
sysconfig.laptop.enable = lib.mkDefault false;
|
||||
sysconfig.homebox.enable = lib.mkDefault false;
|
||||
sysconfig.generic.enable = lib.mkDefault true;
|
||||
}
|
||||
1
system/configuration/generic/default.nix
Normal file
1
system/configuration/generic/default.nix
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
1
system/configuration/homebox/default.nix
Normal file
1
system/configuration/homebox/default.nix
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
77
system/configuration/laptop/default.nix
Normal file
77
system/configuration/laptop/default.nix
Normal file
@@ -0,0 +1,77 @@
|
||||
# Edit this configuration file to define what should be installed on
|
||||
# your system. Help is available in the configuration.nix(5) man page
|
||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||
|
||||
{ config, lib, pkgs, core_inputs, ... }:
|
||||
|
||||
{
|
||||
|
||||
options = {
|
||||
sysconfig.laptop.enable = lib.mkEnableOption "uses laptop config";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.sysconfig.laptop.enable {
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = !config.sysconfig.homebox.enable;
|
||||
message = "sysconfig laptop conflicts with homebox";
|
||||
}
|
||||
];
|
||||
|
||||
imports = [];
|
||||
|
||||
boot = {
|
||||
loader = {
|
||||
systemd-boot.enable = true;
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
kernelParams = [ "snd-intel-dspcfg.dsp_driver=1" ];
|
||||
};
|
||||
|
||||
hardware = {
|
||||
opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
extraPackages = with pkgs; [
|
||||
nvidia-vaapi-driver
|
||||
];
|
||||
};
|
||||
|
||||
nvidia = {
|
||||
modesetting.enable = true;
|
||||
open = false; #suspend fails with open drivers
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.beta;
|
||||
prime = {
|
||||
intelBusId = "PCI:0:2:0";
|
||||
nvidiaBusId = "PCI:1:0:0";
|
||||
# #sync.enable = true;
|
||||
offload = {
|
||||
enable = true;
|
||||
enableOffloadCmd = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
bluetooth.enable = true;
|
||||
|
||||
pulseaudio.enable = false;
|
||||
};
|
||||
|
||||
networking = {
|
||||
hostName = "laptop";
|
||||
nameservers = [ "1.1.1.1#one.one.one.one" "1.0.0.1#one.one.one.one" ];
|
||||
networkmanager.enable = true;
|
||||
};
|
||||
|
||||
services = {
|
||||
xserver = {
|
||||
enable = true;
|
||||
videoDrivers = [ "nvidia" ];
|
||||
};
|
||||
|
||||
displayManager.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
39
system/configuration/laptop/hardware-configuration.nix
Normal file
39
system/configuration/laptop/hardware-configuration.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
# 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, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{ device = "/dev/disk/by-uuid/78c0964d-c09e-4e31-8a73-eb719d79917a";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" =
|
||||
{ device = "/dev/disk/by-uuid/AE5E-AC86";
|
||||
fsType = "vfat";
|
||||
options = [ "fmask=0022" "dmask=0022" ];
|
||||
};
|
||||
|
||||
swapDevices = [ ];
|
||||
|
||||
# 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
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
36
system/disko/default.nix
Normal file
36
system/disko/default.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ config, lib, devices, ... }: {
|
||||
|
||||
options = {
|
||||
disko = {
|
||||
enable = lib.options.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
impermanent = lib.options.mkOption {
|
||||
default = false;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.disko.enable (lib.mkMerge [
|
||||
|
||||
{
|
||||
imports = [
|
||||
./disko.nix { device = devices.main; }
|
||||
];
|
||||
}
|
||||
|
||||
(lib.mkIf (devices.bonus != null) {
|
||||
imports = [
|
||||
(./disko_bonus.nix { devices = devices.bonus; })
|
||||
];
|
||||
})
|
||||
|
||||
(lib.mkIf config.disko.impermanent {
|
||||
imports = [
|
||||
./impermanent.nix
|
||||
];
|
||||
})
|
||||
]);
|
||||
}
|
||||
72
system/disko/disko.nix
Normal file
72
system/disko/disko.nix
Normal file
@@ -0,0 +1,72 @@
|
||||
{ device ? throw "Set this to your device e.g. /dev/sda", ... }: {
|
||||
|
||||
disko.devices = {
|
||||
disk.main = {
|
||||
inherit device;
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
swap = {
|
||||
size = "4G";
|
||||
content = {
|
||||
type = "swap";
|
||||
resumeDevice = true;
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "root";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "root_vg";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lvm_vg = {
|
||||
root_vg = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
root = {
|
||||
size = "100%FREE";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ];
|
||||
subvolumes = {
|
||||
"/root" = {
|
||||
mountpoint = "/";
|
||||
};
|
||||
"/persist" = {
|
||||
mountOptions = [ "subvol=persist" "noatime" ];
|
||||
mountpoint = "/persist";
|
||||
};
|
||||
"/nix" = {
|
||||
mountOptions = [ "subvol=nix" "noatime" ];
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
43
system/disko/disko_bonus.nix
Normal file
43
system/disko/disko_bonus.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{ devices ? throw "Set this to an attribute set of your devices e.g. { disk1 = \"/dev/sda\"; }", ... }: {
|
||||
|
||||
disko.devices = builtins.mapAttrs (name: device: {
|
||||
disk.${name} = {
|
||||
inherit device;
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
${name} = {
|
||||
name = "${name}";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "$name_vg";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lvm_vg = {
|
||||
"${name}_vg" = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
${name} = {
|
||||
size = "100%FREE";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ];
|
||||
subvolumes = {
|
||||
"/${name}" = {
|
||||
mountOptions = [ "subvol=${name}" "noatime" ];
|
||||
mountpoint = "/${name}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}) devices;
|
||||
}
|
||||
19
system/disko/flake.nix
Normal file
19
system/disko/flake.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
description = "disko config";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
|
||||
disko.url = "github:nix-community/disko";
|
||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { ... }@inputs: {
|
||||
|
||||
module = { config, lib, pkgs, devices, ... }: {
|
||||
imports = [
|
||||
(./default.nix { inherit devices; })
|
||||
inputs.disko.nixosModules.default
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
29
system/disko/impermanent.nix
Normal file
29
system/disko/impermanent.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{ config, lib, ... }: {
|
||||
|
||||
boot.initrd.postDeviceCommands = lib.mkAfter ''
|
||||
mkdir /btrfs_tmp
|
||||
mount /dev/root_vg/root /btrfs_tmp
|
||||
if [[ -e /btrfs_tmp/root ]]; then
|
||||
mkdir -p /btrfs_tmp/old_roots
|
||||
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%d_%H:%M:%S")
|
||||
mv /btrfs_tmp/root "btrfs_tmp/old_roots/$timestamp"
|
||||
fi
|
||||
|
||||
deleteSubvolumeRecursively() {
|
||||
IFS=$'\n'
|
||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||
deleteSubvolumeRecursively "/btrfs_tmp/$i"
|
||||
done;
|
||||
btrfs subvolume delete $1
|
||||
}
|
||||
|
||||
for i in $(find /btrfs_tmp/old_roots -maxdepth 1 -mtime +30); do
|
||||
deleteSubvolumeRecursively "$i"
|
||||
done
|
||||
|
||||
btrfs subvolume create /btrfs_tmp/root
|
||||
umount /btrfs_tmp
|
||||
'';
|
||||
|
||||
config.initialPasswords = lib.mkForce true;
|
||||
}
|
||||
@@ -11,6 +11,10 @@
|
||||
|
||||
prgms.url = "./programs";
|
||||
|
||||
disko.url = "./disko";
|
||||
|
||||
impermanence.url = "./impermanence";
|
||||
|
||||
};
|
||||
|
||||
outputs = { self, ... }@inputs: {
|
||||
@@ -18,6 +22,8 @@
|
||||
nixosModule = { config, lib, pkgs, core_inputs, ... }: {
|
||||
imports = [
|
||||
./configuration/configuration.nix
|
||||
inputs.disko.module
|
||||
inputs.impermanence.module
|
||||
inputs.sddm.module
|
||||
inputs.srvcs.module
|
||||
inputs.pckgs.module
|
||||
|
||||
29
system/impermanence/default.nix
Normal file
29
system/impermanence/default.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{ config, lib, self, ... }: {
|
||||
|
||||
options = {};
|
||||
|
||||
config = lib.mkIf config.disko.impermanent {
|
||||
imports = [
|
||||
self.inputs.impermanence.nixosModules.impermanence
|
||||
];
|
||||
|
||||
fileSystems."/persist".neededForBoot = true;
|
||||
environment.persistence."/persist/system" = {
|
||||
hideMounts = true;
|
||||
directories = [
|
||||
"/etc/nixos"
|
||||
"/etc/shadow"
|
||||
"/var/log"
|
||||
"/var/lib/bluetooth"
|
||||
"/var/lib/nixos"
|
||||
"/var/lib/systemd/coredump"
|
||||
"/etc/NetworkManager/system-connections"
|
||||
];
|
||||
files = [
|
||||
"/etc/machine-id"
|
||||
];
|
||||
};
|
||||
|
||||
programs.fuse.userAllowOther = true;
|
||||
};
|
||||
}
|
||||
10
system/impermanence/flake.nix
Normal file
10
system/impermanence/flake.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
description = "nix impermanence config";
|
||||
|
||||
inputs.impermanence.url = "github:nix-community/impermanence";
|
||||
|
||||
outputs = { self, ... }: {
|
||||
|
||||
module = import ./. { inherit self; };
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user