From 38287035e71eca1a651e9cbbede77e195e5cf10c Mon Sep 17 00:00:00 2001 From: CherryKitten Date: Sun, 24 Mar 2024 19:02:28 +0100 Subject: [PATCH] shit i changed way too much at once --- flake.lock | 34 ++++++ flake.nix | 100 +++++++++--------- hosts/maine-coon/hardware-configuration.nix | 1 - misc/module-template.nix | 16 +-- modules/common.nix | 9 ++ modules/default.nix | 24 ----- modules/home/default.nix | 28 +++++ modules/home/fish/default.nix | 21 ++++ .../home/fish}/fish_prompt.fish | 0 .../home/fish}/fish_right_prompt.fish | 0 modules/{ => home}/nvim/default.nix | 2 +- modules/{ => home}/nvim/keymap.lua | 0 modules/{ => home}/nvim/options.lua | 0 modules/{ => home}/nvim/plugins/conform.lua | 0 modules/{ => home}/nvim/plugins/dashboard.lua | 0 modules/{ => home}/nvim/plugins/neo-tree.lua | 0 modules/{ => home}/nvim/plugins/noice.lua | 0 modules/security.nix | 2 +- modules/shell/fish.nix | 30 ------ modules/users.nix | 59 ----------- modules/users/default.nix | 24 +++++ modules/users/sammy.nix | 17 +++ 22 files changed, 195 insertions(+), 172 deletions(-) delete mode 100644 modules/default.nix create mode 100644 modules/home/default.nix create mode 100644 modules/home/fish/default.nix rename {files/config/fish/functions => modules/home/fish}/fish_prompt.fish (100%) rename {files/config/fish/functions => modules/home/fish}/fish_right_prompt.fish (100%) rename modules/{ => home}/nvim/default.nix (97%) rename modules/{ => home}/nvim/keymap.lua (100%) rename modules/{ => home}/nvim/options.lua (100%) rename modules/{ => home}/nvim/plugins/conform.lua (100%) rename modules/{ => home}/nvim/plugins/dashboard.lua (100%) rename modules/{ => home}/nvim/plugins/neo-tree.lua (100%) rename modules/{ => home}/nvim/plugins/noice.lua (100%) delete mode 100644 modules/shell/fish.nix delete mode 100644 modules/users.nix create mode 100644 modules/users/default.nix create mode 100644 modules/users/sammy.nix diff --git a/flake.lock b/flake.lock index 7e1aa01..b91d985 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -53,10 +71,26 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "home-manager": "home-manager", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index bb972dc..8a6a4be 100644 --- a/flake.nix +++ b/flake.nix @@ -2,62 +2,64 @@ inputs = { nixpkgs.url = "nixpkgs/nixos-23.11"; nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = - inputs @ { self - , nixpkgs - , nixpkgs-unstable - , home-manager - , ... - }: - let - mkHost = { hostname, user ? "sammy" }: { + outputs = inputs @ { + self, + nixpkgs, + nixpkgs-unstable, + home-manager, + ... + }: let + inherit (self) outputs; + lib = nixpkgs.lib // home-manager.lib; + mkHost = { + hostname, + user ? "sammy", + }: { + imports = [ + ./hosts/${hostname}/configuration.nix + ./modules/common.nix + (import "${home-manager}/nixos") + ]; - imports = [ - ./hosts/${hostname}/configuration.nix - ./modules - (import "${home-manager}/nixos") - ]; - - deployment = { - targetUser = user; - allowLocalDeployment = true; - }; - }; - in - { - formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; - colmena = { - meta = { - description = "All my NixoS machines"; - specialArgs = { - flake = self; - }; - nixpkgs = import nixpkgs { - system = "x86_64-linux"; - overlays = [ ]; - }; - }; - - bengal = mkHost { hostname = "bengal"; }; - - maine-coon = mkHost { hostname = "maine-coon"; }; - }; - nixosConfigurations.test = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { - flake = self; - }; - modules = [ - ./modules - ./hosts/test-vm/configuration.nix - (import "${home-manager}/nixos") - ]; + deployment = { + targetUser = user; + allowLocalDeployment = true; }; }; + in { + inherit lib; + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; + colmena = { + meta = { + description = "All my NixoS machines"; + specialArgs = {inherit inputs outputs;}; + nixpkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = []; + }; + }; + + bengal = mkHost {hostname = "bengal";}; + + maine-coon = mkHost {hostname = "maine-coon";}; + }; + nixosConfigurations.test = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + flake = self; + }; + modules = [ + ./modules + ./hosts/test-vm/configuration.nix + (import "${home-manager}/nixos") + ]; + }; + }; } diff --git a/hosts/maine-coon/hardware-configuration.nix b/hosts/maine-coon/hardware-configuration.nix index a880a00..fd899c3 100644 --- a/hosts/maine-coon/hardware-configuration.nix +++ b/hosts/maine-coon/hardware-configuration.nix @@ -7,7 +7,6 @@ pkgs, ... }: { - boot.initrd.availableKernelModules = ["ahci" "nvme"]; boot.initrd.kernelModules = []; boot.kernelModules = ["kvm-intel"]; diff --git a/misc/module-template.nix b/misc/module-template.nix index 614920a..ef28f49 100644 --- a/misc/module-template.nix +++ b/misc/module-template.nix @@ -1,10 +1,12 @@ -{ pkgs, config, lib, ... }: -let - cfg = config.cherrykitten; -in { + pkgs, + config, + lib, + ... +}: let + cfg = config.cherrykitten; +in { + options.cherrykitten = {}; - options.cherrykitten = { }; - - config = { }; + config = {}; } diff --git a/modules/common.nix b/modules/common.nix index 69db266..ebaf7f7 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -13,10 +13,19 @@ in { example = "nyanya"; }; }; + imports = [ + ./graphical.nix + ./security.nix + ./users + ./yubikey.nix + ]; config = { nix.settings.experimental-features = ["nix-command" "flakes"]; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "en_US.UTF-8"; diff --git a/modules/default.nix b/modules/default.nix deleted file mode 100644 index c5c05f4..0000000 --- a/modules/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, config, lib, ... }: -let - cfg = config.cherrykitten; -in -with lib; -{ - imports = [ - ./common.nix - ./graphical.nix - ./security.nix - ./users.nix - ./yubikey.nix - ./nvim - ./shell/fish.nix - - ]; - options.cherrykitten = { }; - - config = { - - cherrykitten.fish.enable = mkDefault true; - cherrykitten.graphical.enable = mkDefault false; - }; -} diff --git a/modules/home/default.nix b/modules/home/default.nix new file mode 100644 index 0000000..dab1483 --- /dev/null +++ b/modules/home/default.nix @@ -0,0 +1,28 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [./fish ./nvim]; + home.packages = with pkgs; [ + bat + lsd + gnupg + tmux + colmena + ]; + + programs = { + home-manager.enable = true; + + git = { + enable = true; + extraConfig = { + init = {defaultBranch = "main";}; + core = {editor = "nvim";}; + pull.rebase = true; + }; + }; + }; +} diff --git a/modules/home/fish/default.nix b/modules/home/fish/default.nix new file mode 100644 index 0000000..e99233b --- /dev/null +++ b/modules/home/fish/default.nix @@ -0,0 +1,21 @@ +{ + pkgs, + config, + lib, + ... +}: { + programs.fish = { + enable = true; + }; + + home.file = { + fish_prompt = { + source = ./fish_prompt.fish; + target = ".config/fish/functions/fish_prompt.fish"; + }; + fish_right_prompt = { + source = ./fish_right_prompt.fish; + target = ".config/fish/functions/fish_right_prompt.fish"; + }; + }; +} diff --git a/files/config/fish/functions/fish_prompt.fish b/modules/home/fish/fish_prompt.fish similarity index 100% rename from files/config/fish/functions/fish_prompt.fish rename to modules/home/fish/fish_prompt.fish diff --git a/files/config/fish/functions/fish_right_prompt.fish b/modules/home/fish/fish_right_prompt.fish similarity index 100% rename from files/config/fish/functions/fish_right_prompt.fish rename to modules/home/fish/fish_right_prompt.fish diff --git a/modules/nvim/default.nix b/modules/home/nvim/default.nix similarity index 97% rename from modules/nvim/default.nix rename to modules/home/nvim/default.nix index 1204082..d21b22c 100644 --- a/modules/nvim/default.nix +++ b/modules/home/nvim/default.nix @@ -4,7 +4,7 @@ inputs, ... }: { - home-manager.users.sammy.programs.neovim = let + programs.neovim = let toLua = str: "lua << EOF\n${str}\nEOF\n"; toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; in { diff --git a/modules/nvim/keymap.lua b/modules/home/nvim/keymap.lua similarity index 100% rename from modules/nvim/keymap.lua rename to modules/home/nvim/keymap.lua diff --git a/modules/nvim/options.lua b/modules/home/nvim/options.lua similarity index 100% rename from modules/nvim/options.lua rename to modules/home/nvim/options.lua diff --git a/modules/nvim/plugins/conform.lua b/modules/home/nvim/plugins/conform.lua similarity index 100% rename from modules/nvim/plugins/conform.lua rename to modules/home/nvim/plugins/conform.lua diff --git a/modules/nvim/plugins/dashboard.lua b/modules/home/nvim/plugins/dashboard.lua similarity index 100% rename from modules/nvim/plugins/dashboard.lua rename to modules/home/nvim/plugins/dashboard.lua diff --git a/modules/nvim/plugins/neo-tree.lua b/modules/home/nvim/plugins/neo-tree.lua similarity index 100% rename from modules/nvim/plugins/neo-tree.lua rename to modules/home/nvim/plugins/neo-tree.lua diff --git a/modules/nvim/plugins/noice.lua b/modules/home/nvim/plugins/noice.lua similarity index 100% rename from modules/nvim/plugins/noice.lua rename to modules/home/nvim/plugins/noice.lua diff --git a/modules/security.nix b/modules/security.nix index a3d7ff1..381de29 100644 --- a/modules/security.nix +++ b/modules/security.nix @@ -7,7 +7,7 @@ logLevel = "VERBOSE"; extraConfig = '' StreamLocalBindUnlink yes - ''; + ''; settings = { PermitRootLogin = "no"; PasswordAuthentication = false; diff --git a/modules/shell/fish.nix b/modules/shell/fish.nix deleted file mode 100644 index 35fa086..0000000 --- a/modules/shell/fish.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ pkgs, config, lib, flake, ... }: -let - cfg = config.cherrykitten.fish; -in -with lib; -{ - - options.cherrykitten.fish.enable = mkEnableOption "Fish-Shell"; - - config = mkIf cfg.enable { - home-manager.users.sammy = { - - programs.fish = { - enable = true; - }; - - home.file = { - fish_prompt = { - source = flake + files/config/fish/functions/fish_prompt.fish; - target = ".config/fish/functions/fish_prompt.fish"; - }; - fish_right_prompt = { - source = flake + files/config/fish/functions/fish_right_prompt.fish; - target = ".config/fish/functions/fish_right_prompt.fish"; - }; - }; - - }; - }; -} diff --git a/modules/users.nix b/modules/users.nix deleted file mode 100644 index cce17a4..0000000 --- a/modules/users.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ lib -, pkgs -, config -, ... -}: -let - cfg = config.cherrykitten; -in -{ - - options.cherrykitten.users = { }; - - config = { - users.users = { - sammy = { - isNormalUser = true; - extraGroups = [ "networkmanager" "wheel" "docker" ]; - shell = pkgs.fish; - ignoreShellProgramCheck = true; - openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZyQSZw+pExsx2RXB+yxbaJGB9mtvudbQ/BP7E1yKvr openpgp:0x6068FEBB" ]; - }; - }; - - home-manager.users.sammy = { - home.username = "sammy"; - home.homeDirectory = "/home/sammy"; - home.stateVersion = "23.11"; # Please read the comment before changing. - home.packages = with pkgs; [ - bat - lsd - gnupg - tmux - colmena - ]; - - programs = { - home-manager.enable = true; - - git = { - enable = true; - userName = "CherryKitten"; - userEmail = "git@cherrykitten.dev"; - signing.key = "0xC01A7CBBA617BD5F"; - signing.signByDefault = true; - extraConfig = { - init = { defaultBranch = "main"; }; - core = { editor = "nvim"; }; - pull.rebase = true; - }; - }; - - }; - - home.sessionVariables = { - EDITOR = "nvim"; - }; - }; - }; -} diff --git a/modules/users/default.nix b/modules/users/default.nix new file mode 100644 index 0000000..04aa4bc --- /dev/null +++ b/modules/users/default.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: let + cfg = config.cherrykitten.users; +in { + options.cherrykitten.users = { + sammy.enable = lib.mkEnableOption "sammy" // {default = true;}; + }; + + config = { + users.users.sammy = lib.mkIf cfg.sammy.enable { + isNormalUser = true; + extraGroups = ["networkmanager" "wheel" "docker"]; + shell = pkgs.fish; + ignoreShellProgramCheck = true; + openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZyQSZw+pExsx2RXB+yxbaJGB9mtvudbQ/BP7E1yKvr openpgp:0x6068FEBB"]; + }; + + home-manager.users.sammy = lib.mkIf cfg.sammy.enable (import ./sammy.nix); + }; +} diff --git a/modules/users/sammy.nix b/modules/users/sammy.nix new file mode 100644 index 0000000..97f5844 --- /dev/null +++ b/modules/users/sammy.nix @@ -0,0 +1,17 @@ +{...}: { + imports = [../home]; + + programs.git = { + userName = "CherryKitten"; + userEmail = "git@cherrykitten.dev"; + signing.key = "0xC01A7CBBA617BD5F"; + signing.signByDefault = true; + }; + home.username = "sammy"; + home.homeDirectory = "/home/sammy"; + home.stateVersion = "23.11"; # Please read the comment before changing. + + home.sessionVariables = { + EDITOR = "nvim"; + }; +}