From 478916099ca1e0eb591332e95bf33e00606ed3e4 Mon Sep 17 00:00:00 2001 From: Sokhibjon Orzikulov Date: Sun, 15 Sep 2024 22:48:03 +0500 Subject: [PATCH] new structure --- flake.lock | 18 +-- flake.nix | 194 +++++++++++-------------------- home/muzaffar.nix | 36 ------ modules/nixos/users/default.nix | 1 - modules/nixos/users/muzaffar.nix | 30 ----- nixos/kolyma-3/configuration.nix | 1 - shell.nix | 24 ++-- 7 files changed, 91 insertions(+), 213 deletions(-) delete mode 100644 home/muzaffar.nix delete mode 100644 modules/nixos/users/muzaffar.nix diff --git a/flake.lock b/flake.lock index 42fd617..2a46fc3 100644 --- a/flake.lock +++ b/flake.lock @@ -42,11 +42,11 @@ ] }, "locked": { - "lastModified": 1719827439, - "narHash": "sha256-tneHOIv1lEavZ0vQ+rgz67LPNCgOZVByYki3OkSshFU=", + "lastModified": 1726357542, + "narHash": "sha256-p4OrJL2weh0TRtaeu1fmNYP6+TOp/W2qdaIJxxQay4c=", "owner": "nix-community", "repo": "home-manager", - "rev": "59ce796b2563e19821361abbe2067c3bb4143a7d", + "rev": "e524c57b1fa55d6ca9d8354c6ce1e538d2a1f47f", "type": "github" }, "original": { @@ -58,11 +58,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719707984, - "narHash": "sha256-RoxIr/fbndtuKqulGvNCcuzC6KdAib85Q8gXnjzA1dw=", + "lastModified": 1726320982, + "narHash": "sha256-RuVXUwcYwaUeks6h3OLrEmg14z9aFXdWppTWPMTwdQw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7dca15289a1c2990efbe4680f0923ce14139b042", + "rev": "8f7492cce28977fbf8bd12c72af08b1f6c7c3e49", "type": "github" }, "original": { @@ -74,11 +74,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1719690277, - "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", + "lastModified": 1726243404, + "narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e", + "rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 73fd861..5c62e94 100644 --- a/flake.nix +++ b/flake.nix @@ -25,13 +25,6 @@ # Flake utils for eachSystem flake-utils.url = "github:numtide/flake-utils"; - - # Astro Neovim - # Non-flake repository - astronvim = { - url = "github:AstroNvim/AstroNvim/v3.40.3"; - flake = false; - }; }; # In this context, outputs are mostly about getting home-manager what it @@ -45,128 +38,81 @@ , ... } @ inputs: let - inherit (self) outputs; - - # Legacy packages are needed for home-manager - lib = nixpkgs.lib // home-manager.lib; - - # Supported systems for your flake packages, shell, etc. - systems = [ - "aarch64-linux" - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - - # This is a function that generates an attribute by calling a function you - # pass to it, with each system as an argument - forAllSystems = nixpkgs.lib.genAttrs systems; - - # This is a function that generates an attribute by calling a function you - # pass to it, with each system as an argument - forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system}); - - # This is a function that generates an attribute by calling a function you - # pass to it, with each system as an argument - pkgsFor = lib.genAttrs systems (system: - import nixpkgs { - inherit system; - config.allowUnfree = true; - }); + # Self instance pointer + outputs = self; - # Define a development shell for each system - devShellFor = system: + afes = flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - config.allowUnfree = true; - }; + pkgs = nixpkgs.legacyPackages.${system}; in - pkgs.mkShell { - NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake"; - buildInputs = with pkgs; [ - nix - nil - git - nixd - just - nixpkgs-fmt - nixpkgs-lint - ]; + # Nixpkgs packages for the current system + { + # Your custom packages + # Acessible through 'nix build', 'nix shell', etc + packages = import ./pkgs { inherit pkgs; }; + + # Formatter for your nix files, available through 'nix fmt' + # Other options beside 'alejandra' include 'nixpkgs-fmt' + formatter = pkgs.nixpkgs-fmt; + + # Development shells + devShells.default = import ./shell.nix { inherit pkgs; }; + }); - # Set environment variables, if needed - shellHook = '' - # export SOME_VAR=some_value - echo "Welcome to Kolyma's dotfiles!" - ''; + afse = { + # Nixpkgs and Home-Manager helpful functions + lib = nixpkgs.lib // home-manager.lib; + + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays { inherit inputs; }; + + # Reusable nixos modules you might want to export + # These are usually stuff you would upstream into nixpkgs + nixosModules = import ./modules/nixos; + + # Reusable home-manager modules you might want to export + # These are usually stuff you would upstream into home-manager + homeManagerModules = import ./modules/home; + + # Reusable server modules you might want to export + # These are usually stuff you would upstream services to global + serverModules = import ./modules/server; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + "Kolyma-1" = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + # > Our main nixos configuration file < + ./nixos/kolyma-1/configuration.nix + ]; + }; + "Kolyma-2" = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + # > Our main nixos configuration file < + ./nixos/kolyma-2/configuration.nix + ]; + }; + "Kolyma-3" = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + # > Our main nixos configuration file < + ./nixos/kolyma-3/configuration.nix + ]; + }; + "Kolyma-4" = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ + # > Our main nixos configuration file < + ./nixos/kolyma-4/configuration.nix + ]; + }; }; - in - { - inherit lib; - # Your custom packages - # Acessible through 'nix build', 'nix shell', etc - packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); - - # Formatter for your nix files, available through 'nix fmt' - # Other options beside 'alejandra' include 'nixpkgs-fmt' - formatter = - forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt); - - # Your custom packages and modifications, exported as overlays - overlays = import ./overlays { inherit inputs; }; - - # Reusable nixos modules you might want to export - # These are usually stuff you would upstream into nixpkgs - nixosModules = import ./modules/nixos; - - # Reusable home-manager modules you might want to export - # These are usually stuff you would upstream into home-manager - homeManagerModules = import ./modules/home; - - # Reusable server modules you might want to export - # These are usually stuff you would upstream services to global - serverModules = import ./modules/server; - - # Reusable home-manager modules you might want to export - # These are usually stuff you would upstream into home-manager - # homeManagerModules = import ./modules/home; - - # NixOS configuration entrypoint - # Available through 'nixos-rebuild --flake .#your-hostname' - nixosConfigurations = { - "Kolyma-1" = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main nixos configuration file < - ./nixos/kolyma-1/configuration.nix - ]; - }; - "Kolyma-2" = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main nixos configuration file < - ./nixos/kolyma-2/configuration.nix - ]; - }; - "Kolyma-3" = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main nixos configuration file < - ./nixos/kolyma-3/configuration.nix - ]; - }; - "Kolyma-4" = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; - modules = [ - # > Our main nixos configuration file < - ./nixos/kolyma-4/configuration.nix - ]; - }; }; - - # Development shells - devShell = lib.mapAttrs (system: _: devShellFor system) (lib.genAttrs systems { }); - # devShells = lib.mapAttrs (system: _: devShellFor system) (lib.genAttrs systems {}); - }; + in + # Merging all final results + afse // afes; } diff --git a/home/muzaffar.nix b/home/muzaffar.nix deleted file mode 100644 index e0a9919..0000000 --- a/home/muzaffar.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ inputs -, lib -, pkgs -, config -, outputs -, packages -, self -, ... -}: { - imports = [ - outputs.homeManagerModules.zsh - outputs.homeManagerModules.helix - outputs.homeManagerModules.nixpkgs - outputs.homeManagerModules.packages - ]; - - # This is required information for home-manager to do its job - home = { - stateVersion = "24.05"; - username = "muzaffar"; - homeDirectory = "/home/muzaffar"; - - # Don't check if home manager is same as nixpkgs - enableNixpkgsReleaseCheck = false; - }; - - programs.neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - }; - - # Let's enable home-manager - programs.home-manager.enable = true; -} diff --git a/modules/nixos/users/default.nix b/modules/nixos/users/default.nix index f40c66f..d766fc2 100644 --- a/modules/nixos/users/default.nix +++ b/modules/nixos/users/default.nix @@ -4,6 +4,5 @@ sakhib = import ./sakhib.nix; sardor = import ./sardor.nix; shakhzod = import ./shakhzod.nix; - muzaffar = import ./muzaffar.nix; jakhongir = import ./jakhongir.nix; } diff --git a/modules/nixos/users/muzaffar.nix b/modules/nixos/users/muzaffar.nix deleted file mode 100644 index 1e2d580..0000000 --- a/modules/nixos/users/muzaffar.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ pkgs -, inputs -, outputs -, lib -, config -, packages -, ... -}: { - config = { - users.users = { - muzaffar = { - isNormalUser = true; - description = "Muzaffar Anasbekov"; - initialPassword = "2ReTpN1XG2VOR4aR"; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHDSH+E/7791S2x2QF3WsQU1nnr7WNLyK1BubDmOeib muzaffar.gaming7@gmail.com" - ]; - extraGroups = [ "networkmanager" "wheel" "docker" "admins" ]; - }; - }; - - home-manager = { - extraSpecialArgs = { inherit inputs outputs; }; - users = { - # Import your home-manager configuration - muzaffar = import ../../../home/muzaffar.nix; - }; - }; - }; -} diff --git a/nixos/kolyma-3/configuration.nix b/nixos/kolyma-3/configuration.nix index 469e370..588125f 100644 --- a/nixos/kolyma-3/configuration.nix +++ b/nixos/kolyma-3/configuration.nix @@ -21,7 +21,6 @@ outputs.nixosModules.users.sakhib outputs.nixosModules.users.sardor outputs.nixosModules.users.shakhzod - outputs.nixosModules.users.muzaffar outputs.nixosModules.users.jakhongir # Import your deployed service list diff --git a/shell.nix b/shell.nix index 2f4331f..c2cb4e3 100644 --- a/shell.nix +++ b/shell.nix @@ -7,16 +7,16 @@ in import nixpkgs { overlays = [ ]; } , ... -}: { - default = pkgs.mkShell { - NIX_CONFIG = "extra-experimental-features = nix-command flakes"; - nativeBuildInputs = with pkgs; [ - nix - nil - git - nixd - nixpkgs-fmt - nixpkgs-lint - ]; - }; +}: pkgs.stdenv.mkDerivation { + name = "instances"; + + nativeBuildInputs = with pkgs; [ + nix + nil + nixd + nixpkgs-fmt + git + ]; + + NIX_CONFIG = "extra-experimental-features = nix-command flakes"; }