From 5c0749c36ef22c5769dbafdf975869a52dc0380c Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Fri, 15 Sep 2023 00:21:07 +0200 Subject: [PATCH] Develop edison, standardize home-manager --- base.nix | 5 ++- flake.nix | 5 +++ home/base.nix | 36 +++++++++++++++++ home/felixalb/home.nix | 46 ---------------------- home/felixalb/nvim.nix | 69 --------------------------------- {hosts/worf => home}/neovim.nix | 0 {hosts/worf => home}/zsh.nix | 1 - hosts/edison/configuration.nix | 56 ++++++-------------------- hosts/edison/desktop.nix | 11 ++++++ hosts/edison/home.nix | 23 +++++++++++ hosts/worf/home.nix | 31 +-------------- 11 files changed, 92 insertions(+), 191 deletions(-) create mode 100644 home/base.nix delete mode 100644 home/felixalb/home.nix delete mode 100644 home/felixalb/nvim.nix rename {hosts/worf => home}/neovim.nix (100%) rename {hosts/worf => home}/zsh.nix (94%) create mode 100644 hosts/edison/desktop.nix create mode 100644 hosts/edison/home.nix diff --git a/base.nix b/base.nix index fa002b0..92b0028 100644 --- a/base.nix +++ b/base.nix @@ -7,7 +7,7 @@ networking = { domain = "home.feal.no"; - useDHCP = false; + useDHCP = lib.mkDefault false; }; time.timeZone = "Europe/Oslo"; @@ -15,7 +15,7 @@ console = { font = "Lat2-Terminus16"; - keyMap = "no"; + keyMap = lib.mkDefault "no"; }; nix = { @@ -78,6 +78,7 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHkLmJIkBM6AMbYM/hYm27Flgya81UiGqh9/owYWmrbZ home.feal.no" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH5M7hYl3saBNMAo6sczgfUvASEJWFHuERB7xvf4gxst nix-builder-voyager-worf" ]; + shell = pkgs.zsh; }; sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; } diff --git a/flake.nix b/flake.nix index f2079c6..3c1b1a6 100644 --- a/flake.nix +++ b/flake.nix @@ -58,6 +58,11 @@ ./hosts/edison/configuration.nix sops-nix.nixosModules.sops + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users."felixalb" = import ./hosts/edison/home.nix; + } ]; }; chapel = nixpkgs.lib.nixosSystem { diff --git a/home/base.nix b/home/base.nix new file mode 100644 index 0000000..2b04a57 --- /dev/null +++ b/home/base.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: +{ + imports = [ + ./neovim.nix + ./zsh.nix + ]; + + programs.nix-index = { + enable = true; + enableZshIntegration = true; + }; + + programs.git = { + enable = true; + + extraConfig = { + pull.rebase = true; + push.autoSetupRemote = true; + color.ui = "auto"; + init.defaultBranch = "main"; + lfs.enable = true; + + user = { + name = "Felix Albrigtsen"; + email = "felix@albrigtsen.it"; + }; + }; + ignores = [ + "*~" + "*.swp" + ".DS_Store" + ".vscode" + ]; + }; + +} diff --git a/home/felixalb/home.nix b/home/felixalb/home.nix deleted file mode 100644 index f19ad26..0000000 --- a/home/felixalb/home.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ config, pkgs, ... }: -{ - imports = [ - ./nvim.nix - ]; - home.username = "felixalb"; - home.homeDirectory = "/home/felixalb"; - home.stateVersion = "22.11"; - - programs = { - home-manager.enable = true; - alacritty = { - enable = true; - }; - firefox.enable = true; - rofi.enable = true; - zsh = { - enable = true; - enableAutosuggestions = true; - enableSyntaxHighlighting = true; - prezto = { - enable = true; - prompt.theme = "paradox"; - }; - # initExtra = '' - # bindkey "''${key[Up]}" up-line-or-search - # bindkey "''${key[Down]}" down-line-or-search - # ''; - }; - git = { - enable = true; - userName = "Felix Albrigtsen"; - userEmail = "felixalbrigtsen@gmail.com"; - }; - }; - - services = { - redshift = { - enable = true; - tray = true; - - duskTime = "19:30-20:30"; - dawnTime = "7:30-8:30"; - }; - }; -} diff --git a/home/felixalb/nvim.nix b/home/felixalb/nvim.nix deleted file mode 100644 index b24c4df..0000000 --- a/home/felixalb/nvim.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ pkgs, config, ... } -{ - programs.neovim = { - enable = true; - vimAlias = true; - - extraConfig = '' - set number " Show line numbers - set number relativenumber " Enable hybrid line numbers - set nu rnu - set signcolumn=number - set showmatch " Highlight matching brace - set errorbells " Beep or flash screen on errors - - set hlsearch " Highlight all search results - set smartcase " Enable smart-case search - set incsearch " Searches for strings incrementally - - set autoindent " Auto-indent new lines - set expandtab " Use spaces instead of tabs - set shiftwidth=2 " Number of auto-indent spaces - set smartindent " Enable smart-indent - set smarttab " Enable smart-tabs - set softtabstop=0 " Number of spaces per Tab, auto - - set updatetime=300 " Time interval for updating buffers - - set ruler " Show row and column ruler information - - set undolevels=1000 " Number of undo levels - set backspace=indent,eol,start " Backspace behaviour - ''; - - plugins = with pkgs.vimPlugins; [ - vim-nix - vim-commentary - vim-devicons - { plugin = nerdtree; - config = " - nmap :NERDTreeToggle - autocmd VimEnter * NERDTree \" Autostart nerdtree on vim startup - autocmd VimEnter * wincmd p \" Unselect nerdtree window - \" Close vim if Nerdtree is the only buffer left - autocmd bufenter * if (winnr(\"$\") == 1 && exists(\"b:NERDTree\") && b:NERDTree.isTabTree()) | q | endif - "; - } - ]; - withNodeJs = true; - coc = { - enable = true; - settings = { - "suggest.enablePreview" = true; - "suggest.enablePreselect" = true; - }; - - package = pkgs.vimUtils.buildVimPluginFrom2Nix { - pname = "coc.nvim"; - version = "2022-05-21"; - src = pkgs.fetchFromGitHub { - owner = "neoclide"; - repo = "coc.nvim"; - rev = "791c9f673b882768486450e73d8bda10e391401d"; - sha256 = "sha256-MobgwhFQ1Ld7pFknsurSFAsN5v+vGbEFojTAYD/kI9c="; - }; - meta.homepage = "https://github.com/neoclide/coc.nvim/"; - }; - }; - }; -} diff --git a/hosts/worf/neovim.nix b/home/neovim.nix similarity index 100% rename from hosts/worf/neovim.nix rename to home/neovim.nix diff --git a/hosts/worf/zsh.nix b/home/zsh.nix similarity index 94% rename from hosts/worf/zsh.nix rename to home/zsh.nix index f0736f7..f7ba0d1 100644 --- a/hosts/worf/zsh.nix +++ b/home/zsh.nix @@ -43,7 +43,6 @@ shellAliases = { l = "exa -l"; tree = "exa --tree --icons"; - rebuild = "darwin-rebuild switch --flake /Users/felixalb/nix"; s = "nix-shell --run zsh"; sp = "nix-shell --run zsh -p"; em = "emacsclient -c"; diff --git a/hosts/edison/configuration.nix b/hosts/edison/configuration.nix index f2bad7e..fb9585f 100644 --- a/hosts/edison/configuration.nix +++ b/hosts/edison/configuration.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { imports = @@ -6,62 +6,30 @@ ../../base.nix ../../common/metrics-exporters.nix ./hardware-configuration.nix + ./desktop.nix ]; networking = { hostName = "edison"; defaultGateway = "192.168.10.1"; nameservers = [ "192.168.11.100" "1.1.1.1" ]; - interfaces.eno1.ipv4 = { - addresses = [ - { address = "192.168.10.170"; prefixLength = 24; } - ]; - }; - hostId = "8f84a235"; + + # Networking / Wi-Fi is configured with NM for now. TODO + networkmanager.enable = true; }; + console.keyMap = "us"; + # sops.defaultSopsFile = ../../secrets/edison/edison.yaml; environment.variables = { EDITOR = "vim"; }; - environment.systemPackages = with pkgs; [ - ((vim_configurable.override { }).customize{ - name = "vim"; - vimrcConfig.packages.myplugins = with pkgs.vimPlugins; { - start = [ vim-nix vim-lastplace vim-commentary ]; - opt = []; - }; - vimrcConfig.customRC = '' - " your custom vimrc - set number - set relativenumber - set nu rnu - set signcolumn=number + # environment.systemPackages = with pkgs; [ + # ]; - set hlsearch - set smartcase - set incsearch - - set autoindent - set expandtab - set shiftwidth=2 - set tabstop=2 - set smartindent - set smarttab - - set ruler - - set undolevels=1000 - - set nocompatible - set backspace=indent,eol,start - " Turn on syntax highlighting by default - syntax on - " ... - ''; - } - ) + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "nvidia-x11" + "nvidia-settings" ]; - networking.firewall.allowedTCPPorts = [ 22 ]; system.stateVersion = "23.05"; diff --git a/hosts/edison/desktop.nix b/hosts/edison/desktop.nix new file mode 100644 index 0000000..6e3d853 --- /dev/null +++ b/hosts/edison/desktop.nix @@ -0,0 +1,11 @@ +{ config, pkgs, lib, ... }: +{ + services.xserver = { + enable = true; + desktopManager.xfce.enable = true; + #displayManager.ly.enable = true; + videoDrivers = [ "nvidia" ]; + }; + services.picom.enable = true; + hardware.opengl.enable = true; +} diff --git a/hosts/edison/home.nix b/hosts/edison/home.nix new file mode 100644 index 0000000..1a52d12 --- /dev/null +++ b/hosts/edison/home.nix @@ -0,0 +1,23 @@ +{ pkgs, lib, ... }: +{ + home.packages = with pkgs; [ + bat + bottom + ncdu + neofetch + nix-index + ]; + + imports = [ + ./../../home/base.nix + ]; + + programs = { + alacritty.enable = true; + firefox.enable = true; + rofi.enable = true; + zsh.shellAliases."rebuild" = "nixos-rebuild switch --flake /config"; + }; + + home.stateVersion = "23.05"; +} diff --git a/hosts/worf/home.nix b/hosts/worf/home.nix index 81a2c38..e42061d 100644 --- a/hosts/worf/home.nix +++ b/hosts/worf/home.nix @@ -5,8 +5,7 @@ , ... }: { imports = [ - ./neovim.nix - ./zsh.nix + ./../../home/base.nix ]; home.packages = with pkgs; [ @@ -27,33 +26,7 @@ vscode ]; - programs.git = { - enable = true; - - extraConfig = { - pull.rebase = true; - push.autoSetupRemote = true; - color.ui = "auto"; - init.defaultBranch = "main"; - lfs.enable = true; - - user = { - name = "Felix Albrigtsen"; - email = "felix@albrigtsen.it"; - }; - }; - ignores = [ - "*~" - "*.swp" - ".DS_Store" - ".vscode" - ]; - }; - - programs.nix-index = { - enable = true; - enableZshIntegration = true; - }; + programs.zsh.shellAliases."rebuild" = "darwin-rebuild switch --flake /Users/felixalb/nix"; # Copy Applications to ~/Applications to allow them to be launched from Spotlight disabledModules = [ "targets/darwin/linkapps.nix" ];