diff --git a/default.nix b/default.nix index 506c00a..e5679d7 100644 --- a/default.nix +++ b/default.nix @@ -1,9 +1,8 @@ { inputs, config, lib, pkgs, ... }: let inherit (builtins) toString; - inherit (lib.attrsets) attrValues filterAttrs mapAttrs mapAttrsToList; - inherit (lib.modules) mkAliasOptionModule mkDefault mkIf; - inherit (lib.my) mapModulesRec'; + inherit (lib.modules) mkAliasOptionModule mkIf; + inherit (lib.my) mapModulesRec' mapModules mkSysUser mkHmUser; in { imports = [ @@ -14,8 +13,6 @@ in inputs.sops-nix.nixosModules.sops (mkAliasOptionModule ["hm"] ["home-manager" "users" config.user.name]) (mkAliasOptionModule ["home"] ["hm" "home"]) - (mkAliasOptionModule ["create" "configFile"] ["hm" "xdg" "configFile"]) - (mkAliasOptionModule ["create" "dataFile"] ["hm" "xdg" "dataFile"]) ] ++ (mapModulesRec' (toString ./modules) import); @@ -37,9 +34,4 @@ in age.keyFile = "/home/"; }; - - system = { - stateVersion = "23.11"; - configurationRevision = with inputs; mkIf (self ? rev) self.rev; - }; } diff --git a/flake.nix b/flake.nix index dcd01a5..a82b93a 100644 --- a/flake.nix +++ b/flake.nix @@ -91,7 +91,5 @@ // mapModulesRec ./modules import; nixosConfigurations = mapHosts ./hosts {}; - - devShells."${system}".default = import ./shell.nix { inherit lib pkgs; }; }; } diff --git a/hosts/chris-pc/default.nix b/hosts/chris-pc/default.nix index f35de8d..369beaa 100644 --- a/hosts/chris-pc/default.nix +++ b/hosts/chris-pc/default.nix @@ -1,7 +1,5 @@ { config, lib, pkgs, ... }: { - imports = [ ./hardware.nix ]; - user.name = "chris"; fileSystems."/home/chris/games" = { diff --git a/hosts/chris-pc/users/Kaas/default.nix b/hosts/chris-pc/users/Kaas/default.nix new file mode 100644 index 0000000..f5e5722 --- /dev/null +++ b/hosts/chris-pc/users/Kaas/default.nix @@ -0,0 +1,5 @@ +{}: +{ + full_name = "WOOOP WOOOP"; + is_trusted = true; +} diff --git a/hosts/chris-pc/users/chris.nix b/hosts/chris-pc/users/chris.nix deleted file mode 100644 index ebbe342..0000000 --- a/hosts/chris-pc/users/chris.nix +++ /dev/null @@ -1,65 +0,0 @@ -// { config, lib, pkgs, ... }: -// { -// full_name = "WOOT"; - -// modules = { -// themes = { -// enable = true; -// theme = "everforest"; -// polarity = "dark"; -// }; - -// develop = { -// rust.enable = true; -// js.enable = true; -// dotnet.enable = true; -// }; - -// # EXPERIMENTS -// # services.games.minecraft.enable = true; -// services.auth.enable = true; - -// desktop = { -// plasma.enable = true; -// type = "wayland"; - -// applications = { -// communication.enable = true; -// email.enable = true; -// office.enable = true; -// steam.enable = true; -// recording.enable = true; -// }; - -// terminal = { -// default = "ghostty"; -// alacritty.enable = true; -// ghostty.enable = true; -// }; - -// editors = { -// default = "zed"; -// vscodium.enable = true; -// zed.enable = true; -// nvim.enable = true; -// nano.enable = true; -// kate.enable = true; -// }; - -// browsers = { -// default = "chromium"; -// firefox.enable = true; -// chrome.enable = true; -// }; - -// games = { -// minecraft.enable = true; -// }; -// }; - -// shell = { -// default = "zsh"; -// corePkgs.enable = true; -// }; -// }; -// } diff --git a/lib/nixos.nix b/lib/nixos.nix index 31fc570..76e94c9 100644 --- a/lib/nixos.nix +++ b/lib/nixos.nix @@ -1,24 +1,53 @@ -{ inputs, lib, pkgs, self, ... }: -let +{ + inputs, + lib, + pkgs, + self, + ... +}: let inherit (inputs.nixpkgs.lib) nixosSystem; inherit (builtins) baseNameOf elem; inherit (lib.attrsets) filterAttrs; inherit (lib.modules) mkDefault; inherit (lib.strings) removeSuffix; inherit (self.modules) mapModules; + inherit (self) mkSysUser mkHmUser; in rec { mkHost = path: attrs @ {system ? "x86_64-linux", ...}: nixosSystem { inherit system; - specialArgs = { inherit lib inputs system; }; + specialArgs = {inherit lib inputs system;}; - modules = [ + modules = + let + stateVersion = "23.11"; + in [ inputs.nixos-boot.nixosModules.default { nixpkgs.pkgs = pkgs; networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path)); + + system = { + inherit stateVersion; + configurationRevision = with inputs; mkIf (self ? rev) self.rev; + }; + + imports = [ "${path}/hardware.nix" ]; + + users = { + mutableUsers = false; + users = mapModules "${path}/users" mkSysUser; + }; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + sharedModules = [ + inputs.plasma-manager.homeManagerModules.plasma-manager + ]; + users = mapModules "${path}/users" (p: mkHmUser p stateVersion); + }; } (filterAttrs (n: v: !elem n ["system"]) attrs) ../. # ../default.nix @@ -26,6 +55,6 @@ in rec ]; }; - mapHosts = dir: attrs @ { system ? system, ... }: + mapHosts = dir: attrs @ {system ? system, ...}: mapModules dir (hostPath: mkHost hostPath attrs); } diff --git a/lib/user.nix b/lib/user.nix new file mode 100644 index 0000000..e7046b9 --- /dev/null +++ b/lib/user.nix @@ -0,0 +1,31 @@ +{ lib, ... }: let + inherit (builtins) baseNameOf; + inherit (lib.attrsets) filterAttrs; + inherit (lib.strings) removeSuffix; +in rec +{ + mkSysUser = path: let + user = import path {}; + name = removeSuffix ".nix" (baseNameOf path); + in + { + inherit name; + inherit (user) is_trusted; + description = user.full_name; + extraGroups = (if user.is_trusted then [ "wheel" ] else []); + isNormalUser = true; + home = "/home/${name}"; + group = "users"; + }; + + mkHmUser = path: stateVersion: let + user = import path {}; + name = removeSuffix ".nix" (baseNameOf path); + in + { + home = { + inherit stateVersion; + sessionPath = [ "$SNEEUWVLOK_BIN" "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this. + }; + }; +} diff --git a/modules/desktop/editors/zed.nix b/modules/desktop/editors/zed.nix index 5eb8dba..ca0aa66 100644 --- a/modules/desktop/editors/zed.nix +++ b/modules/desktop/editors/zed.nix @@ -1,19 +1,67 @@ -{ config, options, lib, pkgs, ... }: -let - inherit (lib.meta) getExe; +{ + config, + options, + lib, + pkgs, + ... +}: let inherit (lib.modules) mkIf; inherit (lib.attrsets) attrValues; cfg = config.modules.desktop.editors.zed; -in -{ +in { options.modules.desktop.editors.zed = let inherit (lib.options) mkEnableOption; - in { enable = mkEnableOption "zed"; }; + in {enable = mkEnableOption "zed";}; config = mkIf cfg.enable { user.packages = attrValues { inherit (pkgs) zed-editor; }; + + hm.programs.zed-editor = { + enable = true; + + extraPackages = with pkgs; [ nixd nil alejandra ]; + extensions = ["nix" "toml" "html"]; + + userSettings = { + assistant.enabled = false; + + vim_mode = false; + load_direnv = "shell_hook"; + base_keymap = "JetBrains"; + + tabs = { + file_icons = true; + git_status = true; + }; + project_panel.auto_reveal_entries = false; + + hour_format = "hour24"; + auto_update = false; + + lsp = { + nixd = {}; + nil = { + initialization_options = { + formatting = { + command = ["alejandra" "--quiet" "--"]; + }; + }; + binary = { + path_lookup = true; + }; + }; + }; + + languages = { + "Nix" = { + language_servers = ["nixd" "nil"]; + format_on_save = "on"; + }; + }; + }; + }; }; } diff --git a/modules/desktop/terminal/alacritty.nix b/modules/desktop/terminal/alacritty.nix index d04dc9f..bc3a7cd 100644 --- a/modules/desktop/terminal/alacritty.nix +++ b/modules/desktop/terminal/alacritty.nix @@ -45,55 +45,7 @@ in { args = ["-l" "-c" "tmux new || tmux"]; }; } - -# (mkIf (active != null) { -# import = ["~/.config/alacritty/config/${active}.toml"]; -# }) ]; }; - -# create.configFile = mkIf (active != null) { -# alacritty-conf = { -# target = "alacritty/config/${active}.toml"; -# source = let -# inherit (config.modules.themes.font) mono sans; -# tomlFormat = pkgs.formats.toml {}; -# in tomlFormat.generate "alacritty-theme" { -# font = { -# builtin_box_drawing = true; -# size = mono.size; -# -# normal = { -# family = "${mono.family}"; -# style = "${sans.weight}"; -# }; -# -# italic = { -# family = "${mono.family}"; -# style = "${sans.weight} Italic"; -# }; -# -# bold = { -# family = "${mono.family}"; -# style = "${mono.weight}"; -# }; -# -# bold_italic = { -# family = "${mono.family}"; -# style = "${mono.weight} Italic"; -# }; -# -# offset = { -# x = 0; -# y = 0; -# }; -# glyph_offset = { -# x = 0; -# y = 0; -# }; -# }; -# }; -# }; -# }; }; } diff --git a/modules/options.nix b/modules/options.nix index e06cd85..90872bd 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -6,7 +6,7 @@ let in { options = let - inherit (lib.types) attrs path str; + inherit (lib.types) attrs path; inherit (lib.my) mkOpt; in { @@ -14,7 +14,7 @@ in sneeuwvlok = { dir = mkOpt path (findFirst pathExists (toString ../.) [ - "${config.user.home}/Github/.files" + "${config.user.home}/Github/sneeuwvlok" ]); hostDir = mkOpt path "${config.sneeuwvlok.dir}/hosts/${config.networking.hostName}"; configDir = mkOpt path "${config.sneeuwvlok.dir}/config"; @@ -24,10 +24,6 @@ in }; config = { - environment.systemPackages = [ - pkgs.sops - ]; - user = { name = "chris"; description = "Chris Kruining"; @@ -38,27 +34,16 @@ in uid = 1000; }; - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - sharedModules = [ - inputs.plasma-manager.homeManagerModules.plasma-manager - ]; - }; + users.users.${config.user.name} = mkAliasDefinitions options.user; - home = { - stateVersion = config.system.stateVersion; - sessionPath = [ "$SNEEUWVLOK_BIN" "$XDG_BIN_HOME" "$PATH" ]; - }; + nix.settings = let + inherit (lib) attrNames filterAttrs; - users.users = { - ${config.user.name} = mkAliasDefinitions options.user; - }; - - nix.settings = let users = [ "root" config.user.name ]; in - { - trusted-users = users; - allowed-users = users; - }; + users = (attrNames (filterAttrs ({ is_trusted ? false }: is_trusted) config.users)) ++ [ "root" ]; + in + { + trusted-users = users; + allowed-users = users; + }; }; } diff --git a/modules/shell/toolset/btop.nix b/modules/shell/toolset/btop.nix index b768fdc..74a71d3 100644 --- a/modules/shell/toolset/btop.nix +++ b/modules/shell/toolset/btop.nix @@ -89,56 +89,5 @@ in log_level = "DEBUG"; }; }; - -# create.configFile.btop-theme = let -# inherit (config.modules.themes) active; -# in -# mkIf (active != null) { -# target = "btop/themes/${active}.theme"; -# text = '' -# theme[main_bg]="bg" -# theme[main_fg]="fg" -# theme[title]="fg" -# theme[hi_fg]="highlight" -# theme[selected_bg]="border" -# theme[selected_fg]="bg" -# theme[inactive_fg]="brightBlack" -# theme[graph_text]="brightYellow" -# theme[meter_bg]="brightblack" -# theme[proc_misc]="brightYellow" -# theme[cpu_box]="brightCyan" -# theme[mem_box]="brightGreen" -# theme[net_box]="brightMagenta" -# theme[proc_box]="brightYellow" -# theme[div_line]="brightblack" -# theme[temp_start]="brightYellow" -# theme[temp_mid]="panelbg" -# theme[temp_end]="brightRed" -# theme[cpu_start]="brightCyan" -# theme[cpu_mid]="border" -# theme[cpu_end]="brightGreen" -# theme[free_start]="brightGreen" -# theme[free_mid]="brightGreen" -# theme[free_end]="brightGreen" -# theme[cached_start]="brightYellow" -# theme[cached_mid]="brightYellow" -# theme[cached_end]="brightMagenta" -# theme[available_start]="brightYellow" -# theme[available_mid]="brightYellow" -# theme[available_end]="brightYellow" -# theme[used_start]="panelbg" -# theme[used_mid]="panelbg" -# theme[used_end]="brightRed" -# theme[download_start]="brightBlue" -# theme[download_mid]="brightBlue" -# theme[download_end]="brightMagenta" -# theme[upload_start]="brightBlue" -# theme[upload_mid]="brightBlue" -# theme[upload_end]="brightMagenta" -# theme[process_start]="brightCyan" -# theme[process_mid]="border" -# theme[process_end]="brightGreen" -# ''; -# }; }; } diff --git a/modules/shell/zsh.nix b/modules/shell/zsh.nix index 997e156..d2b8a2a 100644 --- a/modules/shell/zsh.nix +++ b/modules/shell/zsh.nix @@ -159,7 +159,7 @@ in # }; }; - create.configFile.zsh-abbreviations = { + hm.xdg.configFile."zsh-abbreviations" = { target = "zsh/abbreviations"; text = let abbrevs = import "${config.sneeuwvlok.configDir}/shell-abbr"; diff --git a/modules/system/security.nix b/modules/system/security.nix index 4a7fbac..b001307 100644 --- a/modules/system/security.nix +++ b/modules/system/security.nix @@ -3,6 +3,7 @@ environment.systemPackages = with pkgs; [ kdePackages.kwallet-pam bitwarden + sops ]; security = {