From a1bff8dd12c6bfeeb4cd095a2d1c8ff9abae6e91 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Mon, 8 Aug 2022 15:50:54 -0300 Subject: [PATCH] flake: refactor lib a bit, hosts: put more hardware stuff in hardware --- flake.lock | 36 ++++++++++----------- flake.nix | 40 ++++++------------------ home/misterio/cli/default.nix | 1 - hosts/atlas/default.nix | 1 - hosts/atlas/hardware-configuration.nix | 9 ++++++ hosts/electra/default.nix | 9 +----- hosts/electra/hardware-configuration.nix | 20 +++++++++--- hosts/merope/default.nix | 2 -- hosts/merope/hardware-configuration.nix | 6 +++- hosts/pleione/default.nix | 1 - hosts/pleione/hardware-configuration.nix | 9 ++++++ lib/default.nix | 19 ++++------- modules/home-manager/default.nix | 16 +++++----- modules/nixos/default.nix | 4 +-- overlay/default.nix | 8 ++--- shell.nix | 2 +- 16 files changed, 87 insertions(+), 96 deletions(-) diff --git a/flake.lock b/flake.lock index df385831..540f06dc 100644 --- a/flake.lock +++ b/flake.lock @@ -25,11 +25,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1653594315, - "narHash": "sha256-kJ0ENmnQJ4qL2FeYKZba9kvv1KmIuB3NVpBwMeI7AJQ=", + "lastModified": 1659725433, + "narHash": "sha256-1ZxuK67TL29YLw88vQ18Y2Y6iYg8Jb7I6/HVzmNB6nM=", "owner": "serokell", "repo": "deploy-rs", - "rev": "184349d8149436748986d1bdba087e4149e9c160", + "rev": "41f15759dd8b638e7b4f299730d94d5aa46ab7eb", "type": "github" }, "original": { @@ -108,11 +108,11 @@ "utils": "utils_2" }, "locked": { - "lastModified": 1659484873, - "narHash": "sha256-6VoPiGyDdjBHOJ3IpS24lY1lrDiOHeuEefOFI0qz3WE=", + "lastModified": 1659978484, + "narHash": "sha256-VkErPc8pXcuFQG7jkkaUOEMORe81oweRNlAYZJ2+aRI=", "owner": "nix-community", "repo": "home-manager", - "rev": "d8d9ff0b2df77defa10375c6665b51f0251c34d6", + "rev": "c1addfdad3825f75a66f8d73ec7d2f68c78ba6f8", "type": "github" }, "original": { @@ -129,11 +129,11 @@ "wlroots": "wlroots" }, "locked": { - "lastModified": 1659475258, - "narHash": "sha256-ceVRZAq625ZHB3TUXfO5UxYjm0VC61azTb5eocbfcCo=", + "lastModified": 1659900450, + "narHash": "sha256-0gdviZ46VCUAOA0PJNvddgQJQqKnm5theFftSux6L04=", "owner": "hyprwm", "repo": "hyprland", - "rev": "d3c96c248cb556f51f89420aa46e8242746b9a29", + "rev": "9532ff42871615d3293f5fb679282e3423ff380d", "type": "github" }, "original": { @@ -198,11 +198,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1659305579, - "narHash": "sha256-SFeQTmh7hc9Y2fSkooHaoS8mDfPa04sfmUCtQ8MA6Pg=", + "lastModified": 1659889440, + "narHash": "sha256-O8+FsHZzQIqjQjuh+VXbJtGrpPswm5ta2Z/eo72Lz2U=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5857574d45925585baffde730369414319228a84", + "rev": "4bdf4169ad2896236895ca607a843f30c9680345", "type": "github" }, "original": { @@ -245,11 +245,11 @@ }, "nur": { "locked": { - "lastModified": 1659483824, - "narHash": "sha256-dJutEz8UQBi+g9GMBPJXnx54xn0Ow1a/JGV9Gxd9jpw=", + "lastModified": 1659979714, + "narHash": "sha256-9DCdRQvaQwMBln4S/YJTQ2ODnuwFkQlHRkXBIqM7SM4=", "owner": "nix-community", "repo": "NUR", - "rev": "3902a6de021f928e2d0f4b71565853507a525bd1", + "rev": "9885d9a250a732cefceed2c304f976c471226ab8", "type": "github" }, "original": { @@ -388,11 +388,11 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1658770113, - "narHash": "sha256-VBq9vw0hvQPKGKLNKLJS8xsUHvrX0o2LUDBVolixenE=", + "lastModified": 1659738224, + "narHash": "sha256-bV3TLiCgptpKoUKLiH/5RMtiIsfn0hawdaCEHQFB6WY=", "owner": "wlroots", "repo": "wlroots", - "rev": "7b5e890e61a27375725068a7d1884b26851b3102", + "rev": "3baf2a6bcfc4cb86c364f5724aaec80f28715a01", "type": "gitlab" }, "original": { diff --git a/flake.nix b/flake.nix index e211a4a3..d14dacc3 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ outputs = inputs: let lib = import ./lib { inherit inputs; }; - inherit (lib) mkSystem mkHome mkDeploys importAttrset forAllSystems; + inherit (lib) mkSystem mkHome mkDeploys forAllSystems; in rec { inherit lib; @@ -54,7 +54,6 @@ overlays = { default = import ./overlay { inherit inputs; }; nur = inputs.nur.overlay; - deploy-rs = inputs.deploy-rs.overlay; peerix = inputs.peerix.overlay; sops-nix = inputs.sops-nix.overlay; hyprland = inputs.hyprland.overlays.default; @@ -62,8 +61,8 @@ paste-misterio-me = inputs.paste-misterio-me.overlay; }; - nixosModules = importAttrset ./modules/nixos; - homeManagerModules = importAttrset ./modules/home-manager; + nixosModules = import ./modules/nixos; + homeManagerModules = import ./modules/home-manager; templates = import ./templates; @@ -74,7 +73,7 @@ apps = forAllSystems (system: rec { deploy = { type = "app"; - program = "${legacyPackages.${system}.deploy-rs.deploy-rs}/bin/deploy"; + program = "${legacyPackages.${system}.deploy-rs}/bin/deploy"; }; default = deploy; }); @@ -91,25 +90,25 @@ # Desktop atlas = mkSystem { hostname = "atlas"; - system = "x86_64-linux"; + pkgs = legacyPackages."x86_64-linux"; persistence = true; }; # Laptop pleione = mkSystem { hostname = "pleione"; - system = "x86_64-linux"; + pkgs = legacyPackages."x86_64-linux"; persistence = true; }; # Raspi 4 merope = mkSystem { hostname = "merope"; - system = "aarch64-linux"; + pkgs = legacyPackages."aarch64-linux"; persistence = true; }; - # Vultr VPS + # VPS electra = mkSystem { hostname = "electra"; - system = "x86_64-linux"; + pkgs = legacyPackages."x86_64-linux"; persistence = true; }; }; @@ -158,27 +157,6 @@ colorscheme = "solarflare"; }; - - # Generic configs - "misterio@generic" = mkHome { - username = "misterio"; - system = "x86_64-linux"; - - colorscheme = "dracula"; - }; - "misterio@generic-graphical" = mkHome { - username = "misterio"; - system = "x86_64-linux"; - - features = [ "desktop/gnome" ]; - colorscheme = "dracula"; - }; - - # GELOS lab computers - "misterio@emperor" = homeConfigurations."misterio@generic"; - "misterio@galapagos" = homeConfigurations."misterio@generic"; - "misterio@macaroni" = homeConfigurations."misterio@generic-graphical"; - "misterio@rockhopper" = homeConfigurations."misterio@generic-graphical"; }; deploy.nodes = mkDeploys nixosConfigurations homeConfigurations; diff --git a/home/misterio/cli/default.nix b/home/misterio/cli/default.nix index ae931944..4b264af4 100644 --- a/home/misterio/cli/default.nix +++ b/home/misterio/cli/default.nix @@ -29,7 +29,6 @@ jq # JSON pretty printer and manipulator trekscii # Cute startrek cli printer - deploy-rs.deploy-rs # Deployment tool sops # Deployment secrets tool nvd nix-diff # Check derivation differences rnix-lsp # Nix LSP diff --git a/hosts/atlas/default.nix b/hosts/atlas/default.nix index 68e69e17..b8430baf 100644 --- a/hosts/atlas/default.nix +++ b/hosts/atlas/default.nix @@ -17,7 +17,6 @@ ../common/optional/quietboot.nix ../common/optional/starcitizen-fixes.nix ../common/optional/steam.nix - ../common/optional/systemd-boot.nix ../common/optional/tailscale.nix ]; diff --git a/hosts/atlas/hardware-configuration.nix b/hosts/atlas/hardware-configuration.nix index 29f73c80..cbb1e904 100644 --- a/hosts/atlas/hardware-configuration.nix +++ b/hosts/atlas/hardware-configuration.nix @@ -9,6 +9,13 @@ availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; kernelModules = [ "kvm-amd" ]; }; + loader = { + systemd-boot = { + enable = true; + consoleMode = "max"; + }; + efi.canTouchEfiVariables = true; + }; }; fileSystems = { @@ -18,4 +25,6 @@ }; }; + nixpkgs.hostPlatform.system = "x86_64-linux"; + } diff --git a/hosts/electra/default.nix b/hosts/electra/default.nix index 2c4ac194..e1d6c597 100644 --- a/hosts/electra/default.nix +++ b/hosts/electra/default.nix @@ -8,14 +8,7 @@ ./services ]; - boot = { - loader.grub = { - enable = true; - version = 2; - device = "/dev/vda"; - }; - }; - + networking.useDHCP = true; system.stateVersion = "22.05"; } diff --git a/hosts/electra/hardware-configuration.nix b/hosts/electra/hardware-configuration.nix index be5b972d..697cde33 100644 --- a/hosts/electra/hardware-configuration.nix +++ b/hosts/electra/hardware-configuration.nix @@ -1,16 +1,26 @@ -{ config, lib, ... }: - { imports = [ ../common/optional/btrfs-optin-persistence.nix ]; - boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; - networking.useDHCP = lib.mkDefault true; + boot = { + initrd = { + availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; + }; + loader = { + grub = { + enable = true; + version = 2; + device = "/dev/vda"; + }; + }; + }; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = true; virtualisation.hypervGuest.enable = true; systemd.services.hv-kvp.unitConfig.ConditionPathExists = [ "/dev/vmbus/hv_kvp" ]; + + nixpkgs.hostPlatform.system = "x86_64-linux"; } diff --git a/hosts/merope/default.nix b/hosts/merope/default.nix index 9574756f..6922c32a 100644 --- a/hosts/merope/default.nix +++ b/hosts/merope/default.nix @@ -30,8 +30,6 @@ }; }; - boot.loader.timeout = 5; - # Enable argonone fan daemon services.hardware.argonone.enable = true; diff --git a/hosts/merope/hardware-configuration.nix b/hosts/merope/hardware-configuration.nix index aad1f07f..68b3a82c 100644 --- a/hosts/merope/hardware-configuration.nix +++ b/hosts/merope/hardware-configuration.nix @@ -1,12 +1,14 @@ { imports = [ - ../common/optional/btrfs-optin-persistence.nix + ../common/optional/btrfs-optin-persistence.nix ]; + boot = { initrd = { availableKernelModules = [ "xhci_pci" ]; }; + loader.timeout = 5; }; fileSystems = { @@ -27,5 +29,7 @@ }; }; + nixpkgs.hostPlatform.system = "aarch64-linux"; + powerManagement.cpuFreqGovernor = "ondemand"; } diff --git a/hosts/pleione/default.nix b/hosts/pleione/default.nix index a192d556..4cc99175 100644 --- a/hosts/pleione/default.nix +++ b/hosts/pleione/default.nix @@ -14,7 +14,6 @@ ../common/optional/postgres.nix ../common/optional/quietboot.nix ../common/optional/steam.nix - ../common/optional/systemd-boot.nix ../common/optional/tailscale.nix ]; diff --git a/hosts/pleione/hardware-configuration.nix b/hosts/pleione/hardware-configuration.nix index 01c3c9e9..eb38635d 100644 --- a/hosts/pleione/hardware-configuration.nix +++ b/hosts/pleione/hardware-configuration.nix @@ -9,6 +9,13 @@ availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "sd_mod" ]; kernelModules = [ "kvm-amd" ]; }; + loader = { + systemd-boot = { + enable = true; + consoleMode = "max"; + }; + efi.canTouchEfiVariables = true; + }; }; fileSystems = { @@ -18,5 +25,7 @@ }; }; + nixpkgs.hostPlatform.system = "x86_64-linux"; + powerManagement.cpuFreqGovernor = "powersave"; } diff --git a/lib/default.nix b/lib/default.nix index 7084a9e3..7902a6d7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -27,42 +27,35 @@ rec { ]; forAllSystems = genAttrs systems; - importAttrset = path: mapAttrs (_: import) (import path); - mkSystem = { hostname - , system + , pkgs , persistence ? false }: nixosSystem { - inherit system; - pkgs = outputs.legacyPackages.${system}; + inherit pkgs; specialArgs = { inherit inputs outputs hostname persistence; }; - modules = attrValues (import ../modules/nixos) ++ [ - ../hosts/${hostname} - ]; + modules = attrValues (import ../modules/nixos) ++ [ ../hosts/${hostname} ]; }; mkHome = { username , hostname ? null - , system ? outputs.nixosConfigurations.${hostname}.pkgs.system + , pkgs ? outputs.nixosConfigurations.${hostname}.pkgs , persistence ? false , colorscheme ? null , wallpaper ? null , features ? [ ] }: homeManagerConfiguration { - pkgs = outputs.legacyPackages.${system}; + inherit pkgs; extraSpecialArgs = { inherit inputs outputs hostname username persistence colorscheme wallpaper features; }; - modules = attrValues (import ../modules/home-manager) ++ [ - ../home/${username} - ]; + modules = attrValues (import ../modules/home-manager) ++ [ ../home/${username} ]; }; mkDeploys = nixosConfigs: homeConfigs: diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index dd295735..7556e313 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,10 +1,10 @@ { - afuse = ./afuse.nix; - rgbdaemon = ./rgbdaemon.nix; - wallpaper = ./wallpaper.nix; - shellcolor = ./shellcolor.nix; - fonts = ./fonts.nix; - preferred-apps = ./preferred-apps.nix; - swaylock = ./swaylock.nix; - xpo = ./xpo.nix; + afuse = import ./afuse.nix; + rgbdaemon = import ./rgbdaemon.nix; + wallpaper = import ./wallpaper.nix; + shellcolor = import ./shellcolor.nix; + fonts = import ./fonts.nix; + preferred-apps = import ./preferred-apps.nix; + swaylock = import ./swaylock.nix; + xpo = import ./xpo.nix; } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index e9a4c35e..f4353d02 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,4 +1,4 @@ { - openrgb = ./openrgb.nix; - satisfactory = ./satisfactory.nix; + openrgb = import ./openrgb.nix; + satisfactory = import ./satisfactory.nix; } diff --git a/overlay/default.nix b/overlay/default.nix index c1e71bf7..b9c0c911 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -1,7 +1,7 @@ { inputs, ... }: let # Adds my custom packages - additions = final: prev: import ../pkgs { pkgs = prev; }; + additions = final: _prev: import ../pkgs { pkgs = final; }; # Modifies existing packages modifications = final: prev: { @@ -15,14 +15,14 @@ let vim-nix = prev.vimPlugins.vim-nix.overrideAttrs (_oldAttrs: rec { version = "2022-02-20"; - src = prev.fetchFromGitHub { + src = final.fetchFromGitHub { owner = "hqurve"; repo = "vim-nix"; rev = "26abd9cb976b5f4da6da02ee81449a959027b958"; sha256 = "sha256-7TDW6Dgy/H7PRrIvTMpmXO5/3K5F1d4p3rLYon6h6OU="; }; }); - } // import ../pkgs/vim-plugins { pkgs = prev; }; + } // import ../pkgs/vim-plugins { pkgs = final; }; # Don't launch discord when using discocss discocss = prev.discocss.overrideAttrs (oldAttrs: rec { @@ -44,7 +44,7 @@ let pfetch = prev.pfetch.overrideAttrs (oldAttrs: { version = "unstable-2021-12-10"; - src = prev.fetchFromGitHub { + src = final.fetchFromGitHub { owner = "dylanaraps"; repo = "pfetch"; rev = "a906ff89680c78cec9785f3ff49ca8b272a0f96b"; diff --git a/shell.nix b/shell.nix index 0c635112..cd6081e2 100644 --- a/shell.nix +++ b/shell.nix @@ -8,7 +8,7 @@ mkShell { # Para deploy gnupg age - deploy-rs.deploy-rs + deploy-rs sops ]; }