diff --git a/flake.lock b/flake.lock index ef66b60..f0d84d1 100755 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -7,11 +25,11 @@ ] }, "locked": { - "lastModified": 1682203081, - "narHash": "sha256-kRL4ejWDhi0zph/FpebFYhzqlOBrk0Pl3dzGEKSAlEw=", + "lastModified": 1683651229, + "narHash": "sha256-HN0Mw8g1XQIrcdyzqT00YW0Uqi/V/BUUUAgvcK1pcSM=", "owner": "nix-community", "repo": "home-manager", - "rev": "32d3e39c491e2f91152c84f8ad8b003420eab0a1", + "rev": "983f8a1bb965b261492123cd8e2d07da46d4d50a", "type": "github" }, "original": { @@ -22,11 +40,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1680876084, - "narHash": "sha256-eP9yxP0wc7XuVaODugh+ajgbFGaile2O1ihxiLxOuvU=", + "lastModified": 1683269598, + "narHash": "sha256-KNsb+nBbB1Fmxd07dt4E0KXMT4YeKJB7gQaA6Xfk+mo=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "3006d2860a6ed5e01b0c3e7ffb730e9b293116e2", + "rev": "51559e691f1493a26f94f1df1aaf516bb507e78b", "type": "github" }, "original": { @@ -38,11 +56,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1682453498, - "narHash": "sha256-WoWiAd7KZt5Eh6n+qojcivaVpnXKqBsVgpixpV2L9CE=", + "lastModified": 1683408522, + "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c8018361fa1d1650ee8d4b96294783cf564e8a7f", + "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", "type": "github" }, "original": { @@ -52,35 +70,24 @@ "type": "github" } }, - "nixpkgs-stable": { + "nvim": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1682817260, - "narHash": "sha256-kFMXzKNj4d/0Iqbm5l57rHSLyUeyCLMuvlROZIuuhvk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "db1e4eeb0f9a9028bcb920e00abbc1409dd3ef36", + "lastModified": 1683960683, + "narHash": "sha256-hCKwb272GS5uM2eHGs1O9EMZHQIdhh51yIKYPY7Mc/E=", + "owner": "iofq", + "repo": "nvim.nix", + "rev": "bfc15eb6cb362845375e92df2298b0d776bbbbe1", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "release-22.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1682779028, - "narHash": "sha256-tFfSbwSLobpHRznAa35KEU3R+fsFWTlmpFhTUdXq8RE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "54abe781c482f51ff4ff534ebaba77db5bd97442", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", + "owner": "iofq", + "repo": "nvim.nix", "type": "github" } }, @@ -89,25 +96,21 @@ "home-manager": "home-manager", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", - "sops-nix": "sops-nix" + "nvim": "nvim" } }, - "sops-nix": { - "inputs": { - "nixpkgs": "nixpkgs_2", - "nixpkgs-stable": "nixpkgs-stable" - }, + "systems": { "locked": { - "lastModified": 1682823324, - "narHash": "sha256-KNu3OAqVyoKwnDP+gqptjQYCnZXxEwXccR89c0r1/8k=", - "owner": "Mic92", - "repo": "sops-nix", - "rev": "4f308f76633f81253a12b80e7b05b80d325005b2", + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { - "owner": "Mic92", - "repo": "sops-nix", + "owner": "nix-systems", + "repo": "default", "type": "github" } } diff --git a/flake.nix b/flake.nix index 89bdad2..281256a 100755 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Home Manager configuration"; + description = "Home Manager && NixOS configuration"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; @@ -7,18 +7,19 @@ home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; - }; - sops-nix.url = "github:Mic92/sops-nix"; - }; - outputs = { self, nixpkgs, home-manager, nixos-hardware, sops-nix, ... }: + }; + nvim = { + url = "github:iofq/nvim.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = { self, nixpkgs, home-manager, nixos-hardware, ... } @inputs: let username = "e"; in { - nixosConfigurations = ( - import ./hosts { - inherit (nixpkgs) lib; - inherit nixpkgs home-manager nixos-hardware sops-nix username; - } + nixosConfigurations = ( import ./nixos { inherit inputs; } ); + homeConfigurations = ( + import ./home { inherit inputs; } ); }; } diff --git a/home/common.nix b/home/common.nix new file mode 100755 index 0000000..0500667 --- /dev/null +++ b/home/common.nix @@ -0,0 +1,31 @@ +{ inputs, pkgs, ... }: +{ + imports = ( import ../modules/programs ); + programs.home-manager.enable = true; + nixpkgs.config.allowUnfree = true; + nix = { + settings = { + auto-optimise-store = true; + }; + package = pkgs.nixFlakes; + registry.nixpkgs.flake = inputs.nixpkgs; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + home = { + stateVersion = "22.11"; + packages = with pkgs; [ + pulseaudio + pulsemixer + alsa-utils + appimage-run + wireguard-tools + spleen + ]; + }; + + xdg.enable = true; + fonts.fontconfig.enable = true; + systemd.user.startServices = "sd-switch"; +} diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..71b69d3 --- /dev/null +++ b/home/default.nix @@ -0,0 +1,25 @@ +{ inputs, ...}: +{ + "e" = inputs.home-manager.lib.homeManagerConfiguration { + pkgs = import inputs.nixpkgs { + system = "x86_64-linux"; + config.allowUnfree = true; + overlays = [ + (final: prev: { + inherit (inputs.nvim.packages.${final.system}) iofqvim; + }) + ]; + }; + extraSpecialArgs = { + inherit inputs; + host = { + hostName = "t14"; + username = "e"; + }; + }; + modules = [ + ./t14/home.nix + ]; + }; +} + diff --git a/hosts/t14/home.nix b/home/t14/home.nix similarity index 66% rename from hosts/t14/home.nix rename to home/t14/home.nix index b5e3c16..111e468 100755 --- a/hosts/t14/home.nix +++ b/home/t14/home.nix @@ -1,19 +1,19 @@ -{ username, pkgs, ... }: +{ pkgs, ... }: { imports = [ ../../modules/wayland ../../modules/librewolf - ../home.nix + ../common.nix ]; home = { + username = "e"; + homeDirectory = "/home/e"; packages = with pkgs; [ - pulseaudio - pulsemixer - alsa-utils discord signal-desktop runelite framesh + iofqvim ]; }; } diff --git a/hosts/default.nix b/hosts/default.nix deleted file mode 100644 index 4b890e7..0000000 --- a/hosts/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ lib, nixpkgs, username, home-manager, nixos-hardware, sops-nix, ... }: - -let - system = "x86_64-linux"; - - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; - - lib = nixpkgs.lib; -in - { - t14 = lib.nixosSystem { - inherit system; - specialArgs = { - inherit username; - host = { - hostName = "t14"; - }; - }; - modules = [ - sops-nix.nixosModules.sops - ./configuration.nix - ./t14/configuration.nix - nixos-hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1 - home-manager.nixosModules.home-manager { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit username; - }; - home-manager.sharedModules = [ - sops-nix.homeManagerModule - ]; - home-manager.users.${username} = { - programs.home-manager.enable = true; - imports = [ - ./t14/home.nix - ]; - }; - } - ]; - }; - - } - diff --git a/hosts/home.nix b/hosts/home.nix deleted file mode 100755 index ea0bb6d..0000000 --- a/hosts/home.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ username, pkgs, ... }: -{ - imports = ( import ../modules/programs ); - home = { - inherit username; - stateVersion = "22.11"; - packages = with pkgs; [ - htop - appimage-run - ripgrep - fluxcd - k9s - ]; - }; - systemd.user.startServices = "sd-switch"; - xdg.enable = true; -} diff --git a/modules/programs/2fa/default.nix b/modules/programs/2fa/default.nix index b27c40d..1ac5004 100755 --- a/modules/programs/2fa/default.nix +++ b/modules/programs/2fa/default.nix @@ -28,7 +28,4 @@ enable = true; pinentryFlavor = "curses"; }; - home.packages = with pkgs; [ - oath-toolkit - ]; } diff --git a/modules/programs/default.nix b/modules/programs/default.nix index 82e93d6..893aed3 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -1,6 +1,7 @@ [ + ./dev.nix ./alacritty - ./nvim + #./nvim ./shell ./git ./2fa diff --git a/modules/programs/dev.nix b/modules/programs/dev.nix new file mode 100644 index 0000000..97506f7 --- /dev/null +++ b/modules/programs/dev.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + ripgrep + fluxcd + k9s + kubectl + python3 + ]; +} diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index 83061d4..722d861 100755 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -1,44 +1,44 @@ { pkgs, ...}: { - xdg.configFile.nvim = { - source = ../../../config/nvim; - recursive = true; - }; - programs.neovim = { - enable = true; - defaultEditor = true; - vimAlias = true; - vimdiffAlias = true; - extraConfig = ":luafile ~/.config/nvim/lua/init.lua"; + xdg.configFile.nvim = { + source = ../../../config/nvim; + recursive = true; + }; + programs.neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + vimdiffAlias = true; + extraConfig = ":luafile ~/.config/nvim/lua/init.lua"; - plugins = with pkgs.vimPlugins; [ - vim-commentary - vim-surround - toggleterm-nvim - targets-vim - indent-blankline-nvim - vim-go - vim-nix - (nvim-treesitter.withPlugins - ( - plugins: with plugins; [ - tree-sitter-bash - tree-sitter-c - tree-sitter-dockerfile - tree-sitter-go - tree-sitter-javascript - tree-sitter-json - tree-sitter-lua - tree-sitter-nix - tree-sitter-php - tree-sitter-python - tree-sitter-yaml - ] - ) - ) - nvim-treesitter-textobjects - leap-nvim - telescope-nvim - ]; - }; -} + plugins = with pkgs.vimPlugins; [ + vim-commentary + vim-surround + toggleterm-nvim + targets-vim + indent-blankline-nvim + vim-go + vim-nix + (nvim-treesitter.withPlugins + ( + plugins: with plugins; [ + tree-sitter-bash + tree-sitter-c + tree-sitter-dockerfile + tree-sitter-go + tree-sitter-javascript + tree-sitter-json + tree-sitter-lua + tree-sitter-nix + tree-sitter-php + tree-sitter-python + tree-sitter-yaml + ] + ) + ) + nvim-treesitter-textobjects + leap-nvim + telescope-nvim + ]; + }; + } diff --git a/modules/programs/shell/default.nix b/modules/programs/shell/default.nix index ed470ff..fd67d21 100755 --- a/modules/programs/shell/default.nix +++ b/modules/programs/shell/default.nix @@ -1,4 +1,4 @@ -{ homeDirectory, pkgs, ...}: +{ pkgs, host, ...}: { imports = [ (import ./tmux.nix) @@ -19,9 +19,8 @@ ":q" = "exit"; mpv = "mpv --no-keepaspect-window"; sus = "systemctl suspend"; - gitu = "git add . && git commit && git push"; - rcp = "rsync -avh --progress"; - + hms = "home-manager switch --flake $NIX_FLAKE#${host.username}"; + rbs = "sudo nixos-rebuild switch --flake $NIX_FLAKE#${host.hostName}"; }; shellOptions = [ "cmdhist" @@ -39,6 +38,7 @@ export MANPAGER="nvim +Man!" export EDITOR="nvim" export _JAVA_AWT_WM_NONREPARENTING=1 + export NIX_FLAKE="/home/e/dev/nix" [[ $- != *i* ]] && return function exists { type $1 >/dev/null 2>&1 diff --git a/modules/wayland/default.nix b/modules/wayland/default.nix index e362d78..701bede 100644 --- a/modules/wayland/default.nix +++ b/modules/wayland/default.nix @@ -130,10 +130,6 @@ }; }; }; - extraConfig='' - bindswitch lid:on output eDP-1 disable - bindswitch lid:off output eDP-1 enable - ''; }; programs.i3status = { enable = true; @@ -202,11 +198,11 @@ events = [ { event = "lock"; command = "${pkgs.swaylock}/bin/swaylock";} { event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock";} - { event = "after-resume"; command = "${pkgs.sway}/bin/swaymsg \"output * power on\"";} + { event = "after-resume"; command = "${pkgs.sway}/bin/swaymsg \"output * toggle\"";} ]; timeouts = [ { timeout = 600; command = "${pkgs.swaylock}/bin/swaylock";} - { timeout = 1200; command = "${pkgs.sway}/bin/swaymsg \"output * power off\"";} + { timeout = 1200; command = "${pkgs.sway}/bin/swaymsg \"output * toggle\"";} ]; }; services.kanshi = { diff --git a/hosts/configuration.nix b/nixos/configuration.nix similarity index 58% rename from hosts/configuration.nix rename to nixos/configuration.nix index 22b4089..d9288d0 100755 --- a/hosts/configuration.nix +++ b/nixos/configuration.nix @@ -1,10 +1,13 @@ -{ config, pkgs, username, ... }: +{ packages, host, ... }: { boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + networking.networkmanager.enable = true; - time.timeZone = "America/Chicago"; - users.users.${username} = { + + users.groups.plugdev = {}; # Create plugdev group + + users.users.${host.username} = { isNormalUser = true; extraGroups = [ "wheel" @@ -12,8 +15,17 @@ "video" ]; }; - users.groups.plugdev = {}; security.pam.services.swaylock = {}; + time.timeZone = "America/Chicago"; + + # Enable flakes and unfree packages nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.gc = { + automatic = true; + dates = "00:00"; + options = "--delete-older-than 14d"; + }; + nixpkgs.config.allowUnfree = true; + system.stateVersion = "22.11"; } diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..3c426e7 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1,21 @@ +{ inputs, ... }: +let +in + { t14 = inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit inputs; + system = "x86_64-linux"; + host = { + hostName = "t14"; + username = "e"; + }; + }; + modules = [ + ./configuration.nix + ./t14/configuration.nix + inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1 + ]; + }; + + } + diff --git a/hosts/t14/configuration.nix b/nixos/t14/configuration.nix similarity index 66% rename from hosts/t14/configuration.nix rename to nixos/t14/configuration.nix index 88143fc..5c831c7 100755 --- a/hosts/t14/configuration.nix +++ b/nixos/t14/configuration.nix @@ -1,28 +1,24 @@ -{ config, pkgs, nixos-hardware, sops-nix, ... }: +{ pkgs, nixos-hardware, host, ... }: { imports = [ ./hardware-configuration.nix ./nano.nix ]; - networking.hostName = "t14"; + networking.hostName = host.hostName; environment.systemPackages = with pkgs; [ cryptsetup ]; - fonts = { - fonts = with pkgs; [ - spleen - roboto - ]; - }; + programs.light.enable = true; services.pipewire = { enable = true; alsa.enable = true; pulse.enable = true; }; - nixpkgs.config.allowUnfree = true; - boot.kernelPackages = pkgs.linuxPackages_latest; + hardware.opengl.enable = true; + + boot.kernelPackages = pkgs.linuxPackages_latest; system.stateVersion = "22.11"; } diff --git a/hosts/t14/hardware-configuration.nix b/nixos/t14/hardware-configuration.nix similarity index 100% rename from hosts/t14/hardware-configuration.nix rename to nixos/t14/hardware-configuration.nix diff --git a/hosts/t14/nano.nix b/nixos/t14/nano.nix similarity index 100% rename from hosts/t14/nano.nix rename to nixos/t14/nano.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..85ce71c --- /dev/null +++ b/shell.nix @@ -0,0 +1,15 @@ +# devshell for bootstrapping nixos and home-manager +# nix develop + +{ pkgs }: { + default = pkgs.mkShell { + NIX_CONFIG = "experimental-features = nix-command flakes"; + nativeBuildInputs = with pkgs; [ + nix + home-manager + git + vim + ]; + }; +} +