diff --git a/features/avahi.nix b/features/avahi.nix new file mode 100644 index 0000000..eaf19fc --- /dev/null +++ b/features/avahi.nix @@ -0,0 +1,8 @@ +{ _, ... }: +{ + services.avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; +} diff --git a/features/bash.nix b/features/bash.nix new file mode 100644 index 0000000..619714f --- /dev/null +++ b/features/bash.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: +{ + imports = [ + ./starship.nix + ]; + + programs.bash = { + enable = true; + + interactiveShellInit = '' + eval "$(devenv hook bash)" + eval "$(jump shell)" + clear;fastfetch + ''; + }; + + environment.systemPackages = with pkgs; [ + jump + devenv + fastfetch + ]; +} diff --git a/features/docker.nix b/features/docker.nix new file mode 100644 index 0000000..9a297a4 --- /dev/null +++ b/features/docker.nix @@ -0,0 +1,4 @@ +{ _, ... }: +{ + virtualisation.docker.enable = true; +} diff --git a/features/i18n.nix b/features/i18n.nix new file mode 100644 index 0000000..6b7e7f5 --- /dev/null +++ b/features/i18n.nix @@ -0,0 +1,24 @@ +{ _, ... }: +{ + time.timeZone = "America/New_York"; + + i18n = { + defaultLocale = "en_US.UTF-8"; + + extraLocales = [ + "ja_JP.UTF-8/UTF-8" + ]; + + extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + }; +} diff --git a/features/libvirt.nix b/features/libvirt.nix new file mode 100644 index 0000000..a0a4e50 --- /dev/null +++ b/features/libvirt.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +{ + virtualisation = { + spiceUSBRedirection.enable = true; + + libvirtd = { + enable = true; + + qemu = { + package = pkgs.qemu_kvm; + runAsRoot = true; + swtpm.enable = true; + }; + }; + }; +} diff --git a/features/nix-ld.nix b/features/nix-ld.nix new file mode 100644 index 0000000..804a6fc --- /dev/null +++ b/features/nix-ld.nix @@ -0,0 +1,35 @@ +{ pkgs, ... }: +{ + programs.nix-ld = { + enable = true; + libraries = with pkgs; [ + stdenv.cc.cc.lib + openssl + zlib + icu + curl + libxcrypt-legacy + gcc + pkg-config + busybox + libdrm + mesa + libxkbcommon + fontconfig + libglvnd + freetype + libxcb + libx11 + libice + libsm + libxcursor + libxrandr + libxft + skia + dotnet-sdk + dotnet-runtime + dotnet-runtime_8 + dotnet-runtime_10 + ]; + }; +} diff --git a/features/starship.nix b/features/starship.nix new file mode 100644 index 0000000..f3f86d6 --- /dev/null +++ b/features/starship.nix @@ -0,0 +1,13 @@ +{ _, ... }: +{ + programs.starship = { + enable = true; + + settings = { + character = { + success_symbol = "[λ](bold green)"; + error_symbol = "[λ](bold red)"; + }; + }; + }; +} diff --git a/features/systemd-boot.nix b/features/systemd-boot.nix new file mode 100644 index 0000000..7d370b5 --- /dev/null +++ b/features/systemd-boot.nix @@ -0,0 +1,9 @@ +{ _, ... }: +{ + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + systemd-boot.configurationLimit = 10; + timeout = 0; + }; +} diff --git a/features/vim.nix b/features/vim.nix new file mode 100644 index 0000000..6dd1ea2 --- /dev/null +++ b/features/vim.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +{ + programs.neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + + configure = { + customRC = '' + set nocompatible + set backspace=indent,eol,start + set tabstop=2 + set shiftwidth=2 + set expandtab + ''; + + packages.myPlugins = with pkgs.vimPlugins; { + start = [ + vim-lastplace + vim-nix + ]; + + opt = [ ]; + }; + }; + }; +} diff --git a/home/frank.nix b/home/frank.nix index 5cac225..e93d727 100644 --- a/home/frank.nix +++ b/home/frank.nix @@ -5,6 +5,7 @@ in { imports = [ inputs.lazyvim.homeManagerModules.default + ../features/starship.nix ]; home.shellAliases = import ../features/aliases.nix { inherit pkgs; }; @@ -76,17 +77,6 @@ in else { }; - starship = { - enable = true; - - settings = { - character = { - success_symbol = "[λ](bold green)"; - error_symbol = "[λ](bold red)"; - }; - }; - }; - fastfetch = { enable = true; diff --git a/hosts/shared/darwin.nix b/hosts/shared/darwin.nix index c235709..9acbf92 100644 --- a/hosts/shared/darwin.nix +++ b/hosts/shared/darwin.nix @@ -1,38 +1,12 @@ { self, pkgs, ... }: { + imports = [ + ./nix-package-manager.nix + ]; + # Only use homebrew for casks. homebrew.enable = true; - nix = { - gc = { - automatic = true; - interval = { - Hour = 3; - Minute = 15; - Weekday = 7; - }; - options = "--delete-older-than 30d"; - }; - - optimise = { - automatic = true; - interval = { - Hour = 3; - Minute = 15; - Weekday = 7; - }; - }; - - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - - use-xdg-base-directories = true; - }; - }; - # Enables Touch ID for sudo prompts. security.pam.services.sudo_local.touchIdAuth = true; @@ -45,21 +19,23 @@ interactiveShellInit = '' eval "$(jump shell)" + eval "$(devenv hook zsh)" + clear;fastfetch ''; }; }; environment = { - shellAliases = import ../../features/aliases.nix { inherit pkgs; }; - variables = import ../../features/xdg.nix { inherit pkgs; }; + shellAliases = import ../../features/aliases.nix { }; + variables = import ../../features/xdg.nix { }; systemPackages = with pkgs; [ wget - fastfetch btop nerd-fonts.hack - jump + devenv ripgrep + fastfetch ]; }; diff --git a/hosts/shared/nix-package-manager.nix b/hosts/shared/nix-package-manager.nix new file mode 100644 index 0000000..20d3f7c --- /dev/null +++ b/hosts/shared/nix-package-manager.nix @@ -0,0 +1,47 @@ +{ lib, pkgs, ... }: +let + launchd-time = { + Hour = 3; + Minute = 15; + Weekday = 7; + }; + + systemd-time = "weekly"; + + isDarwin = pkgs.stdenv.hostPlatform.isDarwin; +in +{ + nixpkgs.config.allowUnfree = true; + + nix = { + gc = { + automatic = true; + options = "--delete-older-than 30d"; + } + // lib.optionalAttrs isDarwin { + interval = launchd-time; + } + // lib.optionalAttrs (!isDarwin) { + dates = systemd-time; + }; + + optimise = { + automatic = true; + } + // lib.optionalAttrs isDarwin { + interval = launchd-time; + } + // lib.optionalAttrs (!isDarwin) { + dates = systemd-time; + }; + + settings = { + use-xdg-base-directories = true; + + experimental-features = [ + "nix-command" + "flakes" + ]; + }; + }; +} diff --git a/hosts/shared/nixos-pc.nix b/hosts/shared/nixos-pc.nix index 87d6183..c8c0939 100644 --- a/hosts/shared/nixos-pc.nix +++ b/hosts/shared/nixos-pc.nix @@ -5,14 +5,18 @@ ... }: { - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - systemd-boot.configurationLimit = 10; - timeout = 0; - }; + imports = [ + ../../features/bash.nix + ../../features/nix-ld.nix + ../../features/docker.nix + ../../features/vim.nix + ../../features/avahi.nix + ../../features/systemd-boot.nix + ../../features/i18n.nix + ./nix-package-manager.nix + ]; + boot = { consoleLogLevel = 3; kernelParams = [ @@ -116,13 +120,6 @@ openssh.enable = true; affinity-thumbnailer.enable = true; - - # Enables m(ulticast)DNS (a.k.a. Bonjour) support. - avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; }; networking = { @@ -131,10 +128,7 @@ networkmanager.plugins = with pkgs; [ networkmanager-openvpn ]; firewall = { - trustedInterfaces = [ - "virbr0" - "br0" - ]; + allowedTCPPorts = [ 22 ]; allowedTCPPortRanges = [ { @@ -149,132 +143,24 @@ to = 1764; } # KDE Connect ]; - - allowedTCPPorts = [ 22 ]; - }; - }; - - time.timeZone = "America/New_York"; - - i18n = { - defaultLocale = "en_US.UTF-8"; - - extraLocales = [ - "ja_JP.UTF-8/UTF-8" - ]; - - extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; }; }; security.rtkit.enable = true; programs = { + ssh.startAgent = true; + firefox.enable = true; + gnupg.agent = { enable = true; pinentryPackage = pkgs.pinentry-qt; }; - nix-ld = { - enable = true; - libraries = with pkgs; [ - stdenv.cc.cc.lib - openssl - zlib - icu - curl - libxcrypt-legacy - gcc - pkg-config - busybox - libdrm - mesa - libxkbcommon - fontconfig - libglvnd - freetype - libxcb - libx11 - libice - libsm - libxcursor - libxrandr - libxft - skia - dotnet-sdk - dotnet-runtime - dotnet-runtime_8 - dotnet-runtime_10 - ]; - }; - - bash = { - enable = true; - - interactiveShellInit = '' - eval "$(jump shell)" - bind -x '"\eOQ": clear;fastfetch' - ''; - }; - - starship = { - enable = true; - - settings = { - character = { - success_symbol = "[λ](bold green)"; - error_symbol = "[λ](bold red)"; - }; - }; - }; - - ssh.startAgent = true; - - firefox.enable = true; - thunderbird.enable = true; - appimage = { enable = true; binfmt = true; }; - - neovim = { - enable = true; - defaultEditor = true; - vimAlias = true; - - configure = { - customRC = '' - set nocompatible - set backspace=indent,eol,start - set tabstop=2 - set shiftwidth=2 - set expandtab - ''; - - packages.myPlugins = with pkgs.vimPlugins; { - start = [ - vim-lastplace - vim-nix - ]; - - opt = [ ]; - }; - }; - }; - }; - - virtualisation = { - docker.enable = true; }; users.users.frank = { @@ -293,8 +179,6 @@ }; nixpkgs = { - config.allowUnfree = true; - # Fix msitools compiling and failing it's test-suite. overlays = [ (final: prev: { @@ -307,28 +191,6 @@ ]; }; - nix = { - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - - optimise = { - automatic = true; - dates = "weekly"; - }; - - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - - use-xdg-base-directories = true; - }; - }; - environment = { systemPackages = with pkgs; [ wget @@ -355,7 +217,6 @@ affinity-v3 libreoffice-qt qimgv - fastfetch vorta distrobox devenv diff --git a/hosts/shared/nixos-server.nix b/hosts/shared/nixos-server.nix index 305e557..9dc4d83 100644 --- a/hosts/shared/nixos-server.nix +++ b/hosts/shared/nixos-server.nix @@ -1,25 +1,20 @@ { pkgs, - inputs, ... }: { - boot.loader = { - systemd-boot.enable = true; - systemd-boot.configurationLimit = 10; - efi.canTouchEfiVariables = true; - timeout = 0; - }; + imports = [ + ../../features/bash.nix + ../../features/vim.nix + ../../features/docker.nix + ../../features/libvirt.nix + ../../features/avahi.nix + ../../features/systemd-boot.nix + ../../features/i18n.nix + ./nix-package-manager.nix + ]; - services = { - avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; - - openssh.enable = true; - }; + services.openssh.enable = true; networking = { useNetworkd = true; @@ -68,91 +63,7 @@ }; }; - time.timeZone = "America/New_York"; - - i18n = { - defaultLocale = "en_US.UTF-8"; - - extraLocales = [ - "ja_JP.UTF-8/UTF-8" - ]; - - extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; - }; - }; - - programs = { - bash = { - enable = true; - - interactiveShellInit = '' - eval "$(jump shell)" - bind -x '"\eOQ": clear;fastfetch' - ''; - }; - - starship = { - enable = true; - - settings = { - character = { - success_symbol = "[λ](bold green)"; - error_symbol = "[λ](bold red)"; - }; - }; - }; - - neovim = { - enable = true; - defaultEditor = true; - vimAlias = true; - - configure = { - customRC = '' - set nocompatible - set backspace=indent,eol,start - set tabstop=2 - set shiftwidth=2 - set expandtab - ''; - - packages.myPlugins = with pkgs.vimPlugins; { - start = [ - vim-lastplace - vim-nix - ]; - - opt = [ ]; - }; - }; - }; - - ssh.startAgent = true; - }; - - virtualisation = { - docker.enable = true; - spiceUSBRedirection.enable = true; - - libvirtd = { - enable = true; - - qemu = { - package = pkgs.qemu_kvm; - runAsRoot = true; - swtpm.enable = true; - }; - }; - }; + programs.ssh.startAgent = true; users.users.frank = { isNormalUser = true; @@ -174,14 +85,12 @@ nil bash-language-server devenv - jump weather borgbackup openjdk openjdk17 openjdk25 tmux - fastfetch ripgrep (python3.withPackages ( @@ -196,28 +105,5 @@ sessionVariables = import ../../features/xdg.nix { inherit pkgs; }; }; - nix = { - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - - optimise = { - automatic = true; - dates = "weekly"; - }; - - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - - use-xdg-base-directories = true; - }; - }; - - nixpkgs.config.allowUnfree = true; system.stateVersion = "26.05"; }