diff options
| -rw-r--r-- | flake.nix | 90 | ||||
| -rw-r--r-- | hosts/common/desktop/default.nix | 28 | ||||
| -rw-r--r-- | hosts/common/packages.nix | 36 | ||||
| -rw-r--r-- | hosts/common/users.nix | 19 | ||||
| -rw-r--r-- | hosts/default.nix | 32 | ||||
| -rw-r--r-- | hosts/glados-wsl/default.nix | 29 | ||||
| -rw-r--r-- | hosts/glados/default.nix | 21 | ||||
| -rw-r--r-- | profiles/base/default.nix (renamed from hosts/common/default.nix) | 11 | ||||
| -rw-r--r-- | profiles/base/documentation.nix (renamed from hosts/common/documentation.nix) | 0 | ||||
| -rw-r--r-- | profiles/base/packages.nix | 23 | ||||
| -rw-r--r-- | profiles/desktop/default.nix | 21 | ||||
| -rw-r--r-- | profiles/desktop/fonts.nix (renamed from hosts/common/fonts.nix) | 9 | ||||
| -rw-r--r-- | profiles/desktop/gnome/default.nix (renamed from hosts/common/desktop/gnome.nix) | 6 | ||||
| -rw-r--r-- | profiles/desktop/plasma/default.nix (renamed from hosts/common/desktop/plasma.nix) | 3 | ||||
| -rw-r--r-- | profiles/hardware/default.nix (renamed from hosts/common/hardware/default.nix) | 0 | ||||
| -rw-r--r-- | profiles/hardware/nvidia.nix (renamed from hosts/common/hardware/nvidia.nix) | 5 | ||||
| -rw-r--r-- | profiles/nixos/default.nix | 9 | ||||
| -rw-r--r-- | profiles/nixos/locale.nix (renamed from hosts/common/locale.nix) | 0 | ||||
| -rw-r--r-- | profiles/nixos/security.nix (renamed from hosts/common/security.nix) | 17 | ||||
| -rw-r--r-- | profiles/nixos/systemd.nix (renamed from hosts/common/systemd.nix) | 4 | ||||
| -rw-r--r-- | profiles/virtualisation.nix (renamed from hosts/common/virtualisation.nix) | 0 | ||||
| -rw-r--r-- | users/default.nix | 9 | ||||
| -rw-r--r-- | users/root/default.nix | 8 | ||||
| -rw-r--r-- | users/seth/default.nix | 53 | ||||
| -rw-r--r-- | users/seth/desktop/default.nix | 25 | ||||
| -rw-r--r-- | users/seth/desktop/gnome/default.nix (renamed from users/seth/desktop/gnome.nix) | 84 | ||||
| -rw-r--r-- | users/seth/desktop/plasma/default.nix (renamed from users/seth/desktop/plasma.nix) | 3 | ||||
| -rw-r--r-- | users/seth/home.nix | 37 | ||||
| -rw-r--r-- | users/seth/shell/bash.nix | 16 | ||||
| -rw-r--r-- | users/seth/shell/default.nix | 1 | ||||
| -rw-r--r-- | users/seth/shell/fish.nix | 21 | ||||
| -rw-r--r-- | util/default.nix | 16 | ||||
| -rw-r--r-- | util/host.nix | 49 | ||||
| -rw-r--r-- | util/user.nix | 109 |
34 files changed, 371 insertions, 423 deletions
@@ -24,85 +24,31 @@ outputs = inputs @ { nixpkgs, nixpkgsUnstable, - getchoo, - home-manager, - lanzaboote, - nixos-hardware, - nixos-wsl, - nur, ... }: let - supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; + supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;}); - util = import ./util {inherit inputs home-manager;}; - inherit (util) host user; - - seth = { - specialArgs ? {}, - pkgs ? nixpkgsUnstable, - }: - forAllSystems (system: import ./users/seth {inherit pkgs specialArgs system user;}); - in { - homeConfigurations = forAllSystems (system: { - inherit ((seth {}).${system}.hm) seth; - }); + mkPkgsFor = pkgs: forAllSystems (system: import pkgs {inherit system;}); + channels = { + nixpkgs = mkPkgsFor nixpkgs; + nixpkgsUnstable = mkPkgsFor nixpkgsUnstable; + }; - nixosConfigurations = - (host.mkHost rec { - name = "glados"; - specialArgs = { - desktop = "gnome"; - standalone = false; - wsl = false; - }; - version = "23.05"; - pkgs = nixpkgsUnstable; - modules = - [ - nixos-hardware.nixosModules.common-cpu-amd-pstate - nixos-hardware.nixosModules.common-gpu-nvidia-nonprime - nixos-hardware.nixosModules.common-pc-ssd - lanzaboote.nixosModules.lanzaboote - nur.nixosModules.nur + util = import ./util { + inherit (nixpkgs) lib; + inherit inputs; + }; + inherit (util.host) mapHosts; + inherit (util.user) mapHMUsers; - { - nixpkgs.overlays = [nur.overlay getchoo.overlays.default]; - nix.registry.getchoo.flake = getchoo; - } - ] - ++ (seth {inherit specialArgs pkgs;}).x86_64-linux.system; - }) - // (host.mkHost rec { - name = "glados-wsl"; - specialArgs = { - desktop = ""; - standalone = false; - wsl = true; - }; - version = "23.05"; - pkgs = nixpkgsUnstable; - modules = - [ - nixos-wsl.nixosModules.wsl - { - wsl = { - enable = true; - defaultUser = "seth"; - nativeSystemd = true; - wslConf.network.hostname = "glados-wsl"; - startMenuLaunchers = false; - interop.includePath = false; - }; + users = import ./users {inherit inputs;}; + hosts = import ./hosts {inherit inputs;}; + in { + homeConfigurations = forAllSystems (system: mapHMUsers (users.users {inherit system;})); - nixpkgs.overlays = [getchoo.overlays.default]; - nix.registry.getchoo.flake = getchoo; - } - ] - ++ (seth {inherit specialArgs pkgs;}).x86_64-linux.system; - }); + nixosConfigurations = mapHosts hosts; - formatter = forAllSystems (system: nixpkgsFor.${system}.alejandra); + formatter = forAllSystems (system: channels.nixpkgs.${system}.alejandra); }; } diff --git a/hosts/common/desktop/default.nix b/hosts/common/desktop/default.nix deleted file mode 100644 index 68ac655..0000000 --- a/hosts/common/desktop/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - lib, - desktop, - ... -}: let - gui = desktop != ""; -in { - imports = - [] - ++ ( - if (desktop == "gnome") - then [./gnome.nix] - else [] - ) - ++ ( - if (desktop == "plasma") - then [./plasma.nix] - else [] - ); - - environment.noXlibs = lib.mkForce false; - programs = { - dconf.enable = gui; - xwayland.enable = gui; - }; - services.xserver.enable = gui; - xdg.portal.enable = gui; -} diff --git a/hosts/common/packages.nix b/hosts/common/packages.nix deleted file mode 100644 index 3a4d2b2..0000000 --- a/hosts/common/packages.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - pkgs, - desktop, - ... -}: let - gui = desktop != ""; - pinentry = with pkgs; - if desktop == "gnome" - then pinentry-gnome - else pinentry-curses; -in { - environment.systemPackages = with pkgs; - [ - neofetch - python311 - ] - ++ [pinentry]; - - programs = { - firefox.enable = - if gui - then true - else false; - git.enable = true; - gnupg = { - agent = { - enable = true; - pinentryFlavor = - if desktop == "gnome" - then "gnome3" - else "curses"; - }; - }; - vim.defaultEditor = true; - }; -} diff --git a/hosts/common/users.nix b/hosts/common/users.nix deleted file mode 100644 index 6ca24c4..0000000 --- a/hosts/common/users.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - config, - pkgs, - ... -}: { - users = { - defaultUserShell = pkgs.bash; - mutableUsers = false; - - users = { - root = { - home = "/root"; - uid = config.ids.uids.root; - group = "root"; - initialHashedPassword = "***REMOVED***"; - }; - }; - }; -} diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..8aff79e --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,32 @@ +{inputs}: +with inputs; let + common = { + system = "x86_64-linux"; + stateVersion = "23.05"; + pkgs = nixpkgsUnstable; + modules = with inputs; [ + home-manager.nixosModules.home-manager + nur.nixosModules.nur + ]; + }; +in { + glados = { + modules = + common.modules + ++ [ + nixos-hardware.nixosModules.common-cpu-amd-pstate + nixos-hardware.nixosModules.common-gpu-nvidia-nonprime + nixos-hardware.nixosModules.common-pc-ssd + lanzaboote.nixosModules.lanzaboote + ]; + inherit (common) system stateVersion pkgs; + }; + glados-wsl = { + modules = + common.modules + ++ [ + nixos-wsl.nixosModules.wsl + ]; + inherit (common) system stateVersion pkgs; + }; +} diff --git a/hosts/glados-wsl/default.nix b/hosts/glados-wsl/default.nix index af6e712..cb0854e 100644 --- a/hosts/glados-wsl/default.nix +++ b/hosts/glados-wsl/default.nix @@ -1,5 +1,32 @@ -{modulesPath, ...}: { +{ + lib, + modulesPath, + ... +}: { imports = [ (modulesPath + "/profiles/minimal.nix") + ../../profiles/nixos + ../../users/seth ]; + + wsl = { + enable = true; + defaultUser = "seth"; + nativeSystemd = true; + wslConf.network = { + hostname = "glados-wsl"; + generateResolvConf = true; + }; + startMenuLaunchers = false; + interop.includePath = false; + }; + + services.resolved.enable = lib.mkForce false; + security = { + apparmor.enable = lib.mkForce false; + audit.enable = lib.mkForce false; + auditd.enable = lib.mkForce false; + }; + + system.stateVersion = "23.05"; } diff --git a/hosts/glados/default.nix b/hosts/glados/default.nix index 0b6d7c5..e8b083e 100644 --- a/hosts/glados/default.nix +++ b/hosts/glados/default.nix @@ -1,14 +1,25 @@ -_: { +{ + config, + home-manager, + ... +}: { imports = [ - ../common/hardware - ../common/hardware/nvidia.nix - ../common/virtualisation.nix + ../../profiles/desktop/gnome + ../../profiles/hardware/nvidia.nix + ../../profiles/virtualisation.nix + ../../users/seth ./boot.nix ./hardware-configuration.nix ./network.nix ./services.nix ]; + home-manager.users.seth = { + imports = [ + ../../users/seth/desktop/gnome + ]; + }; + environment.etc."environment".text = '' LIBVA_DRIVER_NAME=vdpau ''; @@ -26,4 +37,6 @@ _: { swapDevices = 1; memoryPercent = 50; }; + + system.stateVersion = "23.05"; } diff --git a/hosts/common/default.nix b/profiles/base/default.nix index 25d08d3..dbaabe8 100644 --- a/hosts/common/default.nix +++ b/profiles/base/default.nix @@ -1,16 +1,11 @@ -_: { +{pkgs, ...}: { imports = [ ./documentation.nix - ./desktop - ./fonts.nix - ./locale.nix ./packages.nix - ./security.nix - ./systemd.nix - ./users.nix ]; nix = { + package = pkgs.nixFlakes; gc = { automatic = true; dates = "weekly"; @@ -19,7 +14,7 @@ _: { settings = { auto-optimise-store = true; warn-dirty = false; + experimental-features = ["nix-command" "flakes"]; }; }; - # config.services.kmscon.enable = true; } diff --git a/hosts/common/documentation.nix b/profiles/base/documentation.nix index bd22316..bd22316 100644 --- a/hosts/common/documentation.nix +++ b/profiles/base/documentation.nix diff --git a/profiles/base/packages.nix b/profiles/base/packages.nix new file mode 100644 index 0000000..b0fcae4 --- /dev/null +++ b/profiles/base/packages.nix @@ -0,0 +1,23 @@ +{ + lib, + pkgs, + ... +}: { + environment.systemPackages = with pkgs; [ + hyfetch + neofetch + pinentry-curses + python311 + ]; + + programs = { + git.enable = true; + gnupg = { + agent = { + enable = true; + pinentryFlavor = lib.mkDefault "curses"; + }; + }; + vim.defaultEditor = true; + }; +} diff --git a/profiles/desktop/default.nix b/profiles/desktop/default.nix new file mode 100644 index 0000000..68c6774 --- /dev/null +++ b/profiles/desktop/default.nix @@ -0,0 +1,21 @@ +{ + lib, + pkgs, + ... +}: { + imports = [ + ../nixos + ./fonts.nix + ]; + environment = { + noXlibs = lib.mkForce false; + systemPackages = with pkgs; [pinentry-curses]; + }; + programs = { + dconf.enable = true; + firefox.enable = true; + xwayland.enable = true; + }; + services.xserver.enable = true; + xdg.portal.enable = true; +} diff --git a/hosts/common/fonts.nix b/profiles/desktop/fonts.nix index 698b4fb..89bff21 100644 --- a/hosts/common/fonts.nix +++ b/profiles/desktop/fonts.nix @@ -1,10 +1,4 @@ -{ - pkgs, - desktop, - ... -}: -if desktop != "" -then { +{pkgs, ...}: { fonts = { enableDefaultFonts = true; fonts = with pkgs; [ @@ -24,4 +18,3 @@ then { }; }; } -else {} diff --git a/hosts/common/desktop/gnome.nix b/profiles/desktop/gnome/default.nix index 04e32e1..c0cc5ca 100644 --- a/hosts/common/desktop/gnome.nix +++ b/profiles/desktop/gnome/default.nix @@ -3,6 +3,9 @@ lib, ... }: { + imports = [ + ../. + ]; environment = { gnome.excludePackages = with pkgs; [ epiphany @@ -11,6 +14,7 @@ systemPackages = with pkgs; [ adw-gtk3 blackbox-terminal + pinentry-gnome ]; }; @@ -21,4 +25,6 @@ }; desktopManager.gnome.enable = true; }; + + programs.gnupg.agent.pinentryFlavor = "gnome3"; } diff --git a/hosts/common/desktop/plasma.nix b/profiles/desktop/plasma/default.nix index bc38720..898e259 100644 --- a/hosts/common/desktop/plasma.nix +++ b/profiles/desktop/plasma/default.nix @@ -1,4 +1,7 @@ {pkgs, ...}: { + imports = [ + ../. + ]; services.xserver = { displayManager.sddm.enable = true; desktopManager.plasma5 = { diff --git a/hosts/common/hardware/default.nix b/profiles/hardware/default.nix index be395d2..be395d2 100644 --- a/hosts/common/hardware/default.nix +++ b/profiles/hardware/default.nix diff --git a/hosts/common/hardware/nvidia.nix b/profiles/hardware/nvidia.nix index 99f7d6e..473eb81 100644 --- a/hosts/common/hardware/nvidia.nix +++ b/profiles/hardware/nvidia.nix @@ -3,12 +3,13 @@ pkgs, ... }: { + imports = [ + ./. + ]; hardware = { nvidia = { package = config.boot.kernelPackages.nvidiaPackages.stable; modesetting.enable = true; - # nvidiaPersistenced = true; - # powerManagement.enable = true; }; opengl = { enable = true; diff --git a/profiles/nixos/default.nix b/profiles/nixos/default.nix new file mode 100644 index 0000000..078ee24 --- /dev/null +++ b/profiles/nixos/default.nix @@ -0,0 +1,9 @@ +_: { + imports = [ + ../base + ../../users/root + ./locale.nix + ./security.nix + ./systemd.nix + ]; +} diff --git a/hosts/common/locale.nix b/profiles/nixos/locale.nix index 45589ef..45589ef 100644 --- a/hosts/common/locale.nix +++ b/profiles/nixos/locale.nix diff --git a/hosts/common/security.nix b/profiles/nixos/security.nix index 260538a..7ad0069 100644 --- a/hosts/common/security.nix +++ b/profiles/nixos/security.nix @@ -1,8 +1,12 @@ -{wsl, ...}: { +{ + lib, + pkgs, + ... +}: { security = { - apparmor.enable = !wsl; - audit.enable = !wsl; - auditd.enable = !wsl; + apparmor.enable = lib.mkDefault true; + audit.enable = lib.mkDefault true; + auditd.enable = lib.mkDefault true; rtkit.enable = true; sudo = { execWheelOnly = true; @@ -20,4 +24,9 @@ }; polkit.enable = true; }; + + users = { + defaultUserShell = pkgs.bash; + mutableUsers = false; + }; } diff --git a/hosts/common/systemd.nix b/profiles/nixos/systemd.nix index 86fea4a..0e40e39 100644 --- a/hosts/common/systemd.nix +++ b/profiles/nixos/systemd.nix @@ -1,10 +1,10 @@ -{wsl, ...}: { +{lib, ...}: { services = { journald.extraConfig = '' MaxRetentionSec=1w ''; resolved = { - enable = !wsl; + enable = lib.mkDefault true; dnssec = "allow-downgrade"; extraConfig = '' [Resolve] diff --git a/hosts/common/virtualisation.nix b/profiles/virtualisation.nix index f78ca1d..f78ca1d 100644 --- a/hosts/common/virtualisation.nix +++ b/profiles/virtualisation.nix diff --git a/users/default.nix b/users/default.nix new file mode 100644 index 0000000..6f5a787 --- /dev/null +++ b/users/default.nix @@ -0,0 +1,9 @@ +{inputs}: +with inputs; { + users = {system}: { + seth = { + pkgs = nixpkgsUnstable.legacyPackages.${system}; + stateVersion = "23.05"; + }; + }; +} diff --git a/users/root/default.nix b/users/root/default.nix new file mode 100644 index 0000000..2fec3ea --- /dev/null +++ b/users/root/default.nix @@ -0,0 +1,8 @@ +{config, ...}: { + users.users.root = { + home = "/root"; + uid = config.ids.uids.root; + group = "root"; + initialHashedPassword = "***REMOVED***"; + }; +} diff --git a/users/seth/default.nix b/users/seth/default.nix index c3241d0..52979b3 100644 --- a/users/seth/default.nix +++ b/users/seth/default.nix @@ -1,37 +1,24 @@ { + config, pkgs, - specialArgs, - user, - system ? "x86_64-linux", -}: let - common = { - username = "seth"; - stateVersion = "23.05"; + home-manager, + ... +}: { + users.users.seth = { + extraGroups = ["wheel"]; + isNormalUser = true; + hashedPassword = "***REMOVED***"; + shell = pkgs.fish; }; -in - with user; { - hm.seth = mkHMUser { - inherit (common) username stateVersion; - inherit system; - channel = pkgs; - extraSpecialArgs = { - standalone = true; - desktop = ""; - }; - }; - system = mkUser { - inherit (common) username stateVersion; - inherit system; - extraGroups = ["wheel"]; - extraModules = [ - { - programs.fish.enable = true; - } - ]; - extraSpecialArgs = specialArgs; - hashedPassword = "***REMOVED***"; - shell = pkgs.legacyPackages.${system}.fish; - hm = true; - }; - } + programs.fish.enable = true; + + home-manager.users.seth = let + inherit (config.nixpkgs) overlays; + in { + imports = [ + ./home.nix + ]; + nixpkgs.overlays = overlays; + }; +} diff --git a/users/seth/desktop/default.nix b/users/seth/desktop/default.nix index 3e6b68e..3bd83be 100644 --- a/users/seth/desktop/default.nix +++ b/users/seth/desktop/default.nix @@ -1,23 +1,8 @@ -{ - pkgs, - desktop, - ... -}: { - imports = - [ - ../programs/mangohud.nix - ../programs/firefox.nix - ] - ++ ( - if (desktop == "gnome") - then [./gnome.nix] - else [] - ) - ++ ( - if (desktop == "plasma") - then [./plasma.nix] - else [] - ); +{pkgs, ...}: { + imports = [ + ../programs/mangohud.nix + ../programs/firefox.nix + ]; home.packages = with pkgs; [ chromium diff --git a/users/seth/desktop/gnome.nix b/users/seth/desktop/gnome/default.nix index 8564a5e..5dc0030 100644 --- a/users/seth/desktop/gnome.nix +++ b/users/seth/desktop/gnome/default.nix @@ -1,4 +1,7 @@ {pkgs, ...}: { + imports = [ + ../. + ]; home.packages = with pkgs; [adw-gtk3] ++ (with pkgs.gnomeExtensions; [ @@ -8,45 +11,48 @@ gradience ]); - dconf.settings = { - "org/gnome/shell" = { - disable-user-extensions = false; - enabled-extensions = [ - ]; - favorite-apps = [ - "firefox.desktop" - "org.gnome.Nautilus.desktop" - "discord-canary.desktop" - ]; - }; - "org/gnome/desktop/interface" = { - color-scheme = "prefer-dark"; - font-antialiasing = ''rgba''; - font-name = ''Noto Sans 11''; - document-font-name = ''Noto Sans 11''; - monospace-font-name = ''FiraCode Nerd Font 10''; - }; - "org/gnome/desktop/peripherals/mouse" = { - accel-profile = ''flat''; - }; - "org/gnome/desktop/wm/preferences" = { - titlebar-font = ''Noto Sans Bold 11''; - }; - "org/gnome/desktop/wm/keybindings" = { - switch-windows = ["<Alt>Tab"]; - switch-windows-backward = ["<Shift><Alt>Tab"]; - }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { - name = "blackbox"; - command = "blackbox"; - binding = "<Control><Alt>t"; - }; - "com/raggesilver/BlackBox" = { - font = ''FiraCode Nerd Font 12''; - theme-dark = ''Catppuccin-Mocha''; - remember-window-size = true; + dconf = { + enable = true; + settings = { + "org/gnome/shell" = { + disable-user-extensions = false; + enabled-extensions = [ + ]; + favorite-apps = [ + "firefox.desktop" + "org.gnome.Nautilus.desktop" + "discord-canary.desktop" + ]; + }; + "org/gnome/desktop/interface" = { + color-scheme = "prefer-dark"; + font-antialiasing = ''rgba''; + font-name = ''Noto Sans 11''; + document-font-name = ''Noto Sans 11''; + monospace-font-name = ''FiraCode Nerd Font 10''; + }; + "org/gnome/desktop/peripherals/mouse" = { + accel-profile = ''flat''; + }; + "org/gnome/desktop/wm/preferences" = { + titlebar-font = ''Noto Sans Bold 11''; + }; + "org/gnome/desktop/wm/keybindings" = { + switch-windows = ["<Alt>Tab"]; + switch-windows-backward = ["<Shift><Alt>Tab"]; + }; + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { + name = "blackbox"; + command = "blackbox"; + binding = "<Control><Alt>t"; + }; + "com/raggesilver/BlackBox" = { + font = ''FiraCode Nerd Font 12''; + theme-dark = ''Catppuccin-Mocha''; + remember-window-size = true; + }; }; }; diff --git a/users/seth/desktop/plasma.nix b/users/seth/desktop/plasma/default.nix index 29cb574..24e26a7 100644 --- a/users/seth/desktop/plasma.nix +++ b/users/seth/desktop/plasma/default.nix @@ -1,4 +1,7 @@ {pkgs, ...}: { + imports = [ + ../. + ]; home.packages = with pkgs; [ catppuccin-cursors catppuccin-kde diff --git a/users/seth/home.nix b/users/seth/home.nix index 5c175e7..67b95d1 100644 --- a/users/seth/home.nix +++ b/users/seth/home.nix @@ -1,16 +1,25 @@ -{desktop, ...}: let - usingDesktop = desktop != ""; -in { - imports = - [ - ./programs - ./shell - ] - ++ ( - if usingDesktop - then [./desktop] - else [] - ); +{ + lib, + pkgs, + ... +}: { + imports = [ + ./programs + ./shell + ]; - nix.settings.warn-dirty = false; + nix = { + package = lib.mkDefault pkgs.nixFlakes; + settings.warn-dirty = false; + }; + xdg = { + enable = true; + configFile."nixpkgs/config.nix".text = '' + { + allowUnfree = true; + allowUnsupportedSystem; + } + ''; + }; + home.stateVersion = "23.05"; } diff --git a/users/seth/shell/bash.nix b/users/seth/shell/bash.nix index b3a1257..f9a1afa 100644 --- a/users/seth/shell/bash.nix +++ b/users/seth/shell/bash.nix @@ -1,16 +1,10 @@ -{ - config, - standalone, - ... -}: { +{config, ...}: { programs.bash = { enable = true; - bashrcExtra = - if standalone - then '' - . ${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.sh - '' - else ''''; + bashrcExtra = '' + nixfile=${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.sh + [ -e "$nixfile" ] && source "$nixfile" + ''; historyFile = "${config.xdg.stateHome}/bash/history"; historyFileSize = 1000; historySize = 100; diff --git a/users/seth/shell/default.nix b/users/seth/shell/default.nix index e0e753b..a717e59 100644 --- a/users/seth/shell/default.nix +++ b/users/seth/shell/default.nix @@ -2,7 +2,6 @@ imports = [ ./bash.nix ./fish.nix - ./zsh.nix ]; home = { diff --git a/users/seth/shell/fish.nix b/users/seth/shell/fish.nix index c138db5..455a052 100644 --- a/users/seth/shell/fish.nix +++ b/users/seth/shell/fish.nix @@ -1,7 +1,6 @@ { config, pkgs, - standalone, ... }: { xdg.configFile."fish/themes" = { @@ -19,18 +18,14 @@ programs.fish = { enable = true; - interactiveShellInit = - '' - fish_config theme choose "Catppuccin Mocha" - direnv hook fish | source - '' - + ( - if standalone - then '' - . ${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.fish - '' - else '''' - ); + interactiveShellInit = '' + set -l nixfile ${config.home.homeDirectory}/.nix-profile/etc/profile.d/nix.fish + if test -e $nixfile + source $nixfile + end + fish_config theme choose "Catppuccin Mocha" + direnv hook fish | source + ''; plugins = [ { name = "autopair-fish"; diff --git a/util/default.nix b/util/default.nix index 0fb91b5..c3fa0b8 100644 --- a/util/default.nix +++ b/util/default.nix @@ -1,4 +1,14 @@ -{home-manager, ...}: { - host = import ./host.nix {}; - user = import ./user.nix {inherit home-manager;}; +{ + inputs, + lib, +}: let + mapFilterDirs = dir: filter: map: + with builtins; + with lib; let + dirs = filterAttrs filter (readDir dir); + in + mapAttrs map dirs; +in { + host = import ./host.nix {inherit lib inputs mapFilterDirs;}; + user = import ./user.nix {inherit lib inputs mapFilterDirs;}; } diff --git a/util/host.nix b/util/host.nix index 2c7906c..d100bfb 100644 --- a/util/host.nix +++ b/util/host.nix @@ -1,38 +1,45 @@ -_: { +{ + lib, + inputs, + mapFilterDirs, +}: rec { mkHost = { name, modules, - system ? "x86_64-linux", specialArgs ? {}, - version ? "22.11", + system ? "x86_64-linux", + stateVersion ? "22.11", pkgs, - }: { - ${name} = with pkgs.lib; + }: + with pkgs.lib; nixosSystem { inherit system specialArgs; modules = [ - ../hosts/common + ../profiles/base + ../profiles/nixos ../hosts/${name} - ({pkgs, ...}: { - system.stateVersion = version; + { + system.stateVersion = stateVersion; networking.hostName = mkDefault name; - - # enable non-free packages - nixpkgs.config = { - allowUnfree = true; - allowUnsupportedSystem = true; + nixpkgs = { + overlays = with inputs; [nur.overlay getchoo.overlays.default]; + config = { + allowUnfree = true; + allowUnsupportedSystem = true; + }; }; - - # Enable nix flakes - nix = { - package = pkgs.nixFlakes; - settings.experimental-features = ["nix-command" "flakes"]; - }; - }) + nix.registry.getchoo.flake = inputs.getchoo; + } ] ++ modules; }; - }; + + mapHosts = hosts: + mapFilterDirs ../hosts (_: v: v == "directory") (name: _: + mkHost { + inherit name; + inherit (hosts.${name}) modules system stateVersion pkgs; + }); } diff --git a/util/user.nix b/util/user.nix index 3953f11..c120e31 100644 --- a/util/user.nix +++ b/util/user.nix @@ -1,92 +1,33 @@ -{home-manager, ...}: let - commonHM = { - nixpkgs.config = { - allowUnfree = true; - allowUnsupportedSystem = true; - }; - xdg.configFile."nixpkgs/config.nix".text = '' - { - allowUnfree = true; - } - ''; - }; -in { +{ + lib, + inputs, + mapFilterDirs, + ... +}: rec { mkHMUser = { username, - channel, - modules ? [], + pkgs, stateVersion ? "22.11", - system ? "x86_64-linux", - extraSpecialArgs ? {}, - }: - home-manager.lib.homeManagerConfiguration { - pkgs = channel.legacyPackages.${system}; - inherit extraSpecialArgs; - modules = - [ - ../users/${username}/home.nix - ({pkgs, ...}: - { - home = { - inherit username stateVersion; - homeDirectory = "/home/${username}"; - }; - - programs.home-manager.enable = true; - nix = { - package = pkgs.nixFlakes; - settings.experimental-features = ["nix-command" "flakes"]; - }; - } - // commonHM) - ] - ++ modules; - }; - mkUser = { - username, - extraGroups ? [], - extraModules ? [], - extraSpecialArgs ? {}, - hashedPassword, - hm ? false, - shell, - stateVersion, - system ? "x86_64-linux", }: - [ - { - users.users.${username} = { - inherit extraGroups hashedPassword shell; - isNormalUser = true; - }; - } - ] - ++ extraModules - ++ ( - if hm - then [ - home-manager.nixosModules.home-manager + inputs.home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ../users/${username}/home.nix { - home-manager = { - inherit extraSpecialArgs; - useGlobalPkgs = true; - useUserPackages = true; - users.${username} = - { - imports = [ - ../users/${username}/home.nix - ]; - home.stateVersion = stateVersion; - } - // commonHM - // ( - if builtins.match ".*-linux" system != null - then {systemd.user.startServices = true;} - else {} - ); + home = { + inherit username stateVersion; + homeDirectory = "/home/${username}"; }; + + programs.home-manager.enable = true; } - ] - else [] - ); + ]; + }; + + mapHMUsers = users: + mapFilterDirs ../users (n: v: v == "directory" && n != "root") (username: _: + mkHMUser { + inherit username; + inherit (users.${username}) pkgs stateVersion; + }); } |
