From e6243b48ba1d9c7be807f22f296c13a6524626c0 Mon Sep 17 00:00:00 2001 From: truxnell <19149206+truxnell@users.noreply.github.com> Date: Mon, 25 Mar 2024 22:51:18 +1100 Subject: [PATCH] chore: hax --- docs/vm/faq.md | 3 ++ nixos/hosts/citadel/default.nix | 5 +- .../hosts/citadel/hardware-configuration.nix | 32 ------------- nixos/hosts/common/optional/fish.nix | 10 ---- nixos/hosts/dns01/default.nix | 1 - nixos/hosts/rickenbacker/default.nix | 1 - nixos/modules/nixos/default.nix | 2 + nixos/modules/nixos/programs/default.nix | 5 ++ .../modules/nixos/programs/shell/default.nix | 5 ++ nixos/modules/nixos/programs/shell/fish.nix | 46 +++++++++++++++++++ nixos/modules/nixos/system/nix.nix | 6 +-- nixos/profiles/global.nix | 12 +++-- nixos/profiles/global/default.nix | 9 ++++ nixos/profiles/global/nix.nix | 2 + nixos/profiles/hw-gaming-desktop.nix | 8 ++++ nixos/profiles/hw-thinkpad-e14-amd.nix | 6 +++ nixos/profiles/role-worstation.nix | 11 +++-- 17 files changed, 104 insertions(+), 60 deletions(-) create mode 100644 docs/vm/faq.md delete mode 100644 nixos/hosts/citadel/hardware-configuration.nix delete mode 100644 nixos/hosts/common/optional/fish.nix create mode 100644 nixos/modules/nixos/programs/default.nix create mode 100644 nixos/modules/nixos/programs/shell/default.nix create mode 100644 nixos/modules/nixos/programs/shell/fish.nix create mode 100644 nixos/profiles/global/default.nix diff --git a/docs/vm/faq.md b/docs/vm/faq.md new file mode 100644 index 0000000..7319a55 --- /dev/null +++ b/docs/vm/faq.md @@ -0,0 +1,3 @@ +## Why not recurse the module folder + +Imports are special in NIX and its important that they are definet at runtime for lazy evaluation - if you do optional/coded imports not everything is avaliable for evaluating. diff --git a/nixos/hosts/citadel/default.nix b/nixos/hosts/citadel/default.nix index 2088616..8b7687a 100644 --- a/nixos/hosts/citadel/default.nix +++ b/nixos/hosts/citadel/default.nix @@ -9,7 +9,6 @@ imports = [ # Common imports - ../common/optional/fish.nix ../common/optional/gnome.nix ../common/optional/editors/vscode ../common/optional/firefox.nix @@ -25,13 +24,13 @@ fileSystems."/" = { - device = "/dev/disk/by-label/701fc943-ede7-41ed-8a53-3cc38fc68fe5"; + device = "/dev/disk/by-uuid/701fc943-ede7-41ed-8a53-3cc38fc68fe5"; fsType = "ext4"; }; fileSystems."/boot" = { - device = "/dev/disk/by-uuid/C634-F571"; + device = "/dev/disk/by-uuid/1D5B-36D3"; fsType = "vfat"; }; diff --git a/nixos/hosts/citadel/hardware-configuration.nix b/nixos/hosts/citadel/hardware-configuration.nix deleted file mode 100644 index 14883d8..0000000 --- a/nixos/hosts/citadel/hardware-configuration.nix +++ /dev/null @@ -1,32 +0,0 @@ -# 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, ... }: - -{ - - - fileSystems."/" = - { - device = "/dev/disk/by-uuid/701fc943-ede7-41ed-8a53-3cc38fc68fe5"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { - device = "/dev/disk/by-uuid/C634-F571"; - fsType = "vfat"; - }; - - 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..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp12s0.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp13s0.useDHCP = lib.mkDefault true; - - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/nixos/hosts/common/optional/fish.nix b/nixos/hosts/common/optional/fish.nix deleted file mode 100644 index e53f255..0000000 --- a/nixos/hosts/common/optional/fish.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - programs.fish = { - enable = true; - vendor = { - completions.enable = true; - config.enable = true; - functions.enable = true; - }; - }; -} diff --git a/nixos/hosts/dns01/default.nix b/nixos/hosts/dns01/default.nix index fb7913a..9298d3e 100644 --- a/nixos/hosts/dns01/default.nix +++ b/nixos/hosts/dns01/default.nix @@ -7,7 +7,6 @@ , ... }: { imports = [ - ../common/optional/fish.nix ../common/optional/monitoring.nix ../common/optional/reboot-required.nix diff --git a/nixos/hosts/rickenbacker/default.nix b/nixos/hosts/rickenbacker/default.nix index 34c9c97..3a99a2c 100644 --- a/nixos/hosts/rickenbacker/default.nix +++ b/nixos/hosts/rickenbacker/default.nix @@ -9,7 +9,6 @@ imports = [ # Common imports - ../common/optional/fish.nix ../common/optional/gnome.nix ../common/optional/editors/vscode ../common/optional/firefox.nix diff --git a/nixos/modules/nixos/default.nix b/nixos/modules/nixos/default.nix index 2ad14a5..916039f 100644 --- a/nixos/modules/nixos/default.nix +++ b/nixos/modules/nixos/default.nix @@ -1,5 +1,7 @@ { imports = [ ./system + ./programs + ]; } diff --git a/nixos/modules/nixos/programs/default.nix b/nixos/modules/nixos/programs/default.nix new file mode 100644 index 0000000..5cf8372 --- /dev/null +++ b/nixos/modules/nixos/programs/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./shell + ]; +} diff --git a/nixos/modules/nixos/programs/shell/default.nix b/nixos/modules/nixos/programs/shell/default.nix new file mode 100644 index 0000000..56cb916 --- /dev/null +++ b/nixos/modules/nixos/programs/shell/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./fish.nix + ]; +} diff --git a/nixos/modules/nixos/programs/shell/fish.nix b/nixos/modules/nixos/programs/shell/fish.nix new file mode 100644 index 0000000..de8316e --- /dev/null +++ b/nixos/modules/nixos/programs/shell/fish.nix @@ -0,0 +1,46 @@ +{ lib +, config +, self +, pkgs +, ... +}: +with lib; +let + cfg = config.mySystem.shell.fish; +in +{ + options.mySystem.shell.fish = + { + enable = mkEnableOption "Fish"; + enablePlugins = mkOption + { + type = lib.types.bool; + description = "If we want to add fish plugins"; + default = true; + + }; + + } + + # Install fish systemwide + config.programs.fish = mkIf cfg.enable { + enable = true; + vendor = { + completions.enable = true; + config.enable = true; + functions.enable = true; + }; +}; + +# Install fish plugins systemwide +config.mySystem.system.packages = with pkgs; mkIf cfg.enable [ +fishPlugins.done +fishPlugins.fzf-fish +fishPlugins.forgit +fishPlugins.hydro +fzf +fishPlugins.grc +grc +]; + +} diff --git a/nixos/modules/nixos/system/nix.nix b/nixos/modules/nixos/system/nix.nix index 22e0d7a..0604425 100644 --- a/nixos/modules/nixos/system/nix.nix +++ b/nixos/modules/nixos/system/nix.nix @@ -17,7 +17,7 @@ in }; gc = { - enabled = mkEnableOption "automatic garbage collection" // { + enable = mkEnableOption "automatic garbage collection" // { default = true; }; persistent = mkOption @@ -35,9 +35,9 @@ in optimise.automatic = cfg.autoOptimiseStore; # automatically garbage collect nix store - gc = mkIf cfg.gc.enabled { + gc = mkIf cfg.gc.enable { # garbage collection - automatic = cfg.gc.enabled; + automatic = cfg.gc.enable; options = "--delete-older-than 30d"; persistent = cfg.gc.persistent; }; diff --git a/nixos/profiles/global.nix b/nixos/profiles/global.nix index f544622..43f1c97 100644 --- a/nixos/profiles/global.nix +++ b/nixos/profiles/global.nix @@ -13,11 +13,7 @@ with lib; imports = [ (modulesPath + "/installer/scan/not-detected.nix") # Generated by nixos-config-generate - ./global/nix.nix - ./global/users.nix - ./global/sops.nix - ./global/nixpkgs.nix - ./global/system.nix + ./global ]; mySystem = { @@ -26,8 +22,14 @@ with lib; time.timeZone = "Australia/Melbourne"; security.increaseWheelLoginLimits = true; system.packages = [ pkgs.bat ]; + + # Lets see if fish everywhere is OK on the pi's + # TODO decide if i drop to bash on pis? + shell.fish.enable = true; + # But wont enable plugins globally, leave them for workstations }; + i18n = { defaultLocale = lib.mkDefault "en_AU.UTF-8"; }; diff --git a/nixos/profiles/global/default.nix b/nixos/profiles/global/default.nix new file mode 100644 index 0000000..506ca28 --- /dev/null +++ b/nixos/profiles/global/default.nix @@ -0,0 +1,9 @@ +{ + imports = [ + ./nix.nix + ./nixpkgs.nix + ./sops.nix + ./system.nix + ./users.nix + ]; +} diff --git a/nixos/profiles/global/nix.nix b/nixos/profiles/global/nix.nix index 2e537a2..f6b767b 100644 --- a/nixos/profiles/global/nix.nix +++ b/nixos/profiles/global/nix.nix @@ -26,6 +26,7 @@ # Substitutions trusted-substituters = [ + "https://cache.garnix.io" "https://nix-community.cachix.org" "https://numtide.cachix.org" ]; @@ -33,6 +34,7 @@ trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE=" + "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ]; # Fallback quickly if substituters are not available. diff --git a/nixos/profiles/hw-gaming-desktop.nix b/nixos/profiles/hw-gaming-desktop.nix index 066b5d0..86cf9c7 100644 --- a/nixos/profiles/hw-gaming-desktop.nix +++ b/nixos/profiles/hw-gaming-desktop.nix @@ -2,12 +2,20 @@ with lib; { + + mySystem.system.packages = with pkgs; [ + ntfs3g + ]; + boot = { initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; kernelModules = [ "kvm-amd" ]; extraModulePackages = [ ]; + # for managing/mounting ntfs + supportedFilesystems = [ "ntfs" ]; + loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; diff --git a/nixos/profiles/hw-thinkpad-e14-amd.nix b/nixos/profiles/hw-thinkpad-e14-amd.nix index 2486db9..678111d 100644 --- a/nixos/profiles/hw-thinkpad-e14-amd.nix +++ b/nixos/profiles/hw-thinkpad-e14-amd.nix @@ -9,6 +9,9 @@ with lib; kernelModules = [ "kvm-amd" ]; extraModulePackages = [ ]; + # for managing/mounting ntfs + supportedFilesystems = [ "ntfs" ]; + loader = { systemd-boot.enable = true; efi.canTouchEfiVariables = true; @@ -21,6 +24,9 @@ with lib; # set xserver videodrivers for amp gpu services.xserver.videoDrivers = [ "amdgpu" ]; + # As this is a laptop explicitly enable nmcli (likely enabled by GUI anyway) + networking.networkmanager.enable = true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; } diff --git a/nixos/profiles/role-worstation.nix b/nixos/profiles/role-worstation.nix index a40e66a..0c4555a 100644 --- a/nixos/profiles/role-worstation.nix +++ b/nixos/profiles/role-worstation.nix @@ -5,13 +5,15 @@ with lib; { - boot = { + + config.mySystem.shell.fish.plugins = true; + config.boot = { binfmt.emulatedSystems = [ "aarch64-linux" ]; # Enabled for raspi4 compilation - plymouth.enable = true; + plymouth.enable = true; # hide console with splash screen }; - nix.settings = { + config.nix.settings = { # TODO factor out into mySystem # Avoid disk full issues max-free = lib.mkDefault (1000 * 1000 * 1000); @@ -19,12 +21,11 @@ with lib; }; # set xserver videodrivers if used - services.xserver.enable = true; + config.services.xserver.enable = true; # Laptop so ill likely use wireles # very likely to be set by GUI packages but lets # be declarative. - networking.networkmanager.enable = true; }