From 75b442acb64bac70294681ae6d318a470afeac3c Mon Sep 17 00:00:00 2001 From: ene Date: Sat, 4 Feb 2023 11:54:55 +0100 Subject: Feat: Made more configuration host independent --- flake.lock | 18 +++--- hosts/IDOHVE/hardware/boot.nix | 32 ----------- hosts/IDOHVE/hardware/boot_pictures/gnu.png | Bin 327518 -> 0 bytes .../IDOHVE/hardware/boot_pictures/gnulin_emb_1.png | Bin 207444 -> 0 bytes .../IDOHVE/hardware/boot_pictures/gnulin_emb_2.png | Bin 208347 -> 0 bytes hosts/IDOHVE/hardware/filesystems.nix | 41 -------------- hosts/IDOHVE/hardware/hardware.nix | 15 ++++- system/boot/boot.nix | 28 ++++++++++ system/boot/boot_pictures/gnu.png | Bin 0 -> 327518 bytes system/boot/boot_pictures/gnulin_emb_1.png | Bin 0 -> 207444 bytes system/boot/boot_pictures/gnulin_emb_2.png | Bin 0 -> 208347 bytes system/filesystemLayouts/filesystemLayouts.nix | 62 +++++++++++++++++++++ system/system.nix | 6 +- 13 files changed, 116 insertions(+), 86 deletions(-) delete mode 100644 hosts/IDOHVE/hardware/boot.nix delete mode 100755 hosts/IDOHVE/hardware/boot_pictures/gnu.png delete mode 100755 hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_1.png delete mode 100755 hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_2.png delete mode 100644 hosts/IDOHVE/hardware/filesystems.nix create mode 100644 system/boot/boot.nix create mode 100755 system/boot/boot_pictures/gnu.png create mode 100755 system/boot/boot_pictures/gnulin_emb_1.png create mode 100755 system/boot/boot_pictures/gnulin_emb_2.png create mode 100644 system/filesystemLayouts/filesystemLayouts.nix diff --git a/flake.lock b/flake.lock index 1bfa3e99..9b757473 100644 --- a/flake.lock +++ b/flake.lock @@ -6,11 +6,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1675247113, - "narHash": "sha256-+YcXjfCP4hNu8A68b/UoXFCTDwKLuLV+x/7dQnM5U/o=", + "lastModified": 1675462931, + "narHash": "sha256-JiOUSERBtA1lN/s9YTKGZoZ3XUicHDwr+C8swaPSh3M=", "owner": "nix-community", "repo": "home-manager", - "rev": "782cb855b2f23c485011a196c593e2d7e4fce746", + "rev": "e2c1756e3ae001ca8696912016dd31cb1503ccf3", "type": "github" }, "original": { @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1674211260, - "narHash": "sha256-xU6Rv9sgnwaWK7tgCPadV6HhI2Y/fl4lKxJoG2+m9qs=", + "lastModified": 1675115703, + "narHash": "sha256-4zetAPSyY0D77x+Ww9QBe8RHn1akvIvHJ/kgg8kGDbk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5ed481943351e9fd354aeb557679624224de38d5", + "rev": "2caf4ef5005ecc68141ecb4aac271079f7371c44", "type": "github" }, "original": { @@ -38,11 +38,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1675183161, - "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", + "lastModified": 1675362331, + "narHash": "sha256-VmcnKPj5gJLxWK7Bxlhg2LoQvhKRss7Ax+uoFjd3qKY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", + "rev": "a100acd7bbf105915b0004427802286c37738fef", "type": "github" }, "original": { diff --git a/hosts/IDOHVE/hardware/boot.nix b/hosts/IDOHVE/hardware/boot.nix deleted file mode 100644 index 4cd94191..00000000 --- a/hosts/IDOHVE/hardware/boot.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - config, - pkgs, - ... -}: { - boot = { - initrd = { - compressor = "lz4"; - compressorArgs = ["-9"]; - - # TODO check this: - availableKernelModules = ["xhci_pci" "nvme" "rtsx_pci_sdmmc"]; - }; - - kernelModules = ["kvm-amd"]; - kernelPackages = pkgs.linuxPackages_latest; - loader = { - grub = { - enable = true; - version = 2; - theme = pkgs.nixos-grub2-theme; - splashImage = ./boot_pictures/gnu.png; - efiSupport = true; - device = "nodev"; # only for efi - }; - efi = { - canTouchEfiVariables = true; - efiSysMountPoint = "/boot"; - }; - }; - }; -} diff --git a/hosts/IDOHVE/hardware/boot_pictures/gnu.png b/hosts/IDOHVE/hardware/boot_pictures/gnu.png deleted file mode 100755 index d07dee3e..00000000 Binary files a/hosts/IDOHVE/hardware/boot_pictures/gnu.png and /dev/null differ diff --git a/hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_1.png b/hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_1.png deleted file mode 100755 index 483f2681..00000000 Binary files a/hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_1.png and /dev/null differ diff --git a/hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_2.png b/hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_2.png deleted file mode 100755 index 48cd6ad7..00000000 Binary files a/hosts/IDOHVE/hardware/boot_pictures/gnulin_emb_2.png and /dev/null differ diff --git a/hosts/IDOHVE/hardware/filesystems.nix b/hosts/IDOHVE/hardware/filesystems.nix deleted file mode 100644 index a188df18..00000000 --- a/hosts/IDOHVE/hardware/filesystems.nix +++ /dev/null @@ -1,41 +0,0 @@ -{config, ...}: let - main_disk = "/dev/disk/by-uuid/"; -in { - fileSystems = { - "/" = { - device = "none"; - fsType = "tmpfs"; - options = ["defaults" "size=2G" "mode=755"]; - }; - "/nix" = { - device = main_disk; - fsType = "btrfs"; - options = ["subvol=@nix" "compress-force=zstd:9"]; - }; - "/boot" = { - device = "/dev/disk/by-uuid/"; - fsType = "vfat"; - }; - - "/srv/home" = { - device = main_disk; - fsType = "btrfs"; - options = ["subvol=@home" "compress-force=zstd:9"]; - }; - "/srv/nixos-config" = { - device = main_disk; - fsType = "btrfs"; - options = ["subvol=@nixos-config" "compress-force=zstd:9"]; - }; - - "/etc/nixos" = { - device = "/srv/nix-config"; - options = ["bind"]; - }; - "/home" = { - device = "/srv/home"; - options = ["bind"]; - }; - }; - swapDevices = []; -} diff --git a/hosts/IDOHVE/hardware/hardware.nix b/hosts/IDOHVE/hardware/hardware.nix index 2d21ce8a..c36b7062 100644 --- a/hosts/IDOHVE/hardware/hardware.nix +++ b/hosts/IDOHVE/hardware/hardware.nix @@ -9,9 +9,20 @@ (modulesPath + "/installer/scan/not-detected.nix") # TODO is this necessary? ./cpu.nix ./gpu.nix - ./boot.nix - ./filesystems.nix ]; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + + system.filesystemLayouts = { + enable = true; + mainDisk = "/dev/disk/by-uuid/"; + efiDisk = "/dev/disk/by-uuid/"; + }; + + boot = { + kernelModules = ["kvm-amd"]; + + # TODO check this: + initrd.availableKernelModules = ["xhci_pci" "nvme" "rtsx_pci_sdmmc"]; + }; } diff --git a/system/boot/boot.nix b/system/boot/boot.nix new file mode 100644 index 00000000..629e63ae --- /dev/null +++ b/system/boot/boot.nix @@ -0,0 +1,28 @@ +{ + config, + pkgs, + ... +}: { + boot = { + initrd = { + compressor = "lz4"; + compressorArgs = ["-9"]; + }; + + kernelPackages = pkgs.linuxPackages_latest; + loader = { + grub = { + enable = true; + version = 2; + theme = pkgs.nixos-grub2-theme; + splashImage = ./boot_pictures/gnu.png; + efiSupport = true; + device = "nodev"; # only for efi + }; + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + }; + }; +} diff --git a/system/boot/boot_pictures/gnu.png b/system/boot/boot_pictures/gnu.png new file mode 100755 index 00000000..d07dee3e Binary files /dev/null and b/system/boot/boot_pictures/gnu.png differ diff --git a/system/boot/boot_pictures/gnulin_emb_1.png b/system/boot/boot_pictures/gnulin_emb_1.png new file mode 100755 index 00000000..483f2681 Binary files /dev/null and b/system/boot/boot_pictures/gnulin_emb_1.png differ diff --git a/system/boot/boot_pictures/gnulin_emb_2.png b/system/boot/boot_pictures/gnulin_emb_2.png new file mode 100755 index 00000000..48cd6ad7 Binary files /dev/null and b/system/boot/boot_pictures/gnulin_emb_2.png differ diff --git a/system/filesystemLayouts/filesystemLayouts.nix b/system/filesystemLayouts/filesystemLayouts.nix new file mode 100644 index 00000000..2f7c8fc2 --- /dev/null +++ b/system/filesystemLayouts/filesystemLayouts.nix @@ -0,0 +1,62 @@ +{ + config, + lib, + ... +}: +with lib; let + cfg = config.system.filesystemLayout; +in { + options = { + cfg.enable = mkEnableOption (mdDoc "filesysetemLayout"); + cfg.mainDisk = mkOption { + type = lib.types.path; + example = literalExpression "/dev/disk/by-uuid/0442cb6d-f13a-4635-b487-fa76189774c5"; + description = lib.mdDoc "Path to the main disk"; + }; + cfg.efiDisk = mkOption { + type = lib.types.path; + example = literalExpression "/dev/disk/by-uuid/5143-6136"; + description = lib.mdDoc "Path to the main disk"; + }; + }; + + config = mkif cfg.enabled { + fileSystems = { + "/" = { + device = "none"; + fsType = "tmpfs"; + options = ["defaults" "size=2G" "mode=755"]; + }; + "/nix" = { + device = cfg.mainDisk; + fsType = "btrfs"; + options = ["subvol=@nix" "compress-force=zstd:9"]; + }; + "/boot" = { + device = cfg.efiDisk; + fsType = "vfat"; + }; + + "/srv/home" = { + device = cfg.mainDisk; + fsType = "btrfs"; + options = ["subvol=@home" "compress-force=zstd:9"]; + }; + "/srv/nixos-config" = { + device = cfg.mainDisk; + fsType = "btrfs"; + options = ["subvol=@nixos-config" "compress-force=zstd:9"]; + }; + + "/etc/nixos" = { + device = "/srv/nix-config"; + options = ["bind"]; + }; + "/home" = { + device = "/srv/home"; + options = ["bind"]; + }; + }; + swapDevices = []; + }; +} diff --git a/system/system.nix b/system/system.nix index 3a034742..17e78968 100644 --- a/system/system.nix +++ b/system/system.nix @@ -1,8 +1,10 @@ {config, ...}: { imports = [ + ./boot/boot.nix + ./filesystemLayouts/filesystemLayouts.nix ./locale/locale.nix - ./users/users.nix - ./sound/sound.nix ./packages/packages.nix + ./sound/sound.nix + ./users/users.nix ]; } -- cgit 1.4.1