diff --git a/.tmp/flake.nix b/.tmp/flake.nix new file mode 100644 index 0000000..426c05b --- /dev/null +++ b/.tmp/flake.nix @@ -0,0 +1,30 @@ +{ + description = "Home Manager configuration of ari"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs. + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + homeConfigurations."ari" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + + # Specify your home configuration modules here, for example, + # the path to your home.nix. + modules = [ ./home.nix ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; +} diff --git a/.tmp/home.nix b/.tmp/home.nix new file mode 100644 index 0000000..b889661 --- /dev/null +++ b/.tmp/home.nix @@ -0,0 +1,76 @@ +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "ari"; + home.homeDirectory = "/home/ari"; + + # 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 = "24.05"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = [ + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # pkgs.hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/ari/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/hosts/fwbook.nix b/hosts/fwbook.nix index 41d57bd..fc790f5 100644 --- a/hosts/fwbook.nix +++ b/hosts/fwbook.nix @@ -1,7 +1,7 @@ { user, dataDir ? "/mnt/Data", unstable }: { pkgs, lib, config, ... }: let - zshFWBook = builtins.filterSource (p: t: true) ../configs/fwbook; + zshFWBook = builtins.filterSource (p: t: true) ./scripts/fwbook; zshFunctions = zshFWBook + "/functions.sh"; in { diff --git a/configs/fwbook/functions.sh b/hosts/scripts/fwbook/functions.sh similarity index 100% rename from configs/fwbook/functions.sh rename to hosts/scripts/fwbook/functions.sh diff --git a/modules/skyg/gitconfigs/alias.conf b/modules/gitconfigs/alias.conf similarity index 100% rename from modules/skyg/gitconfigs/alias.conf rename to modules/gitconfigs/alias.conf diff --git a/modules/home-manager.nix b/modules/home-manager.nix new file mode 100644 index 0000000..6728394 --- /dev/null +++ b/modules/home-manager.nix @@ -0,0 +1,101 @@ +{ stateVersion +, enableDevelopmentKit +, name +, fullName +, email +, extraGitConfigs ? [ ] +}: +let + gitconfigs = + (builtins.filterSource (path: type: type != "directory") ./gitconfigs); + gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs); + commonGitConfigs = { + delta = { enable = true; }; + extraConfig = { + color = { ui = "auto"; }; + push = { + default = "upstream"; + autoSetupRemote = true; + }; + init = { defaultBranch = "main"; }; + }; + includes = + (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles) + ++ extraGitConfigs; + }; + commonProgramsConfig = { pkgs }: { + bat.enable = true; + neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + }; + direnv.enable = true; + lsd = { + enable = true; + enableAliases = true; + }; + zsh = { + enable = true; + autosuggestion.enable = true; + initExtra = '' + export PROMPT='%(!.%{%F{yellow}%}.)$USER@%{$fg[white]%}%M %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' + ''; + }; + zsh.oh-my-zsh = { + enable = true; + plugins = [ "git" "sudo" ]; + theme = "robbyrussell"; + }; + tmux = { + enable = true; + clock24 = true; + mouse = true; + plugins = with pkgs.tmuxPlugins; [ nord cpu battery sidebar ]; + }; + }; +in +{ + makeRootUser = { pkgs, ... }: { + home = { + stateVersion = stateVersion; + shellAliases = { + cat = "bat"; + }; + }; + programs = { + git = { + enable = true; + userName = "root"; + } // commonGitConfigs; + } // (commonProgramsConfig { pkgs = pkgs; }); + }; + + makeCommonUser = { pkgs, ... }: { + home = { + stateVersion = stateVersion; + shellAliases = { + cat = "bat"; + }; + packages = with pkgs; + [ jq nixpkgs-fmt ipfetch nixd ] + ++ (if enableDevelopmentKit then [ + rye + devenv + uv + devbox + terraform + kubectl + ] else + [ ]); + }; + programs = { + git = { + enable = true; + userName = fullName; + userEmail = email; + } // commonGitConfigs; + } // (commonProgramsConfig { pkgs = pkgs; }); + }; +} diff --git a/modules/os/default.nix b/modules/os/default.nix index b7b034c..1607245 100644 --- a/modules/os/default.nix +++ b/modules/os/default.nix @@ -12,7 +12,6 @@ { pkgs, ... }: { imports = [ (import ./core.nix { user = user; }) - ./rootUser.nix (import ./user.nix { user = user; }) (import ./containers/default.nix ({ user = user; diff --git a/modules/os/rootUser.nix b/modules/os/rootUser.nix deleted file mode 100644 index 7cab540..0000000 --- a/modules/os/rootUser.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs, ... }: -{ - users.users.root.shell = pkgs.zsh; -} diff --git a/modules/skyg/core.nix b/modules/skyg/core.nix index 558cfd6..5c85ba6 100644 --- a/modules/skyg/core.nix +++ b/modules/skyg/core.nix @@ -16,6 +16,7 @@ in }; config = { + users.users.root.shell = pkgs.zsh; home-manager.users.root.programs.git.userEmail = "root@${cfg.hostName}"; networking.hostName = cfg.hostName; }; diff --git a/modules/skyg/user.nix b/modules/skyg/user.nix index cc2cefe..62549c0 100644 --- a/modules/skyg/user.nix +++ b/modules/skyg/user.nix @@ -4,10 +4,7 @@ with lib; let cfg = config.skyg; - gitconfigs = - (builtins.filterSource (path: type: type != "directory") ./gitconfigs); - gitconfigFiles = builtins.attrNames (builtins.readDir gitconfigs); - + hm = (import ../home-manager.nix cfg.user); in { options = { @@ -41,99 +38,7 @@ in config = { programs.zsh.enable = true; - home-manager.users.root = { - home.stateVersion = cfg.home-manager.version; - programs.git = { - enable = true; - userName = "root"; - }; - programs.zsh = { - enable = true; - autosuggestion.enable = true; - }; - programs.zsh.oh-my-zsh.enable = true; - }; - home-manager.users.${cfg.user.name} = { - home = { - sessionVariables = { }; - stateVersion = cfg.home-manager.version; - shellAliases = { - cat = "bat"; - }; - packages = with pkgs; - [ jq nixfmt-classic devenv ipfetch nixd ] - ++ (if cfg.user.enableDevelopmentKit then [ - rye - uv - devbox - terraform - kubectl - ] else - [ ]); - }; - programs = { - bat.enable = true; - neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - }; - direnv.enable = true; - lsd = { - enable = true; - enableAliases = true; - }; - git = { - enable = true; - userName = cfg.user.fullName; - userEmail = cfg.user.email; - delta = { enable = true; }; - extraConfig = { - color = { ui = "auto"; }; - push = { - default = "upstream"; - autoSetupRemote = true; - }; - init = { defaultBranch = "main"; }; - }; - includes = - (builtins.map (f: { path = gitconfigs + "/" + f; }) gitconfigFiles) - ++ cfg.user.extraGitConfigs; - }; - zsh = { - enable = true; - autosuggestion.enable = true; - initExtra = '' - export PROMPT='%(!.%{%F{yellow}%}.)$USER@%{$fg[white]%}%M %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' - ''; - }; - zsh.oh-my-zsh = { - enable = true; - plugins = [ "git" "sudo" ]; - theme = "robbyrussell"; - }; - tmux = { - enable = true; - clock24 = true; - mouse = true; - plugins = with pkgs.tmuxPlugins; [ nord cpu battery sidebar ]; - }; - }; - }; + home-manager.users.root = hm.makeRootUser { pkgs = pkgs; }; + home-manager.users.${cfg.user.name} = hm.makeCommonUser { pkgs = pkgs; }; }; } - - -# user = { -# name = "ari"; -# fullName = "Ari Sosnovsky"; -# email = "ariel@sosnovsky.ca"; -# }; -# sumoUser = rec { -# name = "asosnovsky"; -# fullName = user.fullName; -# email = "${name}@sumologic.com"; -# homepath = "/Users/${name}"; -# extraGitConfigs = [{ path = "${homepath}/.config/mysumo/gitconfig"; }]; -# };