diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..140a77d Binary files /dev/null and b/.DS_Store differ diff --git a/flake.lock b/flake.lock index 484198f..e0fdea9 100644 --- a/flake.lock +++ b/flake.lock @@ -668,23 +668,43 @@ "type": "github" } }, - "nh_darwin": { + "nh": { "inputs": { "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1739410909, - "narHash": "sha256-wx0oBgnmh6K8PJGyASLAErnrIe8/1hZthVrkfoX+j/E=", - "owner": "ToyVo", - "repo": "nh_darwin", - "rev": "10c8d19efd0ed9f63708d1179468fbb2f2bd7f4e", + "lastModified": 1743682999, + "narHash": "sha256-bg+aAN8K90r3m/I+xXiXG0gawpbkshwlk93wxUN7KEk=", + "owner": "viperML", + "repo": "nh", + "rev": "9e9a4590b38b62b28f07a1fae973ce7b6ca0687a", "type": "github" }, "original": { - "owner": "ToyVo", - "repo": "nh_darwin", + "owner": "viperML", + "repo": "nh", + "type": "github" + } + }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1744518957, + "narHash": "sha256-RLBSWQfTL0v+7uyskC5kP6slLK1jvIuhaAh8QvB75m4=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "4fc9ea78c962904f4ea11046f3db37c62e8a02fd", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", "type": "github" } }, @@ -920,7 +940,8 @@ "hyprland": "hyprland", "hyprland-plugins": "hyprland-plugins", "moonlight": "moonlight", - "nh_darwin": "nh_darwin", + "nh": "nh", + "nix-index-database": "nix-index-database", "nix-options-search": "nix-options-search", "nixos-cosmic": "nixos-cosmic", "nixpkgs": "nixpkgs_5", diff --git a/flake.nix b/flake.nix index f0693de..f19ecb3 100644 --- a/flake.nix +++ b/flake.nix @@ -33,8 +33,6 @@ zig.url = "github:mitchellh/zig-overlay"; zls.url = "github:zigtools/zls?rev=a26718049a8657d4da04c331aeced1697bc7652b"; - # foundryvtt.url = "github:reckenrode/nix-foundryvtt"; - moonlight = { url = "github:moonlight-mod/moonlight"; # Add `/develop` to the flake URL to use nightly. inputs.nixpkgs.follows = "nixpkgs"; @@ -44,90 +42,78 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - nh_darwin = { - url = "github:ToyVo/nh_darwin"; + nh = { + url = "github:viperML/nh"; inputs.nixpkgs.follows = "nixpkgs"; }; nix-options-search = { url = "github:madsbv/nix-options-search"; }; + nix-index-database.url = "github:nix-community/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + chinese-fonts-overlay = { url = "github:brsvh/chinese-fonts-overlay/main"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { - self, + outputs = inputs @ { nixpkgs, - nixpkgs-stable, - nix-options-search, - home-manager, - darwin, - hosts, - hyprland-plugins, - zig, - zls, nixos-cosmic, - nh_darwin, + nix-index-database, + darwin, ... - } @ inputs: let + }: let overlays = [ inputs.zig.overlays.default inputs.rust-overlay.overlays.default inputs.chinese-fonts-overlay.overlays.default + inputs.nh.overlays.default ]; inherit (nixpkgs) lib; + mkIfElse = p: yes: no: + lib.mkMerge [ + (lib.mkIf p yes) + (lib.mkIf (!p) no) + ]; + + user = "nmarks"; + + shared_modules = [ + # {nixpkgs.overlays = overlays;} + # {programs.nix-index-database.comma.enable = true;} + # nixindex + # homemanagerModules + { + _module.args = { + inherit user; + inherit mkIfElse; + }; + } + ]; in { nixosConfigurations = { nixos = lib.nixosSystem { - modules = [ - {nixpkgs.overlays = overlays;} - hosts.nixosModule - { - networking.stevenBlackHosts.enable = true; - } - ./hosts/desktop/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager = { - backupFileExtension = "hm-backup"; - useGlobalPkgs = true; - useUserPackages = true; - users.nmarks = import ./hosts/desktop/home.nix; - }; - home-manager.extraSpecialArgs = { - inherit hyprland-plugins; - inherit zls; - }; - } - nixos-cosmic.nixosModules.default - ]; + system = "x86_64-linux"; + modules = + [ + ./hosts/desktop/configuration.nix + nixos-cosmic.nixosModules.default + ] + ++ shared_modules; specialArgs = inputs; }; }; darwinConfigurations = { "Natalies-MacBook-Air" = darwin.lib.darwinSystem { system = "aarch64-darwin"; - modules = [ - {nixpkgs.overlays = overlays;} - ./hosts/laptop/configuration.nix - home-manager.darwinModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.nmarks = import ./hosts/laptop/home.nix; - }; - home-manager.extraSpecialArgs = { - inherit zls; - }; - users.users.nmarks.home = "/Users/nmarks"; - } - ]; - specialArgs = { - inherit inputs; - }; + specialArgs = inputs; + modules = + [ + ./hosts/laptop/configuration.nix + ] + ++ shared_modules; }; }; }; diff --git a/hosts/.DS_Store b/hosts/.DS_Store new file mode 100644 index 0000000..35fbfdb Binary files /dev/null and b/hosts/.DS_Store differ diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index dfa2ada..9704128 100644 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -1,6 +1,3 @@ -# 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’). { self, inputs, @@ -8,8 +5,14 @@ pkgs, ... }: { - nixpkgs.config.allowUnfree = true; + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ../../modules/shared/nix.nix + ../../modules/nixos/nvidia.nix + ../../modules/nixos/boot.ni + ]; services.avahi = { enable = true; nssmdns4 = true; @@ -51,22 +54,6 @@ nix.settings.trusted-users = ["root" "nmarks"]; - nix.settings.experimental-features = ["nix-command" "flakes"]; - nix.settings = { - substituters = [ - "https://cache.nixos.org/" - "https://nix-community.cachix.org" - "https://cosmic.cachix.org/" - "https://cache.iog.io" - "https://cuda-maintainers.cachix.org" - ]; - trusted-public-keys = [ - "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" - "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" - ]; - }; programs.hyprland.enable = true; programs.fish.enable = true; @@ -109,89 +96,6 @@ nerd-fonts.iosevka ]; - imports = [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - # inputs.foundryvtt.nixosModules.foundryvtt - ]; - - # Enable OpenGL - hardware.graphics = { - enable = true; - }; - services.xserver.videoDrivers = ["nvidia"]; - - hardware.nvidia-container-toolkit.enable = true; - hardware.nvidia = { - forceFullCompositionPipeline = true; - # Modesetting is required. - modesetting.enable = true; - - # Nvidia power management. Experimental, and can cause sleep/suspend to fail. - powerManagement.enable = false; - # Fine-grained power management. Turns off GPU when not in use. - # Experimental and only works on modern Nvidia GPUs (Turing or newer). - powerManagement.finegrained = false; - - # Use the NVidia open source kernel module (not to be confused with the - # independent third-party "nouveau" open source driver). - # Support is limited to the Turing and later architectures. Full list of - # supported GPUs is at: - # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus - # Only available from driver 515.43.04+ - # Currently alpha-quality/buggy, so false is currently the recommended setting. - open = false; - - # Enable the Nvidia settings menu, - # accessible via `nvidia-settings`. - nvidiaSettings = true; - - # Optionally, you may need to select the appropriate driver version for your specific GPU. - package = config.boot.kernelPackages.nvidiaPackages.latest; - #Fixes a glitch - nvidiaPersistenced = true; - - #Required for amdgpu and nvidia gpu pairings - # modesetting.enable = true; - - prime = { - # offload.enable = true; - #sync.enable = true; - - amdgpuBusId = "PCI:0f:00.0"; - - nvidiaBusId = "PCI:01:00.0"; - }; - }; - # Bootloader. - #boot.loader.systemd-boot.enable = true; - #boot.loader.efi.canTouchEfiVariables = true; - - boot.kernelPackages = pkgs.linuxPackages_latest; - - boot.loader = { - # systemd-boot.enable = true; - efi = { - canTouchEfiVariables = true; - # assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends). - efiSysMountPoint = "/boot/efi"; - }; - grub = { - enable = true; - device = "nodev"; - theme = pkgs.catppuccin-grub; - useOSProber = true; - efiSupport = true; - }; - }; - - boot.supportedFilesystems = ["ntfs"]; - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - # Set your time zone. time.timeZone = "America/Los_Angeles"; @@ -340,19 +244,6 @@ networkmanager.enable = true; firewall = { allowedTCPPorts = [22 80 443]; - #KDE Connect - # allowedTCPPortRanges = [ - # { - # from = 1714; - # to = 1764; - # } - # ]; - # allowedUDPPortRanges = [ - # { - # from = 1714; - # to = 1764; - # } - # ]; enable = true; }; interfaces.enp11s0.wakeOnLan = { diff --git a/hosts/laptop/.DS_Store b/hosts/laptop/.DS_Store new file mode 100644 index 0000000..4be084e Binary files /dev/null and b/hosts/laptop/.DS_Store differ diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index 11a565f..bb35a4f 100644 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -1,27 +1,32 @@ { config, pkgs, + lib, ... }: { + imports = [ + ../../modules/shared/nix.nix + ./modules/icons.nix + ]; + environment.systemPackages = with pkgs; [ - home-manager neovim pinentry_mac ]; - nixpkgs.config.allowUnfree = true; + environment.customIcons = { + enable = true; + icons = [ + { + path = "/Applications/Zen.app"; + icon = "/Users/nmarks/.dotfiles/icons/Zen_icons/firefox.icns"; + } + ]; + }; # Use a custom configuration.nix location. #environment.darwinConfig = "$HOME/.dotfiles/hosts/laptop"; - # Auto upgrade nix package and the daemon service. - nix = { - package = pkgs.nix; - settings = { - "extra-experimental-features" = ["nix-command" "flakes"]; - }; - }; - # Create /etc/zshrc that loads the nix-darwin environment. programs = { gnupg.agent.enable = true; diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 7fb74d7..274f722 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -1,36 +1,35 @@ { - inputs, config, pkgs, lib, - ghostty, - moonlight, ... }: { - # Home Manager needs a bit of information about you and the paths it should - # manage. - # This value determines the Home Manager release that your configuration is - # compatible with. This helps avoid breakage when a new Home Manager release - # introduces backwards incompatible changes. - # - # You should not change this value, even if you update Home Manager. If you do - # want to update the value, then make sure to first check the Home Manager - # release notes. - home.stateVersion = "23.05"; # Please read the comment before changing. - - home.packages = pkgs.callPackage ../shared/packages.nix {}; - programs = import ../shared/home-programs.nix {inherit config pkgs lib;}; - home.sessionVariables = { - EDITOR = "nvim"; - VISUAL = "nvim"; - TERMINAL = "ghostty"; - BROWSER = "firefox"; + home = { + # Home Manager needs a bit of information about you and the paths it should + # manage. + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + stateVersion = "23.05"; # Please read the comment before changing. + + packages = pkgs.callPackage ../shared/packages.nix {}; + + sessionVariables = { + EDITOR = "nvim"; + VISUAL = "nvim"; + TERMINAL = "ghostty"; + BROWSER = "firefox"; + }; + sessionPath = [ + "$HOME/.emacs.d/bin" + ]; }; - home.sessionPath = [ - "$HOME/.emacs.d/bin" - ]; # Let Home Manager install and manage itself. } diff --git a/hosts/laptop/icons/.DS_Store b/hosts/laptop/icons/.DS_Store new file mode 100644 index 0000000..2625ed3 Binary files /dev/null and b/hosts/laptop/icons/.DS_Store differ diff --git a/hosts/laptop/icons/Zen_icons/Zen Browser - Dark Mono.icns b/hosts/laptop/icons/Zen_icons/Zen Browser - Dark Mono.icns new file mode 100644 index 0000000..7fdfe63 Binary files /dev/null and b/hosts/laptop/icons/Zen_icons/Zen Browser - Dark Mono.icns differ diff --git a/hosts/laptop/icons/Zen_icons/Zen Browser - Dark.icns b/hosts/laptop/icons/Zen_icons/Zen Browser - Dark.icns new file mode 100644 index 0000000..0018099 Binary files /dev/null and b/hosts/laptop/icons/Zen_icons/Zen Browser - Dark.icns differ diff --git a/hosts/laptop/icons/Zen_icons/Zen Browser - Inverted.icns b/hosts/laptop/icons/Zen_icons/Zen Browser - Inverted.icns new file mode 100644 index 0000000..d41cd7a Binary files /dev/null and b/hosts/laptop/icons/Zen_icons/Zen Browser - Inverted.icns differ diff --git a/hosts/laptop/icons/Zen_icons/Zen Browser - Light Mono.icns b/hosts/laptop/icons/Zen_icons/Zen Browser - Light Mono.icns new file mode 100644 index 0000000..9549c11 Binary files /dev/null and b/hosts/laptop/icons/Zen_icons/Zen Browser - Light Mono.icns differ diff --git a/hosts/laptop/icons/Zen_icons/Zen Browser - Light.icns b/hosts/laptop/icons/Zen_icons/Zen Browser - Light.icns new file mode 100644 index 0000000..f16418d Binary files /dev/null and b/hosts/laptop/icons/Zen_icons/Zen Browser - Light.icns differ diff --git a/hosts/laptop/icons/Zen_icons/firefox.icns b/hosts/laptop/icons/Zen_icons/firefox.icns new file mode 100644 index 0000000..b8e4a15 Binary files /dev/null and b/hosts/laptop/icons/Zen_icons/firefox.icns differ diff --git a/hosts/laptop/modules/icons.nix b/hosts/laptop/modules/icons.nix new file mode 100644 index 0000000..649e7eb --- /dev/null +++ b/hosts/laptop/modules/icons.nix @@ -0,0 +1,61 @@ +{ + lib, + config, + ... +}: let + cfg = config.environment.customIcons; + inherit + (lib) + mkEnableOption + mkIf + mkMerge + mkOption + types + ; +in { + options.environment.customIcons = { + enable = mkEnableOption "environment.customIcons"; + clearCacheOnActivation = mkEnableOption "environment.customIcons.clearCacheOnActivation"; + + icons = mkOption { + type = types.listOf ( + types.submodule { + options = { + path = mkOption {type = types.path;}; + icon = mkOption {type = types.path;}; + }; + } + ); + }; + }; + + config = mkMerge [ + (mkIf cfg.enable { + system.activationScripts.extraActivation.text = '' + echo -e "applying custom icons..." + + ${ + (builtins.concatStringsSep "\n\n" ( + builtins.map (iconCfg: '' + osascript </dev/null + use framework "Cocoa" + + set iconPath to "${iconCfg.icon}" + set destPath to "${iconCfg.path}" + + set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:iconPath) + (current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:destPath options:2) + EOF + '') + cfg.icons + )) + } + + ${lib.optionalString cfg.clearCacheOnActivation '' + sudo rm -rf /Library/Caches/com.apple.iconservices.store + sudo find /private/var/folders/ -name com.apple.dock.iconcache -or -name com.apple.iconservices -or -name com.apple.iconservicesagent -exec rm -rf {} \; || true + killall Dock + ''}''; + }) + ]; +} diff --git a/hosts/shared/home-programs.nix b/hosts/shared/home-programs.nix index 0662bf2..5b913c6 100644 --- a/hosts/shared/home-programs.nix +++ b/hosts/shared/home-programs.nix @@ -26,6 +26,25 @@ bold_font auto"; }; + bat = { + enable = true; + extraPackages = with pkgs.bat-extras; [batdiff batman batgrep batwatch batpipe prettybat]; + config = { + theme = "catpuccin"; + }; + themes = { + catpuccin = { + src = pkgs.fetchFromGitHub { + owner = "catppuccin"; + repo = "bat"; + hash = "sha256-6fWoCH90IGumAMc4buLRWL0N61op+AuMNN9CAR9/OdI="; + rev = "699f60fc8ec434574ca7451b444b880430319941"; + }; + file = "themes/Catppuccin Mocha.tmTheme"; + }; + }; + }; + hyfetch = { enable = true; settings = { @@ -63,7 +82,10 @@ shellAliases = { reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; }; - shellInit = "test -r '/Users/nmarks/.opam/opam-init/init.fish' && source '/Users/nmarks/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true"; + shellInit = '' + test -r '/Users/nmarks/.opam/opam-init/init.fish' && source '/Users/nmarks/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true + batman --export-env | source + ''; }; home-manager.enable = true; } diff --git a/hosts/shared/packages.nix b/hosts/shared/packages.nix index 68d7a40..dbda90a 100644 --- a/hosts/shared/packages.nix +++ b/hosts/shared/packages.nix @@ -32,7 +32,6 @@ with pkgs; [ #nix tools cachix direnv - comma nh #terminal stuff @@ -44,7 +43,6 @@ with pkgs; [ neofetch hyfetch fastfetch - bat eza ollama uv diff --git a/modules/nixos/boot.nix b/modules/nixos/boot.nix new file mode 100644 index 0000000..55bbe8c --- /dev/null +++ b/modules/nixos/boot.nix @@ -0,0 +1,33 @@ +{pkgs, ...}: { + boot = { + kernelPackages = pkgs.linuxPackages_latest; # _zen, _hardened, _rt, _rt_latest, etc. + loader = { + efi = { + canTouchEfiVariables = true; + # assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends). + efiSysMountPoint = "/boot/efi"; + }; + grub = { + enable = true; + device = "nodev"; + theme = pkgs.catppuccin-grub; + useOSProber = true; + efiSupport = true; + }; + }; + + #this is set to false by default for some reason + tmp.cleanOnBoot = true; + + # Make boot screen quiet + kernelParams = [ + "quiet" + "splash" + "rd.systemd.show_status=auto" + "rd.udev.log_level=3" + "udev.log_priority=3" + ]; + consoleLogLevel = 0; + initrd.verbose = false; + }; +} diff --git a/modules/nixos/nvidia.nix b/modules/nixos/nvidia.nix new file mode 100644 index 0000000..d646f41 --- /dev/null +++ b/modules/nixos/nvidia.nix @@ -0,0 +1,95 @@ +{ + lib, + pkgs, + config, + ... +}: let + nvidiaDriverChannel = config.boot.kernelPackages.nvidiaPackages.latest; +in { + services.xserver.videoDrivers = ["nvidia"]; + + nixpkgs.config = { + nvidia.acceptLicense = true; + allowUnfree = true; + }; + # Kernel parameters for better Wayland and Hyprland integration + boot.kernelParams = [ + "nvidia-drm.modeset=1" # Enable mode setting for Wayland + "nvidia.NVreg_PreserveVideoMemoryAllocations=1" # Improves resume after sleep + ]; + + # Blacklist nouveau to avoid conflicts + boot.blacklistedKernelModules = ["nouveau"]; + + hardware = { + nvidia = { + forceFullCompositionPipeline = true; # Prevents screen tearing + # Modesetting is required. + modesetting.enable = true; + + powerManagement = { + enable = true; # Power management + finegrained = true; # More precise power consumption control + }; + + # Use the NVidia open source kernel module (not to be confused with the + # independent third-party "nouveau" open source driver). + # Currently alpha-quality/buggy, so false is currently the recommended setting. + open = false; + + # Environment variables for better compatibility + environment.variables = { + LIBVA_DRIVER_NAME = "nvidia"; # Hardware video acceleration + XDG_SESSION_TYPE = "wayland"; # Force Wayland + GBM_BACKEND = "nvidia-drm"; # Graphics backend for Wayland + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; # Use Nvidia driver for GLX + WLR_NO_HARDWARE_CURSORS = "1"; # Fix for cursors on Wayland + NIXOS_OZONE_WL = "1"; # Wayland support for Electron apps + __GL_GSYNC_ALLOWED = "1"; # Enable G-Sync if available + __GL_VRR_ALLOWED = "1"; # Enable VRR (Variable Refresh Rate) + WLR_DRM_NO_ATOMIC = "1"; # Fix for some issues with Hyprland + NVD_BACKEND = "direct"; # Configuration for new driver + MOZ_ENABLE_WAYLAND = "1"; # Wayland support for Firefox + }; + + # Enable the Nvidia settings menu, + # accessible via `nvidia-settings`. + nvidiaSettings = true; + + package = nvidiaDriverChannel; + + #Fixes a glitch + nvidiaPersistenced = true; + }; + nvidia-container-toolkit.enable = true; + + graphics = { + enable = true; + package = nvidiaDriverChannel; + enable32Bit = true; + extraPackages = with pkgs; [ + nvidia-vaapi-driver + vaapiVdpau + libvdpau-va-gl + mesa + egl-wayland + vulkan-loader + vulkan-validation-layers + libva + ]; + }; + }; + + nix.settings = { + substituters = ["https://cuda-maintainers.cachix.org"]; + trusted-public-keys = [ + "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" + ]; + }; + + environment.systemPackages = with pkgs; [ + vulkan-tools + glxinfo + libva-utils # VA-API debugging tools + ]; +} diff --git a/modules/shared/extras.nix b/modules/shared/extras.nix new file mode 100644 index 0000000..862442b --- /dev/null +++ b/modules/shared/extras.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + inputs, + hostName, + mkIfElse, + darwin, + ... +}: { + networking = { + inherit hostName; + networkmanager = !darwin; + }; +} diff --git a/modules/shared/home-manager.nix b/modules/shared/home-manager.nix new file mode 100644 index 0000000..cb94fa2 --- /dev/null +++ b/modules/shared/home-manager.nix @@ -0,0 +1,8 @@ +{inputs, ...}: { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "hm-backup"; + extraSpecialArgs = {inherit inputs;}; + }; +} diff --git a/modules/shared/nix.nix b/modules/shared/nix.nix new file mode 100644 index 0000000..5e8bbf7 --- /dev/null +++ b/modules/shared/nix.nix @@ -0,0 +1,39 @@ +{ + config, + inputs, + ... +}: { + nixpkgs.config = { + allowUnfree = true; + }; + + nix = { + nixPath = ["nixpkgs = ${inputs.nixpkgs}"]; + extraOptions = '' + warn-dirty = false + ''; + + settings = { + auto-optimise-store = true; + experimental-features = ["nix-command" "flakes"]; + substituters = [ + "https://cache.nixos.org/?priority=10" + + "https://nix-community.cachix.org" + "https://cosmic.cachix.org/" + "https://cache.iog.io" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" + "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + ]; + }; + gc = { + automatic = true; + persistent = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; +} diff --git a/modules/shared/vars.nix b/modules/shared/vars.nix new file mode 100644 index 0000000..2191660 --- /dev/null +++ b/modules/shared/vars.nix @@ -0,0 +1,23 @@ +{ + inputs, + pkgs, + config, + lib, + mkIfElse, + ... +}: let + darwin = pkgs.stdenv.isDarwin; + homemanagerModules = mkIfElse darwin inputs.home-manager.darwinModules inputs.home-manager.nixosModules; + nixindex = mkIfElse darwin inputs.nix-index-database.darwinModules.nix-index inputs.nix-index-database.nixosModules.nix-index; +in { + config.var = { + inherit darwin homemanagerModules nixindex; + }; + + options = { + var = lib.mkOption { + type = lib.types.attrs; + default = {}; + }; + }; +}